commit 71317ff104b565767484a7b469b81c161a0c878c
parent bc69ef737f2549be242bc6d64e075b25a22517cc
Author: Emilio Cobos Álvarez <emilio@crisal.io>
Date: Sat, 29 Nov 2025 09:22:29 +0000
Bug 2002813 - Hide position-try-order from content. r=jwatt
We don't do anything with it so shouldn't claim to support it.
Differential Revision: https://phabricator.services.mozilla.com/D274395
Diffstat:
6 files changed, 97 insertions(+), 69 deletions(-)
diff --git a/layout/style/test/mochitest.toml b/layout/style/test/mochitest.toml
@@ -12,6 +12,7 @@ prefs = [
"layout.css.basic-shape-shape.enabled=true",
"layout.css.field-sizing.enabled=true",
"layout.css.anchor-positioning.enabled=true",
+ "layout.css.anchor-positioning.position-try-order.enabled=true",
"layout.css.scroll-state.enabled=true",
]
support-files = [
diff --git a/layout/style/test/property_database.js b/layout/style/test/property_database.js
@@ -13461,19 +13461,24 @@ if (IsCSSPropertyPrefEnabled("layout.css.anchor-positioning.enabled")) {
invalid_values: ["foo", "none none", "span-y-start self-block-end"],
};
- gCSSProperties["position-try-order"] = {
- domProp: "positionTryOrder",
- inherited: false,
- type: CSS_TYPE_LONGHAND,
- initial_values: ["normal"],
- other_values: [
- "most-width",
- "most-height",
- "most-block-size",
- "most-inline-size",
- ],
- invalid_values: ["auto", "none", "foo"],
- };
+ const tryOrderEnabled = IsCSSPropertyPrefEnabled(
+ "layout.css.anchor-positioning.position-try-order.enabled"
+ );
+ if (tryOrderEnabled) {
+ gCSSProperties["position-try-order"] = {
+ domProp: "positionTryOrder",
+ inherited: false,
+ type: CSS_TYPE_LONGHAND,
+ initial_values: ["normal"],
+ other_values: [
+ "most-width",
+ "most-height",
+ "most-block-size",
+ "most-inline-size",
+ ],
+ invalid_values: ["auto", "none", "foo"],
+ };
+ }
gCSSProperties["position-visibility"] = {
domProp: "positionVisibility",
@@ -13493,7 +13498,7 @@ if (IsCSSPropertyPrefEnabled("layout.css.anchor-positioning.enabled")) {
domProp: "positionTry",
inherited: false,
type: CSS_TYPE_TRUE_SHORTHAND,
- subproperties: ["position-try-order", "position-try-fallbacks"],
+ subproperties: ["position-try-fallbacks"],
initial_values: ["none"],
other_values: [
"--foo",
@@ -13508,54 +13513,6 @@ if (IsCSSPropertyPrefEnabled("layout.css.anchor-positioning.enabled")) {
"span-all self-block-end",
"end span-start",
"center span-all",
- "most-width --foo",
- "most-width flip-block",
- "most-width flip-inline",
- "most-width flip-x",
- "most-width flip-y",
- "most-width flip-start",
- "most-width left",
- "most-width span-y-start",
- "most-width span-block-start inline-end",
- "most-width span-all self-block-end",
- "most-width end span-start",
- "most-width center span-all",
- "most-height --foo",
- "most-height flip-block",
- "most-height flip-inline",
- "most-height flip-x",
- "most-height flip-y",
- "most-height flip-start",
- "most-height left",
- "most-height span-y-start",
- "most-height span-block-start inline-end",
- "most-height span-all self-block-end",
- "most-height end span-start",
- "most-height center span-all",
- "most-block-size --foo",
- "most-block-size flip-block",
- "most-block-size flip-inline",
- "most-block-size flip-x",
- "most-block-size flip-y",
- "most-block-size flip-start",
- "most-block-size left",
- "most-block-size span-y-start",
- "most-block-size span-block-start inline-end",
- "most-block-size span-all self-block-end",
- "most-block-size end span-start",
- "most-block-size center span-all",
- "most-inline-size --foo",
- "most-inline-size flip-block",
- "most-inline-size flip-inline",
- "most-inline-size flip-x",
- "most-inline-size flip-y",
- "most-inline-size flip-start",
- "most-inline-size left",
- "most-inline-size span-y-start",
- "most-inline-size span-block-start inline-end",
- "most-inline-size span-all self-block-end",
- "most-inline-size end span-start",
- "most-inline-size center span-all",
],
invalid_values: [
"foo",
@@ -13563,6 +13520,63 @@ if (IsCSSPropertyPrefEnabled("layout.css.anchor-positioning.enabled")) {
"--foo span-y-start self-block-end",
],
};
+ if (tryOrderEnabled) {
+ gCSSProperties["position-try"].subproperties.push("position-try-order");
+ }
+ const positionTryValuesWithOrder = [
+ "most-width --foo",
+ "most-width flip-block",
+ "most-width flip-inline",
+ "most-width flip-x",
+ "most-width flip-y",
+ "most-width flip-start",
+ "most-width left",
+ "most-width span-y-start",
+ "most-width span-block-start inline-end",
+ "most-width span-all self-block-end",
+ "most-width end span-start",
+ "most-width center span-all",
+ "most-height --foo",
+ "most-height flip-block",
+ "most-height flip-inline",
+ "most-height flip-x",
+ "most-height flip-y",
+ "most-height flip-start",
+ "most-height left",
+ "most-height span-y-start",
+ "most-height span-block-start inline-end",
+ "most-height span-all self-block-end",
+ "most-height end span-start",
+ "most-height center span-all",
+ "most-block-size --foo",
+ "most-block-size flip-block",
+ "most-block-size flip-inline",
+ "most-block-size flip-x",
+ "most-block-size flip-y",
+ "most-block-size flip-start",
+ "most-block-size left",
+ "most-block-size span-y-start",
+ "most-block-size span-block-start inline-end",
+ "most-block-size span-all self-block-end",
+ "most-block-size end span-start",
+ "most-block-size center span-all",
+ "most-inline-size --foo",
+ "most-inline-size flip-block",
+ "most-inline-size flip-inline",
+ "most-inline-size flip-x",
+ "most-inline-size flip-y",
+ "most-inline-size flip-start",
+ "most-inline-size left",
+ "most-inline-size span-y-start",
+ "most-inline-size span-block-start inline-end",
+ "most-inline-size span-all self-block-end",
+ "most-inline-size end span-start",
+ "most-inline-size center span-all",
+ ];
+ (tryOrderEnabled
+ ? gCSSProperties["position-try"].other_values
+ : gCSSProperties["position-try"].invalid_values
+ ).push(...positionTryValuesWithOrder);
}
if (IsCSSPropertyPrefEnabled("layout.css.scroll-state.enabled")) {
diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml
@@ -9897,6 +9897,13 @@
mirror: always
rust: true
+# Whether to enable position-try-order
+- name: layout.css.anchor-positioning.position-try-order.enabled
+ type: RelaxedAtomicBool
+ value: false
+ mirror: always
+ rust: true
+
# Whether to enable generalized CSS Attr Support. If this pref is set to false
# we treat attr as a regular function with support only for the `content` css
# property. If it is set to true, attr is parsed as a subtitution function.
diff --git a/servo/components/style/properties/longhands/position.mako.rs b/servo/components/style/properties/longhands/position.mako.rs
@@ -301,7 +301,7 @@ ${helpers.predefined_type(
engines="gecko",
initial_specified_value="specified::PositionTryOrder::normal()",
animation_type="discrete",
- gecko_pref="layout.css.anchor-positioning.enabled",
+ gecko_pref="layout.css.anchor-positioning.position-try-order.enabled",
spec="https://drafts.csswg.org/css-anchor-position-1/#position-try-order-property",
affects="layout",
)}
diff --git a/servo/components/style/properties/shorthands/position.mako.rs b/servo/components/style/properties/shorthands/position.mako.rs
@@ -858,19 +858,25 @@
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Longhands, ParseError<'i>> {
- let order = input.try_parse(|i| PositionTryOrder::parse(i)).unwrap_or(PositionTryOrder::normal());
+ let order = if static_prefs::pref!("layout.css.anchor-positioning.position-try-order.enabled") {
+ input.try_parse(PositionTryOrder::parse).ok()
+ } else {
+ None
+ };
let fallbacks = PositionTryFallbacks::parse(context, input)?;
Ok(expanded! {
- position_try_order: order,
+ position_try_order: order.unwrap_or(PositionTryOrder::normal()),
position_try_fallbacks: fallbacks,
})
}
impl<'a> ToCss for LonghandsToSerialize<'a> {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
- if *self.position_try_order != PositionTryOrder::Normal {
- self.position_try_order.to_css(dest)?;
- dest.write_char(' ')?;
+ if let Some(o) = self.position_try_order {
+ if *o != PositionTryOrder::Normal {
+ o.to_css(dest)?;
+ dest.write_char(' ')?;
+ }
}
self.position_try_fallbacks.to_css(dest)
}
diff --git a/testing/web-platform/meta/css/__dir__.ini b/testing/web-platform/meta/css/__dir__.ini
@@ -1 +1 @@
-prefs: [dom.customHighlightAPI.enabled:true,layout.css.basic-shape-shape.enabled:true,layout.css.style-queries.enabled:true,dom.hidden_until_found.enabled:true,dom.viewTransitions.enabled:true,gfx.font_rendering.fallback.async:false,layout.css.custom-media.enabled:true]
+prefs: [dom.customHighlightAPI.enabled:true,layout.css.basic-shape-shape.enabled:true,layout.css.style-queries.enabled:true,dom.hidden_until_found.enabled:true,dom.viewTransitions.enabled:true,gfx.font_rendering.fallback.async:false,layout.css.custom-media.enabled:true,layout.css.anchor-positioning.position-try-order.enabled:true]