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

        Finish implementing "any other end tag" for "in body" mode
        https://bugs.webkit.org/show_bug.cgi?id=41582

        * html5lib/resources/inbody01.dat: Added.
        * html5lib/runner-expected-html5.txt:
         - Update the one result which was affected by this.
           That test would pass if we had text node coalescing.
        * html5lib/runner-expected.txt:
         - Update to add the extra test suite.
        * html5lib/runner.html:

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

        I believe I found a "bug" in the HTML5 spec when writing this:
        http://www.w3.org/Bugs/Public/show_bug.cgi?id=10080

        * html/HTMLTreeBuilder.cpp:
        (WebCore::HTMLTreeBuilder::processAnyOtherEndTagForInBody):
        (WebCore::HTMLTreeBuilder::processEndTag):
        * html/HTMLTreeBuilder.h:

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

LayoutTests/ChangeLog
LayoutTests/html5lib/resources/inbody01.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/HTMLTreeBuilder.cpp
WebCore/html/HTMLTreeBuilder.h

index 3088966..416c140 100644 (file)
@@ -1,3 +1,19 @@
+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
+
+        * html5lib/resources/inbody01.dat: Added.
+        * html5lib/runner-expected-html5.txt:
+         - Update the one result which was affected by this.
+           That test would pass if we had text node coalescing.
+        * html5lib/runner-expected.txt:
+         - Update to add the extra test suite.
+        * html5lib/runner.html:
+
+
 2010-07-05  Yury Semikhatsky  <yury@yurys-imac.local>
 
         Unreviewed. Provide Chromium specific expectations for new svg tests.
diff --git a/LayoutTests/html5lib/resources/inbody01.dat b/LayoutTests/html5lib/resources/inbody01.dat
new file mode 100644 (file)
index 0000000..3f2bd37
--- /dev/null
@@ -0,0 +1,43 @@
+#data
+<button>1</foo>
+#errors
+#document
+| <html>
+|   <head>
+|   <body>
+|     <button>
+|       "1"
+
+#data
+<foo>1<p>2</foo>
+#errors
+#document
+| <html>
+|   <head>
+|   <body>
+|     <foo>
+|       "1"
+|       <p>
+|         "2"
+
+#data
+<dd>1</foo>
+#errors
+#document
+| <html>
+|   <head>
+|   <body>
+|     <dd>
+|       "1"
+
+#data
+<foo>1<dd>2</foo>
+#errors
+#document
+| <html>
+|   <head>
+|   <body>
+|     <foo>
+|       "1"
+|       <dd>
+|         "2"
index 53a551a..8e4cb60 100644 (file)
@@ -503,7 +503,7 @@ Got:
 |           "B"
 |           <div>
 |             "C"
-|         "D"
+|             "D"
 Expected:
 | <html>
 |   <head>
@@ -5583,4 +5583,5 @@ Expected:
 |         "2"
 |       "3"
 |     <table>
+resources/inbody01.dat: PASS
 #EOF
index d9be58e..ce1497d 100644 (file)
@@ -4935,3 +4935,4 @@ Expected:
 |         "2"
 |       "3"
 |     <table>
+resources/inbody01.dat: PASS
index f3052f0..bad2f5e 100644 (file)
@@ -59,7 +59,8 @@ var test_files = [
         'resources/entities01.dat',
         'resources/entities02.dat',
         'resources/comments01.dat',
-        'resources/adoption01.dat'
+        'resources/adoption01.dat',
+        'resources/inbody01.dat'
     ],
     tests = [],
     iframe = document.getElementsByTagName("iframe")[0],
index 129666d..96c93b7 100644 (file)
@@ -1,3 +1,18 @@
+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
+
+        I believe I found a "bug" in the HTML5 spec when writing this:
+        http://www.w3.org/Bugs/Public/show_bug.cgi?id=10080
+
+        * html/HTMLTreeBuilder.cpp:
+        (WebCore::HTMLTreeBuilder::processAnyOtherEndTagForInBody):
+        (WebCore::HTMLTreeBuilder::processEndTag):
+        * html/HTMLTreeBuilder.h:
+
 2010-07-05  Martin Robinson  <mrobinson@igalia.com>
 
         Unreviewed.
index b4e7ce1..bf0b7f1 100644 (file)
@@ -881,6 +881,37 @@ bool HTMLTreeBuilder::processBodyEndTagForInBody(AtomicHTMLToken& token)
     return true;
 }
 
+void HTMLTreeBuilder::processAnyOtherEndTagForInBody(AtomicHTMLToken& token)
+{
+    HTMLElementStack::ElementRecord* record = m_openElements.topRecord();
+    while (1) {
+        Element* node = record->element();
+        if (node->hasLocalName(token.name())) {
+            generateImpliedEndTags();
+            if (!currentElement()->hasLocalName(token.name())) {
+                parseError(token);
+                // FIXME: This is either a bug in the spec, or a bug in our
+                // implementation.  Filed a bug with HTML5:
+                // http://www.w3.org/Bugs/Public/show_bug.cgi?id=10080
+                // We might have already popped the node for the token in
+                // generateImpliedEndTags, just abort.
+                if (!m_openElements.contains(node))
+                    return;
+            }
+            m_openElements.popUntil(node);
+            m_openElements.pop();
+            return;
+        }
+        // !phrasing && !formatting == scoping || special
+        const AtomicString& tagName = node->localName();
+        if (isScopingTag(tagName) || isSpecialTag(tagName)) {
+            parseError(token);
+            return;
+        }
+        record = record->next();
+    }
+}
+
 // FIXME: This probably belongs on HTMLElementStack.
 HTMLElementStack::ElementRecord* HTMLTreeBuilder::furthestBlockForFormattingElement(Element* formattingElement)
 {
@@ -1189,13 +1220,7 @@ void HTMLTreeBuilder::processEndTag(AtomicHTMLToken& token)
             m_framesetOk = false;
             return;
         }
-        // FIXME: We need an iterator over m_openElements to implement this
-        // correctly.
-        notImplemented();
-        if (!m_openElements.inScope(token.name()))
-            return;
-        m_openElements.popUntil(token.name());
-        m_openElements.pop();
+        processAnyOtherEndTagForInBody(token);
         break;
     case AfterBodyMode:
         ASSERT(insertionMode() == AfterBodyMode);
index 37e4279..cb32a62 100644 (file)
@@ -123,6 +123,7 @@ private:
 
     bool processStartTagForInHead(AtomicHTMLToken&);
     bool processBodyEndTagForInBody(AtomicHTMLToken&);
+    void processAnyOtherEndTagForInBody(AtomicHTMLToken&);
     void processFakePEndTagIfPInScope();
 
     HTMLElementStack::ElementRecord* furthestBlockForFormattingElement(Element*);