| 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 21 matching lines...) Expand all Loading... |
| 32 #include "core/HTMLNames.h" | 32 #include "core/HTMLNames.h" |
| 33 #include "core/dom/Comment.h" | 33 #include "core/dom/Comment.h" |
| 34 #include "core/dom/DocumentFragment.h" | 34 #include "core/dom/DocumentFragment.h" |
| 35 #include "core/dom/DocumentType.h" | 35 #include "core/dom/DocumentType.h" |
| 36 #include "core/dom/Element.h" | 36 #include "core/dom/Element.h" |
| 37 #include "core/dom/ElementTraversal.h" | 37 #include "core/dom/ElementTraversal.h" |
| 38 #include "core/dom/IgnoreDestructiveWriteCountIncrementer.h" | 38 #include "core/dom/IgnoreDestructiveWriteCountIncrementer.h" |
| 39 #include "core/dom/ScriptLoader.h" | 39 #include "core/dom/ScriptLoader.h" |
| 40 #include "core/dom/TemplateContentDocumentFragment.h" | 40 #include "core/dom/TemplateContentDocumentFragment.h" |
| 41 #include "core/dom/Text.h" | 41 #include "core/dom/Text.h" |
| 42 #include "core/dom/ThrowOnDynamicMarkupInsertionCountIncrementer.h" |
| 42 #include "core/dom/custom/CEReactionsScope.h" | 43 #include "core/dom/custom/CEReactionsScope.h" |
| 43 #include "core/dom/custom/CustomElementDefinition.h" | 44 #include "core/dom/custom/CustomElementDefinition.h" |
| 44 #include "core/dom/custom/CustomElementDescriptor.h" | 45 #include "core/dom/custom/CustomElementDescriptor.h" |
| 45 #include "core/dom/custom/CustomElementRegistry.h" | 46 #include "core/dom/custom/CustomElementRegistry.h" |
| 46 #include "core/frame/LocalDOMWindow.h" | 47 #include "core/frame/LocalDOMWindow.h" |
| 47 #include "core/frame/LocalFrame.h" | 48 #include "core/frame/LocalFrame.h" |
| 48 #include "core/html/HTMLFormElement.h" | 49 #include "core/html/HTMLFormElement.h" |
| 49 #include "core/html/HTMLHtmlElement.h" | 50 #include "core/html/HTMLHtmlElement.h" |
| 50 #include "core/html/HTMLPlugInElement.h" | 51 #include "core/html/HTMLPlugInElement.h" |
| 51 #include "core/html/HTMLScriptElement.h" | 52 #include "core/html/HTMLScriptElement.h" |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 // "4. Let definition be the result of looking up a custom element ..." etc. | 803 // "4. Let definition be the result of looking up a custom element ..." etc. |
| 803 CustomElementDefinition* definition = m_isParsingFragment ? nullptr : lookUp
CustomElementDefinition(document, token); | 804 CustomElementDefinition* definition = m_isParsingFragment ? nullptr : lookUp
CustomElementDefinition(document, token); |
| 804 // "5. If definition is non-null and the parser was not originally created | 805 // "5. If definition is non-null and the parser was not originally created |
| 805 // for the HTML fragment parsing algorithm, then let will execute script | 806 // for the HTML fragment parsing algorithm, then let will execute script |
| 806 // be true." | 807 // be true." |
| 807 bool willExecuteScript = definition && !m_isParsingFragment; | 808 bool willExecuteScript = definition && !m_isParsingFragment; |
| 808 | 809 |
| 809 HTMLElement* element; | 810 HTMLElement* element; |
| 810 | 811 |
| 811 if (willExecuteScript) { | 812 if (willExecuteScript) { |
| 812 // "6.1 Increment the parser's script nesting level." | 813 // "6.1 Increment the document's throw-on-dynamic-insertion counter." |
| 813 HTMLParserReentryPermit::ScriptNestingLevelIncrementer incrementScriptNe
stingLevel = m_reentryPermit->incrementScriptNestingLevel(); | 814 ThrowOnDynamicMarkupInsertionCountIncrementer throwOnDynamicMarkupInsert
ions( |
| 814 | |
| 815 // "6.2 Set the parser pause flag to true." | |
| 816 m_reentryPermit->pause(); | |
| 817 | |
| 818 // TODO(dominicc): Change this once resolved: | |
| 819 // https://github.com/whatwg/html/issues/1630 | |
| 820 IgnoreDestructiveWriteCountIncrementer ignoreDestructiveWrites( | |
| 821 &document); | 815 &document); |
| 822 | 816 |
| 823 // "6.3 If the JavaScript execution context stack is empty, | 817 // "6.2 If the JavaScript execution context stack is empty, |
| 824 // then perform a microtask checkpoint." | 818 // then perform a microtask checkpoint." |
| 825 | 819 |
| 826 // TODO(dominicc): This is the way the Blink HTML parser | 820 // TODO(dominicc): This is the way the Blink HTML parser |
| 827 // performs checkpoints, but note the spec is different--it | 821 // performs checkpoints, but note the spec is different--it |
| 828 // talks about the JavaScript stack, not the script nesting | 822 // talks about the JavaScript stack, not the script nesting |
| 829 // level. | 823 // level. |
| 830 if (1u == m_reentryPermit->scriptNestingLevel()) | 824 if (0u == m_reentryPermit->scriptNestingLevel()) |
| 831 Microtask::performCheckpoint(V8PerIsolateData::mainThreadIsolate()); | 825 Microtask::performCheckpoint(V8PerIsolateData::mainThreadIsolate()); |
| 832 | 826 |
| 833 // "6.4 Push a new element queue onto the custom element | 827 // "6.3 Push a new element queue onto the custom element |
| 834 // reactions stack." | 828 // reactions stack." |
| 835 CEReactionsScope reactions; | 829 CEReactionsScope reactions; |
| 836 | 830 |
| 837 // 7. | 831 // 7. |
| 838 QualifiedName elementQName(nullAtom, token->name(), HTMLNames::xhtmlName
spaceURI); | 832 QualifiedName elementQName(nullAtom, token->name(), HTMLNames::xhtmlName
spaceURI); |
| 839 element = definition->createElementSync(document, elementQName); | 833 element = definition->createElementSync(document, elementQName); |
| 840 | 834 |
| 841 // "8. Append each attribute in the given token to element." | 835 // "8. Append each attribute in the given token to element." |
| 842 // We don't use setAttributes here because the custom element | 836 // We don't use setAttributes here because the custom element |
| 843 // constructor may have manipulated attributes. | 837 // constructor may have manipulated attributes. |
| 844 for (const auto& attribute : token->attributes()) | 838 for (const auto& attribute : token->attributes()) |
| 845 element->setAttribute(attribute.name(), attribute.value()); | 839 element->setAttribute(attribute.name(), attribute.value()); |
| 846 | 840 |
| 847 // "9. If will execute script is true, then ..." etc. The | 841 // "9. If will execute script is true, then ..." etc. The |
| 848 // CEReactionsScope and ScriptNestingLevelIncrementer | 842 // CEReactionsScope and ThrowOnDynamicMarkupInsertionCountIncrementer |
| 849 // destructors implement steps 9.1-4. | 843 // destructors implement steps 9.1-3. |
| 850 } else { | 844 } else { |
| 851 // FIXME: This can't use | 845 // FIXME: This can't use |
| 852 // HTMLConstructionSite::createElement because we have to | 846 // HTMLConstructionSite::createElement because we have to |
| 853 // pass the current form element. We should rework form | 847 // pass the current form element. We should rework form |
| 854 // association to occur after construction to allow better | 848 // association to occur after construction to allow better |
| 855 // code sharing here. | 849 // code sharing here. |
| 856 element = HTMLElementFactory::createHTMLElement(token->name(), document,
form, getCreateElementFlags()); | 850 element = HTMLElementFactory::createHTMLElement(token->name(), document,
form, getCreateElementFlags()); |
| 857 // Definition for the created element does not exist here and | 851 // Definition for the created element does not exist here and |
| 858 // it cannot be custom or failed. | 852 // it cannot be custom or failed. |
| 859 DCHECK_NE(element->getCustomElementState(), CustomElementState::Custom); | 853 DCHECK_NE(element->getCustomElementState(), CustomElementState::Custom); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 queueTask(task); | 977 queueTask(task); |
| 984 } | 978 } |
| 985 | 979 |
| 986 DEFINE_TRACE(HTMLConstructionSite::PendingText) | 980 DEFINE_TRACE(HTMLConstructionSite::PendingText) |
| 987 { | 981 { |
| 988 visitor->trace(parent); | 982 visitor->trace(parent); |
| 989 visitor->trace(nextChild); | 983 visitor->trace(nextChild); |
| 990 } | 984 } |
| 991 | 985 |
| 992 } // namespace blink | 986 } // namespace blink |
| OLD | NEW |