diff --git a/engine/bindings/core/v8/ScriptController.cpp b/engine/bindings/core/v8/ScriptController.cpp index 09710a9c911849614fa2e161cafe84b9b140a0ce..38f1942d6e3cb463f692b192789cde3bcdcf677a 100644 --- a/engine/bindings/core/v8/ScriptController.cpp +++ b/engine/bindings/core/v8/ScriptController.cpp @@ -47,7 +47,6 @@ #include "bindings/core/v8/WindowProxy.h" #include "core/dom/Document.h" #include "core/dom/Node.h" -#include "core/dom/ScriptableDocumentParser.h" #include "core/events/Event.h" #include "core/events/EventListener.h" #include "core/frame/LocalDOMWindow.h" @@ -57,6 +56,7 @@ #include "core/html/HTMLLinkElement.h" #include "core/html/imports/HTMLImportChild.h" #include "core/html/imports/HTMLImportLoader.h" +#include "core/html/parser/HTMLDocumentParser.h" #include "core/inspector/InspectorTraceEvents.h" #include "core/inspector/ScriptCallStack.h" #include "core/loader/FrameLoaderClient.h" @@ -190,7 +190,7 @@ WindowProxy* ScriptController::windowProxy(DOMWrapperWorld& world) TextPosition ScriptController::eventHandlerPosition() const { - ScriptableDocumentParser* parser = m_frame->document()->scriptableDocumentParser(); + HTMLDocumentParser* parser = m_frame->document()->scriptableDocumentParser(); if (parser) return parser->textPosition(); return TextPosition::minimumPosition(); diff --git a/engine/core/core.gni b/engine/core/core.gni index 40eba65c18493af4f5b196a7ce83cffb05e404ab..c23b3f9a7b7b69ca351a4211644717f56dbdfeb4 100644 --- a/engine/core/core.gni +++ b/engine/core/core.gni @@ -445,8 +445,6 @@ sky_core_files = [ "dom/RenderTreeBuilder.cpp", "dom/RenderTreeBuilder.h", "dom/RequestAnimationFrameCallback.h", - "dom/ScriptableDocumentParser.cpp", - "dom/ScriptableDocumentParser.h", "dom/ScriptedAnimationController.cpp", "dom/ScriptedAnimationController.h", "dom/SelectorQuery.cpp", diff --git a/engine/core/dom/Document.cpp b/engine/core/dom/Document.cpp index 859a8506dfd3e560359d7528941b5cd049766cbb..52b8684050a6fa26964496e2cc6ba156d70c6dc1 100644 --- a/engine/core/dom/Document.cpp +++ b/engine/core/dom/Document.cpp @@ -1449,9 +1449,9 @@ PassRefPtrWillBeRawPtr Document::createParser() return HTMLDocumentParser::create(toHTMLDocument(*this), false); } -ScriptableDocumentParser* Document::scriptableDocumentParser() const +HTMLDocumentParser* Document::scriptableDocumentParser() const { - return parser() ? parser()->asScriptableDocumentParser() : 0; + return parser() ? parser()->asHTMLDocumentParser() : 0; } void Document::detachParser() @@ -1743,7 +1743,7 @@ void Document::executeScriptsWaitingForResourcesTimerFired(Timer*) { if (!isRenderingReady()) return; - if (ScriptableDocumentParser* parser = scriptableDocumentParser()) + if (HTMLDocumentParser* parser = scriptableDocumentParser()) parser->executeScriptsWaitingForResources(); } @@ -2767,7 +2767,7 @@ void Document::addMessage(PassRefPtrWillBeRawPtr consoleMessage) if (!consoleMessage->scriptState() && consoleMessage->url().isNull() && !consoleMessage->lineNumber()) { consoleMessage->setURL(url().string()); if (parsing() && scriptableDocumentParser()) { - ScriptableDocumentParser* parser = scriptableDocumentParser(); + HTMLDocumentParser* parser = scriptableDocumentParser(); if (!parser->isWaitingForScripts() && !parser->isExecutingScript()) consoleMessage->setLineNumber(parser->lineNumber().oneBasedInt()); } diff --git a/engine/core/dom/Document.h b/engine/core/dom/Document.h index 4f5ce5129744dafa028d165ccd98c40694a03609..11b0a3fcd9f4f5bc98302e9d3e36552a77428402 100644 --- a/engine/core/dom/Document.h +++ b/engine/core/dom/Document.h @@ -90,6 +90,7 @@ class Frame; class FrameHost; class FrameView; class HTMLCanvasElement; +class HTMLDocumentParser; class HTMLElement; class HTMLImport; class HTMLImportLoader; @@ -112,7 +113,6 @@ class RenderView; class RequestAnimationFrameCallback; class ResourceFetcher; class ScriptRunner; -class ScriptableDocumentParser; class ScriptedAnimationController; class SegmentedString; class SelectorQueryCache; @@ -367,7 +367,7 @@ public: virtual PassRefPtrWillBeRawPtr createParser(); DocumentParser* parser() const { return m_parser.get(); } - ScriptableDocumentParser* scriptableDocumentParser() const; + HTMLDocumentParser* scriptableDocumentParser() const; enum ReadyState { Loading, diff --git a/engine/core/dom/DocumentFragment.cpp b/engine/core/dom/DocumentFragment.cpp index 3a747faa41c1cebc90d97a1445488c7b71926617..8eb48f85a87cf02078d4fba211f5316c35f6c405 100644 --- a/engine/core/dom/DocumentFragment.cpp +++ b/engine/core/dom/DocumentFragment.cpp @@ -68,9 +68,9 @@ PassRefPtrWillBeRawPtr DocumentFragment::cloneNode(bool deep) return clone.release(); } -void DocumentFragment::parseHTML(const String& source, Element* contextElement, ParserContentPolicy parserContentPolicy) +void DocumentFragment::parseHTML(const String& source, Element* contextElement) { - HTMLDocumentParser::parseDocumentFragment(source, this, contextElement, parserContentPolicy); + HTMLDocumentParser::parseDocumentFragment(source, this, contextElement); } } // namespace blink diff --git a/engine/core/dom/DocumentFragment.h b/engine/core/dom/DocumentFragment.h index a256f17a97dfc6cce2dc042beb525aaed3867874..83319cec152d8a9eb80ead32ed5bf906b1080181 100644 --- a/engine/core/dom/DocumentFragment.h +++ b/engine/core/dom/DocumentFragment.h @@ -25,7 +25,6 @@ #define DocumentFragment_h #include "core/dom/ContainerNode.h" -#include "core/dom/ParserContentPolicy.h" namespace blink { @@ -34,7 +33,7 @@ class DocumentFragment : public ContainerNode { public: static PassRefPtrWillBeRawPtr create(Document&); - void parseHTML(const String&, Element* contextElement, ParserContentPolicy = AllowScriptingContent); + void parseHTML(const String&, Element* contextElement); virtual bool canContainRangeEndPoint() const OVERRIDE FINAL { return true; } virtual bool isTemplateContent() const { return false; } diff --git a/engine/core/dom/DocumentParser.h b/engine/core/dom/DocumentParser.h index f7f4d9dc90969da759003ead71a0280ce2e1bccb..9b0b7658ef4430cd6ca13744fc6967d4f52454f5 100644 --- a/engine/core/dom/DocumentParser.h +++ b/engine/core/dom/DocumentParser.h @@ -32,7 +32,7 @@ namespace blink { class Document; class SegmentedString; -class ScriptableDocumentParser; +class HTMLDocumentParser; class TextResourceDecoder; class DocumentParser : public RefCountedWillBeGarbageCollectedFinalized { @@ -40,7 +40,7 @@ public: virtual ~DocumentParser(); virtual void trace(Visitor*); - virtual ScriptableDocumentParser* asScriptableDocumentParser() { return 0; } + virtual HTMLDocumentParser* asHTMLDocumentParser() { return 0; } // http://www.whatwg.org/specs/web-apps/current-work/#insertion-point virtual bool hasInsertionPoint() { return true; } diff --git a/engine/core/dom/Element.cpp b/engine/core/dom/Element.cpp index 7fde14dd419bb64bc29069ef667b85f93ac1338a..1123628b223ae793d5e33a59ea2c13a86f24a09e 100644 --- a/engine/core/dom/Element.cpp +++ b/engine/core/dom/Element.cpp @@ -52,7 +52,6 @@ #include "core/dom/NamedNodeMap.h" #include "core/dom/NodeRenderStyle.h" #include "core/dom/RenderTreeBuilder.h" -#include "core/dom/ScriptableDocumentParser.h" #include "core/dom/SelectorQuery.h" #include "core/dom/StyleEngine.h" #include "core/dom/Text.h" @@ -75,6 +74,7 @@ #include "core/html/HTMLDocument.h" #include "core/html/HTMLElement.h" #include "core/html/HTMLTemplateElement.h" +#include "core/html/parser/HTMLDocumentParser.h" #include "core/html/parser/HTMLParserIdioms.h" #include "core/page/Chrome.h" #include "core/page/ChromeClient.h" @@ -1553,7 +1553,7 @@ String Element::outerHTML() const void Element::setInnerHTML(const String& html, ExceptionState& exceptionState) { - if (RefPtrWillBeRawPtr fragment = createFragmentForInnerOuterHTML(html, this, AllowScriptingContent, "innerHTML", exceptionState)) { + if (RefPtrWillBeRawPtr fragment = createFragmentForInnerOuterHTML(html, this, "innerHTML", exceptionState)) { ContainerNode* container = this; if (isHTMLTemplateElement(*this)) container = toHTMLTemplateElement(this)->content(); @@ -1577,7 +1577,7 @@ void Element::setOuterHTML(const String& html, ExceptionState& exceptionState) RefPtrWillBeRawPtr prev = previousSibling(); RefPtrWillBeRawPtr next = nextSibling(); - RefPtrWillBeRawPtr fragment = createFragmentForInnerOuterHTML(html, parent.get(), AllowScriptingContent, "outerHTML", exceptionState); + RefPtrWillBeRawPtr fragment = createFragmentForInnerOuterHTML(html, parent.get(), "outerHTML", exceptionState); if (exceptionState.hadException()) return; diff --git a/engine/core/dom/ParserContentPolicy.h b/engine/core/dom/ParserContentPolicy.h deleted file mode 100644 index 2b21a8d8b3e91ffa7113c7ddf6b6463cbc5ef303..0000000000000000000000000000000000000000 --- a/engine/core/dom/ParserContentPolicy.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2010 Google, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef ParserContentPolicy_h -#define ParserContentPolicy_h - -namespace blink { - -enum ParserContentPolicy { - DisallowScriptingContent, - AllowScriptingContent, - AllowScriptingContentAndDoNotMarkAlreadyStarted, -}; - -static inline bool scriptingContentIsAllowed(ParserContentPolicy parserContentPolicy) -{ - return parserContentPolicy == AllowScriptingContent || parserContentPolicy == AllowScriptingContentAndDoNotMarkAlreadyStarted; -} - -static inline ParserContentPolicy disallowScriptingContent(ParserContentPolicy parserContentPolicy) -{ - if (!scriptingContentIsAllowed(parserContentPolicy)) - return parserContentPolicy; - return DisallowScriptingContent; -} - -} // namespace blink - -#endif // ParserContentPolicy_h diff --git a/engine/core/dom/ScriptableDocumentParser.cpp b/engine/core/dom/ScriptableDocumentParser.cpp deleted file mode 100644 index e6fc302969287da25b2917f8b8a4c4fbf16620da..0000000000000000000000000000000000000000 --- a/engine/core/dom/ScriptableDocumentParser.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2010 Google, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "core/dom/ScriptableDocumentParser.h" - -#include "core/dom/Document.h" -#include "core/frame/Settings.h" - -namespace blink { - -ScriptableDocumentParser::ScriptableDocumentParser(Document& document, ParserContentPolicy parserContentPolicy) - : DecodedDataDocumentParser(document) - , m_parserContentPolicy(parserContentPolicy) -{ -} - -}; diff --git a/engine/core/dom/ScriptableDocumentParser.h b/engine/core/dom/ScriptableDocumentParser.h deleted file mode 100644 index 0d748f1c28a39732502de86033298c91d5c43156..0000000000000000000000000000000000000000 --- a/engine/core/dom/ScriptableDocumentParser.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2010 Google, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef ScriptableDocumentParser_h -#define ScriptableDocumentParser_h - -#include "core/dom/DecodedDataDocumentParser.h" -#include "core/dom/ParserContentPolicy.h" -#include "wtf/text/TextPosition.h" - -namespace blink { - -class ScriptableDocumentParser : public DecodedDataDocumentParser { -public: - // Only used by Document::open for deciding if its safe to act on a - // JavaScript document.open() call right now, or it should be ignored. - virtual bool isExecutingScript() const { return false; } - - // FIXME: Only the HTMLDocumentParser ever blocks script execution on - // stylesheet load, which is likely a bug in the XMLDocumentParser. - virtual void executeScriptsWaitingForResources() { } - - virtual bool isWaitingForScripts() const = 0; - - // These are used to expose the current line/column to the scripting system. - virtual OrdinalNumber lineNumber() const = 0; - virtual TextPosition textPosition() const = 0; - - ParserContentPolicy parserContentPolicy() { return m_parserContentPolicy; } - -protected: - explicit ScriptableDocumentParser(Document&, ParserContentPolicy = AllowScriptingContent); - -private: - virtual ScriptableDocumentParser* asScriptableDocumentParser() OVERRIDE FINAL { return this; } - - ParserContentPolicy m_parserContentPolicy; -}; - -} - -#endif // ScriptableDocumentParser_h diff --git a/engine/core/dom/StyleElement.cpp b/engine/core/dom/StyleElement.cpp index 739f34fd8932cb343c86422288bcd7fd206c92a2..97f9d02d454fe2069b55e10e8c075386b2f9c152 100644 --- a/engine/core/dom/StyleElement.cpp +++ b/engine/core/dom/StyleElement.cpp @@ -27,10 +27,10 @@ #include "core/css/StyleSheetContents.h" #include "core/dom/Document.h" #include "core/dom/Element.h" -#include "core/dom/ScriptableDocumentParser.h" #include "core/dom/StyleEngine.h" #include "core/frame/LocalFrame.h" #include "core/html/HTMLStyleElement.h" +#include "core/html/parser/HTMLDocumentParser.h" #include "platform/TraceEvent.h" #include "wtf/text/StringBuilder.h" diff --git a/engine/core/dom/shadow/ShadowRoot.cpp b/engine/core/dom/shadow/ShadowRoot.cpp index f1e521687d0dd6a41e53194f2958116c224690f6..b6fb2f78409956eb47dd25f1780ed42310e204e7 100644 --- a/engine/core/dom/shadow/ShadowRoot.cpp +++ b/engine/core/dom/shadow/ShadowRoot.cpp @@ -115,7 +115,7 @@ void ShadowRoot::setInnerHTML(const String& markup, ExceptionState& exceptionSta return; } - if (RefPtrWillBeRawPtr fragment = createFragmentForInnerOuterHTML(markup, host(), AllowScriptingContent, "innerHTML", exceptionState)) + if (RefPtrWillBeRawPtr fragment = createFragmentForInnerOuterHTML(markup, host(), "innerHTML", exceptionState)) replaceChildrenWithFragment(this, fragment.release(), exceptionState); } diff --git a/engine/core/editing/Editor.cpp b/engine/core/editing/Editor.cpp index 845438aaf834deeaef46bf8c018bf6d9eb85df56..3401c706ba3c91d763f0f9f14223c01df5b605d0 100644 --- a/engine/core/editing/Editor.cpp +++ b/engine/core/editing/Editor.cpp @@ -35,7 +35,6 @@ #include "core/dom/DocumentFragment.h" #include "core/dom/DocumentMarkerController.h" #include "core/dom/NodeTraversal.h" -#include "core/dom/ParserContentPolicy.h" #include "core/dom/Text.h" #include "core/editing/DeleteSelectionCommand.h" #include "core/editing/InputMethodController.h" diff --git a/engine/core/editing/markup.cpp b/engine/core/editing/markup.cpp index a04a843a292c9bc4e12575d7fe700e691abeac43..44aecb727b67704579f8d79732a61a474ec6d058 100644 --- a/engine/core/editing/markup.cpp +++ b/engine/core/editing/markup.cpp @@ -529,10 +529,10 @@ String createMarkup(const Range* range, WillBeHeapVector createFragmentFromMarkup(Document& document, const String& markup, ParserContentPolicy parserContentPolicy) +PassRefPtrWillBeRawPtr createFragmentFromMarkup(Document& document, const String& markup) { RefPtrWillBeRawPtr fragment = DocumentFragment::create(document); - fragment->parseHTML(markup, nullptr, parserContentPolicy); + fragment->parseHTML(markup, nullptr); return fragment.release(); } @@ -545,12 +545,12 @@ String createMarkup(const Node* node, EChildrenOnly childrenOnly, WillBeHeapVect return accumulator.serializeNodes(const_cast(*node), childrenOnly, tagNamesToSkip); } -PassRefPtrWillBeRawPtr createFragmentForInnerOuterHTML(const String& markup, Element* contextElement, ParserContentPolicy parserContentPolicy, const char* method, ExceptionState& exceptionState) +PassRefPtrWillBeRawPtr createFragmentForInnerOuterHTML(const String& markup, Element* contextElement, const char* method, ExceptionState& exceptionState) { ASSERT(contextElement); Document& document = isHTMLTemplateElement(*contextElement) ? contextElement->document().ensureTemplateDocument() : contextElement->document(); RefPtrWillBeRawPtr fragment = DocumentFragment::create(document); - fragment->parseHTML(markup, contextElement, parserContentPolicy); + fragment->parseHTML(markup, contextElement); return fragment; } diff --git a/engine/core/editing/markup.h b/engine/core/editing/markup.h index 999f2f24dc2f58ff91b773fe729a6cae97f2516b..a6efe1057339bcfba78086d57705a854cbe5d917 100644 --- a/engine/core/editing/markup.h +++ b/engine/core/editing/markup.h @@ -26,7 +26,6 @@ #ifndef markup_h #define markup_h -#include "core/dom/ParserContentPolicy.h" #include "core/editing/HTMLInterchange.h" #include "platform/heap/Handle.h" #include "wtf/Forward.h" @@ -47,8 +46,8 @@ class Range; enum EChildrenOnly { IncludeNode, ChildrenOnly }; enum EAbsoluteURLs { DoNotResolveURLs, ResolveAllURLs, ResolveNonLocalURLs }; -PassRefPtrWillBeRawPtr createFragmentFromMarkup(Document&, const String& markup, ParserContentPolicy = AllowScriptingContent); -PassRefPtrWillBeRawPtr createFragmentForInnerOuterHTML(const String&, Element*, ParserContentPolicy, const char* method, ExceptionState&); +PassRefPtrWillBeRawPtr createFragmentFromMarkup(Document&, const String& markup); +PassRefPtrWillBeRawPtr createFragmentForInnerOuterHTML(const String&, Element*, const char* method, ExceptionState&); // These methods are used by HTMLElement & ShadowRoot to replace the // children with respected fragment/text. diff --git a/engine/core/html/parser/HTMLConstructionSite.cpp b/engine/core/html/parser/HTMLConstructionSite.cpp index 882ebcee9437744ed9f28e375187a46fb462bfaa..ecf0785589380874a461587ea38ee751147d083f 100644 --- a/engine/core/html/parser/HTMLConstructionSite.cpp +++ b/engine/core/html/parser/HTMLConstructionSite.cpp @@ -46,10 +46,9 @@ namespace blink { static const unsigned maximumHTMLParserDOMTreeDepth = 512; -static inline void setAttributes(Element* element, AtomicHTMLToken* token, ParserContentPolicy parserContentPolicy) +static inline void setAttributes(Element* element, AtomicHTMLToken* token) { - if (!scriptingContentIsAllowed(parserContentPolicy)) - element->stripScriptingAttributes(token->attributes()); + element->stripScriptingAttributes(token->attributes()); element->parserSetAttributes(token->attributes()); } @@ -211,8 +210,6 @@ void HTMLConstructionSite::queueTask(const HTMLConstructionSiteTask& task) void HTMLConstructionSite::attachLater(ContainerNode* parent, PassRefPtrWillBeRawPtr prpChild, bool selfClosing) { - ASSERT(scriptingContentIsAllowed(m_parserContentPolicy) || !prpChild.get()->isElementNode()); - HTMLConstructionSiteTask task(HTMLConstructionSiteTask::Insert); task.parent = parent; task.child = prpChild; @@ -245,17 +242,15 @@ void HTMLConstructionSite::executeQueuedTasks() // We might be detached now. } -HTMLConstructionSite::HTMLConstructionSite(Document* document, ParserContentPolicy parserContentPolicy) +HTMLConstructionSite::HTMLConstructionSite(Document* document) : m_document(document) , m_attachmentRoot(document) - , m_parserContentPolicy(parserContentPolicy) { } -HTMLConstructionSite::HTMLConstructionSite(DocumentFragment* fragment, ParserContentPolicy parserContentPolicy) +HTMLConstructionSite::HTMLConstructionSite(DocumentFragment* fragment) : m_document(&fragment->document()) , m_attachmentRoot(fragment) - , m_parserContentPolicy(parserContentPolicy) { } @@ -322,9 +317,8 @@ void HTMLConstructionSite::insertSelfClosingHTMLElement(AtomicHTMLToken* token) void HTMLConstructionSite::insertScriptElement(AtomicHTMLToken* token) { RefPtrWillBeRawPtr element = HTMLScriptElement::create(ownerDocumentForCurrentNode()); - setAttributes(element.get(), token, m_parserContentPolicy); - if (scriptingContentIsAllowed(m_parserContentPolicy)) - attachLater(currentNode(), element); + setAttributes(element.get(), token); + attachLater(currentNode(), element); m_openElements.push(element.release()); } @@ -349,7 +343,7 @@ PassRefPtrWillBeRawPtr HTMLConstructionSite::createElement(AtomicHTMLTo { QualifiedName tagName(token->name()); RefPtrWillBeRawPtr element = ownerDocumentForCurrentNode().createElement(tagName, true); - setAttributes(element.get(), token, m_parserContentPolicy); + setAttributes(element.get(), token); return element.release(); } @@ -364,7 +358,7 @@ PassRefPtrWillBeRawPtr HTMLConstructionSite::createHTMLElement(Atom { Document& document = ownerDocumentForCurrentNode(); RefPtrWillBeRawPtr element = HTMLElementFactory::createHTMLElement(token->name(), document, true); - setAttributes(element.get(), token, m_parserContentPolicy); + setAttributes(element.get(), token); return element.release(); } diff --git a/engine/core/html/parser/HTMLConstructionSite.h b/engine/core/html/parser/HTMLConstructionSite.h index c2ae7ec44869a5c7ed25cd854178ced235d6b0f4..fdd81525df229110d47309ade626f89db3dd75b1 100644 --- a/engine/core/html/parser/HTMLConstructionSite.h +++ b/engine/core/html/parser/HTMLConstructionSite.h @@ -28,7 +28,6 @@ #define HTMLConstructionSite_h #include "core/dom/Document.h" -#include "core/dom/ParserContentPolicy.h" #include "core/html/parser/HTMLElementStack.h" #include "wtf/Noncopyable.h" #include "wtf/PassRefPtr.h" @@ -88,8 +87,8 @@ class HTMLConstructionSite FINAL { WTF_MAKE_NONCOPYABLE(HTMLConstructionSite); DISALLOW_ALLOCATION(); public: - HTMLConstructionSite(Document*, ParserContentPolicy); - HTMLConstructionSite(DocumentFragment*, ParserContentPolicy); + explicit HTMLConstructionSite(Document*); + explicit HTMLConstructionSite(DocumentFragment*); ~HTMLConstructionSite(); void trace(Visitor*); @@ -131,8 +130,6 @@ public: Document& ownerDocumentForCurrentNode(); HTMLElementStack* openElements() const { return &m_openElements; } - ParserContentPolicy parserContentPolicy() { return m_parserContentPolicy; } - private: // In the common case, this queue will have only one task because most // tokens produce only one DOM mutation. @@ -206,8 +203,6 @@ private: }; PendingText m_pendingText; - - ParserContentPolicy m_parserContentPolicy; }; } // namespace blink diff --git a/engine/core/html/parser/HTMLDocumentParser.cpp b/engine/core/html/parser/HTMLDocumentParser.cpp index ba515826cf984109e57e1d5af2f69f0238aad4a6..c0d782815622efa576f8b100f7f835e6b06601ca 100644 --- a/engine/core/html/parser/HTMLDocumentParser.cpp +++ b/engine/core/html/parser/HTMLDocumentParser.cpp @@ -63,11 +63,11 @@ static HTMLTokenizer::State tokenizerStateForContextElement(Element* contextElem } HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document, bool reportErrors) - : ScriptableDocumentParser(document) + : DecodedDataDocumentParser(document) , m_options(&document) , m_token(m_options.useThreading ? nullptr : adoptPtr(new HTMLToken)) , m_tokenizer(m_options.useThreading ? nullptr : HTMLTokenizer::create(m_options)) - , m_treeBuilder(HTMLTreeBuilder::create(this, &document, parserContentPolicy(), reportErrors, m_options)) + , m_treeBuilder(HTMLTreeBuilder::create(this, &document, reportErrors, m_options)) , m_parserScheduler(HTMLParserScheduler::create(this)) , m_weakFactory(this) , m_isFragment(false) @@ -80,12 +80,12 @@ HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document, bool reportErrors // FIXME: Member variables should be grouped into self-initializing structs to // minimize code duplication between these constructors. -HTMLDocumentParser::HTMLDocumentParser(DocumentFragment* fragment, Element* contextElement, ParserContentPolicy parserContentPolicy) - : ScriptableDocumentParser(fragment->document(), parserContentPolicy) +HTMLDocumentParser::HTMLDocumentParser(DocumentFragment* fragment, Element* contextElement) + : DecodedDataDocumentParser(fragment->document()) , m_options(&fragment->document()) , m_token(adoptPtr(new HTMLToken)) , m_tokenizer(HTMLTokenizer::create(m_options)) - , m_treeBuilder(HTMLTreeBuilder::create(this, fragment, contextElement, this->parserContentPolicy(), m_options)) + , m_treeBuilder(HTMLTreeBuilder::create(this, fragment, contextElement, m_options)) , m_weakFactory(this) , m_isFragment(true) , m_endWasDelayed(false) @@ -117,7 +117,7 @@ HTMLDocumentParser::~HTMLDocumentParser() void HTMLDocumentParser::trace(Visitor* visitor) { visitor->trace(m_treeBuilder); - ScriptableDocumentParser::trace(visitor); + DecodedDataDocumentParser::trace(visitor); } void HTMLDocumentParser::detach() @@ -228,7 +228,6 @@ void HTMLDocumentParser::resumeParsingAfterYield() void HTMLDocumentParser::runScriptsForPausedTreeBuilder() { - ASSERT(scriptingContentIsAllowed(parserContentPolicy())); if (m_isFragment) return; TextPosition scriptStartPosition = TextPosition::belowRangePosition(); @@ -703,9 +702,9 @@ void HTMLDocumentParser::executeScriptsWaitingForResources() resumeParsingAfterScriptExecution(); } -void HTMLDocumentParser::parseDocumentFragment(const String& source, DocumentFragment* fragment, Element* contextElement, ParserContentPolicy parserContentPolicy) +void HTMLDocumentParser::parseDocumentFragment(const String& source, DocumentFragment* fragment, Element* contextElement) { - RefPtrWillBeRawPtr parser = HTMLDocumentParser::create(fragment, contextElement, parserContentPolicy); + RefPtrWillBeRawPtr parser = HTMLDocumentParser::create(fragment, contextElement); parser->insert(source); // Use insert() so that the parser will not yield. parser->finish(); ASSERT(!parser->processingData()); // Make sure we're done. diff --git a/engine/core/html/parser/HTMLDocumentParser.h b/engine/core/html/parser/HTMLDocumentParser.h index 2d996c7dffec98d440afd1255b64e759e32fd987..e6c37742ae062eb6dbe7bcad287cf796c1336281 100644 --- a/engine/core/html/parser/HTMLDocumentParser.h +++ b/engine/core/html/parser/HTMLDocumentParser.h @@ -27,8 +27,7 @@ #define HTMLDocumentParser_h #include "base/memory/weak_ptr.h" -#include "core/dom/ParserContentPolicy.h" -#include "core/dom/ScriptableDocumentParser.h" +#include "core/dom/DecodedDataDocumentParser.h" #include "core/fetch/ResourceClient.h" #include "core/frame/UseCounter.h" #include "core/html/parser/CompactHTMLToken.h" @@ -59,7 +58,7 @@ class ScriptSourceCode; class PumpSession; -class HTMLDocumentParser : public ScriptableDocumentParser { +class HTMLDocumentParser : public DecodedDataDocumentParser { WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLDocumentParser); public: @@ -73,12 +72,12 @@ public: // Exposed for HTMLParserScheduler void resumeParsingAfterYield(); - static void parseDocumentFragment(const String&, DocumentFragment*, Element* contextElement, ParserContentPolicy = AllowScriptingContent); + static void parseDocumentFragment(const String&, DocumentFragment*, Element* contextElement); HTMLTokenizer* tokenizer() const { return m_tokenizer.get(); } - virtual TextPosition textPosition() const OVERRIDE FINAL; - virtual OrdinalNumber lineNumber() const OVERRIDE FINAL; + TextPosition textPosition() const; + OrdinalNumber lineNumber() const; struct ParsedChunk { OwnPtr tokens; @@ -88,6 +87,10 @@ public: virtual void appendBytes(const char* bytes, size_t length) OVERRIDE; virtual void flush() OVERRIDE FINAL; + bool isWaitingForScripts() const; + bool isExecutingScript() const; + void executeScriptsWaitingForResources(); + UseCounter* useCounter() { return UseCounter::getFrom(contextForParsingSession()); } protected: @@ -96,25 +99,24 @@ protected: virtual void finish() OVERRIDE FINAL; HTMLDocumentParser(HTMLDocument&, bool reportErrors); - HTMLDocumentParser(DocumentFragment*, Element* contextElement, ParserContentPolicy); + HTMLDocumentParser(DocumentFragment*, Element* contextElement); HTMLTreeBuilder* treeBuilder() const { return m_treeBuilder.get(); } private: - static PassRefPtrWillBeRawPtr create(DocumentFragment* fragment, Element* contextElement, ParserContentPolicy parserContentPolicy) + static PassRefPtrWillBeRawPtr create(DocumentFragment* fragment, Element* contextElement) { - return adoptRefWillBeNoop(new HTMLDocumentParser(fragment, contextElement, parserContentPolicy)); + return adoptRefWillBeNoop(new HTMLDocumentParser(fragment, contextElement)); } + virtual HTMLDocumentParser* asHTMLDocumentParser() OVERRIDE FINAL { return this; } + // DocumentParser virtual void detach() OVERRIDE FINAL; virtual bool hasInsertionPoint() OVERRIDE FINAL; virtual bool processingData() const OVERRIDE FINAL; virtual void prepareToStopParsing() OVERRIDE FINAL; virtual void stopParsing() OVERRIDE FINAL; - virtual bool isWaitingForScripts() const OVERRIDE FINAL; - virtual bool isExecutingScript() const OVERRIDE FINAL; - virtual void executeScriptsWaitingForResources() OVERRIDE FINAL; void startBackgroundParser(); void stopBackgroundParser(); diff --git a/engine/core/html/parser/HTMLTreeBuilder.cpp b/engine/core/html/parser/HTMLTreeBuilder.cpp index b654d24b19fadd26a4189d45cf41e50df81c2534..a5e7ff64c17305d60f64f901f9e7f121c0812395 100644 --- a/engine/core/html/parser/HTMLTreeBuilder.cpp +++ b/engine/core/html/parser/HTMLTreeBuilder.cpp @@ -45,12 +45,12 @@ static TextPosition uninitializedPositionValue1() return TextPosition(OrdinalNumber::fromOneBasedInt(-1), OrdinalNumber::first()); } -HTMLTreeBuilder::HTMLTreeBuilder(HTMLDocumentParser* parser, HTMLDocument* document, ParserContentPolicy parserContentPolicy, bool, const HTMLParserOptions& options) +HTMLTreeBuilder::HTMLTreeBuilder(HTMLDocumentParser* parser, HTMLDocument* document, bool, const HTMLParserOptions& options) : #if ENABLE(ASSERT) m_isAttached(true), #endif - m_tree(document, parserContentPolicy) + m_tree(document) , m_insertionMode(HTMLMode) , m_originalInsertionMode(HTMLMode) , m_parser(parser) @@ -62,13 +62,13 @@ HTMLTreeBuilder::HTMLTreeBuilder(HTMLDocumentParser* parser, HTMLDocument* docum // FIXME: Member variables should be grouped into self-initializing structs to // minimize code duplication between these constructors. -HTMLTreeBuilder::HTMLTreeBuilder(HTMLDocumentParser* parser, DocumentFragment* fragment, Element* contextElement, ParserContentPolicy parserContentPolicy, const HTMLParserOptions& options) +HTMLTreeBuilder::HTMLTreeBuilder(HTMLDocumentParser* parser, DocumentFragment* fragment, Element* contextElement, const HTMLParserOptions& options) : #if ENABLE(ASSERT) m_isAttached(true), #endif m_fragmentContext(fragment, contextElement) - , m_tree(fragment, parserContentPolicy) + , m_tree(fragment) , m_insertionMode(HTMLMode) , m_originalInsertionMode(HTMLMode) , m_parser(parser) @@ -209,8 +209,7 @@ void HTMLTreeBuilder::processEndTag(AtomicHTMLToken* token) if (token->name() == HTMLNames::scriptTag) { // Pause ourselves so that parsing stops until the script can be processed by the caller. ASSERT(m_tree.currentElement()->hasLocalName(HTMLNames::scriptTag.localName())); - if (scriptingContentIsAllowed(m_tree.parserContentPolicy())) - m_scriptToProcess = m_tree.currentElement(); + m_scriptToProcess = m_tree.currentElement(); m_tree.openElements()->pop(); setInsertionMode(m_originalInsertionMode); diff --git a/engine/core/html/parser/HTMLTreeBuilder.h b/engine/core/html/parser/HTMLTreeBuilder.h index 82fa0931558c0ebbfb4545f953c7500a009e91fa..c0d3c1707fdd2e2241c775590b62530bfa0ef8c0 100644 --- a/engine/core/html/parser/HTMLTreeBuilder.h +++ b/engine/core/html/parser/HTMLTreeBuilder.h @@ -54,13 +54,13 @@ class HTMLDocumentParser; class HTMLTreeBuilder FINAL : public NoBaseWillBeGarbageCollectedFinalized { WTF_MAKE_NONCOPYABLE(HTMLTreeBuilder); WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; public: - static PassOwnPtrWillBeRawPtr create(HTMLDocumentParser* parser, HTMLDocument* document, ParserContentPolicy parserContentPolicy, bool reportErrors, const HTMLParserOptions& options) + static PassOwnPtrWillBeRawPtr create(HTMLDocumentParser* parser, HTMLDocument* document, bool reportErrors, const HTMLParserOptions& options) { - return adoptPtrWillBeNoop(new HTMLTreeBuilder(parser, document, parserContentPolicy, reportErrors, options)); + return adoptPtrWillBeNoop(new HTMLTreeBuilder(parser, document, reportErrors, options)); } - static PassOwnPtrWillBeRawPtr create(HTMLDocumentParser* parser, DocumentFragment* fragment, Element* contextElement, ParserContentPolicy parserContentPolicy, const HTMLParserOptions& options) + static PassOwnPtrWillBeRawPtr create(HTMLDocumentParser* parser, DocumentFragment* fragment, Element* contextElement, const HTMLParserOptions& options) { - return adoptPtrWillBeNoop(new HTMLTreeBuilder(parser, fragment, contextElement, parserContentPolicy, options)); + return adoptPtrWillBeNoop(new HTMLTreeBuilder(parser, fragment, contextElement, options)); } ~HTMLTreeBuilder(); void trace(Visitor*); @@ -92,8 +92,8 @@ private: TextMode, }; - HTMLTreeBuilder(HTMLDocumentParser*, HTMLDocument*, ParserContentPolicy, bool reportErrors, const HTMLParserOptions&); - HTMLTreeBuilder(HTMLDocumentParser*, DocumentFragment*, Element* contextElement, ParserContentPolicy, const HTMLParserOptions&); + HTMLTreeBuilder(HTMLDocumentParser*, HTMLDocument*, bool reportErrors, const HTMLParserOptions&); + HTMLTreeBuilder(HTMLDocumentParser*, DocumentFragment*, Element* contextElement, const HTMLParserOptions&); void processStartTag(AtomicHTMLToken*); void processEndTag(AtomicHTMLToken*); diff --git a/engine/core/loader/DocumentWriter.cpp b/engine/core/loader/DocumentWriter.cpp index fb970709d61e4b158480bde591ddb5be09b8b96e..eca812c64569c045a24fd0cdfa2ee135fc525d66 100644 --- a/engine/core/loader/DocumentWriter.cpp +++ b/engine/core/loader/DocumentWriter.cpp @@ -30,7 +30,7 @@ #include "core/loader/DocumentWriter.h" #include "core/dom/Document.h" -#include "core/dom/ScriptableDocumentParser.h" +#include "core/dom/DocumentParser.h" #include "core/frame/LocalFrame.h" namespace blink {