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

Unified 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, 8 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_attributes.py ('k') | Source/bindings/tests/results/V8TestInterface.cpp » ('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 36fced2352cc6281c2266cd009ff39d521a2f3f9..f396959312a2a09cf7df521ba3c595bf08b80838 100644
--- a/Source/bindings/templates/attributes.cpp
+++ b/Source/bindings/templates/attributes.cpp
@@ -257,8 +257,20 @@ v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info
{% elif not is_node %}{# EventHandler hack #}
moveEventListenerToNewWrapper(holder, {{attribute.event_handler_getter_expression}}, v8Value, {{v8_class}}::eventListenerCacheIndex, info.GetIsolate());
{% endif %}
- {% if attribute.enum_validation_expression %}
- {# Setter ignores invalid enum values: http://www.w3.org/TR/WebIDL/#idl-enums #}
+ {# Type checking, possibly throw a TypeError, per:
+ http://www.w3.org/TR/WebIDL/#es-type-mapping #}
+ {% if attribute.has_type_checking_unrestricted %}
+ {# Non-finite floating point values (NaN, +Infinity or −Infinity), per:
+ http://heycam.github.io/webidl/#es-float
+ http://heycam.github.io/webidl/#es-double #}
+ if (!std::isfinite(cppValue)) {
+ exceptionState.throwTypeError("The provided {{attribute.idl_type}} value is non-finite.");
+ exceptionState.throwIfNeeded();
+ return;
+ }
+ {% elif attribute.enum_validation_expression %}
+ {# Setter ignores invalid enum values:
+ http://www.w3.org/TR/WebIDL/#idl-enums #}
String string = cppValue;
if (!({{attribute.enum_validation_expression}}))
return;
« 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