| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "V8DOMStringList.h" | 42 #include "V8DOMStringList.h" |
| 43 #include "V8DOMWindow.h" | 43 #include "V8DOMWindow.h" |
| 44 #include "V8Element.h" | 44 #include "V8Element.h" |
| 45 #include "V8NodeFilterCondition.h" | 45 #include "V8NodeFilterCondition.h" |
| 46 #include "V8ObjectConstructor.h" | 46 #include "V8ObjectConstructor.h" |
| 47 #include "V8WorkerContext.h" | 47 #include "V8WorkerContext.h" |
| 48 #include "V8XPathNSResolver.h" | 48 #include "V8XPathNSResolver.h" |
| 49 #include "WebCoreMemoryInstrumentation.h" | 49 #include "WebCoreMemoryInstrumentation.h" |
| 50 #include "WorkerContext.h" | 50 #include "WorkerContext.h" |
| 51 #include "WorkerScriptController.h" | 51 #include "WorkerScriptController.h" |
| 52 #include "WorldContextHandle.h" | |
| 53 #include "XPathNSResolver.h" | 52 #include "XPathNSResolver.h" |
| 54 #include <wtf/MathExtras.h> | 53 #include <wtf/MathExtras.h> |
| 55 #include <wtf/MainThread.h> | 54 #include <wtf/MainThread.h> |
| 56 #include <wtf/StdLibExtras.h> | 55 #include <wtf/StdLibExtras.h> |
| 57 #include <wtf/Threading.h> | 56 #include <wtf/Threading.h> |
| 58 #include <wtf/text/AtomicString.h> | 57 #include <wtf/text/AtomicString.h> |
| 59 #include <wtf/text/CString.h> | 58 #include <wtf/text/CString.h> |
| 60 #include <wtf/text/StringBuffer.h> | 59 #include <wtf/text/StringBuffer.h> |
| 61 #include <wtf/text/StringHash.h> | 60 #include <wtf/text/StringHash.h> |
| 62 #include <wtf/text/WTFString.h> | 61 #include <wtf/text/WTFString.h> |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 { | 322 { |
| 324 DOMWindow* window = toDOMWindow(context); | 323 DOMWindow* window = toDOMWindow(context); |
| 325 if (window->isCurrentlyDisplayedInFrame()) | 324 if (window->isCurrentlyDisplayedInFrame()) |
| 326 return window->frame(); | 325 return window->frame(); |
| 327 // We return 0 here because |context| is detached from the Frame. If we | 326 // We return 0 here because |context| is detached from the Frame. If we |
| 328 // did return |frame| we could get in trouble because the frame could be | 327 // did return |frame| we could get in trouble because the frame could be |
| 329 // navigated to another security origin. | 328 // navigated to another security origin. |
| 330 return 0; | 329 return 0; |
| 331 } | 330 } |
| 332 | 331 |
| 333 v8::Local<v8::Context> toV8Context(ScriptExecutionContext* context, const WorldC
ontextHandle& worldContext) | |
| 334 { | |
| 335 if (context->isDocument()) { | |
| 336 if (Frame* frame = toDocument(context)->frame()) | |
| 337 return worldContext.adjustedContext(frame->script()); | |
| 338 } else if (context->isWorkerContext()) { | |
| 339 if (WorkerScriptController* script = static_cast<WorkerContext*>(context
)->script()) | |
| 340 return script->context(); | |
| 341 } | |
| 342 return v8::Local<v8::Context>(); | |
| 343 } | |
| 344 | |
| 345 v8::Local<v8::Context> toV8Context(ScriptExecutionContext* context, DOMWrapperWo
rld* world) | 332 v8::Local<v8::Context> toV8Context(ScriptExecutionContext* context, DOMWrapperWo
rld* world) |
| 346 { | 333 { |
| 347 if (context->isDocument()) { | 334 if (context->isDocument()) { |
| 348 ASSERT(world); | 335 ASSERT(world); |
| 349 if (Frame* frame = toDocument(context)->frame()) | 336 if (Frame* frame = toDocument(context)->frame()) |
| 350 return v8::Local<v8::Context>::New(frame->script()->windowShell(worl
d)->context()); | 337 return v8::Local<v8::Context>::New(frame->script()->windowShell(worl
d)->context()); |
| 351 } else if (context->isWorkerContext()) { | 338 } else if (context->isWorkerContext()) { |
| 352 ASSERT(!world); | 339 ASSERT(!world); |
| 353 if (WorkerScriptController* script = static_cast<WorkerContext*>(context
)->script()) | 340 if (WorkerScriptController* script = static_cast<WorkerContext*>(context
)->script()) |
| 354 return script->context(); | 341 return script->context(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 if (!DOMWrapperWorld::isolatedWorldsExist()) | 392 if (!DOMWrapperWorld::isolatedWorldsExist()) |
| 406 return MainWorld; | 393 return MainWorld; |
| 407 ASSERT(!v8::Context::GetEntered().IsEmpty()); | 394 ASSERT(!v8::Context::GetEntered().IsEmpty()); |
| 408 DOMWrapperWorld* isolatedWorld = DOMWrapperWorld::isolatedWorld(v8::Context:
:GetEntered()); | 395 DOMWrapperWorld* isolatedWorld = DOMWrapperWorld::isolatedWorld(v8::Context:
:GetEntered()); |
| 409 if (isolatedWorld) | 396 if (isolatedWorld) |
| 410 return IsolatedWorld; | 397 return IsolatedWorld; |
| 411 return MainWorld; | 398 return MainWorld; |
| 412 } | 399 } |
| 413 | 400 |
| 414 } // namespace WebCore | 401 } // namespace WebCore |
| OLD | NEW |