Changeset 80209 in webkit


Ignore:
Timestamp:
Mar 2, 2011 10:18:55 PM (13 years ago)
Author:
rniwa@webkit.org
Message:

2011-03-02 Sheriff Bot <webkit.review.bot@gmail.com>

Unreviewed, rolling out r80201.
http://trac.webkit.org/changeset/80201
https://bugs.webkit.org/show_bug.cgi?id=55648

"caused tests to crash on several bots" (Requested by rniwa on
#webkit).

  • dom/Element.h: (WebCore::Node::hasTagName):
  • dom/Node.h:
  • html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLNames::hasImpliedEndTag): (WebCore::HTMLConstructionSite::insertHTMLHtmlStartTagInBody): (WebCore::HTMLConstructionSite::insertComment): (WebCore::HTMLConstructionSite::insertCommentOnHTMLHtmlElement): (WebCore::HTMLConstructionSite::attachToCurrent): (WebCore::HTMLConstructionSite::insertScriptElement): (WebCore::HTMLConstructionSite::insertTextNode): (WebCore::HTMLConstructionSite::createElement): (WebCore::HTMLConstructionSite::createHTMLElement): (WebCore::HTMLConstructionSite::generateImpliedEndTagsWithExclusion): (WebCore::HTMLConstructionSite::generateImpliedEndTags): (WebCore::HTMLConstructionSite::findFosterSite): (WebCore::HTMLConstructionSite::shouldFosterParent):
  • html/parser/HTMLConstructionSite.h:
  • html/parser/HTMLElementStack.cpp: (WebCore::HTMLNames::isNumberedHeaderElement): (WebCore::HTMLNames::isScopeMarker): (WebCore::HTMLNames::isListItemScopeMarker): (WebCore::HTMLNames::isTableScopeMarker): (WebCore::HTMLNames::isTableBodyScopeMarker): (WebCore::HTMLNames::isTableRowScopeMarker): (WebCore::HTMLNames::isButtonScopeMarker): (WebCore::HTMLNames::isSelectScopeMarker): (WebCore::HTMLElementStack::ElementRecord::ElementRecord): (WebCore::HTMLElementStack::ElementRecord::replaceElement): (WebCore::HTMLElementStack::HTMLElementStack): (WebCore::HTMLElementStack::secondElementIsHTMLBodyElement): (WebCore::HTMLElementStack::popAll): (WebCore::HTMLElementStack::popUntilTableScopeMarker): (WebCore::HTMLElementStack::popUntilTableBodyScopeMarker): (WebCore::HTMLElementStack::popUntilTableRowScopeMarker): (WebCore::HTMLElementStack::popUntilForeignContentScopeMarker): (WebCore::HTMLElementStack::pushHTMLHtmlElement): (WebCore::HTMLElementStack::push): (WebCore::HTMLElementStack::insertAbove): (WebCore::HTMLElementStack::find): (WebCore::HTMLElementStack::topmost): (WebCore::inScopeCommon): (WebCore::HTMLElementStack::hasNumberedHeaderElementInScope): (WebCore::HTMLElementStack::htmlElement): (WebCore::HTMLElementStack::bodyElement): (WebCore::HTMLElementStack::pushCommon):
  • html/parser/HTMLElementStack.h: (WebCore::HTMLElementStack::ElementRecord::element): (WebCore::HTMLElementStack::top):
  • html/parser/HTMLTreeBuilder.cpp: (WebCore::HTMLTreeBuilder::HTMLTreeBuilder): (WebCore::HTMLTreeBuilder::FragmentParsingContext::finished): (WebCore::HTMLTreeBuilder::processCloseWhenNestedTag): (WebCore::HTMLTreeBuilder::processStartTagForInBody): (WebCore::HTMLTreeBuilder::processColgroupEndTagForInColumnGroup): (WebCore::HTMLTreeBuilder::processStartTag): (WebCore::HTMLTreeBuilder::processAnyOtherEndTagForInBody): (WebCore::HTMLTreeBuilder::callTheAdoptionAgency): (WebCore::HTMLTreeBuilder::resetInsertionModeAppropriately): (WebCore::HTMLTreeBuilder::processEndTagForInCell): (WebCore::HTMLTreeBuilder::processEndTagForInBody): (WebCore::HTMLTreeBuilder::processEndTag): (WebCore::HTMLTreeBuilder::processEndOfFile): (WebCore::HTMLTreeBuilder::finished):
  • html/parser/HTMLTreeBuilder.h:
Location:
trunk/Source/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r80204 r80209  
     12011-03-02  Sheriff Bot  <webkit.review.bot@gmail.com>
     2
     3        Unreviewed, rolling out r80201.
     4        http://trac.webkit.org/changeset/80201
     5        https://bugs.webkit.org/show_bug.cgi?id=55648
     6
     7        "caused tests to crash on several bots" (Requested by rniwa on
     8        #webkit).
     9
     10        * dom/Element.h:
     11        (WebCore::Node::hasTagName):
     12        * dom/Node.h:
     13        * html/parser/HTMLConstructionSite.cpp:
     14        (WebCore::HTMLNames::hasImpliedEndTag):
     15        (WebCore::HTMLConstructionSite::insertHTMLHtmlStartTagInBody):
     16        (WebCore::HTMLConstructionSite::insertComment):
     17        (WebCore::HTMLConstructionSite::insertCommentOnHTMLHtmlElement):
     18        (WebCore::HTMLConstructionSite::attachToCurrent):
     19        (WebCore::HTMLConstructionSite::insertScriptElement):
     20        (WebCore::HTMLConstructionSite::insertTextNode):
     21        (WebCore::HTMLConstructionSite::createElement):
     22        (WebCore::HTMLConstructionSite::createHTMLElement):
     23        (WebCore::HTMLConstructionSite::generateImpliedEndTagsWithExclusion):
     24        (WebCore::HTMLConstructionSite::generateImpliedEndTags):
     25        (WebCore::HTMLConstructionSite::findFosterSite):
     26        (WebCore::HTMLConstructionSite::shouldFosterParent):
     27        * html/parser/HTMLConstructionSite.h:
     28        * html/parser/HTMLElementStack.cpp:
     29        (WebCore::HTMLNames::isNumberedHeaderElement):
     30        (WebCore::HTMLNames::isScopeMarker):
     31        (WebCore::HTMLNames::isListItemScopeMarker):
     32        (WebCore::HTMLNames::isTableScopeMarker):
     33        (WebCore::HTMLNames::isTableBodyScopeMarker):
     34        (WebCore::HTMLNames::isTableRowScopeMarker):
     35        (WebCore::HTMLNames::isButtonScopeMarker):
     36        (WebCore::HTMLNames::isSelectScopeMarker):
     37        (WebCore::HTMLElementStack::ElementRecord::ElementRecord):
     38        (WebCore::HTMLElementStack::ElementRecord::replaceElement):
     39        (WebCore::HTMLElementStack::HTMLElementStack):
     40        (WebCore::HTMLElementStack::secondElementIsHTMLBodyElement):
     41        (WebCore::HTMLElementStack::popAll):
     42        (WebCore::HTMLElementStack::popUntilTableScopeMarker):
     43        (WebCore::HTMLElementStack::popUntilTableBodyScopeMarker):
     44        (WebCore::HTMLElementStack::popUntilTableRowScopeMarker):
     45        (WebCore::HTMLElementStack::popUntilForeignContentScopeMarker):
     46        (WebCore::HTMLElementStack::pushHTMLHtmlElement):
     47        (WebCore::HTMLElementStack::push):
     48        (WebCore::HTMLElementStack::insertAbove):
     49        (WebCore::HTMLElementStack::find):
     50        (WebCore::HTMLElementStack::topmost):
     51        (WebCore::inScopeCommon):
     52        (WebCore::HTMLElementStack::hasNumberedHeaderElementInScope):
     53        (WebCore::HTMLElementStack::htmlElement):
     54        (WebCore::HTMLElementStack::bodyElement):
     55        (WebCore::HTMLElementStack::pushCommon):
     56        * html/parser/HTMLElementStack.h:
     57        (WebCore::HTMLElementStack::ElementRecord::element):
     58        (WebCore::HTMLElementStack::top):
     59        * html/parser/HTMLTreeBuilder.cpp:
     60        (WebCore::HTMLTreeBuilder::HTMLTreeBuilder):
     61        (WebCore::HTMLTreeBuilder::FragmentParsingContext::finished):
     62        (WebCore::HTMLTreeBuilder::processCloseWhenNestedTag):
     63        (WebCore::HTMLTreeBuilder::processStartTagForInBody):
     64        (WebCore::HTMLTreeBuilder::processColgroupEndTagForInColumnGroup):
     65        (WebCore::HTMLTreeBuilder::processStartTag):
     66        (WebCore::HTMLTreeBuilder::processAnyOtherEndTagForInBody):
     67        (WebCore::HTMLTreeBuilder::callTheAdoptionAgency):
     68        (WebCore::HTMLTreeBuilder::resetInsertionModeAppropriately):
     69        (WebCore::HTMLTreeBuilder::processEndTagForInCell):
     70        (WebCore::HTMLTreeBuilder::processEndTagForInBody):
     71        (WebCore::HTMLTreeBuilder::processEndTag):
     72        (WebCore::HTMLTreeBuilder::processEndOfFile):
     73        (WebCore::HTMLTreeBuilder::finished):
     74        * html/parser/HTMLTreeBuilder.h:
     75
    1762011-03-02  Yury Semikhatsky  <yurys@chromium.org>
    277
  • trunk/Source/WebCore/dom/Element.h

    r80201 r80209  
    428428    return isElementNode() && toElement(this)->hasTagName(name);
    429429}
    430    
    431 inline bool Node::hasLocalName(const AtomicString& name) const
    432 {
    433     return isElementNode() && toElement(this)->hasLocalName(name);
    434 }
    435430
    436431inline bool Node::hasAttributes() const
  • trunk/Source/WebCore/dom/Node.h

    r80201 r80209  
    33 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
    44 *           (C) 2001 Dirk Mueller (mueller@kde.org)
    5  * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
     5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
    66 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
    77 *
     
    135135
    136136    bool hasTagName(const QualifiedName&) const;
    137     bool hasLocalName(const AtomicString&) const;
    138137    virtual String nodeName() const = 0;
    139138    virtual String nodeValue() const;
  • trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp

    r80201 r80209  
    11/*
    22 * Copyright (C) 2010 Google, Inc. All Rights Reserved.
    3  * Copyright (C) 2011 Apple Inc. All rights reserved.
    43 *
    54 * Redistribution and use in source and binary forms, with or without
     
    6059namespace {
    6160
    62 bool hasImpliedEndTag(ContainerNode* node)
    63 {
    64     return node->hasTagName(ddTag)
    65         || node->hasTagName(dtTag)
    66         || node->hasTagName(liTag)
    67         || node->hasTagName(optionTag)
    68         || node->hasTagName(optgroupTag)
    69         || node->hasTagName(pTag)
    70         || node->hasTagName(rpTag)
    71         || node->hasTagName(rtTag);
     61bool hasImpliedEndTag(Element* element)
     62{
     63    return element->hasTagName(ddTag)
     64        || element->hasTagName(dtTag)
     65        || element->hasTagName(liTag)
     66        || element->hasTagName(optionTag)
     67        || element->hasTagName(optgroupTag)
     68        || element->hasTagName(pTag)
     69        || element->hasTagName(rpTag)
     70        || element->hasTagName(rtTag);
    7271}
    7372
     
    206205{
    207206    // FIXME: parse error
    208    
    209     // Fragments do not have a root HTML element, so any additional HTML elements
    210     // encountered during fragment parsing should be ignored.
    211     if (m_isParsingFragment)
    212         return;
    213 
    214207    mergeAttributesFromTokenIntoElement(token, m_openElements.htmlElement());
    215208}
     
    244237{
    245238    ASSERT(token.type() == HTMLToken::Comment);
    246     attach(currentNode(), Comment::create(currentNode()->document(), token.comment()));
     239    attach(currentElement(), Comment::create(currentElement()->document(), token.comment()));
    247240}
    248241
     
    256249{
    257250    ASSERT(token.type() == HTMLToken::Comment);
    258     ContainerNode* parent = m_openElements.rootNode();
     251    Element* parent = m_openElements.htmlElement();
    259252    attach(parent, Comment::create(parent->document(), token.comment()));
    260253}
     
    262255PassRefPtr<Element> HTMLConstructionSite::attachToCurrent(PassRefPtr<Element> child)
    263256{
    264     return attach(currentNode(), child);
     257    return attach(currentElement(), child);
    265258}
    266259
     
    318311void HTMLConstructionSite::insertScriptElement(AtomicHTMLToken& token)
    319312{
    320     RefPtr<HTMLScriptElement> element = HTMLScriptElement::create(scriptTag, currentNode()->document(), true);
     313    RefPtr<HTMLScriptElement> element = HTMLScriptElement::create(scriptTag, currentElement()->document(), true);
    321314    if (m_fragmentScriptingPermission == FragmentScriptingAllowed)
    322315        element->setAttributeMap(token.takeAtributes(), m_fragmentScriptingPermission);
     
    337330{
    338331    AttachmentSite site;
    339     site.parent = currentNode();
     332    site.parent = currentElement();
    340333    site.nextChild = 0;
    341334    if (shouldFosterParent())
     
    357350{
    358351    QualifiedName tagName(nullAtom, token.name(), namespaceURI);
    359     RefPtr<Element> element = currentNode()->document()->createElement(tagName, true);
     352    RefPtr<Element> element = currentElement()->document()->createElement(tagName, true);
    360353    element->setAttributeMap(token.takeAtributes(), m_fragmentScriptingPermission);
    361354    return element.release();
     
    368361    // have to pass the current form element.  We should rework form association
    369362    // to occur after construction to allow better code sharing here.
    370     RefPtr<Element> element = HTMLElementFactory::createHTMLElement(tagName, currentNode()->document(), form(), true);
     363    RefPtr<Element> element = HTMLElementFactory::createHTMLElement(tagName, currentElement()->document(), form(), true);
    371364    element->setAttributeMap(token.takeAtributes(), m_fragmentScriptingPermission);
    372365    ASSERT(element->isHTMLElement());
     
    447440void HTMLConstructionSite::generateImpliedEndTagsWithExclusion(const AtomicString& tagName)
    448441{
    449     while (hasImpliedEndTag(currentNode()) && !currentNode()->hasLocalName(tagName))
     442    while (hasImpliedEndTag(currentElement()) && !currentElement()->hasLocalName(tagName))
    450443        m_openElements.pop();
    451444}
     
    453446void HTMLConstructionSite::generateImpliedEndTags()
    454447{
    455     while (hasImpliedEndTag(currentNode()))
     448    while (hasImpliedEndTag(currentElement()))
    456449        m_openElements.pop();
    457450}
     
    472465    }
    473466    // Fragment case
    474     site.parent = m_openElements.rootNode(); // DocumentFragment
     467    site.parent = m_openElements.bottom(); // <html> element
    475468    site.nextChild = 0;
    476469}
     
    479472{
    480473    return m_redirectAttachToFosterParent
    481         && currentNode()->isElementNode()
    482474        && causesFosterParenting(currentElement()->tagQName());
    483475}
  • trunk/Source/WebCore/html/parser/HTMLConstructionSite.h

    r80201 r80209  
    11/*
    22 * Copyright (C) 2010 Google, Inc. All Rights Reserved.
    3  * Copyright (C) 2011 Apple Inc. All rights reserved.
    43 *
    54 * Redistribution and use in source and binary forms, with or without
     
    8281
    8382    Element* currentElement() const { return m_openElements.top(); }
    84     ContainerNode* currentNode() const { return m_openElements.topNode(); }
    8583    Element* oneBelowTop() const { return m_openElements.oneBelowTop(); }
    8684
  • trunk/Source/WebCore/html/parser/HTMLElementStack.cpp

    r80201 r80209  
    11/*
    22 * Copyright (C) 2010 Google, Inc. All Rights Reserved.
    3  * Copyright (C) 2011 Apple Inc. All rights reserved.
    43 *
    54 * Redistribution and use in source and binary forms, with or without
     
    2827#include "HTMLElementStack.h"
    2928
    30 #include "DocumentFragment.h"
    3129#include "Element.h"
    3230#include "HTMLNames.h"
     
    5048        || element->hasTagName(h6Tag);
    5149}
    52    
    53 inline bool isRootNode(ContainerNode* node)
    54 {
    55     return node->nodeType() == Node::DOCUMENT_FRAGMENT_NODE
    56         || node->hasTagName(htmlTag);
    57 }
    58 
    59 inline bool isScopeMarker(ContainerNode* node)
    60 {
    61     return node->hasTagName(appletTag)
    62         || node->hasTagName(captionTag)
    63         || node->hasTagName(marqueeTag)
    64         || node->hasTagName(objectTag)
    65         || node->hasTagName(tableTag)
    66         || node->hasTagName(tdTag)
    67         || node->hasTagName(thTag)
    68         || node->hasTagName(MathMLNames::miTag)
    69         || node->hasTagName(MathMLNames::moTag)
    70         || node->hasTagName(MathMLNames::mnTag)
    71         || node->hasTagName(MathMLNames::msTag)
    72         || node->hasTagName(MathMLNames::mtextTag)
    73         || node->hasTagName(MathMLNames::annotation_xmlTag)
    74         || node->hasTagName(SVGNames::foreignObjectTag)
    75         || node->hasTagName(SVGNames::descTag)
    76         || node->hasTagName(SVGNames::titleTag)
    77         || isRootNode(node);
    78 }
    79 
    80 inline bool isListItemScopeMarker(ContainerNode* node)
    81 {
    82     return isScopeMarker(node)
    83         || node->hasTagName(olTag)
    84         || node->hasTagName(ulTag);
    85 }
    86 
    87 inline bool isTableScopeMarker(ContainerNode* node)
    88 {
    89     return node->hasTagName(tableTag)
    90         || isRootNode(node);
    91 }
    92 
    93 inline bool isTableBodyScopeMarker(ContainerNode* node)
    94 {
    95     return node->hasTagName(tbodyTag)
    96         || node->hasTagName(tfootTag)
    97         || node->hasTagName(theadTag)
    98         || isRootNode(node);
    99 }
    100 
    101 inline bool isTableRowScopeMarker(ContainerNode* node)
    102 {
    103     return node->hasTagName(trTag)
    104         || isRootNode(node);
     50
     51inline bool isScopeMarker(Element* element)
     52{
     53    return element->hasTagName(appletTag)
     54        || element->hasTagName(captionTag)
     55        || element->hasTagName(htmlTag)
     56        || element->hasTagName(marqueeTag)
     57        || element->hasTagName(objectTag)
     58        || element->hasTagName(tableTag)
     59        || element->hasTagName(tdTag)
     60        || element->hasTagName(thTag)
     61        || element->hasTagName(MathMLNames::miTag)
     62        || element->hasTagName(MathMLNames::moTag)
     63        || element->hasTagName(MathMLNames::mnTag)
     64        || element->hasTagName(MathMLNames::msTag)
     65        || element->hasTagName(MathMLNames::mtextTag)
     66        || element->hasTagName(MathMLNames::annotation_xmlTag)
     67        || element->hasTagName(SVGNames::foreignObjectTag)
     68        || element->hasTagName(SVGNames::descTag)
     69        || element->hasTagName(SVGNames::titleTag);
     70}
     71
     72inline bool isListItemScopeMarker(Element* element)
     73{
     74    return isScopeMarker(element)
     75        || element->hasTagName(olTag)
     76        || element->hasTagName(ulTag);
     77}
     78
     79inline bool isTableScopeMarker(Element* element)
     80{
     81    return element->hasTagName(tableTag)
     82        || element->hasTagName(htmlTag);
     83}
     84
     85inline bool isTableBodyScopeMarker(Element* element)
     86{
     87    return element->hasTagName(tbodyTag)
     88        || element->hasTagName(tfootTag)
     89        || element->hasTagName(theadTag)
     90        || element->hasTagName(htmlTag);
     91}
     92
     93inline bool isTableRowScopeMarker(Element* element)
     94{
     95    return element->hasTagName(trTag)
     96        || element->hasTagName(htmlTag);
    10597}
    10698
     
    118110}
    119111
    120 inline bool isButtonScopeMarker(ContainerNode* node)
    121 {
    122     return isScopeMarker(node)
    123         || node->hasTagName(buttonTag);
    124 }
    125 
    126 inline bool isSelectScopeMarker(ContainerNode* node)
    127 {
    128     return !node->hasTagName(optgroupTag)
    129         && !node->hasTagName(optionTag);
    130 }
    131 
    132 }
    133 
    134 HTMLElementStack::ElementRecord::ElementRecord(PassRefPtr<ContainerNode> node, PassOwnPtr<ElementRecord> next)
    135     : m_node(node)
     112inline bool isButtonScopeMarker(Element* element)
     113{
     114    return isScopeMarker(element)
     115        || element->hasTagName(buttonTag);
     116}
     117
     118inline bool isSelectScopeMarker(Element* element)
     119{
     120    return !element->hasTagName(optgroupTag)
     121        && !element->hasTagName(optionTag);
     122}
     123
     124}
     125
     126HTMLElementStack::ElementRecord::ElementRecord(PassRefPtr<Element> element, PassOwnPtr<ElementRecord> next)
     127    : m_element(element)
    136128    , m_next(next)
    137129{
    138     ASSERT(m_node);
     130    ASSERT(m_element);
    139131}
    140132
     
    146138{
    147139    ASSERT(element);
    148     ASSERT(!m_node || m_node->isElementNode());
    149140    // FIXME: Should this call finishParsingChildren?
    150     m_node = element;
     141    m_element = element;
    151142}
    152143
     
    161152
    162153HTMLElementStack::HTMLElementStack()
    163     : m_rootNode(0)
     154    : m_htmlElement(0)
    164155    , m_headElement(0)
    165156    , m_bodyElement(0)
     
    181172    // insertion mode.
    182173    // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#parsing-main-inbody
    183     ASSERT(m_rootNode);
     174    ASSERT(m_htmlElement);
    184175    // If we have a body element, it must always be the second element on the
    185176    // stack, as we always start with an html element, and any other element
     
    204195void HTMLElementStack::popAll()
    205196{
    206     m_rootNode = 0;
     197    m_htmlElement = 0;
    207198    m_headElement = 0;
    208199    m_bodyElement = 0;
    209200    while (m_top) {
    210         topNode()->finishParsingChildren();
     201        top()->finishParsingChildren();
    211202        m_top = m_top->releaseNext();
    212203    }
     
    256247{
    257248    // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#clear-the-stack-back-to-a-table-context
    258     while (!isTableScopeMarker(topNode()))
     249    while (!isTableScopeMarker(top()))
    259250        pop();
    260251}
     
    263254{
    264255    // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#clear-the-stack-back-to-a-table-body-context
    265     while (!isTableBodyScopeMarker(topNode()))
     256    while (!isTableBodyScopeMarker(top()))
    266257        pop();
    267258}
     
    270261{
    271262    // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#clear-the-stack-back-to-a-table-row-context
    272     while (!isTableRowScopeMarker(topNode()))
     263    while (!isTableRowScopeMarker(top()))
    273264        pop();
    274265}
     
    279270        pop();
    280271}
    281    
    282 void HTMLElementStack::pushRootNode(PassRefPtr<ContainerNode> rootNode)
    283 {
    284     ASSERT(rootNode->nodeType() == Node::DOCUMENT_FRAGMENT_NODE);
    285     pushRootNodeCommon(rootNode);
    286 }
    287272
    288273void HTMLElementStack::pushHTMLHtmlElement(PassRefPtr<Element> element)
    289274{
     275    ASSERT(!m_top); // <html> should always be the bottom of the stack.
    290276    ASSERT(element->hasTagName(HTMLNames::htmlTag));
    291     pushRootNodeCommon(element);
    292 }
    293    
    294 void HTMLElementStack::pushRootNodeCommon(PassRefPtr<ContainerNode> rootNode)
    295 {
    296     ASSERT(!m_top);
    297     ASSERT(!m_rootNode);
    298     m_rootNode = rootNode.get();
    299     pushCommon(rootNode);
     277    ASSERT(!m_htmlElement);
     278    m_htmlElement = element.get();
     279    pushCommon(element);
    300280}
    301281
     
    321301    ASSERT(!element->hasTagName(HTMLNames::headTag));
    322302    ASSERT(!element->hasTagName(HTMLNames::bodyTag));
    323     ASSERT(m_rootNode);
     303    ASSERT(m_htmlElement);
    324304    pushCommon(element);
    325305}
     
    333313    ASSERT(!element->hasTagName(HTMLNames::headTag));
    334314    ASSERT(!element->hasTagName(HTMLNames::bodyTag));
    335     ASSERT(m_rootNode);
     315    ASSERT(m_htmlElement);
    336316    if (recordBelow == m_top) {
    337317        push(element);
     
    393373{
    394374    for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) {
    395         if (pos->node() == element)
     375        if (pos->element() == element)
    396376            return pos;
    397377    }
     
    402382{
    403383    for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) {
    404         if (pos->node()->hasLocalName(tagName))
     384        if (pos->element()->hasLocalName(tagName))
    405385            return pos;
    406386    }
     
    418398}
    419399
    420 template <bool isMarker(ContainerNode*)>
     400template <bool isMarker(Element*)>
    421401bool inScopeCommon(HTMLElementStack::ElementRecord* top, const AtomicString& targetTag)
    422402{
    423403    for (HTMLElementStack::ElementRecord* pos = top; pos; pos = pos->next()) {
    424         ContainerNode* node = pos->node();
    425         if (node->hasLocalName(targetTag))
     404        Element* element = pos->element();
     405        if (element->hasLocalName(targetTag))
    426406            return true;
    427         if (isMarker(node))
     407        if (isMarker(element))
    428408            return false;
    429409    }
     
    448428{
    449429    for (ElementRecord* record = m_top.get(); record; record = record->next()) {
    450         if (isScopeMarker(record->node()))
     430        Element* element = record->element();
     431        if (isNumberedHeaderElement(element))
     432            return true;
     433        if (isScopeMarker(element))
    451434            return false;
    452         if (isNumberedHeaderElement(record->element()))
    453             return true;
    454435    }
    455436    ASSERT_NOT_REACHED(); // <html> is always on the stack and is a scope marker.
     
    527508Element* HTMLElementStack::htmlElement() const
    528509{
    529     ASSERT(m_rootNode);
    530     return toElement(m_rootNode);
     510    ASSERT(m_htmlElement);
     511    return m_htmlElement;
    531512}
    532513
     
    542523    return m_bodyElement;
    543524}
    544    
    545 ContainerNode* HTMLElementStack::rootNode() const
    546 {
    547     ASSERT(m_rootNode);
    548     return m_rootNode;
    549 }
    550 
    551 void HTMLElementStack::pushCommon(PassRefPtr<ContainerNode> node)
    552 {
    553     ASSERT(m_rootNode);
    554     m_top = adoptPtr(new ElementRecord(node, m_top.release()));
    555     topNode()->beginParsingChildren();
     525
     526void HTMLElementStack::pushCommon(PassRefPtr<Element> element)
     527{
     528    ASSERT(m_htmlElement);
     529    m_top = adoptPtr(new ElementRecord(element, m_top.release()));
     530    top()->beginParsingChildren();
    556531}
    557532
  • trunk/Source/WebCore/html/parser/HTMLElementStack.h

    r80201 r80209  
    11/*
    22 * Copyright (C) 2010 Google, Inc. All Rights Reserved.
    3  * Copyright (C) 2011 Apple Inc. All rights reserved.
    43 *
    54 * Redistribution and use in source and binary forms, with or without
     
    2827#define HTMLElementStack_h
    2928
    30 #include "Element.h"
    3129#include <wtf/Forward.h>
    3230#include <wtf/Noncopyable.h>
     
    3735namespace WebCore {
    3836
    39 class ContainerNode;
    40 class DocumentFragment;
    4137class Element;
    4238class QualifiedName;
     
    5551        ~ElementRecord(); // Public for ~PassOwnPtr()
    5652   
    57         Element* element() const { return toElement(m_node.get()); }
    58         ContainerNode* node() const { return m_node.get(); }
     53        Element* element() const { return m_element.get(); }
    5954        void replaceElement(PassRefPtr<Element>);
    6055
     
    6661        friend class HTMLElementStack;
    6762
    68         ElementRecord(PassRefPtr<ContainerNode>, PassOwnPtr<ElementRecord>);
     63        ElementRecord(PassRefPtr<Element>, PassOwnPtr<ElementRecord>);
    6964
    7065        PassOwnPtr<ElementRecord> releaseNext() { return m_next.release(); }
    7166        void setNext(PassOwnPtr<ElementRecord> next) { m_next = next; }
    7267
    73         RefPtr<ContainerNode> m_node;
     68        RefPtr<Element> m_element;
    7469        OwnPtr<ElementRecord> m_next;
    7570    };
     
    8176        ASSERT(m_top->element());
    8277        return m_top->element();
    83     }
    84    
    85     ContainerNode* topNode() const
    86     {
    87         ASSERT(m_top->node());
    88         return m_top->node();
    8978    }
    9079
     
    9887
    9988    void push(PassRefPtr<Element>);
    100     void pushRootNode(PassRefPtr<ContainerNode>);
    10189    void pushHTMLHtmlElement(PassRefPtr<Element>);
    10290    void pushHTMLHeadElement(PassRefPtr<Element>);
     
    144132    Element* headElement() const;
    145133    Element* bodyElement() const;
    146    
    147     ContainerNode* rootNode() const;
    148134
    149135#ifndef NDEBUG
     
    152138
    153139private:
    154     void pushCommon(PassRefPtr<ContainerNode>);
    155     void pushRootNodeCommon(PassRefPtr<ContainerNode>);
     140    void pushCommon(PassRefPtr<Element>);
    156141    void popCommon();
    157142    void removeNonTopCommon(Element*);
     
    159144    OwnPtr<ElementRecord> m_top;
    160145
    161     // We remember the root node, <head> and <body> as they are pushed. Their
    162     // ElementRecords keep them alive. The root node is never popped.
     146    // We remember <html>, <head> and <body> as they are pushed. Their
     147    // ElementRecords keep them alive.  <html> is never popped.
    163148    // FIXME: We don't currently require type-specific information about
    164149    // these elements so we haven't yet bothered to plumb the types all the
    165150    // way down through createElement, etc.
    166     ContainerNode* m_rootNode;
     151    Element* m_htmlElement;
    167152    Element* m_headElement;
    168153    Element* m_bodyElement;
  • trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp

    r80201 r80209  
    11/*
    22 * Copyright (C) 2010 Google, Inc. All Rights Reserved.
    3  * Copyright (C) 2011 Apple Inc. All rights reserved.
    43 *
    54 * Redistribution and use in source and binary forms, with or without
     
    123122        || node->hasTagName(SVGNames::descTag)
    124123        || node->hasTagName(SVGNames::titleTag))
    125         return true;
    126     if (node->nodeType() == Node::DOCUMENT_FRAGMENT_NODE)
    127124        return true;
    128125    if (node->namespaceURI() != xhtmlNamespaceURI)
     
    379376        // Steps 4.2-4.6 of the HTML5 Fragment Case parsing algorithm:
    380377        // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#fragment-case
    381         // For efficiency, we skip step 4.2 ("Let root be a new html element with no attributes")
    382         // and instead use the DocumentFragment as a root node.
    383         m_tree.openElements()->pushRootNode(fragment);
     378        processFakeStartTag(htmlTag);
    384379        resetInsertionModeAppropriately();
    385380        m_tree.setForm(closestFormAncestor(contextElement));
     
    414409{
    415410    ASSERT(!fragment->hasChildNodes());
     411}
     412
     413void HTMLTreeBuilder::FragmentParsingContext::finished()
     414{
     415    if (!m_contextElement)
     416        return;
     417   
     418    // The HTML5 spec says to return the children of the fragment's document
     419    // element when there is a context element (10.4.7).
     420    RefPtr<ContainerNode> documentElement = firstElementChild(m_fragment);
     421    m_fragment->removeChildren();
     422    ASSERT(documentElement);
     423    m_fragment->takeAllChildrenFrom(documentElement.get());
    416424}
    417425
     
    567575namespace {
    568576
    569 bool isLi(const ContainerNode* element)
     577bool isLi(const Element* element)
    570578{
    571579    return element->hasTagName(liTag);
    572580}
    573581
    574 bool isDdOrDt(const ContainerNode* element)
     582bool isDdOrDt(const Element* element)
    575583{
    576584    return element->hasTagName(ddTag)
     
    580588}
    581589
    582 template <bool shouldClose(const ContainerNode*)>
     590template <bool shouldClose(const Element*)>
    583591void HTMLTreeBuilder::processCloseWhenNestedTag(AtomicHTMLToken& token)
    584592{
     
    586594    HTMLElementStack::ElementRecord* nodeRecord = m_tree.openElements()->topRecord();
    587595    while (1) {
    588         ContainerNode* node = nodeRecord->node();
     596        Element* node = nodeRecord->element();
    589597        if (shouldClose(node)) {
    590             ASSERT(node->isElementNode());
    591             processFakeEndTag(toElement(node)->tagQName());
     598            processFakeEndTag(node->tagQName());
    592599            break;
    593600        }
     
    780787    if (isNumberedHeaderTag(token.name())) {
    781788        processFakePEndTagIfPInButtonScope();
    782         if (isNumberedHeaderTag(m_tree.currentNode()->localName())) {
     789        if (isNumberedHeaderTag(m_tree.currentElement()->localName())) {
    783790            parseError(token);
    784791            m_tree.openElements()->pop();
     
    972979        if (m_tree.openElements()->inScope(rubyTag.localName())) {
    973980            m_tree.generateImpliedEndTags();
    974             if (!m_tree.currentNode()->hasTagName(rubyTag)) {
     981            if (!m_tree.currentElement()->hasTagName(rubyTag)) {
    975982                parseError(token);
    976983                m_tree.openElements()->popUntil(rubyTag.localName());
     
    10131020bool HTMLTreeBuilder::processColgroupEndTagForInColumnGroup()
    10141021{
    1015     if (m_tree.currentNode() == m_tree.openElements()->rootNode()) {
     1022    if (m_tree.currentElement() == m_tree.openElements()->htmlElement()) {
    10161023        ASSERT(isParsingFragment());
    10171024        // FIXME: parse error
     
    11091116namespace {
    11101117
    1111 bool shouldProcessForeignContentUsingInBodyInsertionMode(AtomicHTMLToken& token, ContainerNode* currentElement)
     1118bool shouldProcessForeignContentUsingInBodyInsertionMode(AtomicHTMLToken& token, Element* currentElement)
    11121119{
    11131120    ASSERT(token.type() == HTMLToken::StartTag);
     
    14031410        }
    14041411        if (token.name() == optionTag) {
    1405             if (m_tree.currentNode()->hasTagName(optionTag)) {
     1412            if (m_tree.currentElement()->hasTagName(optionTag)) {
    14061413                AtomicHTMLToken endOption(HTMLToken::EndTag, optionTag.localName());
    14071414                processEndTag(endOption);
     
    14111418        }
    14121419        if (token.name() == optgroupTag) {
    1413             if (m_tree.currentNode()->hasTagName(optionTag)) {
     1420            if (m_tree.currentElement()->hasTagName(optionTag)) {
    14141421                AtomicHTMLToken endOption(HTMLToken::EndTag, optionTag.localName());
    14151422                processEndTag(endOption);
    14161423            }
    1417             if (m_tree.currentNode()->hasTagName(optgroupTag)) {
     1424            if (m_tree.currentElement()->hasTagName(optgroupTag)) {
    14181425                AtomicHTMLToken endOptgroup(HTMLToken::EndTag, optgroupTag.localName());
    14191426                processEndTag(endOptgroup);
     
    15371544    HTMLElementStack::ElementRecord* record = m_tree.openElements()->topRecord();
    15381545    while (1) {
    1539         ContainerNode* node = record->node();
     1546        Element* node = record->element();
    15401547        if (node->hasLocalName(token.name())) {
    15411548            m_tree.generateImpliedEndTags();
    1542             if (!m_tree.currentNode()->hasLocalName(token.name())) {
     1549            if (!m_tree.currentElement()->hasLocalName(token.name())) {
    15431550                parseError(token);
    15441551                // FIXME: This is either a bug in the spec, or a bug in our
     
    15471554                // We might have already popped the node for the token in
    15481555                // generateImpliedEndTags, just abort.
    1549                 if (!m_tree.openElements()->contains(record->element()))
     1556                if (!m_tree.openElements()->contains(node))
    15501557                    return;
    15511558            }
    1552             m_tree.openElements()->popUntilPopped(record->element());
     1559            m_tree.openElements()->popUntilPopped(node);
    15531560            return;
    15541561        }
     
    16101617        // 4.
    16111618        ASSERT(furthestBlock->isAbove(formattingElementRecord));
    1612         ContainerNode* commonAncestor = formattingElementRecord->next()->node();
     1619        Element* commonAncestor = formattingElementRecord->next()->element();
    16131620        // 5.
    16141621        HTMLFormattingElementList::Bookmark bookmark = m_tree.activeFormattingElements()->bookmarkFor(formattingElement);
     
    16621669        else {
    16631670            commonAncestor->parserAddChild(lastNode->element());
    1664             ASSERT(lastNode->node()->isElementNode());
    1665             ASSERT(lastNode->element()->parentNode());
    1666             if (lastNode->element()->parentNode()->attached() && !lastNode->element()->attached())
     1671            if (lastNode->element()->parentElement()->attached() && !lastNode->element()->attached())
    16671672                lastNode->element()->lazyAttach();
    16681673        }
     
    16961701    HTMLElementStack::ElementRecord* nodeRecord = m_tree.openElements()->topRecord();
    16971702    while (1) {
    1698         ContainerNode* node = nodeRecord->node();
    1699         if (node == m_tree.openElements()->rootNode()) {
     1703        Element* node = nodeRecord->element();
     1704        if (node == m_tree.openElements()->bottom()) {
    17001705            ASSERT(isParsingFragment());
    17011706            last = true;
     
    18271832        }
    18281833        m_tree.generateImpliedEndTags();
    1829         if (!m_tree.currentNode()->hasLocalName(token.name()))
     1834        if (!m_tree.currentElement()->hasLocalName(token.name()))
    18301835            parseError(token);
    18311836        m_tree.openElements()->popUntilPopped(token.name());
     
    18971902        }
    18981903        m_tree.generateImpliedEndTags();
    1899         if (!m_tree.currentNode()->hasLocalName(token.name()))
     1904        if (!m_tree.currentElement()->hasLocalName(token.name()))
    19001905            parseError(token);
    19011906        m_tree.openElements()->popUntilPopped(token.name());
     
    19221927        }
    19231928        m_tree.generateImpliedEndTagsWithExclusion(token.name());
    1924         if (!m_tree.currentNode()->hasLocalName(token.name()))
     1929        if (!m_tree.currentElement()->hasLocalName(token.name()))
    19251930            parseError(token);
    19261931        m_tree.openElements()->popUntilPopped(token.name());
     
    19331938        }
    19341939        m_tree.generateImpliedEndTagsWithExclusion(token.name());
    1935         if (!m_tree.currentNode()->hasLocalName(token.name()))
     1940        if (!m_tree.currentElement()->hasLocalName(token.name()))
    19361941            parseError(token);
    19371942        m_tree.openElements()->popUntilPopped(token.name());
     
    19451950        }
    19461951        m_tree.generateImpliedEndTagsWithExclusion(token.name());
    1947         if (!m_tree.currentNode()->hasLocalName(token.name()))
     1952        if (!m_tree.currentElement()->hasLocalName(token.name()))
    19481953            parseError(token);
    19491954        m_tree.openElements()->popUntilPopped(token.name());
     
    19561961        }
    19571962        m_tree.generateImpliedEndTags();
    1958         if (!m_tree.currentNode()->hasLocalName(token.name()))
     1963        if (!m_tree.currentElement()->hasLocalName(token.name()))
    19591964            parseError(token);
    19601965        m_tree.openElements()->popUntilNumberedHeaderElementPopped();
     
    19731978        }
    19741979        m_tree.generateImpliedEndTags();
    1975         if (!m_tree.currentNode()->hasLocalName(token.name()))
     1980        if (!m_tree.currentElement()->hasLocalName(token.name()))
    19761981            parseError(token);
    19771982        m_tree.openElements()->popUntilPopped(token.name());
     
    22172222        ASSERT(insertionMode() == InFramesetMode);
    22182223        if (token.name() == framesetTag) {
    2219             if (m_tree.currentNode() == m_tree.openElements()->rootNode()) {
     2224            if (m_tree.currentElement() == m_tree.openElements()->htmlElement()) {
    22202225                parseError(token);
    22212226                return;
     
    22572262        ASSERT(insertionMode() == InSelectMode || insertionMode() == InSelectInTableMode);
    22582263        if (token.name() == optgroupTag) {
    2259             if (m_tree.currentNode()->hasTagName(optionTag) && m_tree.oneBelowTop()->hasTagName(optgroupTag))
     2264            if (m_tree.currentElement()->hasTagName(optionTag) && m_tree.oneBelowTop()->hasTagName(optgroupTag))
    22602265                processFakeEndTag(optionTag);
    2261             if (m_tree.currentNode()->hasTagName(optgroupTag)) {
     2266            if (m_tree.currentElement()->hasTagName(optgroupTag)) {
    22622267                m_tree.openElements()->pop();
    22632268                return;
     
    22902295        break;
    22912296    case InForeignContentMode:
    2292         if (token.name() == SVGNames::scriptTag && m_tree.currentNode()->hasTagName(SVGNames::scriptTag)) {
     2297        if (token.name() == SVGNames::scriptTag && m_tree.currentElement()->hasTagName(SVGNames::scriptTag)) {
    22932298            notImplemented();
    22942299            return;
    22952300        }
    2296         if (m_tree.currentNode()->namespaceURI() != xhtmlNamespaceURI) {
     2301        if (m_tree.currentElement()->namespaceURI() != xhtmlNamespaceURI) {
    22972302            // FIXME: This code just wants an Element* iterator, instead of an ElementRecord*
    22982303            HTMLElementStack::ElementRecord* nodeRecord = m_tree.openElements()->topRecord();
    2299             if (!nodeRecord->node()->hasLocalName(token.name()))
     2304            if (!nodeRecord->element()->hasLocalName(token.name()))
    23002305                parseError(token);
    23012306            while (1) {
    2302                 if (nodeRecord->node()->hasLocalName(token.name())) {
     2307                if (nodeRecord->element()->hasLocalName(token.name())) {
    23032308                    m_tree.openElements()->popUntilPopped(nodeRecord->element());
    23042309                    resetForeignInsertionMode();
     
    23062311                }
    23072312                nodeRecord = nodeRecord->next();
    2308                
    2309                 // Fragments containing only foreign content will not have a
    2310                 // node with the XHTML namespace URI, so we should stop walking
    2311                 // the element stack when we encounter the DocumentFragment itself.
    2312                 if (nodeRecord->node()->nodeType() == Node::DOCUMENT_FRAGMENT_NODE) {
    2313                     ASSERT(isParsingFragment());
    2314                     break;
    2315                 }
    2316                
    2317                 if (nodeRecord->node()->namespaceURI() == xhtmlNamespaceURI)
     2313                if (nodeRecord->element()->namespaceURI() == xhtmlNamespaceURI)
    23182314                    break;
    23192315            }
     
    26142610    case InSelectMode:
    26152611        ASSERT(insertionMode() == InSelectMode || insertionMode() == InSelectInTableMode || insertionMode() == InTableMode || insertionMode() == InFramesetMode || insertionMode() == InTableBodyMode);
    2616         if (m_tree.currentNode() != m_tree.openElements()->rootNode())
     2612        if (m_tree.currentElement() != m_tree.openElements()->htmlElement())
    26172613            parseError(token);
    26182614        break;
    26192615    case InColumnGroupMode:
    2620         if (m_tree.currentNode() == m_tree.openElements()->rootNode()) {
     2616        if (m_tree.currentElement() == m_tree.openElements()->htmlElement()) {
    26212617            ASSERT(isParsingFragment());
    26222618            return; // FIXME: Should we break here instead of returning?
     
    26472643        return;
    26482644    }
    2649     ASSERT(m_tree.currentNode());
     2645    ASSERT(m_tree.openElements()->top());
    26502646    m_tree.openElements()->popAll();
    26512647}
     
    27992795void HTMLTreeBuilder::finished()
    28002796{
    2801     if (isParsingFragment())
    2802         return;
    2803    
    28042797    ASSERT(m_document);
     2798    if (isParsingFragment()) {
     2799        m_fragmentContext.finished();
     2800        return;
     2801    }
     2802
    28052803    // Warning, this may detach the parser. Do not do anything else after this.
    28062804    m_document->finishedParsing();
  • trunk/Source/WebCore/html/parser/HTMLTreeBuilder.h

    r80201 r80209  
    11/*
    22 * Copyright (C) 2010 Google, Inc. All Rights Reserved.
    3  * Copyright (C) 2011 Apple Inc. All rights reserved.
    43 *
    54 * Redistribution and use in source and binary forms, with or without
     
    180179    void closeTheCell();
    181180
    182     template <bool shouldClose(const ContainerNode*)>
     181    template <bool shouldClose(const Element*)>
    183182    void processCloseWhenNestedTag(AtomicHTMLToken&);
    184183
     
    217216        FragmentScriptingPermission scriptingPermission() const { ASSERT(m_fragment); return m_scriptingPermission; }
    218217
     218        void finished();
     219
    219220    private:
    220221        DocumentFragment* m_fragment;
Note: See TracChangeset for help on using the changeset viewer.