| 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/GlobalScopeScriptController.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" |
| 57 #include "core/loader/FrameLoader.h" | 58 #include "core/loader/FrameLoader.h" |
| 58 #include "core/loader/FrameLoaderClient.h" | 59 #include "core/loader/FrameLoaderClient.h" |
| 59 #include "core/workers/WorkerGlobalScope.h" | |
| 60 #include "core/xml/XPathNSResolver.h" | 60 #include "core/xml/XPathNSResolver.h" |
| 61 #include "platform/EventTracer.h" | 61 #include "platform/EventTracer.h" |
| 62 #include "platform/JSONValues.h" | 62 #include "platform/JSONValues.h" |
| 63 #include "wtf/MainThread.h" | 63 #include "wtf/MainThread.h" |
| 64 #include "wtf/MathExtras.h" | 64 #include "wtf/MathExtras.h" |
| 65 #include "wtf/StdLibExtras.h" | 65 #include "wtf/StdLibExtras.h" |
| 66 #include "wtf/Threading.h" | 66 #include "wtf/Threading.h" |
| 67 #include "wtf/text/AtomicString.h" | 67 #include "wtf/text/AtomicString.h" |
| 68 #include "wtf/text/CString.h" | 68 #include "wtf/text/CString.h" |
| 69 #include "wtf/text/CharacterNames.h" | 69 #include "wtf/text/CharacterNames.h" |
| (...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 { | 705 { |
| 706 if (context.IsEmpty()) | 706 if (context.IsEmpty()) |
| 707 return 0; | 707 return 0; |
| 708 v8::Local<v8::Object> global = context->Global(); | 708 v8::Local<v8::Object> global = context->Global(); |
| 709 v8::Local<v8::Object> windowWrapper = V8Window::findInstanceInPrototypeChain
(global, context->GetIsolate()); | 709 v8::Local<v8::Object> windowWrapper = V8Window::findInstanceInPrototypeChain
(global, context->GetIsolate()); |
| 710 if (!windowWrapper.IsEmpty()) | 710 if (!windowWrapper.IsEmpty()) |
| 711 return V8Window::toImpl(windowWrapper)->executionContext(); | 711 return V8Window::toImpl(windowWrapper)->executionContext(); |
| 712 v8::Local<v8::Object> workerWrapper = V8WorkerGlobalScope::findInstanceInPro
totypeChain(global, context->GetIsolate()); | 712 v8::Local<v8::Object> workerWrapper = V8WorkerGlobalScope::findInstanceInPro
totypeChain(global, context->GetIsolate()); |
| 713 if (!workerWrapper.IsEmpty()) | 713 if (!workerWrapper.IsEmpty()) |
| 714 return V8WorkerGlobalScope::toImpl(workerWrapper)->executionContext(); | 714 return V8WorkerGlobalScope::toImpl(workerWrapper)->executionContext(); |
| 715 // FIXME: Is this line of code reachable? | 715 return ModuleProxy::moduleProxy().toExecutionContextForModules(context); |
| 716 return 0; | |
| 717 } | 716 } |
| 718 | 717 |
| 719 ExecutionContext* currentExecutionContext(v8::Isolate* isolate) | 718 ExecutionContext* currentExecutionContext(v8::Isolate* isolate) |
| 720 { | 719 { |
| 721 return toExecutionContext(isolate->GetCurrentContext()); | 720 return toExecutionContext(isolate->GetCurrentContext()); |
| 722 } | 721 } |
| 723 | 722 |
| 724 ExecutionContext* callingExecutionContext(v8::Isolate* isolate) | 723 ExecutionContext* callingExecutionContext(v8::Isolate* isolate) |
| 725 { | 724 { |
| 726 v8::Local<v8::Context> context = isolate->GetCallingContext(); | 725 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); | 769 result.setSmall(storage, length); |
| 771 } | 770 } |
| 772 | 771 |
| 773 v8::Local<v8::Context> toV8Context(ExecutionContext* context, DOMWrapperWorld& w
orld) | 772 v8::Local<v8::Context> toV8Context(ExecutionContext* context, DOMWrapperWorld& w
orld) |
| 774 { | 773 { |
| 775 ASSERT(context); | 774 ASSERT(context); |
| 776 if (context->isDocument()) { | 775 if (context->isDocument()) { |
| 777 if (LocalFrame* frame = toDocument(context)->frame()) | 776 if (LocalFrame* frame = toDocument(context)->frame()) |
| 778 return toV8Context(frame, world); | 777 return toV8Context(frame, world); |
| 779 } else if (context->isWorkerGlobalScope()) { | 778 } else if (context->isWorkerGlobalScope()) { |
| 780 if (WorkerScriptController* script = toWorkerGlobalScope(context)->scrip
t()) { | 779 if (GlobalScopeScriptController* script = toWorkerGlobalScope(context)->
script()) { |
| 781 if (script->scriptState()->contextIsValid()) | 780 if (script->scriptState()->contextIsValid()) |
| 782 return script->scriptState()->context(); | 781 return script->scriptState()->context(); |
| 783 } | 782 } |
| 784 } | 783 } |
| 785 return v8::Local<v8::Context>(); | 784 return ModuleProxy::moduleProxy().toV8ContextForModules(context); |
| 786 } | 785 } |
| 787 | 786 |
| 788 v8::Local<v8::Context> toV8Context(Frame* frame, DOMWrapperWorld& world) | 787 v8::Local<v8::Context> toV8Context(Frame* frame, DOMWrapperWorld& world) |
| 789 { | 788 { |
| 790 if (!frame) | 789 if (!frame) |
| 791 return v8::Local<v8::Context>(); | 790 return v8::Local<v8::Context>(); |
| 792 v8::Local<v8::Context> context = toV8ContextEvenIfDetached(frame, world); | 791 v8::Local<v8::Context> context = toV8ContextEvenIfDetached(frame, world); |
| 793 ScriptState* scriptState = ScriptState::from(context); | 792 ScriptState* scriptState = ScriptState::from(context); |
| 794 if (scriptState->contextIsValid()) { | 793 if (scriptState->contextIsValid()) { |
| 795 ASSERT(toFrameIfNotDetached(context) == frame); | 794 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(); | 1017 v8::Local<v8::Value> data = info.Data(); |
| 1019 ASSERT(data->IsExternal()); | 1018 ASSERT(data->IsExternal()); |
| 1020 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->Cre
ationContext()); | 1019 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->Cre
ationContext()); |
| 1021 if (!perContextData) | 1020 if (!perContextData) |
| 1022 return; | 1021 return; |
| 1023 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u
nwrap(data))); | 1022 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u
nwrap(data))); |
| 1024 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); | 1023 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
| 1025 } | 1024 } |
| 1026 | 1025 |
| 1027 } // namespace blink | 1026 } // namespace blink |
| OLD | NEW |