Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: WebCore/html/parser/HTMLScriptRunner.h

Issue 3776004: Revert 66670 - 2010-09-01 Tony Gentilcore <tonyg@chromium.org>... (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/517/
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « WebCore/html/parser/HTMLDocumentParser.cpp ('k') | WebCore/html/parser/HTMLScriptRunner.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #ifndef HTMLScriptRunner_h 26 #ifndef HTMLScriptRunner_h
27 #define HTMLScriptRunner_h 27 #define HTMLScriptRunner_h
28 28
29 #include "PendingScript.h" 29 #include "PendingScript.h"
30 #include <wtf/Deque.h>
31 #include <wtf/Noncopyable.h> 30 #include <wtf/Noncopyable.h>
32 #include <wtf/PassRefPtr.h> 31 #include <wtf/PassRefPtr.h>
33 32
34 namespace WebCore { 33 namespace WebCore {
35 34
36 class CachedResource; 35 class CachedResource;
37 class CachedScript; 36 class CachedScript;
38 class Document; 37 class Document;
39 class Element; 38 class Element;
40 class Frame; 39 class Frame;
41 class HTMLScriptRunnerHost; 40 class HTMLScriptRunnerHost;
42 class ScriptSourceCode; 41 class ScriptSourceCode;
43 42
44 class HTMLScriptRunner : public Noncopyable { 43 class HTMLScriptRunner : public Noncopyable {
45 public: 44 public:
46 static PassOwnPtr<HTMLScriptRunner> create(Document* document, HTMLScriptRun nerHost* host) 45 static PassOwnPtr<HTMLScriptRunner> create(Document* document, HTMLScriptRun nerHost* host)
47 { 46 {
48 return adoptPtr(new HTMLScriptRunner(document, host)); 47 return adoptPtr(new HTMLScriptRunner(document, host));
49 } 48 }
50 ~HTMLScriptRunner(); 49 ~HTMLScriptRunner();
51 50
52 void detach(); 51 void detach();
53 52
54 // Processes the passed in script and any pending scripts if possible. 53 // Processes the passed in script and any pending scripts if possible.
55 bool execute(PassRefPtr<Element> scriptToProcess, int scriptStartLine); 54 bool execute(PassRefPtr<Element> scriptToProcess, int scriptStartLine);
56 55
57 bool executeScriptsWaitingForLoad(CachedResource*); 56 bool executeScriptsWaitingForLoad(CachedResource*);
58 bool hasScriptsWaitingForStylesheets() const { return m_hasScriptsWaitingFor Stylesheets; } 57 bool hasScriptsWaitingForStylesheets() const { return m_hasScriptsWaitingFor Stylesheets; }
59 bool executeScriptsWaitingForStylesheets(); 58 bool executeScriptsWaitingForStylesheets();
60 bool executeScriptsWaitingForParsing();
61 59
62 bool isExecutingScript() const { return !!m_scriptNestingLevel; } 60 bool isExecutingScript() const { return !!m_scriptNestingLevel; }
63 61
64 private: 62 private:
65 HTMLScriptRunner(Document*, HTMLScriptRunnerHost*); 63 HTMLScriptRunner(Document*, HTMLScriptRunnerHost*);
66 64
67 Frame* frame() const; 65 Frame* frame() const;
68 66
69 void executeParsingBlockingScript(); 67 void executeParsingBlockingScript();
70 void executePendingScriptAndDispatchEvent(PendingScript&); 68 void executePendingScriptAndDispatchEvent(PendingScript&);
71 void executeScript(Element*, const ScriptSourceCode&) const; 69 void executeScript(Element*, const ScriptSourceCode&) const;
72 bool haveParsingBlockingScript() const; 70 bool haveParsingBlockingScript() const;
73 bool executeParsingBlockingScripts(); 71 bool executeParsingBlockingScripts();
74 72
75 void requestParsingBlockingScript(Element*); 73 void requestParsingBlockingScript(Element*);
76 void requestDeferredScript(Element*);
77 bool requestPendingScript(PendingScript&, Element*) const; 74 bool requestPendingScript(PendingScript&, Element*) const;
78 75
79 void runScript(Element*, int startingLineNumber); 76 void runScript(Element*, int startingLineNumber);
80 77
81 // Helpers for dealing with HTMLScriptRunnerHost 78 // Helpers for dealing with HTMLScriptRunnerHost
82 void watchForLoad(PendingScript&); 79 void watchForLoad(PendingScript&);
83 void stopWatchingForLoad(PendingScript&); 80 void stopWatchingForLoad(PendingScript&);
84 bool isPendingScriptReady(const PendingScript&); 81 bool isPendingScriptReady(const PendingScript&);
85 ScriptSourceCode sourceFromPendingScript(const PendingScript&, bool& errorOc curred) const; 82 ScriptSourceCode sourceFromPendingScript(const PendingScript&, bool& errorOc curred) const;
86 83
87 Document* m_document; 84 Document* m_document;
88 HTMLScriptRunnerHost* m_host; 85 HTMLScriptRunnerHost* m_host;
89 PendingScript m_parsingBlockingScript; 86 PendingScript m_parsingBlockingScript;
90 Deque<PendingScript> m_scriptsToExecuteAfterParsing; // http://www.whatwg.or g/specs/web-apps/current-work/#list-of-scripts-that-will-execute-when-the-docume nt-has-finished-parsing
91 unsigned m_scriptNestingLevel; 87 unsigned m_scriptNestingLevel;
92 88
93 // We only want stylesheet loads to trigger script execution if script 89 // We only want stylesheet loads to trigger script execution if script
94 // execution is currently stopped due to stylesheet loads, otherwise we'd 90 // execution is currently stopped due to stylesheet loads, otherwise we'd
95 // cause nested script execution when parsing <style> tags since </style> 91 // cause nested script execution when parsing <style> tags since </style>
96 // tags can cause Document to call executeScriptsWaitingForStylesheets. 92 // tags can cause Document to call executeScriptsWaitingForStylesheets.
97 bool m_hasScriptsWaitingForStylesheets; 93 bool m_hasScriptsWaitingForStylesheets;
98 }; 94 };
99 95
100 } 96 }
101 97
102 #endif 98 #endif
OLDNEW
« no previous file with comments | « WebCore/html/parser/HTMLDocumentParser.cpp ('k') | WebCore/html/parser/HTMLScriptRunner.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698