Index: Source/bindings/templates/interface_base.cpp |
diff --git a/Source/bindings/templates/interface_base.cpp b/Source/bindings/templates/interface_base.cpp |
index 03093ec3cc8c3e948f02b698fcbe5f1430b0ba90..e4b18c30e719066df8212d7abc2b233d4f3e426b 100644 |
--- a/Source/bindings/templates/interface_base.cpp |
+++ b/Source/bindings/templates/interface_base.cpp |
@@ -6,12 +6,14 @@ |
#include "config.h" |
{% filter conditional(conditional_string) %} |
-#include "{{v8_class}}.h" |
+{% set empty_or_partial = '' if not is_partial else 'Partial' %} |
+#include "{{v8_class}}{{empty_or_partial}}.h" |
-{% for filename in cpp_includes if filename != '%s.h' % v8_class %} |
+{% for filename in cpp_includes if filename != '%s%s.h' % (cpp_class, empty_or_partial) %} |
#include "{{filename}}" |
{% endfor %} |
+{% block initialize_script_wrappable %}{% endblock %} |
namespace blink { |
{% set to_active_dom_object = '%s::toActiveDOMObject' % v8_class |
if is_active_dom_object else '0' %} |
@@ -24,7 +26,9 @@ namespace blink { |
{% set wrapper_type_prototype = 'WrapperTypeExceptionPrototype' if is_exception else |
'WrapperTypeObjectPrototype' %} |
-const WrapperTypeInfo {{v8_class}}::wrapperTypeInfo = { gin::kEmbedderBlink, {{v8_class}}::domTemplate, {{v8_class}}::refObject, {{v8_class}}::derefObject, {{v8_class}}::createPersistentHandle, {{to_active_dom_object}}, {{to_event_target}}, {{visit_dom_wrapper}}, {{v8_class}}::installConditionallyEnabledMethods, {{v8_class}}::installConditionallyEnabledProperties, {{parent_wrapper_type_info}}, WrapperTypeInfo::{{wrapper_type_prototype}}, WrapperTypeInfo::{{wrapper_class_id}}, WrapperTypeInfo::{{lifetime}}, WrapperTypeInfo::{{gc_type}} }; |
+{% set wrapper_type_info_type = 'const ' if not has_partial_interface else '' %} |
haraken
2014/10/09 04:24:01
Avoid 'if not ... else ...'. Use 'if ... else ...'
tasak
2014/10/10 07:52:23
Done.
|
+{% if not is_partial %} |
+{{wrapper_type_info_type}}WrapperTypeInfo {{v8_class}}::wrapperTypeInfo = { gin::kEmbedderBlink, {{v8_class}}::domTemplate, {{v8_class}}::refObject, {{v8_class}}::derefObject, {{v8_class}}::createPersistentHandle, {{to_active_dom_object}}, {{to_event_target}}, {{visit_dom_wrapper}}, {{v8_class}}::installConditionallyEnabledMethods, {{v8_class}}::installConditionallyEnabledProperties, {{parent_wrapper_type_info}}, WrapperTypeInfo::{{wrapper_type_prototype}}, WrapperTypeInfo::{{wrapper_class_id}}, WrapperTypeInfo::{{lifetime}}, WrapperTypeInfo::{{gc_type}} }; |
{% if is_script_wrappable %} |
// This static member must be declared by DEFINE_WRAPPERTYPEINFO in {{cpp_class}}.h. |
@@ -33,7 +37,15 @@ const WrapperTypeInfo {{v8_class}}::wrapperTypeInfo = { gin::kEmbedderBlink, {{v |
const WrapperTypeInfo& {{cpp_class}}::s_wrapperTypeInfo = {{v8_class}}::wrapperTypeInfo; |
{% endif %} |
-namespace {{cpp_class}}V8Internal { |
+{% endif %} |
+namespace {{cpp_class}}{{empty_or_partial}}V8Internal { |
+{% if has_partial_interface %} |
+{% for method in methods %} |
+{% if method.overloads and method.overloads.partial_overloads %} |
+static void (*{{method.name}}MethodForPartialInterface)(const v8::FunctionCallbackInfo<v8::Value>&) = 0; |
+{% endif %} |
+{% endfor %} |
+{% endif %} |
{# Constants #} |
{% from 'constants.cpp' import constant_getter_callback |
@@ -87,6 +99,7 @@ static void {{cpp_class}}ConstructorGetter(v8::Local<v8::String>, const v8::Prop |
{% endfor %} |
{##############################################################################} |
{% block replaceable_attribute_setter_and_callback %} |
+{% set empty_or_partial = '' if not is_partial else 'Partial' %} |
{% if has_replaceable_attributes or has_constructor_attributes %} |
static void {{cpp_class}}ForceSetAttributeOnThis(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) |
{ |
@@ -105,13 +118,29 @@ static void {{cpp_class}}ForceSetAttributeOnThis(v8::Local<v8::String> name, v8: |
static void {{cpp_class}}ForceSetAttributeOnThisCallback(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) |
{ |
- {{cpp_class}}V8Internal::{{cpp_class}}ForceSetAttributeOnThis(name, v8Value, info); |
+ {{cpp_class}}{{empty_or_partial}}V8Internal::{{cpp_class}}ForceSetAttributeOnThis(name, v8Value, info); |
+} |
+ |
+{% endif %} |
+{% endblock %} |
+{##############################################################################} |
+{% block security_check_functions %} |
+{% if has_access_check_callbacks %} |
+bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::AccessType type, v8::Local<v8::Value>) |
+{ |
+ {{cpp_class}}* impl = {{v8_class}}::toImpl(host); |
+ return BindingSecurity::shouldAllowAccessToFrame(v8::Isolate::GetCurrent(), impl->frame(), DoNotReportSecurityError); |
+} |
+ |
+bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType type, v8::Local<v8::Value>) |
+{ |
+ {{cpp_class}}* impl = {{v8_class}}::toImpl(host); |
+ return BindingSecurity::shouldAllowAccessToFrame(v8::Isolate::GetCurrent(), impl->frame(), DoNotReportSecurityError); |
} |
{% endif %} |
haraken
2014/10/09 04:24:01
You can land this change separately.
tasak
2014/10/10 07:52:23
Done.
|
{% endblock %} |
{##############################################################################} |
-{% block security_check_functions %}{% endblock %} |
{# Methods #} |
{% from 'methods.cpp' import generate_method, overload_resolution_method, |
method_callback, origin_safe_method_getter, generate_constructor, |
@@ -120,17 +149,26 @@ static void {{cpp_class}}ForceSetAttributeOnThisCallback(v8::Local<v8::String> n |
{% for method in methods %} |
{% if method.should_be_exposed_to_script %} |
{% for world_suffix in method.world_suffixes %} |
-{% if not method.is_custom %} |
+{% if not method.is_custom and method.visible %} |
{{generate_method(method, world_suffix)}} |
{% endif %} |
-{% if method.overloads %} |
+{% if method.overloads and method.overloads.visible %} |
{{overload_resolution_method(method.overloads, world_suffix)}} |
{% endif %} |
{% if not method.overload_index or method.overloads %} |
+{% set overloads_callback_visible_in_partial = True |
+ if is_partial and method.overloads and method.overloads.visible and not method.overloads.partial_overloads else False %} |
+{% set overloads_callback_visible_in_original = True |
+ if not is_partial and method.overloads and method.overloads.visible else False %} |
+{% set method_visible = True |
+ if not method.overloads and method.visible else False %} |
+{% if method_visible or overloads_callback_visible_in_partial or overloads_callback_visible_in_original %} |
haraken
2014/10/09 04:24:01
Add a comment about what these variables mean.
(A
tasak
2014/10/10 07:52:23
Done.
|
{# A single callback is generated for overloaded methods #} |
+{# with considering partial overloads #} |
{{method_callback(method, world_suffix)}} |
{% endif %} |
-{% if method.is_do_not_check_security %} |
+{% endif %} |
+{% if method.is_do_not_check_security and method.visible %} |
{{origin_safe_method_getter(method, world_suffix)}} |
{% endif %} |
{% endfor %} |
@@ -164,12 +202,13 @@ static void {{cpp_class}}ForceSetAttributeOnThisCallback(v8::Local<v8::String> n |
{% block named_property_deleter_callback %}{% endblock %} |
{% block named_property_enumerator %}{% endblock %} |
{% block named_property_enumerator_callback %}{% endblock %} |
-} // namespace {{cpp_class}}V8Internal |
+} // namespace {{cpp_class}}{{empty_or_partial}}V8Internal |
{% block visit_dom_wrapper %}{% endblock %} |
{% block shadow_attributes %}{% endblock %} |
{##############################################################################} |
{% block install_attributes %} |
+{% from 'attributes.cpp' import attribute_configuration with context %} |
{% if has_attribute_configuration %} |
static const V8DOMConfiguration::AttributeConfiguration {{v8_class}}Attributes[] = { |
{% for attribute in attributes |
@@ -190,6 +229,7 @@ static const V8DOMConfiguration::AttributeConfiguration {{v8_class}}Attributes[] |
{% endblock %} |
{##############################################################################} |
{% block install_accessors %} |
+{% from 'attributes.cpp' import attribute_configuration with context %} |
{% if has_accessors %} |
static const V8DOMConfiguration::AccessorConfiguration {{v8_class}}Accessors[] = { |
{% for attribute in attributes if attribute.is_expose_js_accessors and attribute.should_be_exposed_to_script %} |
@@ -221,10 +261,20 @@ static const V8DOMConfiguration::MethodConfiguration {{v8_class}}Methods[] = { |
{##############################################################################} |
{% block install_dom_template %} |
{% from 'methods.cpp' import install_custom_signature with context %} |
+{% from 'attributes.cpp' import attribute_configuration with context %} |
{% from 'constants.cpp' import install_constants with context %} |
+{% set empty_or_partial = '' if not is_partial else 'Partial' %} |
+{% if has_partial_interface or is_partial %} |
+void {{v8_class}}{{empty_or_partial}}::install{{v8_class}}Template(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate) |
+{% else %} |
static void install{{v8_class}}Template(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate) |
+{% endif %} |
{ |
+ {% if not is_partial %} |
functionTemplate->ReadOnlyPrototype(); |
haraken
2014/10/09 04:24:01
Why don't you need to call ReadOnlyPrototype if no
tasak
2014/10/10 07:52:23
When partial interface, ReadOnlyPrototype will be
|
+ {% else %} |
+ {{v8_class}}::install{{v8_class}}Template(functionTemplate, isolate); |
+ {% endif %} |
v8::Local<v8::Signature> defaultSignature; |
{% set parent_template = |
@@ -288,7 +338,7 @@ static void install{{v8_class}}Template(v8::Handle<v8::FunctionTemplate> functio |
{{install_constants() | indent}} |
{% endif %} |
{# Special operations #} |
- {# V8 has access-check callback API and it's used on Window instead of |
+ {# V8 has access-check callback API and it\'s used on Window instead of |
deleters or enumerators; see ObjectTemplate::SetAccessCheckCallbacks. |
In addition, the getter should be set on the prototype template, to get |
the implementation straight out of the Window prototype, regardless of |
@@ -330,7 +380,7 @@ static void install{{v8_class}}Template(v8::Handle<v8::FunctionTemplate> functio |
functionTemplate->{{set_on_template}}()->SetNamedPropertyHandler({{named_property_getter_callback}}, {{named_property_setter_callback}}, {{named_property_query_callback}}, {{named_property_deleter_callback}}, {{named_property_enumerator_callback}}); |
{% endif %} |
{% if iterator_method %} |
- static const V8DOMConfiguration::SymbolKeyedMethodConfiguration symbolKeyedIteratorConfiguration = { v8::Symbol::GetIterator, {{cpp_class}}V8Internal::iteratorMethodCallback, 0, V8DOMConfiguration::ExposedToAllScripts }; |
+ static const V8DOMConfiguration::SymbolKeyedMethodConfiguration symbolKeyedIteratorConfiguration = { v8::Symbol::GetIterator, {{cpp_class}}{{empty_or_partial}}V8Internal::iteratorMethodCallback, 0, V8DOMConfiguration::ExposedToAllScripts }; |
V8DOMConfiguration::installMethod(prototypeTemplate, defaultSignature, v8::DontDelete, symbolKeyedIteratorConfiguration, isolate); |
{% endif %} |
{# End special operations #} |
@@ -363,6 +413,7 @@ static void install{{v8_class}}Template(v8::Handle<v8::FunctionTemplate> functio |
{% endfilter %} |
{% endfor %} |
{# Special interfaces #} |
+ {% if not is_partial %} |
{% if interface_name == 'Window' %} |
prototypeTemplate->SetInternalFieldCount(V8Window::internalFieldCount); |
@@ -380,6 +431,7 @@ static void install{{v8_class}}Template(v8::Handle<v8::FunctionTemplate> functio |
// Custom toString template |
functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate()); |
+ {% endif %} |
} |
{% endblock %} |
@@ -404,5 +456,6 @@ static void install{{v8_class}}Template(v8::Handle<v8::FunctionTemplate> functio |
{{attribute_setter_implemented_in_private_script(attribute)}} |
{% endif %} |
{% endfor %} |
+{% block partial_interface %}{% endblock %} |
} // namespace blink |
{% endfilter %} |