Issue #1838 - Part 2: Remove grid- prefix from grid-(column|row)-gap properties

This removes the `grid` prefix from the gap-related properties of grid since they are now part of the box alignment specification. Former grid-gap* properties were aliased to the unprefixed properties to maintain compatibility.

The previously multi-column layout only `column-gap` property has been modified to apply to the Grid layout (and Flexbox in a following commit), moving the `mColumnGap` member variable from `nsStyleColumn` to `nsStylePosition`.

Notes:
* Bug 1398537 - support for percent values in column-gap for multi-column layout landed as part of Issue #1230. However, it was incomplete because it did not update `nsRuleNode` to allow transformation of percentage values for `column-gap`. This was consequently fixed as part of this commit.
* Bug 1456166 - this might not apply because we don't have that devtools test in UXP
* `nsRuleNode`, `nsCSSParser`, `Declaration`, and other related classes were merged into Stylo. These should be taken into consideration when porting patches from Mozilla.

Partially based on https://bugzilla.mozilla.org/show_bug.cgi?id=1398482
This commit is contained in:
FranklinDM 2022-04-02 13:46:07 +08:00 committed by roytam1
commit b4f2c83687
13 changed files with 103 additions and 121 deletions

View file

@ -183,15 +183,15 @@ nsColumnSetFrame::GetAvailableContentBSize(const ReflowInput& aReflowInput)
static nscoord
GetColumnGap(nsColumnSetFrame* aFrame,
const nsStyleColumn* aColStyle,
nscoord aPercentageBasis)
{
const auto& columnGap = aColStyle->mColumnGap;
if (columnGap.GetUnit() == eStyleUnit_Normal) {
const nsStylePosition* positionData = aFrame->StylePosition();
if (positionData->mColumnGap.GetUnit() == eStyleUnit_Normal) {
return aFrame->StyleFont()->mFont.size;
}
return nsLayoutUtils::ResolveGapToLength(columnGap, aPercentageBasis);
return nsLayoutUtils::ResolveGapToLength(positionData->mColumnGap,
aPercentageBasis);
}
nsColumnSetFrame::ReflowConfig
@ -224,7 +224,7 @@ nsColumnSetFrame::ChooseColumnStrategy(const ReflowInput& aReflowInput,
colBSize = std::min(colBSize, aReflowInput.ComputedMaxBSize());
}
nscoord colGap = GetColumnGap(this, colStyle, aReflowInput.ComputedISize());
nscoord colGap = GetColumnGap(this, aReflowInput.ComputedISize());
int32_t numColumns = colStyle->mColumnCount;
// If column-fill is set to 'balance', then we want to balance the columns.
@ -400,7 +400,7 @@ nsColumnSetFrame::GetMinISize(nsRenderingContext *aRenderingContext)
// include n-1 column gaps.
colISize = iSize;
iSize *= colStyle->mColumnCount;
nscoord colGap = GetColumnGap(this, colStyle, NS_UNCONSTRAINEDSIZE);
nscoord colGap = GetColumnGap(this, NS_UNCONSTRAINEDSIZE);
iSize += colGap * (colStyle->mColumnCount - 1);
// The multiplication above can make 'width' negative (integer overflow),
// so use std::max to protect against that.
@ -421,7 +421,7 @@ nsColumnSetFrame::GetPrefISize(nsRenderingContext *aRenderingContext)
nscoord result = 0;
DISPLAY_PREF_WIDTH(this, result);
const nsStyleColumn* colStyle = StyleColumn();
nscoord colGap = GetColumnGap(this, colStyle, NS_UNCONSTRAINEDSIZE);
nscoord colGap = GetColumnGap(this, NS_UNCONSTRAINEDSIZE);
nscoord colISize;
if (colStyle->mColumnWidth.GetUnit() == eStyleUnit_Coord) {