<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[200131] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/200131">200131</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2016-04-27 10:05:40 -0700 (Wed, 27 Apr 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Web IDL] Clean up support for [Clamp] IDL extended attribute
https://bugs.webkit.org/show_bug.cgi?id=157060

Reviewed by Darin Adler.

Clean up support for [Clamp] IDL extended attribute:
1.  Move [Clamp] handling in the bindings generator from the parameter
    conversion to JSValueToNative(). This has the benefit of
    simplifying the parameter conversion code, adding support for [Clamp]
    on non-readonly attributes, and improving consistency by handling
    this in the same place as [EnforceRange].
2.  Add 'Clamp' to the IntegerConversionConfiguration enumeration in
    JSDOMbindings.h and add support for it to the various toInt*() /
    toUInt*() functions, similary to [EnforceRange]. Call these from
    the generated bindings.

* bindings/js/JSDOMBinding.cpp:
(WebCore::toSmallerInt):
(WebCore::toSmallerUInt):
(WebCore::toInt32EnforceRange):
(WebCore::toInt32Clamp):
(WebCore::toUInt32Clamp):
(WebCore::toUInt32EnforceRange):
(WebCore::toInt64):
(WebCore::toUInt64):
(WebCore::toUInt8): Deleted.
(WebCore::toUInt16): Deleted.
* bindings/js/JSDOMBinding.h:
(WebCore::toInt32):
(WebCore::toUInt32):
* bindings/scripts/CodeGeneratorJS.pm:
(JSValueToNative):
(GenerateParametersCheck): Deleted.
* bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:
(webkit_dom_test_obj_set_property):
(webkit_dom_test_obj_get_property):
(webkit_dom_test_obj_class_init):
(webkit_dom_test_obj_class_method_with_enforce_range):
(webkit_dom_test_obj_get_clamped_short_attr):
(webkit_dom_test_obj_set_clamped_short_attr):
(webkit_dom_test_obj_get_enforce_range_short_attr):
(webkit_dom_test_obj_set_enforce_range_short_attr):
* bindings/scripts/test/GObject/WebKitDOMTestObj.h:
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::jsTestObjClampedShortAttr):
(WebCore::jsTestObjEnforceRangeShortAttr):
(WebCore::setJSTestObjClampedShortAttr):
(WebCore::setJSTestObjEnforceRangeShortAttr):
(WebCore::jsTestObjPrototypeFunctionClassMethodWithClamp):
(WebCore::jsTestObjPrototypeFunctionClassMethodWithEnforceRange):
(WebCore::jsTestObjConstructorFunctionClassMethodWithOptional): Deleted.
(WebCore::jsTestObjConstructorFunctionClassMethod2): Deleted.
* bindings/scripts/test/JS/JSTestTypedefs.cpp:
(WebCore::jsTestTypedefsPrototypeFunctionFuncWithClamp):
(WebCore::jsTestTypedefsPrototypeFunctionImmutablePointFunction): Deleted.
* bindings/scripts/test/ObjC/DOMTestObj.h:
* bindings/scripts/test/ObjC/DOMTestObj.mm:
(-[DOMTestObj clampedShortAttr]):
(-[DOMTestObj setClampedShortAttr:]):
(-[DOMTestObj enforceRangeShortAttr]):
(-[DOMTestObj setEnforceRangeShortAttr:]):
(-[DOMTestObj classMethodWithEnforceRange:objArgsLong:]):
* bindings/scripts/test/TestObj.idl:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMBindingcpp">trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMBindingh">trunk/Source/WebCore/bindings/js/JSDOMBinding.h</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm">trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestGObjectWebKitDOMTestObjcpp">trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestGObjectWebKitDOMTestObjh">trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestObjcpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestTypedefscpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestObjCDOMTestObjh">trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestObjCDOMTestObjmm">trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestTestObjidl">trunk/Source/WebCore/bindings/scripts/test/TestObj.idl</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (200130 => 200131)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-04-27 16:48:59 UTC (rev 200130)
+++ trunk/Source/WebCore/ChangeLog        2016-04-27 17:05:40 UTC (rev 200131)
</span><span class="lines">@@ -1,3 +1,69 @@
</span><ins>+2016-04-27  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        [Web IDL] Clean up support for [Clamp] IDL extended attribute
+        https://bugs.webkit.org/show_bug.cgi?id=157060
+
+        Reviewed by Darin Adler.
+
+        Clean up support for [Clamp] IDL extended attribute:
+        1.  Move [Clamp] handling in the bindings generator from the parameter
+            conversion to JSValueToNative(). This has the benefit of
+            simplifying the parameter conversion code, adding support for [Clamp]
+            on non-readonly attributes, and improving consistency by handling
+            this in the same place as [EnforceRange].
+        2.  Add 'Clamp' to the IntegerConversionConfiguration enumeration in
+            JSDOMbindings.h and add support for it to the various toInt*() /
+            toUInt*() functions, similary to [EnforceRange]. Call these from
+            the generated bindings.
+
+        * bindings/js/JSDOMBinding.cpp:
+        (WebCore::toSmallerInt):
+        (WebCore::toSmallerUInt):
+        (WebCore::toInt32EnforceRange):
+        (WebCore::toInt32Clamp):
+        (WebCore::toUInt32Clamp):
+        (WebCore::toUInt32EnforceRange):
+        (WebCore::toInt64):
+        (WebCore::toUInt64):
+        (WebCore::toUInt8): Deleted.
+        (WebCore::toUInt16): Deleted.
+        * bindings/js/JSDOMBinding.h:
+        (WebCore::toInt32):
+        (WebCore::toUInt32):
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (JSValueToNative):
+        (GenerateParametersCheck): Deleted.
+        * bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:
+        (webkit_dom_test_obj_set_property):
+        (webkit_dom_test_obj_get_property):
+        (webkit_dom_test_obj_class_init):
+        (webkit_dom_test_obj_class_method_with_enforce_range):
+        (webkit_dom_test_obj_get_clamped_short_attr):
+        (webkit_dom_test_obj_set_clamped_short_attr):
+        (webkit_dom_test_obj_get_enforce_range_short_attr):
+        (webkit_dom_test_obj_set_enforce_range_short_attr):
+        * bindings/scripts/test/GObject/WebKitDOMTestObj.h:
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore::jsTestObjClampedShortAttr):
+        (WebCore::jsTestObjEnforceRangeShortAttr):
+        (WebCore::setJSTestObjClampedShortAttr):
+        (WebCore::setJSTestObjEnforceRangeShortAttr):
+        (WebCore::jsTestObjPrototypeFunctionClassMethodWithClamp):
+        (WebCore::jsTestObjPrototypeFunctionClassMethodWithEnforceRange):
+        (WebCore::jsTestObjConstructorFunctionClassMethodWithOptional): Deleted.
+        (WebCore::jsTestObjConstructorFunctionClassMethod2): Deleted.
+        * bindings/scripts/test/JS/JSTestTypedefs.cpp:
+        (WebCore::jsTestTypedefsPrototypeFunctionFuncWithClamp):
+        (WebCore::jsTestTypedefsPrototypeFunctionImmutablePointFunction): Deleted.
+        * bindings/scripts/test/ObjC/DOMTestObj.h:
+        * bindings/scripts/test/ObjC/DOMTestObj.mm:
+        (-[DOMTestObj clampedShortAttr]):
+        (-[DOMTestObj setClampedShortAttr:]):
+        (-[DOMTestObj enforceRangeShortAttr]):
+        (-[DOMTestObj setEnforceRangeShortAttr:]):
+        (-[DOMTestObj classMethodWithEnforceRange:objArgsLong:]):
+        * bindings/scripts/test/TestObj.idl:
+
</ins><span class="cx"> 2016-04-27  Daniel Bates  &lt;dabates@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         CSP: Add app-specific workaround for Ecobee and Quora
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMBindingcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp (200130 => 200131)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp        2016-04-27 16:48:59 UTC (rev 200130)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp        2016-04-27 17:05:40 UTC (rev 200131)
</span><span class="lines">@@ -418,20 +418,31 @@
</span><span class="cx">         int32_t d = value.asInt32();
</span><span class="cx">         if (d &gt;= LimitsTrait::minValue &amp;&amp; d &lt;= LimitsTrait::maxValue)
</span><span class="cx">             return static_cast&lt;T&gt;(d);
</span><del>-        if (configuration == EnforceRange) {
</del><ins>+        switch (configuration) {
+        case NormalConversion:
+            break;
+        case EnforceRange:
</ins><span class="cx">             throwTypeError(exec);
</span><span class="cx">             return 0;
</span><ins>+        case Clamp:
+            return d &lt; LimitsTrait::minValue ? LimitsTrait::minValue : LimitsTrait::maxValue;
</ins><span class="cx">         }
</span><span class="cx">         d %= LimitsTrait::numberOfValues;
</span><span class="cx">         return static_cast&lt;T&gt;(d &gt; LimitsTrait::maxValue ? d - LimitsTrait::numberOfValues : d);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     double x = value.toNumber(exec);
</span><del>-    if (exec-&gt;hadException())
</del><ins>+    if (UNLIKELY(exec-&gt;hadException()))
</ins><span class="cx">         return 0;
</span><span class="cx"> 
</span><del>-    if (configuration == EnforceRange)
</del><ins>+    switch (configuration) {
+    case NormalConversion:
+        break;
+    case EnforceRange:
</ins><span class="cx">         return enforceRange(exec, x, LimitsTrait::minValue, LimitsTrait::maxValue);
</span><ins>+    case Clamp:
+        return std::isnan(x) ? 0 : clampTo&lt;T&gt;(x);
+    }
</ins><span class="cx"> 
</span><span class="cx">     if (std::isnan(x) || std::isinf(x) || !x)
</span><span class="cx">         return 0;
</span><span class="lines">@@ -451,19 +462,29 @@
</span><span class="cx">         uint32_t d = value.asUInt32();
</span><span class="cx">         if (d &lt;= LimitsTrait::maxValue)
</span><span class="cx">             return static_cast&lt;T&gt;(d);
</span><del>-        if (configuration == EnforceRange) {
</del><ins>+        switch (configuration) {
+        case NormalConversion:
+            return static_cast&lt;T&gt;(d);
+        case EnforceRange:
</ins><span class="cx">             throwTypeError(exec);
</span><span class="cx">             return 0;
</span><ins>+        case Clamp:
+            return LimitsTrait::maxValue;
</ins><span class="cx">         }
</span><del>-        return static_cast&lt;T&gt;(d);
</del><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     double x = value.toNumber(exec);
</span><del>-    if (exec-&gt;hadException())
</del><ins>+    if (UNLIKELY(exec-&gt;hadException()))
</ins><span class="cx">         return 0;
</span><span class="cx"> 
</span><del>-    if (configuration == EnforceRange)
</del><ins>+    switch (configuration) {
+    case NormalConversion:
+        break;
+    case EnforceRange:
</ins><span class="cx">         return enforceRange(exec, x, 0, LimitsTrait::maxValue);
</span><ins>+    case Clamp:
+        return std::isnan(x) ? 0 : clampTo&lt;T&gt;(x);
+    }
</ins><span class="cx"> 
</span><span class="cx">     if (std::isnan(x) || std::isinf(x) || !x)
</span><span class="cx">         return 0;
</span><span class="lines">@@ -503,11 +524,33 @@
</span><span class="cx">         return value.asInt32();
</span><span class="cx"> 
</span><span class="cx">     double x = value.toNumber(exec);
</span><del>-    if (exec-&gt;hadException())
</del><ins>+    if (UNLIKELY(exec-&gt;hadException()))
</ins><span class="cx">         return 0;
</span><span class="cx">     return enforceRange(exec, x, kMinInt32, kMaxInt32);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+int32_t toInt32Clamp(ExecState* exec, JSValue value)
+{
+    if (value.isInt32())
+        return value.asInt32();
+
+    double x = value.toNumber(exec);
+    if (UNLIKELY(exec-&gt;hadException()))
+        return 0;
+    return std::isnan(x) ? 0 : clampTo&lt;int32_t&gt;(x);
+}
+
+uint32_t toUInt32Clamp(ExecState* exec, JSValue value)
+{
+    if (value.isUInt32())
+        return value.asUInt32();
+
+    double x = value.toNumber(exec);
+    if (UNLIKELY(exec-&gt;hadException()))
+        return 0;
+    return std::isnan(x) ? 0 : clampTo&lt;uint32_t&gt;(x);
+}
+
</ins><span class="cx"> // http://www.w3.org/TR/WebIDL/#es-unsigned-long
</span><span class="cx"> uint32_t toUInt32EnforceRange(ExecState* exec, JSValue value)
</span><span class="cx"> {
</span><span class="lines">@@ -515,7 +558,7 @@
</span><span class="cx">         return value.asUInt32();
</span><span class="cx"> 
</span><span class="cx">     double x = value.toNumber(exec);
</span><del>-    if (exec-&gt;hadException())
</del><ins>+    if (UNLIKELY(exec-&gt;hadException()))
</ins><span class="cx">         return 0;
</span><span class="cx">     return enforceRange(exec, x, 0, kMaxUInt32);
</span><span class="cx"> }
</span><span class="lines">@@ -527,11 +570,17 @@
</span><span class="cx">         return value.asInt32();
</span><span class="cx"> 
</span><span class="cx">     double x = value.toNumber(exec);
</span><del>-    if (exec-&gt;hadException())
</del><ins>+    if (UNLIKELY(exec-&gt;hadException()))
</ins><span class="cx">         return 0;
</span><span class="cx"> 
</span><del>-    if (configuration == EnforceRange)
</del><ins>+    switch (configuration) {
+    case NormalConversion:
+        break;
+    case EnforceRange:
</ins><span class="cx">         return enforceRange(exec, x, -kJSMaxInteger, kJSMaxInteger);
</span><ins>+    case Clamp:
+        return std::isnan(x) ? 0 : static_cast&lt;int64_t&gt;(std::min&lt;double&gt;(std::max&lt;double&gt;(x, -kJSMaxInteger), kJSMaxInteger));
+    }
</ins><span class="cx"> 
</span><span class="cx">     // Map NaNs and +/-Infinity to 0; convert finite values modulo 2^64.
</span><span class="cx">     unsigned long long n;
</span><span class="lines">@@ -546,11 +595,17 @@
</span><span class="cx">         return value.asUInt32();
</span><span class="cx"> 
</span><span class="cx">     double x = value.toNumber(exec);
</span><del>-    if (exec-&gt;hadException())
</del><ins>+    if (UNLIKELY(exec-&gt;hadException()))
</ins><span class="cx">         return 0;
</span><span class="cx"> 
</span><del>-    if (configuration == EnforceRange)
</del><ins>+    switch (configuration) {
+    case NormalConversion:
+        break;
+    case EnforceRange:
</ins><span class="cx">         return enforceRange(exec, x, 0, kJSMaxInteger);
</span><ins>+    case Clamp:
+        return std::isnan(x) ? 0 : static_cast&lt;uint64_t&gt;(std::min&lt;double&gt;(std::max&lt;double&gt;(x, 0), kJSMaxInteger));
+    }
</ins><span class="cx"> 
</span><span class="cx">     // Map NaNs and +/-Infinity to 0; convert finite values modulo 2^64.
</span><span class="cx">     unsigned long long n;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMBindingh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.h (200130 => 200131)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMBinding.h        2016-04-27 16:48:59 UTC (rev 200130)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.h        2016-04-27 17:05:40 UTC (rev 200131)
</span><span class="lines">@@ -337,12 +337,15 @@
</span><span class="cx"> enum IntegerConversionConfiguration {
</span><span class="cx">     NormalConversion,
</span><span class="cx">     EnforceRange,
</span><del>-    // FIXME: Implement Clamp
</del><ins>+    Clamp
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> WEBCORE_EXPORT int32_t toInt32EnforceRange(JSC::ExecState*, JSC::JSValue);
</span><span class="cx"> WEBCORE_EXPORT uint32_t toUInt32EnforceRange(JSC::ExecState*, JSC::JSValue);
</span><span class="cx"> 
</span><ins>+WEBCORE_EXPORT int32_t toInt32Clamp(JSC::ExecState*, JSC::JSValue);
+WEBCORE_EXPORT uint32_t toUInt32Clamp(JSC::ExecState*, JSC::JSValue);
+
</ins><span class="cx"> WEBCORE_EXPORT int8_t toInt8(JSC::ExecState*, JSC::JSValue, IntegerConversionConfiguration);
</span><span class="cx"> WEBCORE_EXPORT uint8_t toUInt8(JSC::ExecState*, JSC::JSValue, IntegerConversionConfiguration);
</span><span class="cx"> 
</span><span class="lines">@@ -357,15 +360,27 @@
</span><span class="cx"> */
</span><span class="cx"> inline int32_t toInt32(JSC::ExecState* exec, JSC::JSValue value, IntegerConversionConfiguration configuration)
</span><span class="cx"> {
</span><del>-    if (configuration == EnforceRange)
</del><ins>+    switch (configuration) {
+    case NormalConversion:
+        break;
+    case EnforceRange:
</ins><span class="cx">         return toInt32EnforceRange(exec, value);
</span><ins>+    case Clamp:
+        return toInt32Clamp(exec, value);
+    }
</ins><span class="cx">     return value.toInt32(exec);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> inline uint32_t toUInt32(JSC::ExecState* exec, JSC::JSValue value, IntegerConversionConfiguration configuration)
</span><span class="cx"> {
</span><del>-    if (configuration == EnforceRange)
</del><ins>+    switch (configuration) {
+    case NormalConversion:
+        break;
+    case EnforceRange:
</ins><span class="cx">         return toUInt32EnforceRange(exec, value);
</span><ins>+    case Clamp:
+        return toUInt32Clamp(exec, value);
+    }
</ins><span class="cx">     return value.toUInt32(exec);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (200130 => 200131)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2016-04-27 16:48:59 UTC (rev 200130)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2016-04-27 17:05:40 UTC (rev 200131)
</span><span class="lines">@@ -3535,14 +3535,6 @@
</span><span class="cx">                 }
</span><span class="cx">             }
</span><span class="cx">             $value = &quot;WTFMove($name)&quot;;
</span><del>-        } elsif ($parameter-&gt;extendedAttributes-&gt;{&quot;Clamp&quot;}) {
-            my $nativeValue = &quot;${name}NativeValue&quot;;
-            push(@$outputArray, &quot;    $argType $name = 0;\n&quot;);
-            push(@$outputArray, &quot;    double $nativeValue = state-&gt;argument($argsIndex).toNumber(state);\n&quot;);
-            push(@$outputArray, &quot;    if (UNLIKELY(state-&gt;hadException()))\n&quot;);
-            push(@$outputArray, &quot;        return JSValue::encode(jsUndefined());\n\n&quot;);
-            push(@$outputArray, &quot;    if (!std::isnan($nativeValue))\n&quot;);
-            push(@$outputArray, &quot;        $name = clampTo&lt;$argType&gt;($nativeValue);\n\n&quot;);
</del><span class="cx">         } elsif ($parameter-&gt;isVariadic) {
</span><span class="cx">             my $nativeElementType;
</span><span class="cx">             if ($argType eq &quot;DOMString&quot;) {
</span><span class="lines">@@ -4267,7 +4259,9 @@
</span><span class="cx">     return &quot;$value.toNumber(state)&quot; if $type eq &quot;double&quot; or $type eq &quot;unrestricted double&quot; ;
</span><span class="cx">     return &quot;$value.toFloat(state)&quot; if $type eq &quot;float&quot; or $type eq &quot;unrestricted float&quot; ;
</span><span class="cx"> 
</span><del>-    my $intConversion = $signature-&gt;extendedAttributes-&gt;{&quot;EnforceRange&quot;} ? &quot;EnforceRange&quot; : &quot;NormalConversion&quot;;
</del><ins>+    my $intConversion = &quot;NormalConversion&quot;;
+    $intConversion = &quot;EnforceRange&quot; if $signature-&gt;extendedAttributes-&gt;{&quot;EnforceRange&quot;};
+    $intConversion = &quot;Clamp&quot; if $signature-&gt;extendedAttributes-&gt;{&quot;Clamp&quot;};
</ins><span class="cx">     return &quot;toInt8(state, $value, $intConversion)&quot; if $type eq &quot;byte&quot;;
</span><span class="cx">     return &quot;toUInt8(state, $value, $intConversion)&quot; if $type eq &quot;octet&quot;;
</span><span class="cx">     return &quot;toInt16(state, $value, $intConversion)&quot; if $type eq &quot;short&quot;;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestGObjectWebKitDOMTestObjcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp (200130 => 200131)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp        2016-04-27 16:48:59 UTC (rev 200130)
+++ trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp        2016-04-27 17:05:40 UTC (rev 200131)
</span><span class="lines">@@ -84,6 +84,8 @@
</span><span class="cx">     PROP_BYTE_ATTR,
</span><span class="cx">     PROP_OCTET_ATTR,
</span><span class="cx">     PROP_SHORT_ATTR,
</span><ins>+    PROP_CLAMPED_SHORT_ATTR,
+    PROP_ENFORCE_RANGE_SHORT_ATTR,
</ins><span class="cx">     PROP_UNSIGNED_SHORT_ATTR,
</span><span class="cx">     PROP_LONG_ATTR,
</span><span class="cx">     PROP_LONG_LONG_ATTR,
</span><span class="lines">@@ -170,6 +172,12 @@
</span><span class="cx">     case PROP_SHORT_ATTR:
</span><span class="cx">         webkit_dom_test_obj_set_short_attr(self, g_value_get_int(value));
</span><span class="cx">         break;
</span><ins>+    case PROP_CLAMPED_SHORT_ATTR:
+        webkit_dom_test_obj_set_clamped_short_attr(self, g_value_get_int(value));
+        break;
+    case PROP_ENFORCE_RANGE_SHORT_ATTR:
+        webkit_dom_test_obj_set_enforce_range_short_attr(self, g_value_get_int(value));
+        break;
</ins><span class="cx">     case PROP_UNSIGNED_SHORT_ATTR:
</span><span class="cx">         webkit_dom_test_obj_set_unsigned_short_attr(self, g_value_get_uint(value));
</span><span class="cx">         break;
</span><span class="lines">@@ -295,6 +303,12 @@
</span><span class="cx">     case PROP_SHORT_ATTR:
</span><span class="cx">         g_value_set_int(value, webkit_dom_test_obj_get_short_attr(self));
</span><span class="cx">         break;
</span><ins>+    case PROP_CLAMPED_SHORT_ATTR:
+        g_value_set_int(value, webkit_dom_test_obj_get_clamped_short_attr(self));
+        break;
+    case PROP_ENFORCE_RANGE_SHORT_ATTR:
+        g_value_set_int(value, webkit_dom_test_obj_get_enforce_range_short_attr(self));
+        break;
</ins><span class="cx">     case PROP_UNSIGNED_SHORT_ATTR:
</span><span class="cx">         g_value_set_uint(value, webkit_dom_test_obj_get_unsigned_short_attr(self));
</span><span class="cx">         break;
</span><span class="lines">@@ -563,6 +577,26 @@
</span><span class="cx"> 
</span><span class="cx">     g_object_class_install_property(
</span><span class="cx">         gobjectClass,
</span><ins>+        PROP_CLAMPED_SHORT_ATTR,
+        g_param_spec_int(
+            &quot;clamped-short-attr&quot;,
+            &quot;TestObj:clamped-short-attr&quot;,
+            &quot;read-write gshort TestObj:clamped-short-attr&quot;,
+            G_MININT, G_MAXINT, 0,
+            WEBKIT_PARAM_READWRITE));
+
+    g_object_class_install_property(
+        gobjectClass,
+        PROP_ENFORCE_RANGE_SHORT_ATTR,
+        g_param_spec_int(
+            &quot;enforce-range-short-attr&quot;,
+            &quot;TestObj:enforce-range-short-attr&quot;,
+            &quot;read-write gshort TestObj:enforce-range-short-attr&quot;,
+            G_MININT, G_MAXINT, 0,
+            WEBKIT_PARAM_READWRITE));
+
+    g_object_class_install_property(
+        gobjectClass,
</ins><span class="cx">         PROP_UNSIGNED_SHORT_ATTR,
</span><span class="cx">         g_param_spec_uint(
</span><span class="cx">             &quot;unsigned-short-attr&quot;,
</span><span class="lines">@@ -1763,6 +1797,14 @@
</span><span class="cx"> #endif /* ENABLE(Condition1) || ENABLE(Condition2) */
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void webkit_dom_test_obj_class_method_with_enforce_range(WebKitDOMTestObj* self, gushort objArgsShort, gulong objArgsLong)
+{
+    WebCore::JSMainThreadNullState state;
+    g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self));
+    WebCore::TestObj* item = WebKit::core(self);
+    item-&gt;classMethodWithEnforceRange(objArgsShort, objArgsLong);
+}
+
</ins><span class="cx"> void webkit_dom_test_obj_convert1(WebKitDOMTestObj* self, WebKitDOMTestNode* value)
</span><span class="cx"> {
</span><span class="cx">     WebCore::JSMainThreadNullState state;
</span><span class="lines">@@ -1983,6 +2025,40 @@
</span><span class="cx">     item-&gt;setShortAttr(value);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+gshort webkit_dom_test_obj_get_clamped_short_attr(WebKitDOMTestObj* self)
+{
+    WebCore::JSMainThreadNullState state;
+    g_return_val_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self), 0);
+    WebCore::TestObj* item = WebKit::core(self);
+    gshort result = item-&gt;clampedShortAttr();
+    return result;
+}
+
+void webkit_dom_test_obj_set_clamped_short_attr(WebKitDOMTestObj* self, gshort value)
+{
+    WebCore::JSMainThreadNullState state;
+    g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self));
+    WebCore::TestObj* item = WebKit::core(self);
+    item-&gt;setClampedShortAttr(value);
+}
+
+gshort webkit_dom_test_obj_get_enforce_range_short_attr(WebKitDOMTestObj* self)
+{
+    WebCore::JSMainThreadNullState state;
+    g_return_val_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self), 0);
+    WebCore::TestObj* item = WebKit::core(self);
+    gshort result = item-&gt;enforceRangeShortAttr();
+    return result;
+}
+
+void webkit_dom_test_obj_set_enforce_range_short_attr(WebKitDOMTestObj* self, gshort value)
+{
+    WebCore::JSMainThreadNullState state;
+    g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self));
+    WebCore::TestObj* item = WebKit::core(self);
+    item-&gt;setEnforceRangeShortAttr(value);
+}
+
</ins><span class="cx"> gushort webkit_dom_test_obj_get_unsigned_short_attr(WebKitDOMTestObj* self)
</span><span class="cx"> {
</span><span class="cx">     WebCore::JSMainThreadNullState state;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestGObjectWebKitDOMTestObjh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h (200130 => 200131)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h        2016-04-27 16:48:59 UTC (rev 200130)
+++ trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h        2016-04-27 17:05:40 UTC (rev 200131)
</span><span class="lines">@@ -718,6 +718,17 @@
</span><span class="cx"> webkit_dom_test_obj_conditional_method3(WebKitDOMTestObj* self);
</span><span class="cx"> 
</span><span class="cx"> /**
</span><ins>+ * webkit_dom_test_obj_class_method_with_enforce_range:
+ * @self: A #WebKitDOMTestObj
+ * @objArgsShort: A #gushort
+ * @objArgsLong: A #gulong
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API void
+webkit_dom_test_obj_class_method_with_enforce_range(WebKitDOMTestObj* self, gushort objArgsShort, gulong objArgsLong);
+
+/**
</ins><span class="cx">  * webkit_dom_test_obj_convert1:
</span><span class="cx">  * @self: A #WebKitDOMTestObj
</span><span class="cx">  * @value: A #WebKitDOMTestNode
</span><span class="lines">@@ -958,6 +969,48 @@
</span><span class="cx"> webkit_dom_test_obj_set_short_attr(WebKitDOMTestObj* self, gshort value);
</span><span class="cx"> 
</span><span class="cx"> /**
</span><ins>+ * webkit_dom_test_obj_get_clamped_short_attr:
+ * @self: A #WebKitDOMTestObj
+ *
+ * Returns: A #gshort
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API gshort
+webkit_dom_test_obj_get_clamped_short_attr(WebKitDOMTestObj* self);
+
+/**
+ * webkit_dom_test_obj_set_clamped_short_attr:
+ * @self: A #WebKitDOMTestObj
+ * @value: A #gshort
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API void
+webkit_dom_test_obj_set_clamped_short_attr(WebKitDOMTestObj* self, gshort value);
+
+/**
+ * webkit_dom_test_obj_get_enforce_range_short_attr:
+ * @self: A #WebKitDOMTestObj
+ *
+ * Returns: A #gshort
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API gshort
+webkit_dom_test_obj_get_enforce_range_short_attr(WebKitDOMTestObj* self);
+
+/**
+ * webkit_dom_test_obj_set_enforce_range_short_attr:
+ * @self: A #WebKitDOMTestObj
+ * @value: A #gshort
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API void
+webkit_dom_test_obj_set_enforce_range_short_attr(WebKitDOMTestObj* self, gshort value);
+
+/**
</ins><span class="cx">  * webkit_dom_test_obj_get_unsigned_short_attr:
</span><span class="cx">  * @self: A #WebKitDOMTestObj
</span><span class="cx">  *
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestObjcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (200130 => 200131)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp        2016-04-27 16:48:59 UTC (rev 200130)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp        2016-04-27 17:05:40 UTC (rev 200131)
</span><span class="lines">@@ -182,6 +182,7 @@
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionOverloadedMethod1(JSC::ExecState*);
</span><span class="cx"> #endif
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionClassMethodWithClamp(JSC::ExecState*);
</span><ins>+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionClassMethodWithEnforceRange(JSC::ExecState*);
</ins><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithUnsignedLongSequence(JSC::ExecState*);
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionStringArrayFunction(JSC::ExecState*);
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionDomStringListFunction(JSC::ExecState*);
</span><span class="lines">@@ -235,6 +236,10 @@
</span><span class="cx"> bool setJSTestObjOctetAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
</span><span class="cx"> JSC::EncodedJSValue jsTestObjShortAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
</span><span class="cx"> bool setJSTestObjShortAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
</span><ins>+JSC::EncodedJSValue jsTestObjClampedShortAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
+bool setJSTestObjClampedShortAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
+JSC::EncodedJSValue jsTestObjEnforceRangeShortAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
+bool setJSTestObjEnforceRangeShortAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
</ins><span class="cx"> JSC::EncodedJSValue jsTestObjUnsignedShortAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
</span><span class="cx"> bool setJSTestObjUnsignedShortAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
</span><span class="cx"> JSC::EncodedJSValue jsTestObjLongAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
</span><span class="lines">@@ -556,6 +561,8 @@
</span><span class="cx">     { &quot;byteAttr&quot;, CustomAccessor, NoIntrinsic, { (intptr_t)static_cast&lt;PropertySlot::GetValueFunc&gt;(jsTestObjByteAttr), (intptr_t) static_cast&lt;PutPropertySlot::PutValueFunc&gt;(setJSTestObjByteAttr) } },
</span><span class="cx">     { &quot;octetAttr&quot;, CustomAccessor, NoIntrinsic, { (intptr_t)static_cast&lt;PropertySlot::GetValueFunc&gt;(jsTestObjOctetAttr), (intptr_t) static_cast&lt;PutPropertySlot::PutValueFunc&gt;(setJSTestObjOctetAttr) } },
</span><span class="cx">     { &quot;shortAttr&quot;, CustomAccessor, NoIntrinsic, { (intptr_t)static_cast&lt;PropertySlot::GetValueFunc&gt;(jsTestObjShortAttr), (intptr_t) static_cast&lt;PutPropertySlot::PutValueFunc&gt;(setJSTestObjShortAttr) } },
</span><ins>+    { &quot;clampedShortAttr&quot;, CustomAccessor, NoIntrinsic, { (intptr_t)static_cast&lt;PropertySlot::GetValueFunc&gt;(jsTestObjClampedShortAttr), (intptr_t) static_cast&lt;PutPropertySlot::PutValueFunc&gt;(setJSTestObjClampedShortAttr) } },
+    { &quot;enforceRangeShortAttr&quot;, CustomAccessor, NoIntrinsic, { (intptr_t)static_cast&lt;PropertySlot::GetValueFunc&gt;(jsTestObjEnforceRangeShortAttr), (intptr_t) static_cast&lt;PutPropertySlot::PutValueFunc&gt;(setJSTestObjEnforceRangeShortAttr) } },
</ins><span class="cx">     { &quot;unsignedShortAttr&quot;, CustomAccessor, NoIntrinsic, { (intptr_t)static_cast&lt;PropertySlot::GetValueFunc&gt;(jsTestObjUnsignedShortAttr), (intptr_t) static_cast&lt;PutPropertySlot::PutValueFunc&gt;(setJSTestObjUnsignedShortAttr) } },
</span><span class="cx">     { &quot;longAttr&quot;, CustomAccessor, NoIntrinsic, { (intptr_t)static_cast&lt;PropertySlot::GetValueFunc&gt;(jsTestObjLongAttr), (intptr_t) static_cast&lt;PutPropertySlot::PutValueFunc&gt;(setJSTestObjLongAttr) } },
</span><span class="cx">     { &quot;longLongAttr&quot;, CustomAccessor, NoIntrinsic, { (intptr_t)static_cast&lt;PropertySlot::GetValueFunc&gt;(jsTestObjLongLongAttr), (intptr_t) static_cast&lt;PutPropertySlot::PutValueFunc&gt;(setJSTestObjLongLongAttr) } },
</span><span class="lines">@@ -747,6 +754,7 @@
</span><span class="cx">     { &quot;overloadedMethod&quot;, JSC::Function, NoIntrinsic, { (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestObjPrototypeFunctionOverloadedMethod), (intptr_t) (2) } },
</span><span class="cx">     { &quot;overloadedMethodWithOptionalParameter&quot;, JSC::Function, NoIntrinsic, { (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter), (intptr_t) (1) } },
</span><span class="cx">     { &quot;classMethodWithClamp&quot;, JSC::Function, NoIntrinsic, { (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestObjPrototypeFunctionClassMethodWithClamp), (intptr_t) (2) } },
</span><ins>+    { &quot;classMethodWithEnforceRange&quot;, JSC::Function, NoIntrinsic, { (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestObjPrototypeFunctionClassMethodWithEnforceRange), (intptr_t) (2) } },
</ins><span class="cx">     { &quot;methodWithUnsignedLongSequence&quot;, JSC::Function, NoIntrinsic, { (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestObjPrototypeFunctionMethodWithUnsignedLongSequence), (intptr_t) (1) } },
</span><span class="cx">     { &quot;stringArrayFunction&quot;, JSC::Function, NoIntrinsic, { (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestObjPrototypeFunctionStringArrayFunction), (intptr_t) (1) } },
</span><span class="cx">     { &quot;domStringListFunction&quot;, JSC::Function, NoIntrinsic, { (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestObjPrototypeFunctionDomStringListFunction), (intptr_t) (1) } },
</span><span class="lines">@@ -1024,6 +1032,36 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+EncodedJSValue jsTestObjClampedShortAttr(ExecState* state, EncodedJSValue thisValue, PropertyName)
+{
+    UNUSED_PARAM(state);
+    UNUSED_PARAM(thisValue);
+    JSValue decodedThisValue = JSValue::decode(thisValue);
+    auto* castedThis = jsDynamicCast&lt;JSTestObj*&gt;(decodedThisValue);
+    if (UNLIKELY(!castedThis)) {
+        return throwGetterTypeError(*state, &quot;TestObj&quot;, &quot;clampedShortAttr&quot;);
+    }
+    auto&amp; impl = castedThis-&gt;wrapped();
+    JSValue result = jsNumber(impl.clampedShortAttr());
+    return JSValue::encode(result);
+}
+
+
+EncodedJSValue jsTestObjEnforceRangeShortAttr(ExecState* state, EncodedJSValue thisValue, PropertyName)
+{
+    UNUSED_PARAM(state);
+    UNUSED_PARAM(thisValue);
+    JSValue decodedThisValue = JSValue::decode(thisValue);
+    auto* castedThis = jsDynamicCast&lt;JSTestObj*&gt;(decodedThisValue);
+    if (UNLIKELY(!castedThis)) {
+        return throwGetterTypeError(*state, &quot;TestObj&quot;, &quot;enforceRangeShortAttr&quot;);
+    }
+    auto&amp; impl = castedThis-&gt;wrapped();
+    JSValue result = jsNumber(impl.enforceRangeShortAttr());
+    return JSValue::encode(result);
+}
+
+
</ins><span class="cx"> EncodedJSValue jsTestObjUnsignedShortAttr(ExecState* state, EncodedJSValue thisValue, PropertyName)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(state);
</span><span class="lines">@@ -2250,6 +2288,40 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+bool setJSTestObjClampedShortAttr(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
+{
+    JSValue value = JSValue::decode(encodedValue);
+    UNUSED_PARAM(thisValue);
+    JSTestObj* castedThis = jsDynamicCast&lt;JSTestObj*&gt;(JSValue::decode(thisValue));
+    if (UNLIKELY(!castedThis)) {
+        return throwSetterTypeError(*state, &quot;TestObj&quot;, &quot;clampedShortAttr&quot;);
+    }
+    auto&amp; impl = castedThis-&gt;wrapped();
+    int16_t nativeValue = toInt16(state, value, Clamp);
+    if (UNLIKELY(state-&gt;hadException()))
+        return false;
+    impl.setClampedShortAttr(nativeValue);
+    return true;
+}
+
+
+bool setJSTestObjEnforceRangeShortAttr(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
+{
+    JSValue value = JSValue::decode(encodedValue);
+    UNUSED_PARAM(thisValue);
+    JSTestObj* castedThis = jsDynamicCast&lt;JSTestObj*&gt;(JSValue::decode(thisValue));
+    if (UNLIKELY(!castedThis)) {
+        return throwSetterTypeError(*state, &quot;TestObj&quot;, &quot;enforceRangeShortAttr&quot;);
+    }
+    auto&amp; impl = castedThis-&gt;wrapped();
+    int16_t nativeValue = toInt16(state, value, EnforceRange);
+    if (UNLIKELY(state-&gt;hadException()))
+        return false;
+    impl.setEnforceRangeShortAttr(nativeValue);
+    return true;
+}
+
+
</ins><span class="cx"> bool setJSTestObjUnsignedShortAttr(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
</span><span class="cx"> {
</span><span class="cx">     JSValue value = JSValue::decode(encodedValue);
</span><span class="lines">@@ -4916,26 +4988,36 @@
</span><span class="cx">     auto&amp; impl = castedThis-&gt;wrapped();
</span><span class="cx">     if (UNLIKELY(state-&gt;argumentCount() &lt; 2))
</span><span class="cx">         return throwVMError(state, createNotEnoughArgumentsError(state));
</span><del>-    unsigned short objArgsShort = 0;
-    double objArgsShortNativeValue = state-&gt;argument(0).toNumber(state);
</del><ins>+    uint16_t objArgsShort = toUInt16(state, state-&gt;argument(0), Clamp);
</ins><span class="cx">     if (UNLIKELY(state-&gt;hadException()))
</span><span class="cx">         return JSValue::encode(jsUndefined());
</span><del>-
-    if (!std::isnan(objArgsShortNativeValue))
-        objArgsShort = clampTo&lt;unsigned short&gt;(objArgsShortNativeValue);
-
-    unsigned long objArgsLong = 0;
-    double objArgsLongNativeValue = state-&gt;argument(1).toNumber(state);
</del><ins>+    unsigned objArgsLong = toUInt32(state, state-&gt;argument(1), Clamp);
</ins><span class="cx">     if (UNLIKELY(state-&gt;hadException()))
</span><span class="cx">         return JSValue::encode(jsUndefined());
</span><del>-
-    if (!std::isnan(objArgsLongNativeValue))
-        objArgsLong = clampTo&lt;unsigned long&gt;(objArgsLongNativeValue);
-
</del><span class="cx">     impl.classMethodWithClamp(objArgsShort, objArgsLong);
</span><span class="cx">     return JSValue::encode(jsUndefined());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionClassMethodWithEnforceRange(ExecState* state)
+{
+    JSValue thisValue = state-&gt;thisValue();
+    auto castedThis = jsDynamicCast&lt;JSTestObj*&gt;(thisValue);
+    if (UNLIKELY(!castedThis))
+        return throwThisTypeError(*state, &quot;TestObj&quot;, &quot;classMethodWithEnforceRange&quot;);
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+    auto&amp; impl = castedThis-&gt;wrapped();
+    if (UNLIKELY(state-&gt;argumentCount() &lt; 2))
+        return throwVMError(state, createNotEnoughArgumentsError(state));
+    uint16_t objArgsShort = toUInt16(state, state-&gt;argument(0), EnforceRange);
+    if (UNLIKELY(state-&gt;hadException()))
+        return JSValue::encode(jsUndefined());
+    unsigned objArgsLong = toUInt32(state, state-&gt;argument(1), EnforceRange);
+    if (UNLIKELY(state-&gt;hadException()))
+        return JSValue::encode(jsUndefined());
+    impl.classMethodWithEnforceRange(objArgsShort, objArgsLong);
+    return JSValue::encode(jsUndefined());
+}
+
</ins><span class="cx"> EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithUnsignedLongSequence(ExecState* state)
</span><span class="cx"> {
</span><span class="cx">     JSValue thisValue = state-&gt;thisValue();
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestTypedefscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp (200130 => 200131)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp        2016-04-27 16:48:59 UTC (rev 200130)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp        2016-04-27 17:05:40 UTC (rev 200131)
</span><span class="lines">@@ -550,29 +550,19 @@
</span><span class="cx">     auto&amp; impl = castedThis-&gt;wrapped();
</span><span class="cx">     if (UNLIKELY(state-&gt;argumentCount() &lt; 1))
</span><span class="cx">         return throwVMError(state, createNotEnoughArgumentsError(state));
</span><del>-    unsigned long long arg1 = 0;
-    double arg1NativeValue = state-&gt;argument(0).toNumber(state);
</del><ins>+    unsigned long long arg1 = toUInt64(state, state-&gt;argument(0), Clamp);
</ins><span class="cx">     if (UNLIKELY(state-&gt;hadException()))
</span><span class="cx">         return JSValue::encode(jsUndefined());
</span><span class="cx"> 
</span><del>-    if (!std::isnan(arg1NativeValue))
-        arg1 = clampTo&lt;unsigned long long&gt;(arg1NativeValue);
-
-
</del><span class="cx">     size_t argsCount = state-&gt;argumentCount();
</span><span class="cx">     if (argsCount &lt;= 1) {
</span><span class="cx">         impl.funcWithClamp(arg1);
</span><span class="cx">         return JSValue::encode(jsUndefined());
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    unsigned long long arg2 = 0;
-    double arg2NativeValue = state-&gt;argument(1).toNumber(state);
</del><ins>+    unsigned long long arg2 = toUInt64(state, state-&gt;argument(1), Clamp);
</ins><span class="cx">     if (UNLIKELY(state-&gt;hadException()))
</span><span class="cx">         return JSValue::encode(jsUndefined());
</span><del>-
-    if (!std::isnan(arg2NativeValue))
-        arg2 = clampTo&lt;unsigned long long&gt;(arg2NativeValue);
-
</del><span class="cx">     impl.funcWithClamp(arg1, arg2);
</span><span class="cx">     return JSValue::encode(jsUndefined());
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestObjCDOMTestObjh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h (200130 => 200131)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h        2016-04-27 16:48:59 UTC (rev 200130)
+++ trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h        2016-04-27 17:05:40 UTC (rev 200131)
</span><span class="lines">@@ -67,6 +67,8 @@
</span><span class="cx"> @property char byteAttr;
</span><span class="cx"> @property unsigned char octetAttr;
</span><span class="cx"> @property short shortAttr;
</span><ins>+@property short clampedShortAttr;
+@property short enforceRangeShortAttr;
</ins><span class="cx"> @property unsigned short unsignedShortAttr;
</span><span class="cx"> @property int longAttr;
</span><span class="cx"> @property long long longLongAttr;
</span><span class="lines">@@ -193,6 +195,7 @@
</span><span class="cx"> - (void)classMethod;
</span><span class="cx"> - (int)classMethodWithOptional:(int)arg;
</span><span class="cx"> - (void)classMethod2:(int)arg;
</span><ins>+- (void)classMethodWithEnforceRange:(unsigned short)objArgsShort objArgsLong:(unsigned)objArgsLong;
</ins><span class="cx"> - (DOMSVGDocument *)getSVGDocument;
</span><span class="cx"> - (void)convert1:(DOMTestNode *)value;
</span><span class="cx"> - (void)convert2:(DOMTestNode *)value;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestObjCDOMTestObjmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm (200130 => 200131)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm        2016-04-27 16:48:59 UTC (rev 200130)
+++ trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm        2016-04-27 17:05:40 UTC (rev 200131)
</span><span class="lines">@@ -151,6 +151,30 @@
</span><span class="cx">     IMPL-&gt;setShortAttr(newShortAttr);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (short)clampedShortAttr
+{
+    WebCore::JSMainThreadNullState state;
+    return IMPL-&gt;clampedShortAttr();
+}
+
+- (void)setClampedShortAttr:(short)newClampedShortAttr
+{
+    WebCore::JSMainThreadNullState state;
+    IMPL-&gt;setClampedShortAttr(newClampedShortAttr);
+}
+
+- (short)enforceRangeShortAttr
+{
+    WebCore::JSMainThreadNullState state;
+    return IMPL-&gt;enforceRangeShortAttr();
+}
+
+- (void)setEnforceRangeShortAttr:(short)newEnforceRangeShortAttr
+{
+    WebCore::JSMainThreadNullState state;
+    IMPL-&gt;setEnforceRangeShortAttr(newEnforceRangeShortAttr);
+}
+
</ins><span class="cx"> - (unsigned short)unsignedShortAttr
</span><span class="cx"> {
</span><span class="cx">     WebCore::JSMainThreadNullState state;
</span><span class="lines">@@ -1420,6 +1444,12 @@
</span><span class="cx"> 
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+- (void)classMethodWithEnforceRange:(unsigned short)objArgsShort objArgsLong:(unsigned)objArgsLong
+{
+    WebCore::JSMainThreadNullState state;
+    IMPL-&gt;classMethodWithEnforceRange(objArgsShort, objArgsLong);
+}
+
</ins><span class="cx"> - (DOMSVGDocument *)getSVGDocument
</span><span class="cx"> {
</span><span class="cx">     WebCore::JSMainThreadNullState state;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestTestObjidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (200130 => 200131)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl        2016-04-27 16:48:59 UTC (rev 200130)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl        2016-04-27 17:05:40 UTC (rev 200131)
</span><span class="lines">@@ -51,6 +51,8 @@
</span><span class="cx">     attribute byte                     byteAttr;
</span><span class="cx">     attribute octet                    octetAttr;
</span><span class="cx">     attribute short                    shortAttr;
</span><ins>+    [Clamp] attribute short            clampedShortAttr;
+    [EnforceRange] attribute short     enforceRangeShortAttr;
</ins><span class="cx">     attribute unsigned short           unsignedShortAttr;
</span><span class="cx">     attribute long                     longAttr;
</span><span class="cx">     attribute long long                longLongAttr;
</span><span class="lines">@@ -268,6 +270,7 @@
</span><span class="cx">     [Conditional=Condition1] static void overloadedMethod1([StrictTypeChecking] DOMString type);
</span><span class="cx"> 
</span><span class="cx">     void classMethodWithClamp([Clamp] unsigned short objArgsShort, [Clamp] unsigned long objArgsLong);
</span><ins>+    void classMethodWithEnforceRange([EnforceRange] unsigned short objArgsShort, [EnforceRange] unsigned long objArgsLong);
</ins><span class="cx"> 
</span><span class="cx"> #if defined(TESTING_JS)
</span><span class="cx">     void methodWithUnsignedLongSequence(sequence&lt;unsigned long&gt; unsignedLongSequence);
</span></span></pre>
</div>
</div>

</body>
</html>