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

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

Issue 2648753002: Revert of Inline Document::allowExecutingScripts logic (Closed)
Patch Set: 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
242 // FIXME: If script is parser inserted, verify it's still in the original 239 // FIXME: If script is parser inserted, verify it's still in the original
243 // document. 240 // document.
244 Document& elementDocument = m_element->document(); 241 Document& elementDocument = m_element->document();
245 // TODO(kouhei): Remove the following check which doesn't make any sense. 242 Document* contextDocument = elementDocument.contextDocument();
246 if (!elementDocument.executingFrame()) 243
244 if (!contextDocument || !contextDocument->allowExecutingScripts(m_element))
247 return false; 245 return false;
248 246
249 Document* contextDocument = elementDocument.contextDocument();
250 if (!contextDocument)
251 return false;
252
253 LocalFrame* contextFrame = contextDocument->executingFrame();
254 if (!contextFrame)
255 return false;
256 if (!contextFrame->script().canExecuteScripts(AboutToExecuteScript))
257 return false;
258
259 LocalFrame* elementFrame = elementDocument.frame();
260
261 if (!isScriptForEventSupported()) 247 if (!isScriptForEventSupported())
262 return false; 248 return false;
263 249
264 if (!client->charsetAttributeValue().isEmpty()) 250 if (!client->charsetAttributeValue().isEmpty())
265 m_characterEncoding = client->charsetAttributeValue(); 251 m_characterEncoding = client->charsetAttributeValue();
266 else 252 else
267 m_characterEncoding = elementDocument.characterSet(); 253 m_characterEncoding = elementDocument.characterSet();
268 254
269 if (client->hasSourceAttribute()) { 255 if (client->hasSourceAttribute()) {
270 FetchRequest::DeferOption defer = FetchRequest::NoDefer; 256 FetchRequest::DeferOption defer = FetchRequest::NoDefer;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 !m_forceAsync) { 289 !m_forceAsync) {
304 m_pendingScript = PendingScript::create(m_element, m_resource.get()); 290 m_pendingScript = PendingScript::create(m_element, m_resource.get());
305 m_asyncExecType = ScriptRunner::InOrder; 291 m_asyncExecType = ScriptRunner::InOrder;
306 contextDocument->scriptRunner()->queueScriptForExecution(this, 292 contextDocument->scriptRunner()->queueScriptForExecution(this,
307 m_asyncExecType); 293 m_asyncExecType);
308 // Note that watchForLoad can immediately call pendingScriptFinished. 294 // Note that watchForLoad can immediately call pendingScriptFinished.
309 m_pendingScript->watchForLoad(this); 295 m_pendingScript->watchForLoad(this);
310 } else if (client->hasSourceAttribute()) { 296 } else if (client->hasSourceAttribute()) {
311 m_pendingScript = PendingScript::create(m_element, m_resource.get()); 297 m_pendingScript = PendingScript::create(m_element, m_resource.get());
312 m_asyncExecType = ScriptRunner::Async; 298 m_asyncExecType = ScriptRunner::Async;
313 if (elementFrame) { 299 LocalFrame* frame = m_element->document().frame();
314 // TODO(kouhei): I'm not sure below is correct. I think we should use 300 if (frame) {
315 // contextFrame rather than elementFrame. 301 ScriptState* scriptState = ScriptState::forMainWorld(frame);
316 ScriptState* scriptState = ScriptState::forMainWorld(elementFrame); 302 if (scriptState)
317 if (scriptState) {
318 ScriptStreamer::startStreaming( 303 ScriptStreamer::startStreaming(
319 m_pendingScript.get(), ScriptStreamer::Async, 304 m_pendingScript.get(), ScriptStreamer::Async, frame->settings(),
320 elementFrame->settings(), scriptState, 305 scriptState, frame->frameScheduler()->loadingTaskRunner());
321 elementFrame->frameScheduler()->loadingTaskRunner());
322 }
323 } 306 }
324 contextDocument->scriptRunner()->queueScriptForExecution(this, 307 contextDocument->scriptRunner()->queueScriptForExecution(this,
325 m_asyncExecType); 308 m_asyncExecType);
326 // Note that watchForLoad can immediately call pendingScriptFinished. 309 // Note that watchForLoad can immediately call pendingScriptFinished.
327 m_pendingScript->watchForLoad(this); 310 m_pendingScript->watchForLoad(this);
328 } else { 311 } else {
329 // Reset line numbering for nested writes. 312 // Reset line numbering for nested writes.
330 TextPosition position = elementDocument.isInDocumentWrite() 313 TextPosition position = elementDocument.isInDocumentWrite()
331 ? TextPosition() 314 ? TextPosition()
332 : scriptStartPosition; 315 : scriptStartPosition;
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 if (isHTMLScriptLoader(element)) 649 if (isHTMLScriptLoader(element))
667 return toHTMLScriptElement(element)->loader(); 650 return toHTMLScriptElement(element)->loader();
668 651
669 if (isSVGScriptLoader(element)) 652 if (isSVGScriptLoader(element))
670 return toSVGScriptElement(element)->loader(); 653 return toSVGScriptElement(element)->loader();
671 654
672 return 0; 655 return 0;
673 } 656 }
674 657
675 } // namespace blink 658 } // 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