Bug 1546210: Refactor nsHTMLCanvasFrame::ComputeSize to use existing helper functions and avoid redundant GetCanvasSize() call. r=TYLin
authorDaniel Holbert <dholbert@cs.stanford.edu>
Tue, 23 Apr 2019 04:20:20 +0000
changeset 470515 6ed35343aea0f8d44fda91cafd752bd82df530ea
parent 470514 902921194cfe103f48acb8f4404ca8713a9df7a1
child 470516 9bc2f8e17d8062bd98fef67460ef0e74d5e0df17
push id35906
push useraciure@mozilla.com
push dateTue, 23 Apr 2019 22:14:56 +0000
treeherdermozilla-central@0ce3633f8b80 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersTYLin
bugs1546210
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 1546210: Refactor nsHTMLCanvasFrame::ComputeSize to use existing helper functions and avoid redundant GetCanvasSize() call. r=TYLin This patch should not affect behavior; the new implementation is identical to the old one, but with better sharing of code. Also: I'm removing the code-comment saying that the intrinsic ratio is unused, because it's not really useful and it's unclear to me that it's strictly true. There are several cases in the function we pass it to, nsFrame::ComputeSizeWithIntrinsicDimensions, that use the ratio and that look reachable as long as we have 'width:auto' in CSS. Differential Revision: https://phabricator.services.mozilla.com/D28416
layout/generic/nsHTMLCanvasFrame.cpp
--- a/layout/generic/nsHTMLCanvasFrame.cpp
+++ b/layout/generic/nsHTMLCanvasFrame.cpp
@@ -294,25 +294,20 @@ nsSize nsHTMLCanvasFrame::GetIntrinsicRa
 }
 
 /* virtual */
 LogicalSize nsHTMLCanvasFrame::ComputeSize(
     gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize,
     nscoord aAvailableISize, const LogicalSize& aMargin,
     const LogicalSize& aBorder, const LogicalSize& aPadding,
     ComputeSizeFlags aFlags) {
-  nsIntSize size = GetCanvasSize();
+  nsIntSize canvasSizeInPx = GetCanvasSize();
 
-  IntrinsicSize intrinsicSize;
-  intrinsicSize.width.SetCoordValue(
-      nsPresContext::CSSPixelsToAppUnits(size.width));
-  intrinsicSize.height.SetCoordValue(
-      nsPresContext::CSSPixelsToAppUnits(size.height));
-
-  nsSize intrinsicRatio = GetIntrinsicRatio();  // won't actually be used
+  IntrinsicSize intrinsicSize = IntrinsicSizeFromCanvasSize(canvasSizeInPx);
+  nsSize intrinsicRatio = IntrinsicRatioFromCanvasSize(canvasSizeInPx);
 
   return ComputeSizeWithIntrinsicDimensions(
       aRenderingContext, aWM, intrinsicSize, intrinsicRatio, aCBSize, aMargin,
       aBorder, aPadding, aFlags);
 }
 
 void nsHTMLCanvasFrame::Reflow(nsPresContext* aPresContext,
                                ReflowOutput& aMetrics,