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

Unified Diff: third_party/WebKit/Source/core/dom/PendingScript.cpp

Issue 2723793002: De-Element ScriptLoader (Closed)
Patch Set: ScriptLoaderClient->ScriptElementBase, pure virtual interface, add fixme 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/PendingScript.cpp
diff --git a/third_party/WebKit/Source/core/dom/PendingScript.cpp b/third_party/WebKit/Source/core/dom/PendingScript.cpp
index 7ea074252620e6ed402a035c3bbe8bfceba0d48e..cc9974af2c585c3a7d08d681dfc91bfa2e72994b 100644
--- a/third_party/WebKit/Source/core/dom/PendingScript.cpp
+++ b/third_party/WebKit/Source/core/dom/PendingScript.cpp
@@ -26,19 +26,19 @@
#include "core/dom/PendingScript.h"
#include "bindings/core/v8/ScriptSourceCode.h"
-#include "core/dom/Element.h"
+#include "core/dom/ScriptElementBase.h"
#include "core/frame/SubresourceIntegrity.h"
#include "platform/SharedBuffer.h"
#include "wtf/CurrentTime.h"
namespace blink {
-PendingScript* PendingScript::create(Element* element,
+PendingScript* PendingScript::create(ScriptElementBase* element,
ScriptResource* resource) {
return new PendingScript(element, resource, TextPosition());
}
-PendingScript* PendingScript::create(Element* element,
+PendingScript* PendingScript::create(ScriptElementBase* element,
const TextPosition& startingPosition) {
return new PendingScript(element, nullptr, startingPosition);
}
@@ -47,7 +47,7 @@ PendingScript* PendingScript::createForTesting(ScriptResource* resource) {
return new PendingScript(nullptr, resource, TextPosition(), true);
}
-PendingScript::PendingScript(Element* element,
+PendingScript::PendingScript(ScriptElementBase* element,
ScriptResource* resource,
const TextPosition& startingPosition,
bool isForTesting)
@@ -111,9 +111,10 @@ void PendingScript::stopWatchingForLoad() {
m_watchingForLoad = false;
}
-Element* PendingScript::element() const {
- // As mentioned in the comment at |m_element| declaration, |m_element|
- // must points to the corresponding ScriptLoader's element.
+ScriptElementBase* PendingScript::element() const {
+ // As mentioned in the comment at |m_element| declaration,
+ // |m_element| must point to the corresponding ScriptLoader's
+ // client.
CHECK(m_element);
return m_element.get();
}
@@ -131,10 +132,11 @@ void PendingScript::markParserBlockingLoadStartTime() {
}
// Returns true if SRI check passed.
-static bool checkScriptResourceIntegrity(Resource* resource, Element* element) {
+static bool checkScriptResourceIntegrity(Resource* resource,
+ ScriptElementBase* element) {
DCHECK_EQ(resource->getType(), Resource::Script);
ScriptResource* scriptResource = toScriptResource(resource);
- String integrityAttr = element->fastGetAttribute(HTMLNames::integrityAttr);
+ String integrityAttr = element->integrityAttributeValue();
// It is possible to get back a script resource with integrity metadata
// for a request with an empty integrity attribute. In that case, the
@@ -159,7 +161,7 @@ static bool checkScriptResourceIntegrity(Resource* resource, Element* element) {
return true;
bool passed = SubresourceIntegrity::CheckSubresourceIntegrity(
- scriptResource->integrityMetadata(), *element,
+ scriptResource->integrityMetadata(), element->document(),
resource->resourceBuffer()->data(),
resource->resourceBuffer()->size(), resource->url(), *resource);
scriptResource->setIntegrityDisposition(
@@ -197,8 +199,9 @@ void PendingScript::notifyFinished(Resource* resource) {
//
// See https://crbug.com/500701 for more information.
checkState();
- if (m_element)
+ if (m_element) {
m_integrityFailure = !checkScriptResourceIntegrity(resource, m_element);
+ }
// If script streaming is in use, the client will be notified in
// streamingFinished.
« no previous file with comments | « third_party/WebKit/Source/core/dom/PendingScript.h ('k') | third_party/WebKit/Source/core/dom/ScriptElementBase.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698