Title: [124034] trunk/Source/WebCore
Revision
124034
Author
commit-qu...@webkit.org
Date
2012-07-30 09:32:57 -0700 (Mon, 30 Jul 2012)

Log Message

https://bugs.webkit.org/show_bug.cgi?id=92642
[Bindings]Remove custom JS/V8 bindings for WebSocket::close() using [Clamp]

Patch by Vineet Chaudhary <rgf...@motorola.com> on 2012-07-30
Reviewed by Kentaro Hara.

With support of [Clamp] as extended attribute we can replace custom bindings from WebSocket::close().
Spec for WebSocket::close() : http://www.whatwg.org/specs/web-apps/current-work/multipage/network.html#websocket

No new tests. There should be no behavioural changes
Existing tests under http/websocket/tests/hybi/ should cover this.

* Modules/websockets/WebSocket.h:
(WebCore::WebSocket::close):
* Modules/websockets/WebSocket.idl: Used [Clamp].
* bindings/js/JSWebSocketCustom.cpp: Removed custom call close().
(WebCore):
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateParametersCheck):
* bindings/scripts/CodeGeneratorV8.pm:
(GenerateParametersCheck):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::jsTestObjPrototypeFunctionClassMethodWithClamp):
* bindings/scripts/test/V8/V8TestObj.cpp:
(WebCore::TestObjV8Internal::classMethodWithClampCallback):
* bindings/v8/custom/V8WebSocketCustom.cpp: Removed custom call close().
(WebCore):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (124033 => 124034)


--- trunk/Source/WebCore/ChangeLog	2012-07-30 16:19:48 UTC (rev 124033)
+++ trunk/Source/WebCore/ChangeLog	2012-07-30 16:32:57 UTC (rev 124034)
@@ -1,3 +1,32 @@
+2012-07-30  Vineet Chaudhary  <rgf...@motorola.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=92642
+        [Bindings]Remove custom JS/V8 bindings for WebSocket::close() using [Clamp]
+
+        Reviewed by Kentaro Hara.
+
+        With support of [Clamp] as extended attribute we can replace custom bindings from WebSocket::close().
+        Spec for WebSocket::close() : http://www.whatwg.org/specs/web-apps/current-work/multipage/network.html#websocket
+
+        No new tests. There should be no behavioural changes 
+        Existing tests under http/websocket/tests/hybi/ should cover this.
+
+        * Modules/websockets/WebSocket.h:
+        (WebCore::WebSocket::close):
+        * Modules/websockets/WebSocket.idl: Used [Clamp].
+        * bindings/js/JSWebSocketCustom.cpp: Removed custom call close().
+        (WebCore):
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateParametersCheck):
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateParametersCheck):
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore::jsTestObjPrototypeFunctionClassMethodWithClamp):
+        * bindings/scripts/test/V8/V8TestObj.cpp:
+        (WebCore::TestObjV8Internal::classMethodWithClampCallback):
+        * bindings/v8/custom/V8WebSocketCustom.cpp: Removed custom call close().
+        (WebCore):
+
 2012-07-29  Vsevolod Vlasov  <vse...@chromium.org>
 
         Web Inspector: Resource agent's reference to cached resources should be weak.

Modified: trunk/Source/WebCore/Modules/websockets/WebSocket.h (124033 => 124034)


--- trunk/Source/WebCore/Modules/websockets/WebSocket.h	2012-07-30 16:19:48 UTC (rev 124033)
+++ trunk/Source/WebCore/Modules/websockets/WebSocket.h	2012-07-30 16:32:57 UTC (rev 124034)
@@ -38,6 +38,7 @@
 #include "EventNames.h"
 #include "EventTarget.h"
 #include "KURL.h"
+#include "WebSocketChannel.h"
 #include "WebSocketChannelClient.h"
 #include <wtf/Forward.h>
 #include <wtf/OwnPtr.h>
@@ -73,6 +74,8 @@
     bool send(Blob*, ExceptionCode&);
 
     void close(int code, const String& reason, ExceptionCode&);
+    void close(ExceptionCode& ec) { close(WebSocketChannel::CloseEventCodeNotSpecified, String(), ec); }
+    void close(int code, ExceptionCode& ec) { close(code, String(), ec); }
 
     const KURL& url() const;
     State readyState() const;

Modified: trunk/Source/WebCore/Modules/websockets/WebSocket.idl (124033 => 124034)


--- trunk/Source/WebCore/Modules/websockets/WebSocket.idl	2012-07-30 16:19:48 UTC (rev 124033)
+++ trunk/Source/WebCore/Modules/websockets/WebSocket.idl	2012-07-30 16:32:57 UTC (rev 124034)
@@ -73,8 +73,7 @@
         // boolean send(in DOMString data) raises(DOMException);
         [Custom] boolean send(in DOMString data) raises(DOMException);
 
-        // FIXME: Implement and apply [Clamp] attribute instead of [Custom].
-        [Custom] void close(in [Optional] unsigned short code, in [Optional] DOMString reason) raises(DOMException);
+        void close(in [Clamp, Optional] unsigned short code, in [Optional] DOMString reason) raises(DOMException);
 
         // EventTarget interface
         void addEventListener(in DOMString type,

Modified: trunk/Source/WebCore/bindings/js/JSWebSocketCustom.cpp (124033 => 124034)


--- trunk/Source/WebCore/bindings/js/JSWebSocketCustom.cpp	2012-07-30 16:19:48 UTC (rev 124033)
+++ trunk/Source/WebCore/bindings/js/JSWebSocketCustom.cpp	2012-07-30 16:32:57 UTC (rev 124034)
@@ -116,38 +116,6 @@
     return jsBoolean(result);
 }
 
-JSValue JSWebSocket::close(ExecState* exec)
-{
-    // FIXME: We should implement [Clamp] for IDL binding code generator, and
-    // remove this custom method.
-    WebSocket* webSocket = static_cast<WebSocket*>(impl());
-    size_t argumentCount = exec->argumentCount();
-    int code = WebSocketChannel::CloseEventCodeNotSpecified;
-    String reason = "";
-    if (argumentCount >= 1) {
-        JSValue v = exec->argument(0);
-        double x = v.toNumber(exec);
-        double maxValue = static_cast<double>(std::numeric_limits<uint16_t>::max());
-        double minValue = static_cast<double>(std::numeric_limits<uint16_t>::min());
-        if (isnan(x))
-            x = 0.0;
-        else
-            x = clampTo(x, minValue, maxValue);
-        code = clampToInteger(x);
-        if (argumentCount >= 2) {
-            reason = ustringToString(exec->argument(1).toString(exec)->value(exec));
-            if (exec->hadException()) {
-                setDOMException(exec, SYNTAX_ERR);
-                return jsUndefined();
-            }
-        }
-    }
-    ExceptionCode ec = 0;
-    webSocket->close(code, reason, ec);
-    setDOMException(exec, ec);
-    return jsUndefined();
-}
-
 } // namespace WebCore
 
 #endif

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (124033 => 124034)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2012-07-30 16:19:48 UTC (rev 124033)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2012-07-30 16:32:57 UTC (rev 124034)
@@ -2613,7 +2613,7 @@
                 push(@$outputArray, "    double $nativeValue = exec->argument($argsIndex).toNumber(exec);\n");
                 push(@$outputArray, "    if (exec->hadException())\n");
                 push(@$outputArray, "        return JSValue::encode(jsUndefined());\n\n");
-                push(@$outputArray, "    if (!isnan(objArgsShortNativeValue))\n");
+                push(@$outputArray, "    if (!isnan($nativeValue))\n");
                 push(@$outputArray, "        $name = clampTo<$argType>($nativeValue);\n\n");
         } else {
             # If the "StrictTypeChecking" extended attribute is present, and the argument's type is an

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (124033 => 124034)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-07-30 16:19:48 UTC (rev 124033)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-07-30 16:32:57 UTC (rev 124034)
@@ -1683,7 +1683,7 @@
         } elsif ($parameter->extendedAttributes->{"Clamp"}) {
                 my $nativeValue = "${parameterName}NativeValue";
                 my $paramType = $parameter->type;
-                $parameterCheckString .= "    $paramType $parameterName = 0\n";
+                $parameterCheckString .= "    $paramType $parameterName = 0;\n";
                 $parameterCheckString .= "    EXCEPTION_BLOCK(double, $nativeValue, args[$paramIndex]->NumberValue());\n";
                 $parameterCheckString .= "    if (!isnan($nativeValue))\n";
                 $parameterCheckString .= "        $parameterName = clampTo<$paramType>($nativeValue);\n";

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (124033 => 124034)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2012-07-30 16:19:48 UTC (rev 124033)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2012-07-30 16:32:57 UTC (rev 124034)
@@ -2369,7 +2369,7 @@
     if (exec->hadException())
         return JSValue::encode(jsUndefined());
 
-    if (!isnan(objArgsShortNativeValue))
+    if (!isnan(objArgsLongNativeValue))
         objArgsLong = clampTo<unsigned long>(objArgsLongNativeValue);
 
     impl->classMethodWithClamp(objArgsShort, objArgsLong);

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp (124033 => 124034)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp	2012-07-30 16:19:48 UTC (rev 124033)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp	2012-07-30 16:32:57 UTC (rev 124034)
@@ -1728,11 +1728,11 @@
     if (args.Length() < 2)
         return V8Proxy::throwNotEnoughArgumentsError(args.GetIsolate());
     TestObj* imp = V8TestObj::toNative(args.Holder());
-    unsigned short objArgsShort = 0
+    unsigned short objArgsShort = 0;
     EXCEPTION_BLOCK(double, objArgsShortNativeValue, args[0]->NumberValue());
     if (!isnan(objArgsShortNativeValue))
         objArgsShort = clampTo<unsigned short>(objArgsShortNativeValue);
-    unsigned long objArgsLong = 0
+    unsigned long objArgsLong = 0;
     EXCEPTION_BLOCK(double, objArgsLongNativeValue, args[1]->NumberValue());
     if (!isnan(objArgsLongNativeValue))
         objArgsLong = clampTo<unsigned long>(objArgsLongNativeValue);

Modified: trunk/Source/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp (124033 => 124034)


--- trunk/Source/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp	2012-07-30 16:19:48 UTC (rev 124033)
+++ trunk/Source/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp	2012-07-30 16:32:57 UTC (rev 124034)
@@ -144,38 +144,6 @@
     return v8Boolean(result, args.GetIsolate());
 }
 
-v8::Handle<v8::Value> V8WebSocket::closeCallback(const v8::Arguments& args)
-{
-    // FIXME: We should implement [Clamp] for IDL binding code generator, and
-    // remove this custom method.
-    WebSocket* webSocket = toNative(args.Holder());
-    int argumentCount = args.Length();
-    int code = WebSocketChannel::CloseEventCodeNotSpecified;
-    String reason = "";
-    if (argumentCount >= 1) {
-        double x = args[0]->NumberValue();
-        double maxValue = static_cast<double>(std::numeric_limits<uint16_t>::max());
-        double minValue = static_cast<double>(std::numeric_limits<uint16_t>::min());
-        if (isnan(x))
-            x = 0.0;
-        else
-            x = clampTo(x, minValue, maxValue);
-        code = clampToInteger(x);
-        if (argumentCount >= 2) {
-            v8::TryCatch tryCatch;
-            v8::Handle<v8::String> reasonValue = args[1]->ToString();
-            if (tryCatch.HasCaught())
-                return throwError(tryCatch.Exception(), args.GetIsolate());
-            reason = toWebCoreString(reasonValue);
-        }
-    }
-    ExceptionCode ec = 0;
-    webSocket->close(code, reason, ec);
-    if (ec)
-        return throwError(ec, args.GetIsolate());
-    return v8::Undefined();
-}
-
 }  // namespace WebCore
 
 #endif  // ENABLE(WEB_SOCKETS)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to