зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1461046 Part 2: Change ShapeUtils::ComputeInsetRect to return the inverse of a rect deflated more than its bounds can tolerate. r=dholbert
MozReview-Commit-ID: IScKyqzjMoy --HG-- extra : rebase_source : 2057746c86b8ad86a1afd989111f83d6d9b8cafb
This commit is contained in:
Родитель
39839d2bd4
Коммит
cafe50be6c
|
@ -124,15 +124,29 @@ ShapeUtils::ComputeInsetRect(const UniquePtr<StyleBasicShape>& aBasicShape,
|
|||
const nsTArray<nsStyleCoord>& coords = aBasicShape->Coordinates();
|
||||
MOZ_ASSERT(coords.Length() == 4, "wrong number of arguments");
|
||||
|
||||
nsMargin inset(coords[0].ComputeCoordPercentCalc(aRefBox.height),
|
||||
coords[1].ComputeCoordPercentCalc(aRefBox.width),
|
||||
coords[2].ComputeCoordPercentCalc(aRefBox.height),
|
||||
coords[3].ComputeCoordPercentCalc(aRefBox.width));
|
||||
nsMargin inset(coords[0].ComputeCoordPercentCalc(aRefBox.Height()),
|
||||
coords[1].ComputeCoordPercentCalc(aRefBox.Width()),
|
||||
coords[2].ComputeCoordPercentCalc(aRefBox.Height()),
|
||||
coords[3].ComputeCoordPercentCalc(aRefBox.Width()));
|
||||
|
||||
nsRect insetRect(aRefBox);
|
||||
insetRect.Deflate(inset);
|
||||
nscoord x = aRefBox.X() + inset.left;
|
||||
nscoord width = aRefBox.Width() - inset.LeftRight();
|
||||
nscoord y = aRefBox.Y() + inset.top;
|
||||
nscoord height = aRefBox.Height() - inset.TopBottom();
|
||||
|
||||
return insetRect;
|
||||
// Invert left and right, if necessary.
|
||||
if (width < 0) {
|
||||
width *= -1;
|
||||
x -= width;
|
||||
}
|
||||
|
||||
// Invert top and bottom, if necessary.
|
||||
if (height < 0) {
|
||||
height *= -1;
|
||||
y -= height;
|
||||
}
|
||||
|
||||
return nsRect(x, y, width, height);
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
|
|
|
@ -57,7 +57,16 @@ struct ShapeUtils final
|
|||
const UniquePtr<StyleBasicShape>& aBasicShape,
|
||||
const nsPoint& aCenter, const nsRect& aRefBox);
|
||||
|
||||
// Compute the rect for an inset.
|
||||
// Compute the rect for an inset. If the inset amount is larger than
|
||||
// aRefBox itself, this will return a rect the same shape as the inverse
|
||||
// rect that would be created by insetting aRefBox by the inset amount.
|
||||
// This process is *not* what is called for by the current spec at
|
||||
// https://drafts.csswg.org/css-shapes-1/#supported-basic-shapes.
|
||||
// The spec currently treats empty shapes, including overly-inset rects, as
|
||||
// defining 'empty float areas' that don't affect layout. However, it is
|
||||
// practically useful to treat empty shapes as having edges for purposes of
|
||||
// affecting layout, and there is growing momentum for the approach we
|
||||
// are taking here.
|
||||
// @param aRefBox the reference box of the inset.
|
||||
// @return The inset rect in app units.
|
||||
static nsRect ComputeInsetRect(
|
||||
|
|
Загрузка…
Ссылка в новой задаче