Changeset 62207 in webkit


Ignore:
Timestamp:
Jun 30, 2010 2:45:19 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-06-30 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.

Add new popUntil(tagName) function and deploy
https://bugs.webkit.org/show_bug.cgi?id=41405

Add a new popUntil function to share some common code
between states. There is more code to share here, but this
is a start.

I also filled in a couple similar states to these with the
hope of sharing more code, but decided to wait for a later
patch.

No test changes, since this code doesn't do enough yet to
pass any more subtests. Lack of generateImpliedEndTags is the main
blocking issue.

  • html/HTMLElementStack.cpp: (WebCore::HTMLElementStack::popUntil):
  • html/HTMLElementStack.h:
  • html/HTMLTreeBuilder.cpp: (WebCore::HTMLTreeBuilder::processEndTag):
Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r62198 r62207  
     12010-06-30  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Add new popUntil(tagName) function and deploy
     6        https://bugs.webkit.org/show_bug.cgi?id=41405
     7
     8        Add a new popUntil function to share some common code
     9        between states.  There is more code to share here, but this
     10        is a start.
     11
     12        I also filled in a couple similar states to these with the
     13        hope of sharing more code, but decided to wait for a later
     14        patch.
     15
     16        No test changes, since this code doesn't do enough yet to
     17        pass any more subtests.  Lack of generateImpliedEndTags is the main
     18        blocking issue.
     19
     20        * html/HTMLElementStack.cpp:
     21        (WebCore::HTMLElementStack::popUntil):
     22        * html/HTMLElementStack.h:
     23        * html/HTMLTreeBuilder.cpp:
     24        (WebCore::HTMLTreeBuilder::processEndTag):
     25
    1262010-06-30  Xan Lopez  <xlopez@igalia.com>
    227
  • trunk/WebCore/html/HTMLElementStack.cpp

    r62196 r62207  
    7878}
    7979
     80void HTMLElementStack::popUntil(const AtomicString& tagName)
     81{
     82    while (!top()->hasLocalName(tagName)) {
     83        // pop() will ASSERT at <body> if callers fail to check that there is an
     84        // element with localName |tagName| on the stack of open elements.
     85        pop();
     86    }
     87}
     88
    8089void HTMLElementStack::pushHTMLHtmlElement(PassRefPtr<Element> element)
    8190{
  • trunk/WebCore/html/HTMLElementStack.h

    r62196 r62207  
    4949
    5050    void pop();
     51    void popUntil(const AtomicString& tagName);
    5152    void popHTMLHeadElement();
    5253
  • trunk/WebCore/html/HTMLTreeBuilder.cpp

    r62196 r62207  
    662662            if (currentElement()->tagQName() != token.name())
    663663                parseError(token);
    664             while (currentElement()->tagQName() != token.name())
    665                 m_openElements.pop();
     664            m_openElements.popUntil(token.name());
    666665            m_openElements.pop();
    667666        }
     
    682681        }
    683682        if (token.name() == liTag) {
     683            if (!m_openElements.inListItemScope(token.name())) {
     684                parseError(token);
     685                return;
     686            }
    684687            notImplemented();
    685688            return;
    686689        }
    687690        if (token.name() == ddTag || token.name() == dtTag) {
     691            if (!m_openElements.inScope(token.name())) {
     692                parseError(token);
     693                return;
     694            }
    688695            notImplemented();
    689696            return;
    690697        }
    691698        if (token.name() == h1Tag || token.name() == h2Tag || token.name() == h3Tag || token.name() == h4Tag || token.name() == h5Tag || token.name() == h6Tag) {
    692             notImplemented();
     699            if (!m_openElements.inScope(token.name())) {
     700                parseError(token);
     701                return;
     702            }
     703            generateImpliedEndTags();
     704            if (!currentElement()->hasLocalName(token.name()))
     705                parseError(token);
     706            m_openElements.popUntil(token.name());
     707            m_openElements.pop();
    693708            return;
    694709        }
     
    710725            if (currentElement()->tagQName() != token.name())
    711726                parseError(token);
    712             while (currentElement()->tagQName() != token.name())
    713                 m_openElements.pop();
     727            m_openElements.popUntil(token.name());
    714728            m_openElements.pop();
    715729            // FIXME: m_activeFormattingElements should be more interesting
     
    731745        if (!m_openElements.inScope(token.name()))
    732746            return;
    733         while (currentElement()->tagQName() != token.name())
    734             m_openElements.pop();
     747        m_openElements.popUntil(token.name());
    735748        m_openElements.pop();
    736749        break;
Note: See TracChangeset for help on using the changeset viewer.