Skip to content

Commit

Permalink
Bug 1846817 - Change the initial value of offset-position to be norma…
Browse files Browse the repository at this point in the history
…l. r=dholbert

Per spec issue, w3c/fxtf-drafts#522, its
initial value should be normal. (This has been merged into the spec.)

Note: css/motion/inheritance.html was updated in the WPT remote repo, so
I intentionally didn't change it and added the expection for now.

Differential Revision: https://phabricator.services.mozilla.com/D185230
  • Loading branch information
BorisChiou committed Aug 3, 2023
1 parent 7bf9104 commit 7902a61
Show file tree
Hide file tree
Showing 28 changed files with 34 additions and 11 deletions.
2 changes: 1 addition & 1 deletion layout/style/nsStyleStruct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2184,7 +2184,7 @@ nsStyleDisplay::nsStyleDisplay()
mOffsetDistance(LengthPercentage::Zero()),
mOffsetRotate{true, StyleAngle{0.0}},
mOffsetAnchor(StylePositionOrAuto::Auto()),
mOffsetPosition(StyleOffsetPosition::Auto()),
mOffsetPosition(StyleOffsetPosition::Normal()),
mTransformOrigin{LengthPercentage::FromPercentage(0.5),
LengthPercentage::FromPercentage(0.5),
{0.}},
Expand Down
4 changes: 2 additions & 2 deletions layout/style/test/property_database.js
Original file line number Diff line number Diff line change
Expand Up @@ -13612,9 +13612,9 @@ if (
domProp: "offsetPosition",
inherited: false,
type: CSS_TYPE_LONGHAND,
initial_values: ["auto"],
initial_values: ["normal"],
other_values: [
"normal",
"auto",
"left bottom",
"center center",
"calc(20% + 10px) center",
Expand Down
1 change: 1 addition & 0 deletions layout/style/test/test_animations_omta.html
Original file line number Diff line number Diff line change
Expand Up @@ -2728,6 +2728,7 @@
addAsyncAnimTest(async function() {
new_div("offset-path: ray(90deg); " +
"offset-distance: 0%; " +
"offset-position: auto; " +
"transition: offset-path 10s linear");
await waitForPaintsFlushed();

Expand Down
2 changes: 1 addition & 1 deletion servo/components/style/properties/longhands/box.mako.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ ${helpers.predefined_type(
${helpers.predefined_type(
"offset-position",
"OffsetPosition",
"computed::OffsetPosition::auto()",
"computed::OffsetPosition::normal()",
engines="gecko",
animation_value_type="ComputedValue",
gecko_pref="layout.css.motion-path-offset-position.enabled",
Expand Down
4 changes: 2 additions & 2 deletions servo/components/style/properties/shorthands/box.mako.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ ${helpers.two_properties_shorthand(
}).ok();

Ok(expanded! {
offset_position: offset_position.unwrap_or(OffsetPosition::auto()),
offset_position: offset_position.unwrap_or(OffsetPosition::normal()),
offset_path: offset_path.unwrap_or(OffsetPath::none()),
offset_distance: offset_distance.unwrap_or(LengthPercentage::zero()),
offset_rotate: offset_rotate.unwrap_or(OffsetRotate::auto()),
Expand All @@ -218,7 +218,7 @@ ${helpers.two_properties_shorthand(
// offset-path group means "offset-path offset-distance offset-rotate".
let must_serialize_path = *self.offset_path != OffsetPath::None
|| (!self.offset_distance.is_zero() || !self.offset_rotate.is_auto());
let position_is_default = matches!(offset_position, OffsetPosition::Auto);
let position_is_default = matches!(offset_position, OffsetPosition::Normal);
if !position_is_default || !must_serialize_path {
offset_position.to_css(dest)?;
}
Expand Down
6 changes: 3 additions & 3 deletions servo/components/style/values/generics/motion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ pub enum GenericOffsetPosition<H, V> {
pub use self::GenericOffsetPosition as OffsetPosition;

impl<H, V> OffsetPosition<H, V> {
/// Returns the initial value, auto.
/// Returns the initial value, normal.
#[inline]
pub fn auto() -> Self {
Self::Auto
pub fn normal() -> Self {
Self::Normal
}
}
3 changes: 3 additions & 0 deletions testing/web-platform/meta/css/motion/inheritance.html.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[inheritance.html]
[Property offset-position has initial value auto]
expected: FAIL
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
transform-origin: 0px 0px;
offset-path: ray(135deg closest-side);
offset-distance: 20px;
offset-position: auto;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
transform-origin: 0px 0px;
offset-path: ray(135deg closest-side);
offset-distance: 20%;
offset-position: auto;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
transform-origin: 0px 0px;
offset-path: ray(135deg closest-side);
offset-distance: 100%;
offset-position: auto;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
transform-origin: 0px 0px;
offset-path: ray(135deg farthest-side);
offset-distance: 100%;
offset-position: auto;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
transform-origin: 0px 0px;
offset-path: ray(135deg closest-corner);
offset-distance: 100%;
offset-position: auto;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
transform-origin: 0px 0px;
offset-path: ray(135deg farthest-corner);
offset-distance: 100%;
offset-position: auto;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
transform-origin: 0px 0px;
offset-path: ray(180deg sides);
offset-distance: 100%;
offset-position: auto;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
background-color: lime;
offset-path: ray(-90deg sides);
offset-distance: 100%;
offset-position: auto;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
background-color: lime;
offset-path: ray(180deg closest-side);
offset-distance: 100%;
offset-position: auto;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
transform-origin: 0px 0px;
offset-path: ray(135deg);
offset-distance: 20px;
offset-position: auto;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
offset-path: ray(180deg closest-corner contain);
offset-rotate: 0deg;
offset-distance: 100%;
offset-position: auto;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
offset-path: ray(180deg closest-side contain);
offset-rotate: 0deg;
offset-distance: 100%;
offset-position: auto;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
offset-path: ray(45deg closest-side contain);
offset-rotate: 0deg;
offset-distance: 100%;
offset-position: auto;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
offset-path: ray(45deg closest-side contain);
offset-rotate: auto;
offset-distance: 100%;
offset-position: auto;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
offset-anchor: 200% -300%;
offset-rotate: -90deg;
offset-distance: 50%;
offset-position: auto;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
background-color: green;
position: relative;
offset-path: circle();
offset-position: auto;
width: 100px;
height: 100px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
background-color: green;
position: relative;
offset-path: ellipse();
offset-position: auto;
width: 100px;
height: 100px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
transform-origin: 0px 0px;
offset-path: ray(120deg closest-corner);
offset-rotate: auto;
offset-position: auto;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
transform-origin: 0px 0px;
offset-path: ray(-120deg closest-corner);
offset-rotate: reverse 60deg;
offset-position: auto;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<script>
test_valid_value("offset", "100px none auto 90deg", "100px center none auto 90deg");
test_valid_value("offset", "100px", "100px center");
test_valid_value("offset", "auto none reverse", "none reverse");
test_valid_value("offset", "normal none reverse", "none reverse");
test_valid_value("offset", "auto");
test_valid_value("offset", "center bottom path(\"M 1 2 V 3 Z\")");
test_valid_value("offset", "center center path(\"M 0 0 L 100 100 M 100 200 L 200 200 Z L 300 300 Z\") 100% 90deg / left bottom");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
});

test_shorthand_value('offset', 'path("M 0 0 H 2") reverse 50%', {
'offset-position': 'auto',
'offset-position': 'normal',
'offset-path': 'path("M 0 0 H 2")',
'offset-distance': '50%',
'offset-rotate': 'reverse',
Expand Down

0 comments on commit 7902a61

Please sign in to comment.