2010-08-11 Adam Barth <abarth@webkit.org>
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Aug 2010 02:55:27 +0000 (02:55 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Aug 2010 02:55:27 +0000 (02:55 +0000)
        Reviewed by Eric Seidel.

        Conditionalize wrong fragment parsing code to pass more HTML5lib tests
        https://bugs.webkit.org/show_bug.cgi?id=43877

        Test progression.

        * html5lib/runner-expected-html5.txt:
2010-08-11  Adam Barth  <abarth@webkit.org>

        Reviewed by Eric Seidel.

        Conditionalize wrong fragment parsing code to pass more HTML5lib tests
        https://bugs.webkit.org/show_bug.cgi?id=43877

        This code exists to support the LegacyHTMLTreeBuilder.  Unfortunately,
        it causes problems for the new HTMLTreeBuilder (which is more
        self-contained).

        * dom/Element.cpp:
        (WebCore::Element::createContextualFragment):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@65212 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/html5lib/runner-expected-html5.txt
WebCore/ChangeLog
WebCore/dom/Element.cpp

index 2256ba4..3470108 100644 (file)
@@ -1,5 +1,16 @@
 2010-08-11  Adam Barth  <abarth@webkit.org>
 
+        Reviewed by Eric Seidel.
+
+        Conditionalize wrong fragment parsing code to pass more HTML5lib tests
+        https://bugs.webkit.org/show_bug.cgi?id=43877
+
+        Test progression.
+
+        * html5lib/runner-expected-html5.txt:
+
+2010-08-11  Adam Barth  <abarth@webkit.org>
+
         Reviewed by Alexey Proskuryakov.
 
         fast/encoding/japanese-encoding-mix.html fails on Tiger after enabling HTML5 Lexer
index 5ca2329..fdbd8da 100644 (file)
@@ -17,18 +17,8 @@ resources/tests2.dat: PASS
 resources/tests3.dat: PASS
 
 resources/tests4.dat:
-6
 7
 
-Test 6 of 7 in resources/tests4.dat failed. Input:
-setting html's innerHTML
-Got:
-| "setting html's innerHTML"
-Expected:
-| <head>
-| <body>
-|   "setting html's innerHTML"
-
 Test 7 of 7 in resources/tests4.dat failed. Input:
 <title>setting head's innerHTML</title>
 Got:
@@ -41,7 +31,6 @@ resources/tests5.dat: PASS
 resources/tests6.dat:
 27
 30
-45
 
 Test 27 of 51 in resources/tests6.dat failed. Input:
 foo<col>
@@ -56,27 +45,9 @@ Got:
 | 
 Expected:
 | <frame>
-
-Test 45 of 51 in resources/tests6.dat failed. Input:
-<body></body></html>
-Got:
-| 
-Expected:
-| <head>
-| <body>
 resources/tests7.dat:
-24
 30
 
-Test 24 of 30 in resources/tests7.dat failed. Input:
-<body>X</body></body>
-Got:
-| "X"
-Expected:
-| <head>
-| <body>
-|   "X"
-
 Test 30 of 30 in resources/tests7.dat failed. Input:
 <select><keygen>
 Got:
index 53d3ec0..6bc79a5 100644 (file)
@@ -1,3 +1,17 @@
+2010-08-11  Adam Barth  <abarth@webkit.org>
+
+        Reviewed by Eric Seidel.
+
+        Conditionalize wrong fragment parsing code to pass more HTML5lib tests
+        https://bugs.webkit.org/show_bug.cgi?id=43877
+
+        This code exists to support the LegacyHTMLTreeBuilder.  Unfortunately,
+        it causes problems for the new HTMLTreeBuilder (which is more
+        self-contained).
+
+        * dom/Element.cpp:
+        (WebCore::Element::createContextualFragment):
+
 2010-08-11  Ryosuke Niwa  <rniwa@webkit.org>
 
         Reviewed by Tony Chang.
index 0e89e93..cc3bf1f 100644 (file)
@@ -50,6 +50,7 @@
 #include "RenderLayer.h"
 #include "RenderView.h"
 #include "RenderWidget.h"
+#include "Settings.h"
 #include "TextIterator.h"
 #include "XMLNames.h"
 #include <wtf/text/CString.h>
@@ -102,36 +103,37 @@ PassRefPtr<DocumentFragment> Element::createContextualFragment(const String& mar
             return 0;
     }
     
-    // Exceptions are ignored because none ought to happen here.
-    ExceptionCode ignoredExceptionCode;
-    
-    // We need to pop <html> and <body> elements and remove <head> to
-    // accommodate folks passing complete HTML documents to make the
-    // child of an element.
-    
-    RefPtr<Node> nextNode;
-    for (RefPtr<Node> node = fragment->firstChild(); node; node = nextNode) {
-        nextNode = node->nextSibling();
-        if (node->hasTagName(htmlTag) || node->hasTagName(bodyTag)) {
-            Node* firstChild = node->firstChild();
-            if (firstChild)
-                nextNode = firstChild;
-            RefPtr<Node> nextChild;
-            for (RefPtr<Node> child = firstChild; child; child = nextChild) {
-                nextChild = child->nextSibling();
-                node->removeChild(child.get(), ignoredExceptionCode);
+    if (!document()->settings() || !document()->settings()->html5TreeBuilderEnabled()) {
+        // Exceptions are ignored because none ought to happen here.
+        ExceptionCode ignoredExceptionCode;
+        
+        // We need to pop <html> and <body> elements and remove <head> to
+        // accommodate folks passing complete HTML documents to make the
+        // child of an element.
+        
+        RefPtr<Node> nextNode;
+        for (RefPtr<Node> node = fragment->firstChild(); node; node = nextNode) {
+            nextNode = node->nextSibling();
+            if (node->hasTagName(htmlTag) || node->hasTagName(bodyTag)) {
+                Node* firstChild = node->firstChild();
+                if (firstChild)
+                    nextNode = firstChild;
+                RefPtr<Node> nextChild;
+                for (RefPtr<Node> child = firstChild; child; child = nextChild) {
+                    nextChild = child->nextSibling();
+                    node->removeChild(child.get(), ignoredExceptionCode);
+                    ASSERT(!ignoredExceptionCode);
+                    fragment->insertBefore(child, node.get(), ignoredExceptionCode);
+                    ASSERT(!ignoredExceptionCode);
+                }
+                fragment->removeChild(node.get(), ignoredExceptionCode);
                 ASSERT(!ignoredExceptionCode);
-                fragment->insertBefore(child, node.get(), ignoredExceptionCode);
+            } else if (node->hasTagName(headTag)) {
+                fragment->removeChild(node.get(), ignoredExceptionCode);
                 ASSERT(!ignoredExceptionCode);
             }
-            fragment->removeChild(node.get(), ignoredExceptionCode);
-            ASSERT(!ignoredExceptionCode);
-        } else if (node->hasTagName(headTag)) {
-            fragment->removeChild(node.get(), ignoredExceptionCode);
-            ASSERT(!ignoredExceptionCode);
         }
     }
-    
     return fragment.release();
 }