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

eric at webkit.org eric at webkit.org
Wed Dec 22 11:52:24 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit d0d18b9b49a7148244075997cd9cf87adc680149
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Aug 10 07:29:32 2010 +0000

    2010-08-09  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 change 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-09  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.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65056 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index cce8d2d..08fb27b 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,17 @@
+2010-08-09  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 change 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-10  MORITA Hajime  <morrita at google.com>
 
         Unreviewed test fix.
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/WebCore/ChangeLog b/WebCore/ChangeLog
index 9e9b6d3..4df9639 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,30 @@
+2010-08-09  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-09  Yury Semikhatsky  <yurys at chromium.org>
 
         Reviewed by Pavel Feldman.
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