From 8b74ff00e0e43e4f1435ecae1f044d1092b12cff Mon Sep 17 00:00:00 2001 From: Ting-Yu Lin Date: Wed, 28 Jul 2021 18:41:19 +0000 Subject: [PATCH] Bug 1716212 Part 2 - Carry nsComboboxControlFrame's line-height to nsComboboxDisplayFrame when it has auto block-size. r=emilio The issue is that combobox display may contain some non-Latin characters that need extra block-size to display than the one line-height calculate by using a Latin font spec in combobox control's style. Before this patch, when a combobox control has unconstrained block-size, we set combobox display's block-size to combobox control's one line-height in Reflow(), which is intended to properly initialize `BlockReflowInput::mMinLineHeight` since combobox display has `line-height:-moz-block-height`. However, this simply prevents the combobox display from choosing a larger block-size after the reflow. See bug 1716212 comment 11 for an analysis. This patch fixes the issue by carrying combox control's computed line height to combobox display so that its computed block-size is still unconstrained so that it can accommodate taller characters in the display text. After this patch, + + + +
+
+ + +
+ diff --git a/layout/generic/ReflowInput.cpp b/layout/generic/ReflowInput.cpp index a41027c61d69..0ddf27f40da1 100644 --- a/layout/generic/ReflowInput.cpp +++ b/layout/generic/ReflowInput.cpp @@ -2721,6 +2721,17 @@ nscoord ReflowInput::GetLineHeight() const { return mLineHeight; } +void ReflowInput::SetLineHeight(nscoord aLineHeight) { + MOZ_ASSERT(aLineHeight >= 0, "aLineHeight must be >= 0!"); + + if (mLineHeight != aLineHeight) { + mLineHeight = aLineHeight; + // Setting used line height can change a frame's block-size if mFrame's + // block-size behaves as auto. + InitResizeFlags(mFrame->PresContext(), mFrame->Type()); + } +} + /* static */ nscoord ReflowInput::CalcLineHeight(nsIContent* aContent, ComputedStyle* aComputedStyle, diff --git a/layout/generic/ReflowInput.h b/layout/generic/ReflowInput.h index 7fa705000e12..7b32eb220aca 100644 --- a/layout/generic/ReflowInput.h +++ b/layout/generic/ReflowInput.h @@ -697,6 +697,11 @@ struct ReflowInput : public SizeComputationInput { */ nscoord GetLineHeight() const; + /** + * Set the used line-height. aLineHeight must be >= 0. + */ + void SetLineHeight(nscoord aLineHeight); + /** * Calculate the used line-height property without a reflow input instance. * The return value will be >= 0.