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

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

Issue 2693423002: Do not re-initialize PendingScript in HTMLParserScriptRunner (Closed)
Patch Set: Reflect comments Created 3 years, 10 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 4507e23771232f77eff96ac701cb9f45a30af28f..aef299869c63b959398e518b0f8cf72356f6785e 100644
--- a/third_party/WebKit/Source/core/dom/PendingScript.cpp
+++ b/third_party/WebKit/Source/core/dom/PendingScript.cpp
@@ -35,16 +35,31 @@ namespace blink {
PendingScript* PendingScript::create(Element* element,
ScriptResource* resource) {
- return new PendingScript(element, resource);
+ return new PendingScript(element, resource, TextPosition());
}
-PendingScript::PendingScript(Element* element, ScriptResource* resource)
+PendingScript* PendingScript::create(Element* element,
+ const TextPosition& startingPosition) {
+ return new PendingScript(element, nullptr, startingPosition);
+}
+
+PendingScript* PendingScript::createForTesting(ScriptResource* resource) {
+ return new PendingScript(nullptr, resource, TextPosition(), true);
+}
+
+PendingScript::PendingScript(Element* element,
+ ScriptResource* resource,
+ const TextPosition& startingPosition,
+ bool isForTesting)
: m_watchingForLoad(false),
m_element(element),
+ m_startingPosition(startingPosition),
m_integrityFailure(false),
m_parserBlockingLoadStartTime(0),
- m_client(nullptr) {
- setScriptResource(resource);
+ m_client(nullptr),
+ m_isForTesting(isForTesting) {
+ CHECK(m_isForTesting || m_element);
+ setResource(resource);
MemoryCoordinator::instance().registerClient(this);
}
@@ -55,7 +70,7 @@ void PendingScript::dispose() {
DCHECK(!m_client);
DCHECK(!m_watchingForLoad);
- setScriptResource(nullptr);
+ setResource(nullptr);
m_startingPosition = TextPosition::belowRangePosition();
m_integrityFailure = false;
m_parserBlockingLoadStartTime = 0;
@@ -86,20 +101,19 @@ 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.
+ CHECK(m_element);
+ return m_element.get();
+}
+
void PendingScript::streamingFinished() {
DCHECK(resource());
if (m_client)
m_client->pendingScriptFinished(this);
}
-void PendingScript::setElement(Element* element) {
- m_element = element;
-}
-
-void PendingScript::setScriptResource(ScriptResource* resource) {
- setResource(resource);
-}
-
void PendingScript::markParserBlockingLoadStartTime() {
DCHECK_EQ(m_parserBlockingLoadStartTime, 0.0);
m_parserBlockingLoadStartTime = monotonicallyIncreasingTime();
@@ -128,6 +142,7 @@ void PendingScript::notifyFinished(Resource* resource) {
// objects (perhaps attached to identical Resource objects) per request.
//
// See https://crbug.com/500701 for more information.
+ CHECK(m_isForTesting || m_element);
if (m_element) {
DCHECK_EQ(resource->getType(), Resource::Script);
ScriptResource* scriptResource = toScriptResource(resource);

Powered by Google App Engine
This is Rietveld 408576698