OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 11 matching lines...) Expand all Loading... | |
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 */ | 27 */ |
28 | 28 |
29 #include "bindings/core/v8/V8DOMConfiguration.h" | 29 #include "bindings/core/v8/V8DOMConfiguration.h" |
30 | 30 |
31 #include "bindings/core/v8/V8ObjectConstructor.h" | 31 #include "bindings/core/v8/V8ObjectConstructor.h" |
32 #include "bindings/core/v8/V8PerContextData.h" | |
32 #include "platform/TraceEvent.h" | 33 #include "platform/TraceEvent.h" |
33 | 34 |
34 namespace blink { | 35 namespace blink { |
35 | 36 |
36 namespace { | 37 namespace { |
37 | 38 |
38 void installAttributeInternal(v8::Isolate* isolate, v8::Local<v8::ObjectTemplate > instanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, const V8DOM Configuration::AttributeConfiguration& attribute, const DOMWrapperWorld& world) | 39 void installAttributeInternal(v8::Isolate* isolate, v8::Local<v8::ObjectTemplate > instanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, const V8DOM Configuration::AttributeConfiguration& attribute, const DOMWrapperWorld& world) |
39 { | 40 { |
40 if (attribute.exposeConfiguration == V8DOMConfiguration::OnlyExposedToPrivat eScript | 41 if (attribute.exposeConfiguration == V8DOMConfiguration::OnlyExposedToPrivat eScript |
41 && !world.isPrivateScriptIsolatedWorld()) | 42 && !world.isPrivateScriptIsolatedWorld()) |
(...skipping 19 matching lines...) Expand all Loading... | |
61 NOTREACHED(); | 62 NOTREACHED(); |
62 } | 63 } |
63 | 64 |
64 void installAttributeInternal(v8::Isolate* isolate, v8::Local<v8::Object> instan ce, v8::Local<v8::Object> prototype, const V8DOMConfiguration::AttributeConfigur ation& attribute, const DOMWrapperWorld& world) | 65 void installAttributeInternal(v8::Isolate* isolate, v8::Local<v8::Object> instan ce, v8::Local<v8::Object> prototype, const V8DOMConfiguration::AttributeConfigur ation& attribute, const DOMWrapperWorld& world) |
65 { | 66 { |
66 if (attribute.exposeConfiguration == V8DOMConfiguration::OnlyExposedToPrivat eScript | 67 if (attribute.exposeConfiguration == V8DOMConfiguration::OnlyExposedToPrivat eScript |
67 && !world.isPrivateScriptIsolatedWorld()) | 68 && !world.isPrivateScriptIsolatedWorld()) |
68 return; | 69 return; |
69 | 70 |
70 v8::Local<v8::Name> name = v8AtomicString(isolate, attribute.name); | 71 v8::Local<v8::Name> name = v8AtomicString(isolate, attribute.name); |
71 v8::Local<v8::Value> data = v8::External::New(isolate, const_cast<WrapperTyp eInfo*>(attribute.data)); | 72 |
73 // This method is only being used for installing interfaces which are | |
74 // enabled through origin trials. Assert here that it is being called with | |
75 // an attribute conguration for a constructor. | |
haraken
2016/05/31 00:16:32
configuration
iclelland
2016/05/31 03:17:31
Done.
| |
76 // TODO(iclelland): Relax this constraint and allow arbitrary data-type | |
77 // properties to be added here. | |
78 DCHECK_EQ(&v8ConstructorAttributeGetter, attribute.getter); | |
79 | |
80 V8PerContextData* perContextData = V8PerContextData::from(isolate->GetCurren tContext()); | |
81 v8::Local<v8::Function> data = perContextData->constructorForType(attribute. data); | |
72 | 82 |
73 DCHECK(attribute.propertyLocationConfiguration); | 83 DCHECK(attribute.propertyLocationConfiguration); |
74 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnInstance ) | 84 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnInstance ) |
75 v8CallOrCrash(instance->DefineOwnProperty(isolate->GetCurrentContext(), name, data, static_cast<v8::PropertyAttribute>(attribute.attribute))); | 85 v8CallOrCrash(instance->DefineOwnProperty(isolate->GetCurrentContext(), name, data)); |
76 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnPrototyp e) | 86 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnPrototyp e) |
77 v8CallOrCrash(prototype->DefineOwnProperty(isolate->GetCurrentContext(), name, data, static_cast<v8::PropertyAttribute>(attribute.attribute))); | 87 v8CallOrCrash(prototype->DefineOwnProperty(isolate->GetCurrentContext(), name, data)); |
78 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnInterfac e) | 88 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnInterfac e) |
79 NOTREACHED(); | 89 NOTREACHED(); |
80 } | 90 } |
81 | 91 |
82 template<class FunctionOrTemplate> | 92 template<class FunctionOrTemplate> |
83 v8::Local<FunctionOrTemplate> createAccessorFunctionOrTemplate(v8::Isolate*, v8: :FunctionCallback, v8::Local<v8::Value> data, v8::Local<v8::Signature>, int leng th); | 93 v8::Local<FunctionOrTemplate> createAccessorFunctionOrTemplate(v8::Isolate*, v8: :FunctionCallback, v8::Local<v8::Value> data, v8::Local<v8::Signature>, int leng th); |
84 | 94 |
85 template<> | 95 template<> |
86 v8::Local<v8::FunctionTemplate> createAccessorFunctionOrTemplate<v8::FunctionTem plate>(v8::Isolate* isolate, v8::FunctionCallback callback, v8::Local<v8::Value> data, v8::Local<v8::Signature> signature, int length) | 96 v8::Local<v8::FunctionTemplate> createAccessorFunctionOrTemplate<v8::FunctionTem plate>(v8::Isolate* isolate, v8::FunctionCallback callback, v8::Local<v8::Value> data, v8::Local<v8::Signature> signature, int length) |
87 { | 97 { |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
353 data->setInterfaceTemplate(world, wrapperTypeInfo, result); | 363 data->setInterfaceTemplate(world, wrapperTypeInfo, result); |
354 return result; | 364 return result; |
355 } | 365 } |
356 | 366 |
357 void V8DOMConfiguration::setClassString(v8::Isolate* isolate, v8::Local<v8::Obje ctTemplate> objectTemplate, const char* classString) | 367 void V8DOMConfiguration::setClassString(v8::Isolate* isolate, v8::Local<v8::Obje ctTemplate> objectTemplate, const char* classString) |
358 { | 368 { |
359 objectTemplate->Set(v8::Symbol::GetToStringTag(isolate), v8AtomicString(isol ate, classString), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnu m)); | 369 objectTemplate->Set(v8::Symbol::GetToStringTag(isolate), v8AtomicString(isol ate, classString), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnu m)); |
360 } | 370 } |
361 | 371 |
362 } // namespace blink | 372 } // namespace blink |
OLD | NEW |