From c8a55fd819a1c3e32e1696218ab2182762dd4c90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 15 Nov 2021 23:22:36 +0000 Subject: [PATCH] Bug 1740845 - Minor cleanups to text control layout. r=dholbert Differential Revision: https://phabricator.services.mozilla.com/D131147 --- layout/forms/nsTextControlFrame.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index 23bd0af0da5b..a2bb7d1d3595 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -743,8 +743,6 @@ void nsTextControlFrame::ReflowTextControlChild( kidReflowInput.Init(aPresContext, overrideCBSize, Nothing(), overridePadding); LogicalPoint position(wm); - const auto& bp = aReflowInput.ComputedLogicalBorderPadding(outerWM); - if (!isButtonBox) { MOZ_ASSERT(wm == outerWM, "Shouldn't have to care about orthogonal " @@ -752,10 +750,13 @@ void nsTextControlFrame::ReflowTextControlChild( "except for the number spin-box which forces " "horizontal-tb"); - // Offset the frame by the size of the parent's border - const auto& padding = aReflowInput.ComputedLogicalPadding(wm); - position.B(wm) = bp.BStart(wm) - padding.BStart(wm); - position.I(wm) = bp.IStart(wm) - padding.IStart(wm); + const auto& border = aReflowInput.ComputedLogicalBorder(wm); + + // Offset the frame by the size of the parent's border. Note that we don't + // have to account for the parent's padding here, because this child + // actually "inherits" that padding and manages it on behalf of the parent. + position.B(wm) = border.BStart(wm); + position.I(wm) = border.IStart(wm); // Set computed width and computed height for the child (the button box is // the only exception, which has an auto size). @@ -773,6 +774,7 @@ void nsTextControlFrame::ReflowTextControlChild( containerSize, ReflowChildFlags::Default, aStatus); if (isButtonBox) { + const auto& bp = aReflowInput.ComputedLogicalBorderPadding(outerWM); auto size = desiredSize.Size(outerWM); // Center button in the block axis of our content box. We do this // computation in terms of outerWM for simplicity.