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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 } | 88 } |
89 | 89 |
90 void InstallAttributeInternal( | 90 void InstallAttributeInternal( |
91 v8::Isolate* isolate, | 91 v8::Isolate* isolate, |
92 v8::Local<v8::Object> instance, | 92 v8::Local<v8::Object> instance, |
93 v8::Local<v8::Object> prototype, | 93 v8::Local<v8::Object> prototype, |
94 const V8DOMConfiguration::AttributeConfiguration& attribute, | 94 const V8DOMConfiguration::AttributeConfiguration& attribute, |
95 const DOMWrapperWorld& world) { | 95 const DOMWrapperWorld& world) { |
96 if (!WorldConfigurationApplies(attribute, world)) | 96 if (!WorldConfigurationApplies(attribute, world)) |
97 return; | 97 return; |
98 | |
98 v8::Local<v8::Name> name = V8AtomicString(isolate, attribute.name); | 99 v8::Local<v8::Name> name = V8AtomicString(isolate, attribute.name); |
100 v8::AccessorNameGetterCallback getter = attribute.getter; | |
101 v8::AccessorNameSetterCallback setter = attribute.setter; | |
102 v8::Local<v8::Value> data = | |
103 v8::External::New(isolate, const_cast<WrapperTypeInfo*>(attribute.data)); | |
99 | 104 |
100 // This method is only being used for installing interfaces which are | 105 // This method is only being used for installing interfaces which are |
101 // enabled through origin trials. Assert here that it is being called with | 106 // enabled through origin trials. Assert here that it is being called with |
102 // an attribute configuration for a constructor. | 107 // an attribute configuration for a constructor. |
103 // TODO(iclelland): Relax this constraint and allow arbitrary data-type | 108 // TODO(iclelland): Relax this constraint and allow arbitrary data-type |
104 // properties to be added here. | 109 // properties to be added here. |
105 DCHECK_EQ(&V8ConstructorAttributeGetter, attribute.getter); | 110 DCHECK_EQ(&V8ConstructorAttributeGetter, getter); |
106 | 111 |
107 V8PerContextData* per_context_data = | 112 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
108 V8PerContextData::From(isolate->GetCurrentContext()); | |
109 v8::Local<v8::Function> data = | |
110 per_context_data->ConstructorForType(attribute.data); | |
111 | |
112 DCHECK(attribute.property_location_configuration); | 113 DCHECK(attribute.property_location_configuration); |
113 if (attribute.property_location_configuration & | 114 if (attribute.property_location_configuration & |
114 V8DOMConfiguration::kOnInstance) | 115 V8DOMConfiguration::kOnInstance) { |
115 instance | 116 instance |
116 ->DefineOwnProperty( | 117 ->SetAccessor(context, name, getter, setter, data, v8::DEFAULT, |
jbroman
2017/04/13 14:54:45
This is only for origin trials, so maybe you've al
haraken
2017/04/13 15:40:19
The name is really confusing but:
- SetAccessor =
jbroman
2017/04/13 17:11:23
Ah. If that's the case, then ignore me (though it
| |
117 isolate->GetCurrentContext(), name, data, | 118 static_cast<v8::PropertyAttribute>(attribute.attribute)) |
118 static_cast<v8::PropertyAttribute>(attribute.attribute)) | |
119 .ToChecked(); | 119 .ToChecked(); |
120 } | |
120 if (attribute.property_location_configuration & | 121 if (attribute.property_location_configuration & |
121 V8DOMConfiguration::kOnPrototype) | 122 V8DOMConfiguration::kOnPrototype) { |
122 prototype | 123 prototype |
123 ->DefineOwnProperty( | 124 ->SetAccessor(context, name, getter, setter, data, v8::DEFAULT, |
124 isolate->GetCurrentContext(), name, data, | 125 static_cast<v8::PropertyAttribute>(attribute.attribute)) |
125 static_cast<v8::PropertyAttribute>(attribute.attribute)) | |
126 .ToChecked(); | 126 .ToChecked(); |
127 } | |
127 if (attribute.property_location_configuration & | 128 if (attribute.property_location_configuration & |
128 V8DOMConfiguration::kOnInterface) | 129 V8DOMConfiguration::kOnInterface) |
129 NOTREACHED(); | 130 NOTREACHED(); |
130 } | 131 } |
131 | 132 |
132 void InstallLazyDataAttributeInternal( | 133 void InstallLazyDataAttributeInternal( |
133 v8::Isolate* isolate, | 134 v8::Isolate* isolate, |
134 v8::Local<v8::ObjectTemplate> instance_template, | 135 v8::Local<v8::ObjectTemplate> instance_template, |
135 v8::Local<v8::ObjectTemplate> prototype_template, | 136 v8::Local<v8::ObjectTemplate> prototype_template, |
136 const V8DOMConfiguration::AttributeConfiguration& attribute, | 137 const V8DOMConfiguration::AttributeConfiguration& attribute, |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
702 v8::Isolate* isolate, | 703 v8::Isolate* isolate, |
703 v8::Local<v8::ObjectTemplate> object_template, | 704 v8::Local<v8::ObjectTemplate> object_template, |
704 const char* class_string) { | 705 const char* class_string) { |
705 object_template->Set( | 706 object_template->Set( |
706 v8::Symbol::GetToStringTag(isolate), | 707 v8::Symbol::GetToStringTag(isolate), |
707 V8AtomicString(isolate, class_string), | 708 V8AtomicString(isolate, class_string), |
708 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); | 709 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); |
709 } | 710 } |
710 | 711 |
711 } // namespace blink | 712 } // namespace blink |
OLD | NEW |