Diff
Modified: trunk/Source/WebCore/ChangeLog (200157 => 200158)
--- trunk/Source/WebCore/ChangeLog 2016-04-27 23:24:36 UTC (rev 200157)
+++ trunk/Source/WebCore/ChangeLog 2016-04-27 23:31:39 UTC (rev 200158)
@@ -1,3 +1,20 @@
+2016-04-27 Chris Dumez <[email protected]>
+
+ Let the bindings generator use WTF::Optional for optional parameters using [Clamp]
+ https://bugs.webkit.org/show_bug.cgi?id=157077
+
+ Reviewed by Darin Adler.
+
+ Let the bindings generator use WTF::Optional for optional parameters using [Clamp],
+ if they do not have a default value.
+
+ * Modules/websockets/WebSocket.cpp:
+ (WebCore::WebSocket::close):
+ * Modules/websockets/WebSocket.h:
+ * Modules/websockets/WebSocket.idl:
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (CanUseWTFOptionalForParameter): Deleted.
+
2016-04-26 Ada Chan <[email protected]>
Set WebVideoFullscreenInterfaceMac up as a client of WebPlaybackSessionInterfaceMac to listen for playback state changes
Modified: trunk/Source/WebCore/Modules/websockets/WebSocket.cpp (200157 => 200158)
--- trunk/Source/WebCore/Modules/websockets/WebSocket.cpp 2016-04-27 23:24:36 UTC (rev 200157)
+++ trunk/Source/WebCore/Modules/websockets/WebSocket.cpp 2016-04-27 23:31:39 UTC (rev 200158)
@@ -375,8 +375,9 @@
m_channel->send(binaryData);
}
-void WebSocket::close(int code, const String& reason, ExceptionCode& ec)
+void WebSocket::close(Optional<unsigned short> optionalCode, const String& reason, ExceptionCode& ec)
{
+ int code = optionalCode ? optionalCode.value() : static_cast<int>(WebSocketChannel::CloseEventCodeNotSpecified);
if (code == WebSocketChannel::CloseEventCodeNotSpecified)
LOG(Network, "WebSocket %p close() without code and reason", this);
else {
Modified: trunk/Source/WebCore/Modules/websockets/WebSocket.h (200157 => 200158)
--- trunk/Source/WebCore/Modules/websockets/WebSocket.h 2016-04-27 23:24:36 UTC (rev 200157)
+++ trunk/Source/WebCore/Modules/websockets/WebSocket.h 2016-04-27 23:31:39 UTC (rev 200158)
@@ -76,9 +76,7 @@
void send(JSC::ArrayBufferView*, ExceptionCode&);
void 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); }
+ void close(Optional<unsigned short> code, const String& reason, ExceptionCode&);
const URL& url() const;
State readyState() const;
Modified: trunk/Source/WebCore/Modules/websockets/WebSocket.idl (200157 => 200158)
--- trunk/Source/WebCore/Modules/websockets/WebSocket.idl 2016-04-27 23:24:36 UTC (rev 200157)
+++ trunk/Source/WebCore/Modules/websockets/WebSocket.idl 2016-04-27 23:31:39 UTC (rev 200158)
@@ -67,5 +67,5 @@
[RaisesException] void send(Blob data);
[RaisesException] void send(DOMString data);
- [RaisesException] void close([Clamp] optional unsigned short code, optional DOMString reason);
+ [RaisesException] void close([Clamp] optional unsigned short code, optional DOMString reason = null);
};
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (200157 => 200158)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2016-04-27 23:24:36 UTC (rev 200157)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2016-04-27 23:31:39 UTC (rev 200158)
@@ -3377,7 +3377,6 @@
# FIXME: We should progressively stop blacklisting each type below
# and eventually get rid of this function entirely.
- return 0 if $parameter->extendedAttributes->{"Clamp"};
return 0 if $parameter->isVariadic;
return 0 if $codeGenerator->IsCallbackInterface($type);
return 0 if $codeGenerator->IsEnumType($type);
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp (200157 => 200158)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp 2016-04-27 23:24:36 UTC (rev 200157)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp 2016-04-27 23:31:39 UTC (rev 200158)
@@ -553,14 +553,7 @@
unsigned long long arg1 = toUInt64(state, state->argument(0), Clamp);
if (UNLIKELY(state->hadException()))
return JSValue::encode(jsUndefined());
-
- size_t argsCount = state->argumentCount();
- if (argsCount <= 1) {
- impl.funcWithClamp(arg1);
- return JSValue::encode(jsUndefined());
- }
-
- unsigned long long arg2 = toUInt64(state, state->argument(1), Clamp);
+ Optional<unsigned long long> arg2 = state->argument(1).isUndefined() ? Optional<unsigned long long>() : toUInt64(state, state->uncheckedArgument(1), Clamp);
if (UNLIKELY(state->hadException()))
return JSValue::encode(jsUndefined());
impl.funcWithClamp(arg1, arg2);