Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8Binding.cpp

Issue 1535943005: Initial implementation of bindings and basic classes for worklets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address (most) comments. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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/ModuleProxy.h"
33 #include "bindings/core/v8/ScriptController.h" 34 #include "bindings/core/v8/ScriptController.h"
34 #include "bindings/core/v8/V8AbstractEventListener.h" 35 #include "bindings/core/v8/V8AbstractEventListener.h"
35 #include "bindings/core/v8/V8ArrayBufferView.h" 36 #include "bindings/core/v8/V8ArrayBufferView.h"
36 #include "bindings/core/v8/V8BindingMacros.h" 37 #include "bindings/core/v8/V8BindingMacros.h"
37 #include "bindings/core/v8/V8Element.h" 38 #include "bindings/core/v8/V8Element.h"
38 #include "bindings/core/v8/V8EventTarget.h" 39 #include "bindings/core/v8/V8EventTarget.h"
39 #include "bindings/core/v8/V8NodeFilter.h" 40 #include "bindings/core/v8/V8NodeFilter.h"
40 #include "bindings/core/v8/V8NodeFilterCondition.h" 41 #include "bindings/core/v8/V8NodeFilterCondition.h"
41 #include "bindings/core/v8/V8ObjectConstructor.h" 42 #include "bindings/core/v8/V8ObjectConstructor.h"
42 #include "bindings/core/v8/V8Window.h" 43 #include "bindings/core/v8/V8Window.h"
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 (WorkerOrWorkletScriptController* script = toWorkerGlobalScope(contex t)->script()) { 780 if (WorkerOrWorkletScriptController* script = toWorkerGlobalScope(contex t)->script()) {
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 if (context.IsEmpty()) 793 if (context.IsEmpty())
794 return v8::Local<v8::Context>(); 794 return v8::Local<v8::Context>();
795 ScriptState* scriptState = ScriptState::from(context); 795 ScriptState* scriptState = ScriptState::from(context);
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 v8::Local<v8::Value> data = info.Data(); 1020 v8::Local<v8::Value> data = info.Data();
1021 ASSERT(data->IsExternal()); 1021 ASSERT(data->IsExternal());
1022 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->Cre ationContext()); 1022 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->Cre ationContext());
1023 if (!perContextData) 1023 if (!perContextData)
1024 return; 1024 return;
1025 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u nwrap(data))); 1025 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u nwrap(data)));
1026 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 1026 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
1027 } 1027 }
1028 1028
1029 } // namespace blink 1029 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698