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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 // For an uninitialized main window windowProxy, do not incur the cost of |
| 307 // context initialization. | 301 // context initialization. |
| 308 if (!m_windowProxyManager->mainWorldProxy()->isGlobalInitialized()) | 302 if (!m_windowProxyManager->mainWorldProxy()->isGlobalInitialized()) |
| 309 return; | 303 return; |
| 310 | 304 |
| 311 if (!initializeMainWorld()) | 305 if (m_windowProxyManager->mainWorldProxy()->isContextInitialized()) { |
| 312 windowProxy(DOMWrapperWorld::mainWorld())->updateDocument(); | 306 m_windowProxyManager->mainWorldProxy()->updateDocument(); |
| 307 return; | |
| 308 } | |
|
Yuki
2017/01/05 12:10:06
Do we really need the below code? If so, in what
| |
| 309 windowProxy(DOMWrapperWorld::mainWorld()); | |
|
Yuki
2017/01/05 12:10:06
I know that |windowProxy(world)| initializes a Win
| |
| 310 if (!m_windowProxyManager->mainWorldProxy()->isContextInitialized()) { | |
|
Yuki
2017/01/05 12:10:06
You made WindowProxy::initialize{,IfNeeded} always
| |
| 311 m_windowProxyManager->mainWorldProxy()->updateDocument(); | |
| 312 return; | |
| 313 } | |
| 313 } | 314 } |
| 314 | 315 |
| 315 void ScriptController::namedItemAdded(HTMLDocument* doc, | 316 void ScriptController::namedItemAdded(HTMLDocument* doc, |
| 316 const AtomicString& name) { | 317 const AtomicString& name) { |
| 317 windowProxy(DOMWrapperWorld::mainWorld())->namedItemAdded(doc, name); | 318 windowProxy(DOMWrapperWorld::mainWorld())->namedItemAdded(doc, name); |
| 318 } | 319 } |
| 319 | 320 |
| 320 void ScriptController::namedItemRemoved(HTMLDocument* doc, | 321 void ScriptController::namedItemRemoved(HTMLDocument* doc, |
| 321 const AtomicString& name) { | 322 const AtomicString& name) { |
| 322 windowProxy(DOMWrapperWorld::mainWorld())->namedItemRemoved(doc, name); | 323 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) { | 490 for (size_t i = 0; i < resultArray->Length(); ++i) { |
| 490 v8::Local<v8::Value> value; | 491 v8::Local<v8::Value> value; |
| 491 if (!resultArray->Get(scriptState->context(), i).ToLocal(&value)) | 492 if (!resultArray->Get(scriptState->context(), i).ToLocal(&value)) |
| 492 return; | 493 return; |
| 493 results->push_back(value); | 494 results->push_back(value); |
| 494 } | 495 } |
| 495 } | 496 } |
| 496 } | 497 } |
| 497 | 498 |
| 498 } // namespace blink | 499 } // namespace blink |
| OLD | NEW |