| 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 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 } | 731 } |
| 732 | 732 |
| 733 void HTMLConstructionSite::takeAllChildren(HTMLStackItem* newParent, HTMLElement
Stack::ElementRecord* oldParent) | 733 void HTMLConstructionSite::takeAllChildren(HTMLStackItem* newParent, HTMLElement
Stack::ElementRecord* oldParent) |
| 734 { | 734 { |
| 735 HTMLConstructionSiteTask task(HTMLConstructionSiteTask::TakeAllChildren); | 735 HTMLConstructionSiteTask task(HTMLConstructionSiteTask::TakeAllChildren); |
| 736 task.parent = newParent->node(); | 736 task.parent = newParent->node(); |
| 737 task.child = oldParent->node(); | 737 task.child = oldParent->node(); |
| 738 queueTask(task); | 738 queueTask(task); |
| 739 } | 739 } |
| 740 | 740 |
| 741 CreateElementFlags HTMLConstructionSite::getCreateElementFlags() const |
| 742 { |
| 743 // Set SynchronousCustomElements if not for HTML fragment parsing algorithm. |
| 744 // https://html.spec.whatwg.org/#create-an-element-for-the-token |
| 745 return static_cast<CreateElementFlags>(CreatedByParser |
| 746 | (m_isParsingFragment ? AsynchronousCustomElements : SynchronousCustomE
lements)); |
| 747 } |
| 748 |
| 741 Element* HTMLConstructionSite::createElement(AtomicHTMLToken* token, const Atomi
cString& namespaceURI) | 749 Element* HTMLConstructionSite::createElement(AtomicHTMLToken* token, const Atomi
cString& namespaceURI) |
| 742 { | 750 { |
| 743 QualifiedName tagName(nullAtom, token->name(), namespaceURI); | 751 QualifiedName tagName(nullAtom, token->name(), namespaceURI); |
| 744 Element* element = ownerDocumentForCurrentNode().createElement(tagName, true
); | 752 Element* element = ownerDocumentForCurrentNode().createElement(tagName, getC
reateElementFlags()); |
| 745 setAttributes(element, token, m_parserContentPolicy); | 753 setAttributes(element, token, m_parserContentPolicy); |
| 746 return element; | 754 return element; |
| 747 } | 755 } |
| 748 | 756 |
| 749 inline Document& HTMLConstructionSite::ownerDocumentForCurrentNode() | 757 inline Document& HTMLConstructionSite::ownerDocumentForCurrentNode() |
| 750 { | 758 { |
| 751 if (isHTMLTemplateElement(*currentNode())) | 759 if (isHTMLTemplateElement(*currentNode())) |
| 752 return toHTMLTemplateElement(currentElement())->content()->document(); | 760 return toHTMLTemplateElement(currentElement())->content()->document(); |
| 753 return currentNode()->document(); | 761 return currentNode()->document(); |
| 754 } | 762 } |
| 755 | 763 |
| 756 HTMLElement* HTMLConstructionSite::createHTMLElement(AtomicHTMLToken* token) | 764 HTMLElement* HTMLConstructionSite::createHTMLElement(AtomicHTMLToken* token) |
| 757 { | 765 { |
| 758 Document& document = ownerDocumentForCurrentNode(); | 766 Document& document = ownerDocumentForCurrentNode(); |
| 759 // Only associate the element with the current form if we're creating the ne
w element | 767 // Only associate the element with the current form if we're creating the ne
w element |
| 760 // in a document with a browsing context (rather than in <template> contents
). | 768 // in a document with a browsing context (rather than in <template> contents
). |
| 761 HTMLFormElement* form = document.frame() ? m_form.get() : 0; | 769 HTMLFormElement* form = document.frame() ? m_form.get() : 0; |
| 762 // FIXME: This can't use HTMLConstructionSite::createElement because we | 770 // FIXME: This can't use HTMLConstructionSite::createElement because we |
| 763 // have to pass the current form element. We should rework form association | 771 // have to pass the current form element. We should rework form association |
| 764 // to occur after construction to allow better code sharing here. | 772 // to occur after construction to allow better code sharing here. |
| 765 HTMLElement* element = HTMLElementFactory::createHTMLElement(token->name(),
document, form, true); | 773 HTMLElement* element = HTMLElementFactory::createHTMLElement(token->name(),
document, form, getCreateElementFlags()); |
| 766 setAttributes(element, token, m_parserContentPolicy); | 774 setAttributes(element, token, m_parserContentPolicy); |
| 767 return element; | 775 return element; |
| 768 } | 776 } |
| 769 | 777 |
| 770 HTMLStackItem* HTMLConstructionSite::createElementFromSavedToken(HTMLStackItem*
item) | 778 HTMLStackItem* HTMLConstructionSite::createElementFromSavedToken(HTMLStackItem*
item) |
| 771 { | 779 { |
| 772 Element* element; | 780 Element* element; |
| 773 // NOTE: Moving from item -> token -> item copies the Attribute vector twice
! | 781 // NOTE: Moving from item -> token -> item copies the Attribute vector twice
! |
| 774 AtomicHTMLToken fakeToken(HTMLToken::StartTag, item->localName(), item->attr
ibutes()); | 782 AtomicHTMLToken fakeToken(HTMLToken::StartTag, item->localName(), item->attr
ibutes()); |
| 775 if (item->namespaceURI() == HTMLNames::xhtmlNamespaceURI) | 783 if (item->namespaceURI() == HTMLNames::xhtmlNamespaceURI) |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 queueTask(task); | 889 queueTask(task); |
| 882 } | 890 } |
| 883 | 891 |
| 884 DEFINE_TRACE(HTMLConstructionSite::PendingText) | 892 DEFINE_TRACE(HTMLConstructionSite::PendingText) |
| 885 { | 893 { |
| 886 visitor->trace(parent); | 894 visitor->trace(parent); |
| 887 visitor->trace(nextChild); | 895 visitor->trace(nextChild); |
| 888 } | 896 } |
| 889 | 897 |
| 890 } // namespace blink | 898 } // namespace blink |
| OLD | NEW |