| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 } | 304 } |
| 305 | 305 |
| 306 DOMWindow* toDOMWindow(v8::Handle<v8::Context> context) | 306 DOMWindow* toDOMWindow(v8::Handle<v8::Context> context) |
| 307 { | 307 { |
| 308 v8::Handle<v8::Object> global = context->Global(); | 308 v8::Handle<v8::Object> global = context->Global(); |
| 309 ASSERT(!global.IsEmpty()); | 309 ASSERT(!global.IsEmpty()); |
| 310 v8::Handle<v8::Object> window = global->FindInstanceInPrototypeChain(V8DOMWi
ndow::GetTemplate(context->GetIsolate(), MainWorld)); | 310 v8::Handle<v8::Object> window = global->FindInstanceInPrototypeChain(V8DOMWi
ndow::GetTemplate(context->GetIsolate(), MainWorld)); |
| 311 if (!window.IsEmpty()) | 311 if (!window.IsEmpty()) |
| 312 return V8DOMWindow::toNative(window); | 312 return V8DOMWindow::toNative(window); |
| 313 window = global->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(conte
xt->GetIsolate(), IsolatedWorld)); | 313 window = global->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(conte
xt->GetIsolate(), IsolatedWorld)); |
| 314 if (window.IsEmpty()) { |
| 315 // TODO(jacobr): find a better solution. |
| 316 return toDOMWindow(v8::Context::GetEntered()); |
| 317 } |
| 314 ASSERT(!window.IsEmpty()); | 318 ASSERT(!window.IsEmpty()); |
| 315 return V8DOMWindow::toNative(window); | 319 return V8DOMWindow::toNative(window); |
| 316 } | 320 } |
| 317 | 321 |
| 318 ScriptExecutionContext* toScriptExecutionContext(v8::Handle<v8::Context> context
) | 322 ScriptExecutionContext* toScriptExecutionContext(v8::Handle<v8::Context> context
) |
| 319 { | 323 { |
| 320 v8::Handle<v8::Object> global = context->Global(); | 324 v8::Handle<v8::Object> global = context->Global(); |
| 321 v8::Handle<v8::Object> windowWrapper = global->FindInstanceInPrototypeChain(
V8DOMWindow::GetTemplate(context->GetIsolate(), MainWorld)); | 325 v8::Handle<v8::Object> windowWrapper = global->FindInstanceInPrototypeChain(
V8DOMWindow::GetTemplate(context->GetIsolate(), MainWorld)); |
| 322 if (!windowWrapper.IsEmpty()) | 326 if (!windowWrapper.IsEmpty()) |
| 323 return V8DOMWindow::toNative(windowWrapper)->scriptExecutionContext(); | 327 return V8DOMWindow::toNative(windowWrapper)->scriptExecutionContext(); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 if (!DOMWrapperWorld::isolatedWorldsExist()) | 431 if (!DOMWrapperWorld::isolatedWorldsExist()) |
| 428 return MainWorld; | 432 return MainWorld; |
| 429 ASSERT(!v8::Context::GetEntered().IsEmpty()); | 433 ASSERT(!v8::Context::GetEntered().IsEmpty()); |
| 430 DOMWrapperWorld* isolatedWorld = DOMWrapperWorld::isolatedWorld(v8::Context:
:GetEntered()); | 434 DOMWrapperWorld* isolatedWorld = DOMWrapperWorld::isolatedWorld(v8::Context:
:GetEntered()); |
| 431 if (isolatedWorld) | 435 if (isolatedWorld) |
| 432 return IsolatedWorld; | 436 return IsolatedWorld; |
| 433 return MainWorld; | 437 return MainWorld; |
| 434 } | 438 } |
| 435 | 439 |
| 436 } // namespace WebCore | 440 } // namespace WebCore |
| OLD | NEW |