OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 namespace blink { | 36 namespace blink { |
37 | 37 |
38 class Resource; | 38 class Resource; |
39 class Document; | 39 class Document; |
40 class Element; | 40 class Element; |
41 class HTMLScriptRunnerHost; | 41 class HTMLScriptRunnerHost; |
42 | 42 |
43 class HTMLScriptRunner final : public NoBaseWillBeGarbageCollectedFinalized<HTML
ScriptRunner>, private ScriptResourceClient { | 43 class HTMLScriptRunner final : public NoBaseWillBeGarbageCollectedFinalized<HTML
ScriptRunner>, private ScriptResourceClient { |
44 WTF_MAKE_NONCOPYABLE(HTMLScriptRunner); USING_FAST_MALLOC_WILL_BE_REMOVED(HT
MLScriptRunner); | 44 WTF_MAKE_NONCOPYABLE(HTMLScriptRunner); USING_FAST_MALLOC_WILL_BE_REMOVED(HT
MLScriptRunner); |
| 45 WILL_BE_USING_PRE_FINALIZER(HTMLScriptRunner, detach); |
45 public: | 46 public: |
46 static PassOwnPtrWillBeRawPtr<HTMLScriptRunner> create(Document* document, H
TMLScriptRunnerHost* host) | 47 static PassOwnPtrWillBeRawPtr<HTMLScriptRunner> create(Document* document, H
TMLScriptRunnerHost* host) |
47 { | 48 { |
48 return adoptPtrWillBeNoop(new HTMLScriptRunner(document, host)); | 49 return adoptPtrWillBeNoop(new HTMLScriptRunner(document, host)); |
49 } | 50 } |
50 ~HTMLScriptRunner(); | 51 ~HTMLScriptRunner(); |
51 | 52 |
52 void detach(); | 53 void detach(); |
53 | 54 |
54 // Processes the passed in script and any pending scripts if possible. | 55 // Processes the passed in script and any pending scripts if possible. |
(...skipping 10 matching lines...) Expand all Loading... |
65 // ResourceClient | 66 // ResourceClient |
66 void notifyFinished(Resource*) override; | 67 void notifyFinished(Resource*) override; |
67 String debugName() const override { return "HTMLScriptRunner"; } | 68 String debugName() const override { return "HTMLScriptRunner"; } |
68 | 69 |
69 DECLARE_TRACE(); | 70 DECLARE_TRACE(); |
70 | 71 |
71 private: | 72 private: |
72 HTMLScriptRunner(Document*, HTMLScriptRunnerHost*); | 73 HTMLScriptRunner(Document*, HTMLScriptRunnerHost*); |
73 | 74 |
74 void executeParsingBlockingScript(); | 75 void executeParsingBlockingScript(); |
75 void executePendingScriptAndDispatchEvent(PendingScript&, PendingScript::Typ
e); | 76 void executePendingScriptAndDispatchEvent(PendingScript*, PendingScript::Typ
e); |
76 void executeParsingBlockingScripts(); | 77 void executeParsingBlockingScripts(); |
77 | 78 |
78 void requestParsingBlockingScript(Element*); | 79 void requestParsingBlockingScript(Element*); |
79 void requestDeferredScript(Element*); | 80 void requestDeferredScript(Element*); |
80 bool requestPendingScript(PendingScript&, Element*) const; | 81 bool requestPendingScript(PendingScript*, Element*) const; |
81 | 82 |
82 void runScript(Element*, const TextPosition& scriptStartPosition); | 83 void runScript(Element*, const TextPosition& scriptStartPosition); |
83 | 84 |
84 bool isPendingScriptReady(const PendingScript&); | 85 bool isPendingScriptReady(const PendingScript*); |
85 | 86 |
86 void stopWatchingResourceForLoad(Resource*); | 87 void stopWatchingResourceForLoad(Resource*); |
87 | 88 |
88 RawPtrWillBeMember<Document> m_document; | 89 RawPtrWillBeMember<Document> m_document; |
89 RawPtrWillBeMember<HTMLScriptRunnerHost> m_host; | 90 RawPtrWillBeMember<HTMLScriptRunnerHost> m_host; |
90 PendingScript m_parserBlockingScript; | 91 OwnPtrWillBeMember<PendingScript> m_parserBlockingScript; |
91 // http://www.whatwg.org/specs/web-apps/current-work/#list-of-scripts-that-w
ill-execute-when-the-document-has-finished-parsing | 92 // http://www.whatwg.org/specs/web-apps/current-work/#list-of-scripts-that-w
ill-execute-when-the-document-has-finished-parsing |
92 WillBeHeapDeque<PendingScript> m_scriptsToExecuteAfterParsing; | 93 WillBeHeapDeque<OwnPtrWillBeMember<PendingScript>> m_scriptsToExecuteAfterPa
rsing; |
93 unsigned m_scriptNestingLevel; | 94 unsigned m_scriptNestingLevel; |
94 | 95 |
95 // We only want stylesheet loads to trigger script execution if script | 96 // We only want stylesheet loads to trigger script execution if script |
96 // execution is currently stopped due to stylesheet loads, otherwise we'd | 97 // execution is currently stopped due to stylesheet loads, otherwise we'd |
97 // cause nested script execution when parsing <style> tags since </style> | 98 // cause nested script execution when parsing <style> tags since </style> |
98 // tags can cause Document to call executeScriptsWaitingForResources. | 99 // tags can cause Document to call executeScriptsWaitingForResources. |
99 bool m_hasScriptsWaitingForResources; | 100 bool m_hasScriptsWaitingForResources; |
100 | 101 |
101 // For tracking the times between script load and compilation, we need to | 102 // For tracking the times between script load and compilation, we need to |
102 // know whether a parser blocking script was loaded previously, or whether | 103 // know whether a parser blocking script was loaded previously, or whether |
103 // it's really loaded when requested. | 104 // it's really loaded when requested. |
104 bool m_parserBlockingScriptAlreadyLoaded; | 105 bool m_parserBlockingScriptAlreadyLoaded; |
105 }; | 106 }; |
106 | 107 |
107 } | 108 } |
108 | 109 |
109 #endif | 110 #endif |
OLD | NEW |