Bug 1826006 - Fix middle-cropping with explicit inline sizes. r=jfkthame,layout-reviewers

If flexbox algorithm imposes a size on us, we want to look at that too,
not only at the available isize.

Differential Revision: https://phabricator.services.mozilla.com/D174445
This commit is contained in:
Emilio Cobos Álvarez 2023-04-03 11:05:38 +00:00
parent 78a197a2d1
commit f96bb05c6e
4 changed files with 73 additions and 3 deletions

View file

@ -164,10 +164,11 @@ void MiddleCroppingBlockFrame::Reflow(nsPresContext* aPresContext,
nscoord currentICoord = aReflowInput.mLineLayout
? aReflowInput.mLineLayout->GetCurrentICoord()
: 0;
nscoord availSize = aReflowInput.AvailableISize() - currentICoord;
if (LinesBegin()->ISize() > availSize) {
const nscoord availSize = aReflowInput.AvailableISize() - currentICoord;
const nscoord sizeToFit = std::min(aReflowInput.ComputedISize(), availSize);
if (LinesBegin()->ISize() > sizeToFit) {
// The value overflows - crop it and reflow again (once).
if (CropTextToWidth(*aReflowInput.mRenderingContext, availSize, value)) {
if (CropTextToWidth(*aReflowInput.mRenderingContext, sizeToFit, value)) {
nsBlockFrame::DidReflow(aPresContext, &aReflowInput);
aStatus.Reset();
MarkSubtreeDirty();

View file

@ -8,6 +8,7 @@ fuzzy-if(xulRuntime.widgetToolkit=="gtk",0-1,0-11) fuzzy-if(winWidget,0-1,0-1) =
skip-if(!cocoaWidget) == chrome://reftest/content/xul/mac-tab-toolbar.xhtml chrome://reftest/content/xul/mac-tab-toolbar-ref.xhtml
!= chrome://reftest/content/xul/tree-row-outline-1.xhtml chrome://reftest/content/xul/tree-row-outline-1-notref.xhtml
== chrome://reftest/content/xul/text-crop.xhtml chrome://reftest/content/xul/text-crop-ref.xhtml
== chrome://reftest/content/xul/text-crop-002.xhtml chrome://reftest/content/xul/text-crop-002-ref.xhtml
== chrome://reftest/content/xul/text-small-caps-1.xhtml chrome://reftest/content/xul/text-small-caps-1-ref.xhtml
fuzzy(0-1,0-2500) == chrome://reftest/content/xul/inactive-fixed-bg-bug1205630.xhtml inactive-fixed-bg-bug1205630-ref.html
fuzzy(0-1,0-2500) == chrome://reftest/content/xul/inactive-fixed-bg-bug1272525.xhtml inactive-fixed-bg-bug1272525-ref.html

View file

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<window
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<html:style type="text/css">
@font-face {
font-family: firasans;
src: url(../fonts/fira/FiraSans-Regular.otf);
}
hbox {
font-family: firasans;
font-size: 40px;
}
image {
background-color: purple;
}
label {
width: 230px;
color: green;
background-color: blue;
}
.with-padding {
padding-inline: 10px 50px;
}
</html:style>
<hbox style="width: 230px">
<image style="width: 40px; height: 40px"/>
<label value="abcd…xyz"/>
</hbox>
<hbox style="width: 230px">
<image style="width: 40px; height: 40px"/>
<label class="with-padding" value="abc…yz"/>
</hbox>
</window>

View file

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<window
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<html:style type="text/css">
@font-face {
font-family: firasans;
src: url(../fonts/fira/FiraSans-Regular.otf);
}
hbox {
font-family: firasans;
font-size: 40px;
}
image {
background-color: purple;
}
label {
width: 230px;
color: green;
background-color: blue;
}
.with-padding {
padding-inline: 10px 50px;
}
</html:style>
<hbox style="width: 230px">
<image style="width: 40px; height: 40px"/>
<label crop="center" value="abcdefghijklmnopqrstuvwxyz"/>
</hbox>
<hbox style="width: 230px">
<image style="width: 40px; height: 40px"/>
<label class="with-padding" crop="center" value="abcdefghijklmnopqrstuvwxyz"/>
</hbox>
</window>