| Index: Source/bindings/templates/interface_wip.cpp
|
| diff --git a/Source/bindings/templates/interface_wip.cpp b/Source/bindings/templates/interface_wip.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..218c8d837a710ca7454e221ed80ea483eadf63ff
|
| --- /dev/null
|
| +++ b/Source/bindings/templates/interface_wip.cpp
|
| @@ -0,0 +1,526 @@
|
| +/*
|
| + This file is part of the Blink open source project.
|
| + This file has been auto-generated by CodeGeneratorV8.pm. DO NOT MODIFY!
|
| +
|
| + This library is free software; you can redistribute it and/or
|
| + modify it under the terms of the GNU Library General Public
|
| + License as published by the Free Software Foundation; either
|
| + version 2 of the License, or (at your option) any later version.
|
| +
|
| + This library is distributed in the hope that it will be useful,
|
| + but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| + Library General Public License for more details.
|
| +
|
| + You should have received a copy of the GNU Library General Public License
|
| + along with this library; see the file COPYING.LIB. If not, write to
|
| + the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
| + Boston, MA 02111-1307, USA.
|
| +*/
|
| +
|
| +{% from 'attributes_wip.cpp' import attribute_getter, attribute_getter_callback, attribute_setter, attribute_setter_callback, batched_attribute, enabled_at_runtime_batched_attribute with context %}
|
| +{% from 'constants.cpp' import class_consts, const_data, batch_configure_constants with context %}
|
| +{% from 'constructors.cpp' import constructor_callback, make_constructors, more_constructor_stuff with context %}
|
| +{% from 'macros.cpp' import method, method_callback, parameters_check, function_call, feature_observation, deprecation_notification, custom_element_invocation, if_else_statement with context %}
|
| +#include "config.h"
|
| +{% if conditional_string %}
|
| +#if {{conditional_string}}
|
| +{% endif %}
|
| +#include "{{v8_class_name}}.h"
|
| +
|
| +{% for filename in cpp_includes %}
|
| +#include "{{filename}}"
|
| +{% endfor %}
|
| +
|
| +namespace WebCore {
|
| +
|
| +static void initializeScriptWrappableForInterface({{cpp_class_name}}* object)
|
| +{
|
| + if (ScriptWrappable::wrapperCanBeStoredInObject(object))
|
| + ScriptWrappable::setTypeInfoInObject(object, &{{v8_class_name}}::info);
|
| + else
|
| + ASSERT_NOT_REACHED();
|
| +}
|
| +
|
| +} // namespace WebCore
|
| +
|
| +// In ScriptWrappable::init, the use of a local function declaration has an issue on Windows:
|
| +// the local declaration does not pick up the surrounding namespace. Therefore, we provide this function
|
| +// in the global namespace.
|
| +// (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/feedback/details/664619/the-namespace-of-local-function-declarations-in-c)
|
| +void webCoreInitializeScriptWrappableForInterface({{namespace_for_interface=='WebCore' and 'WebCore::' or ''}}{{cpp_class_name}}* object)
|
| +{
|
| + WebCore::initializeScriptWrappableForInterface(object);
|
| +}
|
| +
|
| +namespace WebCore {
|
| +WrapperTypeInfo {{v8_class_name}}::info = { {{v8_class_name}}::GetTemplate, {{v8_class_name}}::derefObject, {{to_active_dom_object}}, {{to_event_target}}, {{root_for_gc}}, {{v8_class_name}}::installPerContextPrototypeProperties, {{parent_class_info}}, {{wrapper_type_prototype}} };
|
| +
|
| +namespace {{cpp_class_name}}V8Internal {
|
| +
|
| +template <typename T> void V8_USE(T) { }
|
| +
|
| +{# ############################################## Attributes #}
|
| +{% for attribute in attributes %}
|
| +{% for for_main_world_suffix in attribute.for_main_world_suffixes %}
|
| +{{attribute_getter(attribute, for_main_world_suffix) -}}
|
| +{{attribute_getter_callback(attribute, for_main_world_suffix)}}{% endfor %}
|
| +{% for for_main_world_suffix in attribute.for_main_world_suffixes %}
|
| +{% if attribute.has_normal_setter and not attribute.has_custom_setter %}
|
| +{{attribute_setter(attribute, for_main_world_suffix)}}{% endif %}
|
| +{% if attribute.has_normal_setter %}
|
| +{{attribute_setter_callback(attribute, for_main_world_suffix)}}{% endif %}
|
| +{% endfor %}
|
| +{% endfor %}
|
| +{# ############################################## Functions #}
|
| +{% for function in functions %}
|
| +{% if function.name and not function.is_custom %}
|
| +{% for for_main_world_suffix in function.for_main_world_suffixes %}
|
| +{{method(function, for_main_world_suffix)}}{% endfor %}
|
| +{% endif %}
|
| +{# ###### Function callback #}
|
| +{% for for_main_world_suffix in function.for_main_world_suffixes %}
|
| +{{method_callback(function, for_main_world_suffix)}}{% endfor %}
|
| +{% endfor %}
|
| +{# for functions #}
|
| +{##############################################################################}
|
| +{# Constructors #}
|
| +{##############################################################################}
|
| +{% if not has_custom_constructor %}
|
| +{{make_constructors()}}{% endif %}
|
| +{##############################################################################}
|
| +{# GenerateImplementationIndexedPropertyAccessors #}
|
| +{# GenerateImplementationIndexedPropertyGetter #}
|
| +{% if special_accessors.indexed.getter.enabled and not special_accessors.indexed.getter.is_custom %}
|
| +static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
|
| +{
|
| + ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
|
| + {{cpp_class_name}}* collection = {{v8_class_name}}::toNative(info.Holder());
|
| +{% if special_accessors.indexed.getter.raises_exceptions %}
|
| + ExceptionState es(info.GetIsolate());
|
| +{% endif %}
|
| +{# TODO use function_call {{function_call(indexed_getter.function_call_parameter)}}#}
|
| +{{special_accessors.indexed.getter.function_call}}
|
| +{% if special_accessors.indexed.getter.raises_exceptions %}
|
| + if (es.throwIfNeeded())
|
| + return;
|
| +{% endif %}
|
| +{% if special_accessors.indexed.getter.return_type_is_union %}
|
| +{#TODO#}
|
| + {{special_accessors.indexed.getter.return_js_value_statement | indent}}
|
| + return;
|
| +{% else %}
|
| + if ({{special_accessors.indexed.getter.is_null_expression}})
|
| + return;
|
| + {{special_accessors.indexed.getter.return_js_value_statement | indent}}
|
| +{% endif %}
|
| +}
|
| +
|
| +{% endif %}
|
| +{# GenerateImplementationIndexedPropertyGetterCallback #}
|
| +{% if special_accessors.indexed.getter.enabled %}
|
| +static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
|
| +{
|
| + TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty");
|
| +{% if special_accessors.indexed.getter.is_custom %}
|
| + {{v8_class_name}}::indexedPropertyGetterCustom(index, info);
|
| +{% else %}
|
| + {{cpp_class_name}}V8Internal::indexedPropertyGetter(index, info);
|
| +{% endif %}
|
| + TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
|
| +}
|
| +
|
| +{% endif %}
|
| +{# GenerateImplementationIndexedPropertySetter #}
|
| +{% if special_accessors.indexed.setter.enabled and not special_accessors.indexed.setter.is_custom %}
|
| +static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
|
| +{
|
| + {{cpp_class_name}}* collection = {{v8_class_name}}::toNative(info.Holder());
|
| + {{special_accessors.indexed.setter.js_to_native_statement}}
|
| +{% if special_accessors.indexed.setter.raises_exceptions %}
|
| + ExceptionState es(info.GetIsolate());
|
| +{% endif %}
|
| +{{if_else_statement('bool', 'result', special_accessors.indexed.setter.condition_and_statements)}}
|
| + if (!result)
|
| + return;
|
| +{% if special_accessors.indexed.setter.raises_exceptions %}
|
| + if (es.throwIfNeeded())
|
| + return;
|
| +{% endif %}
|
| + v8SetReturnValue(info, value);
|
| +}
|
| +
|
| +{% endif %}
|
| +{# GenerateImplementationIndexedPropertySetterCallback #}
|
| +{% if special_accessors.indexed.setter.enabled %}
|
| +static void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
|
| +{
|
| + TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty");
|
| +{% if special_accessors.indexed.getter.is_custom %}
|
| + {{v8_class_name}}::indexedPropertySetterCustom(index, value, info);
|
| +{% else %}
|
| + {{cpp_class_name}}V8Internal::indexedPropertySetter(index, value, info);
|
| +{% endif %}
|
| + TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
|
| +}
|
| +
|
| +{% endif %}
|
| +{# GenerateImplementationIndexedPropertyDeleter #}
|
| +{# GenerateImplementationIndexedPropertyDeleterCallback #}
|
| +{##############################################################################}
|
| +{##############################################################################}
|
| +{# GenerateImplementationNamedPropertyAccessors #}
|
| +{# GenerateImplementationNamedPropertyGetter #}
|
| +{% if special_accessors.named.getter.enabled and not special_accessors.named.getter.is_custom %}
|
| +static void namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
|
| +{
|
| +{% if not special_accessors.named.getter.override_builtins %}
|
| + if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty())
|
| + return;
|
| + if (info.Holder()->HasRealNamedCallbackProperty(name))
|
| + return;
|
| + if (info.Holder()->HasRealNamedProperty(name))
|
| + return;
|
| +
|
| +{% endif %}
|
| + ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
|
| + {{cpp_class_name}}* collection = {{v8_class_name}}::toNative(info.Holder());
|
| + AtomicString propertyName = toWebCoreAtomicString(name);
|
| +{% if special_accessors.named.getter.raises_exceptions %}
|
| + ExceptionState es(info.GetIsolate());
|
| +{% endif %}
|
| +{{special_accessors.named.getter.function_call}}
|
| +{% if special_accessors.named.getter.raises_exceptions %}
|
| + if (es.throwIfNeeded())
|
| + return;
|
| +{% endif %}
|
| +{% if special_accessors.named.getter.is_return_type_union %}
|
| +{{special_accessors.named.getter.return_js_value_code}}
|
| + return;
|
| +{% else %}
|
| + if ({{special_accessors.named.getter.is_null_expression}})
|
| + return;
|
| + {{special_accessors.named.getter.return_js_value_code}}
|
| +{% endif %}
|
| +}
|
| +
|
| +{% endif %}
|
| +{# GenerateImplementationNamedPropertyGetterCallback #}
|
| +{% if special_accessors.named.getter.enabled %}
|
| +static void namedPropertyGetterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
|
| +{
|
| + TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
|
| +{% if special_accessors.named.getter.is_custom %}
|
| + {{v8_class_name}}::namedPropertyGetterCustom(name, info);
|
| +{% else %}
|
| + {{cpp_class_name}}V8Internal::namedPropertyGetter(name, info);
|
| +{% endif %}
|
| + TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
|
| +}
|
| +
|
| +{% endif %}
|
| +{# GenerateImplementationNamedPropertySetter #}
|
| +{# GenerateImplementationNamedPropertySetterCallback #}
|
| +{% if special_accessors.named.setter.enabled %}
|
| +static void namedPropertySetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
|
| +{
|
| + TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
|
| +{% if special_accessors.named.setter.is_custom %}
|
| + {{v8_class_name}}::namedPropertySetterCustom(name, value, info);
|
| +{% else %}
|
| + {{cpp_class_name}}V8Internal::namedPropertySetter(name, value, info);
|
| +{% endif %}
|
| + TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
|
| +}
|
| +
|
| +{% endif %}
|
| +{# GenerateImplementationNamedPropertyDeleter #}
|
| +{# GenerateImplementationNamedPropertyDeleterCallback #}
|
| +{% if special_accessors.named.deleter.enabled %}
|
| +static void namedPropertyDeleterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
|
| +{
|
| + TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
|
| +{% if special_accessors.named.deleter.is_custom %}
|
| + {{v8_class_name}}::namedPropertyDeleterCustom(name, info);
|
| +{% else %}
|
| + {{cpp_class_name}}V8Internal::namedPropertyDeleter(name, info);
|
| +{% endif %}
|
| + TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
|
| +}
|
| +{% endif %}
|
| +{# GenerateImplementationNamedPropertyEnumerator #}
|
| +{# GenerateImplementationNamedPropertyQuery #}
|
| +{# GenerateImplementationNamedPropertyEnumeratorCallback #}
|
| +{# GenerateImplementationNamedPropertyQueryCallback #}
|
| +{##############################################################################}
|
| +{##############################################################################}
|
| +{# GenerateImplementationNamedPropertyAccessors #}
|
| +{# GenerateImplementationMasqueradesAsUndefined #}
|
| +{##############################################################################}
|
| +} // namespace {{cpp_class_name}}V8Internal
|
| +
|
| +{% if needs_opaque_root_for_gc %}
|
| +void* {{v8_class_name}}::opaqueRootForGC(void* object, v8::Isolate* isolate)
|
| +{
|
| + {{cpp_class_name}}* impl = fromInternalPointer(object);
|
| +{% if is_reachable_method %}
|
| + if (Node* owner = impl->{{is_reachable_method}}())
|
| + return V8GCController::opaqueRootForGC(owner, isolate);
|
| +{% endif %}
|
| + return object;
|
| +}
|
| +
|
| +{% endif %}
|
| +{% if not has_custom_constructor %}
|
| +{{more_constructor_stuff()}}{% endif %}
|
| +{# FIXME: pass a list of normal_attributes, instead of length and is_normal #}
|
| +{% if number_of_normal_attributes %}
|
| +{{batched_attribute()}}
|
| +{% endif %}
|
| +{# ### BatchedFunction #}
|
| +{% if function_callbacks %}
|
| +static const V8DOMConfiguration::BatchedMethod {{v8_class_name}}Methods[] = {
|
| +{% for function in functions %}
|
| +{% if function.create_callback %}
|
| +{% if function.conditional_string %}
|
| +#if {{function.conditional_string}}
|
| +{% endif %}
|
| + {"{{function.name}}", {{cpp_class_name}}V8Internal::{{function.name}}MethodCallback, {{function.method_for_main_world}}, {{function.length}}},
|
| +{% if function.conditional_string %}
|
| +#endif // {{function.conditional_string}}
|
| +{% endif %}
|
| +{% endif %}
|
| +{% endfor %}
|
| +};
|
| +
|
| +{% endif %}
|
| +{% if constants %}
|
| +{{class_consts()}}
|
| +{% endif %}
|
| +{% if not has_custom_constructor %}
|
| +{% if is_constructor_template_of_event %}
|
| +bool fill{{cpp_class_name}}Init({{cpp_class_name}}Init& eventInit, const Dictionary& options)
|
| +{
|
| +{% if parent %}
|
| + if (!fill{{parent}}Init(eventInit, options))
|
| + return false;
|
| +
|
| +{% endif %}
|
| +{% for attribute in attributes %}
|
| +{% if attribute.type != 'any' and attribute.initialized_by_event_constructor %}
|
| + options.get("{{attribute.name}}", eventInit.{{attribute.name}});
|
| +{% endif %}
|
| +{% endfor %}
|
| + return true;
|
| +}
|
| +
|
| +{% endif %}
|
| +{% endif %}
|
| +{% if is_constructable %}
|
| +{{constructor_callback()}}
|
| +{% endif %}
|
| +static v8::Handle<v8::FunctionTemplate> Configure{{v8_class_name}}Template(v8::Handle<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType currentWorldType)
|
| +{
|
| + desc->ReadOnlyPrototype();
|
| +
|
| + v8::Local<v8::Signature> defaultSignature;
|
| +{% if enabled_at_runtime %}
|
| + if (!{{enable_function}}())
|
| + defaultSignature = V8DOMConfiguration::configureTemplate(desc, "", {{parent_class_template}}, {{v8_class_name}}::internalFieldCount, 0, 0, 0, 0, isolate, currentWorldType);
|
| + else
|
| +{% endif %}
|
| + defaultSignature = V8DOMConfiguration::configureTemplate(desc, "{{interface_name}}", {{parent_class_template}}, {{v8_class_name}}::internalFieldCount,
|
| + {{configure_template_batched_attribute}}, {{configure_template_attribute_count}},
|
| + {{configure_template_batched_method}}, {{configure_template_method_count}}, isolate, currentWorldType);
|
| + UNUSED_PARAM(defaultSignature); // In some cases, it will not be used.
|
| +{% if is_constructable %}
|
| + desc->SetCallHandler({{v8_class_name}}::constructorCallback);
|
| + desc->SetLength({{interface_length}});
|
| +{% endif %}
|
| +{% if access_check or number_of_enabled_at_runtime_attributes or number_of_normal_functions or constants %}
|
| + v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
|
| + v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
|
| + UNUSED_PARAM(instance); // In some cases, it will not be used.
|
| + UNUSED_PARAM(proto); // In some cases, it will not be used.
|
| +{% endif %}
|
| +{% if access_check %}
|
| + instance->SetAccessCheckCallbacks({{cpp_class_name}}V8Internal::namedSecurityCheck, {{cpp_class_name}}V8Internal::indexedSecurityCheck, v8::External::New(&{{v8_class_name}}::info));
|
| +{% endif %}
|
| +{# FIXME: instead pass a list of enabled_at_runtime_attributes #}
|
| +{% if number_of_enabled_at_runtime_attributes %}
|
| +{{enabled_at_runtime_batched_attribute()}}{% endif %}
|
| +{% for constant in constants %}{{const_data(constant)}}{% endfor %}
|
| +{# TODO GenerateImplementationIndexedPropertyAccessors #}
|
| +{% if special_accessors.indexed.getter.enabled %}
|
| + desc->{{special_accessors.set_on}}Template()->SetIndexedPropertyHandler({{special_accessors.indexed.getter.callback_name}}, {{special_accessors.indexed.setter.callback_name}}, {{special_accessors.indexed.query.callback_name}}, {{special_accessors.indexed.deleter.callback_name}}, {{special_accessors.indexed.enumerator.callback_name}});
|
| +{% endif %}
|
| +{# TODO GenerateImplementationNamedPropertyAccessors #}
|
| +{% if special_accessors.named.getter.enabled %}
|
| + desc->{{special_accessors.set_on}}Template()->SetNamedPropertyHandler({{special_accessors.named.getter.callback_name}}, {{special_accessors.named.setter.callback_name}}, {{special_accessors.named.query.callback_name}}, {{special_accessors.named.deleter.callback_name}}, {{special_accessors.named.enumerator.callback_name}});
|
| +{% endif %}
|
| +{# TODO GenerateImplementationLegacyCall #}
|
| +{% if custom_legacy_call %}
|
| + desc->InstanceTemplate()->SetCallAsFunctionHandler({{v8_class_name}}::legacyCallCustom);
|
| +{% endif %}
|
| +{# TODO GenerateImplementationMasqueradesAsUndefined #}
|
| +{% for function in functions %}
|
| +{% if function.is_representative and function.is_normal_function and not function.is_standard_function %}
|
| +{% if check_security and function.do_not_check_security %}
|
| +
|
| + // {{function.comment_info}}
|
| + {{function.conditional_runtime}}{{function.template}}->SetAccessor(v8::String::NewSymbol("{{function.name}}"), {{cpp_class_name}}V8Internal::{{function.name}}AttrGetterCallback, {{function.setter}}, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>({{function.property_attributes}}));
|
| +
|
| +{% else %}
|
| +{% if function.conditional_string %}
|
| +#if {{function.conditional_string}}
|
| +{%- endif %}
|
| +{% if function.requires_custom_signature %}
|
| +
|
| + // Custom Signature '{{function.name}}'
|
| + const int {{function.name}}Argc = {{function.parameters | length}};
|
| + v8::Handle<v8::FunctionTemplate> {{function.name}}Argv[{{function.name}}Argc] = { {{function.custom_signature}} };
|
| + v8::Handle<v8::Signature> {{function.name}}Signature = v8::Signature::New(desc, {{function.name}}Argc, {{function.name}}Argv);
|
| +{% endif %}
|
| +{# see end of GenerateNonStandardFunction in perl #}
|
| +{% if function.per_world_bindings %}
|
| + if (currentWorldType == MainWorld) {
|
| + {{function.conditional_runtime}}{{function.template}}->Set(v8::String::NewSymbol("{{function.name}}"), v8::FunctionTemplate::New({{cpp_class_name}}V8Internal::{{function.name}}MethodCallbackForMainWorld, v8Undefined(), {{function.signature}}, {{function.mandatory_parameters}}){{function.property_attributes}});
|
| + } else {
|
| + {{function.conditional_runtime}}{{function.template}}->Set(v8::String::NewSymbol("{{function.name}}"), v8::FunctionTemplate::New({{cpp_class_name}}V8Internal::{{function.name}}MethodCallback, v8Undefined(), {{function.signature}}, {{function.mandatory_parameters}}){{function.property_attributes}});
|
| + }
|
| +{% else %}
|
| + {{function.conditional_runtime}}{{function.template}}->Set(v8::String::NewSymbol("{{function.name}}"), v8::FunctionTemplate::New({{cpp_class_name}}V8Internal::{{function.name}}MethodCallback, v8Undefined(), {{function.signature}}, {{function.mandatory_parameters}}){{function.property_attributes}});
|
| +{% endif %}
|
| +{% if function.conditional_string %}
|
| +#endif // {{function.conditional_string}}{% endif %}
|
| +{% endif %}
|
| +{% endif %}
|
| +{% endfor %}
|
| +{% if constants %}
|
| + {{batch_configure_constants()}}
|
| +{% endif %}
|
| +
|
| + // Custom toString template
|
| + desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
|
| + return desc;
|
| +}
|
| +
|
| +v8::Handle<v8::FunctionTemplate> {{v8_class_name}}::GetTemplate(v8::Isolate* isolate, WrapperWorldType currentWorldType)
|
| +{
|
| + V8PerIsolateData* data = V8PerIsolateData::from(isolate);
|
| + V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWorldType).find(&info);
|
| + if (result != data->templateMap(currentWorldType).end())
|
| + return result->value.newLocal(isolate);
|
| +
|
| + TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
|
| + v8::HandleScope handleScope(isolate);
|
| + v8::Handle<v8::FunctionTemplate> templ =
|
| + Configure{{v8_class_name}}Template(data->rawTemplate(&info, currentWorldType), isolate, currentWorldType);
|
| + data->templateMap(currentWorldType).add(&info, UnsafePersistent<v8::FunctionTemplate>(isolate, templ));
|
| + return handleScope.Close(templ);
|
| +}
|
| +
|
| +bool {{v8_class_name}}::HasInstance(v8::Handle<v8::Value> value, v8::Isolate* isolate, WrapperWorldType currentWorldType)
|
| +{
|
| + return V8PerIsolateData::from(isolate)->hasInstance(&info, value, currentWorldType);
|
| +}
|
| +
|
| +bool {{v8_class_name}}::HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8::Isolate* isolate)
|
| +{
|
| + return V8PerIsolateData::from(isolate)->hasInstance(&info, value, MainWorld)
|
| + || V8PerIsolateData::from(isolate)->hasInstance(&info, value, IsolatedWorld)
|
| + || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorld);
|
| +}
|
| +
|
| +{% if number_of_enabled_per_context_functions %}
|
| +void {{v8_class_name}}::installPerContextPrototypeProperties(v8::Handle<v8::Object> proto, v8::Isolate* isolate)
|
| +{
|
| + UNUSED_PARAM(proto);
|
| +{# Setup the enable-by-settings functions if we have them #}
|
| + v8::Local<v8::Signature> defaultSignature = v8::Signature::New(GetTemplate(isolate, worldType(isolate)));
|
| + UNUSED_PARAM(defaultSignature); // In some cases, it will not be used.
|
| +
|
| + ScriptExecutionContext* context = toScriptExecutionContext(proto->CreationContext());
|
| +{% for function in functions %}
|
| +{% if function.is_enabled_per_context_function %}
|
| +{% if function.conditional_string %}
|
| +#if {{function.conditional_string}}
|
| +{% endif %}
|
| + if (context && context->isDocument() && {{function.enable_function}}(toDocument(context)))
|
| + proto->Set(v8::String::NewSymbol("{{function.name}}"), v8::FunctionTemplate::New({{cpp_class_name}}V8Internal::{{function.name}}MethodCallback, v8Undefined(), defaultSignature, {{function.mandatory_parameters}})->GetFunction());
|
| +{% if function.conditional_string %}
|
| +#endif // {{function.conditional_string}}
|
| +{% endif %}
|
| +
|
| +{% endif %}
|
| +{% endfor %}
|
| +}
|
| +{% endif %}
|
| +{% if inherits_extended_attribute_active_dom_object %}
|
| +ActiveDOMObject* {{v8_class_name}}::toActiveDOMObject(v8::Handle<v8::Object> object)
|
| +{
|
| + return {{active_dom_object_return_value}};
|
| +}
|
| +
|
| +{% endif %}
|
| +{% if inherits_event_target %}
|
| +EventTarget* {{v8_class_name}}::toEventTarget(v8::Handle<v8::Object> object)
|
| +{
|
| + return toNative(object);
|
| +}
|
| +
|
| +{% endif %}
|
| +{% if create_wrapper %}
|
| +
|
| +v8::Handle<v8::Object> {{v8_class_name}}::createWrapper(PassRefPtr<{{create_wrapper_argument_type}}> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
|
| +{
|
| + ASSERT(impl.get());
|
| + ASSERT(DOMDataStore::getWrapper<{{v8_class_name}}>(impl.get(), isolate).IsEmpty());
|
| + if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
|
| + const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObject(impl.get());
|
| + // Might be a XXXConstructor::info instead of an XXX::info. These will both have
|
| + // the same object de-ref functions, though, so use that as the basis of the check.
|
| + RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == info.derefObjectFunction);
|
| + }
|
| +
|
| +{% if inherit_document %}
|
| + if (Frame* frame = impl->frame()) {
|
| + if (frame->script()->initializeMainWorld()) {
|
| + // initializeMainWorld may have created a wrapper for the object, retry from the start.
|
| + v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapper<{{v8_class_name}}>(impl.get(), isolate);
|
| + if (!wrapper.IsEmpty())
|
| + return wrapper;
|
| + }
|
| + }
|
| +{% endif %}
|
| +
|
| + v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &info, toInternalPointer(impl.get()), isolate);
|
| + if (UNLIKELY(wrapper.IsEmpty()))
|
| + return wrapper;
|
| +{% if interface_name == 'ArrayBuffer' %}
|
| + if (!impl->hasDeallocationObserver()) {
|
| + v8::V8::AdjustAmountOfExternalAllocatedMemory(impl->byteLength());
|
| + impl->setDeallocationObserver(V8ArrayBufferDeallocationObserver::instance());
|
| + }
|
| +{% elif is_typed_array_type %}
|
| + if (!impl->buffer()->hasDeallocationObserver()) {
|
| + v8::V8::AdjustAmountOfExternalAllocatedMemory(impl->buffer()->byteLength());
|
| + impl->buffer()->setDeallocationObserver(V8ArrayBufferDeallocationObserver::instance());
|
| + }
|
| +{% endif %}
|
| + installPerContextProperties(wrapper, impl.get(), isolate);
|
| + V8DOMWrapper::associateObjectWithWrapper<{{v8_class_name}}>(impl, &info, wrapper, isolate, {{wrapper_configuration}});
|
| + return wrapper;
|
| +}
|
| +{% endif %}
|
| +void {{v8_class_name}}::derefObject(void* object)
|
| +{
|
| + fromInternalPointer(object)->deref();
|
| +}
|
| +
|
| +} // namespace WebCore
|
| +{% if conditional_string %}
|
| +
|
| +#endif // {{conditional_string}}
|
| +{% endif %}
|
| +
|
|
|