[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

abarth at webkit.org abarth at webkit.org
Wed Dec 22 11:54:52 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit e8642e369199c070e0d3bd2fda7c9ddaec850a01
Author: abarth at webkit.org <abarth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Aug 11 07:51:08 2010 +0000

    2010-08-10  Eric Seidel  <eric at webkit.org>
    
            Reviewed by Adam Barth.
    
            Fix three ASSERTs hit with the HTML5 TreeBuilder in fragment mode
            https://bugs.webkit.org/show_bug.cgi?id=43762
    
            In fixing the insertAdjacentHTML I had to make small changes to
            the error logic, which ended up bringing us closer to HTML5.
    
            Test: fast/dom/HTMLElement/insertAdjacentHTML-errors.html
    
            * html/HTMLConstructionSite.cpp:
            (WebCore::HTMLConstructionSite::attach):
             - This ASSERT was just wrong, the child should not be attached
               in the case the parent is not attached.
            * html/HTMLElement.cpp:
            (WebCore::contextElementForInsertion):
             - This is part of HTML5, needed to know what to call the
               HTML or XML parsers with.  The previous code always passed
               "this" which is wrong in the case of beforeBegin or afterEnd insertion.
            (WebCore::HTMLElement::insertAdjacentHTML):
             - Use the right contextElement now that we know how to compute it.
            * html/HTMLTreeBuilder.cpp:
            (WebCore::HTMLTreeBuilder::processEndTagForInCell):
             - This ASSERT is direct from the spec, but it's wrong, so I've filed a spec bug.
    2010-08-10  Eric Seidel  <eric at webkit.org>
    
            Reviewed by Adam Barth.
    
            Fix three ASSERTs hit with the HTML5 TreeBuilder in fragment mode
            https://bugs.webkit.org/show_bug.cgi?id=43762
    
            In order to fix the insertAdjacentHTML I had to some behavior.
            The behavior I changed brings us closer to the HTML5 spec,
            but since it was not previously tested, I added tests.
    
            * fast/dom/HTMLElement/insertAdjacentHTML-errors-expected.txt: Added.
            * fast/dom/HTMLElement/insertAdjacentHTML-errors.html: Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65134 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 99212ee..d0232d1 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,17 @@
+2010-08-10  Eric Seidel  <eric at webkit.org>
+
+        Reviewed by Adam Barth.
+
+        Fix three ASSERTs hit with the HTML5 TreeBuilder in fragment mode
+        https://bugs.webkit.org/show_bug.cgi?id=43762
+
+        In order to fix the insertAdjacentHTML I had to some behavior.
+        The behavior I changed brings us closer to the HTML5 spec,
+        but since it was not previously tested, I added tests.
+
+        * fast/dom/HTMLElement/insertAdjacentHTML-errors-expected.txt: Added.
+        * fast/dom/HTMLElement/insertAdjacentHTML-errors.html: Added.
+
 2010-08-11  Yoshiki Hayashi  <yhayashi at google.com>
 
         Reviewed by Shinichiro Hamaji.
@@ -212,6 +226,10 @@
 
         * fast/dom/HTMLElement/insertAdjacentHTML-errors-expected.txt: Added.
         * fast/dom/HTMLElement/insertAdjacentHTML-errors.html: Added.
+        * fast/dom/HTMLElement/script-tests/TEMPLATE.html: Added.
+        * fast/dom/HTMLElement/script-tests/insertAdjacentHTML-errors.js: Added.
+        * fast/dynamic/insertAdjacentHTML-expected.txt:
+         - Updated to match HTML5's expected exception on error.
 
 2010-08-10  MORITA Hajime  <morrita at google.com>
 
diff --git a/LayoutTests/fast/dom/HTMLElement/insertAdjacentHTML-errors-expected.txt b/LayoutTests/fast/dom/HTMLElement/insertAdjacentHTML-errors-expected.txt
new file mode 100644
index 0000000..c788b47
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLElement/insertAdjacentHTML-errors-expected.txt
@@ -0,0 +1,13 @@
+Test insertAdjacentHTML exceptions to make sure they match HTML5
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS div.insertAdjacentHTML('beforeBegin', 'text') is undefined.
+PASS div.insertAdjacentHTML('afterEnd', 'text') is undefined.
+PASS div.insertAdjacentHTML('FOO', 'text') threw exception Error: SYNTAX_ERR: DOM Exception 12.
+PASS document.documentElement.insertAdjacentHTML('afterEnd', 'text') threw exception Error: NO_MODIFICATION_ALLOWED_ERR: DOM Exception 7.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/HTMLElement/insertAdjacentHTML-errors.html b/LayoutTests/fast/dom/HTMLElement/insertAdjacentHTML-errors.html
new file mode 100644
index 0000000..6176575
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLElement/insertAdjacentHTML-errors.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../js/resources/js-test-style.css">
+<script src="../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/insertAdjacentHTML-errors.js"></script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/backgrounds/repeat/script-tests/TEMPLATE.html b/LayoutTests/fast/dom/HTMLElement/script-tests/TEMPLATE.html
similarity index 100%
copy from LayoutTests/fast/backgrounds/repeat/script-tests/TEMPLATE.html
copy to LayoutTests/fast/dom/HTMLElement/script-tests/TEMPLATE.html
diff --git a/LayoutTests/fast/dom/HTMLElement/script-tests/insertAdjacentHTML-errors.js b/LayoutTests/fast/dom/HTMLElement/script-tests/insertAdjacentHTML-errors.js
new file mode 100644
index 0000000..9aeaebc
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLElement/script-tests/insertAdjacentHTML-errors.js
@@ -0,0 +1,11 @@
+description('Test insertAdjacentHTML exceptions to make sure they match HTML5');
+
+var div = document.createElement("div");
+
+shouldBeUndefined("div.insertAdjacentHTML('beforeBegin', 'text')");
+shouldBeUndefined("div.insertAdjacentHTML('afterEnd', 'text')");
+
+shouldThrow("div.insertAdjacentHTML('FOO', 'text')", '"Error: SYNTAX_ERR: DOM Exception 12"');
+shouldThrow("document.documentElement.insertAdjacentHTML('afterEnd', 'text')", '"Error: NO_MODIFICATION_ALLOWED_ERR: DOM Exception 7"');
+
+var successfullyParsed = true;
diff --git a/LayoutTests/fast/dynamic/insertAdjacentHTML-expected.txt b/LayoutTests/fast/dynamic/insertAdjacentHTML-expected.txt
index b9092e3..a5d1e4b 100644
--- a/LayoutTests/fast/dynamic/insertAdjacentHTML-expected.txt
+++ b/LayoutTests/fast/dynamic/insertAdjacentHTML-expected.txt
@@ -1,4 +1,4 @@
-Caught expected exception: Error: NOT_SUPPORTED_ERR: DOM Exception 9
+Caught expected exception: Error: SYNTAX_ERR: DOM Exception 12
 1 (black) 2 (green) 3 (green) 4 (black) 
 
 PASS
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 04e2855..0585b5e 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,30 @@
+2010-08-10  Eric Seidel  <eric at webkit.org>
+
+        Reviewed by Adam Barth.
+
+        Fix three ASSERTs hit with the HTML5 TreeBuilder in fragment mode
+        https://bugs.webkit.org/show_bug.cgi?id=43762
+
+        In fixing the insertAdjacentHTML I had to make small changes to
+        the error logic, which ended up bringing us closer to HTML5.
+
+        Test: fast/dom/HTMLElement/insertAdjacentHTML-errors.html
+
+        * html/HTMLConstructionSite.cpp:
+        (WebCore::HTMLConstructionSite::attach):
+         - This ASSERT was just wrong, the child should not be attached
+           in the case the parent is not attached.
+        * html/HTMLElement.cpp:
+        (WebCore::contextElementForInsertion):
+         - This is part of HTML5, needed to know what to call the
+           HTML or XML parsers with.  The previous code always passed
+           "this" which is wrong in the case of beforeBegin or afterEnd insertion.
+        (WebCore::HTMLElement::insertAdjacentHTML):
+         - Use the right contextElement now that we know how to compute it.
+        * html/HTMLTreeBuilder.cpp:
+        (WebCore::HTMLTreeBuilder::processEndTagForInCell):
+         - This ASSERT is direct from the spec, but it's wrong, so I've filed a spec bug.
+
 2010-08-11  Adam Barth  <abarth at webkit.org>
 
         Attempt to fix Windows build.
diff --git a/WebCore/html/HTMLConstructionSite.cpp b/WebCore/html/HTMLConstructionSite.cpp
index 1a9a373..9f502e3 100644
--- a/WebCore/html/HTMLConstructionSite.cpp
+++ b/WebCore/html/HTMLConstructionSite.cpp
@@ -93,7 +93,7 @@ PassRefPtr<ChildType> HTMLConstructionSite::attach(Node* parent, PassRefPtr<Chil
     // doesn't.  It feels like we're missing a concept somehow.
     if (shouldFosterParent()) {
         fosterParent(child.get());
-        ASSERT(child->attached());
+        ASSERT(child->attached() || !child->parent()->attached());
         return child.release();
     }
 
diff --git a/WebCore/html/HTMLElement.cpp b/WebCore/html/HTMLElement.cpp
index 6fc53a2..3c3353c 100644
--- a/WebCore/html/HTMLElement.cpp
+++ b/WebCore/html/HTMLElement.cpp
@@ -549,13 +549,35 @@ Element* HTMLElement::insertAdjacentElement(const String& where, Element* newChi
     return static_cast<Element*>(returnValue); 
 }
 
+// Step 3 of http://www.whatwg.org/specs/web-apps/current-work/multipage/apis-in-html-documents.html#insertadjacenthtml()
+static Element* contextElementForInsertion(const String& where, Element* element, ExceptionCode& ec)
+{
+    if (equalIgnoringCase(where, "beforeBegin") || equalIgnoringCase(where, "afterEnd")) {
+        Node* parent = element->parentNode();
+        if (parent && parent->isDocumentNode()) {
+            ec = NO_MODIFICATION_ALLOWED_ERR;
+            return 0;
+        }
+        ASSERT(!parent || parent->isElementNode());
+        return static_cast<Element*>(parent);
+    }
+    if (equalIgnoringCase(where, "afterBegin") || equalIgnoringCase(where, "beforeEnd"))
+        return element;
+    ec =  SYNTAX_ERR;
+    return 0;
+}
+
 void HTMLElement::insertAdjacentHTML(const String& where, const String& markup, ExceptionCode& ec)
 {
     RefPtr<DocumentFragment> fragment = document()->createDocumentFragment();
+    Element* contextElement = contextElementForInsertion(where, this, ec);
+    if (!contextElement)
+        return;
+
     if (document()->isHTMLDocument())
-         fragment->parseHTML(markup, this);
+         fragment->parseHTML(markup, contextElement);
     else {
-        if (!fragment->parseXML(markup, this))
+        if (!fragment->parseXML(markup, contextElement))
             // FIXME: We should propagate a syntax error exception out here.
             return;
     }
diff --git a/WebCore/html/HTMLTreeBuilder.cpp b/WebCore/html/HTMLTreeBuilder.cpp
index 2c7d40d..fc0b9d0 100644
--- a/WebCore/html/HTMLTreeBuilder.cpp
+++ b/WebCore/html/HTMLTreeBuilder.cpp
@@ -1997,7 +1997,9 @@ void HTMLTreeBuilder::processEndTagForInCell(AtomicHTMLToken& token)
         m_tree.openElements()->popUntilPopped(token.name());
         m_tree.activeFormattingElements()->clearToLastMarker();
         setInsertionMode(InRowMode);
-        ASSERT(m_tree.currentElement()->hasTagName(trTag));
+        // FIXME: The fragment case of this ASSERT is a spec bug:
+        // http://www.w3.org/Bugs/Public/show_bug.cgi?id=10338
+        ASSERT(m_tree.currentElement()->hasTagName(trTag) || (isParsingFragment() && m_fragmentContext.contextElement()->hasTagName(trTag)));
         return;
     }
     if (token.name() == bodyTag

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list