2010-07-09 Eric Seidel <eric@webkit.org>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Jul 2010 07:48:06 +0000 (07:48 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Jul 2010 07:48:06 +0000 (07:48 +0000)
        Reviewed by Adam Barth.

        Add new popUntilPopped functions to clean up code
        https://bugs.webkit.org/show_bug.cgi?id=41936

        Pretty self explanatory.  Much awesome code reduction.

        No functional changes, thus no tests.

        * html/HTMLElementStack.cpp:
        (WebCore::HTMLElementStack::popUntilPopped):
        * html/HTMLElementStack.h:
        * html/HTMLTreeBuilder.cpp:
        (WebCore::HTMLTreeBuilder::processAnyOtherEndTagForInBody):
        (WebCore::HTMLTreeBuilder::callTheAdoptionAgency):
        (WebCore::HTMLTreeBuilder::processEndTagForInBody):
        (WebCore::HTMLTreeBuilder::processCaptionEndTagForInCaption):
        (WebCore::HTMLTreeBuilder::processTableEndTagForInTable):
        (WebCore::HTMLTreeBuilder::processEndTag):

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

WebCore/ChangeLog
WebCore/html/HTMLElementStack.cpp
WebCore/html/HTMLElementStack.h
WebCore/html/HTMLTreeBuilder.cpp

index 0640203..9d7409a 100644 (file)
@@ -1,5 +1,27 @@
 2010-07-09  Eric Seidel  <eric@webkit.org>
 
+        Reviewed by Adam Barth.
+
+        Add new popUntilPopped functions to clean up code
+        https://bugs.webkit.org/show_bug.cgi?id=41936
+
+        Pretty self explanatory.  Much awesome code reduction.
+
+        No functional changes, thus no tests.
+
+        * html/HTMLElementStack.cpp:
+        (WebCore::HTMLElementStack::popUntilPopped):
+        * html/HTMLElementStack.h:
+        * html/HTMLTreeBuilder.cpp:
+        (WebCore::HTMLTreeBuilder::processAnyOtherEndTagForInBody):
+        (WebCore::HTMLTreeBuilder::callTheAdoptionAgency):
+        (WebCore::HTMLTreeBuilder::processEndTagForInBody):
+        (WebCore::HTMLTreeBuilder::processCaptionEndTagForInCaption):
+        (WebCore::HTMLTreeBuilder::processTableEndTagForInTable):
+        (WebCore::HTMLTreeBuilder::processEndTag):
+
+2010-07-09  Eric Seidel  <eric@webkit.org>
+
         Unreviewed.  Just renaming (discussed with Adam Barth).
 
         Rename createElement* to createHTMLElement* to better reflect
index 9f815c9..a20525c 100644 (file)
@@ -152,12 +152,24 @@ void HTMLElementStack::popUntil(const AtomicString& tagName)
     }
 }
 
+void HTMLElementStack::popUntilPopped(const AtomicString& tagName)
+{
+    popUntil(tagName);
+    pop();
+}
+
 void HTMLElementStack::popUntil(Element* element)
 {
     while (top() != element)
         pop();
 }
 
+void HTMLElementStack::popUntilPopped(Element* element)
+{
+    popUntil(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
index 07f6e60..86b6b1a 100644 (file)
@@ -84,6 +84,8 @@ public:
     void pop();
     void popUntil(const AtomicString& tagName);
     void popUntil(Element*);
+    void popUntilPopped(const AtomicString& tagName);
+    void popUntilPopped(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 popUntilTableRowScopeMarker(); // "clear the stack back to a table row context" in the spec.
index ebf24ad..3531e6c 100644 (file)
@@ -1302,8 +1302,7 @@ void HTMLTreeBuilder::processAnyOtherEndTagForInBody(AtomicHTMLToken& token)
                 if (!m_tree.openElements()->contains(node))
                     return;
             }
-            m_tree.openElements()->popUntil(node);
-            m_tree.openElements()->pop();
+            m_tree.openElements()->popUntilPopped(node);
             return;
         }
         if (isNotFormattingAndNotPhrasing(node)) {
@@ -1366,8 +1365,7 @@ void HTMLTreeBuilder::callTheAdoptionAgency(AtomicHTMLToken& token)
         HTMLElementStack::ElementRecord* furthestBlock = furthestBlockForFormattingElement(formattingElement);
         // 3.
         if (!furthestBlock) {
-            m_tree.openElements()->popUntil(formattingElement);
-            m_tree.openElements()->pop();
+            m_tree.openElements()->popUntilPopped(formattingElement);
             m_tree.activeFormattingElements()->remove(formattingElement);
             return;
         }
@@ -1557,8 +1555,7 @@ void HTMLTreeBuilder::processEndTagForInBody(AtomicHTMLToken& token)
         m_tree.generateImpliedEndTags();
         if (!m_tree.currentElement()->hasLocalName(token.name()))
             parseError(token);
-        m_tree.openElements()->popUntil(token.name());
-        m_tree.openElements()->pop();
+        m_tree.openElements()->popUntilPopped(token.name());
         return;
     }
     if (token.name() == formTag) {
@@ -1583,8 +1580,7 @@ void HTMLTreeBuilder::processEndTagForInBody(AtomicHTMLToken& token)
         m_tree.generateImpliedEndTagsWithExclusion(token.name());
         if (!m_tree.currentElement()->hasLocalName(token.name()))
             parseError(token);
-        m_tree.openElements()->popUntil(token.name());
-        m_tree.openElements()->pop();
+        m_tree.openElements()->popUntilPopped(token.name());
         return;
     }
     if (token.name() == liTag) {
@@ -1595,8 +1591,7 @@ void HTMLTreeBuilder::processEndTagForInBody(AtomicHTMLToken& token)
         m_tree.generateImpliedEndTagsWithExclusion(token.name());
         if (!m_tree.currentElement()->hasLocalName(token.name()))
             parseError(token);
-        m_tree.openElements()->popUntil(token.name());
-        m_tree.openElements()->pop();
+        m_tree.openElements()->popUntilPopped(token.name());
         return;
     }
     if (token.name() == ddTag
@@ -1608,8 +1603,7 @@ void HTMLTreeBuilder::processEndTagForInBody(AtomicHTMLToken& token)
         m_tree.generateImpliedEndTagsWithExclusion(token.name());
         if (!m_tree.currentElement()->hasLocalName(token.name()))
             parseError(token);
-        m_tree.openElements()->popUntil(token.name());
-        m_tree.openElements()->pop();
+        m_tree.openElements()->popUntilPopped(token.name());
         return;
     }
     if (isNumberedHeaderTag(token.name())) {
@@ -1620,8 +1614,7 @@ void HTMLTreeBuilder::processEndTagForInBody(AtomicHTMLToken& token)
         m_tree.generateImpliedEndTags();
         if (!m_tree.currentElement()->hasLocalName(token.name()))
             parseError(token);
-        m_tree.openElements()->popUntil(token.name());
-        m_tree.openElements()->pop();
+        m_tree.openElements()->popUntilPopped(token.name());
         return;
     }
     if (token.name() == "sarcasm") {
@@ -1642,8 +1635,7 @@ void HTMLTreeBuilder::processEndTagForInBody(AtomicHTMLToken& token)
         m_tree.generateImpliedEndTags();
         if (!m_tree.currentElement()->hasLocalName(token.name()))
             parseError(token);
-        m_tree.openElements()->popUntil(token.name());
-        m_tree.openElements()->pop();
+        m_tree.openElements()->popUntilPopped(token.name());
         m_tree.activeFormattingElements()->clearToLastMarker();
         return;
     }
@@ -1664,8 +1656,7 @@ bool HTMLTreeBuilder::processCaptionEndTagForInCaption()
     }
     m_tree.generateImpliedEndTags();
     // FIXME: parse error if (!m_tree.currentElement()->hasTagName(captionTag))
-    m_tree.openElements()->popUntil(captionTag.localName());
-    m_tree.openElements()->pop();
+    m_tree.openElements()->popUntilPopped(captionTag.localName());
     m_tree.activeFormattingElements()->clearToLastMarker();
     m_insertionMode = InTableMode;
     return true;
@@ -1692,8 +1683,7 @@ bool HTMLTreeBuilder::processTableEndTagForInTable()
         // FIXME: parse error.
         return false;
     }
-    m_tree.openElements()->popUntil(tableTag.localName());
-    m_tree.openElements()->pop();
+    m_tree.openElements()->popUntilPopped(tableTag.localName());
     resetInsertionModeAppropriately();
     return true;
 }
@@ -1859,8 +1849,7 @@ void HTMLTreeBuilder::processEndTag(AtomicHTMLToken& token)
             m_tree.generateImpliedEndTags();
             if (!m_tree.currentElement()->hasLocalName(token.name()))
                 parseError(token);
-            m_tree.openElements()->popUntil(token.name());
-            m_tree.openElements()->pop();
+            m_tree.openElements()->popUntilPopped(token.name());
             m_tree.activeFormattingElements()->clearToLastMarker();
             m_insertionMode = InRowMode;
             ASSERT(m_tree.currentElement()->hasTagName(trTag));
@@ -2031,8 +2020,7 @@ void HTMLTreeBuilder::processEndTag(AtomicHTMLToken& token)
         }
         if (token.name() == selectTag) {
             notImplemented(); // fragment case
-            m_tree.openElements()->popUntil(selectTag.localName());
-            m_tree.openElements()->pop();
+            m_tree.openElements()->popUntilPopped(selectTag.localName());
             resetInsertionModeAppropriately();
             return;
         }