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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 84 } |
85 if (attribute.property_location_configuration & | 85 if (attribute.property_location_configuration & |
86 V8DOMConfiguration::kOnInterface) | 86 V8DOMConfiguration::kOnInterface) |
87 NOTREACHED(); | 87 NOTREACHED(); |
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& config, |
95 const DOMWrapperWorld& world) { | 95 const DOMWrapperWorld& world) { |
96 if (!WorldConfigurationApplies(attribute, world)) | 96 if (!WorldConfigurationApplies(config, world)) |
97 return; | 97 return; |
98 v8::Local<v8::Name> name = V8AtomicString(isolate, attribute.name); | |
99 | 98 |
100 // This method is only being used for installing interfaces which are | 99 v8::Local<v8::Name> name = V8AtomicString(isolate, config.name); |
101 // enabled through origin trials. Assert here that it is being called with | 100 v8::AccessorNameGetterCallback getter = config.getter; |
102 // an attribute configuration for a constructor. | 101 v8::AccessorNameSetterCallback setter = config.setter; |
103 // TODO(iclelland): Relax this constraint and allow arbitrary data-type | 102 v8::Local<v8::Value> data = |
104 // properties to be added here. | 103 v8::External::New(isolate, const_cast<WrapperTypeInfo*>(config.data)); |
105 DCHECK_EQ(&V8ConstructorAttributeGetter, attribute.getter); | 104 v8::PropertyAttribute attribute = |
| 105 static_cast<v8::PropertyAttribute>(config.attribute); |
| 106 unsigned location = config.property_location_configuration; |
106 | 107 |
107 V8PerContextData* per_context_data = | 108 DCHECK(location); |
108 V8PerContextData::From(isolate->GetCurrentContext()); | 109 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
109 v8::Local<v8::Function> data = | 110 if (location & V8DOMConfiguration::kOnInstance) { |
110 per_context_data->ConstructorForType(attribute.data); | |
111 | |
112 DCHECK(attribute.property_location_configuration); | |
113 if (attribute.property_location_configuration & | |
114 V8DOMConfiguration::kOnInstance) | |
115 instance | 111 instance |
116 ->DefineOwnProperty( | 112 ->SetNativeDataProperty(context, name, getter, setter, data, attribute) |
117 isolate->GetCurrentContext(), name, data, | |
118 static_cast<v8::PropertyAttribute>(attribute.attribute)) | |
119 .ToChecked(); | 113 .ToChecked(); |
120 if (attribute.property_location_configuration & | 114 } |
121 V8DOMConfiguration::kOnPrototype) | 115 if (location & V8DOMConfiguration::kOnPrototype) { |
122 prototype | 116 prototype |
123 ->DefineOwnProperty( | 117 ->SetNativeDataProperty(context, name, getter, setter, data, attribute) |
124 isolate->GetCurrentContext(), name, data, | |
125 static_cast<v8::PropertyAttribute>(attribute.attribute)) | |
126 .ToChecked(); | 118 .ToChecked(); |
127 if (attribute.property_location_configuration & | 119 } |
128 V8DOMConfiguration::kOnInterface) | 120 if (location & V8DOMConfiguration::kOnInterface) |
129 NOTREACHED(); | 121 NOTREACHED(); |
130 } | 122 } |
131 | 123 |
132 void InstallLazyDataAttributeInternal( | 124 void InstallLazyDataAttributeInternal( |
133 v8::Isolate* isolate, | 125 v8::Isolate* isolate, |
134 v8::Local<v8::ObjectTemplate> instance_template, | 126 v8::Local<v8::ObjectTemplate> instance_template, |
135 v8::Local<v8::ObjectTemplate> prototype_template, | 127 v8::Local<v8::ObjectTemplate> prototype_template, |
136 const V8DOMConfiguration::AttributeConfiguration& attribute, | 128 const V8DOMConfiguration::AttributeConfiguration& attribute, |
137 const DOMWrapperWorld& world) { | 129 const DOMWrapperWorld& world) { |
138 v8::Local<v8::Name> name = V8AtomicString(isolate, attribute.name); | 130 v8::Local<v8::Name> name = V8AtomicString(isolate, attribute.name); |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 v8::Isolate* isolate, | 694 v8::Isolate* isolate, |
703 v8::Local<v8::ObjectTemplate> object_template, | 695 v8::Local<v8::ObjectTemplate> object_template, |
704 const char* class_string) { | 696 const char* class_string) { |
705 object_template->Set( | 697 object_template->Set( |
706 v8::Symbol::GetToStringTag(isolate), | 698 v8::Symbol::GetToStringTag(isolate), |
707 V8AtomicString(isolate, class_string), | 699 V8AtomicString(isolate, class_string), |
708 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); | 700 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); |
709 } | 701 } |
710 | 702 |
711 } // namespace blink | 703 } // namespace blink |
OLD | NEW |