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 12 matching lines...) Expand all Loading... |
23 | 23 |
24 #include "core/fetch/ResourceClient.h" | 24 #include "core/fetch/ResourceClient.h" |
25 #include "core/fetch/ResourcePtr.h" | 25 #include "core/fetch/ResourcePtr.h" |
26 #include "wtf/text/TextPosition.h" | 26 #include "wtf/text/TextPosition.h" |
27 #include "wtf/text/WTFString.h" | 27 #include "wtf/text/WTFString.h" |
28 | 28 |
29 namespace WebCore { | 29 namespace WebCore { |
30 | 30 |
31 class ScriptResource; | 31 class ScriptResource; |
32 class ContainerNode; | 32 class ContainerNode; |
| 33 class Document; |
33 class Element; | 34 class Element; |
34 class ScriptLoaderClient; | 35 class ScriptLoaderClient; |
35 class ScriptSourceCode; | 36 class ScriptSourceCode; |
36 | 37 |
37 | 38 |
38 class ScriptLoader FINAL : private ResourceClient { | 39 class ScriptLoader FINAL : private ResourceClient { |
39 public: | 40 public: |
40 static PassOwnPtr<ScriptLoader> create(Element*, bool createdByParser, bool
isEvaluated); | 41 static PassOwnPtr<ScriptLoader> create(Element*, bool createdByParser, bool
isEvaluated); |
41 virtual ~ScriptLoader(); | 42 virtual ~ScriptLoader(); |
42 | 43 |
(...skipping 21 matching lines...) Expand all Loading... |
64 void setHaveFiredLoadEvent(bool haveFiredLoad) { m_haveFiredLoad = haveFired
Load; } | 65 void setHaveFiredLoadEvent(bool haveFiredLoad) { m_haveFiredLoad = haveFired
Load; } |
65 bool isParserInserted() const { return m_parserInserted; } | 66 bool isParserInserted() const { return m_parserInserted; } |
66 bool alreadyStarted() const { return m_alreadyStarted; } | 67 bool alreadyStarted() const { return m_alreadyStarted; } |
67 bool forceAsync() const { return m_forceAsync; } | 68 bool forceAsync() const { return m_forceAsync; } |
68 | 69 |
69 // Helper functions used by our parent classes. | 70 // Helper functions used by our parent classes. |
70 void didNotifySubtreeInsertionsToDocument(); | 71 void didNotifySubtreeInsertionsToDocument(); |
71 void childrenChanged(); | 72 void childrenChanged(); |
72 void handleSourceAttribute(const String& sourceUrl); | 73 void handleSourceAttribute(const String& sourceUrl); |
73 void handleAsyncAttribute(); | 74 void handleAsyncAttribute(); |
| 75 void cancel(Document* contextDocument); |
74 | 76 |
75 private: | 77 private: |
76 ScriptLoader(Element*, bool createdByParser, bool isEvaluated); | 78 ScriptLoader(Element*, bool createdByParser, bool isEvaluated); |
77 | 79 |
78 bool ignoresLoadRequest() const; | 80 bool ignoresLoadRequest() const; |
79 bool isScriptForEventSupported() const; | 81 bool isScriptForEventSupported() const; |
80 | 82 |
81 bool fetchScript(const String& sourceUrl); | 83 bool fetchScript(const String& sourceUrl); |
82 void stopLoadRequest(); | 84 void stopLoadRequest(); |
83 | 85 |
84 ScriptLoaderClient* client() const; | 86 ScriptLoaderClient* client() const; |
85 | 87 |
86 // ResourceClient | 88 // ResourceClient |
87 virtual void notifyFinished(Resource*) OVERRIDE; | 89 virtual void notifyFinished(Resource*) OVERRIDE; |
88 | 90 |
| 91 enum FinishType { |
| 92 FinishSuccessfully, |
| 93 FinishWithErrorOrCancel |
| 94 }; |
| 95 |
| 96 void finishLoading(Document* contextDocument, FinishType); |
| 97 |
89 Element* m_element; | 98 Element* m_element; |
90 ResourcePtr<ScriptResource> m_resource; | 99 ResourcePtr<ScriptResource> m_resource; |
91 WTF::OrdinalNumber m_startLineNumber; | 100 WTF::OrdinalNumber m_startLineNumber; |
92 bool m_parserInserted : 1; | 101 bool m_parserInserted : 1; |
93 bool m_isExternalScript : 1; | 102 bool m_isExternalScript : 1; |
94 bool m_alreadyStarted : 1; | 103 bool m_alreadyStarted : 1; |
95 bool m_haveFiredLoad : 1; | 104 bool m_haveFiredLoad : 1; |
96 bool m_willBeParserExecuted : 1; // Same as "The parser will handle executin
g the script." | 105 bool m_willBeParserExecuted : 1; // Same as "The parser will handle executin
g the script." |
97 bool m_readyToBeParserExecuted : 1; | 106 bool m_readyToBeParserExecuted : 1; |
98 bool m_willExecuteWhenDocumentFinishedParsing : 1; | 107 bool m_willExecuteWhenDocumentFinishedParsing : 1; |
99 bool m_forceAsync : 1; | 108 bool m_forceAsync : 1; |
100 bool m_willExecuteInOrder : 1; | 109 bool m_willExecuteInOrder : 1; |
101 String m_characterEncoding; | 110 String m_characterEncoding; |
102 String m_fallbackCharacterEncoding; | 111 String m_fallbackCharacterEncoding; |
103 }; | 112 }; |
104 | 113 |
105 ScriptLoader* toScriptLoaderIfPossible(Element*); | 114 ScriptLoader* toScriptLoaderIfPossible(Element*); |
106 | 115 |
107 inline PassOwnPtr<ScriptLoader> ScriptLoader::create(Element* element, bool crea
tedByParser, bool isEvaluated) | 116 inline PassOwnPtr<ScriptLoader> ScriptLoader::create(Element* element, bool crea
tedByParser, bool isEvaluated) |
108 { | 117 { |
109 return adoptPtr(new ScriptLoader(element, createdByParser, isEvaluated)); | 118 return adoptPtr(new ScriptLoader(element, createdByParser, isEvaluated)); |
110 } | 119 } |
111 | 120 |
112 } | 121 } |
113 | 122 |
114 | 123 |
115 #endif | 124 #endif |
OLD | NEW |