- Revision
- 205218
- Author
- [email protected]
- Date
- 2016-08-30 19:37:12 -0700 (Tue, 30 Aug 2016)
Log Message
Make PendingScript as ref-counted
https://bugs.webkit.org/show_bug.cgi?id=161350
Reviewed by Ryosuke Niwa.
Currently, while PendingScript is copyable, PendingScript is also CachedResourceClient.
So when copying this, the client registration is done in PendingScript's operator= etc.
However, this copying functionality is not effectively used.
In this patch, we change this PendingScript to ref-counted class and make it noncopyable.
This change makes things simple (dropping this copying functionality), and drops unnecessary
addClient / removeClient calls. And we also simplify PendingScript class. Since we can offer
all the members at the construction time, we do not need any setters like setCachedScript,
setElement etc. This prevents us from accidentally generating the half-baked pending script.
Furthermore, by changing PendingScript noncopyable & ref-counted, we easily make it
observable. In this patch, we add PendingScriptClient to receive the notification from
PendingScript. Previously, we directly used CachedScript in PendingScript to receive the
notification. When introducing ScriptModuleGraph and making this PendingScript the container
of the both CachedScript and ScriptModuleGraph, hiding the raw CachedScript operations is
useful.
No behavior changes.
* WebCore.xcodeproj/project.pbxproj:
* dom/PendingScript.cpp:
(WebCore::PendingScript::create): These factory functions take all the information needed
to construct the PendingScript. So the setters of PendingScript are dropped. This is better
since we now do not expose any half-baked pending script accidentally.
(WebCore::PendingScript::PendingScript):
(WebCore::PendingScript::~PendingScript):
(WebCore::PendingScript::notifyClientFinished):
(WebCore::PendingScript::notifyFinished):
(WebCore::PendingScript::isLoaded): When introducing ScriptModuleGraph, this will query to
either CachedScript or ScriptModuleGraph. PendingScript will become the container for the
both types.
(WebCore::PendingScript::setClient):
(WebCore::PendingScript::clearClient): PendingScript is now observable by PendingScriptClient.
This avoids touching CachedScript in PendingScript directly. That is good when we introduce
ScriptModuleGraph and make PendingScript the container of the both CachedScript and ScriptModuleGraph.
(WebCore::PendingScript::releaseElementAndClear): Deleted. Previously, PendingScript is not ref-counted.
So when we would like to say "this pending script is empty", we used the pending script with
`m_element = nullptr`. This releaseElementAndClear cleared this m_element and made the pending
script empty. Now, we use RefPtr<PendingScript> and empty one is just represented by the nullptr.
This function is no longer necessary. Dropped.
(WebCore::PendingScript::setCachedScript): Deleted. The fields are set in the constructor.
So this setter is no longer necessary. Dropped.
* dom/PendingScript.h:
* dom/PendingScriptClient.h: Copied from Source/WebCore/html/parser/HTMLScriptRunnerHost.h.
(WebCore::PendingScriptClient::~PendingScriptClient):
* dom/ScriptRunner.cpp:
(WebCore::ScriptRunner::queueScriptForExecution):
(WebCore::ScriptRunner::notifyScriptReady):
(WebCore::ScriptRunner::timerFired): We use `std::exchange` to retrieve the RefPtr<PendingScript>
and make the original vector element nullptr. Without this, all the PendingScript is held until
the iteration finishes. We keep the original semantics here that the pending script can be
released per iteration.
* dom/ScriptRunner.h:
* html/parser/HTMLDocumentParser.cpp:
(WebCore::HTMLDocumentParser::watchForLoad):
(WebCore::HTMLDocumentParser::stopWatchingForLoad): Use PendingScript instead of touching
CachedScript directly.
(WebCore::HTMLDocumentParser::notifyFinished):
* html/parser/HTMLDocumentParser.h:
* html/parser/HTMLScriptRunner.cpp:
(WebCore::HTMLScriptRunner::~HTMLScriptRunner):
(WebCore::HTMLScriptRunner::sourceFromPendingScript):
(WebCore::HTMLScriptRunner::isPendingScriptReady):
(WebCore::HTMLScriptRunner::executeParsingBlockingScript):
(WebCore::HTMLScriptRunner::executePendingScriptAndDispatchEvent): As the previous comment describes,
we used releaseElementAndClear to make the current pending script empty. Instead of doing so, we now
explicitly clear executeParsingBlockingScript (by assigning nullptr to m_parserBlockingScript).
(WebCore::HTMLScriptRunner::watchForLoad):
(WebCore::HTMLScriptRunner::stopWatchingForLoad): Previously, we used CachedScript::addClient directly
in the m_host.watchForLoad. This means that we did not have a quick way to query whether the pending
script is watched. In the old implementation, we have the `m_watchingForLoad : bool` flag in PendingScript
to hold the watching status for the given pending script. This `pendingScript.setWatchingForLoad(true)`
just made this flag `true`. But now, we do not use CachedScript::addClient directly. Instead, we have
the PendingScriptClient and PendingScript::{setClient,clearClient}. We can know whether this pending
script is watched by checking `m_client != nullptr`. This makes `m_watchingForLoad` unnecessary.
So this patch drops `m_watchingForLoad` and `pendingScript.setWatchingForLoad(true)` call.
(WebCore::HTMLScriptRunner::hasParserBlockingScript):
(WebCore::HTMLScriptRunner::executeParsingBlockingScripts): We clear the m_parserBlockingScript here
instead of the middle of the executePendingScriptAndDispatchEvent.
(WebCore::HTMLScriptRunner::executeScriptsWaitingForLoad):
(WebCore::HTMLScriptRunner::executeScriptsWaitingForParsing):
(WebCore::requestPendingScript):
(WebCore::HTMLScriptRunner::requestParsingBlockingScript): Setting m_parsingBlockingScript is now done
in this caller side.
(WebCore::HTMLScriptRunner::requestDeferredScript):
(WebCore::HTMLScriptRunner::runScript):
(WebCore::HTMLScriptRunner::requestPendingScript): Instead of configuring the passed PendingScript&,
we return the pending script and the caller sets it to m_parserBlockingScript or holds it. And we now
change this function to static location one and drop the member function. Previously, we always make
PendingScript& valid by always calling `setElement(...)`. I think this is the bug since we accidentally
exposed the half-baked pending script. But this bug is not shown since `!cachedScript` path is dead code!
This requestPendingScript is called from two places, requestDeferredScript and requestParsingBlockingScript.
And these functions are called if the script has `willBeParserExecuted` flag. In the case of the script
tag having "src" attribute, this flag is only set if `cachedScript` is correctly instantiated. So when
these functions are called, we can ensure that `cachedScript` is correctly instantiated for the given script.
In the case of the script tag not having "src" attribute, these functions are won't be called. This is
because if such a script tag has `willBeParserExecuted` flag, it also has `m_readyToBeParserExecuted`
and it does not have `m_willExecuteWhenDocumentFinishedParsing` flag, and in that case the both
functions are never called. So we drop that path and insert the assertion to ensure the above conditions.
* html/parser/HTMLScriptRunner.h:
* html/parser/HTMLScriptRunnerHost.h:
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (205217 => 205218)
--- trunk/Source/WebCore/ChangeLog 2016-08-31 02:01:07 UTC (rev 205217)
+++ trunk/Source/WebCore/ChangeLog 2016-08-31 02:37:12 UTC (rev 205218)
@@ -1,3 +1,111 @@
+2016-08-30 Yusuke Suzuki <[email protected]>
+
+ Make PendingScript as ref-counted
+ https://bugs.webkit.org/show_bug.cgi?id=161350
+
+ Reviewed by Ryosuke Niwa.
+
+ Currently, while PendingScript is copyable, PendingScript is also CachedResourceClient.
+ So when copying this, the client registration is done in PendingScript's operator= etc.
+ However, this copying functionality is not effectively used.
+ In this patch, we change this PendingScript to ref-counted class and make it noncopyable.
+ This change makes things simple (dropping this copying functionality), and drops unnecessary
+ addClient / removeClient calls. And we also simplify PendingScript class. Since we can offer
+ all the members at the construction time, we do not need any setters like setCachedScript,
+ setElement etc. This prevents us from accidentally generating the half-baked pending script.
+
+ Furthermore, by changing PendingScript noncopyable & ref-counted, we easily make it
+ observable. In this patch, we add PendingScriptClient to receive the notification from
+ PendingScript. Previously, we directly used CachedScript in PendingScript to receive the
+ notification. When introducing ScriptModuleGraph and making this PendingScript the container
+ of the both CachedScript and ScriptModuleGraph, hiding the raw CachedScript operations is
+ useful.
+
+ No behavior changes.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * dom/PendingScript.cpp:
+ (WebCore::PendingScript::create): These factory functions take all the information needed
+ to construct the PendingScript. So the setters of PendingScript are dropped. This is better
+ since we now do not expose any half-baked pending script accidentally.
+ (WebCore::PendingScript::PendingScript):
+ (WebCore::PendingScript::~PendingScript):
+ (WebCore::PendingScript::notifyClientFinished):
+ (WebCore::PendingScript::notifyFinished):
+ (WebCore::PendingScript::isLoaded): When introducing ScriptModuleGraph, this will query to
+ either CachedScript or ScriptModuleGraph. PendingScript will become the container for the
+ both types.
+ (WebCore::PendingScript::setClient):
+ (WebCore::PendingScript::clearClient): PendingScript is now observable by PendingScriptClient.
+ This avoids touching CachedScript in PendingScript directly. That is good when we introduce
+ ScriptModuleGraph and make PendingScript the container of the both CachedScript and ScriptModuleGraph.
+ (WebCore::PendingScript::releaseElementAndClear): Deleted. Previously, PendingScript is not ref-counted.
+ So when we would like to say "this pending script is empty", we used the pending script with
+ `m_element = nullptr`. This releaseElementAndClear cleared this m_element and made the pending
+ script empty. Now, we use RefPtr<PendingScript> and empty one is just represented by the nullptr.
+ This function is no longer necessary. Dropped.
+ (WebCore::PendingScript::setCachedScript): Deleted. The fields are set in the constructor.
+ So this setter is no longer necessary. Dropped.
+ * dom/PendingScript.h:
+ * dom/PendingScriptClient.h: Copied from Source/WebCore/html/parser/HTMLScriptRunnerHost.h.
+ (WebCore::PendingScriptClient::~PendingScriptClient):
+ * dom/ScriptRunner.cpp:
+ (WebCore::ScriptRunner::queueScriptForExecution):
+ (WebCore::ScriptRunner::notifyScriptReady):
+ (WebCore::ScriptRunner::timerFired): We use `std::exchange` to retrieve the RefPtr<PendingScript>
+ and make the original vector element nullptr. Without this, all the PendingScript is held until
+ the iteration finishes. We keep the original semantics here that the pending script can be
+ released per iteration.
+ * dom/ScriptRunner.h:
+ * html/parser/HTMLDocumentParser.cpp:
+ (WebCore::HTMLDocumentParser::watchForLoad):
+ (WebCore::HTMLDocumentParser::stopWatchingForLoad): Use PendingScript instead of touching
+ CachedScript directly.
+ (WebCore::HTMLDocumentParser::notifyFinished):
+ * html/parser/HTMLDocumentParser.h:
+ * html/parser/HTMLScriptRunner.cpp:
+ (WebCore::HTMLScriptRunner::~HTMLScriptRunner):
+ (WebCore::HTMLScriptRunner::sourceFromPendingScript):
+ (WebCore::HTMLScriptRunner::isPendingScriptReady):
+ (WebCore::HTMLScriptRunner::executeParsingBlockingScript):
+ (WebCore::HTMLScriptRunner::executePendingScriptAndDispatchEvent): As the previous comment describes,
+ we used releaseElementAndClear to make the current pending script empty. Instead of doing so, we now
+ explicitly clear executeParsingBlockingScript (by assigning nullptr to m_parserBlockingScript).
+ (WebCore::HTMLScriptRunner::watchForLoad):
+ (WebCore::HTMLScriptRunner::stopWatchingForLoad): Previously, we used CachedScript::addClient directly
+ in the m_host.watchForLoad. This means that we did not have a quick way to query whether the pending
+ script is watched. In the old implementation, we have the `m_watchingForLoad : bool` flag in PendingScript
+ to hold the watching status for the given pending script. This `pendingScript.setWatchingForLoad(true)`
+ just made this flag `true`. But now, we do not use CachedScript::addClient directly. Instead, we have
+ the PendingScriptClient and PendingScript::{setClient,clearClient}. We can know whether this pending
+ script is watched by checking `m_client != nullptr`. This makes `m_watchingForLoad` unnecessary.
+ So this patch drops `m_watchingForLoad` and `pendingScript.setWatchingForLoad(true)` call.
+ (WebCore::HTMLScriptRunner::hasParserBlockingScript):
+ (WebCore::HTMLScriptRunner::executeParsingBlockingScripts): We clear the m_parserBlockingScript here
+ instead of the middle of the executePendingScriptAndDispatchEvent.
+ (WebCore::HTMLScriptRunner::executeScriptsWaitingForLoad):
+ (WebCore::HTMLScriptRunner::executeScriptsWaitingForParsing):
+ (WebCore::requestPendingScript):
+ (WebCore::HTMLScriptRunner::requestParsingBlockingScript): Setting m_parsingBlockingScript is now done
+ in this caller side.
+ (WebCore::HTMLScriptRunner::requestDeferredScript):
+ (WebCore::HTMLScriptRunner::runScript):
+ (WebCore::HTMLScriptRunner::requestPendingScript): Instead of configuring the passed PendingScript&,
+ we return the pending script and the caller sets it to m_parserBlockingScript or holds it. And we now
+ change this function to static location one and drop the member function. Previously, we always make
+ PendingScript& valid by always calling `setElement(...)`. I think this is the bug since we accidentally
+ exposed the half-baked pending script. But this bug is not shown since `!cachedScript` path is dead code!
+ This requestPendingScript is called from two places, requestDeferredScript and requestParsingBlockingScript.
+ And these functions are called if the script has `willBeParserExecuted` flag. In the case of the script
+ tag having "src" attribute, this flag is only set if `cachedScript` is correctly instantiated. So when
+ these functions are called, we can ensure that `cachedScript` is correctly instantiated for the given script.
+ In the case of the script tag not having "src" attribute, these functions are won't be called. This is
+ because if such a script tag has `willBeParserExecuted` flag, it also has `m_readyToBeParserExecuted`
+ and it does not have `m_willExecuteWhenDocumentFinishedParsing` flag, and in that case the both
+ functions are never called. So we drop that path and insert the assertion to ensure the above conditions.
+ * html/parser/HTMLScriptRunner.h:
+ * html/parser/HTMLScriptRunnerHost.h:
+
2016-08-30 Ricky Mondello <[email protected]>
"pluginReplacementEnabled" should be a Setting, not a RuntimeEnabledFeature
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (205217 => 205218)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-08-31 02:01:07 UTC (rev 205217)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-08-31 02:37:12 UTC (rev 205218)
@@ -6091,6 +6091,7 @@
E1FF8F6D180DB5BE00132674 /* CryptoAlgorithmRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FF8F6B180DB5BE00132674 /* CryptoAlgorithmRegistry.h */; };
E38838981BAD145F00D62EE3 /* JSModuleLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38838941BAD145F00D62EE3 /* JSModuleLoader.cpp */; };
E38838991BAD145F00D62EE3 /* JSModuleLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = E38838951BAD145F00D62EE3 /* JSModuleLoader.h */; };
+ E3FA38641D71812D00AA5950 /* PendingScriptClient.h in Headers */ = {isa = PBXBuildFile; fileRef = E3FA38611D716E7600AA5950 /* PendingScriptClient.h */; };
E401C27517CE53EC00C41A35 /* ElementIteratorAssertions.h in Headers */ = {isa = PBXBuildFile; fileRef = E401C27417CE53EC00C41A35 /* ElementIteratorAssertions.h */; settings = {ATTRIBUTES = (Private, ); }; };
E401E0A41C3C0B8300F34D10 /* StyleChange.h in Headers */ = {isa = PBXBuildFile; fileRef = E401E0A31C3C0B8300F34D10 /* StyleChange.h */; settings = {ATTRIBUTES = (Private, ); }; };
E401E0A61C3C0CF700F34D10 /* StyleChange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E401E0A51C3C0CF700F34D10 /* StyleChange.cpp */; };
@@ -13657,6 +13658,7 @@
E1FF8F6B180DB5BE00132674 /* CryptoAlgorithmRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmRegistry.h; sourceTree = "<group>"; };
E38838941BAD145F00D62EE3 /* JSModuleLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSModuleLoader.cpp; sourceTree = "<group>"; };
E38838951BAD145F00D62EE3 /* JSModuleLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSModuleLoader.h; sourceTree = "<group>"; };
+ E3FA38611D716E7600AA5950 /* PendingScriptClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PendingScriptClient.h; sourceTree = "<group>"; };
E401C27417CE53EC00C41A35 /* ElementIteratorAssertions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementIteratorAssertions.h; sourceTree = "<group>"; };
E401E0A31C3C0B8300F34D10 /* StyleChange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleChange.h; sourceTree = "<group>"; };
E401E0A51C3C0CF700F34D10 /* StyleChange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleChange.cpp; sourceTree = "<group>"; };
@@ -23080,6 +23082,7 @@
83D26D3D1AFDCC50001B3873 /* ParentNode.idl */,
8A7CC96F12076F8A001D4588 /* PendingScript.cpp */,
8A7CC96A12076D73001D4588 /* PendingScript.h */,
+ E3FA38611D716E7600AA5950 /* PendingScriptClient.h */,
41BF700D0FE86F61005E8DEC /* PlatformMessagePortChannel.cpp */,
41BF700E0FE86F61005E8DEC /* PlatformMessagePortChannel.h */,
5189F0DD10B46B0E00F3C739 /* PopStateEvent.cpp */,
@@ -27056,6 +27059,7 @@
59C28046138DC2410079B7E2 /* XMLErrors.h in Headers */,
BC772C470C4EB2C60083285F /* XMLHttpRequest.h in Headers */,
83D35AEC1C7187FA00F70D5A /* XMLHttpRequestEventTarget.h in Headers */,
+ E3FA38641D71812D00AA5950 /* PendingScriptClient.h in Headers */,
F9F0ED7A0DB50CA200D16DB9 /* XMLHttpRequestProgressEvent.h in Headers */,
A136A00D1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.h in Headers */,
BCDFD48E0E305290009D10AD /* XMLHttpRequestUpload.h in Headers */,
Modified: trunk/Source/WebCore/dom/PendingScript.cpp (205217 => 205218)
--- trunk/Source/WebCore/dom/PendingScript.cpp 2016-08-31 02:01:07 UTC (rev 205217)
+++ trunk/Source/WebCore/dom/PendingScript.cpp 2016-08-31 02:37:12 UTC (rev 205218)
@@ -28,32 +28,38 @@
#include "CachedScript.h"
#include "Element.h"
+#include "PendingScriptClient.h"
namespace WebCore {
-PendingScript::~PendingScript()
+Ref<PendingScript> PendingScript::create(Element& element, CachedScript& cachedScript)
{
- if (m_cachedScript)
- m_cachedScript->removeClient(this);
+ Ref<PendingScript> pendingScript = adoptRef(*new PendingScript(element, cachedScript));
+ cachedScript.addClient(&pendingScript.get());
+ return pendingScript;
}
-RefPtr<Element> PendingScript::releaseElementAndClear()
+Ref<PendingScript> PendingScript::create(Element& element, TextPosition scriptStartPosition)
{
- setCachedScript(nullptr);
- m_watchingForLoad = false;
- m_startingPosition = TextPosition::belowRangePosition();
- return WTFMove(m_element);
+ return adoptRef(*new PendingScript(element, scriptStartPosition));
}
-void PendingScript::setCachedScript(CachedScript* cachedScript)
+PendingScript::PendingScript(Element& element, TextPosition startingPosition)
+ : m_element(element)
+ , m_startingPosition(startingPosition)
{
- if (m_cachedScript == cachedScript)
- return;
+}
+
+PendingScript::PendingScript(Element& element, CachedScript& cachedScript)
+ : m_element(element)
+ , m_cachedScript(&cachedScript)
+{
+}
+
+PendingScript::~PendingScript()
+{
if (m_cachedScript)
m_cachedScript->removeClient(this);
- m_cachedScript = cachedScript;
- if (m_cachedScript)
- m_cachedScript->addClient(this);
}
CachedScript* PendingScript::cachedScript() const
@@ -61,8 +67,35 @@
return m_cachedScript.get();
}
+void PendingScript::notifyClientFinished()
+{
+ Ref<PendingScript> protectedThis(*this);
+ if (m_client)
+ m_client->notifyFinished(*this);
+}
+
void PendingScript::notifyFinished(CachedResource*)
{
+ notifyClientFinished();
}
+bool PendingScript::isLoaded() const
+{
+ return m_cachedScript && m_cachedScript->isLoaded();
}
+
+void PendingScript::setClient(PendingScriptClient* client)
+{
+ ASSERT(!m_client);
+ m_client = client;
+ if (isLoaded())
+ notifyClientFinished();
+}
+
+void PendingScript::clearClient()
+{
+ ASSERT(m_client);
+ m_client = nullptr;
+}
+
+}
Modified: trunk/Source/WebCore/dom/PendingScript.h (205217 => 205218)
--- trunk/Source/WebCore/dom/PendingScript.h 2016-08-31 02:01:07 UTC (rev 205217)
+++ trunk/Source/WebCore/dom/PendingScript.h 2016-08-31 02:37:12 UTC (rev 205218)
@@ -23,18 +23,19 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef PendingScript_h
-#define PendingScript_h
+#pragma once
#include "CachedResourceClient.h"
#include "CachedResourceHandle.h"
+#include <wtf/Ref.h>
+#include <wtf/RefCounted.h>
#include <wtf/text/TextPosition.h>
-#include <wtf/RefPtr.h>
namespace WebCore {
class CachedScript;
class Element;
+class PendingScriptClient;
// A container for an external script which may be loaded and executed.
//
@@ -41,67 +42,41 @@
// A CachedResourceHandle alone does not prevent the underlying CachedResource
// from purging its data buffer. This class holds a dummy client open for its
// lifetime in order to guarantee that the data buffer will not be purged.
-class PendingScript final : public CachedResourceClient {
+class PendingScript final : public RefCounted<PendingScript>, public CachedResourceClient {
public:
- PendingScript()
- : m_watchingForLoad(false)
- , m_startingPosition(TextPosition::belowRangePosition())
- {
- }
+ static Ref<PendingScript> create(Element&, CachedScript&);
+ static Ref<PendingScript> create(Element&, TextPosition scriptStartPosition);
- PendingScript(Element* element, CachedScript* cachedScript)
- : m_watchingForLoad(false)
- , m_element(element)
- {
- setCachedScript(cachedScript);
- }
-
- PendingScript(const PendingScript& other)
- : CachedResourceClient(other)
- , m_watchingForLoad(other.m_watchingForLoad)
- , m_element(other.m_element)
- , m_startingPosition(other.m_startingPosition)
- {
- setCachedScript(other.cachedScript());
- }
-
virtual ~PendingScript();
- PendingScript& operator=(const PendingScript& other)
- {
- if (this == &other)
- return *this;
-
- m_watchingForLoad = other.m_watchingForLoad;
- m_element = other.m_element;
- m_startingPosition = other.m_startingPosition;
- setCachedScript(other.cachedScript());
-
- return *this;
- }
-
TextPosition startingPosition() const { return m_startingPosition; }
void setStartingPosition(const TextPosition& position) { m_startingPosition = position; }
- bool watchingForLoad() const { return m_watchingForLoad; }
- void setWatchingForLoad(bool b) { m_watchingForLoad = b; }
+ bool watchingForLoad() const { return needsLoading() && m_client; }
- Element* element() const { return m_element.get(); }
- void setElement(Element* element) { m_element = element; }
- RefPtr<Element> releaseElementAndClear();
+ Element& element() { return m_element.get(); }
+ const Element& element() const { return m_element.get(); }
CachedScript* cachedScript() const;
- void setCachedScript(CachedScript*);
+ bool needsLoading() const { return cachedScript(); }
+ bool isLoaded() const;
+
void notifyFinished(CachedResource*) override;
+ void setClient(PendingScriptClient*);
+ void clearClient();
+
private:
- bool m_watchingForLoad;
- RefPtr<Element> m_element;
+ PendingScript(Element&, CachedScript&);
+ PendingScript(Element&, TextPosition startingPosition);
+
+ void notifyClientFinished();
+
+ Ref<Element> m_element;
TextPosition m_startingPosition; // Only used for inline script tags.
- CachedResourceHandle<CachedScript> m_cachedScript;
+ CachedResourceHandle<CachedScript> m_cachedScript;
+ PendingScriptClient* m_client { nullptr };
};
}
-
-#endif
Copied: trunk/Source/WebCore/dom/PendingScriptClient.h (from rev 205217, trunk/Source/WebCore/html/parser/HTMLScriptRunnerHost.h) (0 => 205218)
--- trunk/Source/WebCore/dom/PendingScriptClient.h (rev 0)
+++ trunk/Source/WebCore/dom/PendingScriptClient.h 2016-08-31 02:37:12 UTC (rev 205218)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2016 Apple, 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.
+ */
+
+#pragma once
+
+namespace WebCore {
+
+class PendingScript;
+
+class PendingScriptClient {
+public:
+ virtual ~PendingScriptClient() { }
+
+ virtual void notifyFinished(PendingScript&) = 0;
+};
+
+}
Modified: trunk/Source/WebCore/dom/ScriptRunner.cpp (205217 => 205218)
--- trunk/Source/WebCore/dom/ScriptRunner.cpp 2016-08-31 02:01:07 UTC (rev 205217)
+++ trunk/Source/WebCore/dom/ScriptRunner.cpp 2016-08-31 02:37:12 UTC (rev 205218)
@@ -61,11 +61,11 @@
switch (executionType) {
case ASYNC_EXECUTION:
- m_pendingAsyncScripts.add(scriptElement, PendingScript(&element, cachedScript.get()));
+ m_pendingAsyncScripts.add(scriptElement, PendingScript::create(element, *cachedScript));
break;
case IN_ORDER_EXECUTION:
- m_scriptsToExecuteInOrder.append(PendingScript(&element, cachedScript.get()));
+ m_scriptsToExecuteInOrder.append(PendingScript::create(element, *cachedScript));
break;
}
}
@@ -86,7 +86,7 @@
switch (executionType) {
case ASYNC_EXECUTION:
ASSERT(m_pendingAsyncScripts.contains(scriptElement));
- m_scriptsToExecuteSoon.append(m_pendingAsyncScripts.take(scriptElement));
+ m_scriptsToExecuteSoon.append(m_pendingAsyncScripts.take(scriptElement)->ptr());
break;
case IN_ORDER_EXECUTION:
@@ -100,23 +100,24 @@
{
Ref<Document> protect(m_document);
- Vector<PendingScript> scripts;
+ Vector<RefPtr<PendingScript>> scripts;
scripts.swap(m_scriptsToExecuteSoon);
size_t numInOrderScriptsToExecute = 0;
- for (; numInOrderScriptsToExecute < m_scriptsToExecuteInOrder.size() && m_scriptsToExecuteInOrder[numInOrderScriptsToExecute].cachedScript()->isLoaded(); ++numInOrderScriptsToExecute)
- scripts.append(m_scriptsToExecuteInOrder[numInOrderScriptsToExecute]);
+ for (; numInOrderScriptsToExecute < m_scriptsToExecuteInOrder.size() && m_scriptsToExecuteInOrder[numInOrderScriptsToExecute]->isLoaded(); ++numInOrderScriptsToExecute)
+ scripts.append(m_scriptsToExecuteInOrder[numInOrderScriptsToExecute].ptr());
if (numInOrderScriptsToExecute)
m_scriptsToExecuteInOrder.remove(0, numInOrderScriptsToExecute);
- for (auto& script : scripts) {
- CachedScript* cachedScript = script.cachedScript();
- RefPtr<Element> element = script.releaseElementAndClear();
- ASSERT(element);
+ for (auto& currentScript : scripts) {
+ auto script = WTFMove(currentScript);
+ ASSERT(script);
// Paper over https://bugs.webkit.org/show_bug.cgi?id=144050
- if (!element)
+ if (!script)
continue;
- toScriptElementIfPossible(element.get())->execute(cachedScript);
+ auto* scriptElement = toScriptElementIfPossible(&script->element());
+ ASSERT(scriptElement);
+ scriptElement->execute(script->cachedScript());
m_document.decrementLoadEventDelayCount();
}
}
Modified: trunk/Source/WebCore/dom/ScriptRunner.h (205217 => 205218)
--- trunk/Source/WebCore/dom/ScriptRunner.h 2016-08-31 02:01:07 UTC (rev 205217)
+++ trunk/Source/WebCore/dom/ScriptRunner.h 2016-08-31 02:37:12 UTC (rev 205218)
@@ -56,9 +56,9 @@
void timerFired();
Document& m_document;
- Vector<PendingScript> m_scriptsToExecuteInOrder;
- Vector<PendingScript> m_scriptsToExecuteSoon; // http://www.whatwg.org/specs/web-apps/current-work/#set-of-scripts-that-will-execute-as-soon-as-possible
- HashMap<ScriptElement*, PendingScript> m_pendingAsyncScripts;
+ Vector<Ref<PendingScript>> m_scriptsToExecuteInOrder;
+ Vector<RefPtr<PendingScript>> m_scriptsToExecuteSoon; // http://www.whatwg.org/specs/web-apps/current-work/#set-of-scripts-that-will-execute-as-soon-as-possible
+ HashMap<ScriptElement*, Ref<PendingScript>> m_pendingAsyncScripts;
Timer m_timer;
};
Modified: trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp (205217 => 205218)
--- trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp 2016-08-31 02:01:07 UTC (rev 205217)
+++ trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp 2016-08-31 02:37:12 UTC (rev 205218)
@@ -27,6 +27,7 @@
#include "config.h"
#include "HTMLDocumentParser.h"
+#include "CachedScript.h"
#include "DocumentFragment.h"
#include "Frame.h"
#include "HTMLDocument.h"
@@ -500,18 +501,18 @@
endIfDelayed();
}
-void HTMLDocumentParser::watchForLoad(CachedResource* cachedScript)
+void HTMLDocumentParser::watchForLoad(PendingScript& pendingScript)
{
- ASSERT(!cachedScript->isLoaded());
- // addClient would call notifyFinished if the load were complete.
+ ASSERT(!pendingScript.isLoaded());
+ // setClient would call notifyFinished if the load were complete.
// Callers do not expect to be re-entered from this call, so they should
- // not an already-loaded CachedResource.
- cachedScript->addClient(this);
+ // not an already-loaded PendingScript.
+ pendingScript.setClient(this);
}
-void HTMLDocumentParser::stopWatchingForLoad(CachedResource* cachedScript)
+void HTMLDocumentParser::stopWatchingForLoad(PendingScript& pendingScript)
{
- cachedScript->removeClient(this);
+ pendingScript.clearClient();
}
void HTMLDocumentParser::appendCurrentInputStreamToPreloadScannerAndScan()
@@ -521,7 +522,7 @@
m_preloadScanner->scan(*m_preloader, *document());
}
-void HTMLDocumentParser::notifyFinished(CachedResource* cachedResource)
+void HTMLDocumentParser::notifyFinished(PendingScript& pendingScript)
{
// pumpTokenizer can cause this parser to be detached from the Document,
// but we need to ensure it isn't deleted yet.
@@ -534,7 +535,7 @@
return;
}
- m_scriptRunner->executeScriptsWaitingForLoad(cachedResource);
+ m_scriptRunner->executeScriptsWaitingForLoad(pendingScript);
if (!isWaitingForScripts())
resumeParsingAfterScriptExecution();
}
Modified: trunk/Source/WebCore/html/parser/HTMLDocumentParser.h (205217 => 205218)
--- trunk/Source/WebCore/html/parser/HTMLDocumentParser.h 2016-08-31 02:01:07 UTC (rev 205217)
+++ trunk/Source/WebCore/html/parser/HTMLDocumentParser.h 2016-08-31 02:37:12 UTC (rev 205218)
@@ -27,11 +27,11 @@
#ifndef HTMLDocumentParser_h
#define HTMLDocumentParser_h
-#include "CachedResourceClient.h"
#include "HTMLInputStream.h"
#include "HTMLScriptRunnerHost.h"
#include "HTMLSourceTracker.h"
#include "HTMLTokenizer.h"
+#include "PendingScriptClient.h"
#include "ScriptableDocumentParser.h"
#include "XSSAuditor.h"
#include "XSSAuditorDelegate.h"
@@ -47,7 +47,7 @@
class HTMLResourcePreloader;
class PumpSession;
-class HTMLDocumentParser : public ScriptableDocumentParser, private HTMLScriptRunnerHost, private CachedResourceClient {
+class HTMLDocumentParser : public ScriptableDocumentParser, private HTMLScriptRunnerHost, private PendingScriptClient {
WTF_MAKE_FAST_ALLOCATED;
public:
static Ref<HTMLDocumentParser> create(HTMLDocument&);
@@ -90,14 +90,14 @@
bool shouldAssociateConsoleMessagesWithTextPosition() const final;
// HTMLScriptRunnerHost
- void watchForLoad(CachedResource*) final;
- void stopWatchingForLoad(CachedResource*) final;
+ void watchForLoad(PendingScript&) final;
+ void stopWatchingForLoad(PendingScript&) final;
HTMLInputStream& inputStream() final;
bool hasPreloadScanner() const final;
void appendCurrentInputStreamToPreloadScannerAndScan() final;
- // CachedResourceClient
- void notifyFinished(CachedResource*) final;
+ // PendingScriptClient
+ void notifyFinished(PendingScript&) final;
Document* contextForParsingSession();
Modified: trunk/Source/WebCore/html/parser/HTMLScriptRunner.cpp (205217 => 205218)
--- trunk/Source/WebCore/html/parser/HTMLScriptRunner.cpp 2016-08-31 02:01:07 UTC (rev 205217)
+++ trunk/Source/WebCore/html/parser/HTMLScriptRunner.cpp 2016-08-31 02:37:12 UTC (rev 205218)
@@ -58,12 +58,14 @@
HTMLScriptRunner::~HTMLScriptRunner()
{
// FIXME: Should we be passed a "done loading/parsing" callback sooner than destruction?
- if (m_parserBlockingScript.cachedScript() && m_parserBlockingScript.watchingForLoad())
- stopWatchingForLoad(m_parserBlockingScript);
+ if (m_parserBlockingScript) {
+ if (m_parserBlockingScript->watchingForLoad())
+ stopWatchingForLoad(*m_parserBlockingScript);
+ }
while (!m_scriptsToExecuteAfterParsing.isEmpty()) {
- PendingScript pendingScript = m_scriptsToExecuteAfterParsing.takeFirst();
- if (pendingScript.cachedScript() && pendingScript.watchingForLoad())
+ auto pendingScript = m_scriptsToExecuteAfterParsing.takeFirst();
+ if (pendingScript->watchingForLoad())
stopWatchingForLoad(pendingScript);
}
}
@@ -95,7 +97,7 @@
return ScriptSourceCode(script.cachedScript());
}
errorOccurred = false;
- return ScriptSourceCode(script.element()->textContent(), documentURLForScriptExecution(m_document), script.startingPosition());
+ return ScriptSourceCode(script.element().textContent(), documentURLForScriptExecution(m_document), script.startingPosition());
}
bool HTMLScriptRunner::isPendingScriptReady(const PendingScript& script)
@@ -105,7 +107,7 @@
m_hasScriptsWaitingForStylesheets = !m_document->haveStylesheetsLoaded();
if (m_hasScriptsWaitingForStylesheets)
return false;
- if (script.cachedScript() && !script.cachedScript()->isLoaded())
+ if (script.needsLoading() && !script.isLoaded())
return false;
return true;
}
@@ -115,27 +117,25 @@
ASSERT(m_document);
ASSERT(!isExecutingScript());
ASSERT(m_document->haveStylesheetsLoaded());
- ASSERT(isPendingScriptReady(m_parserBlockingScript));
+ ASSERT(isPendingScriptReady(*m_parserBlockingScript));
InsertionPointRecord insertionPointRecord(m_host.inputStream());
- executePendingScriptAndDispatchEvent(m_parserBlockingScript);
+ executePendingScriptAndDispatchEvent(WTFMove(m_parserBlockingScript));
}
-void HTMLScriptRunner::executePendingScriptAndDispatchEvent(PendingScript& pendingScript)
+void HTMLScriptRunner::executePendingScriptAndDispatchEvent(RefPtr<PendingScript> pendingScript)
{
bool errorOccurred = false;
- ScriptSourceCode sourceCode = sourceFromPendingScript(pendingScript, errorOccurred);
+ ScriptSourceCode sourceCode = sourceFromPendingScript(*pendingScript, errorOccurred);
// Stop watching loads before executeScript to prevent recursion if the script reloads itself.
- if (pendingScript.cachedScript() && pendingScript.watchingForLoad())
- stopWatchingForLoad(pendingScript);
+ if (pendingScript->watchingForLoad())
+ stopWatchingForLoad(*pendingScript);
if (!isExecutingScript())
MicrotaskQueue::mainThreadQueue().performMicrotaskCheckpoint();
- // Clear the pending script before possible rentrancy from executeScript()
- RefPtr<Element> element = pendingScript.releaseElementAndClear();
- if (ScriptElement* scriptElement = toScriptElementIfPossible(element.get())) {
+ if (auto* scriptElement = toScriptElementIfPossible(&pendingScript->element())) {
NestingLevelIncrementer nestingLevelIncrementer(m_scriptNestingLevel);
IgnoreDestructiveWriteCountIncrementer ignoreDestructiveWriteCountIncrementer(m_document);
if (errorOccurred)
@@ -143,7 +143,7 @@
else {
ASSERT(isExecutingScript());
scriptElement->executeScript(sourceCode);
- element->dispatchEvent(createScriptLoadEvent());
+ pendingScript->element().dispatchEvent(createScriptLoadEvent());
}
}
ASSERT(!isExecutingScript());
@@ -152,15 +152,13 @@
void HTMLScriptRunner::watchForLoad(PendingScript& pendingScript)
{
ASSERT(!pendingScript.watchingForLoad());
- m_host.watchForLoad(pendingScript.cachedScript());
- pendingScript.setWatchingForLoad(true);
+ m_host.watchForLoad(pendingScript);
}
void HTMLScriptRunner::stopWatchingForLoad(PendingScript& pendingScript)
{
ASSERT(pendingScript.watchingForLoad());
- m_host.stopWatchingForLoad(pendingScript.cachedScript());
- pendingScript.setWatchingForLoad(false);
+ m_host.stopWatchingForLoad(pendingScript);
}
// This function should match 10.2.5.11 "An end tag whose tag name is 'script'"
@@ -187,21 +185,21 @@
bool HTMLScriptRunner::hasParserBlockingScript() const
{
- return !!m_parserBlockingScript.element();
+ return !!m_parserBlockingScript;
}
void HTMLScriptRunner::executeParsingBlockingScripts()
{
- while (hasParserBlockingScript() && isPendingScriptReady(m_parserBlockingScript))
+ while (hasParserBlockingScript() && isPendingScriptReady(*m_parserBlockingScript))
executeParsingBlockingScript();
}
-void HTMLScriptRunner::executeScriptsWaitingForLoad(CachedResource* cachedScript)
+void HTMLScriptRunner::executeScriptsWaitingForLoad(PendingScript& pendingScript)
{
ASSERT(!isExecutingScript());
ASSERT(hasParserBlockingScript());
- ASSERT_UNUSED(cachedScript, m_parserBlockingScript.cachedScript() == cachedScript);
- ASSERT(m_parserBlockingScript.cachedScript()->isLoaded());
+ ASSERT_UNUSED(pendingScript, m_parserBlockingScript.get() == &pendingScript);
+ ASSERT(m_parserBlockingScript->isLoaded());
executeParsingBlockingScripts();
}
@@ -221,13 +219,12 @@
while (!m_scriptsToExecuteAfterParsing.isEmpty()) {
ASSERT(!isExecutingScript());
ASSERT(!hasParserBlockingScript());
- ASSERT(m_scriptsToExecuteAfterParsing.first().cachedScript());
- if (!m_scriptsToExecuteAfterParsing.first().cachedScript()->isLoaded()) {
+ ASSERT(m_scriptsToExecuteAfterParsing.first()->needsLoading());
+ if (!m_scriptsToExecuteAfterParsing.first()->isLoaded()) {
watchForLoad(m_scriptsToExecuteAfterParsing.first());
return false;
}
- PendingScript first = m_scriptsToExecuteAfterParsing.takeFirst();
- executePendingScriptAndDispatchEvent(first);
+ executePendingScriptAndDispatchEvent(m_scriptsToExecuteAfterParsing.takeFirst());
// FIXME: What is this m_document check for?
if (!m_document)
return false;
@@ -235,44 +232,34 @@
return true;
}
+static Ref<PendingScript> requestPendingScript(Element* script)
+{
+ auto& scriptElement = *toScriptElementIfPossible(script);
+ ASSERT(scriptElement.willBeParserExecuted());
+ ASSERT(scriptElement.cachedScript());
+ return PendingScript::create(*script, *scriptElement.cachedScript());
+}
+
void HTMLScriptRunner::requestParsingBlockingScript(Element* element)
{
- if (!requestPendingScript(m_parserBlockingScript, element))
- return;
+ ASSERT(!m_parserBlockingScript);
+ m_parserBlockingScript = requestPendingScript(element);
+ ASSERT(m_parserBlockingScript->needsLoading());
- ASSERT(m_parserBlockingScript.cachedScript());
-
// We only care about a load callback if cachedScript is not already
// in the cache. Callers will attempt to run the m_parserBlockingScript
// if possible before returning control to the parser.
- if (!m_parserBlockingScript.cachedScript()->isLoaded())
- watchForLoad(m_parserBlockingScript);
+ if (!m_parserBlockingScript->isLoaded())
+ watchForLoad(*m_parserBlockingScript);
}
void HTMLScriptRunner::requestDeferredScript(Element* element)
{
- PendingScript pendingScript;
- if (!requestPendingScript(pendingScript, element))
- return;
-
- ASSERT(pendingScript.cachedScript());
- m_scriptsToExecuteAfterParsing.append(pendingScript);
+ auto pendingScript = requestPendingScript(element);
+ ASSERT(pendingScript->needsLoading());
+ m_scriptsToExecuteAfterParsing.append(WTFMove(pendingScript));
}
-bool HTMLScriptRunner::requestPendingScript(PendingScript& pendingScript, Element* script) const
-{
- ASSERT(!pendingScript.element());
- pendingScript.setElement(script);
- // This should correctly return 0 for empty or invalid srcValues.
- CachedScript* cachedScript = toScriptElementIfPossible(script)->cachedScript().get();
- if (!cachedScript) {
- notImplemented(); // Dispatch error event.
- return false;
- }
- pendingScript.setCachedScript(cachedScript);
- return true;
-}
-
// This method is meant to match the HTML5 definition of "running a script"
// http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#running-a-script
void HTMLScriptRunner::runScript(Element* script, const TextPosition& scriptStartPosition)
@@ -308,13 +295,10 @@
if (scriptElement->willExecuteWhenDocumentFinishedParsing())
requestDeferredScript(script);
else if (scriptElement->readyToBeParserExecuted()) {
- if (m_scriptNestingLevel == 1) {
- m_parserBlockingScript.setElement(script);
- m_parserBlockingScript.setStartingPosition(scriptStartPosition);
- } else {
- ScriptSourceCode sourceCode(script->textContent(), documentURLForScriptExecution(m_document), scriptStartPosition);
- scriptElement->executeScript(sourceCode);
- }
+ if (m_scriptNestingLevel == 1)
+ m_parserBlockingScript = PendingScript::create(*script, scriptStartPosition);
+ else
+ scriptElement->executeScript(ScriptSourceCode(script->textContent(), documentURLForScriptExecution(m_document), scriptStartPosition));
} else
requestParsingBlockingScript(script);
}
Modified: trunk/Source/WebCore/html/parser/HTMLScriptRunner.h (205217 => 205218)
--- trunk/Source/WebCore/html/parser/HTMLScriptRunner.h 2016-08-31 02:01:07 UTC (rev 205217)
+++ trunk/Source/WebCore/html/parser/HTMLScriptRunner.h 2016-08-31 02:37:12 UTC (rev 205218)
@@ -51,7 +51,7 @@
// Processes the passed in script and any pending scripts if possible.
void execute(PassRefPtr<Element> scriptToProcess, const TextPosition& scriptStartPosition);
- void executeScriptsWaitingForLoad(CachedResource*);
+ void executeScriptsWaitingForLoad(PendingScript&);
bool hasScriptsWaitingForStylesheets() const { return m_hasScriptsWaitingForStylesheets; }
void executeScriptsWaitingForStylesheets();
bool executeScriptsWaitingForParsing();
@@ -63,12 +63,11 @@
Frame* frame() const;
void executeParsingBlockingScript();
- void executePendingScriptAndDispatchEvent(PendingScript&);
+ void executePendingScriptAndDispatchEvent(RefPtr<PendingScript>);
void executeParsingBlockingScripts();
void requestParsingBlockingScript(Element*);
void requestDeferredScript(Element*);
- bool requestPendingScript(PendingScript&, Element*) const;
void runScript(Element*, const TextPosition& scriptStartPosition);
@@ -80,8 +79,8 @@
Document* m_document;
HTMLScriptRunnerHost& m_host;
- PendingScript m_parserBlockingScript;
- Deque<PendingScript> m_scriptsToExecuteAfterParsing; // http://www.whatwg.org/specs/web-apps/current-work/#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing
+ RefPtr<PendingScript> m_parserBlockingScript;
+ Deque<Ref<PendingScript>> m_scriptsToExecuteAfterParsing; // http://www.whatwg.org/specs/web-apps/current-work/#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing
unsigned m_scriptNestingLevel;
// We only want stylesheet loads to trigger script execution if script
Modified: trunk/Source/WebCore/html/parser/HTMLScriptRunnerHost.h (205217 => 205218)
--- trunk/Source/WebCore/html/parser/HTMLScriptRunnerHost.h 2016-08-31 02:01:07 UTC (rev 205217)
+++ trunk/Source/WebCore/html/parser/HTMLScriptRunnerHost.h 2016-08-31 02:37:12 UTC (rev 205218)
@@ -30,9 +30,9 @@
namespace WebCore {
-class CachedResource;
class Element;
class HTMLInputStream;
+class PendingScript;
class ScriptSourceCode;
class HTMLScriptRunnerHost {
@@ -40,9 +40,9 @@
virtual ~HTMLScriptRunnerHost() { }
// Implementors should call cachedResource->addClient() here or soon after.
- virtual void watchForLoad(CachedResource*) = 0;
+ virtual void watchForLoad(PendingScript&) = 0;
// Implementors must call cachedResource->removeClient() immediately.
- virtual void stopWatchingForLoad(CachedResource*) = 0;
+ virtual void stopWatchingForLoad(PendingScript&) = 0;
virtual HTMLInputStream& inputStream() = 0;