Bug 1287492 - Part 2. Rewrite nsSVGUtils::GetNearestSVGViewport draft
authorcku <cku@mozilla.com>
Thu, 09 Feb 2017 22:36:17 +0800
changeset 481261 9407f887b938da7d2fd99c078e20568272f75400
parent 481260 2858afc97f2f34a087343b50af9bda042ab1853c
child 481262 9472ef111572552cb9bea558a3f724f037a478a5
child 481265 46a51ce5f15e82ad00a98f46c5fe792a48a1e993
child 481312 83766cb8a0dc0ae7bdc3178965d40db9f5626f58
child 481367 3c1f061f50a67d38f565e53dfd34989482ffd5a8
child 481581 ea54d04b0660c81f50b3c3899a6aabb356edbc34
push id44753
push userbmo:cku@mozilla.com
push dateThu, 09 Feb 2017 14:41:29 +0000
bugs1287492
milestone54.0a1
Bug 1287492 - Part 2. Rewrite nsSVGUtils::GetNearestSVGViewport GetNearestSVGViewport is not used anymore, rewrite it, Part 3 will need this new version. MozReview-Commit-ID: GNJXICG9akj
layout/svg/nsSVGUtils.cpp
layout/svg/nsSVGUtils.h
--- a/layout/svg/nsSVGUtils.cpp
+++ b/layout/svg/nsSVGUtils.cpp
@@ -143,31 +143,30 @@ nsSVGUtils::Init()
 
   Preferences::AddBoolVarCache(&sSVGDisplayListPaintingEnabled,
                                "svg.display-lists.painting.enabled");
 
   Preferences::AddBoolVarCache(&sSVGNewGetBBoxEnabled,
                                "svg.new-getBBox.enabled");
 }
 
-nsSVGDisplayContainerFrame*
-nsSVGUtils::GetNearestSVGViewport(nsIFrame *aFrame)
+nsIFrame*
+nsSVGUtils::GetNearestSVGParent(nsIFrame *aFrame)
 {
   NS_ASSERTION(aFrame->IsFrameOfType(nsIFrame::eSVG), "SVG frame expected");
-  if (aFrame->GetType() == nsGkAtoms::svgOuterSVGFrame) {
-    return nullptr;
-  }
-  while ((aFrame = aFrame->GetParent())) {
+
+  for (; aFrame &&  aFrame->IsFrameOfType(nsIFrame::eSVG);
+       aFrame = aFrame->GetParent()) {
     NS_ASSERTION(aFrame->IsFrameOfType(nsIFrame::eSVG), "SVG frame expected");
     if (aFrame->GetType() == nsGkAtoms::svgInnerSVGFrame ||
         aFrame->GetType() == nsGkAtoms::svgOuterSVGFrame) {
-      return do_QueryFrame(aFrame);
+      return aFrame;
     }
   }
-  NS_NOTREACHED("This is not reached. It's only needed to compile.");
+
   return nullptr;
 }
 
 nsRect
 nsSVGUtils::GetPostFilterVisualOverflowRect(nsIFrame *aFrame,
                                             const nsRect &aPreFilterRect)
 {
   MOZ_ASSERT(aFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT,
--- a/layout/svg/nsSVGUtils.h
+++ b/layout/svg/nsSVGUtils.h
@@ -191,20 +191,19 @@ public:
   typedef mozilla::image::DrawResult DrawResult;
 
   static void Init();
 
   NS_DECLARE_FRAME_PROPERTY_DELETABLE(ObjectBoundingBoxProperty, gfxRect)
 
   /**
    * Gets the nearest nsSVGInnerSVGFrame or nsSVGOuterSVGFrame frame. aFrame
-   * must be an SVG frame. If aFrame is of type nsGkAtoms::svgOuterSVGFrame,
-   * returns nullptr.
+   * must be an SVG frame.
    */
-  static nsSVGDisplayContainerFrame* GetNearestSVGViewport(nsIFrame *aFrame);
+  static nsIFrame* GetNearestSVGParent(nsIFrame *aFrame);
 
   /**
    * Returns the frame's post-filter visual overflow rect when passed the
    * frame's pre-filter visual overflow rect. If the frame is not currently
    * being filtered, this function simply returns aUnfilteredRect.
    */
   static nsRect GetPostFilterVisualOverflowRect(nsIFrame *aFrame,
                                                 const nsRect &aUnfilteredRect);