| 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 23 matching lines...) Expand all Loading... |
| 34 #include "wtf/PassRefPtr.h" | 34 #include "wtf/PassRefPtr.h" |
| 35 #include "wtf/text/TextPosition.h" | 35 #include "wtf/text/TextPosition.h" |
| 36 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 | 38 |
| 39 class Resource; | 39 class Resource; |
| 40 class Document; | 40 class Document; |
| 41 class Element; | 41 class Element; |
| 42 class HTMLScriptRunnerHost; | 42 class HTMLScriptRunnerHost; |
| 43 | 43 |
| 44 class HTMLScriptRunner final : public NoBaseWillBeGarbageCollectedFinalized<HTML
ScriptRunner>, private ScriptResourceClient { | 44 class HTMLScriptRunner final : public GarbageCollectedFinalized<HTMLScriptRunner
>, private ScriptResourceClient { |
| 45 WTF_MAKE_NONCOPYABLE(HTMLScriptRunner); USING_FAST_MALLOC_WILL_BE_REMOVED(HT
MLScriptRunner); | 45 WTF_MAKE_NONCOPYABLE(HTMLScriptRunner); |
| 46 WILL_BE_USING_PRE_FINALIZER(HTMLScriptRunner, detach); | 46 USING_PRE_FINALIZER(HTMLScriptRunner, detach); |
| 47 public: | 47 public: |
| 48 static PassOwnPtrWillBeRawPtr<HTMLScriptRunner> create(Document* document, H
TMLScriptRunnerHost* host) | 48 static RawPtr<HTMLScriptRunner> create(Document* document, HTMLScriptRunnerH
ost* host) |
| 49 { | 49 { |
| 50 return adoptPtrWillBeNoop(new HTMLScriptRunner(document, host)); | 50 return new HTMLScriptRunner(document, host); |
| 51 } | 51 } |
| 52 ~HTMLScriptRunner(); | 52 ~HTMLScriptRunner(); |
| 53 | 53 |
| 54 void detach(); | 54 void detach(); |
| 55 | 55 |
| 56 // Processes the passed in script and any pending scripts if possible. | 56 // Processes the passed in script and any pending scripts if possible. |
| 57 void execute(PassRefPtrWillBeRawPtr<Element> scriptToProcess, const TextPosi
tion& scriptStartPosition); | 57 void execute(RawPtr<Element> scriptToProcess, const TextPosition& scriptStar
tPosition); |
| 58 | 58 |
| 59 void executeScriptsWaitingForLoad(Resource*); | 59 void executeScriptsWaitingForLoad(Resource*); |
| 60 bool hasScriptsWaitingForResources() const { return m_hasScriptsWaitingForRe
sources; } | 60 bool hasScriptsWaitingForResources() const { return m_hasScriptsWaitingForRe
sources; } |
| 61 void executeScriptsWaitingForResources(); | 61 void executeScriptsWaitingForResources(); |
| 62 bool executeScriptsWaitingForParsing(); | 62 bool executeScriptsWaitingForParsing(); |
| 63 | 63 |
| 64 bool hasParserBlockingScript() const; | 64 bool hasParserBlockingScript() const; |
| 65 bool isExecutingScript() const { return !!m_scriptNestingLevel; } | 65 bool isExecutingScript() const { return !!m_scriptNestingLevel; } |
| 66 | 66 |
| 67 // ResourceClient | 67 // ResourceClient |
| (...skipping 12 matching lines...) Expand all Loading... |
| 80 void requestParsingBlockingScript(Element*); | 80 void requestParsingBlockingScript(Element*); |
| 81 void requestDeferredScript(Element*); | 81 void requestDeferredScript(Element*); |
| 82 bool requestPendingScript(PendingScript*, Element*) const; | 82 bool requestPendingScript(PendingScript*, Element*) const; |
| 83 | 83 |
| 84 void runScript(Element*, const TextPosition& scriptStartPosition); | 84 void runScript(Element*, const TextPosition& scriptStartPosition); |
| 85 | 85 |
| 86 bool isPendingScriptReady(const PendingScript*); | 86 bool isPendingScriptReady(const PendingScript*); |
| 87 | 87 |
| 88 void stopWatchingResourceForLoad(Resource*); | 88 void stopWatchingResourceForLoad(Resource*); |
| 89 | 89 |
| 90 RawPtrWillBeMember<Document> m_document; | 90 Member<Document> m_document; |
| 91 RawPtrWillBeMember<HTMLScriptRunnerHost> m_host; | 91 Member<HTMLScriptRunnerHost> m_host; |
| 92 OwnPtrWillBeMember<PendingScript> m_parserBlockingScript; | 92 Member<PendingScript> m_parserBlockingScript; |
| 93 // http://www.whatwg.org/specs/web-apps/current-work/#list-of-scripts-that-w
ill-execute-when-the-document-has-finished-parsing | 93 // http://www.whatwg.org/specs/web-apps/current-work/#list-of-scripts-that-w
ill-execute-when-the-document-has-finished-parsing |
| 94 WillBeHeapDeque<OwnPtrWillBeMember<PendingScript>> m_scriptsToExecuteAfterPa
rsing; | 94 HeapDeque<Member<PendingScript>> m_scriptsToExecuteAfterParsing; |
| 95 unsigned m_scriptNestingLevel; | 95 unsigned m_scriptNestingLevel; |
| 96 | 96 |
| 97 // We only want stylesheet loads to trigger script execution if script | 97 // We only want stylesheet loads to trigger script execution if script |
| 98 // execution is currently stopped due to stylesheet loads, otherwise we'd | 98 // execution is currently stopped due to stylesheet loads, otherwise we'd |
| 99 // cause nested script execution when parsing <style> tags since </style> | 99 // cause nested script execution when parsing <style> tags since </style> |
| 100 // tags can cause Document to call executeScriptsWaitingForResources. | 100 // tags can cause Document to call executeScriptsWaitingForResources. |
| 101 bool m_hasScriptsWaitingForResources; | 101 bool m_hasScriptsWaitingForResources; |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 } // namespace blink | 104 } // namespace blink |
| 105 | 105 |
| 106 #endif | 106 #endif |
| OLD | NEW |