Bug 1897659. Implement parsing of CSS 'position-try-order' property. r=emilio,firefox-style-system-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D212220
This commit is contained in:
Jonathan Watt 2024-05-31 10:35:07 +00:00
Родитель 0d51892021
Коммит 3fa58fb2fa
13 изменённых файлов: 119 добавлений и 4 удалений

Просмотреть файл

@ -145,6 +145,7 @@ exports.ANIMATION_TYPE_FOR_LONGHANDS = [
"pointer-events",
"position",
"position-anchor",
"position-try-order",
"position-visibility",
"print-color-adjust",
"quotes",

Просмотреть файл

@ -107,7 +107,7 @@ use.counter:
send_in_pings:
- use-counters
# Total of 2343 use counter metrics (excludes denominators).
# Total of 2345 use counter metrics (excludes denominators).
# Total of 364 'page' use counters.
use.counter.page:
svgsvgelement_getelementbyid:
@ -16085,7 +16085,7 @@ use.counter.deprecated_ops.doc:
send_in_pings:
- use-counters
# Total of 702 'CSS (page)' use counters.
# Total of 703 'CSS (page)' use counters.
use.counter.css.page:
css_align_content:
type: counter
@ -17600,6 +17600,23 @@ use.counter.css.page:
send_in_pings:
- use-counters
css_position_try_order:
type: counter
description: >
Whether a page used the CSS property position-try-order.
Compare against `use.counter.top_level_content_documents_destroyed`
to calculate the rate.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
notification_emails:
- dom-core@mozilla.com
- emilio@mozilla.com
expires: never
send_in_pings:
- use-counters
css_position_visibility:
type: counter
description: >
@ -28021,7 +28038,7 @@ use.counter.css.page:
send_in_pings:
- use-counters
# Total of 702 'CSS (document)' use counters.
# Total of 703 'CSS (document)' use counters.
use.counter.css.doc:
css_align_content:
type: counter
@ -29536,6 +29553,23 @@ use.counter.css.doc:
send_in_pings:
- use-counters
css_position_try_order:
type: counter
description: >
Whether a document used the CSS property position-try-order.
Compare against `use.counter.content_documents_destroyed`
to calculate the rate.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
notification_emails:
- dom-core@mozilla.com
- emilio@mozilla.com
expires: never
send_in_pings:
- use-counters
css_position_visibility:
type: counter
description: >

Просмотреть файл

@ -627,6 +627,7 @@ cbindgen-types = [
{ gecko = "StyleAnchorScope", servo = "crate::values::computed::position::AnchorScope" },
{ gecko = "StylePositionAnchor", servo = "crate::values::computed::position::PositionAnchor" },
{ gecko = "StylePositionVisibility", servo = "crate::values::computed::position::PositionVisibility" },
{ gecko = "StylePositionTryOrder", servo = "crate::values::computed::position::PositionTryOrder" },
{ gecko = "StyleInsetArea", servo = "crate::values::computed::position::InsetArea" },
{ gecko = "StyleFontVariantEastAsian", servo = "crate::values::computed::font::FontVariantEastAsian" },
{ gecko = "StyleFontVariantLigatures", servo = "crate::values::computed::font::FontVariantLigatures" },

Просмотреть файл

@ -1051,6 +1051,7 @@ nsStylePosition::nsStylePosition()
mMaxHeight(StyleMaxSize::None()),
mPositionAnchor(StylePositionAnchor::Auto()),
mPositionVisibility(StylePositionVisibility::ALWAYS),
mPositionTryOrder(StylePositionTryOrder::Normal),
mInsetArea(StyleInsetArea{StyleInsetAreaKeyword::None,
StyleInsetAreaKeyword::None}),
mFlexBasis(StyleFlexBasis::Size(StyleSize::Auto())),
@ -1103,6 +1104,7 @@ nsStylePosition::nsStylePosition(const nsStylePosition& aSource)
mMaxHeight(aSource.mMaxHeight),
mPositionAnchor(aSource.mPositionAnchor),
mPositionVisibility(aSource.mPositionVisibility),
mPositionTryOrder(aSource.mPositionTryOrder),
mInsetArea(aSource.mInsetArea),
mFlexBasis(aSource.mFlexBasis),
mGridAutoColumns(aSource.mGridAutoColumns),
@ -1289,6 +1291,7 @@ nsChangeHint nsStylePosition::CalcDifference(
}
if (mPositionVisibility != aNewData.mPositionVisibility ||
mPositionTryOrder != aNewData.mPositionTryOrder ||
mInsetArea != aNewData.mInsetArea) {
hint |= nsChangeHint_NeutralChange;
}

Просмотреть файл

@ -747,6 +747,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStylePosition {
// element.
mozilla::StylePositionAnchor mPositionAnchor;
mozilla::StylePositionVisibility mPositionVisibility;
mozilla::StylePositionTryOrder mPositionTryOrder;
mozilla::StyleInsetArea mInsetArea;
mozilla::StyleFlexBasis mFlexBasis;

Просмотреть файл

@ -13426,6 +13426,20 @@ if (IsCSSPropertyPrefEnabled("layout.css.anchor-positioning.enabled")) {
invalid_values: ["none", "--foo, auto", "auto, --bar", "foo"],
};
gCSSProperties["position-try-order"] = {
domProp: "positionTryOrder",
inherited: false,
type: CSS_TYPE_LONGHAND,
initial_values: ["normal"],
other_values: [
"most-width",
"most-heigh",
"most-block-size",
"most-inline-size",
],
invalid_values: ["auto", "none", "foo"],
};
gCSSProperties["position-visibility"] = {
domProp: "positionVisibility",
inherited: false,

Просмотреть файл

@ -593,6 +593,7 @@ class Longhand(Property):
"OverscrollBehavior",
"PageOrientation",
"Percentage",
"PositionTryOrder",
"PositionVisibility",
"PrintColorAdjust",
"ForcedColorAdjust",

Просмотреть файл

@ -366,6 +366,18 @@ ${helpers.predefined_type(
affects="layout",
)}
${helpers.predefined_type(
"position-try-order",
"PositionTryOrder",
"computed::PositionTryOrder::normal()",
engines="gecko",
initial_specified_value="specified::PositionTryOrder::normal()",
animation_value_type="discrete",
gecko_pref="layout.css.anchor-positioning.enabled",
spec="https://drafts.csswg.org/css-anchor-position-1/#position-try-order-property",
affects="layout",
)}
${helpers.single_keyword(
"box-sizing",
"content-box border-box",

Просмотреть файл

@ -92,6 +92,7 @@ pub use self::position::AnchorName;
pub use self::position::AnchorScope;
pub use self::position::AspectRatio;
pub use self::position::PositionAnchor;
pub use self::position::PositionTryOrder;
pub use self::position::PositionVisibility;
pub use self::position::{
GridAutoFlow, GridTemplateAreas, MasonryAutoFlow, Position, PositionOrAuto, ZIndex,

Просмотреть файл

@ -14,7 +14,8 @@ use crate::values::generics::position::PositionComponent as GenericPositionCompo
use crate::values::generics::position::PositionOrAuto as GenericPositionOrAuto;
use crate::values::generics::position::ZIndex as GenericZIndex;
pub use crate::values::specified::position::{
AnchorName, AnchorScope, InsetArea, InsetAreaKeyword, PositionAnchor, PositionVisibility,
AnchorName, AnchorScope, InsetArea, InsetAreaKeyword, PositionAnchor, PositionTryOrder,
PositionVisibility,
};
pub use crate::values::specified::position::{GridAutoFlow, GridTemplateAreas, MasonryAutoFlow};
use crate::Zero;

Просмотреть файл

@ -84,6 +84,7 @@ pub use self::position::AnchorName;
pub use self::position::AnchorScope;
pub use self::position::AspectRatio;
pub use self::position::PositionAnchor;
pub use self::position::PositionTryOrder;
pub use self::position::PositionVisibility;
pub use self::position::{GridAutoFlow, GridTemplateAreas, Position, PositionOrAuto};
pub use self::position::{InsetArea, InsetAreaKeyword};

Просмотреть файл

@ -489,6 +489,50 @@ impl PositionAnchor {
}
}
/// https://drafts.csswg.org/css-anchor-position-1/#position-try-order-property
#[derive(
Clone,
Copy,
Debug,
Default,
Eq,
MallocSizeOf,
Parse,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
)]
#[repr(u8)]
pub enum PositionTryOrder {
#[default]
/// `normal`
Normal,
/// `most-width`
MostWidth,
/// `most-height`
MostHeight,
/// `most-block-size`
MostBlockSize,
/// `most-inline-size`
MostInlineSize,
}
impl PositionTryOrder {
#[inline]
/// Return the `auto` value.
pub fn normal() -> Self {
Self::Normal
}
/// Returns whether this is the `auto` value.
pub fn is_normal(&self) -> bool {
*self == Self::Normal
}
}
#[derive(
Clone,
Copy,

Просмотреть файл

@ -119,6 +119,7 @@ include = [
"DisplayMode",
"Platform",
"PositionAnchor",
"PositionTryOrder",
"PositionVisibility",
"GtkThemeFamily",
"PrefersColorScheme",