Changeset 65986 in webkit


Ignore:
Timestamp:
Aug 24, 2010 11:21:44 PM (14 years ago)
Author:
abarth@webkit.org
Message:

2010-08-24 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

Delete HTMLElement::checkDTD
https://bugs.webkit.org/show_bug.cgi?id=44563

This function existed to service the LegacyHTMLTreeBuilder. The new
HTMLTreeBuilder has this logic internalized. Pulling on this thread
caused me to remove a legacyParserAddChild and to discover some code
that shouldn't be calling these parser-specific APIs.

  • dom/ContainerNode.cpp: (WebCore::ContainerNode::parserAddChild): (WebCore::ContainerNode::deprecatedParserAddChild):
  • dom/ContainerNode.h:
  • dom/DOMImplementation.cpp: (WebCore::DOMImplementation::createDocument):
  • dom/Node.cpp: (WebCore::Node::deprecatedParserAddChild):
  • dom/Node.h:
  • dom/XMLDocumentParser.cpp: (WebCore::XMLDocumentParser::enterText):
  • dom/XMLDocumentParser.h:
  • dom/XMLDocumentParserLibxml2.cpp: (WebCore::XMLDocumentParser::startElementNs): (WebCore::XMLDocumentParser::characters): (WebCore::XMLDocumentParser::processingInstruction): (WebCore::XMLDocumentParser::cdataBlock): (WebCore::XMLDocumentParser::comment): (WebCore::XMLDocumentParser::internalSubset):
  • dom/XMLDocumentParserQt.cpp: (WebCore::XMLDocumentParser::parse): (WebCore::XMLDocumentParser::parseStartElement): (WebCore::XMLDocumentParser::parseCharacters): (WebCore::XMLDocumentParser::parseProcessingInstruction): (WebCore::XMLDocumentParser::parseCdata): (WebCore::XMLDocumentParser::parseComment): (WebCore::XMLDocumentParser::parseDtd):
  • html/HTMLDataGridElement.cpp:
  • html/HTMLDataGridElement.h:
  • html/HTMLDataGridRowElement.cpp:
  • html/HTMLDataGridRowElement.h:
  • html/HTMLDataListElement.cpp:
  • html/HTMLDataListElement.h:
  • html/HTMLDocument.cpp:
  • html/HTMLDocument.h:
  • html/HTMLElement.cpp:
  • html/HTMLElement.h:
  • html/HTMLFieldSetElement.cpp:
  • html/HTMLFieldSetElement.h:
  • html/HTMLFrameSetElement.cpp:
  • html/HTMLFrameSetElement.h:
  • html/HTMLHeadElement.cpp:
  • html/HTMLHeadElement.h:
  • html/HTMLHeadingElement.cpp:
  • html/HTMLHeadingElement.h:
  • html/HTMLHtmlElement.cpp:
  • html/HTMLHtmlElement.h:
  • html/HTMLKeygenElement.cpp: (WebCore::HTMLKeygenElement::HTMLKeygenElement):
  • html/HTMLMapElement.cpp:
  • html/HTMLMapElement.h:
  • html/HTMLMediaElement.cpp:
  • html/HTMLMediaElement.h:
  • html/HTMLNoScriptElement.cpp:
  • html/HTMLNoScriptElement.h:
  • html/HTMLOptGroupElement.cpp:
  • html/HTMLOptGroupElement.h:
  • html/HTMLOptionElement.cpp:
  • html/HTMLOptionElement.h:
  • html/HTMLParagraphElement.cpp:
  • html/HTMLParagraphElement.h:
  • html/HTMLPlugInElement.cpp:
  • html/HTMLPlugInElement.h:
  • html/HTMLScriptElement.h:
  • html/HTMLSelectElement.cpp:
  • html/HTMLSelectElement.h:
  • html/HTMLStyleElement.h:
  • html/HTMLTableColElement.cpp:
  • html/HTMLTableColElement.h:
  • html/HTMLTableElement.cpp:
  • html/HTMLTableElement.h:
  • html/HTMLTableRowElement.cpp:
  • html/HTMLTableRowElement.h:
  • html/HTMLTableSectionElement.cpp:
  • html/HTMLTableSectionElement.h:
  • html/HTMLTextAreaElement.h:
  • html/HTMLTitleElement.h:
  • rendering/MediaControlElements.cpp: (WebCore::MediaControlElement::attachToParent): (WebCore::MediaControlInputElement::attachToParent):
  • rendering/TextControlInnerElements.cpp: (WebCore::TextControlInnerElement::attachInnerElement):
Location:
trunk/WebCore
Files:
61 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r65982 r65986  
     12010-08-24  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Delete HTMLElement::checkDTD
     6        https://bugs.webkit.org/show_bug.cgi?id=44563
     7
     8        This function existed to service the LegacyHTMLTreeBuilder.  The new
     9        HTMLTreeBuilder has this logic internalized.  Pulling on this thread
     10        caused me to remove a legacyParserAddChild and to discover some code
     11        that shouldn't be calling these parser-specific APIs.
     12
     13        * dom/ContainerNode.cpp:
     14        (WebCore::ContainerNode::parserAddChild):
     15        (WebCore::ContainerNode::deprecatedParserAddChild):
     16        * dom/ContainerNode.h:
     17        * dom/DOMImplementation.cpp:
     18        (WebCore::DOMImplementation::createDocument):
     19        * dom/Node.cpp:
     20        (WebCore::Node::deprecatedParserAddChild):
     21        * dom/Node.h:
     22        * dom/XMLDocumentParser.cpp:
     23        (WebCore::XMLDocumentParser::enterText):
     24        * dom/XMLDocumentParser.h:
     25        * dom/XMLDocumentParserLibxml2.cpp:
     26        (WebCore::XMLDocumentParser::startElementNs):
     27        (WebCore::XMLDocumentParser::characters):
     28        (WebCore::XMLDocumentParser::processingInstruction):
     29        (WebCore::XMLDocumentParser::cdataBlock):
     30        (WebCore::XMLDocumentParser::comment):
     31        (WebCore::XMLDocumentParser::internalSubset):
     32        * dom/XMLDocumentParserQt.cpp:
     33        (WebCore::XMLDocumentParser::parse):
     34        (WebCore::XMLDocumentParser::parseStartElement):
     35        (WebCore::XMLDocumentParser::parseCharacters):
     36        (WebCore::XMLDocumentParser::parseProcessingInstruction):
     37        (WebCore::XMLDocumentParser::parseCdata):
     38        (WebCore::XMLDocumentParser::parseComment):
     39        (WebCore::XMLDocumentParser::parseDtd):
     40        * html/HTMLDataGridElement.cpp:
     41        * html/HTMLDataGridElement.h:
     42        * html/HTMLDataGridRowElement.cpp:
     43        * html/HTMLDataGridRowElement.h:
     44        * html/HTMLDataListElement.cpp:
     45        * html/HTMLDataListElement.h:
     46        * html/HTMLDocument.cpp:
     47        * html/HTMLDocument.h:
     48        * html/HTMLElement.cpp:
     49        * html/HTMLElement.h:
     50        * html/HTMLFieldSetElement.cpp:
     51        * html/HTMLFieldSetElement.h:
     52        * html/HTMLFrameSetElement.cpp:
     53        * html/HTMLFrameSetElement.h:
     54        * html/HTMLHeadElement.cpp:
     55        * html/HTMLHeadElement.h:
     56        * html/HTMLHeadingElement.cpp:
     57        * html/HTMLHeadingElement.h:
     58        * html/HTMLHtmlElement.cpp:
     59        * html/HTMLHtmlElement.h:
     60        * html/HTMLKeygenElement.cpp:
     61        (WebCore::HTMLKeygenElement::HTMLKeygenElement):
     62        * html/HTMLMapElement.cpp:
     63        * html/HTMLMapElement.h:
     64        * html/HTMLMediaElement.cpp:
     65        * html/HTMLMediaElement.h:
     66        * html/HTMLNoScriptElement.cpp:
     67        * html/HTMLNoScriptElement.h:
     68        * html/HTMLOptGroupElement.cpp:
     69        * html/HTMLOptGroupElement.h:
     70        * html/HTMLOptionElement.cpp:
     71        * html/HTMLOptionElement.h:
     72        * html/HTMLParagraphElement.cpp:
     73        * html/HTMLParagraphElement.h:
     74        * html/HTMLPlugInElement.cpp:
     75        * html/HTMLPlugInElement.h:
     76        * html/HTMLScriptElement.h:
     77        * html/HTMLSelectElement.cpp:
     78        * html/HTMLSelectElement.h:
     79        * html/HTMLStyleElement.h:
     80        * html/HTMLTableColElement.cpp:
     81        * html/HTMLTableColElement.h:
     82        * html/HTMLTableElement.cpp:
     83        * html/HTMLTableElement.h:
     84        * html/HTMLTableRowElement.cpp:
     85        * html/HTMLTableRowElement.h:
     86        * html/HTMLTableSectionElement.cpp:
     87        * html/HTMLTableSectionElement.h:
     88        * html/HTMLTextAreaElement.h:
     89        * html/HTMLTitleElement.h:
     90        * rendering/MediaControlElements.cpp:
     91        (WebCore::MediaControlElement::attachToParent):
     92        (WebCore::MediaControlInputElement::attachToParent):
     93        * rendering/TextControlInnerElements.cpp:
     94        (WebCore::TextControlInnerElement::attachInnerElement):
     95
    1962010-08-24  Adam Barth  <abarth@webkit.org>
    297
  • trunk/WebCore/dom/ContainerNode.cpp

    r65769 r65986  
    589589}
    590590
    591 void ContainerNode::addChildCommon(Node* newChild)
     591void ContainerNode::parserAddChild(PassRefPtr<Node> newChild)
    592592{
    593593    ASSERT(newChild);
     
    597597    Node* last = m_lastChild;
    598598    // FIXME: This method should take a PassRefPtr.
    599     appendChildToContainer<Node, ContainerNode>(newChild, this);
     599    appendChildToContainer<Node, ContainerNode>(newChild.get(), this);
    600600    allowEventDispatch();
    601601
     
    607607}
    608608
    609 void ContainerNode::parserAddChild(PassRefPtr<Node> newChild)
    610 {
    611     ASSERT(newChild);
    612     addChildCommon(newChild.get());
    613 }
    614 
    615 ContainerNode* ContainerNode::legacyParserAddChild(PassRefPtr<Node> newChild)
    616 {
    617     ASSERT(newChild);
    618 
    619     // Check for consistency with DTD, but only when parsing HTML.
    620     if (document()->isHTMLDocument() && !childAllowed(newChild.get()))
    621         return 0;
    622 
    623     addChildCommon(newChild.get());
    624 
    625     if (newChild->isElementNode())
    626         return static_cast<ContainerNode*>(newChild.get());
    627     return this;
     609void ContainerNode::deprecatedParserAddChild(PassRefPtr<Node> node)
     610{
     611    parserAddChild(node);
    628612}
    629613
  • trunk/WebCore/dom/ContainerNode.h

    r65849 r65986  
    5252    // They don't send DOM mutation events or handle reparenting.
    5353    // However, arbitrary code may be run by beforeload handlers.
    54     virtual ContainerNode* legacyParserAddChild(PassRefPtr<Node>);
    5554    void parserAddChild(PassRefPtr<Node>);
    5655    void parserRemoveChild(Node*);
     
    101100
    102101private:
    103     // FIXME: This should take a PassRefPtr.
    104     void addChildCommon(Node*);
     102    // Never call this function directly.  If you're trying to call this
     103    // function, your code is either wrong or you're supposed to call
     104    // parserAddChild.  Please do not call parserAddChild unless you are the
     105    // parser!
     106    virtual void deprecatedParserAddChild(PassRefPtr<Node>);
     107
    105108    void removeBetween(Node* previousChild, Node* nextChild, Node* oldChild);
    106109    void insertBeforeCommon(Node* nextChild, Node* oldChild);
  • trunk/WebCore/dom/DOMImplementation.cpp

    r62079 r65986  
    259259    // FIXME: Shouldn't this call appendChild instead?
    260260    if (doctype)
    261         doc->legacyParserAddChild(doctype);
     261        doc->parserAddChild(doctype);
    262262    if (documentElement)
    263         doc->legacyParserAddChild(documentElement.release());
     263        doc->parserAddChild(documentElement.release());
    264264
    265265    return doc.release();
  • trunk/WebCore/dom/Node.cpp

    r65852 r65986  
    642642}
    643643
    644 ContainerNode* Node::legacyParserAddChild(PassRefPtr<Node>)
    645 {
    646     return 0;
     644void Node::deprecatedParserAddChild(PassRefPtr<Node>)
     645{
    647646}
    648647
     
    12241223        return false;
    12251224    return this == node || node->isDescendantOf(this);
    1226 }
    1227 
    1228 bool Node::childAllowed(Node* newChild)
    1229 {
    1230     return childTypeAllowed(newChild->nodeType());
    12311225}
    12321226
  • trunk/WebCore/dom/Node.h

    r65852 r65986  
    259259   
    260260    bool inSameContainingBlockFlowElement(Node*);
    261    
    262     // Used by the parser. Checks against the DTD, unlike DOM operations like appendChild().
    263     // Also does not dispatch DOM mutation events.
    264     // Returns the appropriate container node for future insertions as you parse, or 0 for failure.
    265     virtual ContainerNode* legacyParserAddChild(PassRefPtr<Node>);
     261
     262    // FIXME: All callers of this function are almost certainly wrong!
     263    virtual void deprecatedParserAddChild(PassRefPtr<Node>);
    266264
    267265    // Called by the parser when this element's close tag is reached,
     
    424422    bool contains(const Node*) const;
    425423
    426     // These two methods are mutually exclusive.  The former is used to do strict error-checking
    427     // when adding children via the public DOM API (e.g., appendChild()).  The latter is called only when parsing,
    428     // to sanity-check against the DTD for error recovery.
     424    // This method is used to do strict error-checking when adding children via
     425    // the public DOM API (e.g., appendChild()).
    429426    void checkAddChild(Node* newChild, ExceptionCode&); // Error-checking when adding via the DOM API
    430     virtual bool childAllowed(Node* newChild);          // Error-checking during parsing that checks the DTD
    431427
    432428    void checkReplaceChild(Node* newChild, Node* oldChild, ExceptionCode&);
  • trunk/WebCore/dom/XMLDocumentParser.cpp

    r65958 r65986  
    171171}
    172172
    173 bool XMLDocumentParser::enterText()
     173void XMLDocumentParser::enterText()
    174174{
    175175#if !USE(QXMLSTREAM)
     
    177177#endif
    178178    RefPtr<Node> newNode = Text::create(document(), "");
    179     if (!m_currentNode->legacyParserAddChild(newNode.get()))
    180         return false;
     179    m_currentNode->deprecatedParserAddChild(newNode.get());
    181180    pushCurrentNode(newNode.get());
    182     return true;
    183181}
    184182
  • trunk/WebCore/dom/XMLDocumentParser.h

    r65958 r65986  
    167167        void insertErrorMessageBlock();
    168168
    169         bool enterText();
     169        void enterText();
    170170        void exitText();
    171171
  • trunk/WebCore/dom/XMLDocumentParserLibxml2.cpp

    r65958 r65986  
    809809        m_scriptStartLine = lineNumber();
    810810
    811     if (!m_currentNode->legacyParserAddChild(newElement.get())) {
    812         stopParsing();
    813         return;
    814     }
     811    m_currentNode->deprecatedParserAddChild(newElement.get());
    815812
    816813    pushCurrentNode(newElement.get());
     
    916913    }
    917914
    918     if (m_currentNode->isTextNode() || enterText())
    919         m_bufferedText.append(s, len);
     915    if (!m_currentNode->isTextNode())
     916        enterText();
     917    m_bufferedText.append(s, len);
    920918}
    921919
     
    965963    pi->setCreatedByParser(true);
    966964
    967     if (!m_currentNode->legacyParserAddChild(pi.get()))
    968         return;
     965    m_currentNode->deprecatedParserAddChild(pi.get());
    969966    if (m_view && !pi->attached())
    970967        pi->attach();
     
    992989
    993990    RefPtr<Node> newNode = CDATASection::create(document(), toString(s, len));
    994     if (!m_currentNode->legacyParserAddChild(newNode.get()))
    995         return;
     991    m_currentNode->deprecatedParserAddChild(newNode.get());
    996992    if (m_view && !newNode->attached())
    997993        newNode->attach();
     
    10111007
    10121008    RefPtr<Node> newNode = Comment::create(document(), toString(s));
    1013     m_currentNode->legacyParserAddChild(newNode.get());
     1009    m_currentNode->deprecatedParserAddChild(newNode.get());
    10141010    if (m_view && !newNode->attached())
    10151011        newNode->attach();
     
    10751071#endif
    10761072
    1077         document()->legacyParserAddChild(DocumentType::create(document(), toString(name), toString(externalID), toString(systemID)));
     1073        document()->parserAddChild(DocumentType::create(document(), toString(name), toString(externalID), toString(systemID)));
    10781074    }
    10791075}
  • trunk/WebCore/dom/XMLDocumentParserQt.cpp

    r65878 r65986  
    411411                QString entity = m_stream.name().toString();
    412412                UChar c = decodeNamedEntity(entity.toUtf8().constData());
    413                 if (m_currentNode->isTextNode() || enterText()) {
    414                     ExceptionCode ec = 0;
    415                     String str(&c, 1);
    416                     //qDebug()<<" ------- adding entity "<<str;
    417                     static_cast<Text*>(m_currentNode)->appendData(str, ec);
    418                 }
     413                if (!m_currentNode->isTextNode())
     414                    enterText();
     415                ExceptionCode ec = 0;
     416                String str(&c, 1);
     417                // qDebug()<<" ------- adding entity "<<str;
     418                static_cast<Text*>(m_currentNode)->appendData(str, ec);
    419419            }
    420420        }
     
    519519        m_scriptStartLine = lineNumber();
    520520
    521     if (!m_currentNode->legacyParserAddChild(newElement.get())) {
    522         stopParsing();
    523         return;
    524     }
     521    m_currentNode->parserAddChild(newElement.get());
    525522
    526523    pushCurrentNode(newElement.get());
     
    600597void XMLDocumentParser::parseCharacters()
    601598{
    602     if (m_currentNode->isTextNode() || enterText()) {
    603         ExceptionCode ec = 0;
    604         static_cast<Text*>(m_currentNode)->appendData(m_stream.text(), ec);
    605     }
     599    if (!m_currentNode->isTextNode())
     600        enterText();
     601    ExceptionCode ec = 0;
     602    static_cast<Text*>(m_currentNode)->appendData(m_stream.text(), ec);
    606603}
    607604
     
    620617    pi->setCreatedByParser(true);
    621618
    622     if (!m_currentNode->legacyParserAddChild(pi.get()))
    623         return;
     619    m_currentNode->parserAddChild(pi.get());
    624620    if (m_view && !pi->attached())
    625621        pi->attach();
     
    639635
    640636    RefPtr<Node> newNode = CDATASection::create(document(), m_stream.text());
    641     if (!m_currentNode->legacyParserAddChild(newNode.get()))
    642         return;
     637
     638    m_currentNode->parserAddChild(newNode.get());
    643639    if (m_view && !newNode->attached())
    644640        newNode->attach();
     
    650646
    651647    RefPtr<Node> newNode = Comment::create(document(), m_stream.text());
    652     m_currentNode->legacyParserAddChild(newNode.get());
     648
     649    m_currentNode->parserAddChild(newNode.get());
    653650    if (m_view && !newNode->attached())
    654651        newNode->attach();
     
    709706#endif
    710707    if (!m_parsingFragment)
    711         document()->legacyParserAddChild(DocumentType::create(document(), name, publicId, systemId));
    712 
    713 }
    714 }
    715 
     708        document()->parserAddChild(DocumentType::create(document(), name, publicId, systemId));
     709
     710}
     711}
     712
  • trunk/WebCore/html/HTMLDataGridElement.cpp

    r61293 r65986  
    5454{
    5555    m_columns->clearDataGrid();
    56 }
    57 
    58 bool HTMLDataGridElement::checkDTD(const Node* newChild)
    59 {
    60     if (newChild->isTextNode())
    61         return static_cast<const Text*>(newChild)->containsOnlyWhitespace();
    62     return newChild->hasTagName(dcolTag) || newChild->hasTagName(drowTag);
    6356}
    6457
  • trunk/WebCore/html/HTMLDataGridElement.h

    r65982 r65986  
    5757    HTMLDataGridElement(const QualifiedName&, Document*);
    5858
    59     virtual bool checkDTD(const Node*);
    60 
    6159    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
    6260
  • trunk/WebCore/html/HTMLDataGridRowElement.cpp

    r61293 r65986  
    4646}
    4747
    48 bool HTMLDataGridRowElement::checkDTD(const Node* newChild)
    49 {
    50     if (newChild->isTextNode())
    51         return static_cast<const Text*>(newChild)->containsOnlyWhitespace();
    52     return newChild->hasTagName(drowTag) || newChild->hasTagName(dcellTag);
    53 }
    54 
    5548bool HTMLDataGridRowElement::selected() const
    5649{
  • trunk/WebCore/html/HTMLDataGridRowElement.h

    r65982 r65986  
    4848private:
    4949    HTMLDataGridRowElement(const QualifiedName&, Document*);
    50 
    51     virtual bool checkDTD(const Node*);
    5250};
    5351
  • trunk/WebCore/html/HTMLDataListElement.cpp

    r61293 r65986  
    4848}
    4949
    50 bool HTMLDataListElement::checkDTD(const Node* newChild)
    51 {
    52     return newChild->hasTagName(HTMLNames::optionTag) || HTMLElement::inInlineTagList(newChild);
    53 }
    54 
    5550PassRefPtr<HTMLCollection> HTMLDataListElement::options()
    5651{
  • trunk/WebCore/html/HTMLDataListElement.h

    r60342 r65986  
    4848private:
    4949    HTMLDataListElement(const QualifiedName&, Document*);
    50 
    51     virtual bool checkDTD(const Node*);
    5250};
    5351
  • trunk/WebCore/html/HTMLDocument.cpp

    r65692 r65986  
    296296// not part of the DOM
    297297// --------------------------------------------------------------------------
    298 
    299 bool HTMLDocument::childAllowed(Node *newChild)
    300 {
    301     return newChild->hasTagName(htmlTag) || newChild->isCommentNode() || (newChild->nodeType() == DOCUMENT_TYPE_NODE && !doctype());
    302 }
    303298
    304299PassRefPtr<Element> HTMLDocument::createElement(const AtomicString& name, ExceptionCode& ec)
  • trunk/WebCore/html/HTMLDocument.h

    r65692 r65986  
    8484
    8585private:
    86     virtual bool childAllowed(Node*);
    87 
    8886    virtual PassRefPtr<Element> createElement(const AtomicString& tagName, ExceptionCode&);
    8987
  • trunk/WebCore/html/HTMLElement.cpp

    r65982 r65986  
    754754}
    755755
    756 // DOM Section 1.1.1
    757 bool HTMLElement::childAllowed(Node *newChild)
    758 {
    759     if (!Element::childAllowed(newChild))
    760         return false;
    761 
    762     // For XML documents, we are non-validating and do not check against a DTD, even for HTML elements.
    763     if (!document()->isHTMLDocument())
    764         return true;
    765 
    766     // Future-proof for XML content inside HTML documents (we may allow this some day).
    767     if (newChild->isElementNode() && !newChild->isHTMLElement())
    768         return true;
    769 
    770     // Elements with forbidden tag status can never have children
    771     if (endTagRequirement() == TagStatusForbidden)
    772         return false;
    773 
    774     // Comment nodes are always allowed.
    775     if (newChild->isCommentNode())
    776         return true;
    777 
    778     // Now call checkDTD.
    779     return checkDTD(newChild);
    780 }
    781 
    782756// DTD Stuff
    783757// This unfortunate function is only needed when checking against the DTD.  Other languages (like SVG) won't need this.
     758// FIXME: Remove if only used by LegacyHTMLTreeBuilder.
    784759bool HTMLElement::isRecognizedTagName(const QualifiedName& tagName)
    785760{
     
    980955}
    981956
    982 bool HTMLElement::checkDTD(const Node* newChild)
    983 {
    984     if (hasLocalName(addressTag) && newChild->hasTagName(pTag))
    985         return true;
    986     return inEitherTagList(newChild);
    987 }
    988 
    989957bool HTMLElement::rendererIsNeeded(RenderStyle *style)
    990958{
  • trunk/WebCore/html/HTMLElement.h

    r65982 r65986  
    9090    virtual void parseMappedAttribute(Attribute*);
    9191
    92     virtual bool childAllowed(Node* newChild); // Error-checking during parsing that checks the DTD
    93 
    94     // Helper function to check the DTD for a given child node.
    95     virtual bool checkDTD(const Node*);
    96 
    9792    static bool inEitherTagList(const Node*);
    9893    static bool inInlineTagList(const Node*);
  • trunk/WebCore/html/HTMLFieldSetElement.cpp

    r61293 r65986  
    4545}
    4646
    47 bool HTMLFieldSetElement::checkDTD(const Node* newChild)
    48 {
    49     return newChild->hasTagName(legendTag) || HTMLElement::checkDTD(newChild);
    50 }
    51 
    5247bool HTMLFieldSetElement::supportsFocus() const
    5348{
  • trunk/WebCore/html/HTMLFieldSetElement.h

    r65982 r65986  
    3636    HTMLFieldSetElement(const QualifiedName&, Document*, HTMLFormElement*);
    3737
    38     virtual bool checkDTD(const Node* newChild);
    39 
    4038    virtual bool supportsFocus() const;
    4139    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
  • trunk/WebCore/html/HTMLFrameSetElement.cpp

    r64383 r65986  
    5858{
    5959    return adoptRef(new HTMLFrameSetElement(tagName, document));
    60 }
    61 
    62 bool HTMLFrameSetElement::checkDTD(const Node* newChild)
    63 {
    64     // FIXME: Old code had adjacent double returns and seemed to want to do something with NOFRAMES (but didn't).
    65     // What is the correct behavior?
    66     if (newChild->isTextNode())
    67         return static_cast<const Text*>(newChild)->containsOnlyWhitespace();
    68     return newChild->hasTagName(framesetTag) || newChild->hasTagName(frameTag);
    6960}
    7061
  • trunk/WebCore/html/HTMLFrameSetElement.h

    r65982 r65986  
    6969
    7070    virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
    71     virtual bool checkDTD(const Node* newChild);
    7271
    7372    virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const;
  • trunk/WebCore/html/HTMLHeadElement.cpp

    r61959 r65986  
    4848}
    4949
    50 bool HTMLHeadElement::childAllowed(Node* newChild)
    51 {
    52     // Do not allow non-whitespace text nodes in the head
    53     if (newChild->isTextNode())
    54         return static_cast<Text*>(newChild)->containsOnlyWhitespace();
    55    
    56     return HTMLElement::childAllowed(newChild);
    5750}
    58 
    59 bool HTMLHeadElement::checkDTD(const Node* newChild)
    60 {
    61     return newChild->hasTagName(noscriptTag) || newChild->hasTagName(titleTag) || newChild->hasTagName(isindexTag) ||
    62            newChild->hasTagName(baseTag) || newChild->hasTagName(scriptTag) ||
    63            newChild->hasTagName(styleTag) || newChild->hasTagName(metaTag) ||
    64            newChild->hasTagName(linkTag) || newChild->isTextNode();
    65 }
    66 
    67 }
  • trunk/WebCore/html/HTMLHeadElement.h

    r65982 r65986  
    3838
    3939    virtual HTMLTagStatus endTagRequirement() const { return TagStatusOptional; }
    40     virtual bool childAllowed(Node* newChild);
    41     virtual bool checkDTD(const Node* newChild);
    4240};
    4341
  • trunk/WebCore/html/HTMLHeadingElement.cpp

    r61959 r65986  
    2424#include "HTMLHeadingElement.h"
    2525
    26 #include "HTMLNames.h"
    27 
    2826namespace WebCore {
    29 
    30 using namespace HTMLNames;
    3127
    3228inline HTMLHeadingElement::HTMLHeadingElement(const QualifiedName& tagName, Document* document)
     
    4036}
    4137
    42 bool HTMLHeadingElement::checkDTD(const Node* newChild)
    43 {
    44     if (newChild->hasTagName(h1Tag) || newChild->hasTagName(h2Tag) ||
    45         newChild->hasTagName(h3Tag) || newChild->hasTagName(h4Tag) ||
    46         newChild->hasTagName(h5Tag) || newChild->hasTagName(h6Tag))
    47         return false;
    48 
    49     return inEitherTagList(newChild);
    5038}
    51 
    52 }
  • trunk/WebCore/html/HTMLHeadingElement.h

    r65982 r65986  
    3636
    3737    virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
    38     virtual bool checkDTD(const Node* newChild);
    3938};
    4039
  • trunk/WebCore/html/HTMLHtmlElement.cpp

    r61959 r65986  
    5151}
    5252
    53 bool HTMLHtmlElement::checkDTD(const Node* newChild)
    54 {
    55     return newChild->hasTagName(headTag) || newChild->hasTagName(bodyTag) ||
    56            newChild->hasTagName(framesetTag) || newChild->hasTagName(noframesTag);
    57 }
    58 
    5953#if ENABLE(OFFLINE_WEB_APPLICATIONS)
    6054void HTMLHtmlElement::insertedIntoDocument()
  • trunk/WebCore/html/HTMLHtmlElement.h

    r65982 r65986  
    3838
    3939    virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
    40     virtual bool checkDTD(const Node* newChild);
    4140
    4241#if ENABLE(OFFLINE_WEB_APPLICATIONS)
  • trunk/WebCore/html/HTMLKeygenElement.cpp

    r62079 r65986  
    4646    ASSERT(hasTagName(keygenTag));
    4747
     48    // FIXME: This markup should go in the shadow tree.
    4849    // Add one option element for each key size.
    4950    Vector<String> keys;
     
    5152    for (size_t i = 0; i < keys.size(); ++i) {
    5253        RefPtr<HTMLOptionElement> option = HTMLOptionElement::create(document, this->form());
    53         legacyParserAddChild(option);
    54         option->legacyParserAddChild(Text::create(document, keys[i]));
     54        parserAddChild(option);
     55        option->parserAddChild(Text::create(document, keys[i]));
    5556    }
    5657}
  • trunk/WebCore/html/HTMLMapElement.cpp

    r61959 r65986  
    5757HTMLMapElement::~HTMLMapElement()
    5858{
    59 }
    60 
    61 bool HTMLMapElement::checkDTD(const Node* newChild)
    62 {
    63     return inEitherTagList(newChild) || newChild->hasTagName(areaTag) // HTML 4 DTD
    64         || newChild->hasTagName(scriptTag); // extensions
    6559}
    6660
  • trunk/WebCore/html/HTMLMapElement.h

    r65982 r65986  
    4949
    5050    virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
    51     virtual bool checkDTD(const Node*);
    5251
    5352    virtual void parseMappedAttribute(Attribute*);
  • trunk/WebCore/html/HTMLMediaElement.cpp

    r65324 r65986  
    161161    document()->registerForMediaVolumeCallbacks(this);
    162162    HTMLElement::didMoveToNewOwnerDocument();
    163 }
    164 
    165 
    166 bool HTMLMediaElement::checkDTD(const Node* newChild)
    167 {
    168     return newChild->hasTagName(sourceTag) || HTMLElement::checkDTD(newChild);
    169163}
    170164
  • trunk/WebCore/html/HTMLMediaElement.h

    r65170 r65986  
    184184
    185185private:
    186     virtual bool checkDTD(const Node* newChild);   
    187186    virtual void attributeChanged(Attribute*, bool preserveDecls);
    188187    virtual bool rendererIsNeeded(RenderStyle*);
  • trunk/WebCore/html/HTMLNoScriptElement.cpp

    r61293 r65986  
    4343}
    4444
    45 bool HTMLNoScriptElement::checkDTD(const Node* newChild)
    46 {
    47     return newChild->isTextNode() || inBlockTagList(newChild);
    48 }
    49 
    5045void HTMLNoScriptElement::attach()
    5146{
  • trunk/WebCore/html/HTMLNoScriptElement.h

    r60361 r65986  
    3535    HTMLNoScriptElement(const QualifiedName&, Document*);
    3636
    37     virtual bool checkDTD(const Node*);
    3837    virtual void attach();
    3938    virtual void recalcStyle(StyleChange);
  • trunk/WebCore/html/HTMLOptGroupElement.cpp

    r61959 r65986  
    8787}
    8888
    89 bool HTMLOptGroupElement::checkDTD(const Node* newChild)
    90 {
    91     // Make sure to keep this in sync with <select> (other than not allowing an optgroup).
    92     return newChild->isTextNode() || newChild->hasTagName(HTMLNames::optionTag) || newChild->hasTagName(HTMLNames::hrTag) || newChild->hasTagName(HTMLNames::scriptTag);
    93 }
    94 
    9589void HTMLOptGroupElement::attach()
    9690{
  • trunk/WebCore/html/HTMLOptGroupElement.h

    r61959 r65986  
    4343    HTMLOptGroupElement(const QualifiedName&, Document*, HTMLFormElement*);
    4444
    45     virtual bool checkDTD(const Node*);
    4645    virtual const AtomicString& formControlType() const;
    4746    virtual bool supportsFocus() const;
  • trunk/WebCore/html/HTMLOptionElement.cpp

    r61963 r65986  
    7979}
    8080
    81 bool HTMLOptionElement::checkDTD(const Node* newChild)
    82 {
    83     return newChild->isTextNode() || newChild->hasTagName(scriptTag);
    84 }
    85 
    8681void HTMLOptionElement::attach()
    8782{
  • trunk/WebCore/html/HTMLOptionElement.h

    r65982 r65986  
    6868
    6969    virtual HTMLTagStatus endTagRequirement() const { return TagStatusOptional; }
    70     virtual bool checkDTD(const Node* newChild);
    7170    virtual bool supportsFocus() const;
    7271    virtual bool isFocusable() const;
  • trunk/WebCore/html/HTMLParagraphElement.cpp

    r61959 r65986  
    4545}
    4646
    47 bool HTMLParagraphElement::checkDTD(const Node* newChild)
    48 {
    49     return inInlineTagList(newChild) || (document()->inCompatMode() && newChild->hasTagName(tableTag));
    50 }
    51 
    5247bool HTMLParagraphElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    5348{
  • trunk/WebCore/html/HTMLParagraphElement.h

    r65982 r65986  
    3636
    3737    virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
    38     virtual bool checkDTD(const Node* newChild);
    3938
    4039    virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
  • trunk/WebCore/html/HTMLPlugInElement.cpp

    r64093 r65986  
    144144}
    145145
    146 bool HTMLPlugInElement::checkDTD(const Node* newChild)
    147 {
    148     return newChild->hasTagName(paramTag) || HTMLFrameOwnerElement::checkDTD(newChild);
    149 }
    150 
    151146void HTMLPlugInElement::defaultEventHandler(Event* event)
    152147{
  • trunk/WebCore/html/HTMLPlugInElement.h

    r64093 r65986  
    6767
    6868    virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
    69     virtual bool checkDTD(const Node* newChild);
    7069
    7170    virtual void updateWidget() { }
  • trunk/WebCore/html/HTMLScriptElement.h

    r65982 r65986  
    5151
    5252    virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
    53     virtual bool checkDTD(const Node* newChild) { return newChild->isTextNode(); }
    5453
    5554    virtual void parseMappedAttribute(Attribute*);
  • trunk/WebCore/html/HTMLSelectElement.cpp

    r62391 r65986  
    5959}
    6060
    61 bool HTMLSelectElement::checkDTD(const Node* newChild)
    62 {
    63     // Make sure to keep <optgroup> in sync with this.
    64     return newChild->isTextNode() || newChild->hasTagName(optionTag) || newChild->hasTagName(optgroupTag) || newChild->hasTagName(hrTag) ||
    65            newChild->hasTagName(scriptTag);
    66 }
    67 
    6861void HTMLSelectElement::recalcStyle(StyleChange change)
    6962{
  • trunk/WebCore/html/HTMLSelectElement.h

    r65982 r65986  
    8787
    8888private:
    89     virtual bool checkDTD(const Node* newChild);
    90 
    9189    virtual const AtomicString& formControlType() const;
    9290   
  • trunk/WebCore/html/HTMLStyleElement.h

    r65982 r65986  
    4343
    4444    virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
    45     virtual bool checkDTD(const Node* newChild) { return newChild->isTextNode(); }
    4645
    4746    // overload from HTMLElement
  • trunk/WebCore/html/HTMLTableColElement.cpp

    r65982 r65986  
    5151{
    5252    return hasLocalName(colTag) ? TagStatusForbidden : TagStatusOptional;
    53 }
    54 
    55 bool HTMLTableColElement::checkDTD(const Node* newChild)
    56 {
    57     if (hasLocalName(colTag))
    58         return false;
    59    
    60     if (newChild->isTextNode())
    61         return static_cast<const Text*>(newChild)->containsOnlyWhitespace();
    62     return newChild->hasTagName(colTag);
    6353}
    6454
  • trunk/WebCore/html/HTMLTableColElement.h

    r65982 r65986  
    4444
    4545    virtual HTMLTagStatus endTagRequirement() const;
    46     virtual bool checkDTD(const Node*);
    4746    virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
    4847    virtual void parseMappedAttribute(Attribute*);
  • trunk/WebCore/html/HTMLTableElement.cpp

    r62079 r65986  
    6464}
    6565
    66 bool HTMLTableElement::checkDTD(const Node* newChild)
    67 {
    68     if (newChild->isTextNode())
    69         return static_cast<const Text*>(newChild)->containsOnlyWhitespace();
    70     return newChild->hasTagName(captionTag) ||
    71            newChild->hasTagName(colTag) || newChild->hasTagName(colgroupTag) ||
    72            newChild->hasTagName(theadTag) || newChild->hasTagName(tfootTag) ||
    73            newChild->hasTagName(tbodyTag) || newChild->hasTagName(formTag) ||
    74            newChild->hasTagName(scriptTag);
    75 }
    76 
    7766HTMLTableCaptionElement* HTMLTableElement::caption() const
    7867{
     
    250239    }
    251240    row->remove(ec);
    252 }
    253 
    254 ContainerNode* HTMLTableElement::legacyParserAddChild(PassRefPtr<Node> child)
    255 {
    256     if (child->hasTagName(formTag)) {
    257         // First add the child.
    258         HTMLElement::legacyParserAddChild(child);
    259 
    260         // Now simply return ourselves as the container to insert into.
    261         // This has the effect of demoting the form to a leaf and moving it safely out of the way.
    262         return this;
    263     }
    264 
    265     return HTMLElement::legacyParserAddChild(child.get());
    266241}
    267242
  • trunk/WebCore/html/HTMLTableElement.h

    r65982 r65986  
    6464    String summary() const;
    6565
    66     virtual ContainerNode* legacyParserAddChild(PassRefPtr<Node>);
    67 
    6866    virtual void attach();
    6967
     
    7573
    7674    virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
    77     virtual bool checkDTD(const Node*);
    7875
    7976    virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
  • trunk/WebCore/html/HTMLTableRowElement.cpp

    r62079 r65986  
    5353{
    5454    return adoptRef(new HTMLTableRowElement(tagName, document));
    55 }
    56 
    57 bool HTMLTableRowElement::checkDTD(const Node* newChild)
    58 {
    59     if (newChild->isTextNode())
    60         return static_cast<const Text*>(newChild)->containsOnlyWhitespace();
    61     return newChild->hasTagName(tdTag) || newChild->hasTagName(thTag) ||
    62            newChild->hasTagName(formTag) || newChild->hasTagName(scriptTag);
    63 }
    64 
    65 ContainerNode* HTMLTableRowElement::legacyParserAddChild(PassRefPtr<Node> child)
    66 {
    67     if (child->hasTagName(formTag)) {
    68         // First add the child.
    69         HTMLTablePartElement::legacyParserAddChild(child);
    70 
    71         // Now simply return ourselves as the container to insert into.
    72         // This has the effect of demoting the form to a leaf and moving it safely out of the way.
    73         return this;
    74     }
    75 
    76     return HTMLTablePartElement::legacyParserAddChild(child);
    7755}
    7856
  • trunk/WebCore/html/HTMLTableRowElement.h

    r65982 r65986  
    3636    static PassRefPtr<HTMLTableRowElement> create(const QualifiedName&, Document*);
    3737
    38     virtual ContainerNode* legacyParserAddChild(PassRefPtr<Node>);
    39 
    4038    int rowIndex() const;
    4139    void setRowIndex(int);
     
    5452
    5553    virtual HTMLTagStatus endTagRequirement() const { return TagStatusOptional; }
    56     virtual bool checkDTD(const Node*);
    5754};
    5855
  • trunk/WebCore/html/HTMLTableSectionElement.cpp

    r62079 r65986  
    4646{
    4747    return adoptRef(new HTMLTableSectionElement(tagName, document));
    48 }
    49 
    50 bool HTMLTableSectionElement::checkDTD(const Node* newChild)
    51 {
    52     if (newChild->isTextNode())
    53         return static_cast<const Text*>(newChild)->containsOnlyWhitespace();
    54     return newChild->hasTagName(trTag) || newChild->hasTagName(formTag) ||
    55            newChild->hasTagName(scriptTag);
    56 }
    57 
    58 ContainerNode* HTMLTableSectionElement::legacyParserAddChild(PassRefPtr<Node> child)
    59 {
    60     if (child->hasTagName(formTag)) {
    61         // First add the child.
    62         HTMLTablePartElement::legacyParserAddChild(child);
    63 
    64         // Now simply return ourselves as the container to insert into.
    65         // This has the effect of demoting the form to a leaf and moving it safely out of the way.
    66         return this;
    67     }
    68 
    69     return HTMLTablePartElement::legacyParserAddChild(child);
    7048}
    7149
  • trunk/WebCore/html/HTMLTableSectionElement.h

    r65982 r65986  
    3535    static PassRefPtr<HTMLTableSectionElement> create(const QualifiedName&, Document*);
    3636
    37     virtual ContainerNode* legacyParserAddChild(PassRefPtr<Node>);
    38 
    3937    PassRefPtr<HTMLElement> insertRow(int index, ExceptionCode&);
    4038    void deleteRow(int index, ExceptionCode&);
     
    6058
    6159    virtual HTMLTagStatus endTagRequirement() const { return TagStatusOptional; }
    62     virtual bool checkDTD(const Node*);
    6360    virtual bool canHaveAdditionalAttributeStyleDecls() const { return true; }
    6461    virtual void additionalAttributeStyleDecls(Vector<CSSMutableStyleDeclaration*>&);
  • trunk/WebCore/html/HTMLTextAreaElement.h

    r61959 r65986  
    7777    virtual void defaultEventHandler(Event*);
    7878
    79     virtual bool checkDTD(const Node* newChild) { return newChild->isTextNode(); }
    80 
    8179    virtual bool isEnumeratable() const { return true; }
    8280
  • trunk/WebCore/html/HTMLTitleElement.h

    r60361 r65986  
    3737    HTMLTitleElement(const QualifiedName&, Document*);
    3838
    39     virtual bool checkDTD(const Node* newChild) { return newChild->isTextNode(); }
    40 
    4139    virtual void insertedIntoDocument();
    4240    virtual void removedFromDocument();
  • trunk/WebCore/rendering/MediaControlElements.cpp

    r62821 r65986  
    136136void MediaControlElement::attachToParent(Element* parent)
    137137{
    138     parent->legacyParserAddChild(this);
     138    // FIXME: This code seems very wrong.  Why are we magically adding |this| to the DOM here?
     139    //        We shouldn't be calling parser API methods outside of the parser!
     140    parent->parserAddChild(this);
    139141}
    140142
     
    393395void MediaControlInputElement::attachToParent(Element* parent)
    394396{
    395     parent->legacyParserAddChild(this);
     397    // FIXME: This code seems very wrong.  Why are we magically adding |this| to the DOM here?
     398    //        We shouldn't be calling parser API methods outside of the parser!
     399    parent->parserAddChild(this);
    396400}
    397401
  • trunk/WebCore/rendering/TextControlInnerElements.cpp

    r65856 r65986  
    113113   
    114114    // For elements without a shadow parent, add the node to the DOM normally.
    115     if (!m_shadowParent)
    116         parent->legacyParserAddChild(this);
    117    
     115    if (!m_shadowParent) {
     116        // FIXME: This code seems very wrong.  Why are we magically adding |this| to the DOM here?
     117        //        We shouldn't be calling parser API methods outside of the parser!
     118        parent->deprecatedParserAddChild(this);
     119    }
     120 
    118121    // Add the renderer to the render tree
    119122    if (renderer)
Note: See TracChangeset for help on using the changeset viewer.