Bug 1551137 - <svg:mpath> should work in Shadow DOM. r=longsonr
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 13 May 2019 17:28:59 +0000
changeset 532456 027695189d656e036946b9774921fb8e2e09a1f8
parent 532455 06e37cc6a55c2d06f9164a1f2078b8f8a4d9e3a2
child 532457 46ad1099db88415ea5af702bfd4986a5957b9d6f
child 532495 3c7f3988e7045742252732b4948b6fa851ff6057
push id11268
push usercsabou@mozilla.com
push dateTue, 14 May 2019 15:24:22 +0000
treeherdermozilla-beta@5fb7fcd568d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslongsonr
bugs1551137
milestone68.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 1551137 - <svg:mpath> should work in Shadow DOM. r=longsonr Differential Revision: https://phabricator.services.mozilla.com/D30894
dom/svg/SVGMPathElement.cpp
layout/reftests/svg/smil/motion/animateMotion-mpath-shadow.svg
layout/reftests/svg/smil/motion/reftest.list
--- a/dom/svg/SVGMPathElement.cpp
+++ b/dom/svg/SVGMPathElement.cpp
@@ -72,17 +72,17 @@ already_AddRefed<DOMSVGAnimatedString> S
 nsresult SVGMPathElement::BindToTree(Document* aDocument, nsIContent* aParent,
                                      nsIContent* aBindingParent) {
   MOZ_ASSERT(!mPathTracker.get(),
              "Shouldn't have href-target yet (or it should've been cleared)");
   nsresult rv =
       SVGMPathElementBase::BindToTree(aDocument, aParent, aBindingParent);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  if (aDocument) {
+  if (IsInComposedDoc()) {
     const nsAttrValue* hrefAttrValue =
         HasAttr(kNameSpaceID_None, nsGkAtoms::href)
             ? mAttrs.GetAttr(nsGkAtoms::href, kNameSpaceID_None)
             : mAttrs.GetAttr(nsGkAtoms::href, kNameSpaceID_XLink);
     if (hrefAttrValue) {
       UpdateHrefTarget(aParent, hrefAttrValue->GetStringValue());
     }
   }
@@ -98,17 +98,17 @@ void SVGMPathElement::UnbindFromTree(boo
 bool SVGMPathElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
                                      const nsAString& aValue,
                                      nsIPrincipal* aMaybeScriptedPrincipal,
                                      nsAttrValue& aResult) {
   bool returnVal = SVGMPathElementBase::ParseAttribute(
       aNamespaceID, aAttribute, aValue, aMaybeScriptedPrincipal, aResult);
   if ((aNamespaceID == kNameSpaceID_XLink ||
        aNamespaceID == kNameSpaceID_None) &&
-      aAttribute == nsGkAtoms::href && IsInUncomposedDoc()) {
+      aAttribute == nsGkAtoms::href && IsInComposedDoc()) {
     // Note: If we fail the IsInDoc call, it's ok -- we'll update the target
     // on next BindToTree call.
 
     // Note: "href" takes priority over xlink:href. So if "xlink:href" is being
     // set here, we only let that update our target if "href" is *unset*.
     if (aNamespaceID != kNameSpaceID_XLink ||
         !mStringAttributes[HREF].IsExplicitlySet()) {
       UpdateHrefTarget(GetParent(), aValue);
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/smil/motion/animateMotion-mpath-shadow.svg
@@ -0,0 +1,34 @@
+<svg xmlns="http://www.w3.org/2000/svg"
+     xmlns:xlink="http://www.w3.org/1999/xlink" class="reftest-wait">
+  <title>Test that pathLength works inside a shadow tree</title>
+  <defs>
+    <path id="path" pathLength="100" d="M0,0 h400" />
+    <g id="content">
+      <rect width="100%" height="100%" fill="lime"/>
+
+      <!-- calcMode="linear" -->
+      <rect x="10" y="10" width="100" height="100" fill="red"/>
+      <rect x="-190" y="10" width="100" height="100" fill="lime">
+        <animateMotion begin="100s" dur="1s" keyPoints="0;1" keyTimes="0;1" calcMode="linear">
+          <mpath xlink:href="#path" />
+        </animateMotion>
+      </rect>
+
+      <!-- calcMode="paced" -->
+      <rect x="10" y="110" width="100" height="100" fill="red"/>
+      <rect x="-190" y="110" width="100" height="100" fill="lime">
+        <animateMotion begin="100s" dur="1s">
+          <mpath xlink:href="#path" />
+        </animateMotion>
+      </rect>
+    </g>
+  </defs>
+  <script xlink:href="../smil-util.js" type="text/javascript"/>
+  <script type="text/javascript">
+    function doTest() {
+      setTimeAndSnapshot(100.5, true);
+    }
+    window.addEventListener("MozReftestInvalidate", doTest, false);
+  </script>
+  <use xlink:href="#content"></use>
+</svg>
--- a/layout/reftests/svg/smil/motion/reftest.list
+++ b/layout/reftests/svg/smil/motion/reftest.list
@@ -14,8 +14,9 @@ fuzzy-if(skiaContent,0-1,0-40) == animat
 == animateMotion-values-linear-1.svg animateMotion-values-linear-1-ref.svg
 == animateMotion-values-paced-1a.svg animateMotion-values-paced-1-ref.svg
 fuzzy-if(skiaContent,0-1,0-30) == animateMotion-values-paced-1b.svg animateMotion-values-paced-1-ref.svg
 
 # Tests involving <mpath> sub-element
 == animateMotion-mpath-pathLength-1.svg lime.svg
 == animateMotion-mpath-targetChange-1.svg lime.svg
 == animateMotion-mpath-target-transform-1.svg lime.svg
+== animateMotion-mpath-shadow.svg lime.svg