| 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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 ASSERT(m_taskQueue.isEmpty()); | 343 ASSERT(m_taskQueue.isEmpty()); |
| 344 // Currently we assume that text will never be the last token in the | 344 // Currently we assume that text will never be the last token in the |
| 345 // document and that we'll always queue some additional task to cause it to
flush. | 345 // document and that we'll always queue some additional task to cause it to
flush. |
| 346 ASSERT(m_pendingText.isEmpty()); | 346 ASSERT(m_pendingText.isEmpty()); |
| 347 } | 347 } |
| 348 | 348 |
| 349 void HTMLConstructionSite::trace(Visitor* visitor) | 349 void HTMLConstructionSite::trace(Visitor* visitor) |
| 350 { | 350 { |
| 351 visitor->trace(m_document); | 351 visitor->trace(m_document); |
| 352 visitor->trace(m_attachmentRoot); | 352 visitor->trace(m_attachmentRoot); |
| 353 visitor->trace(m_head); |
| 353 visitor->trace(m_form); | 354 visitor->trace(m_form); |
| 355 visitor->trace(m_openElements); |
| 356 visitor->trace(m_activeFormattingElements); |
| 354 visitor->trace(m_taskQueue); | 357 visitor->trace(m_taskQueue); |
| 355 } | 358 } |
| 356 | 359 |
| 357 void HTMLConstructionSite::detach() | 360 void HTMLConstructionSite::detach() |
| 358 { | 361 { |
| 359 // FIXME: We'd like to ASSERT here that we're canceling and not just discard
ing | 362 // FIXME: We'd like to ASSERT here that we're canceling and not just discard
ing |
| 360 // text that really should have made it into the DOM earlier, but there | 363 // text that really should have made it into the DOM earlier, but there |
| 361 // doesn't seem to be a nice way to do that. | 364 // doesn't seem to be a nice way to do that. |
| 362 m_pendingText.discard(); | 365 m_pendingText.discard(); |
| 363 m_document = nullptr; | 366 m_document = nullptr; |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 HTMLFormElement* form = document.frame() ? m_form.get() : 0; | 750 HTMLFormElement* form = document.frame() ? m_form.get() : 0; |
| 748 // FIXME: This can't use HTMLConstructionSite::createElement because we | 751 // FIXME: This can't use HTMLConstructionSite::createElement because we |
| 749 // have to pass the current form element. We should rework form association | 752 // have to pass the current form element. We should rework form association |
| 750 // to occur after construction to allow better code sharing here. | 753 // to occur after construction to allow better code sharing here. |
| 751 RefPtrWillBeRawPtr<Element> element = HTMLElementFactory::createHTMLElement(
token->name(), document, form, true); | 754 RefPtrWillBeRawPtr<Element> element = HTMLElementFactory::createHTMLElement(
token->name(), document, form, true); |
| 752 setAttributes(element.get(), token, m_parserContentPolicy); | 755 setAttributes(element.get(), token, m_parserContentPolicy); |
| 753 ASSERT(element->isHTMLElement()); | 756 ASSERT(element->isHTMLElement()); |
| 754 return element.release(); | 757 return element.release(); |
| 755 } | 758 } |
| 756 | 759 |
| 757 PassRefPtr<HTMLStackItem> HTMLConstructionSite::createElementFromSavedToken(HTML
StackItem* item) | 760 PassRefPtrWillBeRawPtr<HTMLStackItem> HTMLConstructionSite::createElementFromSav
edToken(HTMLStackItem* item) |
| 758 { | 761 { |
| 759 RefPtrWillBeRawPtr<Element> element; | 762 RefPtrWillBeRawPtr<Element> element; |
| 760 // NOTE: Moving from item -> token -> item copies the Attribute vector twice
! | 763 // NOTE: Moving from item -> token -> item copies the Attribute vector twice
! |
| 761 AtomicHTMLToken fakeToken(HTMLToken::StartTag, item->localName(), item->attr
ibutes()); | 764 AtomicHTMLToken fakeToken(HTMLToken::StartTag, item->localName(), item->attr
ibutes()); |
| 762 if (item->namespaceURI() == HTMLNames::xhtmlNamespaceURI) | 765 if (item->namespaceURI() == HTMLNames::xhtmlNamespaceURI) |
| 763 element = createHTMLElement(&fakeToken); | 766 element = createHTMLElement(&fakeToken); |
| 764 else | 767 else |
| 765 element = createElement(&fakeToken, item->namespaceURI()); | 768 element = createElement(&fakeToken, item->namespaceURI()); |
| 766 return HTMLStackItem::create(element.release(), &fakeToken, item->namespaceU
RI()); | 769 return HTMLStackItem::create(element.release(), &fakeToken, item->namespaceU
RI()); |
| 767 } | 770 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 786 void HTMLConstructionSite::reconstructTheActiveFormattingElements() | 789 void HTMLConstructionSite::reconstructTheActiveFormattingElements() |
| 787 { | 790 { |
| 788 unsigned firstUnopenElementIndex; | 791 unsigned firstUnopenElementIndex; |
| 789 if (!indexOfFirstUnopenFormattingElement(firstUnopenElementIndex)) | 792 if (!indexOfFirstUnopenFormattingElement(firstUnopenElementIndex)) |
| 790 return; | 793 return; |
| 791 | 794 |
| 792 unsigned unopenEntryIndex = firstUnopenElementIndex; | 795 unsigned unopenEntryIndex = firstUnopenElementIndex; |
| 793 ASSERT(unopenEntryIndex < m_activeFormattingElements.size()); | 796 ASSERT(unopenEntryIndex < m_activeFormattingElements.size()); |
| 794 for (; unopenEntryIndex < m_activeFormattingElements.size(); ++unopenEntryIn
dex) { | 797 for (; unopenEntryIndex < m_activeFormattingElements.size(); ++unopenEntryIn
dex) { |
| 795 HTMLFormattingElementList::Entry& unopenedEntry = m_activeFormattingElem
ents.at(unopenEntryIndex); | 798 HTMLFormattingElementList::Entry& unopenedEntry = m_activeFormattingElem
ents.at(unopenEntryIndex); |
| 796 RefPtr<HTMLStackItem> reconstructed = createElementFromSavedToken(unopen
edEntry.stackItem().get()); | 799 RefPtrWillBeRawPtr<HTMLStackItem> reconstructed = createElementFromSaved
Token(unopenedEntry.stackItem().get()); |
| 797 attachLater(currentNode(), reconstructed->node()); | 800 attachLater(currentNode(), reconstructed->node()); |
| 798 m_openElements.push(reconstructed); | 801 m_openElements.push(reconstructed); |
| 799 unopenedEntry.replaceElement(reconstructed.release()); | 802 unopenedEntry.replaceElement(reconstructed.release()); |
| 800 } | 803 } |
| 801 } | 804 } |
| 802 | 805 |
| 803 void HTMLConstructionSite::generateImpliedEndTagsWithExclusion(const AtomicStrin
g& tagName) | 806 void HTMLConstructionSite::generateImpliedEndTagsWithExclusion(const AtomicStrin
g& tagName) |
| 804 { | 807 { |
| 805 while (hasImpliedEndTag(currentStackItem()) && !currentStackItem()->matchesH
TMLTag(tagName)) | 808 while (hasImpliedEndTag(currentStackItem()) && !currentStackItem()->matchesH
TMLTag(tagName)) |
| 806 m_openElements.pop(); | 809 m_openElements.pop(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 void HTMLConstructionSite::fosterParent(PassRefPtrWillBeRawPtr<Node> node) | 862 void HTMLConstructionSite::fosterParent(PassRefPtrWillBeRawPtr<Node> node) |
| 860 { | 863 { |
| 861 HTMLConstructionSiteTask task(HTMLConstructionSiteTask::Insert); | 864 HTMLConstructionSiteTask task(HTMLConstructionSiteTask::Insert); |
| 862 findFosterSite(task); | 865 findFosterSite(task); |
| 863 task.child = node; | 866 task.child = node; |
| 864 ASSERT(task.parent); | 867 ASSERT(task.parent); |
| 865 queueTask(task); | 868 queueTask(task); |
| 866 } | 869 } |
| 867 | 870 |
| 868 } | 871 } |
| OLD | NEW |