| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "wtf/text/TextPosition.h" | 29 #include "wtf/text/TextPosition.h" |
| 30 #include "wtf/text/WTFString.h" | 30 #include "wtf/text/WTFString.h" |
| 31 | 31 |
| 32 namespace blink { | 32 namespace blink { |
| 33 | 33 |
| 34 class Element; | 34 class Element; |
| 35 class ScriptLoaderClient; | 35 class ScriptLoaderClient; |
| 36 class ScriptSourceCode; | 36 class ScriptSourceCode; |
| 37 | 37 |
| 38 | 38 |
| 39 class ScriptLoader : public NoBaseWillBeGarbageCollectedFinalized<ScriptLoader>,
private ScriptResourceClient { | 39 class ScriptLoader final : public NoBaseWillBeGarbageCollectedFinalized<ScriptLo
ader>, private ScriptResourceClient { |
| 40 public: | 40 public: |
| 41 static PassOwnPtrWillBeRawPtr<ScriptLoader> create(Element* element, bool cr
eatedByParser, bool isEvaluated) | 41 static PassOwnPtrWillBeRawPtr<ScriptLoader> create(Element* element, bool cr
eatedByParser, bool isEvaluated) |
| 42 { | 42 { |
| 43 return adoptPtrWillBeNoop(new ScriptLoader(element, createdByParser, isE
valuated)); | 43 return adoptPtrWillBeNoop(new ScriptLoader(element, createdByParser, isE
valuated)); |
| 44 } | 44 } |
| 45 | 45 |
| 46 virtual ~ScriptLoader(); | 46 virtual ~ScriptLoader(); |
| 47 virtual void trace(Visitor*); | 47 virtual void trace(Visitor*); |
| 48 | 48 |
| 49 Element* element() const { return m_element; } | 49 Element* element() const { return m_element; } |
| 50 | 50 |
| 51 enum LegacyTypeSupport { DisallowLegacyTypeInTypeAttribute, AllowLegacyTypeI
nTypeAttribute }; | 51 enum LegacyTypeSupport { DisallowLegacyTypeInTypeAttribute, AllowLegacyTypeI
nTypeAttribute }; |
| 52 bool prepareScript(const TextPosition& scriptStartPosition = TextPosition::m
inimumPosition(), LegacyTypeSupport = DisallowLegacyTypeInTypeAttribute); | 52 bool prepareScript(const TextPosition& scriptStartPosition = TextPosition::m
inimumPosition(), LegacyTypeSupport = DisallowLegacyTypeInTypeAttribute); |
| 53 | 53 |
| 54 String scriptCharset() const { return m_characterEncoding; } | 54 String scriptCharset() const { return m_characterEncoding; } |
| 55 String scriptContent() const; | 55 String scriptContent() const; |
| 56 void executeScript(const ScriptSourceCode&, double* compilationFinishTime =
0); | 56 void executeScript(const ScriptSourceCode&, double* compilationFinishTime =
0); |
| 57 virtual void execute(); | 57 void execute(); |
| 58 | 58 |
| 59 // XML parser calls these | 59 // XML parser calls these |
| 60 void dispatchLoadEvent(); | 60 void dispatchLoadEvent(); |
| 61 void dispatchErrorEvent(); | 61 void dispatchErrorEvent(); |
| 62 bool isScriptTypeSupported(LegacyTypeSupport) const; | 62 bool isScriptTypeSupported(LegacyTypeSupport) const; |
| 63 | 63 |
| 64 bool haveFiredLoadEvent() const { return m_haveFiredLoad; } | 64 bool haveFiredLoadEvent() const { return m_haveFiredLoad; } |
| 65 bool willBeParserExecuted() const { return m_willBeParserExecuted; } | 65 bool willBeParserExecuted() const { return m_willBeParserExecuted; } |
| 66 bool readyToBeParserExecuted() const { return m_readyToBeParserExecuted; } | 66 bool readyToBeParserExecuted() const { return m_readyToBeParserExecuted; } |
| 67 bool willExecuteWhenDocumentFinishedParsing() const { return m_willExecuteWh
enDocumentFinishedParsing; } | 67 bool willExecuteWhenDocumentFinishedParsing() const { return m_willExecuteWh
enDocumentFinishedParsing; } |
| 68 ResourcePtr<ScriptResource> resource() { return m_resource; } | 68 ResourcePtr<ScriptResource> resource() { return m_resource; } |
| 69 | 69 |
| 70 void setHaveFiredLoadEvent(bool haveFiredLoad) { m_haveFiredLoad = haveFired
Load; } | 70 void setHaveFiredLoadEvent(bool haveFiredLoad) { m_haveFiredLoad = haveFired
Load; } |
| 71 bool isParserInserted() const { return m_parserInserted; } | 71 bool isParserInserted() const { return m_parserInserted; } |
| 72 bool alreadyStarted() const { return m_alreadyStarted; } | 72 bool alreadyStarted() const { return m_alreadyStarted; } |
| 73 bool forceAsync() const { return m_forceAsync; } | 73 bool forceAsync() const { return m_forceAsync; } |
| 74 | 74 |
| 75 // Helper functions used by our parent classes. | 75 // Helper functions used by our parent classes. |
| 76 void didNotifySubtreeInsertionsToDocument(); | 76 void didNotifySubtreeInsertionsToDocument(); |
| 77 void childrenChanged(); | 77 void childrenChanged(); |
| 78 void handleSourceAttribute(const String& sourceUrl); | 78 void handleSourceAttribute(const String& sourceUrl); |
| 79 void handleAsyncAttribute(); | 79 void handleAsyncAttribute(); |
| 80 | 80 |
| 81 virtual bool isReady() const { return m_pendingScript.isReady(); } | 81 bool isReady() const { return m_pendingScript.isReady(); } |
| 82 | 82 |
| 83 // Clears the connection to the PendingScript (and Element and Resource). | 83 // Clears the connection to the PendingScript (and Element and Resource). |
| 84 void detach(); | 84 void detach(); |
| 85 | 85 |
| 86 protected: | 86 private: |
| 87 ScriptLoader(Element*, bool createdByParser, bool isEvaluated); | 87 ScriptLoader(Element*, bool createdByParser, bool isEvaluated); |
| 88 | 88 |
| 89 private: | |
| 90 bool ignoresLoadRequest() const; | 89 bool ignoresLoadRequest() const; |
| 91 bool isScriptForEventSupported() const; | 90 bool isScriptForEventSupported() const; |
| 92 | 91 |
| 93 bool fetchScript(const String& sourceUrl, FetchRequest::DeferOption); | 92 bool fetchScript(const String& sourceUrl, FetchRequest::DeferOption); |
| 94 | 93 |
| 95 ScriptLoaderClient* client() const; | 94 ScriptLoaderClient* client() const; |
| 96 | 95 |
| 97 // ResourceClient | 96 // ResourceClient |
| 98 virtual void notifyFinished(Resource*) override; | 97 virtual void notifyFinished(Resource*) override; |
| 99 | 98 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 114 bool m_willExecuteWhenDocumentFinishedParsing : 1; | 113 bool m_willExecuteWhenDocumentFinishedParsing : 1; |
| 115 bool m_forceAsync : 1; | 114 bool m_forceAsync : 1; |
| 116 bool m_willExecuteInOrder : 1; | 115 bool m_willExecuteInOrder : 1; |
| 117 }; | 116 }; |
| 118 | 117 |
| 119 ScriptLoader* toScriptLoaderIfPossible(Element*); | 118 ScriptLoader* toScriptLoaderIfPossible(Element*); |
| 120 | 119 |
| 121 } // namespace blink | 120 } // namespace blink |
| 122 | 121 |
| 123 #endif // ScriptLoader_h | 122 #endif // ScriptLoader_h |
| OLD | NEW |