Changeset 80209 in webkit
- Timestamp:
- Mar 2, 2011 10:18:55 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r80204 r80209 1 2011-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 1 76 2011-03-02 Yury Semikhatsky <yurys@chromium.org> 2 77 -
trunk/Source/WebCore/dom/Element.h
r80201 r80209 428 428 return isElementNode() && toElement(this)->hasTagName(name); 429 429 } 430 431 inline bool Node::hasLocalName(const AtomicString& name) const432 {433 return isElementNode() && toElement(this)->hasLocalName(name);434 }435 430 436 431 inline bool Node::hasAttributes() const -
trunk/Source/WebCore/dom/Node.h
r80201 r80209 3 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 4 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 , 2011Apple Inc. All rights reserved.5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 6 6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) 7 7 * … … 135 135 136 136 bool hasTagName(const QualifiedName&) const; 137 bool hasLocalName(const AtomicString&) const;138 137 virtual String nodeName() const = 0; 139 138 virtual String nodeValue() const; -
trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp
r80201 r80209 1 1 /* 2 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. 3 * Copyright (C) 2011 Apple Inc. All rights reserved.4 3 * 5 4 * Redistribution and use in source and binary forms, with or without … … 60 59 namespace { 61 60 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);61 bool 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); 72 71 } 73 72 … … 206 205 { 207 206 // FIXME: parse error 208 209 // Fragments do not have a root HTML element, so any additional HTML elements210 // encountered during fragment parsing should be ignored.211 if (m_isParsingFragment)212 return;213 214 207 mergeAttributesFromTokenIntoElement(token, m_openElements.htmlElement()); 215 208 } … … 244 237 { 245 238 ASSERT(token.type() == HTMLToken::Comment); 246 attach(current Node(), Comment::create(currentNode()->document(), token.comment()));239 attach(currentElement(), Comment::create(currentElement()->document(), token.comment())); 247 240 } 248 241 … … 256 249 { 257 250 ASSERT(token.type() == HTMLToken::Comment); 258 ContainerNode* parent = m_openElements.rootNode();251 Element* parent = m_openElements.htmlElement(); 259 252 attach(parent, Comment::create(parent->document(), token.comment())); 260 253 } … … 262 255 PassRefPtr<Element> HTMLConstructionSite::attachToCurrent(PassRefPtr<Element> child) 263 256 { 264 return attach(current Node(), child);257 return attach(currentElement(), child); 265 258 } 266 259 … … 318 311 void HTMLConstructionSite::insertScriptElement(AtomicHTMLToken& token) 319 312 { 320 RefPtr<HTMLScriptElement> element = HTMLScriptElement::create(scriptTag, current Node()->document(), true);313 RefPtr<HTMLScriptElement> element = HTMLScriptElement::create(scriptTag, currentElement()->document(), true); 321 314 if (m_fragmentScriptingPermission == FragmentScriptingAllowed) 322 315 element->setAttributeMap(token.takeAtributes(), m_fragmentScriptingPermission); … … 337 330 { 338 331 AttachmentSite site; 339 site.parent = current Node();332 site.parent = currentElement(); 340 333 site.nextChild = 0; 341 334 if (shouldFosterParent()) … … 357 350 { 358 351 QualifiedName tagName(nullAtom, token.name(), namespaceURI); 359 RefPtr<Element> element = current Node()->document()->createElement(tagName, true);352 RefPtr<Element> element = currentElement()->document()->createElement(tagName, true); 360 353 element->setAttributeMap(token.takeAtributes(), m_fragmentScriptingPermission); 361 354 return element.release(); … … 368 361 // have to pass the current form element. We should rework form association 369 362 // to occur after construction to allow better code sharing here. 370 RefPtr<Element> element = HTMLElementFactory::createHTMLElement(tagName, current Node()->document(), form(), true);363 RefPtr<Element> element = HTMLElementFactory::createHTMLElement(tagName, currentElement()->document(), form(), true); 371 364 element->setAttributeMap(token.takeAtributes(), m_fragmentScriptingPermission); 372 365 ASSERT(element->isHTMLElement()); … … 447 440 void HTMLConstructionSite::generateImpliedEndTagsWithExclusion(const AtomicString& tagName) 448 441 { 449 while (hasImpliedEndTag(current Node()) && !currentNode()->hasLocalName(tagName))442 while (hasImpliedEndTag(currentElement()) && !currentElement()->hasLocalName(tagName)) 450 443 m_openElements.pop(); 451 444 } … … 453 446 void HTMLConstructionSite::generateImpliedEndTags() 454 447 { 455 while (hasImpliedEndTag(current Node()))448 while (hasImpliedEndTag(currentElement())) 456 449 m_openElements.pop(); 457 450 } … … 472 465 } 473 466 // Fragment case 474 site.parent = m_openElements. rootNode(); // DocumentFragment467 site.parent = m_openElements.bottom(); // <html> element 475 468 site.nextChild = 0; 476 469 } … … 479 472 { 480 473 return m_redirectAttachToFosterParent 481 && currentNode()->isElementNode()482 474 && causesFosterParenting(currentElement()->tagQName()); 483 475 } -
trunk/Source/WebCore/html/parser/HTMLConstructionSite.h
r80201 r80209 1 1 /* 2 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. 3 * Copyright (C) 2011 Apple Inc. All rights reserved.4 3 * 5 4 * Redistribution and use in source and binary forms, with or without … … 82 81 83 82 Element* currentElement() const { return m_openElements.top(); } 84 ContainerNode* currentNode() const { return m_openElements.topNode(); }85 83 Element* oneBelowTop() const { return m_openElements.oneBelowTop(); } 86 84 -
trunk/Source/WebCore/html/parser/HTMLElementStack.cpp
r80201 r80209 1 1 /* 2 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. 3 * Copyright (C) 2011 Apple Inc. All rights reserved.4 3 * 5 4 * Redistribution and use in source and binary forms, with or without … … 28 27 #include "HTMLElementStack.h" 29 28 30 #include "DocumentFragment.h"31 29 #include "Element.h" 32 30 #include "HTMLNames.h" … … 50 48 || element->hasTagName(h6Tag); 51 49 } 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 51 inline 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 72 inline bool isListItemScopeMarker(Element* element) 73 { 74 return isScopeMarker(element) 75 || element->hasTagName(olTag) 76 || element->hasTagName(ulTag); 77 } 78 79 inline bool isTableScopeMarker(Element* element) 80 { 81 return element->hasTagName(tableTag) 82 || element->hasTagName(htmlTag); 83 } 84 85 inline bool isTableBodyScopeMarker(Element* element) 86 { 87 return element->hasTagName(tbodyTag) 88 || element->hasTagName(tfootTag) 89 || element->hasTagName(theadTag) 90 || element->hasTagName(htmlTag); 91 } 92 93 inline bool isTableRowScopeMarker(Element* element) 94 { 95 return element->hasTagName(trTag) 96 || element->hasTagName(htmlTag); 105 97 } 106 98 … … 118 110 } 119 111 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)112 inline bool isButtonScopeMarker(Element* element) 113 { 114 return isScopeMarker(element) 115 || element->hasTagName(buttonTag); 116 } 117 118 inline bool isSelectScopeMarker(Element* element) 119 { 120 return !element->hasTagName(optgroupTag) 121 && !element->hasTagName(optionTag); 122 } 123 124 } 125 126 HTMLElementStack::ElementRecord::ElementRecord(PassRefPtr<Element> element, PassOwnPtr<ElementRecord> next) 127 : m_element(element) 136 128 , m_next(next) 137 129 { 138 ASSERT(m_ node);130 ASSERT(m_element); 139 131 } 140 132 … … 146 138 { 147 139 ASSERT(element); 148 ASSERT(!m_node || m_node->isElementNode());149 140 // FIXME: Should this call finishParsingChildren? 150 m_ node= element;141 m_element = element; 151 142 } 152 143 … … 161 152 162 153 HTMLElementStack::HTMLElementStack() 163 : m_ rootNode(0)154 : m_htmlElement(0) 164 155 , m_headElement(0) 165 156 , m_bodyElement(0) … … 181 172 // insertion mode. 182 173 // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#parsing-main-inbody 183 ASSERT(m_ rootNode);174 ASSERT(m_htmlElement); 184 175 // If we have a body element, it must always be the second element on the 185 176 // stack, as we always start with an html element, and any other element … … 204 195 void HTMLElementStack::popAll() 205 196 { 206 m_ rootNode= 0;197 m_htmlElement = 0; 207 198 m_headElement = 0; 208 199 m_bodyElement = 0; 209 200 while (m_top) { 210 top Node()->finishParsingChildren();201 top()->finishParsingChildren(); 211 202 m_top = m_top->releaseNext(); 212 203 } … … 256 247 { 257 248 // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#clear-the-stack-back-to-a-table-context 258 while (!isTableScopeMarker(top Node()))249 while (!isTableScopeMarker(top())) 259 250 pop(); 260 251 } … … 263 254 { 264 255 // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#clear-the-stack-back-to-a-table-body-context 265 while (!isTableBodyScopeMarker(top Node()))256 while (!isTableBodyScopeMarker(top())) 266 257 pop(); 267 258 } … … 270 261 { 271 262 // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#clear-the-stack-back-to-a-table-row-context 272 while (!isTableRowScopeMarker(top Node()))263 while (!isTableRowScopeMarker(top())) 273 264 pop(); 274 265 } … … 279 270 pop(); 280 271 } 281 282 void HTMLElementStack::pushRootNode(PassRefPtr<ContainerNode> rootNode)283 {284 ASSERT(rootNode->nodeType() == Node::DOCUMENT_FRAGMENT_NODE);285 pushRootNodeCommon(rootNode);286 }287 272 288 273 void HTMLElementStack::pushHTMLHtmlElement(PassRefPtr<Element> element) 289 274 { 275 ASSERT(!m_top); // <html> should always be the bottom of the stack. 290 276 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); 300 280 } 301 281 … … 321 301 ASSERT(!element->hasTagName(HTMLNames::headTag)); 322 302 ASSERT(!element->hasTagName(HTMLNames::bodyTag)); 323 ASSERT(m_ rootNode);303 ASSERT(m_htmlElement); 324 304 pushCommon(element); 325 305 } … … 333 313 ASSERT(!element->hasTagName(HTMLNames::headTag)); 334 314 ASSERT(!element->hasTagName(HTMLNames::bodyTag)); 335 ASSERT(m_ rootNode);315 ASSERT(m_htmlElement); 336 316 if (recordBelow == m_top) { 337 317 push(element); … … 393 373 { 394 374 for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) { 395 if (pos-> node() == element)375 if (pos->element() == element) 396 376 return pos; 397 377 } … … 402 382 { 403 383 for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) { 404 if (pos-> node()->hasLocalName(tagName))384 if (pos->element()->hasLocalName(tagName)) 405 385 return pos; 406 386 } … … 418 398 } 419 399 420 template <bool isMarker( ContainerNode*)>400 template <bool isMarker(Element*)> 421 401 bool inScopeCommon(HTMLElementStack::ElementRecord* top, const AtomicString& targetTag) 422 402 { 423 403 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)) 426 406 return true; 427 if (isMarker( node))407 if (isMarker(element)) 428 408 return false; 429 409 } … … 448 428 { 449 429 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)) 451 434 return false; 452 if (isNumberedHeaderElement(record->element()))453 return true;454 435 } 455 436 ASSERT_NOT_REACHED(); // <html> is always on the stack and is a scope marker. … … 527 508 Element* HTMLElementStack::htmlElement() const 528 509 { 529 ASSERT(m_ rootNode);530 return toElement(m_rootNode);510 ASSERT(m_htmlElement); 511 return m_htmlElement; 531 512 } 532 513 … … 542 523 return m_bodyElement; 543 524 } 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 526 void HTMLElementStack::pushCommon(PassRefPtr<Element> element) 527 { 528 ASSERT(m_htmlElement); 529 m_top = adoptPtr(new ElementRecord(element, m_top.release())); 530 top()->beginParsingChildren(); 556 531 } 557 532 -
trunk/Source/WebCore/html/parser/HTMLElementStack.h
r80201 r80209 1 1 /* 2 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. 3 * Copyright (C) 2011 Apple Inc. All rights reserved.4 3 * 5 4 * Redistribution and use in source and binary forms, with or without … … 28 27 #define HTMLElementStack_h 29 28 30 #include "Element.h"31 29 #include <wtf/Forward.h> 32 30 #include <wtf/Noncopyable.h> … … 37 35 namespace WebCore { 38 36 39 class ContainerNode;40 class DocumentFragment;41 37 class Element; 42 38 class QualifiedName; … … 55 51 ~ElementRecord(); // Public for ~PassOwnPtr() 56 52 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(); } 59 54 void replaceElement(PassRefPtr<Element>); 60 55 … … 66 61 friend class HTMLElementStack; 67 62 68 ElementRecord(PassRefPtr< ContainerNode>, PassOwnPtr<ElementRecord>);63 ElementRecord(PassRefPtr<Element>, PassOwnPtr<ElementRecord>); 69 64 70 65 PassOwnPtr<ElementRecord> releaseNext() { return m_next.release(); } 71 66 void setNext(PassOwnPtr<ElementRecord> next) { m_next = next; } 72 67 73 RefPtr< ContainerNode> m_node;68 RefPtr<Element> m_element; 74 69 OwnPtr<ElementRecord> m_next; 75 70 }; … … 81 76 ASSERT(m_top->element()); 82 77 return m_top->element(); 83 }84 85 ContainerNode* topNode() const86 {87 ASSERT(m_top->node());88 return m_top->node();89 78 } 90 79 … … 98 87 99 88 void push(PassRefPtr<Element>); 100 void pushRootNode(PassRefPtr<ContainerNode>);101 89 void pushHTMLHtmlElement(PassRefPtr<Element>); 102 90 void pushHTMLHeadElement(PassRefPtr<Element>); … … 144 132 Element* headElement() const; 145 133 Element* bodyElement() const; 146 147 ContainerNode* rootNode() const;148 134 149 135 #ifndef NDEBUG … … 152 138 153 139 private: 154 void pushCommon(PassRefPtr<ContainerNode>); 155 void pushRootNodeCommon(PassRefPtr<ContainerNode>); 140 void pushCommon(PassRefPtr<Element>); 156 141 void popCommon(); 157 142 void removeNonTopCommon(Element*); … … 159 144 OwnPtr<ElementRecord> m_top; 160 145 161 // We remember the root node, <head> and <body> as they are pushed.Their162 // ElementRecords keep them alive. The root nodeis never popped.146 // We remember <html>, <head> and <body> as they are pushed. Their 147 // ElementRecords keep them alive. <html> is never popped. 163 148 // FIXME: We don't currently require type-specific information about 164 149 // these elements so we haven't yet bothered to plumb the types all the 165 150 // way down through createElement, etc. 166 ContainerNode* m_rootNode;151 Element* m_htmlElement; 167 152 Element* m_headElement; 168 153 Element* m_bodyElement; -
trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp
r80201 r80209 1 1 /* 2 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. 3 * Copyright (C) 2011 Apple Inc. All rights reserved.4 3 * 5 4 * Redistribution and use in source and binary forms, with or without … … 123 122 || node->hasTagName(SVGNames::descTag) 124 123 || node->hasTagName(SVGNames::titleTag)) 125 return true;126 if (node->nodeType() == Node::DOCUMENT_FRAGMENT_NODE)127 124 return true; 128 125 if (node->namespaceURI() != xhtmlNamespaceURI) … … 379 376 // Steps 4.2-4.6 of the HTML5 Fragment Case parsing algorithm: 380 377 // 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); 384 379 resetInsertionModeAppropriately(); 385 380 m_tree.setForm(closestFormAncestor(contextElement)); … … 414 409 { 415 410 ASSERT(!fragment->hasChildNodes()); 411 } 412 413 void 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()); 416 424 } 417 425 … … 567 575 namespace { 568 576 569 bool isLi(const ContainerNode* element)577 bool isLi(const Element* element) 570 578 { 571 579 return element->hasTagName(liTag); 572 580 } 573 581 574 bool isDdOrDt(const ContainerNode* element)582 bool isDdOrDt(const Element* element) 575 583 { 576 584 return element->hasTagName(ddTag) … … 580 588 } 581 589 582 template <bool shouldClose(const ContainerNode*)>590 template <bool shouldClose(const Element*)> 583 591 void HTMLTreeBuilder::processCloseWhenNestedTag(AtomicHTMLToken& token) 584 592 { … … 586 594 HTMLElementStack::ElementRecord* nodeRecord = m_tree.openElements()->topRecord(); 587 595 while (1) { 588 ContainerNode* node = nodeRecord->node();596 Element* node = nodeRecord->element(); 589 597 if (shouldClose(node)) { 590 ASSERT(node->isElementNode()); 591 processFakeEndTag(toElement(node)->tagQName()); 598 processFakeEndTag(node->tagQName()); 592 599 break; 593 600 } … … 780 787 if (isNumberedHeaderTag(token.name())) { 781 788 processFakePEndTagIfPInButtonScope(); 782 if (isNumberedHeaderTag(m_tree.current Node()->localName())) {789 if (isNumberedHeaderTag(m_tree.currentElement()->localName())) { 783 790 parseError(token); 784 791 m_tree.openElements()->pop(); … … 972 979 if (m_tree.openElements()->inScope(rubyTag.localName())) { 973 980 m_tree.generateImpliedEndTags(); 974 if (!m_tree.current Node()->hasTagName(rubyTag)) {981 if (!m_tree.currentElement()->hasTagName(rubyTag)) { 975 982 parseError(token); 976 983 m_tree.openElements()->popUntil(rubyTag.localName()); … … 1013 1020 bool HTMLTreeBuilder::processColgroupEndTagForInColumnGroup() 1014 1021 { 1015 if (m_tree.current Node() == m_tree.openElements()->rootNode()) {1022 if (m_tree.currentElement() == m_tree.openElements()->htmlElement()) { 1016 1023 ASSERT(isParsingFragment()); 1017 1024 // FIXME: parse error … … 1109 1116 namespace { 1110 1117 1111 bool shouldProcessForeignContentUsingInBodyInsertionMode(AtomicHTMLToken& token, ContainerNode* currentElement)1118 bool shouldProcessForeignContentUsingInBodyInsertionMode(AtomicHTMLToken& token, Element* currentElement) 1112 1119 { 1113 1120 ASSERT(token.type() == HTMLToken::StartTag); … … 1403 1410 } 1404 1411 if (token.name() == optionTag) { 1405 if (m_tree.current Node()->hasTagName(optionTag)) {1412 if (m_tree.currentElement()->hasTagName(optionTag)) { 1406 1413 AtomicHTMLToken endOption(HTMLToken::EndTag, optionTag.localName()); 1407 1414 processEndTag(endOption); … … 1411 1418 } 1412 1419 if (token.name() == optgroupTag) { 1413 if (m_tree.current Node()->hasTagName(optionTag)) {1420 if (m_tree.currentElement()->hasTagName(optionTag)) { 1414 1421 AtomicHTMLToken endOption(HTMLToken::EndTag, optionTag.localName()); 1415 1422 processEndTag(endOption); 1416 1423 } 1417 if (m_tree.current Node()->hasTagName(optgroupTag)) {1424 if (m_tree.currentElement()->hasTagName(optgroupTag)) { 1418 1425 AtomicHTMLToken endOptgroup(HTMLToken::EndTag, optgroupTag.localName()); 1419 1426 processEndTag(endOptgroup); … … 1537 1544 HTMLElementStack::ElementRecord* record = m_tree.openElements()->topRecord(); 1538 1545 while (1) { 1539 ContainerNode* node = record->node();1546 Element* node = record->element(); 1540 1547 if (node->hasLocalName(token.name())) { 1541 1548 m_tree.generateImpliedEndTags(); 1542 if (!m_tree.current Node()->hasLocalName(token.name())) {1549 if (!m_tree.currentElement()->hasLocalName(token.name())) { 1543 1550 parseError(token); 1544 1551 // FIXME: This is either a bug in the spec, or a bug in our … … 1547 1554 // We might have already popped the node for the token in 1548 1555 // generateImpliedEndTags, just abort. 1549 if (!m_tree.openElements()->contains( record->element()))1556 if (!m_tree.openElements()->contains(node)) 1550 1557 return; 1551 1558 } 1552 m_tree.openElements()->popUntilPopped( record->element());1559 m_tree.openElements()->popUntilPopped(node); 1553 1560 return; 1554 1561 } … … 1610 1617 // 4. 1611 1618 ASSERT(furthestBlock->isAbove(formattingElementRecord)); 1612 ContainerNode* commonAncestor = formattingElementRecord->next()->node();1619 Element* commonAncestor = formattingElementRecord->next()->element(); 1613 1620 // 5. 1614 1621 HTMLFormattingElementList::Bookmark bookmark = m_tree.activeFormattingElements()->bookmarkFor(formattingElement); … … 1662 1669 else { 1663 1670 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()) 1667 1672 lastNode->element()->lazyAttach(); 1668 1673 } … … 1696 1701 HTMLElementStack::ElementRecord* nodeRecord = m_tree.openElements()->topRecord(); 1697 1702 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()) { 1700 1705 ASSERT(isParsingFragment()); 1701 1706 last = true; … … 1827 1832 } 1828 1833 m_tree.generateImpliedEndTags(); 1829 if (!m_tree.current Node()->hasLocalName(token.name()))1834 if (!m_tree.currentElement()->hasLocalName(token.name())) 1830 1835 parseError(token); 1831 1836 m_tree.openElements()->popUntilPopped(token.name()); … … 1897 1902 } 1898 1903 m_tree.generateImpliedEndTags(); 1899 if (!m_tree.current Node()->hasLocalName(token.name()))1904 if (!m_tree.currentElement()->hasLocalName(token.name())) 1900 1905 parseError(token); 1901 1906 m_tree.openElements()->popUntilPopped(token.name()); … … 1922 1927 } 1923 1928 m_tree.generateImpliedEndTagsWithExclusion(token.name()); 1924 if (!m_tree.current Node()->hasLocalName(token.name()))1929 if (!m_tree.currentElement()->hasLocalName(token.name())) 1925 1930 parseError(token); 1926 1931 m_tree.openElements()->popUntilPopped(token.name()); … … 1933 1938 } 1934 1939 m_tree.generateImpliedEndTagsWithExclusion(token.name()); 1935 if (!m_tree.current Node()->hasLocalName(token.name()))1940 if (!m_tree.currentElement()->hasLocalName(token.name())) 1936 1941 parseError(token); 1937 1942 m_tree.openElements()->popUntilPopped(token.name()); … … 1945 1950 } 1946 1951 m_tree.generateImpliedEndTagsWithExclusion(token.name()); 1947 if (!m_tree.current Node()->hasLocalName(token.name()))1952 if (!m_tree.currentElement()->hasLocalName(token.name())) 1948 1953 parseError(token); 1949 1954 m_tree.openElements()->popUntilPopped(token.name()); … … 1956 1961 } 1957 1962 m_tree.generateImpliedEndTags(); 1958 if (!m_tree.current Node()->hasLocalName(token.name()))1963 if (!m_tree.currentElement()->hasLocalName(token.name())) 1959 1964 parseError(token); 1960 1965 m_tree.openElements()->popUntilNumberedHeaderElementPopped(); … … 1973 1978 } 1974 1979 m_tree.generateImpliedEndTags(); 1975 if (!m_tree.current Node()->hasLocalName(token.name()))1980 if (!m_tree.currentElement()->hasLocalName(token.name())) 1976 1981 parseError(token); 1977 1982 m_tree.openElements()->popUntilPopped(token.name()); … … 2217 2222 ASSERT(insertionMode() == InFramesetMode); 2218 2223 if (token.name() == framesetTag) { 2219 if (m_tree.current Node() == m_tree.openElements()->rootNode()) {2224 if (m_tree.currentElement() == m_tree.openElements()->htmlElement()) { 2220 2225 parseError(token); 2221 2226 return; … … 2257 2262 ASSERT(insertionMode() == InSelectMode || insertionMode() == InSelectInTableMode); 2258 2263 if (token.name() == optgroupTag) { 2259 if (m_tree.current Node()->hasTagName(optionTag) && m_tree.oneBelowTop()->hasTagName(optgroupTag))2264 if (m_tree.currentElement()->hasTagName(optionTag) && m_tree.oneBelowTop()->hasTagName(optgroupTag)) 2260 2265 processFakeEndTag(optionTag); 2261 if (m_tree.current Node()->hasTagName(optgroupTag)) {2266 if (m_tree.currentElement()->hasTagName(optgroupTag)) { 2262 2267 m_tree.openElements()->pop(); 2263 2268 return; … … 2290 2295 break; 2291 2296 case InForeignContentMode: 2292 if (token.name() == SVGNames::scriptTag && m_tree.current Node()->hasTagName(SVGNames::scriptTag)) {2297 if (token.name() == SVGNames::scriptTag && m_tree.currentElement()->hasTagName(SVGNames::scriptTag)) { 2293 2298 notImplemented(); 2294 2299 return; 2295 2300 } 2296 if (m_tree.current Node()->namespaceURI() != xhtmlNamespaceURI) {2301 if (m_tree.currentElement()->namespaceURI() != xhtmlNamespaceURI) { 2297 2302 // FIXME: This code just wants an Element* iterator, instead of an ElementRecord* 2298 2303 HTMLElementStack::ElementRecord* nodeRecord = m_tree.openElements()->topRecord(); 2299 if (!nodeRecord-> node()->hasLocalName(token.name()))2304 if (!nodeRecord->element()->hasLocalName(token.name())) 2300 2305 parseError(token); 2301 2306 while (1) { 2302 if (nodeRecord-> node()->hasLocalName(token.name())) {2307 if (nodeRecord->element()->hasLocalName(token.name())) { 2303 2308 m_tree.openElements()->popUntilPopped(nodeRecord->element()); 2304 2309 resetForeignInsertionMode(); … … 2306 2311 } 2307 2312 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) 2318 2314 break; 2319 2315 } … … 2614 2610 case InSelectMode: 2615 2611 ASSERT(insertionMode() == InSelectMode || insertionMode() == InSelectInTableMode || insertionMode() == InTableMode || insertionMode() == InFramesetMode || insertionMode() == InTableBodyMode); 2616 if (m_tree.current Node() != m_tree.openElements()->rootNode())2612 if (m_tree.currentElement() != m_tree.openElements()->htmlElement()) 2617 2613 parseError(token); 2618 2614 break; 2619 2615 case InColumnGroupMode: 2620 if (m_tree.current Node() == m_tree.openElements()->rootNode()) {2616 if (m_tree.currentElement() == m_tree.openElements()->htmlElement()) { 2621 2617 ASSERT(isParsingFragment()); 2622 2618 return; // FIXME: Should we break here instead of returning? … … 2647 2643 return; 2648 2644 } 2649 ASSERT(m_tree. currentNode());2645 ASSERT(m_tree.openElements()->top()); 2650 2646 m_tree.openElements()->popAll(); 2651 2647 } … … 2799 2795 void HTMLTreeBuilder::finished() 2800 2796 { 2801 if (isParsingFragment())2802 return;2803 2804 2797 ASSERT(m_document); 2798 if (isParsingFragment()) { 2799 m_fragmentContext.finished(); 2800 return; 2801 } 2802 2805 2803 // Warning, this may detach the parser. Do not do anything else after this. 2806 2804 m_document->finishedParsing(); -
trunk/Source/WebCore/html/parser/HTMLTreeBuilder.h
r80201 r80209 1 1 /* 2 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. 3 * Copyright (C) 2011 Apple Inc. All rights reserved.4 3 * 5 4 * Redistribution and use in source and binary forms, with or without … … 180 179 void closeTheCell(); 181 180 182 template <bool shouldClose(const ContainerNode*)>181 template <bool shouldClose(const Element*)> 183 182 void processCloseWhenNestedTag(AtomicHTMLToken&); 184 183 … … 217 216 FragmentScriptingPermission scriptingPermission() const { ASSERT(m_fragment); return m_scriptingPermission; } 218 217 218 void finished(); 219 219 220 private: 220 221 DocumentFragment* m_fragment;
Note: See TracChangeset
for help on using the changeset viewer.