2010-07-04 Eric Seidel <eric@webkit.org>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 4 Jul 2010 21:54:59 +0000 (21:54 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 4 Jul 2010 21:54:59 +0000 (21:54 +0000)
        Reviewed by Adam Barth.

        Add a very basic InTable insertion mode
        https://bugs.webkit.org/show_bug.cgi?id=41581

        * html5lib/runner-expected-html5.txt:
         - Update expectations now that we pass 6 more tests.
2010-07-04  Eric Seidel  <eric@webkit.org>

        Reviewed by Adam Barth.

        Add a very basic InTable insertion mode
        https://bugs.webkit.org/show_bug.cgi?id=41581

        There is still a bunch of low-hanging fruit left for this
        mode, but even this most-basic support lets us pass 6 more tests. :)

        It's a progression, ship it! :)

        * html/HTMLElementStack.cpp:
        (WebCore::HTMLNames::isScopeMarker):
        (WebCore::HTMLNames::isListItemScopeMarker):
        (WebCore::HTMLNames::isTableScopeMarker):
        (WebCore::HTMLElementStack::popUntilTableScopeMarker):
        * html/HTMLElementStack.h:
        * html/HTMLFormattingElementList.cpp:
        (WebCore::HTMLFormattingElementList::appendMarker):
        * html/HTMLFormattingElementList.h:
        * html/HTMLTreeBuilder.cpp:
        (WebCore::HTMLTreeBuilder::processStartTag):
        * html/HTMLTreeBuilder.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@62469 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/HTMLFormattingElementList.cpp
WebCore/html/HTMLFormattingElementList.h
WebCore/html/HTMLTreeBuilder.cpp
WebCore/html/HTMLTreeBuilder.h

index 214ec0f..e7ea87f 100644 (file)
@@ -1,3 +1,13 @@
+2010-07-04  Eric Seidel  <eric@webkit.org>
+
+        Reviewed by Adam Barth.
+
+        Add a very basic InTable insertion mode
+        https://bugs.webkit.org/show_bug.cgi?id=41581
+
+        * html5lib/runner-expected-html5.txt:
+         - Update expectations now that we pass 6 more tests.
+
 2010-07-02  Eric Seidel  <eric@webkit.org>
 
         Reviewed by Adam Barth.
index 5a3b8d8..8e459f6 100644 (file)
@@ -1318,6 +1318,7 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <colgroup>
 Expected:
 | <html>
 |   <head>
@@ -1343,6 +1344,7 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <tbody>
 Expected:
 | <html>
 |   <head>
@@ -1370,6 +1372,7 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <colgroup>
 Expected:
 | <html>
 |   <head>
@@ -1570,6 +1573,7 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <caption>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -2103,20 +2107,14 @@ resources/tests6.dat:
 16
 17
 19
-20
-22
 23
 24
 26
 27
-28
 30
 33
 36
 37
-38
-40
-41
 42
 44
 45
@@ -2262,6 +2260,7 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <caption>
 Expected:
 | <html>
 |   <head>
@@ -2279,6 +2278,7 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <caption>
 Expected:
 | <html>
 |   <head>
@@ -2294,41 +2294,14 @@ Got:
 |   <head>
 |   <body>
 |     <table>
-Expected:
-| <html>
-|   <head>
-|   <body>
-|     <table>
 |       <caption>
-|         <div>
-
-Test 20 of 51 in resources/tests6.dat failed. Input:
-<table><caption></table>
-Got:
-| <html>
-|   <head>
-|   <body>
-|     <table>
-Expected:
-| <html>
-|   <head>
-|   <body>
-|     <table>
-|       <caption>
-
-Test 22 of 51 in resources/tests6.dat failed. Input:
-<table><caption></body></col></colgroup></html></tbody></td></tfoot></th></thead></tr>
-Got:
-| <html>
-|   <head>
-|   <body>
-|     <table>
 Expected:
 | <html>
 |   <head>
 |   <body>
 |     <table>
 |       <caption>
+|         <div>
 
 Test 23 of 51 in resources/tests6.dat failed. Input:
 <table><caption><div></div>
@@ -2337,6 +2310,7 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <caption>
 Expected:
 | <html>
 |   <head>
@@ -2368,6 +2342,7 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <colgroup>
 Expected:
 | <html>
 |   <head>
@@ -2383,20 +2358,6 @@ Got:
 Expected:
 | <col>
 
-Test 28 of 51 in resources/tests6.dat failed. Input:
-<table><colgroup></col>
-Got:
-| <html>
-|   <head>
-|   <body>
-|     <table>
-Expected:
-| <html>
-|   <head>
-|   <body>
-|     <table>
-|       <colgroup>
-
 Test 30 of 51 in resources/tests6.dat failed. Input:
 </frameset><frame>
 Got:
@@ -2449,48 +2410,6 @@ Got:
 Expected:
 | <tr>
 
-Test 38 of 51 in resources/tests6.dat failed. Input:
-<table><tbody></thead>
-Got:
-| <html>
-|   <head>
-|   <body>
-|     <table>
-Expected:
-| <html>
-|   <head>
-|   <body>
-|     <table>
-|       <tbody>
-
-Test 40 of 51 in resources/tests6.dat failed. Input:
-<table><tbody></body></caption></col></colgroup></html></td></th></tr>
-Got:
-| <html>
-|   <head>
-|   <body>
-|     <table>
-Expected:
-| <html>
-|   <head>
-|   <body>
-|     <table>
-|       <tbody>
-
-Test 41 of 51 in resources/tests6.dat failed. Input:
-<table><tbody></div>
-Got:
-| <html>
-|   <head>
-|   <body>
-|     <table>
-Expected:
-| <html>
-|   <head>
-|   <body>
-|     <table>
-|       <tbody>
-
 Test 42 of 51 in resources/tests6.dat failed. Input:
 <table><table>
 Got:
@@ -2661,6 +2580,8 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <style>
+|         " <tr>x "
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -2679,6 +2600,7 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <tbody>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -3286,6 +3208,7 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <tbody>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -3307,6 +3230,7 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <tbody>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -3329,6 +3253,7 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <tbody>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -3352,6 +3277,7 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <tbody>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -3377,6 +3303,7 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <caption>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -3400,6 +3327,7 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <caption>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -3425,6 +3353,7 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <caption>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -3449,6 +3378,7 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <colgroup>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -3788,6 +3718,7 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <tbody>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -3809,6 +3740,7 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <tbody>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -3831,6 +3763,7 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <tbody>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -3854,6 +3787,7 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <tbody>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -3879,6 +3813,7 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <caption>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -3902,6 +3837,7 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <caption>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -3927,6 +3863,7 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <caption>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -3951,6 +3888,7 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <colgroup>
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -5360,6 +5298,8 @@ Got:
 |   <head>
 |   <body>
 |     <table>
+|       <style>
+|         " <tr>x "
 Expected:
 | <!DOCTYPE html>
 | <html>
index 701b25a..fd396d1 100644 (file)
@@ -1,3 +1,28 @@
+2010-07-04  Eric Seidel  <eric@webkit.org>
+
+        Reviewed by Adam Barth.
+
+        Add a very basic InTable insertion mode
+        https://bugs.webkit.org/show_bug.cgi?id=41581
+
+        There is still a bunch of low-hanging fruit left for this
+        mode, but even this most-basic support lets us pass 6 more tests. :)
+
+        It's a progression, ship it! :)
+
+        * html/HTMLElementStack.cpp:
+        (WebCore::HTMLNames::isScopeMarker):
+        (WebCore::HTMLNames::isListItemScopeMarker):
+        (WebCore::HTMLNames::isTableScopeMarker):
+        (WebCore::HTMLElementStack::popUntilTableScopeMarker):
+        * html/HTMLElementStack.h:
+        * html/HTMLFormattingElementList.cpp:
+        (WebCore::HTMLFormattingElementList::appendMarker):
+        * html/HTMLFormattingElementList.h:
+        * html/HTMLTreeBuilder.cpp:
+        (WebCore::HTMLTreeBuilder::processStartTag):
+        * html/HTMLTreeBuilder.h:
+
 2010-07-01  Eric Seidel  <eric@webkit.org>
 
         Reviewed by Adam Barth.
index 3865897..c0348cb 100644 (file)
@@ -38,6 +38,38 @@ namespace WebCore {
 
 using namespace HTMLNames;
 
+namespace {
+
+inline bool isScopeMarker(Element* element)
+{
+    return element->hasTagName(appletTag)
+        || element->hasTagName(buttonTag)
+        || element->hasTagName(captionTag)
+#if ENABLE(SVG_FOREIGN_OBJECT)
+        || element->hasTagName(SVGNames::foreignObjectTag)
+#endif
+        || element->hasTagName(htmlTag)
+        || element->hasTagName(marqueeTag)
+        || element->hasTagName(objectTag)
+        || element->hasTagName(tableTag)
+        || element->hasTagName(tdTag)
+        || element->hasTagName(thTag);
+}
+
+inline bool isListItemScopeMarker(Element* element)
+{
+    return isScopeMarker(element)
+        || element->hasTagName(olTag)
+        || element->hasTagName(ulTag);
+}
+inline bool isTableScopeMarker(Element* element)
+{
+    return element->hasTagName(htmlTag)
+        || element->hasTagName(tableTag);
+}
+
+}
+
 HTMLElementStack::ElementRecord::ElementRecord(PassRefPtr<Element> element, PassOwnPtr<ElementRecord> next)
     : m_element(element)
     , m_next(next)
@@ -111,6 +143,13 @@ void HTMLElementStack::popUntil(Element* element)
         pop();
 }
 
+void HTMLElementStack::popUntilTableScopeMarker()
+{
+    // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#clear-the-stack-back-to-a-table-context
+    while (!isTableScopeMarker(top()))
+        pop();
+}
+
 void HTMLElementStack::pushHTMLHtmlElement(PassRefPtr<Element> element)
 {
     ASSERT(!m_top); // <html> should always be the bottom of the stack.
@@ -229,39 +268,6 @@ bool HTMLElementStack::contains(Element* element) const
     return !!find(element);
 }
 
-namespace {
-
-inline bool isScopeMarker(Element* element)
-{
-    return element->hasTagName(appletTag)
-        || element->hasTagName(buttonTag)
-        || element->hasTagName(captionTag)
-        || element->hasTagName(htmlTag)
-        || element->hasTagName(marqueeTag)
-        || element->hasTagName(objectTag)
-        || element->hasTagName(tableTag)
-        || element->hasTagName(tdTag)
-        || element->hasTagName(thTag)
-#if ENABLE(SVG_FOREIGN_OBJECT)
-        || element->hasTagName(SVGNames::foreignObjectTag)
-#endif
-        ;
-}
-
-inline bool isListItemScopeMarker(Element* element)
-{
-    return isScopeMarker(element)
-        || element->hasTagName(olTag)
-        || element->hasTagName(ulTag);
-}
-inline bool isTableScopeMarker(Element* element)
-{
-    return element->hasTagName(htmlTag)
-        || element->hasTagName(tableTag);
-}
-
-}
-
 template <bool isMarker(Element*)>
 bool inScopeCommon(HTMLElementStack::ElementRecord* top, const AtomicString& targetTag)
 {
index df290d4..0e2c779 100644 (file)
@@ -82,6 +82,7 @@ public:
     void pop();
     void popUntil(const AtomicString& tagName);
     void popUntil(Element*);
+    void popUntilTableScopeMarker(); // "clear the stack back to a table context" in the spec.
     void popHTMLHeadElement();
     void popHTMLBodyElement();
 
index f8e1dd5..0198261 100644 (file)
@@ -121,6 +121,11 @@ void HTMLFormattingElementList::remove(Element* element)
         m_entries.remove(index);
 }
 
+void HTMLFormattingElementList::appendMarker()
+{
+    m_entries.append(Entry::MarkerEntry);
+}
+
 void HTMLFormattingElementList::clearToLastMarker()
 {
     while (m_entries.size() && !m_entries.last().isMarker())
index d613a86..da30f75 100644 (file)
@@ -73,6 +73,8 @@ public:
     bool contains(Element*);
     void append(Element*);
     void remove(Element*);
+
+    void appendMarker();
     void clearToLastMarker();
 
     const Entry& operator[](size_t i) const { return m_entries[i]; }
index 160dd48..4850cfc 100644 (file)
@@ -723,6 +723,57 @@ void HTMLTreeBuilder::processStartTag(AtomicHTMLToken& token)
         reconstructTheActiveFormattingElements();
         insertElement(token);
         break;
+    case InTableMode:
+        ASSERT(insertionMode() == InTableMode);
+        if (token.name() == captionTag) {
+            m_openElements.popUntilTableScopeMarker();
+            m_activeFormattingElements.appendMarker();
+            insertElement(token);
+            m_insertionMode = InCaptionMode;
+            return;
+        }
+        if (token.name() == colgroupTag) {
+            m_openElements.popUntilTableScopeMarker();
+            insertElement(token);
+            m_insertionMode = InColumnGroupMode;
+            return;
+        }
+        if (token.name() == colTag) {
+            notImplemented();
+            return;
+        }
+        if (token.name() == tbodyTag || token.name() == tfootTag || token.name() == theadTag) {
+            m_openElements.popUntilTableScopeMarker();
+            insertElement(token);
+            m_insertionMode = InTableBodyMode;
+            return;
+        }
+        if (token.name() == tdTag || token.name() == thTag || token.name() == trTag) {
+            notImplemented();
+            return;
+        }
+        if (token.name() == tableTag) {
+            notImplemented();
+            return;
+        }
+        if (token.name() == styleTag || token.name() == scriptTag) {
+            processStartTagForInHead(token);
+            return;
+        }
+        if (token.name() == inputTag) {
+            notImplemented();
+            return;
+        }
+        if (token.name() == formTag) {
+            parseError(token);
+            if (m_formElement)
+                return;
+            insertSelfClosingElement(token);
+            return;
+        }
+        parseError(token);
+        notImplemented();
+        break;
     case AfterBodyMode:
     case AfterAfterBodyMode:
         ASSERT(insertionMode() == AfterBodyMode || insertionMode() == AfterAfterBodyMode);
index bb76b9c..37e4279 100644 (file)
@@ -169,7 +169,6 @@ private:
 
     bool indexOfFirstUnopenFormattingElement(unsigned& firstUnopenElementIndex) const;
     void reconstructTheActiveFormattingElements();
-    void clearActiveFormatingElementsUpToLastMarker() { }
 
     void generateImpliedEndTags();
     void generateImpliedEndTagsWithExclusion(const AtomicString& tagName);