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

@ -8877,25 +8877,27 @@ nsRuleNode::ComputePositionData(void* aStartStruct,
parentPos->mGridRowEnd,
conditions);
// grid-column-gap
if (SetCoord(*aRuleData->ValueForGridColumnGap(),
pos->mGridColumnGap, parentPos->mGridColumnGap,
SETCOORD_LPH | SETCOORD_INITIAL_ZERO | SETCOORD_STORE_CALC |
SETCOORD_CALC_CLAMP_NONNEGATIVE | SETCOORD_UNSET_INITIAL,
// column-gap: normal, length, percent, calc, inherit, initial
if (SetCoord(*aRuleData->ValueForColumnGap(),
pos->mColumnGap, parentPos->mColumnGap,
SETCOORD_LPH | SETCOORD_NORMAL | SETCOORD_INITIAL_NORMAL |
SETCOORD_STORE_CALC | SETCOORD_CALC_CLAMP_NONNEGATIVE |
SETCOORD_UNSET_INITIAL,
aContext, mPresContext, conditions)) {
} else {
MOZ_ASSERT(aRuleData->ValueForGridColumnGap()->GetUnit() == eCSSUnit_Null,
MOZ_ASSERT(aRuleData->ValueForColumnGap()->GetUnit() == eCSSUnit_Null,
"unexpected unit");
}
// grid-row-gap
if (SetCoord(*aRuleData->ValueForGridRowGap(),
pos->mGridRowGap, parentPos->mGridRowGap,
SETCOORD_LPH | SETCOORD_INITIAL_ZERO | SETCOORD_STORE_CALC |
SETCOORD_CALC_CLAMP_NONNEGATIVE | SETCOORD_UNSET_INITIAL,
// row-gap: normal, length, percent, calc, inherit, initial
if (SetCoord(*aRuleData->ValueForRowGap(),
pos->mRowGap, parentPos->mRowGap,
SETCOORD_LPH | SETCOORD_NORMAL | SETCOORD_INITIAL_NORMAL |
SETCOORD_STORE_CALC | SETCOORD_CALC_CLAMP_NONNEGATIVE |
SETCOORD_UNSET_INITIAL,
aContext, mPresContext, conditions)) {
} else {
MOZ_ASSERT(aRuleData->ValueForGridRowGap()->GetUnit() == eCSSUnit_Null,
MOZ_ASSERT(aRuleData->ValueForRowGap()->GetUnit() == eCSSUnit_Null,
"unexpected unit");
}
@ -9302,18 +9304,6 @@ nsRuleNode::ComputeColumnData(void* aStartStruct,
SETCOORD_UNSET_INITIAL,
aContext, mPresContext, conditions);
// column-gap: length, inherit, normal
SetCoord(*aRuleData->ValueForColumnGap(),
column->mColumnGap, parent->mColumnGap,
SETCOORD_LH | SETCOORD_NORMAL | SETCOORD_INITIAL_NORMAL |
SETCOORD_CALC_LENGTH_ONLY | SETCOORD_UNSET_INITIAL,
aContext, mPresContext, conditions);
// clamp negative calc() to 0
if (column->mColumnGap.GetUnit() == eStyleUnit_Coord) {
column->mColumnGap.SetCoordValue(
std::max(column->mColumnGap.GetCoordValue(), 0));
}
// column-count: auto, integer, inherit
const nsCSSValue* columnCountValue = aRuleData->ValueForColumnCount();
if (eCSSUnit_Auto == columnCountValue->GetUnit() ||