Bug 1357432 - Part 3. Resolve local-ref in SVGUseElement::LookupHref by nsSVGEffects::GetBaseURLForLocalRef. draft
authorcku <cku@mozilla.com>
Wed, 19 Apr 2017 02:06:07 +0800
changeset 565684 b9c52e209b62ad5331c9f8f858f7f865bec88f4e
parent 565683 86f3241de747f1e936ccf51288eb3ef661c58de8
child 565685 c7fb52081c4f8217f5f631e2d5f2039e25c20a5c
push id54957
push userbmo:cku@mozilla.com
push dateThu, 20 Apr 2017 07:59:21 +0000
bugs1357432
milestone55.0a1
Bug 1357432 - Part 3. Resolve local-ref in SVGUseElement::LookupHref by nsSVGEffects::GetBaseURLForLocalRef. MozReview-Commit-ID: CGCwQ73EQA7
dom/svg/SVGUseElement.cpp
--- a/dom/svg/SVGUseElement.cpp
+++ b/dom/svg/SVGUseElement.cpp
@@ -11,16 +11,17 @@
 #include "nsGkAtoms.h"
 #include "mozilla/dom/SVGSVGElement.h"
 #include "nsIDocument.h"
 #include "nsIPresShell.h"
 #include "mozilla/dom/Element.h"
 #include "nsContentUtils.h"
 #include "nsIURI.h"
 #include "mozilla/URLExtraData.h"
+#include "nsSVGEffects.h"
 
 NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Use)
 
 namespace mozilla {
 namespace dom {
 
 JSObject*
 SVGUseElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
@@ -417,21 +418,25 @@ SVGUseElement::LookupHref()
   } else {
     mStringAttributes[XLINK_HREF].GetAnimValue(href, this);
   }
 
   if (href.IsEmpty()) {
     return;
   }
 
+  nsCOMPtr<nsIURI> originURI =
+    mOriginal ? mOriginal->GetBaseURI() : GetBaseURI();
+  nsCOMPtr<nsIURI> baseURI = nsContentUtils::IsLocalRefURL(href)
+    ? nsSVGEffects::GetBaseURLForLocalRef(this, originURI)
+    : originURI;
+
   nsCOMPtr<nsIURI> targetURI;
-  nsCOMPtr<nsIURI> baseURI = mOriginal ? mOriginal->GetBaseURI() : GetBaseURI();
   nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(targetURI), href,
                                             GetComposedDoc(), baseURI);
-
   mSource.Reset(this, targetURI);
 }
 
 void
 SVGUseElement::TriggerReclone()
 {
   nsIDocument *doc = GetComposedDoc();
   if (!doc)