|
Lines 36-41
a/Source/WebCore/html/parser/HTMLScriptRunner.cpp_sec1
|
| 36 |
#include "HTMLNames.h" |
36 |
#include "HTMLNames.h" |
| 37 |
#include "HTMLScriptRunnerHost.h" |
37 |
#include "HTMLScriptRunnerHost.h" |
| 38 |
#include "IgnoreDestructiveWriteCountIncrementer.h" |
38 |
#include "IgnoreDestructiveWriteCountIncrementer.h" |
|
|
39 |
#include "MutationObserver.h" |
| 39 |
#include "NestingLevelIncrementer.h" |
40 |
#include "NestingLevelIncrementer.h" |
| 40 |
#include "NotImplemented.h" |
41 |
#include "NotImplemented.h" |
| 41 |
#include "ScriptElement.h" |
42 |
#include "ScriptElement.h" |
|
Lines 110-116
bool HTMLScriptRunner::isPendingScriptReady(const PendingScript& script)
a/Source/WebCore/html/parser/HTMLScriptRunner.cpp_sec2
|
| 110 |
void HTMLScriptRunner::executeParsingBlockingScript() |
111 |
void HTMLScriptRunner::executeParsingBlockingScript() |
| 111 |
{ |
112 |
{ |
| 112 |
ASSERT(m_document); |
113 |
ASSERT(m_document); |
| 113 |
ASSERT(!m_scriptNestingLevel); |
114 |
ASSERT(!isExecutingScript()); |
| 114 |
ASSERT(m_document->haveStylesheetsLoaded()); |
115 |
ASSERT(m_document->haveStylesheetsLoaded()); |
| 115 |
ASSERT(isPendingScriptReady(m_parserBlockingScript)); |
116 |
ASSERT(isPendingScriptReady(m_parserBlockingScript)); |
| 116 |
|
117 |
|
|
Lines 127-132
void HTMLScriptRunner::executePendingScriptAndDispatchEvent(PendingScript& pendi
a/Source/WebCore/html/parser/HTMLScriptRunner.cpp_sec3
|
| 127 |
if (pendingScript.cachedScript() && pendingScript.watchingForLoad()) |
128 |
if (pendingScript.cachedScript() && pendingScript.watchingForLoad()) |
| 128 |
stopWatchingForLoad(pendingScript); |
129 |
stopWatchingForLoad(pendingScript); |
| 129 |
|
130 |
|
|
|
131 |
if (!isExecutingScript()) |
| 132 |
MutationObserver::deliverAllMutations(); |
| 133 |
|
| 130 |
// Clear the pending script before possible rentrancy from executeScript() |
134 |
// Clear the pending script before possible rentrancy from executeScript() |
| 131 |
RefPtr<Element> element = pendingScript.releaseElementAndClear(); |
135 |
RefPtr<Element> element = pendingScript.releaseElementAndClear(); |
| 132 |
if (ScriptElement* scriptElement = toScriptElement(element.get())) { |
136 |
if (ScriptElement* scriptElement = toScriptElement(element.get())) { |
|
Lines 140-146
void HTMLScriptRunner::executePendingScriptAndDispatchEvent(PendingScript& pendi
a/Source/WebCore/html/parser/HTMLScriptRunner.cpp_sec4
|
| 140 |
element->dispatchEvent(createScriptLoadEvent()); |
144 |
element->dispatchEvent(createScriptLoadEvent()); |
| 141 |
} |
145 |
} |
| 142 |
} |
146 |
} |
| 143 |
ASSERT(!m_scriptNestingLevel); |
147 |
ASSERT(!isExecutingScript()); |
| 144 |
} |
148 |
} |
| 145 |
|
149 |
|
| 146 |
void HTMLScriptRunner::watchForLoad(PendingScript& pendingScript) |
150 |
void HTMLScriptRunner::watchForLoad(PendingScript& pendingScript) |
|
Lines 170-176
void HTMLScriptRunner::execute(PassRefPtr<Element> scriptElement, const TextPosi
a/Source/WebCore/html/parser/HTMLScriptRunner.cpp_sec5
|
| 170 |
runScript(scriptElement.get(), scriptStartPosition); |
174 |
runScript(scriptElement.get(), scriptStartPosition); |
| 171 |
|
175 |
|
| 172 |
if (hasParserBlockingScript()) { |
176 |
if (hasParserBlockingScript()) { |
| 173 |
if (m_scriptNestingLevel) |
177 |
if (isExecutingScript()) |
| 174 |
return; // Unwind to the outermost HTMLScriptRunner::execute before continuing parsing. |
178 |
return; // Unwind to the outermost HTMLScriptRunner::execute before continuing parsing. |
| 175 |
// If preload scanner got created, it is missing the source after the current insertion point. Append it and scan. |
179 |
// If preload scanner got created, it is missing the source after the current insertion point. Append it and scan. |
| 176 |
if (!hadPreloadScanner && m_host->hasPreloadScanner()) |
180 |
if (!hadPreloadScanner && m_host->hasPreloadScanner()) |
|
Lines 192-198
void HTMLScriptRunner::executeParsingBlockingScripts()
a/Source/WebCore/html/parser/HTMLScriptRunner.cpp_sec6
|
| 192 |
|
196 |
|
| 193 |
void HTMLScriptRunner::executeScriptsWaitingForLoad(CachedResource* cachedScript) |
197 |
void HTMLScriptRunner::executeScriptsWaitingForLoad(CachedResource* cachedScript) |
| 194 |
{ |
198 |
{ |
| 195 |
ASSERT(!m_scriptNestingLevel); |
199 |
ASSERT(!isExecutingScript()); |
| 196 |
ASSERT(hasParserBlockingScript()); |
200 |
ASSERT(hasParserBlockingScript()); |
| 197 |
ASSERT_UNUSED(cachedScript, m_parserBlockingScript.cachedScript() == cachedScript); |
201 |
ASSERT_UNUSED(cachedScript, m_parserBlockingScript.cachedScript() == cachedScript); |
| 198 |
ASSERT(m_parserBlockingScript.cachedScript()->isLoaded()); |
202 |
ASSERT(m_parserBlockingScript.cachedScript()->isLoaded()); |
|
Lines 205-211
void HTMLScriptRunner::executeScriptsWaitingForStylesheets()
a/Source/WebCore/html/parser/HTMLScriptRunner.cpp_sec7
|
| 205 |
// Callers should check hasScriptsWaitingForStylesheets() before calling |
209 |
// Callers should check hasScriptsWaitingForStylesheets() before calling |
| 206 |
// to prevent parser or script re-entry during </style> parsing. |
210 |
// to prevent parser or script re-entry during </style> parsing. |
| 207 |
ASSERT(hasScriptsWaitingForStylesheets()); |
211 |
ASSERT(hasScriptsWaitingForStylesheets()); |
| 208 |
ASSERT(!m_scriptNestingLevel); |
212 |
ASSERT(!isExecutingScript()); |
| 209 |
ASSERT(m_document->haveStylesheetsLoaded()); |
213 |
ASSERT(m_document->haveStylesheetsLoaded()); |
| 210 |
executeParsingBlockingScripts(); |
214 |
executeParsingBlockingScripts(); |
| 211 |
} |
215 |
} |
|
Lines 213-219
void HTMLScriptRunner::executeScriptsWaitingForStylesheets()
a/Source/WebCore/html/parser/HTMLScriptRunner.cpp_sec8
|
| 213 |
bool HTMLScriptRunner::executeScriptsWaitingForParsing() |
217 |
bool HTMLScriptRunner::executeScriptsWaitingForParsing() |
| 214 |
{ |
218 |
{ |
| 215 |
while (!m_scriptsToExecuteAfterParsing.isEmpty()) { |
219 |
while (!m_scriptsToExecuteAfterParsing.isEmpty()) { |
| 216 |
ASSERT(!m_scriptNestingLevel); |
220 |
ASSERT(!isExecutingScript()); |
| 217 |
ASSERT(!hasParserBlockingScript()); |
221 |
ASSERT(!hasParserBlockingScript()); |
| 218 |
ASSERT(m_scriptsToExecuteAfterParsing.first().cachedScript()); |
222 |
ASSERT(m_scriptsToExecuteAfterParsing.first().cachedScript()); |
| 219 |
if (!m_scriptsToExecuteAfterParsing.first().cachedScript()->isLoaded()) { |
223 |
if (!m_scriptsToExecuteAfterParsing.first().cachedScript()->isLoaded()) { |
|
Lines 274-282
void HTMLScriptRunner::runScript(Element* script, const TextPosition& scriptStar
a/Source/WebCore/html/parser/HTMLScriptRunner.cpp_sec9
|
| 274 |
ASSERT(m_document); |
278 |
ASSERT(m_document); |
| 275 |
ASSERT(!hasParserBlockingScript()); |
279 |
ASSERT(!hasParserBlockingScript()); |
| 276 |
{ |
280 |
{ |
| 277 |
InsertionPointRecord insertionPointRecord(m_host->inputStream()); |
|
|
| 278 |
NestingLevelIncrementer nestingLevelIncrementer(m_scriptNestingLevel); |
| 279 |
|
| 280 |
ScriptElement* scriptElement = toScriptElement(script); |
281 |
ScriptElement* scriptElement = toScriptElement(script); |
| 281 |
|
282 |
|
| 282 |
// This contains both and ASSERTION and a null check since we should not |
283 |
// This contains both and ASSERTION and a null check since we should not |
|
Lines 287-292
void HTMLScriptRunner::runScript(Element* script, const TextPosition& scriptStar
a/Source/WebCore/html/parser/HTMLScriptRunner.cpp_sec10
|
| 287 |
if (!scriptElement) |
288 |
if (!scriptElement) |
| 288 |
return; |
289 |
return; |
| 289 |
|
290 |
|
|
|
291 |
// FIXME: This may be too agressive as we always deliver mutations at |
| 292 |
// every script element, even if it's not ready to execute yet. There's |
| 293 |
// unfortuantely no obvious way to tell if prepareScript is going to |
| 294 |
// execute the script from out here. |
| 295 |
if (!isExecutingScript()) |
| 296 |
MutationObserver::deliverAllMutations(); |
| 297 |
|
| 298 |
InsertionPointRecord insertionPointRecord(m_host->inputStream()); |
| 299 |
NestingLevelIncrementer nestingLevelIncrementer(m_scriptNestingLevel); |
| 300 |
|
| 290 |
scriptElement->prepareScript(scriptStartPosition); |
301 |
scriptElement->prepareScript(scriptStartPosition); |
| 291 |
|
302 |
|
| 292 |
if (!scriptElement->willBeParserExecuted()) |
303 |
if (!scriptElement->willBeParserExecuted()) |