Merge inbound to mozilla-central. a=merge
authorCsoregi Natalia <ncsoregi@mozilla.com>
Fri, 16 Aug 2019 06:59:41 +0300
changeset 488384 d887276421d30c773431c006b0607cd30f4d9259
parent 488382 a58b7dc85887bcc257f525c2ae1df4427f1df613 (current diff)
parent 488383 bd6df046c082cdab22dac956e16e357c1d9b5f4b (diff)
child 488385 8da8443e0bcb7a6d9766d179332443660c926d8b
child 488426 37aaf28a693732407ded4ab9e7e153bc680f02a6
child 488643 fcd47d1e1ed53bf0bfe00a811925bd5cd1451609
push id36441
push userncsoregi@mozilla.com
push dateFri, 16 Aug 2019 03:59:57 +0000
treeherdermozilla-central@d887276421d3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone70.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
Merge inbound to mozilla-central. a=merge
dom/base/Document.cpp
dom/base/Document.h
--- a/dom/base/Document.cpp
+++ b/dom/base/Document.cpp
@@ -326,16 +326,17 @@
 #include "mozilla/MediaManager.h"
 
 #include "AutoplayPolicy.h"
 #include "nsIURIMutator.h"
 #include "mozilla/DocumentStyleRootIterator.h"
 #include "mozilla/PendingFullscreenEvent.h"
 #include "mozilla/RestyleManager.h"
 #include "mozilla/ClearOnShutdown.h"
+#include "mozilla/ResultExtensions.h"
 #include "nsHTMLTags.h"
 #include "MobileViewportManager.h"
 #include "NodeUbiReporting.h"
 #include "nsICookieService.h"
 #include "mozilla/net/ChannelEventQueue.h"
 #include "mozilla/net/RequestContextService.h"
 #include "StorageAccessPermissionRequest.h"
 #include "mozilla/dom/WindowProxyHolder.h"
@@ -5745,16 +5746,24 @@ void Document::SetBaseURI(nsIURI* aURI) 
       return;
     }
   }
 
   mDocumentBaseURI = aURI;
   RefreshLinkHrefs();
 }
 
+Result<nsCOMPtr<nsIURI>, nsresult> Document::ResolveWithBaseURI(
+    const nsAString& aURI) {
+  nsCOMPtr<nsIURI> resolvedURI;
+  MOZ_TRY(
+      NS_NewURI(getter_AddRefs(resolvedURI), aURI, nullptr, GetDocBaseURI()));
+  return std::move(resolvedURI);
+}
+
 URLExtraData* Document::DefaultStyleAttrURLData() {
   MOZ_ASSERT(NS_IsMainThread());
   nsIURI* baseURI = GetDocBaseURI();
   nsIPrincipal* principal = NodePrincipal();
   bool equals;
   if (!mCachedURLData || mCachedURLData->BaseURI() != baseURI ||
       mCachedURLData->Principal() != principal || !mCachedReferrerInfo ||
       NS_FAILED(mCachedURLData->ReferrerInfo()->Equals(mCachedReferrerInfo,
--- a/dom/base/Document.h
+++ b/dom/base/Document.h
@@ -906,16 +906,21 @@ class Document : public nsINode,
     return GetFallbackBaseURI();
   }
 
   nsIURI* GetBaseURI(bool aTryUseXHRDocBaseURI = false) const final;
 
   void SetBaseURI(nsIURI* aURI);
 
   /**
+   * Resolves a URI based on the document's base URI.
+   */
+  Result<nsCOMPtr<nsIURI>, nsresult> ResolveWithBaseURI(const nsAString& aURI);
+
+  /**
    * Return the URL data which style system needs for resolving url value.
    * This method attempts to use the cached object in mCachedURLData, but
    * if the base URI, document URI, or principal has changed since last
    * call to this function, or the function is called the first time for
    * the document, a new one is created.
    */
   URLExtraData* DefaultStyleAttrURLData();