Skip to content
Permalink
Browse files
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):

Canonical link: https://commits.webkit.org/53799@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@62909 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
eseidel committed Jul 9, 2010
1 parent 78d5f5e commit df5d03126399a4b8ebdc3700c91752cd23137e73
Showing 4 changed files with 48 additions and 24 deletions.
@@ -1,3 +1,25 @@
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).
@@ -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
@@ -84,6 +84,8 @@ class HTMLElementStack : public Noncopyable {
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.
@@ -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;
}

0 comments on commit df5d031

Please sign in to comment.