2010-07-28 Adam Barth <abarth@webkit.org>
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Jul 2010 22:31:36 +0000 (22:31 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Jul 2010 22:31:36 +0000 (22:31 +0000)
        Reviewed by Eric Seidel.

        Update numbered header element closing to match recent spec change
        https://bugs.webkit.org/show_bug.cgi?id=43072

        * html5lib/runner-expected-html5.txt:
2010-07-28  Adam Barth  <abarth@webkit.org>

        Reviewed by Eric Seidel.

        Update numbered header element closing to match recent spec change
        https://bugs.webkit.org/show_bug.cgi?id=43072

        Pretty straightforward transcription of the spec change.

        * html/HTMLElementStack.cpp:
        (WebCore::HTMLNames::isNumberedHeaderElement):
        (WebCore::HTMLElementStack::popUntilNumberedHeaderElementPopped):
        (WebCore::HTMLElementStack::hasOnlyHTMLElementsInScope):
        (WebCore::HTMLElementStack::hasNumberedHeaderElementInScope):
        * html/HTMLElementStack.h:
        * html/HTMLTreeBuilder.cpp:
        (WebCore::HTMLTreeBuilder::HTMLTreeBuilder):
        (WebCore::HTMLTreeBuilder::processEndTagForInBody):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@64237 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 859f939..91588cb 100644 (file)
@@ -1,3 +1,12 @@
+2010-07-28  Adam Barth  <abarth@webkit.org>
+
+        Reviewed by Eric Seidel.
+
+        Update numbered header element closing to match recent spec change
+        https://bugs.webkit.org/show_bug.cgi?id=43072
+
+        * html5lib/runner-expected-html5.txt:
+
 2010-07-28  Eric Seidel  <eric@webkit.org>
 
         No review.  Skipping test to restore peace and justice.
index 892a563..3a5442b 100644 (file)
@@ -161,8 +161,6 @@ resources/tests17.dat: PASS
 resources/tests18.dat: PASS
 
 resources/tests19.dat:
-22
-24
 63
 77
 78
@@ -171,49 +169,6 @@ resources/tests19.dat:
 101
 102
 
-Test 22 of 102 in resources/tests19.dat failed. Input:
-<!doctype html><h1><div><h3><span></h1>foo
-Got:
-| <!DOCTYPE html>
-| <html>
-|   <head>
-|   <body>
-|     <h1>
-|       <div>
-|         <h3>
-|           <span>
-|     "foo"
-Expected:
-| <!DOCTYPE html>
-| <html>
-|   <head>
-|   <body>
-|     <h1>
-|       <div>
-|         <h3>
-|           <span>
-|         "foo"
-
-Test 24 of 102 in resources/tests19.dat failed. Input:
-<!doctype html><h3><li>abc</h2>foo
-Got:
-| <!DOCTYPE html>
-| <html>
-|   <head>
-|   <body>
-|     <h3>
-|       <li>
-|         "abcfoo"
-Expected:
-| <!DOCTYPE html>
-| <html>
-|   <head>
-|   <body>
-|     <h3>
-|       <li>
-|         "abc"
-|     "foo"
-
 Test 63 of 102 in resources/tests19.dat failed. Input:
 <!doctype html><keygen><frameset>
 Got:
index 9b9e727..2e5945f 100644 (file)
@@ -1,3 +1,22 @@
+2010-07-28  Adam Barth  <abarth@webkit.org>
+
+        Reviewed by Eric Seidel.
+
+        Update numbered header element closing to match recent spec change
+        https://bugs.webkit.org/show_bug.cgi?id=43072
+
+        Pretty straightforward transcription of the spec change.
+
+        * html/HTMLElementStack.cpp:
+        (WebCore::HTMLNames::isNumberedHeaderElement):
+        (WebCore::HTMLElementStack::popUntilNumberedHeaderElementPopped):
+        (WebCore::HTMLElementStack::hasOnlyHTMLElementsInScope):
+        (WebCore::HTMLElementStack::hasNumberedHeaderElementInScope):
+        * html/HTMLElementStack.h:
+        * html/HTMLTreeBuilder.cpp:
+        (WebCore::HTMLTreeBuilder::HTMLTreeBuilder):
+        (WebCore::HTMLTreeBuilder::processEndTagForInBody):
+
 2010-07-28  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Sam Weinig.
index 75ae751..531a3b4 100644 (file)
@@ -40,6 +40,16 @@ using namespace HTMLNames;
 
 namespace {
 
+inline bool isNumberedHeaderElement(Element* element)
+{
+    return element->hasTagName(h1Tag)
+        || element->hasTagName(h2Tag)
+        || element->hasTagName(h3Tag)
+        || element->hasTagName(h4Tag)
+        || element->hasTagName(h5Tag)
+        || element->hasTagName(h6Tag);
+}
+
 inline bool isScopeMarker(Element* element)
 {
     return element->hasTagName(appletTag)
@@ -180,6 +190,13 @@ void HTMLElementStack::popUntilPopped(const AtomicString& tagName)
     pop();
 }
 
+void HTMLElementStack::popUntilNumberedHeaderElementPopped()
+{
+    while (!isNumberedHeaderElement(top()))
+        pop();
+    pop();
+}
+
 void HTMLElementStack::popUntil(Element* element)
 {
     while (top() != element)
@@ -367,6 +384,19 @@ bool HTMLElementStack::hasOnlyHTMLElementsInScope() const
     return true;
 }
 
+bool HTMLElementStack::hasNumberedHeaderElementInScope() const
+{
+    for (ElementRecord* record = m_top.get(); record; record = record->next()) {
+        Element* element = record->element();
+        if (isNumberedHeaderElement(element))
+            return true;
+        if (isScopeMarker(element))
+            return false;
+    }
+    ASSERT_NOT_REACHED(); // <html> is always on the stack and is a scope marker.
+    return false;
+}
+
 bool HTMLElementStack::inScope(Element* targetElement) const
 {
     for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) {
index 7fc4043..62d031f 100644 (file)
@@ -94,6 +94,7 @@ public:
     void popUntil(Element*);
     void popUntilPopped(const AtomicString& tagName);
     void popUntilPopped(Element*);
+    void popUntilNumberedHeaderElementPopped();
     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.
@@ -118,6 +119,7 @@ public:
     bool inButtonScope(const QualifiedName&) const;
 
     bool hasOnlyHTMLElementsInScope() const;
+    bool hasNumberedHeaderElementInScope() const;
 
     Element* htmlElement() const;
     Element* headElement() const;
index 0a5c859..ec15f9f 100644 (file)
@@ -2008,14 +2008,14 @@ void HTMLTreeBuilder::processEndTagForInBody(AtomicHTMLToken& token)
         return;
     }
     if (isNumberedHeaderTag(token.name())) {
-        if (!m_tree.openElements()->inScope(token.name())) {
+        if (!m_tree.openElements()->hasNumberedHeaderElementInScope()) {
             parseError(token);
             return;
         }
         m_tree.generateImpliedEndTags();
         if (!m_tree.currentElement()->hasLocalName(token.name()))
             parseError(token);
-        m_tree.openElements()->popUntilPopped(token.name());
+        m_tree.openElements()->popUntilNumberedHeaderElementPopped();
         return;
     }
     if (token.name() == "sarcasm") {