Chromium Code Reviews| 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 23 matching lines...) Expand all Loading... | |
| 34 #include "bindings/core/v8/V8AbstractEventListener.h" | 34 #include "bindings/core/v8/V8AbstractEventListener.h" |
| 35 #include "bindings/core/v8/V8ArrayBufferView.h" | 35 #include "bindings/core/v8/V8ArrayBufferView.h" |
| 36 #include "bindings/core/v8/V8BindingMacros.h" | 36 #include "bindings/core/v8/V8BindingMacros.h" |
| 37 #include "bindings/core/v8/V8Element.h" | 37 #include "bindings/core/v8/V8Element.h" |
| 38 #include "bindings/core/v8/V8EventTarget.h" | 38 #include "bindings/core/v8/V8EventTarget.h" |
| 39 #include "bindings/core/v8/V8NodeFilter.h" | 39 #include "bindings/core/v8/V8NodeFilter.h" |
| 40 #include "bindings/core/v8/V8NodeFilterCondition.h" | 40 #include "bindings/core/v8/V8NodeFilterCondition.h" |
| 41 #include "bindings/core/v8/V8ObjectConstructor.h" | 41 #include "bindings/core/v8/V8ObjectConstructor.h" |
| 42 #include "bindings/core/v8/V8Window.h" | 42 #include "bindings/core/v8/V8Window.h" |
| 43 #include "bindings/core/v8/V8WorkerGlobalScope.h" | 43 #include "bindings/core/v8/V8WorkerGlobalScope.h" |
| 44 #include "bindings/core/v8/V8WorkletGlobalScope.h" | |
| 44 #include "bindings/core/v8/V8XPathNSResolver.h" | 45 #include "bindings/core/v8/V8XPathNSResolver.h" |
| 45 #include "bindings/core/v8/WindowProxy.h" | 46 #include "bindings/core/v8/WindowProxy.h" |
| 46 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" | 47 #include "bindings/core/v8/WorkerOrWorkletScriptController.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" |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 696 v8::Local<v8::Context> context = isolate->GetCallingContext(); | 697 v8::Local<v8::Context> context = isolate->GetCallingContext(); |
| 697 if (context.IsEmpty()) { | 698 if (context.IsEmpty()) { |
| 698 // Unfortunately, when processing script from a plugin, we might not | 699 // Unfortunately, when processing script from a plugin, we might not |
| 699 // have a calling context. In those cases, we fall back to the | 700 // have a calling context. In those cases, we fall back to the |
| 700 // entered context. | 701 // entered context. |
| 701 context = isolate->GetEnteredContext(); | 702 context = isolate->GetEnteredContext(); |
| 702 } | 703 } |
| 703 return toLocalDOMWindow(toDOMWindow(context)); | 704 return toLocalDOMWindow(toDOMWindow(context)); |
| 704 } | 705 } |
| 705 | 706 |
| 706 namespace { | |
| 707 ExecutionContext* (*s_toExecutionContextForModules)(v8::Local<v8::Context>) = nu llptr; | |
| 708 } | |
| 709 | |
| 710 ExecutionContext* toExecutionContext(v8::Local<v8::Context> context) | 707 ExecutionContext* toExecutionContext(v8::Local<v8::Context> context) |
| 711 { | 708 { |
| 712 if (context.IsEmpty()) | 709 if (context.IsEmpty()) |
| 713 return 0; | 710 return 0; |
| 714 v8::Local<v8::Object> global = context->Global(); | 711 v8::Local<v8::Object> global = context->Global(); |
| 715 v8::Local<v8::Object> windowWrapper = V8Window::findInstanceInPrototypeChain (global, context->GetIsolate()); | 712 v8::Local<v8::Object> windowWrapper = V8Window::findInstanceInPrototypeChain (global, context->GetIsolate()); |
| 716 if (!windowWrapper.IsEmpty()) | 713 if (!windowWrapper.IsEmpty()) |
| 717 return V8Window::toImpl(windowWrapper)->getExecutionContext(); | 714 return V8Window::toImpl(windowWrapper)->getExecutionContext(); |
| 718 v8::Local<v8::Object> workerWrapper = V8WorkerGlobalScope::findInstanceInPro totypeChain(global, context->GetIsolate()); | 715 v8::Local<v8::Object> workerWrapper = V8WorkerGlobalScope::findInstanceInPro totypeChain(global, context->GetIsolate()); |
| 719 if (!workerWrapper.IsEmpty()) | 716 if (!workerWrapper.IsEmpty()) |
| 720 return V8WorkerGlobalScope::toImpl(workerWrapper)->getExecutionContext() ; | 717 return V8WorkerGlobalScope::toImpl(workerWrapper)->getExecutionContext() ; |
| 721 ASSERT(s_toExecutionContextForModules); | 718 v8::Local<v8::Object> workletWrapper = V8WorkletGlobalScope::findInstanceInP rototypeChain(global, context->GetIsolate()); |
| 722 return (*s_toExecutionContextForModules)(context); | 719 if (!workletWrapper.IsEmpty()) |
| 723 } | 720 return V8WorkerGlobalScope::toImpl(workletWrapper)->getExecutionContext( ); |
|
yhirano
2016/06/02 08:14:42
Shouldn't this be V8WorkletGlobalScope?
ikilpatrick
2016/06/02 18:26:00
Yup, done.
| |
| 724 | 721 // FIXME: Is this line of code reachable? |
| 725 void registerToExecutionContextForModules(ExecutionContext* (*toExecutionContext ForModules)(v8::Local<v8::Context>)) | 722 return nullptr; |
| 726 { | |
| 727 s_toExecutionContextForModules = toExecutionContextForModules; | |
| 728 } | 723 } |
| 729 | 724 |
| 730 ExecutionContext* currentExecutionContext(v8::Isolate* isolate) | 725 ExecutionContext* currentExecutionContext(v8::Isolate* isolate) |
| 731 { | 726 { |
| 732 return toExecutionContext(isolate->GetCurrentContext()); | 727 return toExecutionContext(isolate->GetCurrentContext()); |
| 733 } | 728 } |
| 734 | 729 |
| 735 ExecutionContext* enteredExecutionContext(v8::Isolate* isolate) | 730 ExecutionContext* enteredExecutionContext(v8::Isolate* isolate) |
| 736 { | 731 { |
| 737 ExecutionContext* context = toExecutionContext(isolate->GetEnteredContext()) ; | 732 ExecutionContext* context = toExecutionContext(isolate->GetEnteredContext()) ; |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 946 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u nwrap(data))); | 941 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u nwrap(data))); |
| 947 } | 942 } |
| 948 | 943 |
| 949 v8::Local<v8::Value> freezeV8Object(v8::Local<v8::Value> value, v8::Isolate* iso late) | 944 v8::Local<v8::Value> freezeV8Object(v8::Local<v8::Value> value, v8::Isolate* iso late) |
| 950 { | 945 { |
| 951 v8CallOrCrash(value.As<v8::Object>()->SetIntegrityLevel(isolate->GetCurrentC ontext(), v8::IntegrityLevel::kFrozen)); | 946 v8CallOrCrash(value.As<v8::Object>()->SetIntegrityLevel(isolate->GetCurrentC ontext(), v8::IntegrityLevel::kFrozen)); |
| 952 return value; | 947 return value; |
| 953 } | 948 } |
| 954 | 949 |
| 955 } // namespace blink | 950 } // namespace blink |
| OLD | NEW |