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

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

Issue 265753003: Add support for type checking of floating point attributes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove nop [TypeChecking=Unrestricted] Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 {##############################################################################} 1 {##############################################################################}
2 {% macro attribute_getter(attribute, world_suffix) %} 2 {% macro attribute_getter(attribute, world_suffix) %}
3 {% filter conditional(attribute.conditional_string) %} 3 {% filter conditional(attribute.conditional_string) %}
4 static void {{attribute.name}}AttributeGetter{{world_suffix}}( 4 static void {{attribute.name}}AttributeGetter{{world_suffix}}(
5 {%- if attribute.is_expose_js_accessors %} 5 {%- if attribute.is_expose_js_accessors %}
6 const v8::FunctionCallbackInfo<v8::Value>& info 6 const v8::FunctionCallbackInfo<v8::Value>& info
7 {%- else %} 7 {%- else %}
8 const v8::PropertyCallbackInfo<v8::Value>& info 8 const v8::PropertyCallbackInfo<v8::Value>& info
9 {%- endif %}) 9 {%- endif %})
10 { 10 {
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 {% if attribute.idl_type == 'EventHandler' and interface_name == 'Window' %} 250 {% if attribute.idl_type == 'EventHandler' and interface_name == 'Window' %}
251 if (!impl->document()) 251 if (!impl->document())
252 return; 252 return;
253 {% endif %} 253 {% endif %}
254 {# Convert JS value to C++ value #} 254 {# Convert JS value to C++ value #}
255 {% if attribute.idl_type != 'EventHandler' %} 255 {% if attribute.idl_type != 'EventHandler' %}
256 {{attribute.v8_value_to_local_cpp_value}}; 256 {{attribute.v8_value_to_local_cpp_value}};
257 {% elif not is_node %}{# EventHandler hack #} 257 {% elif not is_node %}{# EventHandler hack #}
258 moveEventListenerToNewWrapper(holder, {{attribute.event_handler_getter_expre ssion}}, v8Value, {{v8_class}}::eventListenerCacheIndex, info.GetIsolate()); 258 moveEventListenerToNewWrapper(holder, {{attribute.event_handler_getter_expre ssion}}, v8Value, {{v8_class}}::eventListenerCacheIndex, info.GetIsolate());
259 {% endif %} 259 {% endif %}
260 {% if attribute.enum_validation_expression %} 260 {# Type checking, possibly throw a TypeError, per:
261 {# Setter ignores invalid enum values: http://www.w3.org/TR/WebIDL/#idl-enum s #} 261 http://www.w3.org/TR/WebIDL/#es-type-mapping #}
262 {% if attribute.has_type_checking_unrestricted %}
263 {# Non-finite floating point values (NaN, +Infinity or −Infinity), per:
264 http://heycam.github.io/webidl/#es-float
265 http://heycam.github.io/webidl/#es-double #}
266 if (!std::isfinite(cppValue)) {
267 exceptionState.throwTypeError("The provided {{attribute.idl_type}} value is non-finite.");
268 exceptionState.throwIfNeeded();
269 return;
270 }
271 {% elif attribute.enum_validation_expression %}
272 {# Setter ignores invalid enum values:
273 http://www.w3.org/TR/WebIDL/#idl-enums #}
262 String string = cppValue; 274 String string = cppValue;
263 if (!({{attribute.enum_validation_expression}})) 275 if (!({{attribute.enum_validation_expression}}))
264 return; 276 return;
265 {% endif %} 277 {% endif %}
266 {# Pre-set context #} 278 {# Pre-set context #}
267 {% if attribute.is_custom_element_callbacks or 279 {% if attribute.is_custom_element_callbacks or
268 (attribute.is_reflect and 280 (attribute.is_reflect and
269 not(attribute.idl_type == 'DOMString' and is_node)) %} 281 not(attribute.idl_type == 'DOMString' and is_node)) %}
270 {# Skip on compact node DOMString getters #} 282 {# Skip on compact node DOMString getters #}
271 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; 283 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 {% endif %} 332 {% endif %}
321 {% if attribute.has_custom_setter %} 333 {% if attribute.has_custom_setter %}
322 {{v8_class}}::{{attribute.name}}AttributeSetterCustom(v8Value, info); 334 {{v8_class}}::{{attribute.name}}AttributeSetterCustom(v8Value, info);
323 {% else %} 335 {% else %}
324 {{cpp_class}}V8Internal::{{attribute.name}}AttributeSetter{{world_suffix}}(v 8Value, info); 336 {{cpp_class}}V8Internal::{{attribute.name}}AttributeSetter{{world_suffix}}(v 8Value, info);
325 {% endif %} 337 {% endif %}
326 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 338 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
327 } 339 }
328 {% endfilter %} 340 {% endfilter %}
329 {% endmacro %} 341 {% endmacro %}
OLDNEW
« no previous file with comments | « Source/bindings/scripts/v8_attributes.py ('k') | Source/bindings/tests/results/V8TestInterface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698