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

Side by Side Diff: Source/bindings/templates/interface_base.cpp

Issue 1153613007: bindings: Use CreateDataProperty() instead of ForceSet() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix uninitialized error 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 unified diff | Download patch
OLDNEW
1 {% include 'copyright_block.txt' %} 1 {% include 'copyright_block.txt' %}
2 #include "config.h" 2 #include "config.h"
3 {% filter conditional(conditional_string) %} 3 {% filter conditional(conditional_string) %}
4 #include "{{v8_class_or_partial}}.h" 4 #include "{{v8_class_or_partial}}.h"
5 5
6 {% for filename in cpp_includes if filename != '%s.h' % cpp_class_or_partial %} 6 {% for filename in cpp_includes if filename != '%s.h' % cpp_class_or_partial %}
7 #include "{{filename}}" 7 #include "{{filename}}"
8 {% endfor %} 8 {% endfor %}
9 9
10 namespace blink { 10 namespace blink {
(...skipping 30 matching lines...) Expand all
41 {# Constants #} 41 {# Constants #}
42 {% from 'constants.cpp' import constant_getter_callback 42 {% from 'constants.cpp' import constant_getter_callback
43 with context %} 43 with context %}
44 {% for constant in special_getter_constants %} 44 {% for constant in special_getter_constants %}
45 {{constant_getter_callback(constant)}} 45 {{constant_getter_callback(constant)}}
46 {% endfor %} 46 {% endfor %}
47 {# Attributes #} 47 {# Attributes #}
48 {% block replaceable_attribute_setter_and_callback %} 48 {% block replaceable_attribute_setter_and_callback %}
49 {% if has_replaceable_attributes or has_constructor_attributes %} 49 {% if has_replaceable_attributes or has_constructor_attributes %}
50 template<class CallbackInfo> 50 template<class CallbackInfo>
51 static void {{cpp_class}}ForceSetAttributeOnThis(v8::Local<v8::Name> name, v8::L ocal<v8::Value> v8Value, const CallbackInfo& info) 51 static bool {{cpp_class}}CreateDataProperty(v8::Local<v8::Name> name, v8::Local< v8::Value> v8Value, const CallbackInfo& info)
52 { 52 {
53 {% if is_check_security %} 53 {% if is_check_security %}
54 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 54 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
55 v8::String::Utf8Value attributeName(name); 55 v8::String::Utf8Value attributeName(name);
56 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName, "{{interface_name}}", info.Holder(), info.GetIsolate()); 56 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName, "{{interface_name}}", info.Holder(), info.GetIsolate());
57 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram e(), exceptionState)) { 57 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram e(), exceptionState)) {
58 exceptionState.throwIfNeeded(); 58 exceptionState.throwIfNeeded();
59 return; 59 return false;
60 } 60 }
61 {% endif %} 61 {% endif %}
62 ASSERT(info.This()->IsObject()); 62 ASSERT(info.This()->IsObject());
63 v8::Local<v8::Object>::Cast(info.This())->ForceSet(info.GetIsolate()->GetCur rentContext(), name, v8Value); 63 return v8CallBoolean(v8::Local<v8::Object>::Cast(info.This())->CreateDataPro perty(info.GetIsolate()->GetCurrentContext(), name, v8Value));
64 } 64 }
65 65
66 {% if has_constructor_attributes %} 66 {% if has_constructor_attributes %}
67 static void {{cpp_class}}ConstructorAttributeSetterCallback(v8::Local<v8::Name>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 67 static void {{cpp_class}}ConstructorAttributeSetterCallback(v8::Local<v8::Name>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
68 { 68 {
69 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); 69 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
70 do { 70 do {
71 v8::Local<v8::Value> data = info.Data(); 71 v8::Local<v8::Value> data = info.Data();
72 ASSERT(data->IsExternal()); 72 ASSERT(data->IsExternal());
73 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()- >CreationContext()); 73 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()- >CreationContext());
74 if (!perContextData) 74 if (!perContextData)
75 break; 75 break;
76 const WrapperTypeInfo* wrapperTypeInfo = WrapperTypeInfo::unwrap(data); 76 const WrapperTypeInfo* wrapperTypeInfo = WrapperTypeInfo::unwrap(data);
77 if (!wrapperTypeInfo) 77 if (!wrapperTypeInfo)
78 break; 78 break;
79 {{cpp_class}}ForceSetAttributeOnThis(v8String(info.GetIsolate(), wrapper TypeInfo->interfaceName), v8Value, info); 79 {{cpp_class}}CreateDataProperty(v8String(info.GetIsolate(), wrapperTypeI nfo->interfaceName), v8Value, info);
80 } while (false); // do ... while (false) just for use of break 80 } while (false); // do ... while (false) just for use of break
81 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 81 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
82 } 82 }
83 83
84 {% endif %} 84 {% endif %}
85 {% endif %} 85 {% endif %}
86 {% endblock %} 86 {% endblock %}
87 {##############################################################################} 87 {##############################################################################}
88 {% from 'attributes.cpp' import constructor_getter_callback, 88 {% from 'attributes.cpp' import constructor_getter_callback,
89 attribute_getter, attribute_getter_callback, 89 attribute_getter, attribute_getter_callback,
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 {% endfor %} 493 {% endfor %}
494 {% for attribute in attributes if attribute.is_implemented_in_private_script %} 494 {% for attribute in attributes if attribute.is_implemented_in_private_script %}
495 {{attribute_getter_implemented_in_private_script(attribute)}} 495 {{attribute_getter_implemented_in_private_script(attribute)}}
496 {% if attribute.has_setter %} 496 {% if attribute.has_setter %}
497 {{attribute_setter_implemented_in_private_script(attribute)}} 497 {{attribute_setter_implemented_in_private_script(attribute)}}
498 {% endif %} 498 {% endif %}
499 {% endfor %} 499 {% endfor %}
500 {% block partial_interface %}{% endblock %} 500 {% block partial_interface %}{% endblock %}
501 } // namespace blink 501 } // namespace blink
502 {% endfilter %} 502 {% endfilter %}
OLDNEW
« no previous file with comments | « Source/bindings/templates/interface.cpp ('k') | Source/bindings/tests/results/core/V8TestDictionary.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698