| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. |
| 3 * Copyright (C) 2011 Apple Inc. All rights reserved. | 3 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 } | 264 } |
| 265 } | 265 } |
| 266 | 266 |
| 267 void HTMLConstructionSite::queueTask(const HTMLConstructionSiteTask& task) | 267 void HTMLConstructionSite::queueTask(const HTMLConstructionSiteTask& task) |
| 268 { | 268 { |
| 269 flushPendingText(FlushAlways); | 269 flushPendingText(FlushAlways); |
| 270 ASSERT(m_pendingText.isEmpty()); | 270 ASSERT(m_pendingText.isEmpty()); |
| 271 m_taskQueue.append(task); | 271 m_taskQueue.append(task); |
| 272 } | 272 } |
| 273 | 273 |
| 274 void HTMLConstructionSite::attachLater(ContainerNode* parent, PassRefPtrWillBeRa
wPtr<Node> prpChild, bool selfClosing) | 274 void HTMLConstructionSite::attachLater(ContainerNode* parent, RawPtr<Node> prpCh
ild, bool selfClosing) |
| 275 { | 275 { |
| 276 ASSERT(scriptingContentIsAllowed(m_parserContentPolicy) || !prpChild.get()->
isElementNode() || !toScriptLoaderIfPossible(toElement(prpChild.get()))); | 276 ASSERT(scriptingContentIsAllowed(m_parserContentPolicy) || !prpChild.get()->
isElementNode() || !toScriptLoaderIfPossible(toElement(prpChild.get()))); |
| 277 ASSERT(pluginContentIsAllowed(m_parserContentPolicy) || !isHTMLPlugInElement
(prpChild)); | 277 ASSERT(pluginContentIsAllowed(m_parserContentPolicy) || !isHTMLPlugInElement
(prpChild)); |
| 278 | 278 |
| 279 HTMLConstructionSiteTask task(HTMLConstructionSiteTask::Insert); | 279 HTMLConstructionSiteTask task(HTMLConstructionSiteTask::Insert); |
| 280 task.parent = parent; | 280 task.parent = parent; |
| 281 task.child = prpChild; | 281 task.child = prpChild; |
| 282 task.selfClosing = selfClosing; | 282 task.selfClosing = selfClosing; |
| 283 | 283 |
| 284 if (shouldFosterParent()) { | 284 if (shouldFosterParent()) { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 m_attachmentRoot = nullptr; | 367 m_attachmentRoot = nullptr; |
| 368 } | 368 } |
| 369 | 369 |
| 370 void HTMLConstructionSite::setForm(HTMLFormElement* form) | 370 void HTMLConstructionSite::setForm(HTMLFormElement* form) |
| 371 { | 371 { |
| 372 // This method should only be needed for HTMLTreeBuilder in the fragment cas
e. | 372 // This method should only be needed for HTMLTreeBuilder in the fragment cas
e. |
| 373 ASSERT(!m_form); | 373 ASSERT(!m_form); |
| 374 m_form = form; | 374 m_form = form; |
| 375 } | 375 } |
| 376 | 376 |
| 377 PassRefPtrWillBeRawPtr<HTMLFormElement> HTMLConstructionSite::takeForm() | 377 RawPtr<HTMLFormElement> HTMLConstructionSite::takeForm() |
| 378 { | 378 { |
| 379 return m_form.release(); | 379 return m_form.release(); |
| 380 } | 380 } |
| 381 | 381 |
| 382 void HTMLConstructionSite::dispatchDocumentElementAvailableIfNeeded() | 382 void HTMLConstructionSite::dispatchDocumentElementAvailableIfNeeded() |
| 383 { | 383 { |
| 384 ASSERT(m_document); | 384 ASSERT(m_document); |
| 385 if (m_document->frame() && !m_isParsingFragment) { | 385 if (m_document->frame() && !m_isParsingFragment) { |
| 386 m_document->frame()->loader().dispatchDocumentElementAvailable(); | 386 m_document->frame()->loader().dispatchDocumentElementAvailable(); |
| 387 m_document->frame()->loader().runScriptsAtDocumentElementAvailable(); | 387 m_document->frame()->loader().runScriptsAtDocumentElementAvailable(); |
| 388 // runScriptsAtDocumentElementAvailable might have invalidated m_documen
t. | 388 // runScriptsAtDocumentElementAvailable might have invalidated m_documen
t. |
| 389 } | 389 } |
| 390 } | 390 } |
| 391 | 391 |
| 392 void HTMLConstructionSite::insertHTMLHtmlStartTagBeforeHTML(AtomicHTMLToken* tok
en) | 392 void HTMLConstructionSite::insertHTMLHtmlStartTagBeforeHTML(AtomicHTMLToken* tok
en) |
| 393 { | 393 { |
| 394 ASSERT(m_document); | 394 ASSERT(m_document); |
| 395 RefPtrWillBeRawPtr<HTMLHtmlElement> element = HTMLHtmlElement::create(*m_doc
ument); | 395 RawPtr<HTMLHtmlElement> element = HTMLHtmlElement::create(*m_document); |
| 396 setAttributes(element.get(), token, m_parserContentPolicy); | 396 setAttributes(element.get(), token, m_parserContentPolicy); |
| 397 attachLater(m_attachmentRoot, element); | 397 attachLater(m_attachmentRoot, element); |
| 398 m_openElements.pushHTMLHtmlElement(HTMLStackItem::create(element, token)); | 398 m_openElements.pushHTMLHtmlElement(HTMLStackItem::create(element, token)); |
| 399 | 399 |
| 400 executeQueuedTasks(); | 400 executeQueuedTasks(); |
| 401 element->insertedByParser(); | 401 element->insertedByParser(); |
| 402 dispatchDocumentElementAvailableIfNeeded(); | 402 dispatchDocumentElementAvailableIfNeeded(); |
| 403 } | 403 } |
| 404 | 404 |
| 405 void HTMLConstructionSite::mergeAttributesFromTokenIntoElement(AtomicHTMLToken*
token, Element* element) | 405 void HTMLConstructionSite::mergeAttributesFromTokenIntoElement(AtomicHTMLToken*
token, Element* element) |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 flush(FlushAlways); | 544 flush(FlushAlways); |
| 545 m_document->finishedParsing(); | 545 m_document->finishedParsing(); |
| 546 } | 546 } |
| 547 | 547 |
| 548 void HTMLConstructionSite::insertDoctype(AtomicHTMLToken* token) | 548 void HTMLConstructionSite::insertDoctype(AtomicHTMLToken* token) |
| 549 { | 549 { |
| 550 ASSERT(token->type() == HTMLToken::DOCTYPE); | 550 ASSERT(token->type() == HTMLToken::DOCTYPE); |
| 551 | 551 |
| 552 const String& publicId = StringImpl::create8BitIfPossible(token->publicIdent
ifier()); | 552 const String& publicId = StringImpl::create8BitIfPossible(token->publicIdent
ifier()); |
| 553 const String& systemId = StringImpl::create8BitIfPossible(token->systemIdent
ifier()); | 553 const String& systemId = StringImpl::create8BitIfPossible(token->systemIdent
ifier()); |
| 554 RefPtrWillBeRawPtr<DocumentType> doctype = DocumentType::create(m_document,
token->name(), publicId, systemId); | 554 RawPtr<DocumentType> doctype = DocumentType::create(m_document, token->name(
), publicId, systemId); |
| 555 attachLater(m_attachmentRoot, doctype.release()); | 555 attachLater(m_attachmentRoot, doctype.release()); |
| 556 | 556 |
| 557 // DOCTYPE nodes are only processed when parsing fragments w/o contextElemen
ts, which | 557 // DOCTYPE nodes are only processed when parsing fragments w/o contextElemen
ts, which |
| 558 // never occurs. However, if we ever chose to support such, this code is su
btly wrong, | 558 // never occurs. However, if we ever chose to support such, this code is su
btly wrong, |
| 559 // because context-less fragments can determine their own quirks mode, and t
hus change | 559 // because context-less fragments can determine their own quirks mode, and t
hus change |
| 560 // parsing rules (like <p> inside <table>). For now we ASSERT that we never
hit this code | 560 // parsing rules (like <p> inside <table>). For now we ASSERT that we never
hit this code |
| 561 // in a fragment, as changing the owning document's compatibility mode would
be wrong. | 561 // in a fragment, as changing the owning document's compatibility mode would
be wrong. |
| 562 ASSERT(!m_isParsingFragment); | 562 ASSERT(!m_isParsingFragment); |
| 563 if (m_isParsingFragment) | 563 if (m_isParsingFragment) |
| 564 return; | 564 return; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 594 { | 594 { |
| 595 ASSERT(!shouldFosterParent()); | 595 ASSERT(!shouldFosterParent()); |
| 596 m_head = HTMLStackItem::create(createHTMLElement(token), token); | 596 m_head = HTMLStackItem::create(createHTMLElement(token), token); |
| 597 attachLater(currentNode(), m_head->element()); | 597 attachLater(currentNode(), m_head->element()); |
| 598 m_openElements.pushHTMLHeadElement(m_head); | 598 m_openElements.pushHTMLHeadElement(m_head); |
| 599 } | 599 } |
| 600 | 600 |
| 601 void HTMLConstructionSite::insertHTMLBodyElement(AtomicHTMLToken* token) | 601 void HTMLConstructionSite::insertHTMLBodyElement(AtomicHTMLToken* token) |
| 602 { | 602 { |
| 603 ASSERT(!shouldFosterParent()); | 603 ASSERT(!shouldFosterParent()); |
| 604 RefPtrWillBeRawPtr<HTMLElement> body = createHTMLElement(token); | 604 RawPtr<HTMLElement> body = createHTMLElement(token); |
| 605 attachLater(currentNode(), body); | 605 attachLater(currentNode(), body); |
| 606 m_openElements.pushHTMLBodyElement(HTMLStackItem::create(body.release(), tok
en)); | 606 m_openElements.pushHTMLBodyElement(HTMLStackItem::create(body.release(), tok
en)); |
| 607 if (m_document && m_document->frame()) | 607 if (m_document && m_document->frame()) |
| 608 m_document->frame()->loader().client()->dispatchWillInsertBody(); | 608 m_document->frame()->loader().client()->dispatchWillInsertBody(); |
| 609 } | 609 } |
| 610 | 610 |
| 611 void HTMLConstructionSite::insertHTMLFormElement(AtomicHTMLToken* token, bool is
Demoted) | 611 void HTMLConstructionSite::insertHTMLFormElement(AtomicHTMLToken* token, bool is
Demoted) |
| 612 { | 612 { |
| 613 RefPtrWillBeRawPtr<HTMLElement> element = createHTMLElement(token); | 613 RawPtr<HTMLElement> element = createHTMLElement(token); |
| 614 ASSERT(isHTMLFormElement(element)); | 614 ASSERT(isHTMLFormElement(element)); |
| 615 m_form = static_pointer_cast<HTMLFormElement>(element.release()); | 615 m_form = static_pointer_cast<HTMLFormElement>(element.release()); |
| 616 m_form->setDemoted(isDemoted); | 616 m_form->setDemoted(isDemoted); |
| 617 attachLater(currentNode(), m_form.get()); | 617 attachLater(currentNode(), m_form.get()); |
| 618 m_openElements.push(HTMLStackItem::create(m_form.get(), token)); | 618 m_openElements.push(HTMLStackItem::create(m_form.get(), token)); |
| 619 } | 619 } |
| 620 | 620 |
| 621 void HTMLConstructionSite::insertHTMLElement(AtomicHTMLToken* token) | 621 void HTMLConstructionSite::insertHTMLElement(AtomicHTMLToken* token) |
| 622 { | 622 { |
| 623 RefPtrWillBeRawPtr<HTMLElement> element = createHTMLElement(token); | 623 RawPtr<HTMLElement> element = createHTMLElement(token); |
| 624 attachLater(currentNode(), element); | 624 attachLater(currentNode(), element); |
| 625 m_openElements.push(HTMLStackItem::create(element.release(), token)); | 625 m_openElements.push(HTMLStackItem::create(element.release(), token)); |
| 626 } | 626 } |
| 627 | 627 |
| 628 void HTMLConstructionSite::insertSelfClosingHTMLElementDestroyingToken(AtomicHTM
LToken* token) | 628 void HTMLConstructionSite::insertSelfClosingHTMLElementDestroyingToken(AtomicHTM
LToken* token) |
| 629 { | 629 { |
| 630 ASSERT(token->type() == HTMLToken::StartTag); | 630 ASSERT(token->type() == HTMLToken::StartTag); |
| 631 // Normally HTMLElementStack is responsible for calling finishParsingChildre
n, | 631 // Normally HTMLElementStack is responsible for calling finishParsingChildre
n, |
| 632 // but self-closing elements are never in the element stack so the stack | 632 // but self-closing elements are never in the element stack so the stack |
| 633 // doesn't get a chance to tell them that we're done parsing their children. | 633 // doesn't get a chance to tell them that we're done parsing their children. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 647 | 647 |
| 648 void HTMLConstructionSite::insertScriptElement(AtomicHTMLToken* token) | 648 void HTMLConstructionSite::insertScriptElement(AtomicHTMLToken* token) |
| 649 { | 649 { |
| 650 // http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.h
tml#already-started | 650 // http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.h
tml#already-started |
| 651 // http://html5.org/specs/dom-parsing.html#dom-range-createcontextualfragmen
t | 651 // http://html5.org/specs/dom-parsing.html#dom-range-createcontextualfragmen
t |
| 652 // For createContextualFragment, the specifications say to mark it parser-in
serted and already-started and later unmark them. | 652 // For createContextualFragment, the specifications say to mark it parser-in
serted and already-started and later unmark them. |
| 653 // However, we short circuit that logic to avoid the subtree traversal to fi
nd script elements since scripts can never see | 653 // However, we short circuit that logic to avoid the subtree traversal to fi
nd script elements since scripts can never see |
| 654 // those flags or effects thereof. | 654 // those flags or effects thereof. |
| 655 const bool parserInserted = m_parserContentPolicy != AllowScriptingContentAn
dDoNotMarkAlreadyStarted; | 655 const bool parserInserted = m_parserContentPolicy != AllowScriptingContentAn
dDoNotMarkAlreadyStarted; |
| 656 const bool alreadyStarted = m_isParsingFragment && parserInserted; | 656 const bool alreadyStarted = m_isParsingFragment && parserInserted; |
| 657 RefPtrWillBeRawPtr<HTMLScriptElement> element = HTMLScriptElement::create(ow
nerDocumentForCurrentNode(), parserInserted, alreadyStarted); | 657 RawPtr<HTMLScriptElement> element = HTMLScriptElement::create(ownerDocumentF
orCurrentNode(), parserInserted, alreadyStarted); |
| 658 setAttributes(element.get(), token, m_parserContentPolicy); | 658 setAttributes(element.get(), token, m_parserContentPolicy); |
| 659 if (scriptingContentIsAllowed(m_parserContentPolicy)) | 659 if (scriptingContentIsAllowed(m_parserContentPolicy)) |
| 660 attachLater(currentNode(), element); | 660 attachLater(currentNode(), element); |
| 661 m_openElements.push(HTMLStackItem::create(element.release(), token)); | 661 m_openElements.push(HTMLStackItem::create(element.release(), token)); |
| 662 } | 662 } |
| 663 | 663 |
| 664 void HTMLConstructionSite::insertForeignElement(AtomicHTMLToken* token, const At
omicString& namespaceURI) | 664 void HTMLConstructionSite::insertForeignElement(AtomicHTMLToken* token, const At
omicString& namespaceURI) |
| 665 { | 665 { |
| 666 ASSERT(token->type() == HTMLToken::StartTag); | 666 ASSERT(token->type() == HTMLToken::StartTag); |
| 667 DVLOG(1) << "Not implemented."; // parseError when xmlns or xmlns:xlink are
wrong. | 667 DVLOG(1) << "Not implemented."; // parseError when xmlns or xmlns:xlink are
wrong. |
| 668 | 668 |
| 669 RefPtrWillBeRawPtr<Element> element = createElement(token, namespaceURI); | 669 RawPtr<Element> element = createElement(token, namespaceURI); |
| 670 if (scriptingContentIsAllowed(m_parserContentPolicy) || !toScriptLoaderIfPos
sible(element.get())) | 670 if (scriptingContentIsAllowed(m_parserContentPolicy) || !toScriptLoaderIfPos
sible(element.get())) |
| 671 attachLater(currentNode(), element, token->selfClosing()); | 671 attachLater(currentNode(), element, token->selfClosing()); |
| 672 if (!token->selfClosing()) | 672 if (!token->selfClosing()) |
| 673 m_openElements.push(HTMLStackItem::create(element.release(), token, name
spaceURI)); | 673 m_openElements.push(HTMLStackItem::create(element.release(), token, name
spaceURI)); |
| 674 } | 674 } |
| 675 | 675 |
| 676 void HTMLConstructionSite::insertTextNode(const String& string, WhitespaceMode w
hitespaceMode) | 676 void HTMLConstructionSite::insertTextNode(const String& string, WhitespaceMode w
hitespaceMode) |
| 677 { | 677 { |
| 678 HTMLConstructionSiteTask dummyTask(HTMLConstructionSiteTask::Insert); | 678 HTMLConstructionSiteTask dummyTask(HTMLConstructionSiteTask::Insert); |
| 679 dummyTask.parent = currentNode(); | 679 dummyTask.parent = currentNode(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 } | 723 } |
| 724 | 724 |
| 725 void HTMLConstructionSite::takeAllChildren(HTMLStackItem* newParent, HTMLElement
Stack::ElementRecord* oldParent) | 725 void HTMLConstructionSite::takeAllChildren(HTMLStackItem* newParent, HTMLElement
Stack::ElementRecord* oldParent) |
| 726 { | 726 { |
| 727 HTMLConstructionSiteTask task(HTMLConstructionSiteTask::TakeAllChildren); | 727 HTMLConstructionSiteTask task(HTMLConstructionSiteTask::TakeAllChildren); |
| 728 task.parent = newParent->node(); | 728 task.parent = newParent->node(); |
| 729 task.child = oldParent->node(); | 729 task.child = oldParent->node(); |
| 730 queueTask(task); | 730 queueTask(task); |
| 731 } | 731 } |
| 732 | 732 |
| 733 PassRefPtrWillBeRawPtr<Element> HTMLConstructionSite::createElement(AtomicHTMLTo
ken* token, const AtomicString& namespaceURI) | 733 RawPtr<Element> HTMLConstructionSite::createElement(AtomicHTMLToken* token, cons
t AtomicString& namespaceURI) |
| 734 { | 734 { |
| 735 QualifiedName tagName(nullAtom, token->name(), namespaceURI); | 735 QualifiedName tagName(nullAtom, token->name(), namespaceURI); |
| 736 RefPtrWillBeRawPtr<Element> element = ownerDocumentForCurrentNode().createEl
ement(tagName, true); | 736 RawPtr<Element> element = ownerDocumentForCurrentNode().createElement(tagNam
e, true); |
| 737 setAttributes(element.get(), token, m_parserContentPolicy); | 737 setAttributes(element.get(), token, m_parserContentPolicy); |
| 738 return element.release(); | 738 return element.release(); |
| 739 } | 739 } |
| 740 | 740 |
| 741 inline Document& HTMLConstructionSite::ownerDocumentForCurrentNode() | 741 inline Document& HTMLConstructionSite::ownerDocumentForCurrentNode() |
| 742 { | 742 { |
| 743 if (isHTMLTemplateElement(*currentNode())) | 743 if (isHTMLTemplateElement(*currentNode())) |
| 744 return toHTMLTemplateElement(currentElement())->content()->document(); | 744 return toHTMLTemplateElement(currentElement())->content()->document(); |
| 745 return currentNode()->document(); | 745 return currentNode()->document(); |
| 746 } | 746 } |
| 747 | 747 |
| 748 PassRefPtrWillBeRawPtr<HTMLElement> HTMLConstructionSite::createHTMLElement(Atom
icHTMLToken* token) | 748 RawPtr<HTMLElement> HTMLConstructionSite::createHTMLElement(AtomicHTMLToken* tok
en) |
| 749 { | 749 { |
| 750 Document& document = ownerDocumentForCurrentNode(); | 750 Document& document = ownerDocumentForCurrentNode(); |
| 751 // Only associate the element with the current form if we're creating the ne
w element | 751 // Only associate the element with the current form if we're creating the ne
w element |
| 752 // in a document with a browsing context (rather than in <template> contents
). | 752 // in a document with a browsing context (rather than in <template> contents
). |
| 753 HTMLFormElement* form = document.frame() ? m_form.get() : 0; | 753 HTMLFormElement* form = document.frame() ? m_form.get() : 0; |
| 754 // FIXME: This can't use HTMLConstructionSite::createElement because we | 754 // FIXME: This can't use HTMLConstructionSite::createElement because we |
| 755 // have to pass the current form element. We should rework form association | 755 // have to pass the current form element. We should rework form association |
| 756 // to occur after construction to allow better code sharing here. | 756 // to occur after construction to allow better code sharing here. |
| 757 RefPtrWillBeRawPtr<HTMLElement> element = HTMLElementFactory::createHTMLElem
ent(token->name(), document, form, true); | 757 RawPtr<HTMLElement> element = HTMLElementFactory::createHTMLElement(token->n
ame(), document, form, true); |
| 758 setAttributes(element.get(), token, m_parserContentPolicy); | 758 setAttributes(element.get(), token, m_parserContentPolicy); |
| 759 return element.release(); | 759 return element.release(); |
| 760 } | 760 } |
| 761 | 761 |
| 762 PassRefPtrWillBeRawPtr<HTMLStackItem> HTMLConstructionSite::createElementFromSav
edToken(HTMLStackItem* item) | 762 RawPtr<HTMLStackItem> HTMLConstructionSite::createElementFromSavedToken(HTMLStac
kItem* item) |
| 763 { | 763 { |
| 764 RefPtrWillBeRawPtr<Element> element; | 764 RawPtr<Element> element; |
| 765 // NOTE: Moving from item -> token -> item copies the Attribute vector twice
! | 765 // NOTE: Moving from item -> token -> item copies the Attribute vector twice
! |
| 766 AtomicHTMLToken fakeToken(HTMLToken::StartTag, item->localName(), item->attr
ibutes()); | 766 AtomicHTMLToken fakeToken(HTMLToken::StartTag, item->localName(), item->attr
ibutes()); |
| 767 if (item->namespaceURI() == HTMLNames::xhtmlNamespaceURI) | 767 if (item->namespaceURI() == HTMLNames::xhtmlNamespaceURI) |
| 768 element = createHTMLElement(&fakeToken); | 768 element = createHTMLElement(&fakeToken); |
| 769 else | 769 else |
| 770 element = createElement(&fakeToken, item->namespaceURI()); | 770 element = createElement(&fakeToken, item->namespaceURI()); |
| 771 return HTMLStackItem::create(element.release(), &fakeToken, item->namespaceU
RI()); | 771 return HTMLStackItem::create(element.release(), &fakeToken, item->namespaceU
RI()); |
| 772 } | 772 } |
| 773 | 773 |
| 774 bool HTMLConstructionSite::indexOfFirstUnopenFormattingElement(unsigned& firstUn
openElementIndex) const | 774 bool HTMLConstructionSite::indexOfFirstUnopenFormattingElement(unsigned& firstUn
openElementIndex) const |
| (...skipping 16 matching lines...) Expand all Loading... |
| 791 void HTMLConstructionSite::reconstructTheActiveFormattingElements() | 791 void HTMLConstructionSite::reconstructTheActiveFormattingElements() |
| 792 { | 792 { |
| 793 unsigned firstUnopenElementIndex; | 793 unsigned firstUnopenElementIndex; |
| 794 if (!indexOfFirstUnopenFormattingElement(firstUnopenElementIndex)) | 794 if (!indexOfFirstUnopenFormattingElement(firstUnopenElementIndex)) |
| 795 return; | 795 return; |
| 796 | 796 |
| 797 unsigned unopenEntryIndex = firstUnopenElementIndex; | 797 unsigned unopenEntryIndex = firstUnopenElementIndex; |
| 798 ASSERT(unopenEntryIndex < m_activeFormattingElements.size()); | 798 ASSERT(unopenEntryIndex < m_activeFormattingElements.size()); |
| 799 for (; unopenEntryIndex < m_activeFormattingElements.size(); ++unopenEntryIn
dex) { | 799 for (; unopenEntryIndex < m_activeFormattingElements.size(); ++unopenEntryIn
dex) { |
| 800 HTMLFormattingElementList::Entry& unopenedEntry = m_activeFormattingElem
ents.at(unopenEntryIndex); | 800 HTMLFormattingElementList::Entry& unopenedEntry = m_activeFormattingElem
ents.at(unopenEntryIndex); |
| 801 RefPtrWillBeRawPtr<HTMLStackItem> reconstructed = createElementFromSaved
Token(unopenedEntry.stackItem().get()); | 801 RawPtr<HTMLStackItem> reconstructed = createElementFromSavedToken(unopen
edEntry.stackItem().get()); |
| 802 attachLater(currentNode(), reconstructed->node()); | 802 attachLater(currentNode(), reconstructed->node()); |
| 803 m_openElements.push(reconstructed); | 803 m_openElements.push(reconstructed); |
| 804 unopenedEntry.replaceElement(reconstructed.release()); | 804 unopenedEntry.replaceElement(reconstructed.release()); |
| 805 } | 805 } |
| 806 } | 806 } |
| 807 | 807 |
| 808 void HTMLConstructionSite::generateImpliedEndTagsWithExclusion(const AtomicStrin
g& tagName) | 808 void HTMLConstructionSite::generateImpliedEndTagsWithExclusion(const AtomicStrin
g& tagName) |
| 809 { | 809 { |
| 810 while (hasImpliedEndTag(currentStackItem()) && !currentStackItem()->matchesH
TMLTag(tagName)) | 810 while (hasImpliedEndTag(currentStackItem()) && !currentStackItem()->matchesH
TMLTag(tagName)) |
| 811 m_openElements.pop(); | 811 m_openElements.pop(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 task.parent = lastTable->next()->element(); | 857 task.parent = lastTable->next()->element(); |
| 858 } | 858 } |
| 859 | 859 |
| 860 bool HTMLConstructionSite::shouldFosterParent() const | 860 bool HTMLConstructionSite::shouldFosterParent() const |
| 861 { | 861 { |
| 862 return m_redirectAttachToFosterParent | 862 return m_redirectAttachToFosterParent |
| 863 && currentStackItem()->isElementNode() | 863 && currentStackItem()->isElementNode() |
| 864 && currentStackItem()->causesFosterParenting(); | 864 && currentStackItem()->causesFosterParenting(); |
| 865 } | 865 } |
| 866 | 866 |
| 867 void HTMLConstructionSite::fosterParent(PassRefPtrWillBeRawPtr<Node> node) | 867 void HTMLConstructionSite::fosterParent(RawPtr<Node> node) |
| 868 { | 868 { |
| 869 HTMLConstructionSiteTask task(HTMLConstructionSiteTask::Insert); | 869 HTMLConstructionSiteTask task(HTMLConstructionSiteTask::Insert); |
| 870 findFosterSite(task); | 870 findFosterSite(task); |
| 871 task.child = node; | 871 task.child = node; |
| 872 ASSERT(task.parent); | 872 ASSERT(task.parent); |
| 873 queueTask(task); | 873 queueTask(task); |
| 874 } | 874 } |
| 875 | 875 |
| 876 DEFINE_TRACE(HTMLConstructionSite::PendingText) | 876 DEFINE_TRACE(HTMLConstructionSite::PendingText) |
| 877 { | 877 { |
| 878 visitor->trace(parent); | 878 visitor->trace(parent); |
| 879 visitor->trace(nextChild); | 879 visitor->trace(nextChild); |
| 880 } | 880 } |
| 881 | 881 |
| 882 } // namespace blink | 882 } // namespace blink |
| OLD | NEW |