Changeset 123577 in webkit
- Timestamp:
- Jul 24, 2012 10:47:29 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r123572 r123577 1 2012-07-24 Kwang Yul Seo <skyul@company100.net> 2 3 Read tag names and attributes from the saved tokens where possible. 4 https://bugs.webkit.org/show_bug.cgi?id=92079 5 6 Reviewed by Adam Barth. 7 8 Read tag names and attributes from the saved tokens, not from the DOM. 9 Also added convenient methods such as hasLocalName, hasTagName, localName, 10 isElementNode and isDocumentFragmentNode to HTMLStackItem class. 11 12 No new tests, covered by existing tests. 13 14 * html/parser/HTMLConstructionSite.cpp: 15 (WebCore::HTMLNames::hasImpliedEndTag): 16 (WebCore::HTMLNames::causesFosterParenting): 17 (WebCore::HTMLConstructionSite::generateImpliedEndTagsWithExclusion): 18 (WebCore::HTMLConstructionSite::generateImpliedEndTags): 19 (WebCore::HTMLConstructionSite::shouldFosterParent): 20 * html/parser/HTMLConstructionSite.h: 21 (WebCore::HTMLConstructionSite::currentStackItem): 22 * html/parser/HTMLElementStack.cpp: 23 (WebCore::HTMLNames::isNumberedHeaderElement): 24 (WebCore::HTMLNames::isRootNode): 25 (WebCore::HTMLNames::isScopeMarker): 26 (WebCore::HTMLNames::isListItemScopeMarker): 27 (WebCore::HTMLNames::isTableScopeMarker): 28 (WebCore::HTMLNames::isTableBodyScopeMarker): 29 (WebCore::HTMLNames::isTableRowScopeMarker): 30 (WebCore::HTMLNames::isForeignContentScopeMarker): 31 (WebCore::HTMLNames::isButtonScopeMarker): 32 (WebCore::HTMLNames::isSelectScopeMarker): 33 (WebCore::HTMLElementStack::ElementRecord::replaceElement): 34 (WebCore::HTMLElementStack::popUntilNumberedHeaderElementPopped): 35 (WebCore::HTMLElementStack::popUntilTableScopeMarker): 36 (WebCore::HTMLElementStack::popUntilTableBodyScopeMarker): 37 (WebCore::HTMLElementStack::popUntilTableRowScopeMarker): 38 (WebCore::HTMLElementStack::isMathMLTextIntegrationPoint): 39 (WebCore::HTMLElementStack::isHTMLIntegrationPoint): 40 (WebCore::HTMLElementStack::popUntilForeignContentScopeMarker): 41 (WebCore::HTMLElementStack::pushRootNode): 42 (WebCore::HTMLElementStack::oneBelowTop): 43 (WebCore::HTMLElementStack::topmost): 44 (WebCore): 45 (WebCore::inScopeCommon): 46 (WebCore::HTMLElementStack::hasNumberedHeaderElementInScope): 47 (WebCore::HTMLElementStack::inScope): 48 * html/parser/HTMLElementStack.h: 49 (WebCore::HTMLElementStack::topStackItem): 50 (HTMLElementStack): 51 (WebCore::isInHTMLNamespace): 52 * html/parser/HTMLStackItem.h: 53 (WebCore::HTMLStackItem::isDocumentFragmentNode): 54 (WebCore::HTMLStackItem::isElementNode): 55 (HTMLStackItem): 56 (WebCore::HTMLStackItem::hasLocalName): 57 (WebCore::HTMLStackItem::hasTagName): 58 (WebCore::HTMLStackItem::HTMLStackItem): 59 * html/parser/HTMLTreeBuilder.cpp: 60 (WebCore): 61 (WebCore::HTMLTreeBuilder::constructTreeFromAtomicToken): 62 (WebCore::HTMLTreeBuilder::processFakeEndTag): 63 (WebCore::HTMLTreeBuilder::processCloseWhenNestedTag): 64 (WebCore::HTMLTreeBuilder::processStartTagForInBody): 65 (WebCore::HTMLTreeBuilder::processStartTag): 66 (WebCore::HTMLTreeBuilder::processAnyOtherEndTagForInBody): 67 (WebCore::HTMLTreeBuilder::furthestBlockForFormattingElement): 68 (WebCore::HTMLTreeBuilder::callTheAdoptionAgency): 69 (WebCore::HTMLTreeBuilder::processEndTagForInTableBody): 70 (WebCore::HTMLTreeBuilder::processEndTagForInCell): 71 (WebCore::HTMLTreeBuilder::processEndTagForInBody): 72 (WebCore::HTMLTreeBuilder::processCaptionEndTagForInCaption): 73 (WebCore::HTMLTreeBuilder::processTrEndTagForInRow): 74 (WebCore::HTMLTreeBuilder::processEndTag): 75 (WebCore::HTMLTreeBuilder::processCharacterBuffer): 76 (WebCore::HTMLTreeBuilder::processEndOfFile): 77 (WebCore::HTMLTreeBuilder::shouldProcessTokenInForeignContent): 78 (WebCore::HTMLTreeBuilder::processTokenInForeignContent): 79 * html/parser/HTMLTreeBuilder.h: 80 1 81 2012-07-24 Hironori Bono <hbono@chromium.org> 2 82 -
trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp
r123399 r123577 61 61 namespace { 62 62 63 bool hasImpliedEndTag( ContainerNode* node)64 { 65 return node->hasTagName(ddTag)66 || node->hasTagName(dtTag)67 || node->hasTagName(liTag)68 || node->hasTagName(optionTag)69 || node->hasTagName(optgroupTag)70 || node->hasTagName(pTag)71 || node->hasTagName(rpTag)72 || node->hasTagName(rtTag);73 } 74 75 bool causesFosterParenting(const QualifiedName& tagName)76 { 77 return tagName == tableTag78 || tagName == tbodyTag79 || tagName == tfootTag80 || tagName == theadTag81 || tagName == trTag;63 bool hasImpliedEndTag(const HTMLStackItem* item) 64 { 65 return item->hasTagName(ddTag) 66 || item->hasTagName(dtTag) 67 || item->hasTagName(liTag) 68 || item->hasTagName(optionTag) 69 || item->hasTagName(optgroupTag) 70 || item->hasTagName(pTag) 71 || item->hasTagName(rpTag) 72 || item->hasTagName(rtTag); 73 } 74 75 bool causesFosterParenting(const HTMLStackItem* item) 76 { 77 return item->hasTagName(tableTag) 78 || item->hasTagName(tbodyTag) 79 || item->hasTagName(tfootTag) 80 || item->hasTagName(theadTag) 81 || item->hasTagName(trTag); 82 82 } 83 83 … … 466 466 void HTMLConstructionSite::generateImpliedEndTagsWithExclusion(const AtomicString& tagName) 467 467 { 468 while (hasImpliedEndTag(current Node()) && !currentNode()->hasLocalName(tagName))468 while (hasImpliedEndTag(currentStackItem()) && !currentStackItem()->hasLocalName(tagName)) 469 469 m_openElements.pop(); 470 470 } … … 472 472 void HTMLConstructionSite::generateImpliedEndTags() 473 473 { 474 while (hasImpliedEndTag(current Node()))474 while (hasImpliedEndTag(currentStackItem())) 475 475 m_openElements.pop(); 476 476 } … … 496 496 { 497 497 return m_redirectAttachToFosterParent 498 && current Node()->isElementNode()499 && causesFosterParenting(current Element()->tagQName());498 && currentStackItem()->isElementNode() 499 && causesFosterParenting(currentStackItem()); 500 500 } 501 501 -
trunk/Source/WebCore/html/parser/HTMLConstructionSite.h
r123399 r123577 122 122 Element* currentElement() const { return m_openElements.top(); } 123 123 ContainerNode* currentNode() const { return m_openElements.topNode(); } 124 HTMLStackItem* currentStackItem() const { return m_openElements.topStackItem(); } 124 125 Element* oneBelowTop() const { return m_openElements.oneBelowTop(); } 125 126 -
trunk/Source/WebCore/html/parser/HTMLElementStack.cpp
r123399 r123577 41 41 namespace { 42 42 43 inline bool isNumberedHeaderElement( ContainerNode* node)44 { 45 return node->hasTagName(h1Tag)46 || node->hasTagName(h2Tag)47 || node->hasTagName(h3Tag)48 || node->hasTagName(h4Tag)49 || node->hasTagName(h5Tag)50 || node->hasTagName(h6Tag);43 inline bool isNumberedHeaderElement(HTMLStackItem* item) 44 { 45 return item->hasTagName(h1Tag) 46 || item->hasTagName(h2Tag) 47 || item->hasTagName(h3Tag) 48 || item->hasTagName(h4Tag) 49 || item->hasTagName(h5Tag) 50 || item->hasTagName(h6Tag); 51 51 } 52 52 53 inline bool isRootNode( ContainerNode* node)54 { 55 return node->nodeType() == Node::DOCUMENT_FRAGMENT_NODE56 || 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);105 } 106 107 inline bool isForeignContentScopeMarker( ContainerNode* node)108 { 109 return HTMLElementStack::isMathMLTextIntegrationPoint( node)110 || HTMLElementStack::isHTMLIntegrationPoint( node)111 || isInHTMLNamespace( node);112 } 113 114 inline bool isButtonScopeMarker( ContainerNode* node)115 { 116 return isScopeMarker( node)117 || node->hasTagName(buttonTag);118 } 119 120 inline bool isSelectScopeMarker( ContainerNode* node)121 { 122 return ! node->hasTagName(optgroupTag)123 && ! node->hasTagName(optionTag);53 inline bool isRootNode(HTMLStackItem* item) 54 { 55 return item->isDocumentFragmentNode() 56 || item->hasTagName(htmlTag); 57 } 58 59 inline bool isScopeMarker(HTMLStackItem* item) 60 { 61 return item->hasTagName(appletTag) 62 || item->hasTagName(captionTag) 63 || item->hasTagName(marqueeTag) 64 || item->hasTagName(objectTag) 65 || item->hasTagName(tableTag) 66 || item->hasTagName(tdTag) 67 || item->hasTagName(thTag) 68 || item->hasTagName(MathMLNames::miTag) 69 || item->hasTagName(MathMLNames::moTag) 70 || item->hasTagName(MathMLNames::mnTag) 71 || item->hasTagName(MathMLNames::msTag) 72 || item->hasTagName(MathMLNames::mtextTag) 73 || item->hasTagName(MathMLNames::annotation_xmlTag) 74 || item->hasTagName(SVGNames::foreignObjectTag) 75 || item->hasTagName(SVGNames::descTag) 76 || item->hasTagName(SVGNames::titleTag) 77 || isRootNode(item); 78 } 79 80 inline bool isListItemScopeMarker(HTMLStackItem* item) 81 { 82 return isScopeMarker(item) 83 || item->hasTagName(olTag) 84 || item->hasTagName(ulTag); 85 } 86 87 inline bool isTableScopeMarker(HTMLStackItem* item) 88 { 89 return item->hasTagName(tableTag) 90 || isRootNode(item); 91 } 92 93 inline bool isTableBodyScopeMarker(HTMLStackItem* item) 94 { 95 return item->hasTagName(tbodyTag) 96 || item->hasTagName(tfootTag) 97 || item->hasTagName(theadTag) 98 || isRootNode(item); 99 } 100 101 inline bool isTableRowScopeMarker(HTMLStackItem* item) 102 { 103 return item->hasTagName(trTag) 104 || isRootNode(item); 105 } 106 107 inline bool isForeignContentScopeMarker(HTMLStackItem* item) 108 { 109 return HTMLElementStack::isMathMLTextIntegrationPoint(item) 110 || HTMLElementStack::isHTMLIntegrationPoint(item) 111 || isInHTMLNamespace(item); 112 } 113 114 inline bool isButtonScopeMarker(HTMLStackItem* item) 115 { 116 return isScopeMarker(item) 117 || item->hasTagName(buttonTag); 118 } 119 120 inline bool isSelectScopeMarker(HTMLStackItem* item) 121 { 122 return !item->hasTagName(optgroupTag) 123 && !item->hasTagName(optionTag); 124 124 } 125 125 … … 140 140 { 141 141 ASSERT(item); 142 ASSERT(!m_item || m_item-> node()->isElementNode());142 ASSERT(!m_item || m_item->isElementNode()); 143 143 // FIXME: Should this call finishParsingChildren? 144 144 m_item = item; … … 232 232 void HTMLElementStack::popUntilNumberedHeaderElementPopped() 233 233 { 234 while (!isNumberedHeaderElement(top Node()))234 while (!isNumberedHeaderElement(topStackItem())) 235 235 pop(); 236 236 pop(); … … 252 252 { 253 253 // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#clear-the-stack-back-to-a-table-context 254 while (!isTableScopeMarker(top Node()))254 while (!isTableScopeMarker(topStackItem())) 255 255 pop(); 256 256 } … … 259 259 { 260 260 // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#clear-the-stack-back-to-a-table-body-context 261 while (!isTableBodyScopeMarker(top Node()))261 while (!isTableBodyScopeMarker(topStackItem())) 262 262 pop(); 263 263 } … … 266 266 { 267 267 // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#clear-the-stack-back-to-a-table-row-context 268 while (!isTableRowScopeMarker(top Node()))268 while (!isTableRowScopeMarker(topStackItem())) 269 269 pop(); 270 270 } 271 271 272 272 // http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html#mathml-text-integration-point 273 bool HTMLElementStack::isMathMLTextIntegrationPoint( ContainerNode* node)274 { 275 if (! node->isElementNode())273 bool HTMLElementStack::isMathMLTextIntegrationPoint(HTMLStackItem* item) 274 { 275 if (!item->isElementNode()) 276 276 return false; 277 Element* element = static_cast<Element*>(node); 278 return element->hasTagName(MathMLNames::miTag) 279 || element->hasTagName(MathMLNames::moTag) 280 || element->hasTagName(MathMLNames::mnTag) 281 || element->hasTagName(MathMLNames::msTag) 282 || element->hasTagName(MathMLNames::mtextTag); 277 return item->hasTagName(MathMLNames::miTag) 278 || item->hasTagName(MathMLNames::moTag) 279 || item->hasTagName(MathMLNames::mnTag) 280 || item->hasTagName(MathMLNames::msTag) 281 || item->hasTagName(MathMLNames::mtextTag); 283 282 } 284 283 285 284 // http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html#html-integration-point 286 bool HTMLElementStack::isHTMLIntegrationPoint( ContainerNode* node)287 { 288 if (! node->isElementNode())285 bool HTMLElementStack::isHTMLIntegrationPoint(HTMLStackItem* item) 286 { 287 if (!item->isElementNode()) 289 288 return false; 290 Element* element = static_cast<Element*>(node);291 if (element->hasTagName(MathMLNames::annotation_xmlTag)) {292 // FIXME: Technically we shouldn't read back from the DOM here.293 // Instead, we're supposed to track this information in the element294 // stack, which lets the parser run on its own thread.295 String encoding = element->fastGetAttribute(MathMLNames::encodingAttr);296 return equalIgnoringCase(encoding, "text/html")297 || equalIgnoringCase(encoding, "application/xhtml+xml");298 } 299 return element->hasTagName(SVGNames::foreignObjectTag)300 || element->hasTagName(SVGNames::descTag)301 || element->hasTagName(SVGNames::titleTag);289 if (item->hasTagName(MathMLNames::annotation_xmlTag)) { 290 Attribute* encodingAttr = item->token()->getAttributeItem(MathMLNames::encodingAttr); 291 if (encodingAttr) { 292 const String& encoding = encodingAttr->value(); 293 return equalIgnoringCase(encoding, "text/html") 294 || equalIgnoringCase(encoding, "application/xhtml+xml"); 295 } 296 return false; 297 } 298 return item->hasTagName(SVGNames::foreignObjectTag) 299 || item->hasTagName(SVGNames::descTag) 300 || item->hasTagName(SVGNames::titleTag); 302 301 } 303 302 304 303 void HTMLElementStack::popUntilForeignContentScopeMarker() 305 304 { 306 while (!isForeignContentScopeMarker(top Node()))305 while (!isForeignContentScopeMarker(topStackItem())) 307 306 pop(); 308 307 } … … 310 309 void HTMLElementStack::pushRootNode(PassRefPtr<HTMLStackItem> rootItem) 311 310 { 312 ASSERT(rootItem-> node()->nodeType() == Node::DOCUMENT_FRAGMENT_NODE);311 ASSERT(rootItem->isDocumentFragmentNode()); 313 312 pushRootNodeCommon(rootItem); 314 313 } … … 390 389 ASSERT(m_top); 391 390 ASSERT(m_top->next()); 392 if (m_top->next()-> node()->isElementNode())391 if (m_top->next()->stackItem()->isElementNode()) 393 392 return m_top->next()->element(); 394 393 return 0; … … 433 432 { 434 433 for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) { 435 if (pos-> node()->hasLocalName(tagName))434 if (pos->stackItem()->hasLocalName(tagName)) 436 435 return pos; 437 436 } … … 449 448 } 450 449 451 template <bool isMarker( ContainerNode*)>450 template <bool isMarker(HTMLStackItem*)> 452 451 bool inScopeCommon(HTMLElementStack::ElementRecord* top, const AtomicString& targetTag) 453 452 { 454 453 for (HTMLElementStack::ElementRecord* pos = top; pos; pos = pos->next()) { 455 ContainerNode* node = pos->node();456 if ( node->hasLocalName(targetTag))454 HTMLStackItem* item = pos->stackItem().get(); 455 if (item->hasLocalName(targetTag)) 457 456 return true; 458 if (isMarker( node))457 if (isMarker(item)) 459 458 return false; 460 459 } … … 466 465 { 467 466 for (ElementRecord* record = m_top.get(); record; record = record->next()) { 468 ContainerNode* node = record->node();469 if (isNumberedHeaderElement( node))467 HTMLStackItem* item = record->stackItem().get(); 468 if (isNumberedHeaderElement(item)) 470 469 return true; 471 if (isScopeMarker( node))470 if (isScopeMarker(item)) 472 471 return false; 473 472 } … … 479 478 { 480 479 for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) { 481 ContainerNode* node = pos->node();482 if ( node== targetElement)480 HTMLStackItem* item = pos->stackItem().get(); 481 if (item->node() == targetElement) 483 482 return true; 484 if (isScopeMarker( node))483 if (isScopeMarker(item)) 485 484 return false; 486 485 } -
trunk/Source/WebCore/html/parser/HTMLElementStack.h
r123399 r123577 93 93 } 94 94 95 HTMLStackItem* topStackItem() const 96 { 97 ASSERT(m_top->stackItem()); 98 return m_top->stackItem().get(); 99 } 100 95 101 Element* oneBelowTop() const; 96 102 ElementRecord* topRecord() const; … … 121 127 void popAll(); 122 128 123 static bool isMathMLTextIntegrationPoint( ContainerNode*);124 static bool isHTMLIntegrationPoint( ContainerNode*);129 static bool isMathMLTextIntegrationPoint(HTMLStackItem*); 130 static bool isHTMLIntegrationPoint(HTMLStackItem*); 125 131 126 132 void remove(Element*); … … 176 182 }; 177 183 178 inline bool isInHTMLNamespace( Node* node)184 inline bool isInHTMLNamespace(const HTMLStackItem* item) 179 185 { 180 186 // A DocumentFragment takes the place of the document element when parsing 181 187 // fragments and should be considered in the HTML namespace. 182 return node->namespaceURI() == HTMLNames::xhtmlNamespaceURI183 || node->nodeType() == Node::DOCUMENT_FRAGMENT_NODE; // FIXME: Does this also apply to ShadowRoot?188 return item->namespaceURI() == HTMLNames::xhtmlNamespaceURI 189 || item->isDocumentFragmentNode(); // FIXME: Does this also apply to ShadowRoot? 184 190 } 185 191 -
trunk/Source/WebCore/html/parser/HTMLStackItem.h
r123537 r123577 56 56 ContainerNode* node() const { return m_node.get(); } 57 57 58 bool isDocumentFragmentNode() const { return m_isDocumentFragmentNode; } 59 bool isElementNode() const { return !m_isDocumentFragmentNode; } 60 58 61 AtomicHTMLToken* token() { return m_token.get(); } 59 62 const AtomicString& namespaceURI() const { return m_namespaceURI; } 60 63 const AtomicString& localName() const { return m_token->name(); } 64 65 bool hasLocalName(const AtomicString& name) const { return m_token->name() == name; } 66 bool hasTagName(const QualifiedName& name) const { return m_token->name() == name.localName() && m_namespaceURI == name.namespaceURI(); } 61 67 62 68 private: … … 65 71 , m_isDocumentFragmentNode(true) 66 72 { 73 // Create a fake token for a document fragment node. This looks ugly but required for performance 74 // because we want to use m_token->name() in localName(), hasLocalName() and hasTagName() without 75 // checking m_isDocumentFragmentNode flag. 76 m_token = AtomicHTMLToken::create(HTMLTokenTypes::StartTag, nullAtom); 67 77 } 68 78 -
trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp
r123536 r123577 110 110 111 111 // http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#special 112 bool isSpecialNode( Node* node)113 { 114 if ( node->hasTagName(MathMLNames::miTag)115 || node->hasTagName(MathMLNames::moTag)116 || node->hasTagName(MathMLNames::mnTag)117 || node->hasTagName(MathMLNames::msTag)118 || node->hasTagName(MathMLNames::mtextTag)119 || node->hasTagName(MathMLNames::annotation_xmlTag)120 || node->hasTagName(SVGNames::foreignObjectTag)121 || node->hasTagName(SVGNames::descTag)122 || node->hasTagName(SVGNames::titleTag))112 bool isSpecialNode(const HTMLStackItem* item) 113 { 114 if (item->hasTagName(MathMLNames::miTag) 115 || item->hasTagName(MathMLNames::moTag) 116 || item->hasTagName(MathMLNames::mnTag) 117 || item->hasTagName(MathMLNames::msTag) 118 || item->hasTagName(MathMLNames::mtextTag) 119 || item->hasTagName(MathMLNames::annotation_xmlTag) 120 || item->hasTagName(SVGNames::foreignObjectTag) 121 || item->hasTagName(SVGNames::descTag) 122 || item->hasTagName(SVGNames::titleTag)) 123 123 return true; 124 if ( node->nodeType() == Node::DOCUMENT_FRAGMENT_NODE)124 if (item->isDocumentFragmentNode()) 125 125 return true; 126 if (!isInHTMLNamespace( node))126 if (!isInHTMLNamespace(item)) 127 127 return false; 128 const AtomicString& tagName = node->localName();128 const AtomicString& tagName = item->localName(); 129 129 return tagName == addressTag 130 130 || tagName == appletTag … … 472 472 473 473 bool inForeignContent = !m_tree.isEmpty() 474 && !isInHTMLNamespace(m_tree.current Node())475 && !HTMLElementStack::isHTMLIntegrationPoint(m_tree.current Node())476 && !HTMLElementStack::isMathMLTextIntegrationPoint(m_tree.current Node());474 && !isInHTMLNamespace(m_tree.currentStackItem()) 475 && !HTMLElementStack::isHTMLIntegrationPoint(m_tree.currentStackItem()) 476 && !HTMLElementStack::isMathMLTextIntegrationPoint(m_tree.currentStackItem()); 477 477 478 478 m_parser->tokenizer()->setForceNullCharacterReplacement(m_insertionMode == TextMode || inForeignContent); … … 538 538 } 539 539 540 void HTMLTreeBuilder::processFakeEndTag(const AtomicString& tagName) 541 { 542 RefPtr<AtomicHTMLToken> fakeToken = AtomicHTMLToken::create(HTMLTokenTypes::EndTag, tagName); 543 processEndTag(fakeToken.get()); 544 } 545 540 546 void HTMLTreeBuilder::processFakeEndTag(const QualifiedName& tagName) 541 547 { 542 548 // FIXME: We'll need a fancier conversion than just "localName" for SVG/MathML tags. 543 RefPtr<AtomicHTMLToken> fakeToken = AtomicHTMLToken::create(HTMLTokenTypes::EndTag, tagName.localName()); 544 processEndTag(fakeToken.get()); 549 processFakeEndTag(tagName.localName()); 545 550 } 546 551 … … 601 606 namespace { 602 607 603 bool isLi(const ContainerNode* element)604 { 605 return element->hasTagName(liTag);606 } 607 608 bool isDdOrDt(const ContainerNode* element)609 { 610 return element->hasTagName(ddTag)611 || element->hasTagName(dtTag);612 } 613 614 } 615 616 template <bool shouldClose(const ContainerNode*)>608 bool isLi(const HTMLStackItem* item) 609 { 610 return item->hasTagName(liTag); 611 } 612 613 bool isDdOrDt(const HTMLStackItem* item) 614 { 615 return item->hasTagName(ddTag) 616 || item->hasTagName(dtTag); 617 } 618 619 } 620 621 template <bool shouldClose(const HTMLStackItem*)> 617 622 void HTMLTreeBuilder::processCloseWhenNestedTag(AtomicHTMLToken* token) 618 623 { … … 620 625 HTMLElementStack::ElementRecord* nodeRecord = m_tree.openElements()->topRecord(); 621 626 while (1) { 622 RefPtr< ContainerNode> node = nodeRecord->node();623 if (shouldClose( node.get())) {624 ASSERT( node->isElementNode());625 processFakeEndTag( toElement(node.get())->tagQName());627 RefPtr<HTMLStackItem> item = nodeRecord->stackItem(); 628 if (shouldClose(item.get())) { 629 ASSERT(item->isElementNode()); 630 processFakeEndTag(item->localName()); 626 631 break; 627 632 } 628 if (isSpecialNode( node.get()) && !node->hasTagName(addressTag) && !node->hasTagName(divTag) && !node->hasTagName(pTag))633 if (isSpecialNode(item.get()) && !item->hasTagName(addressTag) && !item->hasTagName(divTag) && !item->hasTagName(pTag)) 629 634 break; 630 635 nodeRecord = nodeRecord->next(); … … 808 813 if (isNumberedHeaderTag(token->name())) { 809 814 processFakePEndTagIfPInButtonScope(); 810 if (isNumberedHeaderTag(m_tree.current Node()->localName())) {815 if (isNumberedHeaderTag(m_tree.currentStackItem()->localName())) { 811 816 parseError(token); 812 817 m_tree.openElements()->pop(); … … 988 993 } 989 994 if (token->name() == optgroupTag || token->name() == optionTag) { 990 if (m_tree.current Node()->hasTagName(optionTag)) {995 if (m_tree.currentStackItem()->hasTagName(optionTag)) { 991 996 RefPtr<AtomicHTMLToken> endOption = AtomicHTMLToken::create(HTMLTokenTypes::EndTag, optionTag.localName()); 992 997 processEndTag(endOption.get()); … … 999 1004 if (m_tree.openElements()->inScope(rubyTag.localName())) { 1000 1005 m_tree.generateImpliedEndTags(); 1001 if (!m_tree.current Node()->hasTagName(rubyTag))1006 if (!m_tree.currentStackItem()->hasTagName(rubyTag)) 1002 1007 parseError(token); 1003 1008 } … … 1266 1271 } 1267 1272 m_tree.openElements()->popUntilTableBodyScopeMarker(); 1268 ASSERT(isTableBodyContextTag(m_tree.current Element()->localName()));1269 processFakeEndTag(m_tree.current Element()->tagQName());1273 ASSERT(isTableBodyContextTag(m_tree.currentStackItem()->localName())); 1274 processFakeEndTag(m_tree.currentStackItem()->localName()); 1270 1275 processStartTag(token); 1271 1276 return; … … 1400 1405 } 1401 1406 if (token->name() == optionTag) { 1402 if (m_tree.current Node()->hasTagName(optionTag)) {1407 if (m_tree.currentStackItem()->hasTagName(optionTag)) { 1403 1408 RefPtr<AtomicHTMLToken> endOption = AtomicHTMLToken::create(HTMLTokenTypes::EndTag, optionTag.localName()); 1404 1409 processEndTag(endOption.get()); … … 1408 1413 } 1409 1414 if (token->name() == optgroupTag) { 1410 if (m_tree.current Node()->hasTagName(optionTag)) {1415 if (m_tree.currentStackItem()->hasTagName(optionTag)) { 1411 1416 RefPtr<AtomicHTMLToken> endOption = AtomicHTMLToken::create(HTMLTokenTypes::EndTag, optionTag.localName()); 1412 1417 processEndTag(endOption.get()); 1413 1418 } 1414 if (m_tree.current Node()->hasTagName(optgroupTag)) {1419 if (m_tree.currentStackItem()->hasTagName(optgroupTag)) { 1415 1420 RefPtr<AtomicHTMLToken> endOptgroup = AtomicHTMLToken::create(HTMLTokenTypes::EndTag, optgroupTag.localName()); 1416 1421 processEndTag(endOptgroup.get()); … … 1478 1483 HTMLElementStack::ElementRecord* record = m_tree.openElements()->topRecord(); 1479 1484 while (1) { 1480 RefPtr< ContainerNode> node = record->node();1481 if ( node->hasLocalName(token->name())) {1485 RefPtr<HTMLStackItem> item = record->stackItem(); 1486 if (item->hasLocalName(token->name())) { 1482 1487 m_tree.generateImpliedEndTagsWithExclusion(token->name()); 1483 if (!m_tree.current Node()->hasLocalName(token->name()))1488 if (!m_tree.currentStackItem()->hasLocalName(token->name())) 1484 1489 parseError(token); 1485 m_tree.openElements()->popUntilPopped( toElement(node.get()));1486 return; 1487 } 1488 if (isSpecialNode( node.get())) {1490 m_tree.openElements()->popUntilPopped(item->element()); 1491 return; 1492 } 1493 if (isSpecialNode(item.get())) { 1489 1494 parseError(token); 1490 1495 return; … … 1502 1507 if (record->element() == formattingElement) 1503 1508 return furthestBlock; 1504 if (isSpecialNode(record-> element()))1509 if (isSpecialNode(record->stackItem().get())) 1505 1510 furthestBlock = record; 1506 1511 } … … 1598 1603 else { 1599 1604 commonAncestor->parserAddChild(lastNode->element()); 1600 ASSERT(lastNode-> node()->isElementNode());1605 ASSERT(lastNode->stackItem()->isElementNode()); 1601 1606 ASSERT(lastNode->element()->parentNode()); 1602 1607 if (lastNode->element()->parentNode()->attached() && !lastNode->element()->attached()) … … 1699 1704 } 1700 1705 m_tree.openElements()->popUntilTableBodyScopeMarker(); 1701 ASSERT(isTableBodyContextTag(m_tree.current Element()->localName()));1702 processFakeEndTag(m_tree.current Element()->tagQName());1706 ASSERT(isTableBodyContextTag(m_tree.currentStackItem()->localName())); 1707 processFakeEndTag(m_tree.currentStackItem()->localName()); 1703 1708 processEndTag(token); 1704 1709 return; … … 1760 1765 } 1761 1766 m_tree.generateImpliedEndTags(); 1762 if (!m_tree.current Node()->hasLocalName(token->name()))1767 if (!m_tree.currentStackItem()->hasLocalName(token->name())) 1763 1768 parseError(token); 1764 1769 m_tree.openElements()->popUntilPopped(token->name()); … … 1830 1835 } 1831 1836 m_tree.generateImpliedEndTags(); 1832 if (!m_tree.current Node()->hasLocalName(token->name()))1837 if (!m_tree.currentStackItem()->hasLocalName(token->name())) 1833 1838 parseError(token); 1834 1839 m_tree.openElements()->popUntilPopped(token->name()); … … 1855 1860 } 1856 1861 m_tree.generateImpliedEndTagsWithExclusion(token->name()); 1857 if (!m_tree.current Node()->hasLocalName(token->name()))1862 if (!m_tree.currentStackItem()->hasLocalName(token->name())) 1858 1863 parseError(token); 1859 1864 m_tree.openElements()->popUntilPopped(token->name()); … … 1866 1871 } 1867 1872 m_tree.generateImpliedEndTagsWithExclusion(token->name()); 1868 if (!m_tree.current Node()->hasLocalName(token->name()))1873 if (!m_tree.currentStackItem()->hasLocalName(token->name())) 1869 1874 parseError(token); 1870 1875 m_tree.openElements()->popUntilPopped(token->name()); … … 1878 1883 } 1879 1884 m_tree.generateImpliedEndTagsWithExclusion(token->name()); 1880 if (!m_tree.current Node()->hasLocalName(token->name()))1885 if (!m_tree.currentStackItem()->hasLocalName(token->name())) 1881 1886 parseError(token); 1882 1887 m_tree.openElements()->popUntilPopped(token->name()); … … 1889 1894 } 1890 1895 m_tree.generateImpliedEndTags(); 1891 if (!m_tree.current Node()->hasLocalName(token->name()))1896 if (!m_tree.currentStackItem()->hasLocalName(token->name())) 1892 1897 parseError(token); 1893 1898 m_tree.openElements()->popUntilNumberedHeaderElementPopped(); … … 1906 1911 } 1907 1912 m_tree.generateImpliedEndTags(); 1908 if (!m_tree.current Node()->hasLocalName(token->name()))1913 if (!m_tree.currentStackItem()->hasLocalName(token->name())) 1909 1914 parseError(token); 1910 1915 m_tree.openElements()->popUntilPopped(token->name()); … … 1928 1933 } 1929 1934 m_tree.generateImpliedEndTags(); 1930 // FIXME: parse error if (!m_tree.current Element()->hasTagName(captionTag))1935 // FIXME: parse error if (!m_tree.currentStackItem()->hasTagName(captionTag)) 1931 1936 m_tree.openElements()->popUntilPopped(captionTag.localName()); 1932 1937 m_tree.activeFormattingElements()->clearToLastMarker(); … … 1943 1948 } 1944 1949 m_tree.openElements()->popUntilTableRowScopeMarker(); 1945 ASSERT(m_tree.current Element()->hasTagName(trTag));1950 ASSERT(m_tree.currentStackItem()->hasTagName(trTag)); 1946 1951 m_tree.openElements()->pop(); 1947 1952 setInsertionMode(InTableBodyMode); … … 2111 2116 ASSERT(insertionMode() == InHeadNoscriptMode); 2112 2117 if (token->name() == noscriptTag) { 2113 ASSERT(m_tree.current Element()->hasTagName(noscriptTag));2118 ASSERT(m_tree.currentStackItem()->hasTagName(noscriptTag)); 2114 2119 m_tree.openElements()->pop(); 2115 ASSERT(m_tree.current Element()->hasTagName(headTag));2120 ASSERT(m_tree.currentStackItem()->hasTagName(headTag)); 2116 2121 setInsertionMode(InHeadMode); 2117 2122 return; … … 2127 2132 if (token->name() == scriptTag) { 2128 2133 // Pause ourselves so that parsing stops until the script can be processed by the caller. 2129 ASSERT(m_tree.current Element()->hasTagName(scriptTag));2134 ASSERT(m_tree.currentStackItem()->hasTagName(scriptTag)); 2130 2135 m_scriptToProcess = m_tree.currentElement(); 2131 2136 m_tree.openElements()->pop(); … … 2153 2158 } 2154 2159 m_tree.openElements()->pop(); 2155 if (!isParsingFragment() && !m_tree.current Element()->hasTagName(framesetTag))2160 if (!isParsingFragment() && !m_tree.currentStackItem()->hasTagName(framesetTag)) 2156 2161 setInsertionMode(AfterFramesetMode); 2157 2162 return; … … 2188 2193 ASSERT(insertionMode() == InSelectMode || insertionMode() == InSelectInTableMode); 2189 2194 if (token->name() == optgroupTag) { 2190 if (m_tree.current Node()->hasTagName(optionTag) && m_tree.oneBelowTop() && m_tree.oneBelowTop()->hasTagName(optgroupTag))2195 if (m_tree.currentStackItem()->hasTagName(optionTag) && m_tree.oneBelowTop() && m_tree.oneBelowTop()->hasTagName(optgroupTag)) 2191 2196 processFakeEndTag(optionTag); 2192 if (m_tree.current Node()->hasTagName(optgroupTag)) {2197 if (m_tree.currentStackItem()->hasTagName(optgroupTag)) { 2193 2198 m_tree.openElements()->pop(); 2194 2199 return; … … 2198 2203 } 2199 2204 if (token->name() == optionTag) { 2200 if (m_tree.current Node()->hasTagName(optionTag)) {2205 if (m_tree.currentStackItem()->hasTagName(optionTag)) { 2201 2206 m_tree.openElements()->pop(); 2202 2207 return; … … 2330 2335 ASSERT(insertionMode() == InTableMode || insertionMode() == InTableBodyMode || insertionMode() == InRowMode); 2331 2336 ASSERT(m_pendingTableCharacters.isEmpty()); 2332 if (m_tree.current Node()->isElementNode()2333 && (m_tree.current Element()->hasTagName(HTMLNames::tableTag)2334 || m_tree.current Element()->hasTagName(HTMLNames::tbodyTag)2335 || m_tree.current Element()->hasTagName(HTMLNames::tfootTag)2336 || m_tree.current Element()->hasTagName(HTMLNames::theadTag)2337 || m_tree.current Element()->hasTagName(HTMLNames::trTag))) {2337 if (m_tree.currentStackItem()->isElementNode() 2338 && (m_tree.currentStackItem()->hasTagName(HTMLNames::tableTag) 2339 || m_tree.currentStackItem()->hasTagName(HTMLNames::tbodyTag) 2340 || m_tree.currentStackItem()->hasTagName(HTMLNames::tfootTag) 2341 || m_tree.currentStackItem()->hasTagName(HTMLNames::theadTag) 2342 || m_tree.currentStackItem()->hasTagName(HTMLNames::trTag))) { 2338 2343 m_originalInsertionMode = m_insertionMode; 2339 2344 setInsertionMode(InTableTextMode); … … 2498 2503 case TextMode: 2499 2504 parseError(token); 2500 if (m_tree.current Node()->hasTagName(scriptTag))2505 if (m_tree.currentStackItem()->hasTagName(scriptTag)) 2501 2506 notImplemented(); // mark the script element as "already started". 2502 2507 m_tree.openElements()->pop(); … … 2652 2657 if (m_tree.isEmpty()) 2653 2658 return false; 2654 ContainerNode* node = m_tree.currentNode();2655 if (isInHTMLNamespace( node))2659 HTMLStackItem* item = m_tree.currentStackItem(); 2660 if (isInHTMLNamespace(item)) 2656 2661 return false; 2657 if (HTMLElementStack::isMathMLTextIntegrationPoint( node)) {2662 if (HTMLElementStack::isMathMLTextIntegrationPoint(item)) { 2658 2663 if (token->type() == HTMLTokenTypes::StartTag 2659 2664 && token->name() != MathMLNames::mglyphTag … … 2663 2668 return false; 2664 2669 } 2665 if ( node->hasTagName(MathMLNames::annotation_xmlTag)2670 if (item->hasTagName(MathMLNames::annotation_xmlTag) 2666 2671 && token->type() == HTMLTokenTypes::StartTag 2667 2672 && token->name() == SVGNames::svgTag) 2668 2673 return false; 2669 if (HTMLElementStack::isHTMLIntegrationPoint( node)) {2674 if (HTMLElementStack::isHTMLIntegrationPoint(item)) { 2670 2675 if (token->type() == HTMLTokenTypes::StartTag) 2671 2676 return false; … … 2733 2738 return; 2734 2739 } 2735 const AtomicString& currentNamespace = m_tree.current Element()->namespaceURI();2740 const AtomicString& currentNamespace = m_tree.currentStackItem()->namespaceURI(); 2736 2741 if (currentNamespace == MathMLNames::mathmlNamespaceURI) 2737 2742 adjustMathMLAttributes(token); … … 2745 2750 } 2746 2751 case HTMLTokenTypes::EndTag: { 2747 if (m_tree.current Node()->namespaceURI() == SVGNames::svgNamespaceURI)2752 if (m_tree.currentStackItem()->namespaceURI() == SVGNames::svgNamespaceURI) 2748 2753 adjustSVGTagNameCase(token); 2749 2754 2750 if (token->name() == SVGNames::scriptTag && m_tree.current Node()->hasTagName(SVGNames::scriptTag)) {2755 if (token->name() == SVGNames::scriptTag && m_tree.currentStackItem()->hasTagName(SVGNames::scriptTag)) { 2751 2756 m_scriptToProcess = m_tree.currentElement(); 2752 2757 m_tree.openElements()->pop(); 2753 2758 return; 2754 2759 } 2755 if (!isInHTMLNamespace(m_tree.current Node())) {2760 if (!isInHTMLNamespace(m_tree.currentStackItem())) { 2756 2761 // FIXME: This code just wants an Element* iterator, instead of an ElementRecord* 2757 2762 HTMLElementStack::ElementRecord* nodeRecord = m_tree.openElements()->topRecord(); 2758 if (!nodeRecord-> node()->hasLocalName(token->name()))2763 if (!nodeRecord->stackItem()->hasLocalName(token->name())) 2759 2764 parseError(token); 2760 2765 while (1) { 2761 if (nodeRecord-> node()->hasLocalName(token->name())) {2766 if (nodeRecord->stackItem()->hasLocalName(token->name())) { 2762 2767 m_tree.openElements()->popUntilPopped(nodeRecord->element()); 2763 2768 return; … … 2765 2770 nodeRecord = nodeRecord->next(); 2766 2771 2767 if (isInHTMLNamespace(nodeRecord-> node()))2772 if (isInHTMLNamespace(nodeRecord->stackItem().get())) 2768 2773 break; 2769 2774 } -
trunk/Source/WebCore/html/parser/HTMLTreeBuilder.h
r123389 r123577 153 153 void processFakeStartTag(const QualifiedName&, const Vector<Attribute>& attributes = Vector<Attribute>()); 154 154 void processFakeEndTag(const QualifiedName&); 155 void processFakeEndTag(const AtomicString&); 155 156 void processFakeCharacters(const String&); 156 157 void processFakePEndTagIfPInButtonScope(); … … 179 180 void closeTheCell(); 180 181 181 template <bool shouldClose(const ContainerNode*)>182 template <bool shouldClose(const HTMLStackItem*)> 182 183 void processCloseWhenNestedTag(AtomicHTMLToken*); 183 184
Note: See TracChangeset
for help on using the changeset viewer.