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..1fa7c088a713a76668a50091385a7a43249745ec 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,17 @@ void PendingScript::stopWatchingForLoad() { |
m_watchingForLoad = false; |
} |
+Element* PendingScript::element() const { |
+ CHECK(m_element); |
sof
2017/02/16 08:15:15
Could you xref the element() declaration's comment
hiroshige
2017/02/17 23:15:15
Done.
|
+ 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 +140,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) { |
sof
2017/02/16 08:15:15
Not part of this CL at all, but moving this SRI-sp
hiroshige
2017/02/17 23:15:15
Created https://codereview.chromium.org/2698613007
|
DCHECK_EQ(resource->getType(), Resource::Script); |
ScriptResource* scriptResource = toScriptResource(resource); |