Skip to content

Commit 71317ff

Browse files
committed
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
1 parent bc69ef7 commit 71317ff

File tree

6 files changed

+97
-69
lines changed

6 files changed

+97
-69
lines changed

layout/style/test/mochitest.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ prefs = [
1212
"layout.css.basic-shape-shape.enabled=true",
1313
"layout.css.field-sizing.enabled=true",
1414
"layout.css.anchor-positioning.enabled=true",
15+
"layout.css.anchor-positioning.position-try-order.enabled=true",
1516
"layout.css.scroll-state.enabled=true",
1617
]
1718
support-files = [

layout/style/test/property_database.js

Lines changed: 76 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -13461,19 +13461,24 @@ if (IsCSSPropertyPrefEnabled("layout.css.anchor-positioning.enabled")) {
1346113461
invalid_values: ["foo", "none none", "span-y-start self-block-end"],
1346213462
};
1346313463

13464-
gCSSProperties["position-try-order"] = {
13465-
domProp: "positionTryOrder",
13466-
inherited: false,
13467-
type: CSS_TYPE_LONGHAND,
13468-
initial_values: ["normal"],
13469-
other_values: [
13470-
"most-width",
13471-
"most-height",
13472-
"most-block-size",
13473-
"most-inline-size",
13474-
],
13475-
invalid_values: ["auto", "none", "foo"],
13476-
};
13464+
const tryOrderEnabled = IsCSSPropertyPrefEnabled(
13465+
"layout.css.anchor-positioning.position-try-order.enabled"
13466+
);
13467+
if (tryOrderEnabled) {
13468+
gCSSProperties["position-try-order"] = {
13469+
domProp: "positionTryOrder",
13470+
inherited: false,
13471+
type: CSS_TYPE_LONGHAND,
13472+
initial_values: ["normal"],
13473+
other_values: [
13474+
"most-width",
13475+
"most-height",
13476+
"most-block-size",
13477+
"most-inline-size",
13478+
],
13479+
invalid_values: ["auto", "none", "foo"],
13480+
};
13481+
}
1347713482

1347813483
gCSSProperties["position-visibility"] = {
1347913484
domProp: "positionVisibility",
@@ -13493,7 +13498,7 @@ if (IsCSSPropertyPrefEnabled("layout.css.anchor-positioning.enabled")) {
1349313498
domProp: "positionTry",
1349413499
inherited: false,
1349513500
type: CSS_TYPE_TRUE_SHORTHAND,
13496-
subproperties: ["position-try-order", "position-try-fallbacks"],
13501+
subproperties: ["position-try-fallbacks"],
1349713502
initial_values: ["none"],
1349813503
other_values: [
1349913504
"--foo",
@@ -13508,61 +13513,70 @@ if (IsCSSPropertyPrefEnabled("layout.css.anchor-positioning.enabled")) {
1350813513
"span-all self-block-end",
1350913514
"end span-start",
1351013515
"center span-all",
13511-
"most-width --foo",
13512-
"most-width flip-block",
13513-
"most-width flip-inline",
13514-
"most-width flip-x",
13515-
"most-width flip-y",
13516-
"most-width flip-start",
13517-
"most-width left",
13518-
"most-width span-y-start",
13519-
"most-width span-block-start inline-end",
13520-
"most-width span-all self-block-end",
13521-
"most-width end span-start",
13522-
"most-width center span-all",
13523-
"most-height --foo",
13524-
"most-height flip-block",
13525-
"most-height flip-inline",
13526-
"most-height flip-x",
13527-
"most-height flip-y",
13528-
"most-height flip-start",
13529-
"most-height left",
13530-
"most-height span-y-start",
13531-
"most-height span-block-start inline-end",
13532-
"most-height span-all self-block-end",
13533-
"most-height end span-start",
13534-
"most-height center span-all",
13535-
"most-block-size --foo",
13536-
"most-block-size flip-block",
13537-
"most-block-size flip-inline",
13538-
"most-block-size flip-x",
13539-
"most-block-size flip-y",
13540-
"most-block-size flip-start",
13541-
"most-block-size left",
13542-
"most-block-size span-y-start",
13543-
"most-block-size span-block-start inline-end",
13544-
"most-block-size span-all self-block-end",
13545-
"most-block-size end span-start",
13546-
"most-block-size center span-all",
13547-
"most-inline-size --foo",
13548-
"most-inline-size flip-block",
13549-
"most-inline-size flip-inline",
13550-
"most-inline-size flip-x",
13551-
"most-inline-size flip-y",
13552-
"most-inline-size flip-start",
13553-
"most-inline-size left",
13554-
"most-inline-size span-y-start",
13555-
"most-inline-size span-block-start inline-end",
13556-
"most-inline-size span-all self-block-end",
13557-
"most-inline-size end span-start",
13558-
"most-inline-size center span-all",
1355913516
],
1356013517
invalid_values: [
1356113518
"foo",
1356213519
"--foo none none",
1356313520
"--foo span-y-start self-block-end",
1356413521
],
1356513522
};
13523+
if (tryOrderEnabled) {
13524+
gCSSProperties["position-try"].subproperties.push("position-try-order");
13525+
}
13526+
const positionTryValuesWithOrder = [
13527+
"most-width --foo",
13528+
"most-width flip-block",
13529+
"most-width flip-inline",
13530+
"most-width flip-x",
13531+
"most-width flip-y",
13532+
"most-width flip-start",
13533+
"most-width left",
13534+
"most-width span-y-start",
13535+
"most-width span-block-start inline-end",
13536+
"most-width span-all self-block-end",
13537+
"most-width end span-start",
13538+
"most-width center span-all",
13539+
"most-height --foo",
13540+
"most-height flip-block",
13541+
"most-height flip-inline",
13542+
"most-height flip-x",
13543+
"most-height flip-y",
13544+
"most-height flip-start",
13545+
"most-height left",
13546+
"most-height span-y-start",
13547+
"most-height span-block-start inline-end",
13548+
"most-height span-all self-block-end",
13549+
"most-height end span-start",
13550+
"most-height center span-all",
13551+
"most-block-size --foo",
13552+
"most-block-size flip-block",
13553+
"most-block-size flip-inline",
13554+
"most-block-size flip-x",
13555+
"most-block-size flip-y",
13556+
"most-block-size flip-start",
13557+
"most-block-size left",
13558+
"most-block-size span-y-start",
13559+
"most-block-size span-block-start inline-end",
13560+
"most-block-size span-all self-block-end",
13561+
"most-block-size end span-start",
13562+
"most-block-size center span-all",
13563+
"most-inline-size --foo",
13564+
"most-inline-size flip-block",
13565+
"most-inline-size flip-inline",
13566+
"most-inline-size flip-x",
13567+
"most-inline-size flip-y",
13568+
"most-inline-size flip-start",
13569+
"most-inline-size left",
13570+
"most-inline-size span-y-start",
13571+
"most-inline-size span-block-start inline-end",
13572+
"most-inline-size span-all self-block-end",
13573+
"most-inline-size end span-start",
13574+
"most-inline-size center span-all",
13575+
];
13576+
(tryOrderEnabled
13577+
? gCSSProperties["position-try"].other_values
13578+
: gCSSProperties["position-try"].invalid_values
13579+
).push(...positionTryValuesWithOrder);
1356613580
}
1356713581

1356813582
if (IsCSSPropertyPrefEnabled("layout.css.scroll-state.enabled")) {

modules/libpref/init/StaticPrefList.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9897,6 +9897,13 @@
98979897
mirror: always
98989898
rust: true
98999899

9900+
# Whether to enable position-try-order
9901+
- name: layout.css.anchor-positioning.position-try-order.enabled
9902+
type: RelaxedAtomicBool
9903+
value: false
9904+
mirror: always
9905+
rust: true
9906+
99009907
# Whether to enable generalized CSS Attr Support. If this pref is set to false
99019908
# we treat attr as a regular function with support only for the `content` css
99029909
# property. If it is set to true, attr is parsed as a subtitution function.

servo/components/style/properties/longhands/position.mako.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ ${helpers.predefined_type(
301301
engines="gecko",
302302
initial_specified_value="specified::PositionTryOrder::normal()",
303303
animation_type="discrete",
304-
gecko_pref="layout.css.anchor-positioning.enabled",
304+
gecko_pref="layout.css.anchor-positioning.position-try-order.enabled",
305305
spec="https://drafts.csswg.org/css-anchor-position-1/#position-try-order-property",
306306
affects="layout",
307307
)}

servo/components/style/properties/shorthands/position.mako.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -858,19 +858,25 @@
858858
context: &ParserContext,
859859
input: &mut Parser<'i, 't>,
860860
) -> Result<Longhands, ParseError<'i>> {
861-
let order = input.try_parse(|i| PositionTryOrder::parse(i)).unwrap_or(PositionTryOrder::normal());
861+
let order = if static_prefs::pref!("layout.css.anchor-positioning.position-try-order.enabled") {
862+
input.try_parse(PositionTryOrder::parse).ok()
863+
} else {
864+
None
865+
};
862866
let fallbacks = PositionTryFallbacks::parse(context, input)?;
863867
Ok(expanded! {
864-
position_try_order: order,
868+
position_try_order: order.unwrap_or(PositionTryOrder::normal()),
865869
position_try_fallbacks: fallbacks,
866870
})
867871
}
868872

869873
impl<'a> ToCss for LonghandsToSerialize<'a> {
870874
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
871-
if *self.position_try_order != PositionTryOrder::Normal {
872-
self.position_try_order.to_css(dest)?;
873-
dest.write_char(' ')?;
875+
if let Some(o) = self.position_try_order {
876+
if *o != PositionTryOrder::Normal {
877+
o.to_css(dest)?;
878+
dest.write_char(' ')?;
879+
}
874880
}
875881
self.position_try_fallbacks.to_css(dest)
876882
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +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]
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,layout.css.anchor-positioning.position-try-order.enabled:true]

0 commit comments

Comments
 (0)