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 12 matching lines...) Expand all Loading... |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "bindings/core/v8/V8Binding.h" | 31 #include "bindings/core/v8/V8Binding.h" |
32 | 32 |
| 33 #include "bindings/core/v8/IsolatedScriptController.h" |
| 34 #include "bindings/core/v8/ModuleProxy.h" |
33 #include "bindings/core/v8/ScriptController.h" | 35 #include "bindings/core/v8/ScriptController.h" |
34 #include "bindings/core/v8/V8AbstractEventListener.h" | 36 #include "bindings/core/v8/V8AbstractEventListener.h" |
35 #include "bindings/core/v8/V8ArrayBufferView.h" | 37 #include "bindings/core/v8/V8ArrayBufferView.h" |
36 #include "bindings/core/v8/V8BindingMacros.h" | 38 #include "bindings/core/v8/V8BindingMacros.h" |
37 #include "bindings/core/v8/V8Element.h" | 39 #include "bindings/core/v8/V8Element.h" |
38 #include "bindings/core/v8/V8EventTarget.h" | 40 #include "bindings/core/v8/V8EventTarget.h" |
39 #include "bindings/core/v8/V8NodeFilter.h" | 41 #include "bindings/core/v8/V8NodeFilter.h" |
40 #include "bindings/core/v8/V8NodeFilterCondition.h" | 42 #include "bindings/core/v8/V8NodeFilterCondition.h" |
41 #include "bindings/core/v8/V8ObjectConstructor.h" | 43 #include "bindings/core/v8/V8ObjectConstructor.h" |
42 #include "bindings/core/v8/V8Window.h" | 44 #include "bindings/core/v8/V8Window.h" |
43 #include "bindings/core/v8/V8WorkerGlobalScope.h" | 45 #include "bindings/core/v8/V8WorkerGlobalScope.h" |
44 #include "bindings/core/v8/V8XPathNSResolver.h" | 46 #include "bindings/core/v8/V8XPathNSResolver.h" |
45 #include "bindings/core/v8/WindowProxy.h" | 47 #include "bindings/core/v8/WindowProxy.h" |
46 #include "bindings/core/v8/WorkerScriptController.h" | |
47 #include "bindings/core/v8/custom/V8CustomXPathNSResolver.h" | 48 #include "bindings/core/v8/custom/V8CustomXPathNSResolver.h" |
48 #include "core/dom/Document.h" | 49 #include "core/dom/Document.h" |
49 #include "core/dom/Element.h" | 50 #include "core/dom/Element.h" |
50 #include "core/dom/FlexibleArrayBufferView.h" | 51 #include "core/dom/FlexibleArrayBufferView.h" |
51 #include "core/dom/NodeFilter.h" | 52 #include "core/dom/NodeFilter.h" |
52 #include "core/dom/QualifiedName.h" | 53 #include "core/dom/QualifiedName.h" |
53 #include "core/frame/LocalDOMWindow.h" | 54 #include "core/frame/LocalDOMWindow.h" |
54 #include "core/frame/LocalFrame.h" | 55 #include "core/frame/LocalFrame.h" |
55 #include "core/frame/Settings.h" | 56 #include "core/frame/Settings.h" |
56 #include "core/inspector/InspectorTraceEvents.h" | 57 #include "core/inspector/InspectorTraceEvents.h" |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 { | 706 { |
706 if (context.IsEmpty()) | 707 if (context.IsEmpty()) |
707 return 0; | 708 return 0; |
708 v8::Local<v8::Object> global = context->Global(); | 709 v8::Local<v8::Object> global = context->Global(); |
709 v8::Local<v8::Object> windowWrapper = V8Window::findInstanceInPrototypeChain
(global, context->GetIsolate()); | 710 v8::Local<v8::Object> windowWrapper = V8Window::findInstanceInPrototypeChain
(global, context->GetIsolate()); |
710 if (!windowWrapper.IsEmpty()) | 711 if (!windowWrapper.IsEmpty()) |
711 return V8Window::toImpl(windowWrapper)->executionContext(); | 712 return V8Window::toImpl(windowWrapper)->executionContext(); |
712 v8::Local<v8::Object> workerWrapper = V8WorkerGlobalScope::findInstanceInPro
totypeChain(global, context->GetIsolate()); | 713 v8::Local<v8::Object> workerWrapper = V8WorkerGlobalScope::findInstanceInPro
totypeChain(global, context->GetIsolate()); |
713 if (!workerWrapper.IsEmpty()) | 714 if (!workerWrapper.IsEmpty()) |
714 return V8WorkerGlobalScope::toImpl(workerWrapper)->executionContext(); | 715 return V8WorkerGlobalScope::toImpl(workerWrapper)->executionContext(); |
715 // FIXME: Is this line of code reachable? | 716 return ModuleProxy::moduleProxy().toExecutionContextForModules(context); |
716 return 0; | |
717 } | 717 } |
718 | 718 |
719 ExecutionContext* currentExecutionContext(v8::Isolate* isolate) | 719 ExecutionContext* currentExecutionContext(v8::Isolate* isolate) |
720 { | 720 { |
721 return toExecutionContext(isolate->GetCurrentContext()); | 721 return toExecutionContext(isolate->GetCurrentContext()); |
722 } | 722 } |
723 | 723 |
724 ExecutionContext* callingExecutionContext(v8::Isolate* isolate) | 724 ExecutionContext* callingExecutionContext(v8::Isolate* isolate) |
725 { | 725 { |
726 v8::Local<v8::Context> context = isolate->GetCallingContext(); | 726 v8::Local<v8::Context> context = isolate->GetCallingContext(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 result.setSmall(storage, length); | 770 result.setSmall(storage, length); |
771 } | 771 } |
772 | 772 |
773 v8::Local<v8::Context> toV8Context(ExecutionContext* context, DOMWrapperWorld& w
orld) | 773 v8::Local<v8::Context> toV8Context(ExecutionContext* context, DOMWrapperWorld& w
orld) |
774 { | 774 { |
775 ASSERT(context); | 775 ASSERT(context); |
776 if (context->isDocument()) { | 776 if (context->isDocument()) { |
777 if (LocalFrame* frame = toDocument(context)->frame()) | 777 if (LocalFrame* frame = toDocument(context)->frame()) |
778 return toV8Context(frame, world); | 778 return toV8Context(frame, world); |
779 } else if (context->isWorkerGlobalScope()) { | 779 } else if (context->isWorkerGlobalScope()) { |
780 if (WorkerScriptController* script = toWorkerGlobalScope(context)->scrip
t()) { | 780 if (IsolatedScriptController* script = toWorkerGlobalScope(context)->scr
ipt()) { |
781 if (script->scriptState()->contextIsValid()) | 781 if (script->scriptState()->contextIsValid()) |
782 return script->scriptState()->context(); | 782 return script->scriptState()->context(); |
783 } | 783 } |
784 } | 784 } |
785 return v8::Local<v8::Context>(); | 785 return ModuleProxy::moduleProxy().toV8ContextForModules(context); |
786 } | 786 } |
787 | 787 |
788 v8::Local<v8::Context> toV8Context(Frame* frame, DOMWrapperWorld& world) | 788 v8::Local<v8::Context> toV8Context(Frame* frame, DOMWrapperWorld& world) |
789 { | 789 { |
790 if (!frame) | 790 if (!frame) |
791 return v8::Local<v8::Context>(); | 791 return v8::Local<v8::Context>(); |
792 v8::Local<v8::Context> context = toV8ContextEvenIfDetached(frame, world); | 792 v8::Local<v8::Context> context = toV8ContextEvenIfDetached(frame, world); |
793 ScriptState* scriptState = ScriptState::from(context); | 793 ScriptState* scriptState = ScriptState::from(context); |
794 if (scriptState->contextIsValid()) { | 794 if (scriptState->contextIsValid()) { |
795 ASSERT(toFrameIfNotDetached(context) == frame); | 795 ASSERT(toFrameIfNotDetached(context) == frame); |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1018 v8::Local<v8::Value> data = info.Data(); | 1018 v8::Local<v8::Value> data = info.Data(); |
1019 ASSERT(data->IsExternal()); | 1019 ASSERT(data->IsExternal()); |
1020 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->Cre
ationContext()); | 1020 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->Cre
ationContext()); |
1021 if (!perContextData) | 1021 if (!perContextData) |
1022 return; | 1022 return; |
1023 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u
nwrap(data))); | 1023 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u
nwrap(data))); |
1024 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); | 1024 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
1025 } | 1025 } |
1026 | 1026 |
1027 } // namespace blink | 1027 } // namespace blink |
OLD | NEW |