Bug 1596511 - Simplify SVGObserverUtils::GetBaseURLForLocalRef. r=smaug
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 14 Nov 2019 22:34:10 +0000
changeset 502131 fc12d7dbaaf54ce5af741b400589ba2ad7454425
parent 502130 fd63a50a812ec869d3e17e86f9a89ed47c8f1671
child 502132 94cd78feaa1f293c4cf8e34d70c5ee9f02e1561f
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1596511
milestone72.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 1596511 - Simplify SVGObserverUtils::GetBaseURLForLocalRef. r=smaug It looked a bit weird after the XBL removal. Can be simpler and not use GetBindingParent. Differential Revision: https://phabricator.services.mozilla.com/D53062
layout/svg/SVGObserverUtils.cpp
--- a/layout/svg/SVGObserverUtils.cpp
+++ b/layout/svg/SVGObserverUtils.cpp
@@ -1670,48 +1670,35 @@ void SVGObserverUtils::InvalidateDirectR
     InvalidateDirectRenderingObservers(content->AsElement(), aFlags);
   }
 }
 
 already_AddRefed<nsIURI> SVGObserverUtils::GetBaseURLForLocalRef(
     nsIContent* content, nsIURI* aDocURI) {
   MOZ_ASSERT(content);
 
-  // For a local-reference URL, resolve that fragment against the current
-  // document that relative URLs are resolved against.
-  nsCOMPtr<nsIURI> baseURI = content->OwnerDoc()->GetDocumentURI();
-
-  nsCOMPtr<nsIURI> originalURI;
   // Content is in a shadow tree.  If this URL was specified in the subtree
-  // referenced by the <use>(or -moz-binding) element, and that subtree came
-  // from a separate resource document, then we want the fragment-only URL
-  // to resolve to an element from the resource document.  Otherwise, the
-  // URL was specified somewhere in the document with the <use> element, and
-  // we want the fragment-only URL to resolve to an element in that document.
+  // referenced by the <use>, element, and that subtree came from a separate
+  // resource document, then we want the fragment-only URL to resolve to an
+  // element from the resource document.  Otherwise, the URL was specified
+  // somewhere in the document with the <use> element, and we want the
+  // fragment-only URL to resolve to an element in that document.
   if (SVGUseElement* use = content->GetContainingSVGUseShadowHost()) {
-    originalURI = use->GetSourceDocURI();
-  } else if (content->IsInAnonymousSubtree()) {
-    nsIContent* bindingParent = content->GetBindingParent();
-
-    if (bindingParent) {
-      MOZ_ASSERT(content->IsInNativeAnonymousSubtree(),
-                 "a non-native anonymous tree which is not from "
-                 "an XBL binding?");
+    if (nsIURI* originalURI = use->GetSourceDocURI()) {
+      bool isEqualsExceptRef = false;
+      aDocURI->EqualsExceptRef(originalURI, &isEqualsExceptRef);
+      if (isEqualsExceptRef) {
+        return do_AddRef(originalURI);
+      }
     }
   }
 
-  if (originalURI) {
-    bool isEqualsExceptRef = false;
-    aDocURI->EqualsExceptRef(originalURI, &isEqualsExceptRef);
-    if (isEqualsExceptRef) {
-      return originalURI.forget();
-    }
-  }
-
-  return baseURI.forget();
+  // For a local-reference URL, resolve that fragment against the current
+  // document that relative URLs are resolved against.
+  return do_AddRef(content->OwnerDoc()->GetDocumentURI());
 }
 
 already_AddRefed<URLAndReferrerInfo> SVGObserverUtils::GetFilterURI(
     nsIFrame* aFrame, const StyleFilter& aFilter) {
   MOZ_ASSERT(!aFrame->StyleEffects()->mFilters.IsEmpty() ||
              !aFrame->StyleEffects()->mBackdropFilters.IsEmpty());
   MOZ_ASSERT(aFilter.IsUrl());
   return ResolveURLUsingLocalRef(aFrame, aFilter.AsUrl());