2010-07-21 Adam Barth <abarth@webkit.org>
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Jul 2010 01:00:46 +0000 (01:00 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Jul 2010 01:00:46 +0000 (01:00 +0000)
        Reviewed by Eric Seidel.

        HTMLTreeBuilder needs to update to match new spec behavior for <button>
        https://bugs.webkit.org/show_bug.cgi?id=42233

        The spec has some typos in this area, but this is my best guess for
        what Ian means.  I've filed bugs against the spec for each typo.

        * html/HTMLElementStack.cpp:
        (WebCore::HTMLNames::isScopeMarker):
        (WebCore::HTMLNames::isButtonScopeMarker):
        (WebCore::HTMLElementStack::inButtonScope):
        * html/HTMLElementStack.h:
        * html/HTMLTreeBuilder.cpp:
        (WebCore::HTMLTreeBuilder::processFakePEndTagIfPInButtonScope):
        (WebCore::HTMLTreeBuilder::processCloseWhenNestedTag):
        (WebCore::HTMLTreeBuilder::processStartTagForInBody):
        (WebCore::HTMLTreeBuilder::processEndTagForInBody):
        * html/HTMLTreeBuilder.h:
2010-07-21  Adam Barth  <abarth@webkit.org>

        Reviewed by Eric Seidel.

        HTMLTreeBuilder needs to update to match new spec behavior for <button>
        https://bugs.webkit.org/show_bug.cgi?id=42233

        Test progression.  There's one regression mixed in here.  I'll
        investigate in the next patch.

        * html5lib/runner-expected-html5.txt:

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

index 1cdd81c..77e83b2 100644 (file)
@@ -1,3 +1,15 @@
+2010-07-21  Adam Barth  <abarth@webkit.org>
+
+        Reviewed by Eric Seidel.
+
+        HTMLTreeBuilder needs to update to match new spec behavior for <button>
+        https://bugs.webkit.org/show_bug.cgi?id=42233
+
+        Test progression.  There's one regression mixed in here.  I'll
+        investigate in the next patch.
+
+        * html5lib/runner-expected-html5.txt:
+
 2010-07-21  Justin Schuh  <jschuh@chromium.org>
 
         Unreviewed. Build fix.
index d9eb5f2..f010234 100644 (file)
@@ -10,44 +10,8 @@ CONSOLE MESSAGE: line 1: SyntaxError: Parse error
 CONSOLE MESSAGE: line 2: PASS
 CONSOLE MESSAGE: line 2: FOO<span>BAR</span>BAZ
 Content-Type: text/plain
-resources/tests1.dat:
-24
-98
-
-Test 24 of 114 in resources/tests1.dat failed. Input:
-<b><button>foo</b>bar
-Got:
-| <html>
-|   <head>
-|   <body>
-|     <b>
-|       <button>
-|         "foobar"
-Expected:
-| <html>
-|   <head>
-|   <body>
-|     <b>
-|     <button>
-|       <b>
-|         "foo"
-|       "bar"
+resources/tests1.dat: PASS
 
-Test 98 of 114 in resources/tests1.dat failed. Input:
-<b><button></b></button></b>
-Got:
-| <html>
-|   <head>
-|   <body>
-|     <b>
-|       <button>
-Expected:
-| <html>
-|   <head>
-|   <body>
-|     <b>
-|     <button>
-|       <b>
 resources/tests2.dat: PASS
 
 resources/tests3.dat: PASS
@@ -467,48 +431,29 @@ Expected:
 |       <article>
 |     "a"
 resources/tests20.dat:
-20
-21
+16
 24
 25
 
-Test 20 of 25 in resources/tests20.dat failed. Input:
-<!doctype html><address><button></address>a
+Test 16 of 25 in resources/tests20.dat failed. Input:
+<!doctype html><p><button><table>
 Got:
 | <!DOCTYPE html>
 | <html>
 |   <head>
 |   <body>
-|     <address>
-|       <button>
-|         "a"
-Expected:
-| <!DOCTYPE html>
-| <html>
-|   <head>
-|   <body>
-|     <address>
-|       <button>
-|     "a"
-
-Test 21 of 25 in resources/tests20.dat failed. Input:
-<!doctype html><address><button></address>a
-Got:
-| <!DOCTYPE html>
-| <html>
-|   <head>
-|   <body>
-|     <address>
+|     <p>
 |       <button>
-|         "a"
+|         <p>
+|         <table>
 Expected:
 | <!DOCTYPE html>
 | <html>
 |   <head>
 |   <body>
-|     <address>
+|     <p>
 |       <button>
-|     "a"
+|         <table>
 
 Test 24 of 25 in resources/tests20.dat failed. Input:
 <!doctype html><p><figcaption>
@@ -888,30 +833,8 @@ resources/entities02.dat: PASS
 resources/comments01.dat: PASS
 
 resources/adoption01.dat:
-3
 12
 
-Test 3 of 12 in resources/adoption01.dat failed. Input:
-<a>1<button>2</a>3</button>
-Got:
-| <html>
-|   <head>
-|   <body>
-|     <a>
-|       "1"
-|       <button>
-|         "23"
-Expected:
-| <html>
-|   <head>
-|   <body>
-|     <a>
-|       "1"
-|     <button>
-|       <a>
-|         "2"
-|       "3"
-
 Test 12 of 12 in resources/adoption01.dat failed. Input:
 <table>A<td>B</td>C</table>
 Got:
index 3aa7b8c..86a2118 100644 (file)
@@ -1,3 +1,25 @@
+2010-07-21  Adam Barth  <abarth@webkit.org>
+
+        Reviewed by Eric Seidel.
+
+        HTMLTreeBuilder needs to update to match new spec behavior for <button>
+        https://bugs.webkit.org/show_bug.cgi?id=42233
+
+        The spec has some typos in this area, but this is my best guess for
+        what Ian means.  I've filed bugs against the spec for each typo.
+
+        * html/HTMLElementStack.cpp:
+        (WebCore::HTMLNames::isScopeMarker):
+        (WebCore::HTMLNames::isButtonScopeMarker):
+        (WebCore::HTMLElementStack::inButtonScope):
+        * html/HTMLElementStack.h:
+        * html/HTMLTreeBuilder.cpp:
+        (WebCore::HTMLTreeBuilder::processFakePEndTagIfPInButtonScope):
+        (WebCore::HTMLTreeBuilder::processCloseWhenNestedTag):
+        (WebCore::HTMLTreeBuilder::processStartTagForInBody):
+        (WebCore::HTMLTreeBuilder::processEndTagForInBody):
+        * html/HTMLTreeBuilder.h:
+
 2010-07-21  Justin Schuh  <jschuh@chromium.org>
 
         Reviewed by Oliver Hunt.
index 5c325e5..f3e78f5 100644 (file)
@@ -43,7 +43,6 @@ 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)
@@ -83,6 +82,12 @@ inline bool isTableRowScopeMarker(Element* element)
         || element->hasTagName(htmlTag);
 }
 
+inline bool isButtonScopeMarker(Element* element)
+{
+    return isScopeMarker(element)
+        || element->hasTagName(buttonTag);
+}
+
 }
 
 HTMLElementStack::ElementRecord::ElementRecord(PassRefPtr<Element> element, PassOwnPtr<ElementRecord> next)
@@ -414,6 +419,17 @@ bool HTMLElementStack::inTableScope(const QualifiedName& tagName) const
     return inTableScope(tagName.localName());
 }
 
+bool HTMLElementStack::inButtonScope(const AtomicString& targetTag) const
+{
+    return inScopeCommon<isButtonScopeMarker>(m_top.get(), targetTag);
+}
+
+bool HTMLElementStack::inButtonScope(const QualifiedName& tagName) const
+{
+    // FIXME: Is localName() right for non-html elements?
+    return inButtonScope(tagName.localName());
+}
+
 Element* HTMLElementStack::htmlElement() const
 {
     ASSERT(m_htmlElement);
index 830faf0..5969c80 100644 (file)
@@ -107,6 +107,8 @@ public:
     bool inListItemScope(const QualifiedName&) const;
     bool inTableScope(const AtomicString& tagName) const;
     bool inTableScope(const QualifiedName&) const;
+    bool inButtonScope(const AtomicString& tagName) const;
+    bool inButtonScope(const QualifiedName&) const;
 
     bool hasOnlyHTMLElementsInScope() const;
 
index 93da3f7..13b6f5c 100644 (file)
@@ -183,7 +183,6 @@ bool isSpecialTag(const AtomicString& tagName)
 bool isScopingTag(const AtomicString& tagName)
 {
     return tagName == appletTag
-        || tagName == buttonTag
         || tagName == captionTag
         || tagName == SVGNames::foreignObjectTag
         || tagName == htmlTag
@@ -572,9 +571,9 @@ void HTMLTreeBuilder::processFakeCharacters(const String& characters)
     processCharacterBuffer(buffer);
 }
 
-void HTMLTreeBuilder::processFakePEndTagIfPInScope()
+void HTMLTreeBuilder::processFakePEndTagIfPInButtonScope()
 {
-    if (!m_tree.openElements()->inScope(pTag.localName()))
+    if (!m_tree.openElements()->inButtonScope(pTag.localName()))
         return;
     AtomicHTMLToken endP(HTMLToken::EndTag, pTag.localName());
     processEndTag(endP);
@@ -654,7 +653,7 @@ void HTMLTreeBuilder::processCloseWhenNestedTag(AtomicHTMLToken& token)
             break;
         nodeRecord = nodeRecord->next();
     }
-    processFakePEndTagIfPInScope();
+    processFakePEndTagIfPInButtonScope();
     m_tree.insertHTMLElement(token);
 }
 
@@ -820,12 +819,12 @@ void HTMLTreeBuilder::processStartTagForInBody(AtomicHTMLToken& token)
         || token.name() == pTag
         || token.name() == sectionTag
         || token.name() == ulTag) {
-        processFakePEndTagIfPInScope();
+        processFakePEndTagIfPInButtonScope();
         m_tree.insertHTMLElement(token);
         return;
     }
     if (isNumberedHeaderTag(token.name())) {
-        processFakePEndTagIfPInScope();
+        processFakePEndTagIfPInButtonScope();
         if (isNumberedHeaderTag(m_tree.currentElement()->localName())) {
             parseError(token);
             m_tree.openElements()->pop();
@@ -834,7 +833,7 @@ void HTMLTreeBuilder::processStartTagForInBody(AtomicHTMLToken& token)
         return;
     }
     if (token.name() == preTag || token.name() == listingTag) {
-        processFakePEndTagIfPInScope();
+        processFakePEndTagIfPInButtonScope();
         m_tree.insertHTMLElement(token);
         m_tokenizer->skipLeadingNewLineForListing();
         m_framesetOk = false;
@@ -845,7 +844,7 @@ void HTMLTreeBuilder::processStartTagForInBody(AtomicHTMLToken& token)
             parseError(token);
             return;
         }
-        processFakePEndTagIfPInScope();
+        processFakePEndTagIfPInButtonScope();
         m_tree.insertHTMLFormElement(token);
         return;
     }
@@ -858,7 +857,7 @@ void HTMLTreeBuilder::processStartTagForInBody(AtomicHTMLToken& token)
         return;
     }
     if (token.name() == plaintextTag) {
-        processFakePEndTagIfPInScope();
+        processFakePEndTagIfPInButtonScope();
         m_tree.insertHTMLElement(token);
         m_tokenizer->setState(HTMLTokenizer::PLAINTEXTState);
         return;
@@ -947,7 +946,7 @@ void HTMLTreeBuilder::processStartTagForInBody(AtomicHTMLToken& token)
         return;
     }
     if (token.name() == hrTag) {
-        processFakePEndTagIfPInScope();
+        processFakePEndTagIfPInButtonScope();
         m_tree.insertSelfClosingHTMLElement(token);
         m_framesetOk = false;
         return;
@@ -966,7 +965,7 @@ void HTMLTreeBuilder::processStartTagForInBody(AtomicHTMLToken& token)
         return;
     }
     if (token.name() == xmpTag) {
-        processFakePEndTagIfPInScope();
+        processFakePEndTagIfPInButtonScope();
         m_tree.reconstructTheActiveFormattingElements();
         m_framesetOk = false;
         processGenericRawTextStartTag(token);
@@ -1973,7 +1972,7 @@ void HTMLTreeBuilder::processEndTagForInBody(AtomicHTMLToken& token)
         m_tree.openElements()->remove(node.get());
     }
     if (token.name() == pTag) {
-        if (!m_tree.openElements()->inScope(token.name())) {
+        if (!m_tree.openElements()->inButtonScope(token.name())) {
             parseError(token);
             processFakeStartTag(pTag);
             ASSERT(m_tree.openElements()->inScope(token.name()));
index 0f87cb0..735c9f3 100644 (file)
@@ -140,7 +140,7 @@ private:
     void processFakeStartTag(const QualifiedName&, PassRefPtr<NamedNodeMap> attributes = 0);
     void processFakeEndTag(const QualifiedName&);
     void processFakeCharacters(const String&);
-    void processFakePEndTagIfPInScope();
+    void processFakePEndTagIfPInButtonScope();
 
     void processGenericRCDATAStartTag(AtomicHTMLToken&);
     void processGenericRawTextStartTag(AtomicHTMLToken&);