2010-07-04 Eric Seidel <eric@webkit.org>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Jul 2010 04:45:30 +0000 (04:45 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Jul 2010 04:45:30 +0000 (04:45 +0000)
        Reviewed by Adam Barth.

        Add basic "in table body" mode to support <tr> insertion
        https://bugs.webkit.org/show_bug.cgi?id=41587

        * html5lib/runner-expected-html5.txt:
         - <tr> tags now show up, imagine that.
2010-07-04  Eric Seidel  <eric@webkit.org>

        Reviewed by Adam Barth.

        Add basic "in table body" mode to support <tr> insertion
        https://bugs.webkit.org/show_bug.cgi?id=41587

        This also adds a (currently untestable?)
        popUntilTableBodyScopeMarker code path.
        Any tags which would be between a tbody a <tr> would end up
        foster parented outside the <table>.  I think the spec was
        just being over-cautious with popUntilTableBodyScopeMarker.

        * html/HTMLElementStack.cpp:
        (WebCore::HTMLNames::isTableScopeMarker):
        (WebCore::HTMLNames::isTableBodyScopeMarker):
        (WebCore::HTMLElementStack::popUntilTableBodyScopeMarker):
        * html/HTMLElementStack.h:
        * html/HTMLTreeBuilder.cpp:
        (WebCore::HTMLTreeBuilder::processStartTag):
        (WebCore::HTMLTreeBuilder::callTheAdoptionAgency):

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

LayoutTests/ChangeLog
LayoutTests/html5lib/runner-expected-html5.txt
WebCore/ChangeLog
WebCore/html/HTMLElementStack.cpp
WebCore/html/HTMLElementStack.h
WebCore/html/HTMLTreeBuilder.cpp

index 827ad78..8e26287 100644 (file)
@@ -1,3 +1,13 @@
+2010-07-04  Eric Seidel  <eric@webkit.org>
+
+        Reviewed by Adam Barth.
+
+        Add basic "in table body" mode to support <tr> insertion
+        https://bugs.webkit.org/show_bug.cgi?id=41587
+
+        * html5lib/runner-expected-html5.txt:
+         - <tr> tags now show up, imagine that.
+
 2010-07-04  Peter Kasting  <pkasting@google.com>
 
         Unreviewed.  Update Chromium test expectations.
index 8e459f6..53a551a 100644 (file)
@@ -1345,6 +1345,7 @@ Got:
 |   <body>
 |     <table>
 |       <tbody>
+|         <tr>
 Expected:
 | <html>
 |   <head>
@@ -2601,6 +2602,7 @@ Got:
 |   <body>
 |     <table>
 |       <tbody>
+|         <tr>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -3231,6 +3233,7 @@ Got:
 |   <body>
 |     <table>
 |       <tbody>
+|         <tr>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -3254,6 +3257,7 @@ Got:
 |   <body>
 |     <table>
 |       <tbody>
+|         <tr>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -3278,6 +3282,7 @@ Got:
 |   <body>
 |     <table>
 |       <tbody>
+|         <tr>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -3741,6 +3746,7 @@ Got:
 |   <body>
 |     <table>
 |       <tbody>
+|         <tr>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -3764,6 +3770,7 @@ Got:
 |   <body>
 |     <table>
 |       <tbody>
+|         <tr>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -3788,6 +3795,7 @@ Got:
 |   <body>
 |     <table>
 |       <tbody>
+|         <tr>
 Expected:
 | <!DOCTYPE html>
 | <html>
index ff26ff9..d0cd19e 100644 (file)
@@ -1,3 +1,25 @@
+2010-07-04  Eric Seidel  <eric@webkit.org>
+
+        Reviewed by Adam Barth.
+
+        Add basic "in table body" mode to support <tr> insertion
+        https://bugs.webkit.org/show_bug.cgi?id=41587
+
+        This also adds a (currently untestable?)
+        popUntilTableBodyScopeMarker code path.
+        Any tags which would be between a tbody a <tr> would end up
+        foster parented outside the <table>.  I think the spec was
+        just being over-cautious with popUntilTableBodyScopeMarker.
+
+        * html/HTMLElementStack.cpp:
+        (WebCore::HTMLNames::isTableScopeMarker):
+        (WebCore::HTMLNames::isTableBodyScopeMarker):
+        (WebCore::HTMLElementStack::popUntilTableBodyScopeMarker):
+        * html/HTMLElementStack.h:
+        * html/HTMLTreeBuilder.cpp:
+        (WebCore::HTMLTreeBuilder::processStartTag):
+        (WebCore::HTMLTreeBuilder::callTheAdoptionAgency):
+
 2010-07-04  Anders Carlsson  <andersca@apple.com>
 
         Fix Windows build.
index c0348cb..2f1b792 100644 (file)
@@ -64,8 +64,16 @@ inline bool isListItemScopeMarker(Element* element)
 }
 inline bool isTableScopeMarker(Element* element)
 {
-    return element->hasTagName(htmlTag)
-        || element->hasTagName(tableTag);
+    return element->hasTagName(tableTag)
+        || element->hasTagName(htmlTag);
+}
+
+inline bool isTableBodyScopeMarker(Element* element)
+{
+    return element->hasTagName(tbodyTag)
+        || element->hasTagName(tfootTag)
+        || element->hasTagName(theadTag)
+        || element->hasTagName(htmlTag);
 }
 
 }
@@ -150,6 +158,13 @@ void HTMLElementStack::popUntilTableScopeMarker()
         pop();
 }
 
+void HTMLElementStack::popUntilTableBodyScopeMarker()
+{
+    // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#clear-the-stack-back-to-a-table-body-context
+    while (!isTableBodyScopeMarker(top()))
+        pop();
+}
+
 void HTMLElementStack::pushHTMLHtmlElement(PassRefPtr<Element> element)
 {
     ASSERT(!m_top); // <html> should always be the bottom of the stack.
index 0e2c779..efc3fd8 100644 (file)
@@ -83,6 +83,7 @@ public:
     void popUntil(const AtomicString& tagName);
     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 popHTMLHeadElement();
     void popHTMLBodyElement();
 
index 965bcf5..b4e7ce1 100644 (file)
@@ -77,6 +77,13 @@ bool isNumberedHeaderTag(const AtomicString& tagName)
         || tagName == h6Tag;
 }
 
+bool isTableBodyContextTag(const AtomicString& tagName)
+{
+    return tagName == tbodyTag
+        || tagName == tfootTag
+        || tagName == theadTag;
+}
+
 // http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#special
 bool isSpecialTag(const AtomicString& tagName)
 {
@@ -134,10 +141,8 @@ bool isSpecialTag(const AtomicString& tagName)
         || tagName == sectionTag
         || tagName == selectTag
         || tagName == styleTag
-        || tagName == tbodyTag
+        || isTableBodyContextTag(tagName)
         || tagName == textareaTag
-        || tagName == tfootTag
-        || tagName == theadTag
         || tagName == titleTag
         || tagName == trTag
         || tagName == ulTag
@@ -744,7 +749,7 @@ void HTMLTreeBuilder::processStartTag(AtomicHTMLToken& token)
             notImplemented();
             return;
         }
-        if (token.name() == tbodyTag || token.name() == tfootTag || token.name() == theadTag) {
+        if (isTableBodyContextTag(token.name())) {
             m_openElements.popUntilTableScopeMarker();
             insertElement(token);
             m_insertionMode = InTableBodyMode;
@@ -776,6 +781,29 @@ void HTMLTreeBuilder::processStartTag(AtomicHTMLToken& token)
         parseError(token);
         notImplemented();
         break;
+    case InTableBodyMode:
+        ASSERT(insertionMode() == InTableBodyMode);
+        if (token.name() == trTag) {
+            m_openElements.popUntilTableBodyScopeMarker(); // How is there ever anything to pop?
+            insertElement(token);
+            m_insertionMode = InRowMode;
+            return;
+        }
+        if (token.name() == thTag || token.name() == tdTag) {
+            parseError(token);
+            AtomicHTMLToken fakeToken(HTMLToken::StartTag, trTag.localName());
+            processStartTag(fakeToken);
+            ASSERT(insertionMode() == InRowMode);
+            processStartTag(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 AfterBodyMode:
     case AfterAfterBodyMode:
         ASSERT(insertionMode() == AfterBodyMode || insertionMode() == AfterAfterBodyMode);
@@ -980,10 +1008,8 @@ void HTMLTreeBuilder::callTheAdoptionAgency(AtomicHTMLToken& token)
         // 7
         const AtomicString& commonAncestorTag = commonAncestor->localName();
         if (commonAncestorTag == tableTag
-            || commonAncestorTag == tbodyTag
-            || commonAncestorTag == tfootTag
-            || commonAncestorTag == theadTag
-            || commonAncestorTag == trTag)
+            || commonAncestorTag == trTag
+            || isTableBodyContextTag(commonAncestorTag))
             findFosterParentFor(lastNode->element());
         else {
             ExceptionCode ec;