Chromium Code Reviews| 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/ScriptResource.h" | 28 #include "core/fetch/ScriptResource.h" |
| 29 #include "core/html/parser/HTMLConstructionSite.h" | |
| 29 #include "wtf/text/TextPosition.h" | 30 #include "wtf/text/TextPosition.h" |
| 30 #include "wtf/text/WTFString.h" | 31 #include "wtf/text/WTFString.h" |
| 31 | 32 |
| 32 namespace blink { | 33 namespace blink { |
| 33 | 34 |
| 34 class Element; | 35 class Element; |
| 35 class ScriptLoaderClient; | 36 class ScriptLoaderClient; |
| 36 class ScriptSourceCode; | 37 class ScriptSourceCode; |
| 37 class LocalFrame; | 38 class LocalFrame; |
| 38 | 39 |
| 40 enum ElementConstructionContextFlags { | |
|
kouhei (in TOK)
2016/04/05 13:20:45
Thanks for this change!
Would you use enum class
| |
| 41 DefaultContext = 0, | |
| 42 ParserInserted = 1 << 0, | |
| 43 AlreadyStarted = 1 << 1, | |
| 44 CreatedDuringDocumentWrite = 1 << 2, | |
| 45 }; | |
| 46 | |
| 39 class CORE_EXPORT ScriptLoader : public GarbageCollectedFinalized<ScriptLoader>, public ScriptResourceClient { | 47 class CORE_EXPORT ScriptLoader : public GarbageCollectedFinalized<ScriptLoader>, public ScriptResourceClient { |
| 40 public: | 48 public: |
| 41 static RawPtr<ScriptLoader> create(Element* element, bool createdByParser, b ool isEvaluated) | 49 static RawPtr<ScriptLoader> create(Element* element, int constructionContext Flags) |
| 42 { | 50 { |
| 43 return new ScriptLoader(element, createdByParser, isEvaluated); | 51 return new ScriptLoader(element, constructionContextFlags); |
| 44 } | 52 } |
| 45 | 53 |
| 46 ~ScriptLoader() override; | 54 ~ScriptLoader() override; |
| 47 DECLARE_VIRTUAL_TRACE(); | 55 DECLARE_VIRTUAL_TRACE(); |
| 48 | 56 |
| 49 Element* element() const { return m_element; } | 57 Element* element() const { return m_element; } |
| 50 | 58 |
| 51 enum LegacyTypeSupport { DisallowLegacyTypeInTypeAttribute, AllowLegacyTypeI nTypeAttribute }; | 59 enum LegacyTypeSupport { DisallowLegacyTypeInTypeAttribute, AllowLegacyTypeI nTypeAttribute }; |
| 52 bool prepareScript(const TextPosition& scriptStartPosition = TextPosition::m inimumPosition(), LegacyTypeSupport = DisallowLegacyTypeInTypeAttribute); | 60 bool prepareScript(const TextPosition& scriptStartPosition = TextPosition::m inimumPosition(), LegacyTypeSupport = DisallowLegacyTypeInTypeAttribute); |
| 53 | 61 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 78 void childrenChanged(); | 86 void childrenChanged(); |
| 79 void handleSourceAttribute(const String& sourceUrl); | 87 void handleSourceAttribute(const String& sourceUrl); |
| 80 void handleAsyncAttribute(); | 88 void handleAsyncAttribute(); |
| 81 | 89 |
| 82 virtual bool isReady() const { return m_pendingScript && m_pendingScript->is Ready(); } | 90 virtual bool isReady() const { return m_pendingScript && m_pendingScript->is Ready(); } |
| 83 bool errorOccurred() const { return m_pendingScript && m_pendingScript->erro rOccurred(); } | 91 bool errorOccurred() const { return m_pendingScript && m_pendingScript->erro rOccurred(); } |
| 84 | 92 |
| 85 // Clears the connection to the PendingScript (and Element and Resource). | 93 // Clears the connection to the PendingScript (and Element and Resource). |
| 86 void detach(); | 94 void detach(); |
| 87 | 95 |
| 96 bool wasCreatedDuringDocumentWrite() { return m_wasCreatedDuringDocumentWrit e; } | |
| 97 | |
| 88 protected: | 98 protected: |
| 89 ScriptLoader(Element*, bool createdByParser, bool isEvaluated); | 99 ScriptLoader(Element*, int constructionContextFlags); |
| 90 | 100 |
| 91 private: | 101 private: |
| 92 bool ignoresLoadRequest() const; | 102 bool ignoresLoadRequest() const; |
| 93 bool isScriptForEventSupported() const; | 103 bool isScriptForEventSupported() const; |
| 94 void logScriptMimetype(ScriptResource*, LocalFrame*, String); | 104 void logScriptMimetype(ScriptResource*, LocalFrame*, String); |
| 95 | 105 |
| 96 bool fetchScript(const String& sourceUrl, FetchRequest::DeferOption); | 106 bool fetchScript(const String& sourceUrl, FetchRequest::DeferOption); |
| 97 | 107 |
| 98 ScriptLoaderClient* client() const; | 108 ScriptLoaderClient* client() const; |
| 99 | 109 |
| 100 // ResourceClient | 110 // ResourceClient |
| 101 void notifyFinished(Resource*) override; | 111 void notifyFinished(Resource*) override; |
| 102 String debugName() const override { return "ScriptLoader"; } | 112 String debugName() const override { return "ScriptLoader"; } |
| 103 | 113 |
| 104 Member<Element> m_element; | 114 Member<Element> m_element; |
| 105 Member<ScriptResource> m_resource; | 115 Member<ScriptResource> m_resource; |
| 106 WTF::OrdinalNumber m_startLineNumber; | 116 WTF::OrdinalNumber m_startLineNumber; |
| 107 String m_characterEncoding; | 117 String m_characterEncoding; |
| 108 String m_fallbackCharacterEncoding; | 118 String m_fallbackCharacterEncoding; |
| 109 | 119 |
| 110 bool m_parserInserted : 1; | 120 bool m_parserInserted : 1; |
| 111 bool m_isExternalScript : 1; | 121 bool m_isExternalScript : 1; |
| 112 bool m_alreadyStarted : 1; | 122 bool m_alreadyStarted : 1; |
| 113 bool m_haveFiredLoad : 1; | 123 bool m_haveFiredLoad : 1; |
| 114 bool m_willBeParserExecuted : 1; // Same as "The parser will handle executin g the script." | 124 bool m_willBeParserExecuted : 1; // Same as "The parser will handle executin g the script." |
| 115 bool m_readyToBeParserExecuted : 1; | 125 bool m_readyToBeParserExecuted : 1; |
| 116 bool m_willExecuteInOrder : 1; | 126 bool m_willExecuteInOrder : 1; |
| 117 bool m_willExecuteWhenDocumentFinishedParsing : 1; | 127 bool m_willExecuteWhenDocumentFinishedParsing : 1; |
| 118 bool m_forceAsync : 1; | 128 bool m_forceAsync : 1; |
| 129 const bool m_wasCreatedDuringDocumentWrite : 1; | |
|
kouhei (in TOK)
2016/04/05 13:20:45
can we store constructioncontext instead of expand
| |
| 119 | 130 |
| 120 Member<PendingScript> m_pendingScript; | 131 Member<PendingScript> m_pendingScript; |
| 121 }; | 132 }; |
| 122 | 133 |
| 123 ScriptLoader* toScriptLoaderIfPossible(Element*); | 134 ScriptLoader* toScriptLoaderIfPossible(Element*); |
| 124 | 135 |
| 125 } // namespace blink | 136 } // namespace blink |
| 126 | 137 |
| 127 #endif // ScriptLoader_h | 138 #endif // ScriptLoader_h |
| OLD | NEW |