2323 * Boston, MA 02110-1301, USA.
2424 */
2525
26+ #include " config.h"
2627#include " DOMURL.h"
2728
28- // #include "ActiveDOMObject.h"
29+ #include " ActiveDOMObject.h"
2930// #include "Blob.h"
3031// #include "BlobURL.h"
3132// #include "MemoryCache.h"
3233// #include "PublicURLManager.h"
3334// #include "ResourceRequest.h"
35+ #include " ScriptExecutionContext.h"
36+ // #include "SecurityOrigin.h"
3437#include " URLSearchParams.h"
35- // #include <wtf/MainThread.h>
38+ #include < wtf/MainThread.h>
39+
40+ class URLRegistrable {
41+ public:
42+ };
43+
44+ class Blob {
45+ public:
46+ };
3647
3748namespace WebCore {
3849
3950static inline String redact (const String& input)
4051{
41- if (input.contains (" @ " _s ))
52+ if (input.contains (' @ ' ))
4253 return " <redacted>" _s;
4354
4455 return makeString (' "' , input, ' "' );
4556}
4657
47- inline DOMURL::DOMURL (URL && completeURL, const URL & baseURL)
48- : m_baseURL(baseURL)
49- , m_url(WTFMove(completeURL))
58+ inline DOMURL::DOMURL (URL && completeURL)
59+ : m_url(WTFMove(completeURL))
5060{
61+ ASSERT (m_url.isValid ());
5162}
5263
53- DOMURL ::~DOMURL () = default ;
54-
55- bool DOMURL::canParse (const String& url, const String& base)
64+ ExceptionOr<Ref<DOMURL >> DOMURL::create (const String& url)
5665{
57- URL baseURL { base };
58- if (!base.isNull () && !baseURL.isValid ())
59- return false ;
60- URL completeURL { baseURL, url };
61- return completeURL.isValid ();
66+ URL completeURL { url };
67+ if (!completeURL.isValid ())
68+ return Exception { TypeError, makeString (redact (url), " cannot be parsed as a URL." ) };
69+ return adoptRef (*new DOMURL (WTFMove (completeURL)));
6270}
6371
6472ExceptionOr<Ref<DOMURL >> DOMURL::create (const String& url, const URL & base)
@@ -67,7 +75,7 @@ ExceptionOr<Ref<DOMURL>> DOMURL::create(const String& url, const URL& base)
6775 URL completeURL { base, url };
6876 if (!completeURL.isValid ())
6977 return Exception { TypeError, makeString (redact (url), " cannot be parsed as a URL." ) };
70- return adoptRef (*new DOMURL (WTFMove (completeURL), base ));
78+ return adoptRef (*new DOMURL (WTFMove (completeURL)));
7179}
7280
7381ExceptionOr<Ref<DOMURL >> DOMURL::create (const String& url, const String& base)
@@ -78,9 +86,27 @@ ExceptionOr<Ref<DOMURL>> DOMURL::create(const String& url, const String& base)
7886 return create (url, baseURL);
7987}
8088
81- ExceptionOr<Ref<DOMURL >> DOMURL::create (const String& url, const DOMURL & base)
89+ DOMURL ::~DOMURL () = default ;
90+
91+ static URL parseInternal (const String& url, const String& base)
92+ {
93+ URL baseURL { base };
94+ if (!base.isNull () && !baseURL.isValid ())
95+ return {};
96+ return { baseURL, url };
97+ }
98+
99+ RefPtr<DOMURL > DOMURL::parse (const String& url, const String& base)
82100{
83- return create (url, base.href ());
101+ auto completeURL = parseInternal (url, base);
102+ if (!completeURL.isValid ())
103+ return {};
104+ return adoptRef (*new DOMURL (WTFMove (completeURL)));
105+ }
106+
107+ bool DOMURL::canParse (const String& url, const String& base)
108+ {
109+ return parseInternal (url, base).isValid ();
84110}
85111
86112ExceptionOr<void > DOMURL::setHref (const String& url)
@@ -96,26 +122,27 @@ ExceptionOr<void> DOMURL::setHref(const String& url)
96122 return {};
97123}
98124
99- void DOMURL::setQuery ( const String& query )
125+ String DOMURL::createObjectURL (ScriptExecutionContext& scriptExecutionContext, Blob& blob )
100126{
101- m_url.setQuery (query);
127+ UNUSED_PARAM (blob);
128+ UNUSED_PARAM (scriptExecutionContext);
129+ return String ();
130+ // return createPublicURL(scriptExecutionContext, blob);
102131}
103132
104- // String DOMURL::createObjectURL(Blob& blob)
105- // {
106- // return createPublicURL(scriptExecutionContext, blob);
107- // }
108-
109- // String DOMURL::createPublicURL(URLRegistrable& registrable)
110- // {
111- // URL publicURL = BlobURL::createPublicURL(scriptExecutionContext.securityOrigin());
112- // if (publicURL.isEmpty())
113- // return String();
133+ String DOMURL::createPublicURL (ScriptExecutionContext& scriptExecutionContext, URLRegistrable& registrable)
134+ {
135+ // URL publicURL = BlobURL::createPublicURL(scriptExecutionContext.securityOrigin());
136+ // if (publicURL.isEmpty())
137+ // return String();
114138
115- // scriptExecutionContext.publicURLManager().registerURL(publicURL, registrable);
139+ // scriptExecutionContext.publicURLManager().registerURL(publicURL, registrable);
116140
117- // return publicURL.string();
118- // }
141+ // return publicURL.string();
142+ UNUSED_PARAM (scriptExecutionContext);
143+ UNUSED_PARAM (registrable);
144+ return String ();
145+ }
119146
120147URLSearchParams& DOMURL::searchParams ()
121148{
@@ -124,15 +151,17 @@ URLSearchParams& DOMURL::searchParams()
124151 return *m_searchParams;
125152}
126153
127- // void DOMURL::revokeObjectURL(const String& urlString)
128- // {
129- // // URL url(URL(), urlString) ;
130- // // ResourceRequest request(url);
131- // // request.setDomainForCachePartition(scriptExecutionContext.domainForCachePartition());
154+ void DOMURL::revokeObjectURL (ScriptExecutionContext& scriptExecutionContext, const String& urlString)
155+ {
156+ // URL url { urlString } ;
157+ // ResourceRequest request(url);
158+ // request.setDomainForCachePartition(scriptExecutionContext.domainForCachePartition());
132159
133- // // MemoryCache::removeRequestFromSessionCaches(scriptExecutionContext, request);
160+ // MemoryCache::removeRequestFromSessionCaches(scriptExecutionContext, request);
134161
135- // // scriptExecutionContext.publicURLManager().revoke(url);
136- // }
162+ // scriptExecutionContext.publicURLManager().revoke(url);
163+ UNUSED_PARAM (scriptExecutionContext);
164+ UNUSED_PARAM (urlString);
165+ }
137166
138167} // namespace WebCore
0 commit comments