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

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

Issue 953473002: bindings: Supports [Replaceable] accessors. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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/attributes.cpp
diff --git a/Source/bindings/templates/attributes.cpp b/Source/bindings/templates/attributes.cpp
index f7bc807acd6fcd53e79afed39c967926936fb1f9..b34c87c096ef8699a1faeda9e361ed848af1b7c5 100644
--- a/Source/bindings/templates/attributes.cpp
+++ b/Source/bindings/templates/attributes.cpp
@@ -211,7 +211,7 @@ v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info
{% set cpp_class, v8_class = 'Element', 'V8Element' %}
{% endif %}
{# Local variables #}
- {% if not attribute.is_static %}
+ {% if not attribute.is_static and not attribute.is_replaceable %}
haraken 2015/02/23 14:48:52 For readability, it seems better to remove this br
Yuki 2015/02/23 15:18:42 Most of attributes need |holder|. Only static att
v8::Local<v8::Object> holder = info.Holder();
{% endif %}
{% if attribute.has_setter_exception_state %}
@@ -226,6 +226,19 @@ v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info
{{attribute.cpp_type}} impl = WTF::getPtr(proxyImpl->{{attribute.name}}());
if (!impl)
return;
+ {% elif attribute.is_replaceable %}
+ {% if is_check_security %}
haraken 2015/02/23 14:48:52 Why do we have the is_check_security clause only i
Yuki 2015/02/23 15:18:42 The code was copied from https://code.google.com/p
+ {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
+ ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.name}}", "{{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::String> propertyName = v8AtomicString(info.GetIsolate(), "{{attribute.name}}");
+ v8::Local<v8::Object>::Cast(info.This())->ForceSet(propertyName, v8Value);
+ }
{% elif not attribute.is_static %}
{{cpp_class}}* impl = {{v8_class}}::toImpl(holder);
{% endif %}
@@ -235,7 +248,9 @@ v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info
{% endif %}
{# Convert JS value to C++ value #}
{% if attribute.idl_type != 'EventHandler' %}
+ {% if attribute.v8_value_to_local_cpp_value %}
{{attribute.v8_value_to_local_cpp_value}};
+ {% endif %}
{% elif not is_node %}{# EventHandler hack #}
moveEventListenerToNewWrapper(info.GetIsolate(), holder, {{attribute.event_handler_getter_expression}}, v8Value, {{v8_class}}::eventListenerCacheIndex);
{% endif %}
@@ -268,7 +283,9 @@ v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info
ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate());
{% endif %}
{# Set #}
+ {% if attribute.cpp_setter %}
{{attribute.cpp_setter}};
+ {% endif %}
{# Post-set #}
{% if attribute.is_setter_raises_exception %}
exceptionState.throwIfNeeded();

Powered by Google App Engine
This is Rietveld 408576698