OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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(blink::toInternalPo
inter(v8::Handle<v8::Object>::Cast(value))) : 0; | 1153 return hasInstance(value, isolate) ? fromInternalPointer(blink::toInternalPo
inter(v8::Handle<v8::Object>::Cast(value))) : 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
tanceObject, {{cpp_class}}* impl, v8::Isolate* isolate) | 1162 void {{v8_class}}::installConditionallyEnabledProperties(v8::Handle<v8::Object>
instanceObject, v8::Isolate* isolate) |
1161 { | 1163 { |
1162 v8::Local<v8::Object> prototypeObject = v8::Local<v8::Object>::Cast(instance
Object->GetPrototype()); | 1164 v8::Local<v8::Object> prototypeObject = v8::Local<v8::Object>::Cast(instance
Object->GetPrototype()); |
1163 {% for attribute in attributes if attribute.per_context_enabled_function %} | 1165 ExecutionContext* context = toExecutionContext(prototypeObject->CreationCont
ext()); |
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(instanceObject, prototypeObject, at
tributeConfiguration, isolate); | 1169 {% filter exposed(attribute.exposed_test) %} |
1168 } | 1170 static const V8DOMConfiguration::AttributeConfiguration attributeConfigurati
on =\ |
| 1171 {{attribute_configuration(attribute)}}; |
| 1172 V8DOMConfiguration::installAttribute(instanceObject, prototypeObject, attrib
uteConfiguration, 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 conditionally_enabled_methods %} |
1179 void {{v8_class}}::installPerContextEnabledMethods(v8::Handle<v8::Object> protot
ypeObject, v8::Isolate* isolate) | 1185 void {{v8_class}}::installConditionallyEnabledMethods(v8::Handle<v8::Object> pro
totypeObject, 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 | |
1184 ExecutionContext* context = toExecutionContext(prototypeObject->CreationCont
ext()); | 1189 ExecutionContext* context = toExecutionContext(prototypeObject->CreationCont
ext()); |
1185 ASSERT(context); | 1190 ASSERT(context); |
1186 {% for method in per_context_enabled_methods %} | 1191 |
1187 if (context->isDocument() && {{method.per_context_enabled_function}}(toDocum
ent(context))) { | 1192 {% for method in conditionally_enabled_methods %} |
1188 static const V8DOMConfiguration::MethodConfiguration methodConfiguration
= {{method_configuration(method)}}; | 1193 {% filter per_context_enabled(method.per_context_enabled_function) %} |
1189 V8DOMConfiguration::installMethod(prototypeObject, defaultSignature, v8:
:None, methodConfiguration, isolate); | 1194 {% filter exposed(method.exposed_test) %} |
1190 } | 1195 prototypeObject->Set(v8AtomicString(isolate, "{{method.name}}"), v8::Functio
nTemplate::New(isolate, {{cpp_class}}V8Internal::{{method.name}}MethodCallback,
v8Undefined(), defaultSignature, {{method.number_of_required_arguments}})->GetFu
nction()); |
| 1196 {% endfilter %} |
| 1197 {% endfilter %} |
1191 {% endfor %} | 1198 {% endfor %} |
1192 } | 1199 } |
1193 | 1200 |
1194 {% endif %} | 1201 {% endif %} |
1195 {% endblock %} | 1202 {% endblock %} |
1196 | 1203 |
1197 | 1204 |
1198 {##############################################################################} | 1205 {##############################################################################} |
1199 {% block to_active_dom_object %} | 1206 {% block to_active_dom_object %} |
1200 {% if is_active_dom_object %} | 1207 {% if is_active_dom_object %} |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1317 {% if is_audio_buffer %} | 1324 {% if is_audio_buffer %} |
1318 {# We only setDeallocationObservers on array buffers that are held by some | 1325 {# We only setDeallocationObservers on array buffers that are held by some |
1319 object in the V8 heap, not in the ArrayBuffer constructor itself. | 1326 object in the V8 heap, not in the ArrayBuffer constructor itself. |
1320 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 |
1321 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. #} |
1322 for (unsigned i = 0, n = impl->numberOfChannels(); i < n; i++) { | 1329 for (unsigned i = 0, n = impl->numberOfChannels(); i < n; i++) { |
1323 Float32Array* channelData = impl->getChannelData(i); | 1330 Float32Array* channelData = impl->getChannelData(i); |
1324 channelData->buffer()->setDeallocationObserver(V8ArrayBufferDeallocation
Observer::instanceTemplate()); | 1331 channelData->buffer()->setDeallocationObserver(V8ArrayBufferDeallocation
Observer::instanceTemplate()); |
1325 } | 1332 } |
1326 {% endif %} | 1333 {% endif %} |
1327 installPerContextEnabledProperties(wrapper, impl.get(), isolate); | 1334 installConditionallyEnabledProperties(wrapper, isolate); |
1328 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl, &wrapperTypeInf
o, wrapper, isolate, {{wrapper_configuration}}); | 1335 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl, &wrapperTypeInf
o, wrapper, isolate, {{wrapper_configuration}}); |
1329 return wrapper; | 1336 return wrapper; |
1330 } | 1337 } |
1331 | 1338 |
1332 {% endif %} | 1339 {% endif %} |
1333 {% endblock %} | 1340 {% endblock %} |
1334 | 1341 |
1335 | 1342 |
1336 {##############################################################################} | 1343 {##############################################################################} |
1337 {% block deref_object_and_to_v8_no_inline %} | 1344 {% block deref_object_and_to_v8_no_inline %} |
1338 void {{v8_class}}::derefObject(ScriptWrappableBase* internalPointer) | 1345 void {{v8_class}}::derefObject(ScriptWrappableBase* internalPointer) |
1339 { | 1346 { |
1340 {% if gc_type == 'RefCountedObject' %} | 1347 {% if gc_type == 'RefCountedObject' %} |
1341 fromInternalPointer(internalPointer)->deref(); | 1348 fromInternalPointer(internalPointer)->deref(); |
1342 {% elif gc_type == 'WillBeGarbageCollectedObject' %} | 1349 {% elif gc_type == 'WillBeGarbageCollectedObject' %} |
1343 {% filter conditional('!ENABLE(OILPAN)') %} | 1350 {% filter conditional('!ENABLE(OILPAN)') %} |
1344 fromInternalPointer(internalPointer)->deref(); | 1351 fromInternalPointer(internalPointer)->deref(); |
1345 {% endfilter %} | 1352 {% endfilter %} |
1346 {% endif %} | 1353 {% endif %} |
1347 } | 1354 } |
1348 | 1355 |
1349 template<> | 1356 template<> |
1350 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) |
1351 { | 1358 { |
1352 return toV8(impl, creationContext, isolate); | 1359 return toV8(impl, creationContext, isolate); |
1353 } | 1360 } |
1354 | 1361 |
1355 {% endblock %} | 1362 {% endblock %} |
OLD | NEW |