зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1825709 - Account for min/max bsize in nsTextControlFrame::ComputeBaseline. r=dshin
This isn't needed for nsTextControlFrame because its ComputeAutoSize implementation doesn't return an unconstrained line-height for inputs, so we never end up in the UNCONSTRAINEDSIZE case, but it's needed for date/time inputs. Use GetLineHeight while at it, since it's the inflated line-height which is what we want, and may be cached so we can avoid computing it. Maybe in the future we can make date/time inputs just use nsTextControlFrame, which would prevent this from happening in the future. Depends on D175745 Differential Revision: https://phabricator.services.mozilla.com/D175746
This commit is contained in:
Родитель
908c61fcf4
Коммит
6b96db2587
|
@ -186,7 +186,6 @@ void nsDateTimeControlFrame::Reflow(nsPresContext* aPresContext,
|
|||
|
||||
LogicalSize logicalDesiredSize(myWM, borderBoxISize, borderBoxBSize);
|
||||
aDesiredSize.SetSize(myWM, logicalDesiredSize);
|
||||
|
||||
aDesiredSize.SetOverflowAreasToDesiredBounds();
|
||||
|
||||
if (inputAreaFrame) {
|
||||
|
|
|
@ -631,16 +631,14 @@ Maybe<nscoord> nsTextControlFrame::ComputeBaseline(
|
|||
}
|
||||
WritingMode wm = aReflowInput.GetWritingMode();
|
||||
|
||||
// Calculate the baseline and store it in mFirstBaseline.
|
||||
nscoord lineHeight = aReflowInput.ComputedBSize();
|
||||
float inflation = nsLayoutUtils::FontSizeInflationFor(aFrame);
|
||||
if (!aForSingleLineControl || lineHeight == NS_UNCONSTRAINEDSIZE) {
|
||||
lineHeight = ReflowInput::CalcLineHeight(
|
||||
*aFrame->Style(), aFrame->PresContext(), aFrame->GetContent(),
|
||||
NS_UNCONSTRAINEDSIZE, inflation);
|
||||
lineHeight = NS_CSS_MINMAX(aReflowInput.GetLineHeight(),
|
||||
aReflowInput.ComputedMinBSize(),
|
||||
aReflowInput.ComputedMaxBSize());
|
||||
}
|
||||
RefPtr<nsFontMetrics> fontMet =
|
||||
nsLayoutUtils::GetFontMetricsForFrame(aFrame, inflation);
|
||||
nsLayoutUtils::GetInflatedFontMetricsForFrame(aFrame);
|
||||
return Some(nsLayoutUtils::GetCenteredFontBaseline(fontMet, lineHeight,
|
||||
wm.IsLineInverted()) +
|
||||
aReflowInput.ComputedLogicalBorderPadding(wm).BStart(wm));
|
||||
|
@ -667,6 +665,7 @@ void nsTextControlFrame::Reflow(nsPresContext* aPresContext,
|
|||
aDesiredSize.SetSize(wm, aReflowInput.ComputedSizeWithBorderPadding(wm));
|
||||
|
||||
{
|
||||
// Calculate the baseline and store it in mFirstBaseline.
|
||||
auto baseline =
|
||||
ComputeBaseline(this, aReflowInput, IsSingleLineTextControl());
|
||||
mFirstBaseline = baseline.valueOr(NS_INTRINSIC_ISIZE_UNKNOWN);
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<title>CSS Test Reference</title>
|
||||
<div>
|
||||
abc <input type=date style="height: 40px"> def
|
||||
</div>
|
|
@ -0,0 +1,10 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<title>date input baseline should account for min-height</title>
|
||||
<link rel="match" href="input-date-baseline-min-height-ref.html">
|
||||
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1825709">
|
||||
<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
|
||||
<link rel="author" title="Mozilla" href="https://mozilla.org">
|
||||
<div>
|
||||
abc <input type=date style="min-height: 40px"> def
|
||||
</div>
|
Загрузка…
Ссылка в новой задаче