2010-07-05 Eric Seidel <eric@webkit.org>
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Jul 2010 20:02:11 +0000 (20:02 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Jul 2010 20:02:11 +0000 (20:02 +0000)
        Reviewed by Adam Barth.

        Add basic "in row" mode to support <td> and <th> insertion
        https://bugs.webkit.org/show_bug.cgi?id=41588

        Also fixed <td> or <th> as a direct child of <table>.

        Most of this was covered by html5lib/runner.html tests,
        but I had to add a new tables01.dat to cover the <th> cases.

        * html/HTMLElementStack.cpp:
        (WebCore::HTMLNames::isTableRowScopeMarker):
        (WebCore::HTMLElementStack::popUntilTableRowScopeMarker):
        * html/HTMLElementStack.h:
        * html/HTMLTreeBuilder.cpp:
        (WebCore::HTMLTreeBuilder::processStartTag):
2010-07-05  Eric Seidel  <eric@webkit.org>

        Reviewed by Adam Barth.

        Add basic "in row" mode to support <td> insertion
        https://bugs.webkit.org/show_bug.cgi?id=41588

        Added tables01.dat to test a previously untested
        <table><th> case.  I expect we'll add many more table
        tests there as we complete our implementation.

        * html5lib/runner-expected-html5.txt:
        * html5lib/runner-expected.txt:
        * html5lib/runner.html:
        * html5lib/resources/tables01.dat: Added.

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

LayoutTests/ChangeLog
LayoutTests/html5lib/resources/tables01.dat [new file with mode: 0644]
LayoutTests/html5lib/runner-expected-html5.txt
LayoutTests/html5lib/runner-expected.txt
LayoutTests/html5lib/runner.html
WebCore/ChangeLog
WebCore/html/HTMLElementStack.cpp
WebCore/html/HTMLElementStack.h
WebCore/html/HTMLTreeBuilder.cpp

index 416c140..a8c099a 100644 (file)
@@ -2,6 +2,22 @@
 
         Reviewed by Adam Barth.
 
+        Add basic "in row" mode to support <td> insertion
+        https://bugs.webkit.org/show_bug.cgi?id=41588
+
+        Added tables01.dat to test a previously untested
+        <table><th> case.  I expect we'll add many more table
+        tests there as we complete our implementation.
+
+        * html5lib/runner-expected-html5.txt:
+        * html5lib/runner-expected.txt:
+        * html5lib/runner.html:
+        * html5lib/resources/tables01.dat: Added.
+
+2010-07-05  Eric Seidel  <eric@webkit.org>
+
+        Reviewed by Adam Barth.
+
         Finish implementing "any other end tag" for "in body" mode
         https://bugs.webkit.org/show_bug.cgi?id=41582
 
diff --git a/LayoutTests/html5lib/resources/tables01.dat b/LayoutTests/html5lib/resources/tables01.dat
new file mode 100644 (file)
index 0000000..9fb79e0
--- /dev/null
@@ -0,0 +1,23 @@
+#data
+<table><th>
+#errors
+#document
+| <html>
+|   <head>
+|   <body>
+|     <table>
+|       <tbody>
+|         <tr>
+|           <th>
+
+#data
+<table><td>
+#errors
+#document
+| <html>
+|   <head>
+|   <body>
+|     <table>
+|       <tbody>
+|         <tr>
+|           <td>
index 8e4cb60..f236235 100644 (file)
@@ -67,6 +67,9 @@ Got:
 |   <body>
 |     <b>
 |       <table>
+|         <tbody>
+|           <tr>
+|             <td>
 Expected:
 | <html>
 |   <head>
@@ -86,6 +89,9 @@ Got:
 |   <body>
 |     <b>
 |       <table>
+|         <tbody>
+|           <tr>
+|             <td>
 Expected:
 | <html>
 |   <head>
@@ -221,6 +227,9 @@ Got:
 |   <body>
 |     <a>
 |       <table>
+|         <tbody>
+|           <tr>
+|             <td>
 Expected:
 | <html>
 |   <head>
@@ -282,7 +291,10 @@ Got:
 |       <div>
 |         "hello"
 |         <table>
-|           <!-- X -->
+|           <tbody>
+|             <tr>
+|               <th>
+|                 <!-- X -->
 Expected:
 | <!-- - -->
 | <html>
@@ -918,6 +930,9 @@ Got:
 |       href="blah"
 |       "aba"
 |       <table>
+|         <tbody>
+|           <tr>
+|             <td>
 Expected:
 | <html>
 |   <head>
@@ -949,6 +964,9 @@ Got:
 |       href="blah"
 |       "aba"
 |       <table>
+|         <tbody>
+|           <tr>
+|             <td>
 Expected:
 | <html>
 |   <head>
@@ -972,6 +990,9 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <tbody>
+|         <tr>
+|           <td>
 Expected:
 | <html>
 |   <head>
@@ -1055,6 +1076,9 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <tbody>
+|         <tr>
+|           <td>
 Expected:
 | <html>
 |   <head>
@@ -1098,6 +1122,9 @@ Got:
 |   <body>
 |     <b>
 |       <table>
+|         <tbody>
+|           <tr>
+|             <td>
 Expected:
 | <html>
 |   <head>
@@ -1117,6 +1144,9 @@ Got:
 |   <body>
 |     <b>
 |       <table>
+|         <tbody>
+|           <tr>
+|             <td>
 Expected:
 | <html>
 |   <head>
@@ -1238,6 +1268,9 @@ Got:
 |   <body>
 |     <a>
 |       <table>
+|         <tbody>
+|           <tr>
+|             <td>
 Expected:
 | <html>
 |   <head>
@@ -1299,6 +1332,9 @@ Got:
 |   <body>
 |     <h1>
 |       <table>
+|         <tbody>
+|           <tr>
+|             <td>
 Expected:
 | <html>
 |   <head>
@@ -1346,6 +1382,7 @@ Got:
 |     <table>
 |       <tbody>
 |         <tr>
+|           <td>
 Expected:
 | <html>
 |   <head>
@@ -1411,6 +1448,8 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <tbody>
+|         <tr>
 Expected:
 | <html>
 |   <head>
@@ -1421,7 +1460,6 @@ Expected:
 |         <tr>
 |     <p>
 resources/tests2.dat:
-3
 4
 8
 9
@@ -1442,29 +1480,16 @@ resources/tests2.dat:
 54
 58
 
-Test 3 of 59 in resources/tests2.dat failed. Input:
-<table><td>
+Test 4 of 59 in resources/tests2.dat failed. Input:
+<table><td>test</tbody></table>
 Got:
 | <html>
 |   <head>
 |   <body>
 |     <table>
-Expected:
-| <html>
-|   <head>
-|   <body>
-|     <table>
 |       <tbody>
 |         <tr>
 |           <td>
-
-Test 4 of 59 in resources/tests2.dat failed. Input:
-<table><td>test</tbody></table>
-Got:
-| <html>
-|   <head>
-|   <body>
-|     <table>
 Expected:
 | <html>
 |   <head>
@@ -1524,6 +1549,9 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <tbody>
+|         <tr>
+|           <td>
 Expected:
 | <html>
 |   <head>
@@ -1540,6 +1568,8 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <tbody>
+|         <tr>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -1794,6 +1824,9 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <tbody>
+|         <tr>
+|           <td>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -2104,12 +2137,10 @@ resources/tests6.dat:
 12
 13
 14
-15
 16
 17
 19
 23
-24
 26
 27
 30
@@ -2238,22 +2269,6 @@ Expected:
 |     <button>
 |     <button>
 
-Test 15 of 51 in resources/tests6.dat failed. Input:
-<table><tr><td></th>
-Got:
-| <html>
-|   <head>
-|   <body>
-|     <table>
-Expected:
-| <html>
-|   <head>
-|   <body>
-|     <table>
-|       <tbody>
-|         <tr>
-|           <td>
-
 Test 16 of 51 in resources/tests6.dat failed. Input:
 <table><caption><td>
 Got:
@@ -2320,22 +2335,6 @@ Expected:
 |       <caption>
 |         <div>
 
-Test 24 of 51 in resources/tests6.dat failed. Input:
-<table><tr><td></body></caption></col></colgroup></html>
-Got:
-| <html>
-|   <head>
-|   <body>
-|     <table>
-Expected:
-| <html>
-|   <head>
-|   <body>
-|     <table>
-|       <tbody>
-|         <tr>
-|           <td>
-
 Test 26 of 51 in resources/tests6.dat failed. Input:
 <table><colgroup>foo
 Got:
@@ -2373,6 +2372,8 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <tbody>
+|         <tr>
 Expected:
 | <html>
 |   <head>
@@ -2389,6 +2390,9 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <tbody>
+|         <tr>
+|           <td>
 Expected:
 | <html>
 |   <head>
@@ -2531,6 +2535,9 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <tbody>
+|         <tr>
+|           <td>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -2745,6 +2752,8 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <tbody>
+|         <tr>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -2806,6 +2815,9 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <tbody>
+|         <tr>
+|           <td>
 Expected:
 | <html>
 |   <head>
@@ -2824,6 +2836,9 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <tbody>
+|         <tr>
+|           <td>
 Expected:
 | <html>
 |   <head>
@@ -2847,6 +2862,8 @@ Got:
 |   <body>
 |     "A"
 |     <table>
+|       <tbody>
+|         <tr>
 Expected:
 | <html>
 |   <head>
@@ -2864,6 +2881,8 @@ Got:
 |   <body>
 |     "A"
 |     <table>
+|       <tbody>
+|         <tr>
 Expected:
 | <html>
 |   <head>
@@ -3258,6 +3277,7 @@ Got:
 |     <table>
 |       <tbody>
 |         <tr>
+|           <td>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -3283,6 +3303,7 @@ Got:
 |     <table>
 |       <tbody>
 |         <tr>
+|           <td>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -3409,6 +3430,9 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <tbody>
+|         <tr>
+|           <td>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -3771,6 +3795,7 @@ Got:
 |     <table>
 |       <tbody>
 |         <tr>
+|           <td>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -3796,6 +3821,7 @@ Got:
 |     <table>
 |       <tbody>
 |         <tr>
+|           <td>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -3922,6 +3948,9 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <tbody>
+|         <tr>
+|           <td>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -5062,6 +5091,9 @@ Got:
 |     <p>
 |       "spam"
 |       <table>
+|         <tbody>
+|           <tr>
+|             <td>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -5113,6 +5145,9 @@ Got:
 |               <p>
 |                 "spam"
 |                 <table>
+|                   <tbody>
+|                     <tr>
+|                       <td>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -5288,6 +5323,8 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <tbody>
+|         <tr>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -5328,6 +5365,9 @@ Got:
 |   <body>
 |     <div>
 |       <table>
+|         <tbody>
+|           <tr>
+|             <td>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -5374,6 +5414,9 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <tbody>
+|         <tr>
+|           <td>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -5584,4 +5627,6 @@ Expected:
 |       "3"
 |     <table>
 resources/inbody01.dat: PASS
+
+resources/tables01.dat: PASS
 #EOF
index ce1497d..0f17f07 100644 (file)
@@ -4936,3 +4936,5 @@ Expected:
 |       "3"
 |     <table>
 resources/inbody01.dat: PASS
+
+resources/tables01.dat: PASS
index bad2f5e..cd17ea1 100644 (file)
@@ -60,7 +60,8 @@ var test_files = [
         'resources/entities02.dat',
         'resources/comments01.dat',
         'resources/adoption01.dat',
-        'resources/inbody01.dat'
+        'resources/inbody01.dat',
+        'resources/tables01.dat'
     ],
     tests = [],
     iframe = document.getElementsByTagName("iframe")[0],
index 96c93b7..763e0bb 100644 (file)
@@ -2,6 +2,25 @@
 
         Reviewed by Adam Barth.
 
+        Add basic "in row" mode to support <td> and <th> insertion
+        https://bugs.webkit.org/show_bug.cgi?id=41588
+
+        Also fixed <td> or <th> as a direct child of <table>.
+
+        Most of this was covered by html5lib/runner.html tests,
+        but I had to add a new tables01.dat to cover the <th> cases.
+
+        * html/HTMLElementStack.cpp:
+        (WebCore::HTMLNames::isTableRowScopeMarker):
+        (WebCore::HTMLElementStack::popUntilTableRowScopeMarker):
+        * html/HTMLElementStack.h:
+        * html/HTMLTreeBuilder.cpp:
+        (WebCore::HTMLTreeBuilder::processStartTag):
+
+2010-07-05  Eric Seidel  <eric@webkit.org>
+
+        Reviewed by Adam Barth.
+
         Finish implementing "any other end tag" for "in body" mode
         https://bugs.webkit.org/show_bug.cgi?id=41582
 
index 2f1b792..31a2364 100644 (file)
@@ -76,6 +76,12 @@ inline bool isTableBodyScopeMarker(Element* element)
         || element->hasTagName(htmlTag);
 }
 
+inline bool isTableRowScopeMarker(Element* element)
+{
+    return element->hasTagName(trTag)
+        || element->hasTagName(htmlTag);
+}
+
 }
 
 HTMLElementStack::ElementRecord::ElementRecord(PassRefPtr<Element> element, PassOwnPtr<ElementRecord> next)
@@ -165,6 +171,13 @@ void HTMLElementStack::popUntilTableBodyScopeMarker()
         pop();
 }
 
+void HTMLElementStack::popUntilTableRowScopeMarker()
+{
+    // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#clear-the-stack-back-to-a-table-row-context
+    while (!isTableRowScopeMarker(top()))
+        pop();
+}
+
 void HTMLElementStack::pushHTMLHtmlElement(PassRefPtr<Element> element)
 {
     ASSERT(!m_top); // <html> should always be the bottom of the stack.
index efc3fd8..1db4c20 100644 (file)
@@ -84,6 +84,7 @@ public:
     void popUntil(Element*);
     void popUntilTableScopeMarker(); // "clear the stack back to a table context" in the spec.
     void popUntilTableBodyScopeMarker(); // "clear the stack back to a table body context" in the spec.
+    void popUntilTableRowScopeMarker(); // "clear the stack back to a table row context" in the spec.
     void popHTMLHeadElement();
     void popHTMLBodyElement();
 
index bf0b7f1..d7a6285 100644 (file)
@@ -756,7 +756,10 @@ void HTMLTreeBuilder::processStartTag(AtomicHTMLToken& token)
             return;
         }
         if (token.name() == tdTag || token.name() == thTag || token.name() == trTag) {
-            notImplemented();
+            AtomicHTMLToken fakeToken(HTMLToken::StartTag, tbodyTag.localName());
+            processStartTag(fakeToken);
+            ASSERT(insertionMode() == InTableBodyMode);
+            processStartTag(token);
             return;
         }
         if (token.name() == tableTag) {
@@ -798,12 +801,24 @@ void HTMLTreeBuilder::processStartTag(AtomicHTMLToken& token)
             return;
         }
         if (token.name() == captionTag || token.name() == colTag || token.name() == colgroupTag || isTableBodyContextTag(token.name())) {
-            // FIXME: The spec is unclear as to what is supposed to happen here.
             notImplemented();
             return;
         }
         notImplemented(); // process using "in table" rules
         break;
+    case InRowMode:
+        if (token.name() == thTag || token.name() == tdTag) {
+            m_openElements.popUntilTableRowScopeMarker();
+            insertElement(token);
+            m_insertionMode = InCellMode;
+            m_activeFormattingElements.appendMarker();
+        }
+        if (token.name() == captionTag || token.name() == colTag || token.name() == colgroupTag || isTableBodyContextTag(token.name())) {
+            notImplemented();
+            return;
+        }
+        notImplemented();
+        break;
     case AfterBodyMode:
     case AfterAfterBodyMode:
         ASSERT(insertionMode() == AfterBodyMode || insertionMode() == AfterAfterBodyMode);