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

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

Issue 1539813002: bindings: Fixes [LenientThis] to refer to the correct object. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2564
Patch Set: Created 5 years 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: third_party/WebKit/Source/bindings/templates/attributes.cpp
diff --git a/third_party/WebKit/Source/bindings/templates/attributes.cpp b/third_party/WebKit/Source/bindings/templates/attributes.cpp
index e50f24a0b38506db6a76d696f8dfb639d028c6f4..b636f3d3c685f9b3c548f23feba1449583129e74 100644
--- a/third_party/WebKit/Source/bindings/templates/attributes.cpp
+++ b/third_party/WebKit/Source/bindings/templates/attributes.cpp
@@ -19,14 +19,11 @@ const v8::FunctionCallbackInfo<v8::Value>& info
{# 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())
+ {# Make sure that info.Holder() really points to an instance if [LenientThis]. #}
+ if (!{{v8_class}}::hasInstance(info.Holder(), info.GetIsolate()))
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 %}
+ v8::Local<v8::Object> holder = info.Holder();
{% endif %}
{# impl #}
{% if attribute.cached_attribute_validation_method %}
@@ -263,14 +260,11 @@ v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info
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())
+ {# Make sure that info.Holder() really points to an instance if [LenientThis]. #}
+ if (!{{v8_class}}::hasInstance(info.Holder(), info.GetIsolate()))
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 %}
+ v8::Local<v8::Object> holder = info.Holder();
{% endif %}
{% if raise_exception %}
ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.name}}", "{{interface_name}}", holder, info.GetIsolate());

Powered by Google App Engine
This is Rietveld 408576698