2010-07-02 Adam Barth <abarth@webkit.org>
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Jul 2010 08:29:43 +0000 (08:29 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Jul 2010 08:29:43 +0000 (08:29 +0000)
        Reviewed by Eric Seidel.

        Implement AfterBodyMode for HTML5 tree builder
        https://bugs.webkit.org/show_bug.cgi?id=41500

        Update expected results to show test progression.  Also, add some test
        cases to cover how attributes on </br> tags are handled.

        * html5lib/resources/webkit01.dat:
        * html5lib/runner-expected-html5.txt:
        * html5lib/runner-expected.txt:
        * html5lib/webkit-resumer-expected.txt:
2010-07-02  Adam Barth  <abarth@webkit.org>

        Reviewed by Eric Seidel.

        Implement AfterBodyMode for HTML5 tree builder
        https://bugs.webkit.org/show_bug.cgi?id=41500

        In the coarse of implementing this state, I ran into an ASSERT in how
        </br> tags where handled, which I fixed.  Technically, that could be a
        separate patch, but it seemed harmless to include it here (with tests).

        * html/HTMLTreeBuilder.cpp:
        (WebCore::HTMLTreeBuilder::processStartTag):
        (WebCore::HTMLTreeBuilder::processEndTag):
        (WebCore::HTMLTreeBuilder::processComment):
        (WebCore::HTMLTreeBuilder::processCharacter):
        (WebCore::HTMLTreeBuilder::processEndOfFile):
        (WebCore::HTMLTreeBuilder::insertCommentOnHTMLHtmlElement):
        * html/HTMLTreeBuilder.h:

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

LayoutTests/ChangeLog
LayoutTests/html5lib/resources/webkit01.dat
LayoutTests/html5lib/runner-expected-html5.txt
LayoutTests/html5lib/runner-expected.txt
LayoutTests/html5lib/webkit-resumer-expected.txt
WebCore/ChangeLog
WebCore/html/HTMLTreeBuilder.cpp
WebCore/html/HTMLTreeBuilder.h

index c2f465a..abe2a95 100644 (file)
@@ -2,6 +2,21 @@
 
         Reviewed by Eric Seidel.
 
+        Implement AfterBodyMode for HTML5 tree builder
+        https://bugs.webkit.org/show_bug.cgi?id=41500
+
+        Update expected results to show test progression.  Also, add some test
+        cases to cover how attributes on </br> tags are handled.
+
+        * html5lib/resources/webkit01.dat:
+        * html5lib/runner-expected-html5.txt:
+        * html5lib/runner-expected.txt:
+        * html5lib/webkit-resumer-expected.txt:
+
+2010-07-02  Adam Barth  <abarth@webkit.org>
+
+        Reviewed by Eric Seidel.
+
         Handle <base> and friends in AfterHeadMode
         https://bugs.webkit.org/show_bug.cgi?id=41502
 
index b7a6a10..64ae498 100644 (file)
@@ -228,3 +228,43 @@ console.log("FOO<span>BAR</span>BAZ");
 |   <body>
 |     foo="bar"
 |     yo="mama"
+
+#data
+<body></br foo="bar"></body>
+#errors
+#document
+| <html>
+|   <head>
+|   <body>
+|     <br>
+
+#data
+<bdy><br foo="bar"></body>
+#errors
+#document
+| <html>
+|   <head>
+|   <body>
+|     <bdy>
+|       <br>
+|         foo="bar"
+
+#data
+<body></body></br foo="bar">
+#errors
+#document
+| <html>
+|   <head>
+|   <body>
+|     <br>
+
+#data
+<bdy></body><br foo="bar">
+#errors
+#document
+| <html>
+|   <head>
+|   <body>
+|     <bdy>
+|       <br>
+|         foo="bar"
index 0f85a57..fb2e4eb 100644 (file)
@@ -46,7 +46,6 @@ resources/tests1.dat:
 86
 89
 90
-92
 93
 94
 95
@@ -367,7 +366,7 @@ Got:
 |           <li>
 |             "do"
 |         "you"
-|         <!-- do -->
+|   <!-- do -->
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -1156,19 +1155,6 @@ Expected:
 |     <div>
 |       <a>
 
-Test 92 of 113 in resources/tests1.dat failed. Input:
-<head></html><meta><p>
-Got:
-| <html>
-|   <head>
-|   <body>
-Expected:
-| <html>
-|   <head>
-|   <body>
-|     <meta>
-|     <p>
-
 Test 93 of 113 in resources/tests1.dat failed. Input:
 <b><table><td><i></table>
 Got:
@@ -1506,6 +1492,7 @@ Got:
 | <html>
 |   <head>
 |   <body>
+|     <br>
 Expected:
 | <html>
 |   <head>
@@ -1551,10 +1538,8 @@ resources/tests2.dat:
 47
 48
 49
-51
 53
 54
-55
 58
 
 Test 3 of 59 in resources/tests2.dat failed. Input:
@@ -1741,6 +1726,8 @@ Got:
 |   <head>
 |   <body>
 |     "X"
+|     "X"
+|     "X"
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -1935,22 +1922,6 @@ Expected:
 |     "  "
 |   <body>
 
-Test 51 of 59 in resources/tests2.dat failed. Input:
-<!DOCTYPE html>X</body><html id="x">
-Got:
-| <!DOCTYPE html>
-| <html>
-|   <head>
-|   <body>
-|     "X"
-Expected:
-| <!DOCTYPE html>
-| <html>
-|   id="x"
-|   <head>
-|   <body>
-|     "X"
-
 Test 53 of 59 in resources/tests2.dat failed. Input:
 <!DOCTYPE html>X</html>X
 Got:
@@ -1959,6 +1930,8 @@ Got:
 |   <head>
 |   <body>
 |     "X"
+|     "X"
+|     "X"
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -1974,6 +1947,8 @@ Got:
 |   <head>
 |   <body>
 |     "X"
+|     " "
+|     " "
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -1981,23 +1956,6 @@ Expected:
 |   <body>
 |     "X "
 
-Test 55 of 59 in resources/tests2.dat failed. Input:
-<!DOCTYPE html>X</html><p>X
-Got:
-| <!DOCTYPE html>
-| <html>
-|   <head>
-|   <body>
-|     "X"
-Expected:
-| <!DOCTYPE html>
-| <html>
-|   <head>
-|   <body>
-|     "X"
-|     <p>
-|       "X"
-
 Test 58 of 59 in resources/tests2.dat failed. Input:
 <!DOCTYPE html><table><tr><td></p></table>
 Got:
@@ -3802,6 +3760,13 @@ Got:
 | <html>
 |   <head>
 |   <body>
+|     <math>
+|       <mi>
+|         "foo"
+|       <mi>
+|         "bar"
+|       <p>
+|         "baz"
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -4290,6 +4255,13 @@ Got:
 | <html>
 |   <head>
 |   <body>
+|     <svg>
+|       <g>
+|         "foo"
+|       <g>
+|         "bar"
+|       <p>
+|         "baz"
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -5439,9 +5411,7 @@ resources/tests14.dat: PASS
 resources/tests15.dat:
 1
 2
-4
 5
-6
 7
 8
 9
@@ -5515,20 +5485,6 @@ Expected:
 |           <p>
 |             "X"
 
-Test 4 of 14 in resources/tests15.dat failed. Input:
-<!doctype html></body><meta>
-Got:
-| <!DOCTYPE html>
-| <html>
-|   <head>
-|   <body>
-Expected:
-| <!DOCTYPE html>
-| <html>
-|   <head>
-|   <body>
-|     <meta>
-
 Test 5 of 14 in resources/tests15.dat failed. Input:
 <html></html><!-- foo -->
 Got:
@@ -5542,21 +5498,6 @@ Expected:
 |   <body>
 | <!--  foo  -->
 
-Test 6 of 14 in resources/tests15.dat failed. Input:
-<!doctype html></body><title>X</title>
-Got:
-| <!DOCTYPE html>
-| <html>
-|   <head>
-|   <body>
-Expected:
-| <!DOCTYPE html>
-| <html>
-|   <head>
-|   <body>
-|     <title>
-|       "X"
-
 Test 7 of 14 in resources/tests15.dat failed. Input:
 <!doctype html><table> X<meta></table>
 Got:
@@ -5750,7 +5691,7 @@ Expected:
 resources/webkit01.dat:
 17
 
-Test 17 of 19 in resources/webkit01.dat failed. Input:
+Test 17 of 23 in resources/webkit01.dat failed. Input:
 <A>test< /A>
 Got:
 | <html>
index 43bffe5..484d339 100644 (file)
@@ -4687,8 +4687,10 @@ Expected:
 |     "-->"
 resources/webkit01.dat:
 17
+20
+22
 
-Test 17 of 19 in resources/webkit01.dat failed. Input:
+Test 17 of 23 in resources/webkit01.dat failed. Input:
 <A>test< /A>
 Got:
 | <html>
@@ -4703,6 +4705,34 @@ Expected:
 |   <body>
 |     <a>
 |       "test< /A>"
+
+Test 20 of 23 in resources/webkit01.dat failed. Input:
+<body></br foo="bar"></body>
+Got:
+| <html>
+|   <head>
+|   <body>
+|     <br>
+|       foo="bar"
+Expected:
+| <html>
+|   <head>
+|   <body>
+|     <br>
+
+Test 22 of 23 in resources/webkit01.dat failed. Input:
+<body></body></br foo="bar">
+Got:
+| <html>
+|   <head>
+|   <body>
+|     <br>
+|       foo="bar"
+Expected:
+| <html>
+|   <head>
+|   <body>
+|     <br>
 resources/doctype01.dat: PASS
 
 resources/scriptdata01.dat: PASS
index 8bdb433..0d61b63 100644 (file)
@@ -168,3 +168,57 @@ resources/webkit01.dat:
 601.9
 602.10
 603.11
+648.1
+649.2
+650.3
+651.4
+652.5
+653.6
+654.7
+655.8
+656.9
+657.10
+658.11
+659.12
+660.13
+661.14
+662.15
+663.16
+664.17
+665.18
+666.19
+667.20
+668.21
+669.22
+670.23
+671.24
+672.25
+673.26
+674.27
+700.1
+701.2
+702.3
+703.4
+704.5
+705.6
+706.7
+707.8
+708.9
+709.10
+710.11
+711.12
+712.13
+713.14
+714.15
+715.16
+716.17
+717.18
+718.19
+719.20
+720.21
+721.22
+722.23
+723.24
+724.25
+725.26
+726.27
index c43367b..ffcac24 100644 (file)
@@ -2,6 +2,26 @@
 
         Reviewed by Eric Seidel.
 
+        Implement AfterBodyMode for HTML5 tree builder
+        https://bugs.webkit.org/show_bug.cgi?id=41500
+
+        In the coarse of implementing this state, I ran into an ASSERT in how
+        </br> tags where handled, which I fixed.  Technically, that could be a
+        separate patch, but it seemed harmless to include it here (with tests).
+
+        * html/HTMLTreeBuilder.cpp:
+        (WebCore::HTMLTreeBuilder::processStartTag):
+        (WebCore::HTMLTreeBuilder::processEndTag):
+        (WebCore::HTMLTreeBuilder::processComment):
+        (WebCore::HTMLTreeBuilder::processCharacter):
+        (WebCore::HTMLTreeBuilder::processEndOfFile):
+        (WebCore::HTMLTreeBuilder::insertCommentOnHTMLHtmlElement):
+        * html/HTMLTreeBuilder.h:
+
+2010-07-02  Adam Barth  <abarth@webkit.org>
+
+        Reviewed by Eric Seidel.
+
         Handle <base> and friends in AfterHeadMode
         https://bugs.webkit.org/show_bug.cgi?id=41502
 
index 2fc8206..c29a4b7 100644 (file)
@@ -564,6 +564,15 @@ void HTMLTreeBuilder::processStartTag(AtomicHTMLToken& token)
         reconstructTheActiveFormattingElements();
         insertElement(token);
         break;
+    case AfterBodyMode:
+        ASSERT(insertionMode() == AfterBodyMode);
+        if (token.name() == htmlTag) {
+            insertHTMLStartTagInBody(token);
+            return;
+        }
+        m_insertionMode = InBodyMode;
+        processStartTag(token);
+        break;
     case InHeadNoscriptMode:
         ASSERT(insertionMode() == InHeadNoscriptMode);
         if (token.name() == htmlTag) {
@@ -749,7 +758,9 @@ void HTMLTreeBuilder::processEndTag(AtomicHTMLToken& token)
         if (token.name() == brTag) {
             parseError(token);
             reconstructTheActiveFormattingElements();
-            insertSelfClosingElement(token);
+            // Notice that we lose the attributes.
+            AtomicHTMLToken startBr(HTMLToken::StartTag, token.name());
+            insertSelfClosingElement(startBr);
             m_framesetOk = false;
             return;
         }
@@ -761,6 +772,19 @@ void HTMLTreeBuilder::processEndTag(AtomicHTMLToken& token)
         m_openElements.popUntil(token.name());
         m_openElements.pop();
         break;
+    case AfterBodyMode:
+        ASSERT(insertionMode() == AfterBodyMode);
+        if (token.name() == htmlTag) {
+            if (m_isParsingFragment) {
+                parseError(token);
+                return;
+            }
+            m_insertionMode = AfterAfterBodyMode;
+            return;
+        }
+        m_insertionMode = InBodyMode;
+        processEndTag(token);
+        break;
     case InHeadNoscriptMode:
         ASSERT(insertionMode() == InHeadNoscriptMode);
         if (token.name() == noscriptTag) {
@@ -801,6 +825,10 @@ void HTMLTreeBuilder::processComment(AtomicHTMLToken& token)
         insertCommentOnDocument(token);
         return;
     }
+    if (m_insertionMode == AfterBodyMode) {
+        insertCommentOnHTMLHtmlElement(token);
+        return;
+    }
     insertComment(token);
 }
 
@@ -838,6 +866,10 @@ void HTMLTreeBuilder::processCharacter(AtomicHTMLToken& token)
         notImplemented();
         insertTextNode(token);
         break;
+    case AfterBodyMode:
+        ASSERT(insertionMode() == AfterBodyMode);
+        m_insertionMode = InBodyMode;
+        processCharacter(token);
     case TextMode:
         notImplemented();
         insertTextNode(token);
@@ -879,6 +911,10 @@ void HTMLTreeBuilder::processEndOfFile(AtomicHTMLToken& token)
         ASSERT(insertionMode() == InBodyMode);
         notImplemented();
         break;
+    case AfterBodyMode:
+        ASSERT(insertionMode() == AfterBodyMode);
+        notImplemented();
+        break;
     case InHeadNoscriptMode:
         ASSERT(insertionMode() == InHeadNoscriptMode);
         processDefaultForInHeadNoscriptMode(token);
@@ -990,6 +1026,12 @@ void HTMLTreeBuilder::insertCommentOnDocument(AtomicHTMLToken& token)
     attach(m_document, Comment::create(m_document, token.comment()));
 }
 
+void HTMLTreeBuilder::insertCommentOnHTMLHtmlElement(AtomicHTMLToken& token)
+{
+    ASSERT(token.type() == HTMLToken::Comment);
+    attach(m_openElements.htmlElement(), Comment::create(m_document, token.comment()));
+}
+
 PassRefPtr<Element> HTMLTreeBuilder::createElementAndAttachToCurrent(AtomicHTMLToken& token)
 {
     ASSERT(token.type() == HTMLToken::StartTag);
index fd280e6..1b4ccfc 100644 (file)
@@ -142,6 +142,7 @@ private:
     void insertDoctype(AtomicHTMLToken&);
     void insertComment(AtomicHTMLToken&);
     void insertCommentOnDocument(AtomicHTMLToken&);
+    void insertCommentOnHTMLHtmlElement(AtomicHTMLToken&);
     void insertHTMLHtmlElement(AtomicHTMLToken&);
     void insertHTMLHeadElement(AtomicHTMLToken&);
     void insertHTMLBodyElement(AtomicHTMLToken&);