Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights |
| 6 * reserved. | 6 * reserved. |
| 7 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> | 7 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 229 if (!isScriptTypeSupported(supportLegacyTypes)) | 229 if (!isScriptTypeSupported(supportLegacyTypes)) |
| 230 return false; | 230 return false; |
| 231 | 231 |
| 232 if (wasParserInserted) { | 232 if (wasParserInserted) { |
| 233 m_parserInserted = true; | 233 m_parserInserted = true; |
| 234 m_forceAsync = false; | 234 m_forceAsync = false; |
| 235 } | 235 } |
| 236 | 236 |
| 237 m_alreadyStarted = true; | 237 m_alreadyStarted = true; |
| 238 | 238 |
| 239 // FIXME: Eventually we'd like to evaluate scripts which are inserted into a | |
| 240 // viewless document but this'll do for now. | |
| 241 // See http://bugs.webkit.org/show_bug.cgi?id=5727 | |
| 239 // FIXME: If script is parser inserted, verify it's still in the original | 242 // FIXME: If script is parser inserted, verify it's still in the original |
| 240 // document. | 243 // document. |
| 241 Document& elementDocument = m_element->document(); | 244 Document& elementDocument = m_element->document(); |
| 245 // TODO(kouhei): Remove the following check which doesn't make any sense. | |
| 246 if (!elementDocument.executingFrame()) | |
| 247 return false; | |
| 248 | |
| 242 Document* contextDocument = elementDocument.contextDocument(); | 249 Document* contextDocument = elementDocument.contextDocument(); |
| 250 if (!contextDocument) | |
| 251 return false; | |
| 243 | 252 |
| 244 if (!contextDocument || !contextDocument->allowExecutingScripts(m_element)) | 253 LocalFrame* contextFrame = contextDocument->executingFrame(); |
| 254 if (!contextFrame) | |
| 245 return false; | 255 return false; |
| 256 if (!contextFrame->script().canExecuteScripts(AboutToExecuteScript)) | |
| 257 return false; | |
| 258 | |
| 259 LocalFrame* elementFrame = elementDocument.frame(); | |
| 246 | 260 |
| 247 if (!isScriptForEventSupported()) | 261 if (!isScriptForEventSupported()) |
| 248 return false; | 262 return false; |
| 249 | 263 |
| 250 if (!client->charsetAttributeValue().isEmpty()) | 264 if (!client->charsetAttributeValue().isEmpty()) |
| 251 m_characterEncoding = client->charsetAttributeValue(); | 265 m_characterEncoding = client->charsetAttributeValue(); |
| 252 else | 266 else |
| 253 m_characterEncoding = elementDocument.characterSet(); | 267 m_characterEncoding = elementDocument.characterSet(); |
| 254 | 268 |
| 255 if (client->hasSourceAttribute()) { | 269 if (client->hasSourceAttribute()) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 289 !m_forceAsync) { | 303 !m_forceAsync) { |
| 290 m_pendingScript = PendingScript::create(m_element, m_resource.get()); | 304 m_pendingScript = PendingScript::create(m_element, m_resource.get()); |
| 291 m_asyncExecType = ScriptRunner::InOrder; | 305 m_asyncExecType = ScriptRunner::InOrder; |
| 292 contextDocument->scriptRunner()->queueScriptForExecution(this, | 306 contextDocument->scriptRunner()->queueScriptForExecution(this, |
| 293 m_asyncExecType); | 307 m_asyncExecType); |
| 294 // Note that watchForLoad can immediately call pendingScriptFinished. | 308 // Note that watchForLoad can immediately call pendingScriptFinished. |
| 295 m_pendingScript->watchForLoad(this); | 309 m_pendingScript->watchForLoad(this); |
| 296 } else if (client->hasSourceAttribute()) { | 310 } else if (client->hasSourceAttribute()) { |
| 297 m_pendingScript = PendingScript::create(m_element, m_resource.get()); | 311 m_pendingScript = PendingScript::create(m_element, m_resource.get()); |
| 298 m_asyncExecType = ScriptRunner::Async; | 312 m_asyncExecType = ScriptRunner::Async; |
| 299 LocalFrame* frame = m_element->document().frame(); | 313 if (elementFrame) { |
|
Yuki
2017/01/20 07:23:51
nit: I thought you can declare |elementFrame| here
kouhei (in TOK)
2017/01/20 09:09:02
Let me remove the elementFrame right away in the f
| |
| 300 if (frame) { | 314 // TODO(kouhei): I'm not sure below is correct. I think we should use |
| 301 ScriptState* scriptState = ScriptState::forMainWorld(frame); | 315 // contextFrame rather than elementFrame. |
| 302 if (scriptState) | 316 ScriptState* scriptState = ScriptState::forMainWorld(elementFrame); |
| 317 if (scriptState) { | |
| 303 ScriptStreamer::startStreaming( | 318 ScriptStreamer::startStreaming( |
| 304 m_pendingScript.get(), ScriptStreamer::Async, frame->settings(), | 319 m_pendingScript.get(), ScriptStreamer::Async, |
| 305 scriptState, frame->frameScheduler()->loadingTaskRunner()); | 320 elementFrame->settings(), scriptState, |
| 321 elementFrame->frameScheduler()->loadingTaskRunner()); | |
| 322 } | |
| 306 } | 323 } |
| 307 contextDocument->scriptRunner()->queueScriptForExecution(this, | 324 contextDocument->scriptRunner()->queueScriptForExecution(this, |
| 308 m_asyncExecType); | 325 m_asyncExecType); |
| 309 // Note that watchForLoad can immediately call pendingScriptFinished. | 326 // Note that watchForLoad can immediately call pendingScriptFinished. |
| 310 m_pendingScript->watchForLoad(this); | 327 m_pendingScript->watchForLoad(this); |
| 311 } else { | 328 } else { |
| 312 // Reset line numbering for nested writes. | 329 // Reset line numbering for nested writes. |
| 313 TextPosition position = elementDocument.isInDocumentWrite() | 330 TextPosition position = elementDocument.isInDocumentWrite() |
| 314 ? TextPosition() | 331 ? TextPosition() |
| 315 : scriptStartPosition; | 332 : scriptStartPosition; |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 649 if (isHTMLScriptLoader(element)) | 666 if (isHTMLScriptLoader(element)) |
| 650 return toHTMLScriptElement(element)->loader(); | 667 return toHTMLScriptElement(element)->loader(); |
| 651 | 668 |
| 652 if (isSVGScriptLoader(element)) | 669 if (isSVGScriptLoader(element)) |
| 653 return toSVGScriptElement(element)->loader(); | 670 return toSVGScriptElement(element)->loader(); |
| 654 | 671 |
| 655 return 0; | 672 return 0; |
| 656 } | 673 } |
| 657 | 674 |
| 658 } // namespace blink | 675 } // namespace blink |
| OLD | NEW |