OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "bindings/core/v8/ConditionalFeaturesForCore.h" | 5 #include "bindings/core/v8/ConditionalFeaturesForCore.h" |
6 | 6 |
7 #include "bindings/core/v8/ConditionalFeatures.h" | 7 #include "bindings/core/v8/ConditionalFeatures.h" |
8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
9 #include "bindings/core/v8/V8Document.h" | 9 #include "bindings/core/v8/V8Document.h" |
10 #include "bindings/core/v8/V8HTMLLinkElement.h" | 10 #include "bindings/core/v8/V8HTMLLinkElement.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 if (!executionContext) | 37 if (!executionContext) |
38 return; | 38 return; |
39 v8::Isolate* isolate = scriptState->isolate(); | 39 v8::Isolate* isolate = scriptState->isolate(); |
40 const DOMWrapperWorld& world = scriptState->world(); | 40 const DOMWrapperWorld& world = scriptState->world(); |
41 if (wrapperTypeInfo == &V8HTMLLinkElement::wrapperTypeInfo) { | 41 if (wrapperTypeInfo == &V8HTMLLinkElement::wrapperTypeInfo) { |
42 if (OriginTrials::linkServiceWorkerEnabled(executionContext)) { | 42 if (OriginTrials::linkServiceWorkerEnabled(executionContext)) { |
43 V8HTMLLinkElement::installLinkServiceWorker( | 43 V8HTMLLinkElement::installLinkServiceWorker( |
44 isolate, world, v8::Local<v8::Object>(), prototypeObject, | 44 isolate, world, v8::Local<v8::Object>(), prototypeObject, |
45 interfaceObject); | 45 interfaceObject); |
46 } | 46 } |
47 } else if (wrapperTypeInfo == &V8Document::wrapperTypeInfo) { | |
48 if (OriginTrials::setRootScrollerEnabled(executionContext)) { | |
49 V8Document::installRootScroller(isolate, world, v8::Local<v8::Object>(), | |
50 prototypeObject, interfaceObject); | |
51 } | |
52 } | 47 } |
53 } | 48 } |
54 | 49 |
55 void installPendingConditionalFeatureCore(const String& feature, | 50 void installPendingConditionalFeatureCore(const String& feature, |
56 const ScriptState* scriptState) { | 51 const ScriptState* scriptState) { |
57 (*s_oldInstallPendingConditionalFeatureFunction)(feature, scriptState); | 52 (*s_oldInstallPendingConditionalFeatureFunction)(feature, scriptState); |
58 | 53 |
59 // TODO(iclelland): Generate all of this logic at compile-time, based on the | 54 // TODO(iclelland): Generate all of this logic at compile-time, based on the |
60 // configuration of origin trial enabled attributes and interfaces in IDL | 55 // configuration of origin trial enabled attributes and interfaces in IDL |
61 // files. (crbug.com/615060) | 56 // files. (crbug.com/615060) |
62 v8::Local<v8::Object> prototypeObject; | 57 v8::Local<v8::Object> prototypeObject; |
63 v8::Local<v8::Function> interfaceObject; | 58 v8::Local<v8::Function> interfaceObject; |
64 v8::Isolate* isolate = scriptState->isolate(); | 59 v8::Isolate* isolate = scriptState->isolate(); |
65 const DOMWrapperWorld& world = scriptState->world(); | 60 const DOMWrapperWorld& world = scriptState->world(); |
66 V8PerContextData* contextData = scriptState->perContextData(); | 61 V8PerContextData* contextData = scriptState->perContextData(); |
67 if (feature == "ForeignFetch") { | 62 if (feature == "ForeignFetch") { |
68 if (contextData->getExistingConstructorAndPrototypeForType( | 63 if (contextData->getExistingConstructorAndPrototypeForType( |
69 &V8HTMLLinkElement::wrapperTypeInfo, &prototypeObject, | 64 &V8HTMLLinkElement::wrapperTypeInfo, &prototypeObject, |
70 &interfaceObject)) { | 65 &interfaceObject)) { |
71 V8HTMLLinkElement::installLinkServiceWorker( | 66 V8HTMLLinkElement::installLinkServiceWorker( |
72 isolate, world, v8::Local<v8::Object>(), prototypeObject, | 67 isolate, world, v8::Local<v8::Object>(), prototypeObject, |
73 interfaceObject); | 68 interfaceObject); |
74 } | 69 } |
75 return; | 70 return; |
76 } | 71 } |
77 if (feature == "RootScroller") { | |
78 if (contextData->getExistingConstructorAndPrototypeForType( | |
79 &V8Document::wrapperTypeInfo, &prototypeObject, &interfaceObject)) { | |
80 V8Document::installRootScroller(isolate, world, v8::Local<v8::Object>(), | |
81 prototypeObject, interfaceObject); | |
82 } | |
83 return; | |
84 } | |
85 } | 72 } |
86 | 73 |
87 void installConditionalFeaturesOnWindow(const ScriptState* scriptState) { | 74 void installConditionalFeaturesOnWindow(const ScriptState* scriptState) { |
88 DCHECK(scriptState); | 75 DCHECK(scriptState); |
89 DCHECK(scriptState->context() == scriptState->isolate()->GetCurrentContext()); | 76 DCHECK(scriptState->context() == scriptState->isolate()->GetCurrentContext()); |
90 DCHECK(scriptState->perContextData()); | 77 DCHECK(scriptState->perContextData()); |
91 DCHECK(scriptState->world().isMainWorld()); | 78 DCHECK(scriptState->world().isMainWorld()); |
92 installConditionalFeatures(&V8Window::wrapperTypeInfo, scriptState, | 79 installConditionalFeatures(&V8Window::wrapperTypeInfo, scriptState, |
93 v8::Local<v8::Object>(), | 80 v8::Local<v8::Object>(), |
94 v8::Local<v8::Function>()); | 81 v8::Local<v8::Function>()); |
(...skipping 19 matching lines...) Expand all Loading... |
114 | 101 |
115 void registerInstallConditionalFeaturesForCore() { | 102 void registerInstallConditionalFeaturesForCore() { |
116 s_oldInstallConditionalFeaturesFunction = | 103 s_oldInstallConditionalFeaturesFunction = |
117 setInstallConditionalFeaturesFunction(&installConditionalFeaturesCore); | 104 setInstallConditionalFeaturesFunction(&installConditionalFeaturesCore); |
118 s_oldInstallPendingConditionalFeatureFunction = | 105 s_oldInstallPendingConditionalFeatureFunction = |
119 setInstallPendingConditionalFeatureFunction( | 106 setInstallPendingConditionalFeatureFunction( |
120 &installPendingConditionalFeatureCore); | 107 &installPendingConditionalFeatureCore); |
121 } | 108 } |
122 | 109 |
123 } // namespace blink | 110 } // namespace blink |
OLD | NEW |