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

Unified Diff: Source/core/dom/ScriptElement.h

Issue 18676002: Refactoring: Decouple ScriptElement from HTMLScriptElement and SVGScriptElement. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed points Created 7 years, 5 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
« no previous file with comments | « no previous file | Source/core/dom/ScriptElement.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/ScriptElement.h
diff --git a/Source/core/dom/ScriptElement.h b/Source/core/dom/ScriptElement.h
index 32a011d326af0b59a0593767a5969b987b88ba53..645dd321bc311b419fc2805ae1aa9689384eb43e 100644
--- a/Source/core/dom/ScriptElement.h
+++ b/Source/core/dom/ScriptElement.h
@@ -34,9 +34,26 @@ class Element;
class ScriptElement;
class ScriptSourceCode;
+class ScriptElementClient {
+public:
+ virtual ~ScriptElementClient() { }
+
+ virtual void dispatchLoadEvent() = 0;
+
+ virtual String sourceAttributeValue() const = 0;
+ virtual String charsetAttributeValue() const = 0;
+ virtual String typeAttributeValue() const = 0;
+ virtual String languageAttributeValue() const = 0;
+ virtual String forAttributeValue() const = 0;
+ virtual String eventAttributeValue() const = 0;
+ virtual bool asyncAttributeValue() const = 0;
+ virtual bool deferAttributeValue() const = 0;
+ virtual bool hasSourceAttribute() const = 0;
+};
+
class ScriptElement : private CachedResourceClient {
public:
- ScriptElement(Element*, bool createdByParser, bool isEvaluated);
+ static PassOwnPtr<ScriptElement> create(Element*, bool createdByParser, bool isEvaluated);
virtual ~ScriptElement();
Element* element() const { return m_element; }
@@ -50,7 +67,7 @@ public:
void execute(CachedScript*);
// XML parser calls these
- virtual void dispatchLoadEvent() = 0;
+ void dispatchLoadEvent();
void dispatchErrorEvent();
bool isScriptTypeSupported(LegacyTypeSupport) const;
@@ -60,7 +77,6 @@ public:
bool willExecuteWhenDocumentFinishedParsing() const { return m_willExecuteWhenDocumentFinishedParsing; }
CachedResourceHandle<CachedScript> cachedScript() { return m_cachedScript; }
-protected:
void setHaveFiredLoadEvent(bool haveFiredLoad) { m_haveFiredLoad = haveFiredLoad; }
bool isParserInserted() const { return m_parserInserted; }
bool alreadyStarted() const { return m_alreadyStarted; }
@@ -73,23 +89,18 @@ protected:
void handleAsyncAttribute();
private:
+ ScriptElement(Element*, bool createdByParser, bool isEvaluated);
+
bool ignoresLoadRequest() const;
bool isScriptForEventSupported() const;
bool requestScript(const String& sourceUrl);
void stopLoadRequest();
- virtual void notifyFinished(CachedResource*);
+ ScriptElementClient* client() const;
- virtual String sourceAttributeValue() const = 0;
- virtual String charsetAttributeValue() const = 0;
- virtual String typeAttributeValue() const = 0;
- virtual String languageAttributeValue() const = 0;
- virtual String forAttributeValue() const = 0;
- virtual String eventAttributeValue() const = 0;
- virtual bool asyncAttributeValue() const = 0;
- virtual bool deferAttributeValue() const = 0;
- virtual bool hasSourceAttribute() const = 0;
+ // CachedResourceClient
+ virtual void notifyFinished(CachedResource*) OVERRIDE;
Element* m_element;
CachedResourceHandle<CachedScript> m_cachedScript;
@@ -109,6 +120,12 @@ private:
ScriptElement* toScriptElementIfPossible(Element*);
+inline PassOwnPtr<ScriptElement> ScriptElement::create(Element* element, bool createdByParser, bool isEvaluated)
+{
+ return adoptPtr(new ScriptElement(element, createdByParser, isEvaluated));
}
+}
+
+
#endif
« no previous file with comments | « no previous file | Source/core/dom/ScriptElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698