Chromium Code Reviews| 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. | |
|
Yuki
2017/01/05 13:21:26
I think this comment was very good.
haraken
2017/01/05 23:46:19
Done.
| |
| 308 if (!m_windowProxyManager->mainWorldProxy()->isGlobalInitialized()) | |
|
dcheng
2017/01/05 16:20:32
Note this is the only caller to isGlobalInitialize
| |
| 309 return; | |
| 310 | |
| 311 if (!initializeMainWorld()) | |
| 312 windowProxy(DOMWrapperWorld::mainWorld())->updateDocument(); | |
| 313 } | 301 } |
| 314 | 302 |
| 315 void ScriptController::namedItemAdded(HTMLDocument* doc, | 303 void ScriptController::namedItemAdded(HTMLDocument* doc, |
| 316 const AtomicString& name) { | 304 const AtomicString& name) { |
| 317 windowProxy(DOMWrapperWorld::mainWorld())->namedItemAdded(doc, name); | 305 windowProxy(DOMWrapperWorld::mainWorld())->namedItemAdded(doc, name); |
| 318 } | 306 } |
| 319 | 307 |
| 320 void ScriptController::namedItemRemoved(HTMLDocument* doc, | 308 void ScriptController::namedItemRemoved(HTMLDocument* doc, |
| 321 const AtomicString& name) { | 309 const AtomicString& name) { |
| 322 windowProxy(DOMWrapperWorld::mainWorld())->namedItemRemoved(doc, name); | 310 windowProxy(DOMWrapperWorld::mainWorld())->namedItemRemoved(doc, name); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 489 for (size_t i = 0; i < resultArray->Length(); ++i) { | 477 for (size_t i = 0; i < resultArray->Length(); ++i) { |
| 490 v8::Local<v8::Value> value; | 478 v8::Local<v8::Value> value; |
| 491 if (!resultArray->Get(scriptState->context(), i).ToLocal(&value)) | 479 if (!resultArray->Get(scriptState->context(), i).ToLocal(&value)) |
| 492 return; | 480 return; |
| 493 results->push_back(value); | 481 results->push_back(value); |
| 494 } | 482 } |
| 495 } | 483 } |
| 496 } | 484 } |
| 497 | 485 |
| 498 } // namespace blink | 486 } // namespace blink |
| OLD | NEW |