mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-15 08:53:07 +09:00
Issue #1970 - Part 7: Restore proper spacing in select for CJK/asian
The issue is that select elements may contain some non-Latin characters that need extra block-size to display than the one line-height calculated by using a Latin font spec in the style. Before this patch, when a control has an unconstrained block-size, we set the element's block-size to one line-height in Reflow(), which is intended to properly initialize `BlockReflowInput::mMinLineHeight` since it uses `line-height:-moz-block-height`. However, this simply prevents the display from choosing a larger block-size after the reflow occurs. Previously, this discrepancy was absorbed by the extra padding present to make select elements the same intrinsic size as buttons, but since we did away with that, we're losing the extra space and the font glyphs get clipped. This patch fixes the issue by carrying the computed line height over to the element's display so that its computed block-size is still unconstrained. This way it can accommodate taller characters in the display text. After this patch, a <select><option> containing non-Latin characters should have the same block-size as <button>, and no characters should be clipped.
This commit is contained in:
parent
7203916733
commit
b18a680d4f
4 changed files with 53 additions and 1 deletions
|
|
@ -1322,7 +1322,8 @@ nsComboboxDisplayFrame::Reflow(nsPresContext* aPresContext,
|
|||
// Note that the only way we can have a computed block size here is
|
||||
// if the combobox had a specified block size. If it didn't, size
|
||||
// based on what our rows look like, for lack of anything better.
|
||||
state.SetComputedBSize(mComboBox->mListControlFrame->GetBSizeOfARow());
|
||||
//state.SetComputedBSize(mComboBox->mListControlFrame->GetBSizeOfARow());
|
||||
state.SetLineHeight(state.mParentReflowInput->GetLineHeight());
|
||||
}
|
||||
WritingMode wm = aReflowInput.GetWritingMode();
|
||||
nscoord computedISize = mComboBox->mDisplayISize -
|
||||
|
|
|
|||
35
layout/forms/test/test_issue1970_manual.html
Normal file
35
layout/forms/test/test_issue1970_manual.html
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<style>
|
||||
.fontA {
|
||||
font-family: "Noto Sans";
|
||||
}
|
||||
.fontB {
|
||||
font-family: "Noto Sans CJK TC";
|
||||
}
|
||||
.fontC {
|
||||
font-family: "WenQuanYi Zen Hei";
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p>No clipping of the font glyphs should occur.</p>
|
||||
<select>
|
||||
<option>Latin Text jpg</option>
|
||||
</select>
|
||||
<select>
|
||||
<option>漢字 jpg</option>
|
||||
</select>
|
||||
<select class="fontA">
|
||||
<option>漢字 jpg</option>
|
||||
</select>
|
||||
<select class="fontB">
|
||||
<option>漢字 jpg</option>
|
||||
</select>
|
||||
<select class="fontC">
|
||||
<option>漢字 jpg</option>
|
||||
</select>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -2817,6 +2817,17 @@ nscoord ReflowInput::GetLineHeight() const {
|
|||
nsLayoutUtils::FontSizeInflationFor(mFrame));
|
||||
}
|
||||
|
||||
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->GetType());
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ nscoord
|
||||
ReflowInput::CalcLineHeight(nsIContent* aContent,
|
||||
nsStyleContext* aStyleContext,
|
||||
|
|
|
|||
|
|
@ -747,6 +747,11 @@ public:
|
|||
* Get the used line-height property. The return value will be >= 0.
|
||||
*/
|
||||
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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue