Title: [207914] trunk/Source/WebCore
- Revision
- 207914
- Author
- [email protected]
- Date
- 2016-10-26 16:15:51 -0700 (Wed, 26 Oct 2016)
Log Message
The URLSearchParams constructor should take a union in parameter
https://bugs.webkit.org/show_bug.cgi?id=163906
Reviewed by Darin Adler.
The URLSearchParams constructor should take a union in parameter:
- https://url.spec.whatwg.org/#urlsearchparams
No new tests, no web-exposed behavior change.
* html/URLSearchParams.h:
(WebCore::URLSearchParams::create):
* html/URLSearchParams.idl:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (207913 => 207914)
--- trunk/Source/WebCore/ChangeLog 2016-10-26 21:09:38 UTC (rev 207913)
+++ trunk/Source/WebCore/ChangeLog 2016-10-26 23:15:51 UTC (rev 207914)
@@ -1,3 +1,19 @@
+2016-10-26 Chris Dumez <[email protected]>
+
+ The URLSearchParams constructor should take a union in parameter
+ https://bugs.webkit.org/show_bug.cgi?id=163906
+
+ Reviewed by Darin Adler.
+
+ The URLSearchParams constructor should take a union in parameter:
+ - https://url.spec.whatwg.org/#urlsearchparams
+
+ No new tests, no web-exposed behavior change.
+
+ * html/URLSearchParams.h:
+ (WebCore::URLSearchParams::create):
+ * html/URLSearchParams.idl:
+
2016-10-26 Sam Weinig <[email protected]>
[WebIDL] Move more string conversions over to JSDOMConvert
Modified: trunk/Source/WebCore/html/URLSearchParams.h (207913 => 207914)
--- trunk/Source/WebCore/html/URLSearchParams.h 2016-10-26 21:09:38 UTC (rev 207913)
+++ trunk/Source/WebCore/html/URLSearchParams.h 2016-10-26 23:15:51 UTC (rev 207914)
@@ -25,6 +25,7 @@
#pragma once
#include "DOMURL.h"
+#include <wtf/Variant.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
@@ -32,8 +33,8 @@
class URLSearchParams : public RefCounted<URLSearchParams> {
public:
- static Ref<URLSearchParams> create(const String& string, DOMURL* associatedURL = nullptr) { return adoptRef(*new URLSearchParams(string, associatedURL)); }
- static Ref<URLSearchParams> create(const Vector<std::pair<String, String>>& pairs) { return adoptRef(*new URLSearchParams(pairs)); }
+ using StringOrURLSearchParams = WTF::Variant<String, RefPtr<URLSearchParams>>;
+ static Ref<URLSearchParams> create(const StringOrURLSearchParams&, DOMURL* associatedURL = nullptr);
void associatedURLDestroyed() { m_associatedURL = nullptr; }
void append(const String& name, const String& value);
@@ -55,4 +56,14 @@
Vector<std::pair<String, String>> m_pairs;
};
+inline Ref<URLSearchParams> URLSearchParams::create(const StringOrURLSearchParams& variant, DOMURL* associatedURL)
+{
+ auto visitor = WTF::makeVisitor([&](const String& string) {
+ return adoptRef(*new URLSearchParams(string, associatedURL));
+ }, [&](const RefPtr<URLSearchParams>& params) {
+ return adoptRef(*new URLSearchParams(static_cast<const Vector<std::pair<String, String>>&>(*params)));
+ });
+ return WTF::visit(visitor, variant);
}
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/html/URLSearchParams.idl (207913 => 207914)
--- trunk/Source/WebCore/html/URLSearchParams.idl 2016-10-26 21:09:38 UTC (rev 207913)
+++ trunk/Source/WebCore/html/URLSearchParams.idl 2016-10-26 23:15:51 UTC (rev 207914)
@@ -24,9 +24,7 @@
*/
[
- // FIXME: This should use unions once they are supported
- Constructor(optional USVString arg = ""),
- Constructor(URLSearchParams init),
+ Constructor(optional (USVString or URLSearchParams) init = ""),
Exposed=(Window,Worker),
ImplementationLacksVTable,
] interface URLSearchParams {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes