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

Side by Side Diff: third_party/WebKit/Source/core/dom/ScriptLoader.cpp

Issue 2640983005: Inline Document::allowExecutingScripts logic (Closed)
Patch Set: Streamer fix Created 3 years, 11 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 | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | no next file » | 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) 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
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();
242 Document* contextDocument = elementDocument.contextDocument(); 245 Document* contextDocument = elementDocument.contextDocument();
246 if (!contextDocument)
247 return false;
243 248
244 if (!contextDocument || !contextDocument->allowExecutingScripts(m_element)) 249 LocalFrame* contextFrame = contextDocument->executingFrame();
250 if (!contextFrame)
251 return false;
252 LocalFrame* elementFrame = elementDocument.frame();
Yuki 2017/01/20 06:15:17 question: This was elementDocument.executingFrame(
kouhei (in TOK) 2017/01/20 06:19:03 No? We still use contextFrame to chck which is exe
Yuki 2017/01/20 06:24:36 Oops, I was misreading. Let me revise my question
253 if (!contextFrame->script().canExecuteScripts(AboutToExecuteScript))
245 return false; 254 return false;
246 255
247 if (!isScriptForEventSupported()) 256 if (!isScriptForEventSupported())
248 return false; 257 return false;
249 258
250 if (!client->charsetAttributeValue().isEmpty()) 259 if (!client->charsetAttributeValue().isEmpty())
251 m_characterEncoding = client->charsetAttributeValue(); 260 m_characterEncoding = client->charsetAttributeValue();
252 else 261 else
253 m_characterEncoding = elementDocument.characterSet(); 262 m_characterEncoding = elementDocument.characterSet();
254 263
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 !m_forceAsync) { 298 !m_forceAsync) {
290 m_pendingScript = PendingScript::create(m_element, m_resource.get()); 299 m_pendingScript = PendingScript::create(m_element, m_resource.get());
291 m_asyncExecType = ScriptRunner::InOrder; 300 m_asyncExecType = ScriptRunner::InOrder;
292 contextDocument->scriptRunner()->queueScriptForExecution(this, 301 contextDocument->scriptRunner()->queueScriptForExecution(this,
293 m_asyncExecType); 302 m_asyncExecType);
294 // Note that watchForLoad can immediately call pendingScriptFinished. 303 // Note that watchForLoad can immediately call pendingScriptFinished.
295 m_pendingScript->watchForLoad(this); 304 m_pendingScript->watchForLoad(this);
296 } else if (client->hasSourceAttribute()) { 305 } else if (client->hasSourceAttribute()) {
297 m_pendingScript = PendingScript::create(m_element, m_resource.get()); 306 m_pendingScript = PendingScript::create(m_element, m_resource.get());
298 m_asyncExecType = ScriptRunner::Async; 307 m_asyncExecType = ScriptRunner::Async;
299 LocalFrame* frame = m_element->document().frame(); 308 if (elementFrame) {
300 if (frame) { 309 // TODO(kouhei): I'm not sure below is correct. I think we should use
301 ScriptState* scriptState = ScriptState::forMainWorld(frame); 310 // contextFrame rather than elementFrame.
302 if (scriptState) 311 ScriptState* scriptState = ScriptState::forMainWorld(elementFrame);
312 if (scriptState) {
303 ScriptStreamer::startStreaming( 313 ScriptStreamer::startStreaming(
304 m_pendingScript.get(), ScriptStreamer::Async, frame->settings(), 314 m_pendingScript.get(), ScriptStreamer::Async,
305 scriptState, frame->frameScheduler()->loadingTaskRunner()); 315 elementFrame->settings(), scriptState,
316 elementFrame->frameScheduler()->loadingTaskRunner());
317 }
306 } 318 }
307 contextDocument->scriptRunner()->queueScriptForExecution(this, 319 contextDocument->scriptRunner()->queueScriptForExecution(this,
308 m_asyncExecType); 320 m_asyncExecType);
309 // Note that watchForLoad can immediately call pendingScriptFinished. 321 // Note that watchForLoad can immediately call pendingScriptFinished.
310 m_pendingScript->watchForLoad(this); 322 m_pendingScript->watchForLoad(this);
311 } else { 323 } else {
312 // Reset line numbering for nested writes. 324 // Reset line numbering for nested writes.
313 TextPosition position = elementDocument.isInDocumentWrite() 325 TextPosition position = elementDocument.isInDocumentWrite()
314 ? TextPosition() 326 ? TextPosition()
315 : scriptStartPosition; 327 : scriptStartPosition;
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 if (isHTMLScriptLoader(element)) 661 if (isHTMLScriptLoader(element))
650 return toHTMLScriptElement(element)->loader(); 662 return toHTMLScriptElement(element)->loader();
651 663
652 if (isSVGScriptLoader(element)) 664 if (isSVGScriptLoader(element))
653 return toSVGScriptElement(element)->loader(); 665 return toSVGScriptElement(element)->loader();
654 666
655 return 0; 667 return 0;
656 } 668 }
657 669
658 } // namespace blink 670 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698