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

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: comments and merge test files 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
« no previous file with comments | « Source/bindings/templates/interface.h ('k') | Source/bindings/templates/interface_base.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.exposed_test 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.exposed_test 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());
1164 if ({{attribute.per_context_enabled_function}}(impl->document())) { 1166
1165 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu ration =\ 1167 {% for attribute in attributes if attribute.per_context_enabled_function or attribute.exposed_test %}
1166 {{attribute_configuration(attribute)}}; 1168 {% filter per_context_enabled(attribute.per_context_enabled_function) %}
1167 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate , attributeConfiguration, isolate); 1169 {% filter exposed(attribute.exposed_test) %}
1168 } 1170 static const V8DOMConfiguration::AttributeConfiguration attributeConfigurati on =\
1171 {{attribute_configuration(attribute)}};
1172 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate, at tributeConfiguration, isolate);
1173 {% endfilter %}
1174 {% endfilter %}
1169 {% endfor %} 1175 {% endfor %}
1170 } 1176 }
1171 1177
1172 {% endif %} 1178 {% endif %}
1173 {% endblock %} 1179 {% endblock %}
1174 1180
1175 1181
1176 {##############################################################################} 1182 {##############################################################################}
1177 {% block install_per_context_methods %} 1183 {% block install_conditional_methods %}
1178 {% if per_context_enabled_methods %} 1184 {% if has_conditional_methods %}
1179 void {{v8_class}}::installPerContextEnabledMethods(v8::Handle<v8::Object> protot ypeTemplate, v8::Isolate* isolate) 1185 void {{v8_class}}::installConditionallyEnabledMethods(v8::Handle<v8::Object> pro totypeTemplate, v8::Isolate* isolate)
1180 { 1186 {
1181 {# Define per-context enabled operations #} 1187 {# Define per-context enabled operations #}
1182 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, domT emplate(isolate)); 1188 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, domT emplate(isolate));
1183 1189
1184 ExecutionContext* context = toExecutionContext(prototypeTemplate->CreationCo ntext()); 1190 ExecutionContext* context = toExecutionContext(prototypeTemplate->CreationCo ntext());
1185 {% for method in per_context_enabled_methods %} 1191 {% for method in per_context_enabled_methods %}
Jens Widell 2014/07/31 19:47:11 Should we group these two sets of methods together
Peter Beverloo 2014/08/01 14:04:01 Done. I removed |cpp_class* impl| argument from in
1186 if (context && context->isDocument() && {{method.per_context_enabled_functio n}}(toDocument(context))) 1192 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()); 1193 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 %} 1194 {% endfor %}
1195 {% for method in conditionally_exposed_methods %}
1196 if (context && ({{method.exposed_test}}))
1197 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());
1198 {% endfor %}
1189 } 1199 }
1190 1200
1191 {% endif %} 1201 {% endif %}
1192 {% endblock %} 1202 {% endblock %}
1193 1203
1194 1204
1195 {##############################################################################} 1205 {##############################################################################}
1196 {% block to_active_dom_object %} 1206 {% block to_active_dom_object %}
1197 {% if is_active_dom_object %} 1207 {% if is_active_dom_object %}
1198 ActiveDOMObject* {{v8_class}}::toActiveDOMObject(v8::Handle<v8::Object> wrapper) 1208 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 %} 1324 {% if is_audio_buffer %}
1315 {# We only setDeallocationObservers on array buffers that are held by some 1325 {# We only setDeallocationObservers on array buffers that are held by some
1316 object in the V8 heap, not in the ArrayBuffer constructor itself. 1326 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 1327 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. #} 1328 until the object is exposed to JavaScript, V8 GC doesn't affect it. #}
1319 for (unsigned i = 0, n = impl->numberOfChannels(); i < n; i++) { 1329 for (unsigned i = 0, n = impl->numberOfChannels(); i < n; i++) {
1320 Float32Array* channelData = impl->getChannelData(i); 1330 Float32Array* channelData = impl->getChannelData(i);
1321 channelData->buffer()->setDeallocationObserver(V8ArrayBufferDeallocation Observer::instanceTemplate()); 1331 channelData->buffer()->setDeallocationObserver(V8ArrayBufferDeallocation Observer::instanceTemplate());
1322 } 1332 }
1323 {% endif %} 1333 {% endif %}
1324 installPerContextEnabledProperties(wrapper, impl.get(), isolate); 1334 installConditionallyEnabledProperties(wrapper, impl.get(), isolate);
1325 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl, &wrapperTypeInf o, wrapper, isolate, {{wrapper_configuration}}); 1335 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl, &wrapperTypeInf o, wrapper, isolate, {{wrapper_configuration}});
1326 return wrapper; 1336 return wrapper;
1327 } 1337 }
1328 1338
1329 {% endif %} 1339 {% endif %}
1330 {% endblock %} 1340 {% endblock %}
1331 1341
1332 1342
1333 {##############################################################################} 1343 {##############################################################################}
1334 {% block deref_object_and_to_v8_no_inline %} 1344 {% block deref_object_and_to_v8_no_inline %}
1335 void {{v8_class}}::derefObject(void* object) 1345 void {{v8_class}}::derefObject(void* object)
1336 { 1346 {
1337 {% if gc_type == 'RefCountedObject' %} 1347 {% if gc_type == 'RefCountedObject' %}
1338 fromInternalPointer(object)->deref(); 1348 fromInternalPointer(object)->deref();
1339 {% elif gc_type == 'WillBeGarbageCollectedObject' %} 1349 {% elif gc_type == 'WillBeGarbageCollectedObject' %}
1340 {% filter conditional('!ENABLE(OILPAN)') %} 1350 {% filter conditional('!ENABLE(OILPAN)') %}
1341 fromInternalPointer(object)->deref(); 1351 fromInternalPointer(object)->deref();
1342 {% endfilter %} 1352 {% endfilter %}
1343 {% endif %} 1353 {% endif %}
1344 } 1354 }
1345 1355
1346 template<> 1356 template<>
1347 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate) 1357 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate)
1348 { 1358 {
1349 return toV8(impl, creationContext, isolate); 1359 return toV8(impl, creationContext, isolate);
1350 } 1360 }
1351 1361
1352 {% endblock %} 1362 {% endblock %}
OLDNEW
« no previous file with comments | « Source/bindings/templates/interface.h ('k') | Source/bindings/templates/interface_base.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698