Bug 1626155. nsLayoutUtils::TransformAncestorPointToFrame passes null for ancestor frame. r=botond
authorTimothy Nikkel <tnikkel@gmail.com>
Thu, 02 Apr 2020 00:38:46 +0000
changeset 521710 3506ad8b3ae2d23270ed33db79cf6bb304a662a9
parent 521709 bd051fd71e1cb24626db992fe079109eca9aee6f
child 521711 13930d078e015f09442d845d06a378a5bbf6122c
push id37274
push userdvarga@mozilla.com
push dateThu, 02 Apr 2020 09:51:45 +0000
treeherdermozilla-central@95ddb3213aec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1626155
milestone76.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 1626155. nsLayoutUtils::TransformAncestorPointToFrame passes null for ancestor frame. r=botond It probably doesn't case any problems because the two callers of the function don't hit the case with the bug. nsLayoutUtils::TransformRootPointToFrame passes nullptr for the ancester frame. nsIFrame::GetContentOffsetsFromPoint only calls this function if aFrame is in an svg text subtree, so it takes the other branch. Looks like this was a simple oversight in this change https://hg.mozilla.org/mozilla-central/rev/204b51a6c6458a30be158a3d1bdca8e9b4edfd67 where TransformRootPointToFrame was changed to TransformAncestorPointToFrame and it originally passed nullptr (which was correct to the Root version fo the function) but didn't get updated in the change. Differential Revision: https://phabricator.services.mozilla.com/D68954
layout/base/nsLayoutUtils.cpp
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -2963,25 +2963,23 @@ nsPoint nsLayoutUtils::TransformAncestor
                                                      const nsPoint& aPoint,
                                                      nsIFrame* aAncestor) {
   SVGTextFrame* text = GetContainingSVGTextFrame(aFrame);
 
   float factor = aFrame->PresContext()->AppUnitsPerDevPixel();
   Point result(NSAppUnitsToFloatPixels(aPoint.x, factor),
                NSAppUnitsToFloatPixels(aPoint.y, factor));
 
+  if (!TransformGfxPointFromAncestor(text ? text : aFrame, result, aAncestor,
+                                     &result)) {
+    return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
+  }
+
   if (text) {
-    if (!TransformGfxPointFromAncestor(text, result, aAncestor, &result)) {
-      return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
-    }
     result = text->TransformFramePointToTextChild(result, aFrame);
-  } else {
-    if (!TransformGfxPointFromAncestor(aFrame, result, nullptr, &result)) {
-      return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
-    }
   }
 
   return nsPoint(NSFloatPixelsToAppUnits(float(result.x), factor),
                  NSFloatPixelsToAppUnits(float(result.y), factor));
 }
 
 nsRect nsLayoutUtils::TransformFrameRectToAncestor(
     const nsIFrame* aFrame, const nsRect& aRect, const nsIFrame* aAncestor,