#ifndef ScriptLoader_h
#define ScriptLoader_h
+#include "core/dom/PendingScript.h"
#include "core/fetch/FetchRequest.h"
#include "core/fetch/ResourceClient.h"
#include "core/fetch/ResourcePtr.h"
class ScriptSourceCode;
-class ScriptLoader FINAL : private ScriptResourceClient {
+class ScriptLoader final : public NoBaseWillBeGarbageCollectedFinalized<ScriptLoader>, private ScriptResourceClient {
public:
- static PassOwnPtr<ScriptLoader> create(Element*, bool createdByParser, bool isEvaluated);
+ static PassOwnPtrWillBeRawPtr<ScriptLoader> create(Element* element, bool createdByParser, bool isEvaluated)
+ {
+ return adoptPtrWillBeNoop(new ScriptLoader(element, createdByParser, isEvaluated));
+ }
+
virtual ~ScriptLoader();
+ virtual void trace(Visitor*);
Element* element() const { return m_element; }
String scriptCharset() const { return m_characterEncoding; }
String scriptContent() const;
void executeScript(const ScriptSourceCode&, double* compilationFinishTime = 0);
- void execute(ScriptResource*);
+ void execute();
// XML parser calls these
void dispatchLoadEvent();
void handleSourceAttribute(const String& sourceUrl);
void handleAsyncAttribute();
+ bool isReady() const { return m_pendingScript.isReady(); }
+
+ // Clears the connection to the PendingScript (and Element and Resource).
+ void detach();
+
private:
ScriptLoader(Element*, bool createdByParser, bool isEvaluated);
bool isScriptForEventSupported() const;
bool fetchScript(const String& sourceUrl, FetchRequest::DeferOption);
- void stopLoadRequest();
ScriptLoaderClient* client() const;
// ResourceClient
- virtual void notifyFinished(Resource*) OVERRIDE;
+ virtual void notifyFinished(Resource*) override;
- // FIXME: Oilpan: This should become a Member once ResourceClient is moved to the heap.
- Element* m_element;
+ RawPtrWillBeMember<Element> m_element;
ResourcePtr<ScriptResource> m_resource;
WTF::OrdinalNumber m_startLineNumber;
+ String m_characterEncoding;
+ String m_fallbackCharacterEncoding;
+
+ PendingScript m_pendingScript;
+
bool m_parserInserted : 1;
bool m_isExternalScript : 1;
bool m_alreadyStarted : 1;
bool m_willExecuteWhenDocumentFinishedParsing : 1;
bool m_forceAsync : 1;
bool m_willExecuteInOrder : 1;
- String m_characterEncoding;
- String m_fallbackCharacterEncoding;
};
ScriptLoader* toScriptLoaderIfPossible(Element*);
-inline PassOwnPtr<ScriptLoader> ScriptLoader::create(Element* element, bool createdByParser, bool isEvaluated)
-{
- return adoptPtr(new ScriptLoader(element, createdByParser, isEvaluated));
-}
-
-}
-
+} // namespace blink
-#endif
+#endif // ScriptLoader_h