Bug 1596511 - Remove binding parent usage from SVGSVGElement. r=smaug
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 15 Nov 2019 10:19:55 +0000
changeset 502132 94cd78feaa1f293c4cf8e34d70c5ee9f02e1561f
parent 502131 fc12d7dbaaf54ce5af741b400589ba2ad7454425
child 502133 c7c61985bf36098a2ef0d038a7fdc94e1b2624c1
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 - Remove binding parent usage from SVGSVGElement. r=smaug This doesn't need to handle NAC anymore since <svg:use> element doesn't use NAC anymore. Handle Shadow DOM by using GetParentOrShadowHostNode(), though we should figure out what the right thing to do since GetOwnerSVGElement and co. use GetFlattenedTreeParent(). In practice, these should be equivalent because SVG Elements can't be shadow hosts. Differential Revision: https://phabricator.services.mozilla.com/D53063
dom/svg/SVGSVGElement.cpp
dom/svg/SVGSVGElement.h
--- a/dom/svg/SVGSVGElement.cpp
+++ b/dom/svg/SVGSVGElement.cpp
@@ -369,17 +369,17 @@ SMILTimeContainer* SVGSVGElement::GetTim
 // SVGElement
 nsresult SVGSVGElement::BindToTree(BindContext& aContext, nsINode& aParent) {
   SMILAnimationController* smilController = nullptr;
 
   // FIXME(emilio, bug 1555948): Should probably use composed doc.
   if (Document* doc = aContext.GetUncomposedDoc()) {
     if ((smilController = doc->GetAnimationController())) {
       // SMIL is enabled in this document
-      if (WillBeOutermostSVG(aParent, aContext.GetBindingParent())) {
+      if (WillBeOutermostSVG(aParent)) {
         // We'll be the outermost <svg> element.  We'll need a time container.
         if (!mTimedDocumentRoot) {
           mTimedDocumentRoot = new SMILTimeContainer();
         }
       } else {
         // We're a child of some other <svg> element, so we don't need our own
         // time container. However, we need to make sure that we'll get a
         // kick-start if we get promoted to be outermost later on.
@@ -479,29 +479,27 @@ void SVGSVGElement::FlushImageTransformI
     InvalidateTransformNotifyFrame();
     mImageNeedsTransformInvalidation = false;
   }
 }
 
 //----------------------------------------------------------------------
 // implementation helpers
 
-bool SVGSVGElement::WillBeOutermostSVG(nsINode& aParent,
-                                       Element* aBindingParent) const {
-  nsINode* parent = aBindingParent ? aBindingParent : &aParent;
-
+bool SVGSVGElement::WillBeOutermostSVG(nsINode& aParent) const {
+  nsINode* parent = &aParent;
   while (parent && parent->IsSVGElement()) {
     if (parent->IsSVGElement(nsGkAtoms::foreignObject)) {
       // SVG in a foreignObject must have its own <svg> (nsSVGOuterSVGFrame).
       return false;
     }
     if (parent->IsSVGElement(nsGkAtoms::svg)) {
       return false;
     }
-    parent = parent->GetParent();
+    parent = parent->GetParentOrShadowHostNode();
   }
 
   return true;
 }
 
 void SVGSVGElement::InvalidateTransformNotifyFrame() {
   nsISVGSVGFrame* svgframe = do_QueryFrame(GetPrimaryFrame());
   // might fail this check if we've failed conditional processing
--- a/dom/svg/SVGSVGElement.h
+++ b/dom/svg/SVGSVGElement.h
@@ -190,18 +190,21 @@ class SVGSVGElement final : public SVGSV
   /*
    * While binding to the tree we need to determine if we will be the outermost
    * <svg> element _before_ the children are bound (as they want to know what
    * timed document root to register with) and therefore _before_ our parent is
    * set (both actions are performed by Element::BindToTree) so we
    * can't use GetOwnerSVGElement() as it relies on GetParent(). This code is
    * basically a simplified version of GetOwnerSVGElement that uses the parent
    * parameters passed in instead.
+   *
+   * FIXME(bug 1596690): GetOwnerSVGElement() uses the flattened tree parent
+   * rather than the DOM tree parent nowadays.
    */
-  bool WillBeOutermostSVG(nsINode& aParent, Element* aBindingParent) const;
+  bool WillBeOutermostSVG(nsINode& aParent) const;
 
   // invalidate viewbox -> viewport xform & inform frames
   void InvalidateTransformNotifyFrame();
 
   // Methods for <image> elements to override my "PreserveAspectRatio" value.
   // These are private so that only our friends
   // (AutoPreserveAspectRatioOverride in particular) have access.
   void SetImageOverridePreserveAspectRatio(const SVGPreserveAspectRatio& aPAR);