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 1161463009: bindings: Supports [LenientThis] extended attributes. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Added a layout test for [LenientThis]. Created 5 years, 6 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
« no previous file with comments | « Source/bindings/scripts/v8_methods.py ('k') | Source/bindings/tests/idls/core/TestInterface.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/templates/attributes.cpp
diff --git a/Source/bindings/templates/attributes.cpp b/Source/bindings/templates/attributes.cpp
index d1e9c6af832be89932b24f425dfd86744edd7bcc..e5a17b06a86846b959e08804fdd23574e67d3164 100644
--- a/Source/bindings/templates/attributes.cpp
+++ b/Source/bindings/templates/attributes.cpp
@@ -18,8 +18,16 @@ const v8::PropertyCallbackInfo<v8::Value>& info
{% endif %}
{# holder #}
{% if not attribute.is_static %}
+ {% if attribute.is_lenient_this %}
+ v8::Local<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(info.This(), info.GetIsolate());
+ if (holder.IsEmpty())
+ return; // Return silently because of [LenientThis].
+ // Note that it's okay to use |holder|, but |info.Holder()| is still unsafe
+ // and must not be used.
+ {% else %}
v8::Local<v8::Object> holder = info.Holder();
{% endif %}
+ {% endif %}
{# impl #}
{% if attribute.cached_attribute_validation_method %}
v8::Local<v8::String> propertyName = v8AtomicString(info.GetIsolate(), "{{attribute.name}}");
@@ -258,8 +266,16 @@ v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info
not attribute.is_replaceable and
not attribute.constructor_type) or
raise_exception %}
+ {% if attribute.is_lenient_this %}
+ v8::Local<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(info.This(), info.GetIsolate());
+ if (holder.IsEmpty())
+ return; // Return silently because of [LenientThis].
+ // Note that it's okay to use |holder|, but |info.Holder()| is still unsafe
+ // and must not be used.
+ {% else %}
v8::Local<v8::Object> holder = info.Holder();
{% endif %}
+ {% endif %}
{% if raise_exception %}
ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.name}}", "{{interface_name}}", holder, info.GetIsolate());
{% endif %}
@@ -515,6 +531,8 @@ bool {{v8_class}}::PrivateScript::{{attribute.name}}AttributeSetter(LocalFrame*
{% set on_prototype = 'V8DOMConfiguration::OnPrototype'
if interface_name == 'Window' and attribute.idl_type == 'EventHandler'
else 'V8DOMConfiguration::OnInstance' %}
+{% set holder_check = 'V8DOMConfiguration::DoNotCheckHolder'
+ if attribute.is_lenient_this else 'V8DOMConfiguration::CheckHolder' %}
{% set attribute_configuration_list = [
'"%s"' % attribute.name,
getter_callback,
@@ -526,7 +544,10 @@ bool {{v8_class}}::PrivateScript::{{attribute.name}}AttributeSetter(LocalFrame*
property_attribute,
only_exposed_to_private_script,
] %}
-{% if not attribute.is_expose_js_accessors %}
+{% if attribute.is_expose_js_accessors %}
+{% set attribute_configuration_list = attribute_configuration_list
+ + [holder_check] %}
+{% else %}
{% set attribute_configuration_list = attribute_configuration_list
+ [on_prototype] %}
{% endif %}
« no previous file with comments | « Source/bindings/scripts/v8_methods.py ('k') | Source/bindings/tests/idls/core/TestInterface.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698