Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2723793002: De-Element ScriptLoader (Closed)
Patch Set: Address comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All
7 * rights reserved. 7 * rights reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
(...skipping 5111 matching lines...) Expand 10 before | Expand all | Expand 10 after
5122 UseCounter::count(*this, osdDisposition); 5122 UseCounter::count(*this, osdDisposition);
5123 5123
5124 return linkElement->href(); 5124 return linkElement->href();
5125 } 5125 }
5126 5126
5127 return KURL(); 5127 return KURL();
5128 } 5128 }
5129 5129
5130 void Document::currentScriptForBinding( 5130 void Document::currentScriptForBinding(
5131 HTMLScriptElementOrSVGScriptElement& scriptElement) const { 5131 HTMLScriptElementOrSVGScriptElement& scriptElement) const {
5132 if (Element* script = currentScript()) { 5132 if (!m_currentScriptStack.isEmpty())
5133 if (script->isInV1ShadowTree()) 5133 m_currentScriptStack.back()->setScriptElementForBinding(scriptElement);
5134 return;
5135 if (isHTMLScriptElement(script))
5136 scriptElement.setHTMLScriptElement(toHTMLScriptElement(script));
5137 else if (isSVGScriptElement(script))
5138 scriptElement.setSVGScriptElement(toSVGScriptElement(script));
5139 }
5140 } 5134 }
5141 5135
5142 void Document::pushCurrentScript(Element* newCurrentScript) { 5136 void Document::pushCurrentScript(ScriptLoaderClient* newCurrentScript) {
5143 DCHECK(isHTMLScriptElement(newCurrentScript) ||
5144 isSVGScriptElement(newCurrentScript));
5145 m_currentScriptStack.push_back(newCurrentScript); 5137 m_currentScriptStack.push_back(newCurrentScript);
5146 } 5138 }
5147 5139
5148 void Document::popCurrentScript() { 5140 void Document::popCurrentScript(ScriptLoaderClient* script) {
5149 DCHECK(!m_currentScriptStack.isEmpty()); 5141 DCHECK(!m_currentScriptStack.isEmpty());
5142 DCHECK_EQ(m_currentScriptStack.back(), script);
5150 m_currentScriptStack.pop_back(); 5143 m_currentScriptStack.pop_back();
5151 } 5144 }
5152 5145
5153 void Document::setTransformSource(std::unique_ptr<TransformSource> source) { 5146 void Document::setTransformSource(std::unique_ptr<TransformSource> source) {
5154 m_transformSource = std::move(source); 5147 m_transformSource = std::move(source);
5155 } 5148 }
5156 5149
5157 String Document::designMode() const { 5150 String Document::designMode() const {
5158 return inDesignMode() ? "on" : "off"; 5151 return inDesignMode() ? "on" : "off";
5159 } 5152 }
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
5666 if (!contextDocument()->canExecuteScripts(NotAboutToExecuteScript)) 5659 if (!contextDocument()->canExecuteScripts(NotAboutToExecuteScript))
5667 return false; 5660 return false;
5668 if (node && node->document() != this && 5661 if (node && node->document() != this &&
5669 !node->document().allowInlineEventHandler(node, listener, contextURL, 5662 !node->document().allowInlineEventHandler(node, listener, contextURL,
5670 contextLine)) 5663 contextLine))
5671 return false; 5664 return false;
5672 5665
5673 return true; 5666 return true;
5674 } 5667 }
5675 5668
5676 bool Document::allowExecutingScripts(Node* node) {
5677 // FIXME: Eventually we'd like to evaluate scripts which are inserted into a
5678 // viewless document but this'll do for now.
5679 // See http://bugs.webkit.org/show_bug.cgi?id=5727
5680 LocalFrame* frame = executingFrame();
5681 if (!frame)
5682 return false;
5683 if (!node->document().executingFrame())
5684 return false;
5685 if (!canExecuteScripts(AboutToExecuteScript))
5686 return false;
5687 return true;
5688 }
5689
5690 void Document::enforceSandboxFlags(SandboxFlags mask) { 5669 void Document::enforceSandboxFlags(SandboxFlags mask) {
5691 RefPtr<SecurityOrigin> standInOrigin = getSecurityOrigin(); 5670 RefPtr<SecurityOrigin> standInOrigin = getSecurityOrigin();
5692 applySandboxFlags(mask); 5671 applySandboxFlags(mask);
5693 // Send a notification if the origin has been updated. 5672 // Send a notification if the origin has been updated.
5694 if (standInOrigin && !standInOrigin->isUnique() && 5673 if (standInOrigin && !standInOrigin->isUnique() &&
5695 getSecurityOrigin()->isUnique()) { 5674 getSecurityOrigin()->isUnique()) {
5696 getSecurityOrigin()->setUniqueOriginIsPotentiallyTrustworthy( 5675 getSecurityOrigin()->setUniqueOriginIsPotentiallyTrustworthy(
5697 standInOrigin->isPotentiallyTrustworthy()); 5676 standInOrigin->isPotentiallyTrustworthy());
5698 if (frame()) 5677 if (frame())
5699 frame()->loader().client()->didUpdateToUniqueOrigin(); 5678 frame()->loader().client()->didUpdateToUniqueOrigin();
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
6661 } 6640 }
6662 6641
6663 void showLiveDocumentInstances() { 6642 void showLiveDocumentInstances() {
6664 WeakDocumentSet& set = liveDocumentSet(); 6643 WeakDocumentSet& set = liveDocumentSet();
6665 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6644 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6666 for (blink::Document* document : set) 6645 for (blink::Document* document : set)
6667 fprintf(stderr, "- Document %p URL: %s\n", document, 6646 fprintf(stderr, "- Document %p URL: %s\n", document,
6668 document->url().getString().utf8().data()); 6647 document->url().getString().utf8().data());
6669 } 6648 }
6670 #endif 6649 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698