Bug 1368950 - Remove URL Constructor with a URL base argument, r=qdot
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 31 May 2017 21:18:19 +0200
changeset 412133 cadb789ebd3972c8e5f65bff0fc12ae61e162e69
parent 412132 0f4474710f24dbce9a92ebc75610fe8ab34bd638
child 412134 7d9c81795eeda760c11c4c8eb217cfecb7699d01
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot
bugs1368950
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1368950 - Remove URL Constructor with a URL base argument, r=qdot
dom/url/URL.cpp
dom/url/URL.h
dom/webidl/URL.webidl
--- a/dom/url/URL.cpp
+++ b/dom/url/URL.cpp
@@ -57,20 +57,16 @@ CreateObjectURLInternal(const GlobalObje
 }
 
 // The URL implementation for the main-thread
 class URLMainThread final : public URL
 {
 public:
   static already_AddRefed<URLMainThread>
   Constructor(const GlobalObject& aGlobal, const nsAString& aURL,
-              URL& aBase, ErrorResult& aRv);
-
-  static already_AddRefed<URLMainThread>
-  Constructor(const GlobalObject& aGlobal, const nsAString& aURL,
               const Optional<nsAString>& aBase, ErrorResult& aRv);
 
   static already_AddRefed<URLMainThread>
   Constructor(nsISupports* aParent, const nsAString& aURL,
               const nsAString& aBase, ErrorResult& aRv);
 
   static already_AddRefed<URLMainThread>
   Constructor(nsISupports* aParent, const nsAString& aURL, nsIURI* aBase,
@@ -189,25 +185,16 @@ private:
     MOZ_ASSERT(NS_IsMainThread());
   }
 
   nsCOMPtr<nsIURI> mURI;
 };
 
 /* static */ already_AddRefed<URLMainThread>
 URLMainThread::Constructor(const GlobalObject& aGlobal, const nsAString& aURL,
-                           URL& aBase, ErrorResult& aRv)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  URLMainThread& base = static_cast<URLMainThread&>(aBase);
-  return Constructor(aGlobal.GetAsSupports(), aURL, base.GetURI(), aRv);
-}
-
-/* static */ already_AddRefed<URLMainThread>
-URLMainThread::Constructor(const GlobalObject& aGlobal, const nsAString& aURL,
                            const Optional<nsAString>& aBase, ErrorResult& aRv)
 {
   if (aBase.WasPassed()) {
     return Constructor(aGlobal.GetAsSupports(), aURL, aBase.Value(), aRv);
   }
 
   return Constructor(aGlobal.GetAsSupports(), aURL, nullptr, aRv);
 }
@@ -628,20 +615,16 @@ private:
 };
 
 // URLWorker implements the URL object in workers.
 class URLWorker final : public URL
 {
 public:
   static already_AddRefed<URLWorker>
   Constructor(const GlobalObject& aGlobal, const nsAString& aURL,
-              URL& aBase, ErrorResult& aRv);
-
-  static already_AddRefed<URLWorker>
-  Constructor(const GlobalObject& aGlobal, const nsAString& aURL,
               const Optional<nsAString>& aBase, ErrorResult& aRv);
 
   static already_AddRefed<URLWorker>
   Constructor(const GlobalObject& aGlobal, const nsAString& aURL,
               const nsAString& aBase, ErrorResult& aRv);
 
   static void
   CreateObjectURL(const GlobalObject& aGlobal, Blob& aBlob,
@@ -895,17 +878,16 @@ public:
 
 // This class creates a URL object on the main thread.
 class ConstructorRunnable : public WorkerMainThreadRunnable
 {
 private:
   const nsString mURL;
 
   nsString mBase; // IsVoid() if we have no base URI string.
-  RefPtr<URLProxy> mBaseProxy;
 
   RefPtr<URLProxy> mRetval;
 
 public:
   ConstructorRunnable(WorkerPrivate* aWorkerPrivate,
                       const nsAString& aURL, const Optional<nsAString>& aBase)
   : WorkerMainThreadRunnable(aWorkerPrivate,
                              NS_LITERAL_CSTRING("URL :: Constructor"))
@@ -914,37 +896,24 @@ public:
     if (aBase.WasPassed()) {
       mBase = aBase.Value();
     } else {
       mBase.SetIsVoid(true);
     }
     mWorkerPrivate->AssertIsOnWorkerThread();
   }
 
-  ConstructorRunnable(WorkerPrivate* aWorkerPrivate,
-                      const nsAString& aURL, URLProxy* aBaseProxy)
-  : WorkerMainThreadRunnable(aWorkerPrivate,
-                             NS_LITERAL_CSTRING("URL :: Constructor with BaseURL"))
-  , mURL(aURL)
-  , mBaseProxy(aBaseProxy)
-  {
-    mBase.SetIsVoid(true);
-    mWorkerPrivate->AssertIsOnWorkerThread();
-  }
-
   bool
   MainThreadRun()
   {
     AssertIsOnMainThread();
 
     ErrorResult rv;
     RefPtr<URLMainThread> url;
-    if (mBaseProxy) {
-      url = URLMainThread::Constructor(nullptr, mURL, mBaseProxy->URI(), rv);
-    } else if (!mBase.IsVoid()) {
+    if (!mBase.IsVoid()) {
       url = URLMainThread::Constructor(nullptr, mURL, mBase, rv);
     } else {
       url = URLMainThread::Constructor(nullptr, mURL, nullptr, rv);
     }
 
     if (rv.Failed()) {
       rv.SuppressException();
       return true;
@@ -1212,32 +1181,16 @@ FinishConstructor(JSContext* aCx, Worker
   }
 
   RefPtr<URLWorker> url = new URLWorker(aPrivate, proxy);
   return url.forget();
 }
 
 /* static */ already_AddRefed<URLWorker>
 URLWorker::Constructor(const GlobalObject& aGlobal, const nsAString& aURL,
-                       URL& aBase, ErrorResult& aRv)
-{
-  MOZ_ASSERT(!NS_IsMainThread());
-
-  JSContext* cx = aGlobal.Context();
-  WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(cx);
-
-  URLWorker& base = static_cast<URLWorker&>(aBase);
-  RefPtr<ConstructorRunnable> runnable =
-    new ConstructorRunnable(workerPrivate, aURL, base.GetURLProxy());
-
-  return FinishConstructor(cx, workerPrivate, runnable, aRv);
-}
-
-/* static */ already_AddRefed<URLWorker>
-URLWorker::Constructor(const GlobalObject& aGlobal, const nsAString& aURL,
                        const Optional<nsAString>& aBase, ErrorResult& aRv)
 {
   JSContext* cx = aGlobal.Context();
   WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(cx);
 
   RefPtr<ConstructorRunnable> runnable =
     new ConstructorRunnable(workerPrivate, aURL, aBase);
 
@@ -1650,27 +1603,16 @@ NS_INTERFACE_MAP_END
 JSObject*
 URL::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return URLBinding::Wrap(aCx, this, aGivenProto);
 }
 
 /* static */ already_AddRefed<URL>
 URL::Constructor(const GlobalObject& aGlobal, const nsAString& aURL,
-                 URL& aBase, ErrorResult& aRv)
-{
-  if (NS_IsMainThread()) {
-    return URLMainThread::Constructor(aGlobal, aURL, aBase, aRv);
-  }
-
-  return URLWorker::Constructor(aGlobal, aURL, aBase, aRv);
-}
-
-/* static */ already_AddRefed<URL>
-URL::Constructor(const GlobalObject& aGlobal, const nsAString& aURL,
                  const Optional<nsAString>& aBase, ErrorResult& aRv)
 {
   if (NS_IsMainThread()) {
     return URLMainThread::Constructor(aGlobal, aURL, aBase, aRv);
   }
 
   return URLWorker::Constructor(aGlobal, aURL, aBase, aRv);
 }
--- a/dom/url/URL.h
+++ b/dom/url/URL.h
@@ -44,20 +44,16 @@ public:
     return mParent;
   }
 
   virtual JSObject*
   WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
   static already_AddRefed<URL>
   Constructor(const GlobalObject& aGlobal, const nsAString& aURL,
-              URL& aBase, ErrorResult& aRv);
-
-  static already_AddRefed<URL>
-  Constructor(const GlobalObject& aGlobal, const nsAString& aURL,
               const Optional<nsAString>& aBase, ErrorResult& aRv);
 
   // Helper for Fetch API
   static already_AddRefed<URL>
   WorkerConstructor(const GlobalObject& aGlobal, const nsAString& aURL,
                     const nsAString& aBase, ErrorResult& aRv);
 
 
--- a/dom/webidl/URL.webidl
+++ b/dom/webidl/URL.webidl
@@ -7,19 +7,17 @@
  * http://url.spec.whatwg.org/#api
  * http://dev.w3.org/2006/webapi/FileAPI/#creating-revoking
  * http://dev.w3.org/2011/webrtc/editor/getusermedia.html#url
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
-// [Constructor(DOMString url, optional (URL or DOMString) base = "about:blank")]
-[Constructor(DOMString url, URL base),
- Constructor(DOMString url, optional DOMString base),
+[Constructor(USVString url, optional USVString base),
  Exposed=(Window,Worker,WorkerDebugger)]
 interface URL {
   // Bug 824857: no support for stringifier attributes yet.
   //  stringifier attribute USVString href;
 
   // Bug 824857 should remove this.
   [Throws]
   stringifier;