| 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
| 15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
| 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
| 18 * | 18 * |
| 19 */ | 19 */ |
| 20 | 20 |
| 21 #ifndef ScriptLoader_h | 21 #ifndef ScriptLoader_h |
| 22 #define ScriptLoader_h | 22 #define ScriptLoader_h |
| 23 | 23 |
| 24 #include "core/CoreExport.h" | 24 #include "core/CoreExport.h" |
| 25 #include "core/dom/PendingScript.h" | 25 #include "core/dom/PendingScript.h" |
| 26 #include "core/fetch/FetchRequest.h" | 26 #include "core/fetch/FetchRequest.h" |
| 27 #include "core/fetch/ResourceClient.h" | 27 #include "core/fetch/ResourceClient.h" |
| 28 #include "core/fetch/ResourcePtr.h" | |
| 29 #include "core/fetch/ScriptResource.h" | 28 #include "core/fetch/ScriptResource.h" |
| 30 #include "wtf/text/TextPosition.h" | 29 #include "wtf/text/TextPosition.h" |
| 31 #include "wtf/text/WTFString.h" | 30 #include "wtf/text/WTFString.h" |
| 32 | 31 |
| 33 namespace blink { | 32 namespace blink { |
| 34 | 33 |
| 35 class Element; | 34 class Element; |
| 36 class ScriptLoaderClient; | 35 class ScriptLoaderClient; |
| 37 class ScriptSourceCode; | 36 class ScriptSourceCode; |
| 38 class LocalFrame; | 37 class LocalFrame; |
| 39 | 38 |
| 40 class CORE_EXPORT ScriptLoader : public NoBaseWillBeGarbageCollectedFinalized<Sc
riptLoader>, private ScriptResourceClient { | 39 class CORE_EXPORT ScriptLoader : public NoBaseWillBeGarbageCollectedFinalized<Sc
riptLoader>, public ScriptResourceClient { |
| 41 USING_FAST_MALLOC_WILL_BE_REMOVED(ScriptLoader); | 40 USING_FAST_MALLOC_WILL_BE_REMOVED(ScriptLoader); |
| 42 WILL_BE_USING_PRE_FINALIZER(ScriptLoader, detach); | |
| 43 public: | 41 public: |
| 44 static PassOwnPtrWillBeRawPtr<ScriptLoader> create(Element* element, bool cr
eatedByParser, bool isEvaluated) | 42 static PassOwnPtrWillBeRawPtr<ScriptLoader> create(Element* element, bool cr
eatedByParser, bool isEvaluated) |
| 45 { | 43 { |
| 46 return adoptPtrWillBeNoop(new ScriptLoader(element, createdByParser, isE
valuated)); | 44 return adoptPtrWillBeNoop(new ScriptLoader(element, createdByParser, isE
valuated)); |
| 47 } | 45 } |
| 48 | 46 |
| 49 ~ScriptLoader() override; | 47 ~ScriptLoader() override; |
| 50 DECLARE_VIRTUAL_TRACE(); | 48 DECLARE_VIRTUAL_TRACE(); |
| 51 | 49 |
| 52 Element* element() const { return m_element; } | 50 Element* element() const { return m_element; } |
| 53 | 51 |
| 54 enum LegacyTypeSupport { DisallowLegacyTypeInTypeAttribute, AllowLegacyTypeI
nTypeAttribute }; | 52 enum LegacyTypeSupport { DisallowLegacyTypeInTypeAttribute, AllowLegacyTypeI
nTypeAttribute }; |
| 55 bool prepareScript(const TextPosition& scriptStartPosition = TextPosition::m
inimumPosition(), LegacyTypeSupport = DisallowLegacyTypeInTypeAttribute); | 53 bool prepareScript(const TextPosition& scriptStartPosition = TextPosition::m
inimumPosition(), LegacyTypeSupport = DisallowLegacyTypeInTypeAttribute); |
| 56 | 54 |
| 57 String scriptCharset() const { return m_characterEncoding; } | 55 String scriptCharset() const { return m_characterEncoding; } |
| 58 String scriptContent() const; | 56 String scriptContent() const; |
| 59 // Returns false if and only if execution was blocked. | 57 // Returns false if and only if execution was blocked. |
| 60 bool executeScript(const ScriptSourceCode&, double* compilationFinishTime =
0); | 58 bool executeScript(const ScriptSourceCode&, double* compilationFinishTime =
0); |
| 61 virtual void execute(); | 59 virtual void execute(); |
| 62 | 60 |
| 63 // XML parser calls these | 61 // XML parser calls these |
| 64 void dispatchLoadEvent(); | 62 void dispatchLoadEvent(); |
| 65 void dispatchErrorEvent(); | 63 void dispatchErrorEvent(); |
| 66 bool isScriptTypeSupported(LegacyTypeSupport) const; | 64 bool isScriptTypeSupported(LegacyTypeSupport) const; |
| 67 | 65 |
| 68 bool haveFiredLoadEvent() const { return m_haveFiredLoad; } | 66 bool haveFiredLoadEvent() const { return m_haveFiredLoad; } |
| 69 bool willBeParserExecuted() const { return m_willBeParserExecuted; } | 67 bool willBeParserExecuted() const { return m_willBeParserExecuted; } |
| 70 bool readyToBeParserExecuted() const { return m_readyToBeParserExecuted; } | 68 bool readyToBeParserExecuted() const { return m_readyToBeParserExecuted; } |
| 71 bool willExecuteWhenDocumentFinishedParsing() const { return m_willExecuteWh
enDocumentFinishedParsing; } | 69 bool willExecuteWhenDocumentFinishedParsing() const { return m_willExecuteWh
enDocumentFinishedParsing; } |
| 72 ResourcePtr<ScriptResource> resource() { return m_resource; } | 70 ScriptResource* resource() { return m_resource.get(); } |
| 73 | 71 |
| 74 void setHaveFiredLoadEvent(bool haveFiredLoad) { m_haveFiredLoad = haveFired
Load; } | 72 void setHaveFiredLoadEvent(bool haveFiredLoad) { m_haveFiredLoad = haveFired
Load; } |
| 75 bool isParserInserted() const { return m_parserInserted; } | 73 bool isParserInserted() const { return m_parserInserted; } |
| 76 bool alreadyStarted() const { return m_alreadyStarted; } | 74 bool alreadyStarted() const { return m_alreadyStarted; } |
| 77 bool forceAsync() const { return m_forceAsync; } | 75 bool forceAsync() const { return m_forceAsync; } |
| 78 | 76 |
| 79 // Helper functions used by our parent classes. | 77 // Helper functions used by our parent classes. |
| 80 void didNotifySubtreeInsertionsToDocument(); | 78 void didNotifySubtreeInsertionsToDocument(); |
| 81 void childrenChanged(); | 79 void childrenChanged(); |
| 82 void handleSourceAttribute(const String& sourceUrl); | 80 void handleSourceAttribute(const String& sourceUrl); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 97 | 95 |
| 98 bool fetchScript(const String& sourceUrl, FetchRequest::DeferOption); | 96 bool fetchScript(const String& sourceUrl, FetchRequest::DeferOption); |
| 99 | 97 |
| 100 ScriptLoaderClient* client() const; | 98 ScriptLoaderClient* client() const; |
| 101 | 99 |
| 102 // ResourceClient | 100 // ResourceClient |
| 103 void notifyFinished(Resource*) override; | 101 void notifyFinished(Resource*) override; |
| 104 String debugName() const override { return "ScriptLoader"; } | 102 String debugName() const override { return "ScriptLoader"; } |
| 105 | 103 |
| 106 RawPtrWillBeMember<Element> m_element; | 104 RawPtrWillBeMember<Element> m_element; |
| 107 ResourcePtr<ScriptResource> m_resource; | 105 RefPtrWillBeMember<ScriptResource> m_resource; |
| 108 WTF::OrdinalNumber m_startLineNumber; | 106 WTF::OrdinalNumber m_startLineNumber; |
| 109 String m_characterEncoding; | 107 String m_characterEncoding; |
| 110 String m_fallbackCharacterEncoding; | 108 String m_fallbackCharacterEncoding; |
| 111 | 109 |
| 112 OwnPtrWillBeMember<PendingScript> m_pendingScript; | 110 OwnPtrWillBeMember<PendingScript> m_pendingScript; |
| 113 | 111 |
| 114 bool m_parserInserted : 1; | 112 bool m_parserInserted : 1; |
| 115 bool m_isExternalScript : 1; | 113 bool m_isExternalScript : 1; |
| 116 bool m_alreadyStarted : 1; | 114 bool m_alreadyStarted : 1; |
| 117 bool m_haveFiredLoad : 1; | 115 bool m_haveFiredLoad : 1; |
| 118 bool m_willBeParserExecuted : 1; // Same as "The parser will handle executin
g the script." | 116 bool m_willBeParserExecuted : 1; // Same as "The parser will handle executin
g the script." |
| 119 bool m_readyToBeParserExecuted : 1; | 117 bool m_readyToBeParserExecuted : 1; |
| 120 bool m_willExecuteWhenDocumentFinishedParsing : 1; | 118 bool m_willExecuteWhenDocumentFinishedParsing : 1; |
| 121 bool m_forceAsync : 1; | 119 bool m_forceAsync : 1; |
| 122 bool m_willExecuteInOrder : 1; | 120 bool m_willExecuteInOrder : 1; |
| 123 }; | 121 }; |
| 124 | 122 |
| 125 ScriptLoader* toScriptLoaderIfPossible(Element*); | 123 ScriptLoader* toScriptLoaderIfPossible(Element*); |
| 126 | 124 |
| 127 } // namespace blink | 125 } // namespace blink |
| 128 | 126 |
| 129 #endif // ScriptLoader_h | 127 #endif // ScriptLoader_h |
| OLD | NEW |