Bug 1330962 part 1 - Add baseline methods to nsTextControlFrame. r=dholbert

This commit is contained in:
Mats Palmgren
2017-01-28 02:34:13 +01:00
parent 147b757592
commit 1c65043efe
2 changed files with 41 additions and 5 deletions

View File

@@ -105,6 +105,7 @@ private:
nsTextControlFrame::nsTextControlFrame(nsStyleContext* aContext)
: nsContainerFrame(aContext)
, mFirstBaseline(NS_INTRINSIC_WIDTH_UNKNOWN)
, mEditorHasBeenInitialized(false)
, mIsProcessing(false)
, mUsePlaceholder(false)
@@ -533,20 +534,20 @@ nsTextControlFrame::Reflow(nsPresContext* aPresContext,
aReflowInput.ComputedLogicalBorderPadding().BStartEnd(wm));
aDesiredSize.SetSize(wm, finalSize);
// computation of the ascent wrt the input height
// Calculate the baseline and store it in mFirstBaseline.
nscoord lineHeight = aReflowInput.ComputedBSize();
float inflation = nsLayoutUtils::FontSizeInflationFor(this);
if (!IsSingleLineTextControl()) {
lineHeight = ReflowInput::CalcLineHeight(GetContent(), StyleContext(),
NS_AUTOHEIGHT, inflation);
NS_AUTOHEIGHT, inflation);
}
RefPtr<nsFontMetrics> fontMet =
nsLayoutUtils::GetFontMetricsForFrame(this, inflation);
// now adjust for our borders and padding
aDesiredSize.SetBlockStartAscent(
mFirstBaseline =
nsLayoutUtils::GetCenteredFontBaseline(fontMet, lineHeight,
wm.IsLineInverted()) +
aReflowInput.ComputedLogicalBorderPadding().BStart(wm));
aReflowInput.ComputedLogicalBorderPadding().BStart(wm);
aDesiredSize.SetBlockStartAscent(mFirstBaseline);
// overflow handling
aDesiredSize.SetOverflowAreasToDesiredBounds();