| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Apple Inc. All rights reserved. | 3 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 4 * Copyright (C) 2014 Opera Software ASA. All rights reserved. | 4 * Copyright (C) 2014 Opera Software ASA. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions are | 7 * modification, are permitted provided that the following conditions are |
| 8 * met: | 8 * met: |
| 9 * | 9 * |
| 10 * * Redistributions of source code must retain the above copyright | 10 * * Redistributions of source code must retain the above copyright |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 V8ScriptRunner::runCompiledScript( | 202 V8ScriptRunner::runCompiledScript( |
| 203 isolate(), compiledScript.script(isolate()), frame()->document()), | 203 isolate(), compiledScript.script(isolate()), frame()->document()), |
| 204 result, tryCatch)) | 204 result, tryCatch)) |
| 205 return; | 205 return; |
| 206 | 206 |
| 207 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), | 207 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), |
| 208 "UpdateCounters", TRACE_EVENT_SCOPE_THREAD, "data", | 208 "UpdateCounters", TRACE_EVENT_SCOPE_THREAD, "data", |
| 209 InspectorUpdateCountersEvent::data()); | 209 InspectorUpdateCountersEvent::data()); |
| 210 } | 210 } |
| 211 | 211 |
| 212 bool ScriptController::initializeMainWorld() { | |
| 213 if (m_windowProxyManager->mainWorldProxy()->isContextInitialized()) | |
| 214 return false; | |
| 215 return windowProxy(DOMWrapperWorld::mainWorld())->isContextInitialized(); | |
| 216 } | |
| 217 | |
| 218 WindowProxy* ScriptController::windowProxy(DOMWrapperWorld& world) { | 212 WindowProxy* ScriptController::windowProxy(DOMWrapperWorld& world) { |
| 219 WindowProxy* windowProxy = m_windowProxyManager->windowProxy(world); | 213 WindowProxy* windowProxy = m_windowProxyManager->windowProxy(world); |
| 220 if (!windowProxy->isContextInitialized()) { | 214 if (!windowProxy->isContextInitialized()) { |
| 221 windowProxy->initializeIfNeeded(); | 215 windowProxy->initializeIfNeeded(); |
| 222 if (world.isMainWorld()) | 216 if (world.isMainWorld()) |
| 223 frame()->loader().dispatchDidClearWindowObjectInMainWorld(); | 217 frame()->loader().dispatchDidClearWindowObjectInMainWorld(); |
| 224 } | 218 } |
| 225 return windowProxy; | 219 return windowProxy; |
| 226 } | 220 } |
| 227 | 221 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 } | 290 } |
| 297 | 291 |
| 298 void ScriptController::clearWindowProxy() { | 292 void ScriptController::clearWindowProxy() { |
| 299 // V8 binding expects ScriptController::clearWindowProxy only be called when a | 293 // V8 binding expects ScriptController::clearWindowProxy only be called when a |
| 300 // frame is loading a new page. This creates a new context for the new page. | 294 // frame is loading a new page. This creates a new context for the new page. |
| 301 m_windowProxyManager->clearForNavigation(); | 295 m_windowProxyManager->clearForNavigation(); |
| 302 MainThreadDebugger::instance()->didClearContextsForFrame(frame()); | 296 MainThreadDebugger::instance()->didClearContextsForFrame(frame()); |
| 303 } | 297 } |
| 304 | 298 |
| 305 void ScriptController::updateDocument() { | 299 void ScriptController::updateDocument() { |
| 306 // For an uninitialized main window windowProxy, do not incur the cost of | 300 m_windowProxyManager->mainWorldProxy()->updateDocument(); |
| 307 // context initialization. | |
| 308 if (!m_windowProxyManager->mainWorldProxy()->isGlobalInitialized()) | |
| 309 return; | |
| 310 | |
| 311 if (!initializeMainWorld()) | |
| 312 windowProxy(DOMWrapperWorld::mainWorld())->updateDocument(); | |
| 313 } | 301 } |
| 314 | 302 |
| 315 bool ScriptController::canExecuteScripts( | 303 bool ScriptController::canExecuteScripts( |
| 316 ReasonForCallingCanExecuteScripts reason) { | 304 ReasonForCallingCanExecuteScripts reason) { |
| 317 | 305 |
| 318 if (frame()->document() && frame()->document()->isSandboxed(SandboxScripts)) { | 306 if (frame()->document() && frame()->document()->isSandboxed(SandboxScripts)) { |
| 319 // FIXME: This message should be moved off the console once a solution to | 307 // FIXME: This message should be moved off the console once a solution to |
| 320 // https://bugs.webkit.org/show_bug.cgi?id=103274 exists. | 308 // https://bugs.webkit.org/show_bug.cgi?id=103274 exists. |
| 321 if (reason == AboutToExecuteScript) | 309 if (reason == AboutToExecuteScript) |
| 322 frame()->document()->addConsoleMessage(ConsoleMessage::create( | 310 frame()->document()->addConsoleMessage(ConsoleMessage::create( |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 for (size_t i = 0; i < resultArray->Length(); ++i) { | 467 for (size_t i = 0; i < resultArray->Length(); ++i) { |
| 480 v8::Local<v8::Value> value; | 468 v8::Local<v8::Value> value; |
| 481 if (!resultArray->Get(scriptState->context(), i).ToLocal(&value)) | 469 if (!resultArray->Get(scriptState->context(), i).ToLocal(&value)) |
| 482 return; | 470 return; |
| 483 results->push_back(value); | 471 results->push_back(value); |
| 484 } | 472 } |
| 485 } | 473 } |
| 486 } | 474 } |
| 487 | 475 |
| 488 } // namespace blink | 476 } // namespace blink |
| OLD | NEW |