2010-07-06 Eric Seidel <eric@webkit.org>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Jul 2010 01:49:20 +0000 (01:49 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Jul 2010 01:49:20 +0000 (01:49 +0000)
        Reviewed by Adam Barth.

        "In cell" does not correctly handle <td><tr> or <td><td>
        https://bugs.webkit.org/show_bug.cgi?id=41729

        * html5lib/resources/tables01.dat:
         - Added a case for <td><tr> since it was missing from the rest of the suite.
        * html5lib/runner-expected-html5.txt:
        * html5lib/runner-expected.txt:
2010-07-06  Eric Seidel  <eric@webkit.org>

        Reviewed by Adam Barth.

        "In cell" does not correctly handle <td><tr> or <td><td>
        https://bugs.webkit.org/show_bug.cgi?id=41729

        This change is mostly cleanup to try and prevent forgetting
        tag name checks in the future by using inlines to reduce
        copy/paste code.

        3 little bugs in InCellMode:
         - Missing trTag from the long or statement (reason for the cleanup)
         - Used || instead of &&
         - Forgot to reprocess the tag after closeTheCell()

        * html/HTMLTreeBuilder.cpp:
        (WebCore::HTMLTreeBuilder::processStartTagForInBody):
        (WebCore::HTMLTreeBuilder::processStartTagForInTable):
        (WebCore::HTMLTreeBuilder::processStartTag):
        (WebCore::HTMLTreeBuilder::processEndTagForInTable):
        (WebCore::HTMLTreeBuilder::processEndTag):

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

LayoutTests/ChangeLog
LayoutTests/html5lib/resources/tables01.dat
LayoutTests/html5lib/runner-expected-html5.txt
LayoutTests/html5lib/runner-expected.txt
WebCore/ChangeLog
WebCore/html/HTMLTreeBuilder.cpp

index 6fb2ee7..d758dc8 100644 (file)
@@ -1,3 +1,15 @@
+2010-07-06  Eric Seidel  <eric@webkit.org>
+
+        Reviewed by Adam Barth.
+
+        "In cell" does not correctly handle <td><tr> or <td><td>
+        https://bugs.webkit.org/show_bug.cgi?id=41729
+
+        * html5lib/resources/tables01.dat:
+         - Added a case for <td><tr> since it was missing from the rest of the suite.
+        * html5lib/runner-expected-html5.txt:
+        * html5lib/runner-expected.txt:
+
 2010-07-06  Vitaly Repeshko  <vitalyr@chromium.org>
 
         Unreviewed.
index 9275ad3..8c5652e 100644 (file)
 |         <tr>
 |           <td>
 |             "foo"
+
+#data
+<table><td><tr>
+#errors
+#document
+| <html>
+|   <head>
+|   <body>
+|     <table>
+|       <tbody>
+|         <tr>
+|           <td>
+|         <tr>
index 64510b9..f72fa65 100644 (file)
@@ -11,11 +11,8 @@ resources/tests1.dat:
 78
 79
 80
-86
 90
 103
-109
-110
 112
 
 Test 30 of 113 in resources/tests1.dat failed. Input:
@@ -255,34 +252,6 @@ Expected:
 |       href="blah"
 |       "aoe"
 
-Test 86 of 113 in resources/tests1.dat failed. Input:
-<table><tr><tr><td><td><span><th><span>X</table>
-Got:
-| <html>
-|   <head>
-|   <body>
-|     <table>
-|       <tbody>
-|         <tr>
-|           <td>
-|             <span>
-|               <span>
-|                 "X"
-Expected:
-| <html>
-|   <head>
-|   <body>
-|     <table>
-|       <tbody>
-|         <tr>
-|         <tr>
-|           <td>
-|           <td>
-|             <span>
-|           <th>
-|             <span>
-|               "X"
-
 Test 90 of 113 in resources/tests1.dat failed. Input:
 <a><table><a></table><p><a><div><a>
 Got:
@@ -339,77 +308,6 @@ Expected:
 |               <a>
 |     <a>
 
-Test 109 of 113 in resources/tests1.dat failed. Input:
-<table><col><tbody><col><tr><col><td><col></table><col>
-Got:
-| <html>
-|   <head>
-|   <body>
-|     <table>
-|       <colgroup>
-|         <col>
-|       <tbody>
-|       <colgroup>
-|         <col>
-|       <tbody>
-|         <tr>
-|       <colgroup>
-|         <col>
-|       <tbody>
-|         <tr>
-|           <td>
-Expected:
-| <html>
-|   <head>
-|   <body>
-|     <table>
-|       <colgroup>
-|         <col>
-|       <tbody>
-|       <colgroup>
-|         <col>
-|       <tbody>
-|         <tr>
-|       <colgroup>
-|         <col>
-|       <tbody>
-|         <tr>
-|           <td>
-|       <colgroup>
-|         <col>
-
-Test 110 of 113 in resources/tests1.dat failed. Input:
-<table><colgroup><tbody><colgroup><tr><colgroup><td><colgroup></table><colgroup>
-Got:
-| <html>
-|   <head>
-|   <body>
-|     <table>
-|       <colgroup>
-|       <tbody>
-|       <colgroup>
-|       <tbody>
-|         <tr>
-|       <colgroup>
-|       <tbody>
-|         <tr>
-|           <td>
-Expected:
-| <html>
-|   <head>
-|   <body>
-|     <table>
-|       <colgroup>
-|       <tbody>
-|       <colgroup>
-|       <tbody>
-|         <tr>
-|       <colgroup>
-|       <tbody>
-|         <tr>
-|           <td>
-|       <colgroup>
-
 Test 112 of 113 in resources/tests1.dat failed. Input:
 <table><tr></strong></b></em></i></u></strike></s></blink></tt></pre></big></small></font></select></h1></h2></h3></h4></h5></h6></body></br></a></img></title></span></style></script></table></th></td></tr></frame></area></link></param></hr></input></col></base></meta></basefont></bgsound></embed></spacer></p></dd></dt></caption></colgroup></tbody></tfoot></thead></address></blockquote></center></dir></div></dl></fieldset></listing></menu></ol></ul></li></nobr></wbr></form></button></marquee></object></html></frameset></head></iframe></image></isindex></noembed></noframes></noscript></optgroup></option></plaintext></textarea>
 Got:
@@ -949,6 +847,7 @@ Got:
 |     <table>
 |       <tbody>
 |         <tr>
+|           <div>
 Expected:
 | <html>
 |   <head>
@@ -967,6 +866,7 @@ Got:
 |     <table>
 |       <tbody>
 |         <tr>
+|           <div>
 |           <td>
 Expected:
 | <html>
@@ -1672,7 +1572,11 @@ Got:
 |     <table>
 |       <tbody>
 |         <tr>
-|           "foobar"
+|           <math>
+|             <mi>
+|               "foo"
+|               <mi>
+|                 "bar"
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -2211,7 +2115,11 @@ Got:
 |     <table>
 |       <tbody>
 |         <tr>
-|           "foobar"
+|           <svg>
+|             <g>
+|               "foo"
+|               <g>
+|                 "bar"
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -4019,7 +3927,7 @@ resources/tables01.dat:
 9
 10
 
-Test 4 of 14 in resources/tables01.dat failed. Input:
+Test 4 of 15 in resources/tables01.dat failed. Input:
 <table><colgroup></html>foo
 Got:
 | <html>
@@ -4036,7 +3944,7 @@ Expected:
 |     <table>
 |       <colgroup>
 
-Test 7 of 14 in resources/tables01.dat failed. Input:
+Test 7 of 15 in resources/tables01.dat failed. Input:
 <table><select><option>3</select></table>
 Got:
 | <html>
@@ -4055,7 +3963,7 @@ Expected:
 |         "3"
 |     <table>
 
-Test 8 of 14 in resources/tables01.dat failed. Input:
+Test 8 of 15 in resources/tables01.dat failed. Input:
 <table><select><table></table></select></table>
 Got:
 | <html>
@@ -4071,7 +3979,7 @@ Expected:
 |     <table>
 |     <table>
 
-Test 9 of 14 in resources/tables01.dat failed. Input:
+Test 9 of 15 in resources/tables01.dat failed. Input:
 <table><select></table>
 Got:
 | <html>
@@ -4086,7 +3994,7 @@ Expected:
 |     <select>
 |     <table>
 
-Test 10 of 14 in resources/tables01.dat failed. Input:
+Test 10 of 15 in resources/tables01.dat failed. Input:
 <table><select><option>A<tr><td>B</td></tr></table>
 Got:
 | <html>
index 1aa9647..43c63d7 100644 (file)
@@ -5135,7 +5135,7 @@ resources/tables01.dat:
 8
 9
 
-Test 3 of 14 in resources/tables01.dat failed. Input:
+Test 3 of 15 in resources/tables01.dat failed. Input:
 <table><col foo='bar'>
 Got:
 | <html>
@@ -5153,7 +5153,7 @@ Expected:
 |         <col>
 |           foo="bar"
 
-Test 7 of 14 in resources/tables01.dat failed. Input:
+Test 7 of 15 in resources/tables01.dat failed. Input:
 <table><select><option>3</select></table>
 Got:
 | <html>
@@ -5173,7 +5173,7 @@ Expected:
 |         "3"
 |     <table>
 
-Test 8 of 14 in resources/tables01.dat failed. Input:
+Test 8 of 15 in resources/tables01.dat failed. Input:
 <table><select><table></table></select></table>
 Got:
 | <html>
@@ -5191,7 +5191,7 @@ Expected:
 |     <table>
 |     <table>
 
-Test 9 of 14 in resources/tables01.dat failed. Input:
+Test 9 of 15 in resources/tables01.dat failed. Input:
 <table><select></table>
 Got:
 | <html>
index bb0b829..0f73f9f 100644 (file)
@@ -1,3 +1,26 @@
+2010-07-06  Eric Seidel  <eric@webkit.org>
+
+        Reviewed by Adam Barth.
+
+        "In cell" does not correctly handle <td><tr> or <td><td>
+        https://bugs.webkit.org/show_bug.cgi?id=41729
+
+        This change is mostly cleanup to try and prevent forgetting
+        tag name checks in the future by using inlines to reduce
+        copy/paste code.
+
+        3 little bugs in InCellMode:
+         - Missing trTag from the long or statement (reason for the cleanup)
+         - Used || instead of &&
+         - Forgot to reprocess the tag after closeTheCell()
+
+        * html/HTMLTreeBuilder.cpp:
+        (WebCore::HTMLTreeBuilder::processStartTagForInBody):
+        (WebCore::HTMLTreeBuilder::processStartTagForInTable):
+        (WebCore::HTMLTreeBuilder::processStartTag):
+        (WebCore::HTMLTreeBuilder::processEndTagForInTable):
+        (WebCore::HTMLTreeBuilder::processEndTag):
+
 2010-07-06  Adam Barth  <abarth@webkit.org>
 
         Reviewed by Eric Seidel.
index d35fd45..d457019 100644 (file)
@@ -81,6 +81,18 @@ bool isNumberedHeaderTag(const AtomicString& tagName)
         || tagName == h6Tag;
 }
 
+bool isCaptionColOrColgroupTag(const AtomicString& tagName)
+{
+    return tagName == captionTag
+        || tagName == colTag
+        || tagName == colgroupTag;
+}
+
+bool isTableCellContextTag(const AtomicString& tagName)
+{
+    return tagName == thTag || tagName == tdTag;
+}
+
 bool isTableBodyContextTag(const AtomicString& tagName)
 {
     return tagName == tbodyTag
@@ -169,8 +181,7 @@ bool isScopingTag(const AtomicString& tagName)
         || tagName == marqueeTag
         || tagName == objectTag
         || tagName == tableTag
-        || tagName == tdTag
-        || tagName == thTag;
+        || isTableCellContextTag(tagName);
 }
 
 bool isNonAnchorFormattingTag(const AtomicString& tagName)
@@ -751,7 +762,12 @@ void HTMLTreeBuilder::processStartTagForInBody(AtomicHTMLToken& token)
         // This is the SVG foreign content branch point.
         notImplemented();
     }
-    if (token.name() == captionTag || token.name() == colTag || token.name() == colgroupTag || token.name() == frameTag || token.name() == headTag || isTableBodyContextTag(token.name()) || token.name() == tdTag || token.name() == thTag || token.name() == trTag) {
+    if (isCaptionColOrColgroupTag(token.name())
+        || token.name() == frameTag
+        || token.name() == headTag
+        || isTableBodyContextTag(token.name())
+        || isTableCellContextTag(token.name())
+        || token.name() == trTag) {
         parseError(token);
         return;
     }
@@ -813,7 +829,7 @@ void HTMLTreeBuilder::processStartTagForInTable(AtomicHTMLToken& token)
         m_insertionMode = InTableBodyMode;
         return;
     }
-    if (token.name() == tdTag || token.name() == thTag || token.name() == trTag) {
+    if (isTableCellContextTag(token.name()) || token.name() == trTag) {
         processFakeStartTag(tbodyTag);
         ASSERT(insertionMode() == InTableBodyMode);
         processStartTag(token);
@@ -921,7 +937,10 @@ void HTMLTreeBuilder::processStartTag(AtomicHTMLToken& token)
         break;
     case InCaptionMode:
         ASSERT(insertionMode() == InCaptionMode);
-        if (token.name() == captionTag || token.name() == colTag || token.name() == colgroupTag || isTableBodyContextTag(token.name()) || token.name() == tdTag || token.name() == thTag || token.name() == trTag) {
+        if (isCaptionColOrColgroupTag(token.name())
+            || isTableBodyContextTag(token.name())
+            || isTableCellContextTag(token.name())
+            || token.name() == trTag) {
             parseError(token);
             if (!processCaptionEndTagForInCaption()) {
                 ASSERT(m_isParsingFragment);
@@ -956,14 +975,14 @@ void HTMLTreeBuilder::processStartTag(AtomicHTMLToken& token)
             m_insertionMode = InRowMode;
             return;
         }
-        if (token.name() == thTag || token.name() == tdTag) {
+        if (isTableCellContextTag(token.name())) {
             parseError(token);
             processFakeStartTag(trTag);
             ASSERT(insertionMode() == InRowMode);
             processStartTag(token);
             return;
         }
-        if (token.name() == captionTag || token.name() == colTag || token.name() == colgroupTag || isTableBodyContextTag(token.name())) {
+        if (isCaptionColOrColgroupTag(token.name()) || isTableBodyContextTag(token.name())) {
             // FIXME: This is slow.
             if (!m_tree.openElements()->inTableScope(tbodyTag.localName()) && !m_tree.openElements()->inTableScope(theadTag.localName()) && !m_tree.openElements()->inTableScope(tfootTag.localName())) {
                 ASSERT(m_isParsingFragment);
@@ -980,13 +999,16 @@ void HTMLTreeBuilder::processStartTag(AtomicHTMLToken& token)
         break;
     case InRowMode:
         ASSERT(insertionMode() == InRowMode);
-        if (token.name() == thTag || token.name() == tdTag) {
+        if (isTableCellContextTag(token.name())) {
             m_tree.openElements()->popUntilTableRowScopeMarker();
             m_tree.insertElement(token);
             m_insertionMode = InCellMode;
             m_tree.activeFormattingElements()->appendMarker();
+            return;
         }
-        if (token.name() == captionTag || token.name() == colTag || token.name() == colgroupTag || isTableBodyContextTag(token.name())) {
+        if (token.name() == trTag
+            || isCaptionColOrColgroupTag(token.name())
+            || isTableBodyContextTag(token.name())) {
             if (!processTrEndTagForInRow()) {
                 ASSERT(m_isParsingFragment);
                 return;
@@ -995,17 +1017,22 @@ void HTMLTreeBuilder::processStartTag(AtomicHTMLToken& token)
             processStartTag(token);
             return;
         }
-        notImplemented();
+        processStartTagForInTable(token);
         break;
     case InCellMode:
         ASSERT(insertionMode() == InCellMode);
-        if (token.name() == captionTag || token.name() == colTag || token.name() == colgroupTag || token.name() == thTag || token.name() == tdTag || isTableBodyContextTag(token.name())) {
+        if (isCaptionColOrColgroupTag(token.name())
+            || isTableCellContextTag(token.name())
+            || token.name() == trTag
+            || isTableBodyContextTag(token.name())) {
             // FIXME: This could be more efficient.
-            if (!m_tree.openElements()->inTableScope(tdTag) || !m_tree.openElements()->inTableScope(thTag)) {
+            if (!m_tree.openElements()->inTableScope(tdTag) && !m_tree.openElements()->inTableScope(thTag)) {
+                ASSERT(m_isParsingFragment);
                 parseError(token);
                 return;
             }
             closeTheCell();
+            processStartTag(token);
             return;
         }
         processStartTagForInBody(token);
@@ -1073,7 +1100,11 @@ void HTMLTreeBuilder::processStartTag(AtomicHTMLToken& token)
         break;
     case InSelectInTableMode:
         ASSERT(insertionMode() == InSelectInTableMode);
-        if (token.name() == captionTag || token.name() == tableTag || isTableBodyContextTag(token.name()) || token.name() == trTag || token.name() == tdTag || token.name() == thTag) {
+        if (token.name() == captionTag
+            || token.name() == tableTag
+            || isTableBodyContextTag(token.name())
+            || token.name() == trTag
+            || isTableCellContextTag(token.name())) {
             parseError(token);
             AtomicHTMLToken endSelect(HTMLToken::EndTag, selectTag.localName());
             processEndTag(endSelect);
@@ -1542,7 +1573,12 @@ void HTMLTreeBuilder::processEndTagForInTable(AtomicHTMLToken& token)
         resetInsertionModeAppropriately();
         return;
     }
-    if (token.name() == bodyTag || token.name() == captionTag || token.name() == colTag || token.name() == colgroupTag || token.name() == htmlTag || isTableBodyContextTag(token.name()) || token.name() == tdTag || token.name() == thTag || token.name() == trTag) {
+    if (token.name() == bodyTag
+        || isCaptionColOrColgroupTag(token.name())
+        || token.name() == htmlTag
+        || isTableBodyContextTag(token.name())
+        || isTableCellContextTag(token.name())
+        || token.name() == trTag) {
         parseError(token);
         return;
     }
@@ -1618,7 +1654,13 @@ void HTMLTreeBuilder::processEndTag(AtomicHTMLToken& token)
             processEndTag(token);
             return;
         }
-        if (token.name() == bodyTag || token.name() == colTag || token.name() == colgroupTag || token.name() == htmlTag || isTableBodyContextTag(token.name()) || token.name() == tdTag || token.name() == thTag || token.name() == trTag) {
+        if (token.name() == bodyTag
+            || token.name() == colTag
+            || token.name() == colgroupTag
+            || token.name() == htmlTag
+            || isTableBodyContextTag(token.name())
+            || isTableCellContextTag(token.name())
+            || token.name() == trTag) {
             parseError(token);
             return;
         }
@@ -1665,7 +1707,10 @@ void HTMLTreeBuilder::processEndTag(AtomicHTMLToken& token)
             processEndTag(token);
             return;
         }
-        if (token.name() == bodyTag || token.name() == captionTag || token.name() == colTag || token.name() == colgroupTag || token.name() == htmlTag || token.name() == tdTag || token.name() == thTag) {
+        if (token.name() == bodyTag
+            || isCaptionColOrColgroupTag(token.name())
+            || token.name() == htmlTag
+            || isTableCellContextTag(token.name())) {
             parseError(token);
             return;
         }
@@ -1673,7 +1718,7 @@ void HTMLTreeBuilder::processEndTag(AtomicHTMLToken& token)
         break;
     case InCellMode:
         ASSERT(insertionMode() == InCellMode);
-        if (token.name() == thTag || token.name() == tdTag) {
+        if (isTableCellContextTag(token.name())) {
             if (!m_tree.openElements()->inTableScope(token.name())) {
                 parseError(token);
                 return;
@@ -1688,7 +1733,9 @@ void HTMLTreeBuilder::processEndTag(AtomicHTMLToken& token)
             ASSERT(m_tree.currentElement()->hasTagName(trTag));
             return;
         }
-        if (token.name() == bodyTag || token.name() == captionTag || token.name() == colTag || token.name() == colgroupTag || token.name() == htmlTag) {
+        if (token.name() == bodyTag
+            || isCaptionColOrColgroupTag(token.name())
+            || token.name() == htmlTag) {
             parseError(token);
             return;
         }
@@ -1731,7 +1778,11 @@ void HTMLTreeBuilder::processEndTag(AtomicHTMLToken& token)
             processEndTag(token);
             return;
         }
-        if (token.name() == bodyTag || token.name() == captionTag || token.name() == colTag || token.name() == colgroupTag || token.name() == htmlTag || token.name() == tdTag || token.name() == thTag || token.name() == trTag) {
+        if (token.name() == bodyTag
+            || isCaptionColOrColgroupTag(token.name())
+            || token.name() == htmlTag
+            || isTableCellContextTag(token.name())
+            || token.name() == trTag) {
             parseError(token);
             return;
         }
@@ -1809,7 +1860,11 @@ void HTMLTreeBuilder::processEndTag(AtomicHTMLToken& token)
         break;
     case InSelectInTableMode:
         ASSERT(insertionMode() == InSelectInTableMode);
-        if (token.name() == captionTag || token.name() == tableTag || isTableBodyContextTag(token.name()) || token.name() == trTag || token.name() == tdTag || token.name() == thTag) {
+        if (token.name() == captionTag
+            || token.name() == tableTag
+            || isTableBodyContextTag(token.name())
+            || token.name() == trTag
+            || isTableCellContextTag(token.name())) {
             parseError(token);
             if (m_tree.openElements()->inTableScope(token.name())) {
                 AtomicHTMLToken endSelect(HTMLToken::EndTag, selectTag.localName());