Changeset 207914 in webkit


Ignore:
Timestamp:
Oct 26, 2016 4:15:51 PM (7 years ago)
Author:
Chris Dumez
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:

No new tests, no web-exposed behavior change.

  • html/URLSearchParams.h:

(WebCore::URLSearchParams::create):

  • html/URLSearchParams.idl:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r207912 r207914  
     12016-10-26  Chris Dumez  <cdumez@apple.com>
     2
     3        The URLSearchParams constructor should take a union in parameter
     4        https://bugs.webkit.org/show_bug.cgi?id=163906
     5
     6        Reviewed by Darin Adler.
     7
     8        The URLSearchParams constructor should take a union in parameter:
     9        - https://url.spec.whatwg.org/#urlsearchparams
     10
     11        No new tests, no web-exposed behavior change.
     12
     13        * html/URLSearchParams.h:
     14        (WebCore::URLSearchParams::create):
     15        * html/URLSearchParams.idl:
     16
    1172016-10-26  Sam Weinig  <sam@webkit.org>
    218
  • trunk/Source/WebCore/html/URLSearchParams.h

    r206632 r207914  
    2626
    2727#include "DOMURL.h"
     28#include <wtf/Variant.h>
    2829#include <wtf/Vector.h>
    2930#include <wtf/text/WTFString.h>
     
    3334class URLSearchParams : public RefCounted<URLSearchParams> {
    3435public:
    35     static Ref<URLSearchParams> create(const String& string, DOMURL* associatedURL = nullptr) { return adoptRef(*new URLSearchParams(string, associatedURL)); }
    36     static Ref<URLSearchParams> create(const Vector<std::pair<String, String>>& pairs) { return adoptRef(*new URLSearchParams(pairs)); }
     36    using StringOrURLSearchParams = WTF::Variant<String, RefPtr<URLSearchParams>>;
     37    static Ref<URLSearchParams> create(const StringOrURLSearchParams&, DOMURL* associatedURL = nullptr);
    3738
    3839    void associatedURLDestroyed() { m_associatedURL = nullptr; }
     
    5657};
    5758
     59inline Ref<URLSearchParams> URLSearchParams::create(const StringOrURLSearchParams& variant, DOMURL* associatedURL)
     60{
     61    auto visitor = WTF::makeVisitor([&](const String& string) {
     62        return adoptRef(*new URLSearchParams(string, associatedURL));
     63    }, [&](const RefPtr<URLSearchParams>& params) {
     64        return adoptRef(*new URLSearchParams(static_cast<const Vector<std::pair<String, String>>&>(*params)));
     65    });
     66    return WTF::visit(visitor, variant);
    5867}
     68
     69} // namespace WebCore
  • trunk/Source/WebCore/html/URLSearchParams.idl

    r205893 r207914  
    2525
    2626[
    27     // FIXME: This should use unions once they are supported
    28     Constructor(optional USVString arg = ""),
    29     Constructor(URLSearchParams init),
     27    Constructor(optional (USVString or URLSearchParams) init = ""),
    3028    Exposed=(Window,Worker),
    3129    ImplementationLacksVTable,
Note: See TracChangeset for help on using the changeset viewer.