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

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: absolute paths for DEPS file. 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 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 v8::Local<v8::Context> context = isolate->GetCallingContext(); 694 v8::Local<v8::Context> context = isolate->GetCallingContext();
695 if (context.IsEmpty()) { 695 if (context.IsEmpty()) {
696 // Unfortunately, when processing script from a plugin, we might not 696 // Unfortunately, when processing script from a plugin, we might not
697 // have a calling context. In those cases, we fall back to the 697 // have a calling context. In those cases, we fall back to the
698 // entered context. 698 // entered context.
699 context = isolate->GetEnteredContext(); 699 context = isolate->GetEnteredContext();
700 } 700 }
701 return toLocalDOMWindow(toDOMWindow(context)); 701 return toLocalDOMWindow(toDOMWindow(context));
702 } 702 }
703 703
704 namespace {
705 ExecutionContext* (*s_toExecutionContextForModules)(v8::Local<v8::Context>) = nu llptr;
706 }
707
704 ExecutionContext* toExecutionContext(v8::Local<v8::Context> context) 708 ExecutionContext* toExecutionContext(v8::Local<v8::Context> context)
705 { 709 {
706 if (context.IsEmpty()) 710 if (context.IsEmpty())
707 return 0; 711 return 0;
708 v8::Local<v8::Object> global = context->Global(); 712 v8::Local<v8::Object> global = context->Global();
709 v8::Local<v8::Object> windowWrapper = V8Window::findInstanceInPrototypeChain (global, context->GetIsolate()); 713 v8::Local<v8::Object> windowWrapper = V8Window::findInstanceInPrototypeChain (global, context->GetIsolate());
710 if (!windowWrapper.IsEmpty()) 714 if (!windowWrapper.IsEmpty())
711 return V8Window::toImpl(windowWrapper)->executionContext(); 715 return V8Window::toImpl(windowWrapper)->executionContext();
712 v8::Local<v8::Object> workerWrapper = V8WorkerGlobalScope::findInstanceInPro totypeChain(global, context->GetIsolate()); 716 v8::Local<v8::Object> workerWrapper = V8WorkerGlobalScope::findInstanceInPro totypeChain(global, context->GetIsolate());
713 if (!workerWrapper.IsEmpty()) 717 if (!workerWrapper.IsEmpty())
714 return V8WorkerGlobalScope::toImpl(workerWrapper)->executionContext(); 718 return V8WorkerGlobalScope::toImpl(workerWrapper)->executionContext();
715 // FIXME: Is this line of code reachable? 719 ASSERT(s_toExecutionContextForModules);
716 return 0; 720 return (*s_toExecutionContextForModules)(context);
721 }
722
723 void registerToExecutionContextForModules(ExecutionContext* (*toExecutionContext ForModules)(v8::Local<v8::Context>))
724 {
725 s_toExecutionContextForModules = toExecutionContextForModules;
717 } 726 }
718 727
719 ExecutionContext* currentExecutionContext(v8::Isolate* isolate) 728 ExecutionContext* currentExecutionContext(v8::Isolate* isolate)
720 { 729 {
721 return toExecutionContext(isolate->GetCurrentContext()); 730 return toExecutionContext(isolate->GetCurrentContext());
722 } 731 }
723 732
724 ExecutionContext* enteredExecutionContext(v8::Isolate* isolate) 733 ExecutionContext* enteredExecutionContext(v8::Isolate* isolate)
725 { 734 {
726 ExecutionContext* context = toExecutionContext(isolate->GetEnteredContext()) ; 735 ExecutionContext* context = toExecutionContext(isolate->GetEnteredContext()) ;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 result.setSmall(storage, length); 780 result.setSmall(storage, length);
772 } 781 }
773 782
774 v8::Local<v8::Context> toV8Context(ExecutionContext* context, DOMWrapperWorld& w orld) 783 v8::Local<v8::Context> toV8Context(ExecutionContext* context, DOMWrapperWorld& w orld)
775 { 784 {
776 ASSERT(context); 785 ASSERT(context);
777 if (context->isDocument()) { 786 if (context->isDocument()) {
778 if (LocalFrame* frame = toDocument(context)->frame()) 787 if (LocalFrame* frame = toDocument(context)->frame())
779 return toV8Context(frame, world); 788 return toV8Context(frame, world);
780 } else if (context->isWorkerGlobalScope()) { 789 } else if (context->isWorkerGlobalScope()) {
781 if (WorkerOrWorkletScriptController* script = toWorkerGlobalScope(contex t)->script()) { 790 if (WorkerOrWorkletScriptController* script = toWorkerOrWorkletGlobalSco pe(context)->script()) {
782 if (script->scriptState()->contextIsValid()) 791 if (script->scriptState()->contextIsValid())
783 return script->scriptState()->context(); 792 return script->scriptState()->context();
784 } 793 }
785 } 794 }
786 return v8::Local<v8::Context>(); 795 return v8::Local<v8::Context>();
787 } 796 }
788 797
789 v8::Local<v8::Context> toV8Context(Frame* frame, DOMWrapperWorld& world) 798 v8::Local<v8::Context> toV8Context(Frame* frame, DOMWrapperWorld& world)
790 { 799 {
791 if (!frame) 800 if (!frame)
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 v8::Local<v8::Value> data = info.Data(); 1030 v8::Local<v8::Value> data = info.Data();
1022 ASSERT(data->IsExternal()); 1031 ASSERT(data->IsExternal());
1023 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->Cre ationContext()); 1032 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->Cre ationContext());
1024 if (!perContextData) 1033 if (!perContextData)
1025 return; 1034 return;
1026 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u nwrap(data))); 1035 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u nwrap(data)));
1027 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 1036 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
1028 } 1037 }
1029 1038
1030 } // namespace blink 1039 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/V8Binding.h ('k') | third_party/WebKit/Source/bindings/core/v8/V8DOMWrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698