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

Unified Diff: Source/bindings/templates/interface_base.cpp

Issue 953473002: bindings: Supports [Replaceable] accessors. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed a review comment. Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: Source/bindings/templates/interface_base.cpp
diff --git a/Source/bindings/templates/interface_base.cpp b/Source/bindings/templates/interface_base.cpp
index b5dce157bc2d5a7edd9433e158a94e916f9d3cb2..3faaad5836828b2d9987fa4f03000d58bb46c518 100644
--- a/Source/bindings/templates/interface_base.cpp
+++ b/Source/bindings/templates/interface_base.cpp
@@ -51,6 +51,34 @@ static void (*{{method.name}}MethodForPartialInterface)(const v8::FunctionCallba
{{constant_getter_callback(constant)}}
{% endfor %}
{# Attributes #}
+{% block replaceable_attribute_setter_and_callback %}
+{% if has_replaceable_attributes or has_constructor_attributes %}
+template<class CallbackInfo>
+static void {{cpp_class}}ForceSetAttributeOnThis(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const CallbackInfo& info)
+{
+ {% if is_check_security %}
+ {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
+ v8::String::Utf8Value attributeName(name);
+ ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName, "{{interface_name}}", info.Holder(), info.GetIsolate());
+ if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->frame(), exceptionState)) {
+ exceptionState.throwIfNeeded();
+ return;
+ }
+ {% endif %}
+ if (info.This()->IsObject())
haraken 2015/02/25 14:27:34 Not related to your CL, I guess this is always tru
Yuki 2015/02/25 14:33:12 Will do.
+ v8::Local<v8::Object>::Cast(info.This())->ForceSet(name, v8Value);
+}
+
+{% endif %}
+{% if has_constructor_attributes %}
+static void {{cpp_class}}ForceSetAttributeOnThisCallback(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
haraken 2015/02/25 14:27:34 Not related to your CL, do we need this method ind
Yuki 2015/02/25 14:33:12 I'm still studying what constructor attributes are
+{
+ {{cpp_class_or_partial}}V8Internal::{{cpp_class}}ForceSetAttributeOnThis(name, v8Value, info);
+}
+
+{% endif %}
+{% endblock %}
+{##############################################################################}
{% from 'attributes.cpp' import constructor_getter_callback,
attribute_getter, attribute_getter_callback,
attribute_setter, attribute_setter_callback,
@@ -64,7 +92,9 @@ static void (*{{method.name}}MethodForPartialInterface)(const v8::FunctionCallba
{{attribute_getter(attribute, world_suffix)}}
{% endif %}
{{attribute_getter_callback(attribute, world_suffix)}}
-{% if not attribute.is_read_only or attribute.put_forwards %}
+{% if (not attribute.is_read_only or
+ attribute.put_forwards or
+ attribute.is_replaceable) %}
{% if not attribute.has_custom_setter %}
{{attribute_setter(attribute, world_suffix)}}
{% endif %}
@@ -95,31 +125,6 @@ static void {{cpp_class}}ConstructorGetter(v8::Local<v8::String>, const v8::Prop
{% endfor %}
{% endfor %}
{##############################################################################}
-{% block replaceable_attribute_setter_and_callback %}
-{% 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)
-{
- {% if is_check_security %}
- {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
- v8::String::Utf8Value attributeName(name);
- ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName, "{{interface_name}}", info.Holder(), info.GetIsolate());
- if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->frame(), exceptionState)) {
- exceptionState.throwIfNeeded();
- return;
- }
- {% endif %}
- if (info.This()->IsObject())
- v8::Local<v8::Object>::Cast(info.This())->ForceSet(name, v8Value);
-}
-
-static void {{cpp_class}}ForceSetAttributeOnThisCallback(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
-{
- {{cpp_class_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>)
« no previous file with comments | « Source/bindings/templates/attributes.cpp ('k') | Source/bindings/tests/idls/core/TestInterfaceCheckSecurity.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698