Bug 1476127: Implement 'contain:size' for select elements. r=TYLin

Note that this is an imperfect implementation, in that it doesn't exactly
match the sizing behavior of a truly empty `<select>` element.  I've filed
followup bug 1562057 on that.  However, the behavior that's implemented
here *does* successfully make us ignore a `<select>`'s contents for sizing
purposes, and it's much better than what we do currently (which is pretty
broken via inheriting a partial `contain:size` implementation from our
parent class, nsBlockFrame).

Differential Revision: https://phabricator.services.mozilla.com/D36253

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Daniel Holbert 2019-06-28 20:32:13 +00:00
Родитель b5a2513e31
Коммит 2bfc73da09
3 изменённых файлов: 18 добавлений и 6 удалений

Просмотреть файл

@ -716,8 +716,9 @@ nscoord nsComboboxControlFrame::GetIntrinsicISize(
presContext, aRenderingContext, GetWritingMode());
}
const bool isContainSize = StyleDisplay()->IsContainSize();
nscoord displayISize = 0;
if (MOZ_LIKELY(mDisplayFrame)) {
if (MOZ_LIKELY(mDisplayFrame) && !isContainSize) {
displayISize = nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
mDisplayFrame, aType);
}
@ -727,13 +728,15 @@ nscoord nsComboboxControlFrame::GetIntrinsicISize(
bool isUsingOverlayScrollbars =
LookAndFeel::GetInt(LookAndFeel::eIntID_UseOverlayScrollbars) != 0;
if (aType == nsLayoutUtils::MIN_ISIZE) {
dropdownContentISize = mDropdownFrame->GetMinISize(aRenderingContext);
dropdownContentISize =
isContainSize ? 0 : mDropdownFrame->GetMinISize(aRenderingContext);
if (isUsingOverlayScrollbars) {
dropdownContentISize += scrollbarWidth;
}
} else {
NS_ASSERTION(aType == nsLayoutUtils::PREF_ISIZE, "Unexpected type");
dropdownContentISize = mDropdownFrame->GetPrefISize(aRenderingContext);
dropdownContentISize =
isContainSize ? 0 : mDropdownFrame->GetPrefISize(aRenderingContext);
if (isUsingOverlayScrollbars) {
dropdownContentISize += scrollbarWidth;
}

Просмотреть файл

@ -1861,11 +1861,20 @@ void nsBlockFrame::ComputeFinalSize(const ReflowInput& aReflowInput,
// Don't carry out a block-end margin when our BSize is fixed.
aMetrics.mCarriedOutBEndMargin.Zero();
} else if (aReflowInput.mStyleDisplay->IsContainSize()) {
} else if (!IsComboboxControlFrame() &&
aReflowInput.mStyleDisplay->IsContainSize()) {
// If we're size-containing and we don't have a specified size, then our
// final size should actually be computed from only our border and padding,
// as though we were empty.
// Hence this case is a simplified version of the case below.
//
// NOTE: We exempt the nsComboboxControlFrame subclass from taking this
// special case, because comboboxes implicitly honors the size-containment
// behavior on its nsComboboxDisplayFrame child (which it shrinkwraps)
// rather than on the nsComboboxControlFrame. (Moreover, the DisplayFrame
// child doesn't even need any special content-size-ignoring behavior in
// its reflow method, because that method just resolves "auto" BSize values
// to one line-height rather than by measuring its contents' BSize.)
nscoord contentBSize = 0;
nscoord autoBSize = aReflowInput.ApplyMinMaxBSize(contentBSize);
aMetrics.mCarriedOutBEndMargin.Zero();

Просмотреть файл

@ -35,8 +35,8 @@ fuzzy-if(webrender&&winWidget,0-24,0-2) == contain-size-inline-flex-001.html con
== contain-size-fieldset-002.html contain-size-fieldset-002-ref.html
== contain-size-multicol-002.html contain-size-multicol-002-ref.html
== contain-size-multicol-003.html contain-size-multicol-003-ref.html
fails == contain-size-select-elem-001.html contain-size-select-elem-001-ref.html # bug 1476127
fails == contain-size-select-elem-002.html contain-size-select-elem-002-ref.html # bug 1476127
fuzzy-if(Android,0-4,0-4) == contain-size-select-elem-001.html contain-size-select-elem-001-ref.html # bug 1480862
fails-if(!gtkWidget) == contain-size-select-elem-002.html contain-size-select-elem-002-ref.html # bug 1562057
== contain-layout-overflow-001.html contain-layout-overflow-001-ref.html
== contain-layout-overflow-002.html contain-layout-overflow-002-ref.html
== contain-size-table-caption-001.html contain-size-table-caption-001-ref.html