Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: Source/bindings/templates/interface.cpp

Issue 424163002: Enable the WebIDL [Exposed] annotation on an interface's members. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: remove some noise Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 {% extends 'interface_base.cpp' %} 1 {% extends 'interface_base.cpp' %}
2 2
3 3
4 {##############################################################################} 4 {##############################################################################}
5 {% macro attribute_configuration(attribute) %} 5 {% macro attribute_configuration(attribute) %}
6 {% set getter_callback = 6 {% set getter_callback =
7 '%sV8Internal::%sAttributeGetterCallback' % 7 '%sV8Internal::%sAttributeGetterCallback' %
8 (cpp_class, attribute.name) 8 (cpp_class, attribute.name)
9 if not attribute.constructor_type else 9 if not attribute.constructor_type else
10 ('%sV8Internal::%sConstructorGetterCallback' % 10 ('%sV8Internal::%sConstructorGetterCallback' %
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 553
554 554
555 {##############################################################################} 555 {##############################################################################}
556 {% from 'methods.cpp' import generate_constructor with context %} 556 {% from 'methods.cpp' import generate_constructor with context %}
557 {% block named_constructor %} 557 {% block named_constructor %}
558 {% if named_constructor %} 558 {% if named_constructor %}
559 {% set to_active_dom_object = '%s::toActiveDOMObject' % v8_class 559 {% set to_active_dom_object = '%s::toActiveDOMObject' % v8_class
560 if is_active_dom_object else '0' %} 560 if is_active_dom_object else '0' %}
561 {% set to_event_target = '%s::toEventTarget' % v8_class 561 {% set to_event_target = '%s::toEventTarget' % v8_class
562 if is_event_target else '0' %} 562 if is_event_target else '0' %}
563 const WrapperTypeInfo {{v8_class}}Constructor::wrapperTypeInfo = { gin::kEmbedde rBlink, {{v8_class}}Constructor::domTemplate, {{v8_class}}::derefObject, {{to_ac tive_dom_object}}, {{to_event_target}}, 0, {{v8_class}}::installPerContextEnable dMethods, 0, WrapperTypeObjectPrototype, {{gc_type}} }; 563 const WrapperTypeInfo {{v8_class}}Constructor::wrapperTypeInfo = { gin::kEmbedde rBlink, {{v8_class}}Constructor::domTemplate, {{v8_class}}::derefObject, {{to_ac tive_dom_object}}, {{to_event_target}}, 0, {{v8_class}}::installConditionallyEna bledMethods, 0, WrapperTypeObjectPrototype, {{gc_type}} };
564 564
565 {{generate_constructor(named_constructor)}} 565 {{generate_constructor(named_constructor)}}
566 v8::Handle<v8::FunctionTemplate> {{v8_class}}Constructor::domTemplate(v8::Isolat e* isolate) 566 v8::Handle<v8::FunctionTemplate> {{v8_class}}Constructor::domTemplate(v8::Isolat e* isolate)
567 { 567 {
568 static int domTemplateKey; // This address is used for a key to look up the dom template. 568 static int domTemplateKey; // This address is used for a key to look up the dom template.
569 V8PerIsolateData* data = V8PerIsolateData::from(isolate); 569 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
570 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(&domTempl ateKey); 570 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(&domTempl ateKey);
571 if (!result.IsEmpty()) 571 if (!result.IsEmpty())
572 return result; 572 return result;
573 573
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 741
742 {##############################################################################} 742 {##############################################################################}
743 {% block install_attributes %} 743 {% block install_attributes %}
744 {% if has_attribute_configuration %} 744 {% if has_attribute_configuration %}
745 static const V8DOMConfiguration::AttributeConfiguration {{v8_class}}Attributes[] = { 745 static const V8DOMConfiguration::AttributeConfiguration {{v8_class}}Attributes[] = {
746 {% for attribute in attributes 746 {% for attribute in attributes
747 if not (attribute.is_expose_js_accessors or 747 if not (attribute.is_expose_js_accessors or
748 attribute.is_static or 748 attribute.is_static or
749 attribute.runtime_enabled_function or 749 attribute.runtime_enabled_function or
750 attribute.per_context_enabled_function or 750 attribute.per_context_enabled_function or
751 attribute.custom_exposed_rules or
751 (interface_name == 'Window' and attribute.is_unforgeable)) 752 (interface_name == 'Window' and attribute.is_unforgeable))
752 and attribute.should_be_exposed_to_script %} 753 and attribute.should_be_exposed_to_script %}
753 {% filter conditional(attribute.conditional_string) %} 754 {% filter conditional(attribute.conditional_string) %}
754 {{attribute_configuration(attribute)}}, 755 {{attribute_configuration(attribute)}},
755 {% endfilter %} 756 {% endfilter %}
756 {% endfor %} 757 {% endfor %}
757 }; 758 };
758 759
759 {% endif %} 760 {% endif %}
760 {% endblock %} 761 {% endblock %}
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 functionTemplate->SetLength({{interface_length}}); 916 functionTemplate->SetLength({{interface_length}});
916 {% endif %} 917 {% endif %}
917 v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTempla te->InstanceTemplate(); 918 v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTempla te->InstanceTemplate();
918 v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTempl ate->PrototypeTemplate(); 919 v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTempl ate->PrototypeTemplate();
919 {% if is_check_security and interface_name != 'Window' %} 920 {% if is_check_security and interface_name != 'Window' %}
920 instanceTemplate->SetAccessCheckCallbacks({{cpp_class}}V8Internal::namedSecu rityCheck, {{cpp_class}}V8Internal::indexedSecurityCheck, v8::External::New(isol ate, const_cast<WrapperTypeInfo*>(&{{v8_class}}::wrapperTypeInfo))); 921 instanceTemplate->SetAccessCheckCallbacks({{cpp_class}}V8Internal::namedSecu rityCheck, {{cpp_class}}V8Internal::indexedSecurityCheck, v8::External::New(isol ate, const_cast<WrapperTypeInfo*>(&{{v8_class}}::wrapperTypeInfo)));
921 {% endif %} 922 {% endif %}
922 {% for attribute in attributes 923 {% for attribute in attributes
923 if attribute.runtime_enabled_function and 924 if attribute.runtime_enabled_function and
924 not attribute.per_context_enabled_function and 925 not attribute.per_context_enabled_function and
926 not attribute.custom_exposed_rules and
925 not attribute.is_static %} 927 not attribute.is_static %}
926 {% filter conditional(attribute.conditional_string) %} 928 {% filter conditional(attribute.conditional_string) %}
927 if ({{attribute.runtime_enabled_function}}()) { 929 if ({{attribute.runtime_enabled_function}}()) {
928 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu ration =\ 930 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu ration =\
929 {{attribute_configuration(attribute)}}; 931 {{attribute_configuration(attribute)}};
930 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate , attributeConfiguration, isolate); 932 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate , attributeConfiguration, isolate);
931 } 933 }
932 {% endfilter %} 934 {% endfilter %}
933 {% endfor %} 935 {% endfor %}
934 {% if constants %} 936 {% if constants %}
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 {% block to_native_with_type_check %} 1150 {% block to_native_with_type_check %}
1149 {{cpp_class}}* {{v8_class}}::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Han dle<v8::Value> value) 1151 {{cpp_class}}* {{v8_class}}::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Han dle<v8::Value> value)
1150 { 1152 {
1151 return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Obje ct>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) : 0; 1153 return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Obje ct>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) : 0;
1152 } 1154 }
1153 1155
1154 {% endblock %} 1156 {% endblock %}
1155 1157
1156 1158
1157 {##############################################################################} 1159 {##############################################################################}
1158 {% block install_per_context_attributes %} 1160 {% block install_conditional_attributes %}
1159 {% if has_per_context_enabled_attributes %} 1161 {% if has_conditional_attributes %}
1160 void {{v8_class}}::installPerContextEnabledProperties(v8::Handle<v8::Object> ins tanceTemplate, {{cpp_class}}* impl, v8::Isolate* isolate) 1162 void {{v8_class}}::installConditionallyEnabledProperties(v8::Handle<v8::Object> instanceTemplate, {{cpp_class}}* impl, v8::Isolate* isolate)
1161 { 1163 {
1162 v8::Local<v8::Object> prototypeTemplate = v8::Local<v8::Object>::Cast(instan ceTemplate->GetPrototype()); 1164 v8::Local<v8::Object> prototypeTemplate = v8::Local<v8::Object>::Cast(instan ceTemplate->GetPrototype());
1163 {% for attribute in attributes if attribute.per_context_enabled_function %} 1165 ExecutionContext* context = toExecutionContext(prototypeTemplate->CreationCo ntext());
1166
1167 {% for attribute in attributes if attribute.per_context_enabled_function or attribute.custom_exposed_rules %}
1168 {% if attribute.per_context_enabled_function %}
1164 if ({{attribute.per_context_enabled_function}}(impl->document())) { 1169 if ({{attribute.per_context_enabled_function}}(impl->document())) {
1170 {% else %}
Jens Widell 2014/07/29 18:24:29 Are these really mutually exclusive? Also, we cou
Peter Beverloo 2014/07/30 14:48:15 No, they are not. It was just easier to the first
Jens Widell 2014/07/30 15:16:17 My thinking was that you would introduce a filters
1171 if (context && ({{attribute.custom_exposed_rules}})) {
1172 {% endif %}
1165 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu ration =\ 1173 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu ration =\
1166 {{attribute_configuration(attribute)}}; 1174 {{attribute_configuration(attribute)}};
1167 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate , attributeConfiguration, isolate); 1175 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate , attributeConfiguration, isolate);
1168 } 1176 }
1169 {% endfor %} 1177 {% endfor %}
1170 } 1178 }
1171 1179
1172 {% endif %} 1180 {% endif %}
1173 {% endblock %} 1181 {% endblock %}
1174 1182
1175 1183
1176 {##############################################################################} 1184 {##############################################################################}
1177 {% block install_per_context_methods %} 1185 {% block install_conditional_methods %}
1178 {% if per_context_enabled_methods %} 1186 {% if has_conditional_methods %}
1179 void {{v8_class}}::installPerContextEnabledMethods(v8::Handle<v8::Object> protot ypeTemplate, v8::Isolate* isolate) 1187 void {{v8_class}}::installConditionallyEnabledMethods(v8::Handle<v8::Object> pro totypeTemplate, v8::Isolate* isolate)
1180 { 1188 {
1181 {# Define per-context enabled operations #} 1189 {# Define per-context enabled operations #}
1182 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, domT emplate(isolate)); 1190 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, domT emplate(isolate));
1183 1191
1184 ExecutionContext* context = toExecutionContext(prototypeTemplate->CreationCo ntext()); 1192 ExecutionContext* context = toExecutionContext(prototypeTemplate->CreationCo ntext());
1185 {% for method in per_context_enabled_methods %} 1193 {% for method in per_context_enabled_methods %}
1186 if (context && context->isDocument() && {{method.per_context_enabled_functio n}}(toDocument(context))) 1194 if (context && context->isDocument() && {{method.per_context_enabled_functio n}}(toDocument(context)))
1187 prototypeTemplate->Set(v8AtomicString(isolate, "{{method.name}}"), v8::F unctionTemplate::New(isolate, {{cpp_class}}V8Internal::{{method.name}}MethodCall back, v8Undefined(), defaultSignature, {{method.number_of_required_arguments}})- >GetFunction()); 1195 prototypeTemplate->Set(v8AtomicString(isolate, "{{method.name}}"), v8::F unctionTemplate::New(isolate, {{cpp_class}}V8Internal::{{method.name}}MethodCall back, v8Undefined(), defaultSignature, {{method.number_of_required_arguments}})- >GetFunction());
1188 {% endfor %} 1196 {% endfor %}
1197 {% for method in conditionally_exposed_methods %}
1198 if (context && ({{method.custom_exposed_rules}}))
1199 prototypeTemplate->Set(v8AtomicString(isolate, "{{method.name}}"), v8::F unctionTemplate::New(isolate, {{cpp_class}}V8Internal::{{method.name}}MethodCall back, v8Undefined(), defaultSignature, {{method.number_of_required_arguments}})- >GetFunction());
1200 {% endfor %}
1189 } 1201 }
1190 1202
1191 {% endif %} 1203 {% endif %}
1192 {% endblock %} 1204 {% endblock %}
1193 1205
1194 1206
1195 {##############################################################################} 1207 {##############################################################################}
1196 {% block to_active_dom_object %} 1208 {% block to_active_dom_object %}
1197 {% if is_active_dom_object %} 1209 {% if is_active_dom_object %}
1198 ActiveDOMObject* {{v8_class}}::toActiveDOMObject(v8::Handle<v8::Object> wrapper) 1210 ActiveDOMObject* {{v8_class}}::toActiveDOMObject(v8::Handle<v8::Object> wrapper)
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 {% if is_audio_buffer %} 1326 {% if is_audio_buffer %}
1315 {# We only setDeallocationObservers on array buffers that are held by some 1327 {# We only setDeallocationObservers on array buffers that are held by some
1316 object in the V8 heap, not in the ArrayBuffer constructor itself. 1328 object in the V8 heap, not in the ArrayBuffer constructor itself.
1317 This is because V8 GC only cares about memory it can free on GC, and 1329 This is because V8 GC only cares about memory it can free on GC, and
1318 until the object is exposed to JavaScript, V8 GC doesn't affect it. #} 1330 until the object is exposed to JavaScript, V8 GC doesn't affect it. #}
1319 for (unsigned i = 0, n = impl->numberOfChannels(); i < n; i++) { 1331 for (unsigned i = 0, n = impl->numberOfChannels(); i < n; i++) {
1320 Float32Array* channelData = impl->getChannelData(i); 1332 Float32Array* channelData = impl->getChannelData(i);
1321 channelData->buffer()->setDeallocationObserver(V8ArrayBufferDeallocation Observer::instanceTemplate()); 1333 channelData->buffer()->setDeallocationObserver(V8ArrayBufferDeallocation Observer::instanceTemplate());
1322 } 1334 }
1323 {% endif %} 1335 {% endif %}
1324 installPerContextEnabledProperties(wrapper, impl.get(), isolate); 1336 installConditionallyEnabledProperties(wrapper, impl.get(), isolate);
1325 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl, &wrapperTypeInf o, wrapper, isolate, {{wrapper_configuration}}); 1337 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl, &wrapperTypeInf o, wrapper, isolate, {{wrapper_configuration}});
1326 return wrapper; 1338 return wrapper;
1327 } 1339 }
1328 1340
1329 {% endif %} 1341 {% endif %}
1330 {% endblock %} 1342 {% endblock %}
1331 1343
1332 1344
1333 {##############################################################################} 1345 {##############################################################################}
1334 {% block deref_object_and_to_v8_no_inline %} 1346 {% block deref_object_and_to_v8_no_inline %}
1335 void {{v8_class}}::derefObject(void* object) 1347 void {{v8_class}}::derefObject(void* object)
1336 { 1348 {
1337 {% if gc_type == 'RefCountedObject' %} 1349 {% if gc_type == 'RefCountedObject' %}
1338 fromInternalPointer(object)->deref(); 1350 fromInternalPointer(object)->deref();
1339 {% elif gc_type == 'WillBeGarbageCollectedObject' %} 1351 {% elif gc_type == 'WillBeGarbageCollectedObject' %}
1340 {% filter conditional('!ENABLE(OILPAN)') %} 1352 {% filter conditional('!ENABLE(OILPAN)') %}
1341 fromInternalPointer(object)->deref(); 1353 fromInternalPointer(object)->deref();
1342 {% endfilter %} 1354 {% endfilter %}
1343 {% endif %} 1355 {% endif %}
1344 } 1356 }
1345 1357
1346 template<> 1358 template<>
1347 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate) 1359 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate)
1348 { 1360 {
1349 return toV8(impl, creationContext, isolate); 1361 return toV8(impl, creationContext, isolate);
1350 } 1362 }
1351 1363
1352 {% endblock %} 1364 {% endblock %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698