forked from mirrors/gecko-dev
		
	Bug 1897619. Implement parsing of CSS 'position-anchor' property. r=emilio,firefox-style-system-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D210880
This commit is contained in:
		
							parent
							
								
									c81f644f55
								
							
						
					
					
						commit
						3fa7097c7f
					
				
					 12 changed files with 111 additions and 4 deletions
				
			
		|  | @ -143,6 +143,7 @@ exports.ANIMATION_TYPE_FOR_LONGHANDS = [ | ||||||
|       "paint-order", |       "paint-order", | ||||||
|       "pointer-events", |       "pointer-events", | ||||||
|       "position", |       "position", | ||||||
|  |       "position-anchor", | ||||||
|       "print-color-adjust", |       "print-color-adjust", | ||||||
|       "quotes", |       "quotes", | ||||||
|       "resize", |       "resize", | ||||||
|  |  | ||||||
|  | @ -107,7 +107,7 @@ use.counter: | ||||||
|     send_in_pings: |     send_in_pings: | ||||||
|       - use-counters |       - use-counters | ||||||
| 
 | 
 | ||||||
| # Total of 2305 use counter metrics (excludes denominators). | # Total of 2307 use counter metrics (excludes denominators). | ||||||
| # Total of 354 'page' use counters. | # Total of 354 'page' use counters. | ||||||
| use.counter.page: | use.counter.page: | ||||||
|   svgsvgelement_getelementbyid: |   svgsvgelement_getelementbyid: | ||||||
|  | @ -15541,7 +15541,7 @@ use.counter.deprecated_ops.doc: | ||||||
|     send_in_pings: |     send_in_pings: | ||||||
|       - use-counters |       - use-counters | ||||||
| 
 | 
 | ||||||
| # Total of 699 'CSS (page)' use counters. | # Total of 700 'CSS (page)' use counters. | ||||||
| use.counter.css.page: | use.counter.css.page: | ||||||
|   css_align_content: |   css_align_content: | ||||||
|     type: counter |     type: counter | ||||||
|  | @ -19759,6 +19759,23 @@ use.counter.css.page: | ||||||
|     send_in_pings: |     send_in_pings: | ||||||
|       - use-counters |       - use-counters | ||||||
| 
 | 
 | ||||||
|  |   css_position_anchor: | ||||||
|  |     type: counter | ||||||
|  |     description: > | ||||||
|  |       Whether a page used the CSS property position-anchor. | ||||||
|  |       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_quotes: |   css_quotes: | ||||||
|     type: counter |     type: counter | ||||||
|     description: > |     description: > | ||||||
|  | @ -27426,7 +27443,7 @@ use.counter.css.page: | ||||||
|     send_in_pings: |     send_in_pings: | ||||||
|       - use-counters |       - use-counters | ||||||
| 
 | 
 | ||||||
| # Total of 699 'CSS (document)' use counters. | # Total of 700 'CSS (document)' use counters. | ||||||
| use.counter.css.doc: | use.counter.css.doc: | ||||||
|   css_align_content: |   css_align_content: | ||||||
|     type: counter |     type: counter | ||||||
|  | @ -31644,6 +31661,23 @@ use.counter.css.doc: | ||||||
|     send_in_pings: |     send_in_pings: | ||||||
|       - use-counters |       - use-counters | ||||||
| 
 | 
 | ||||||
|  |   css_position_anchor: | ||||||
|  |     type: counter | ||||||
|  |     description: > | ||||||
|  |       Whether a document used the CSS property position-anchor. | ||||||
|  |       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_quotes: |   css_quotes: | ||||||
|     type: counter |     type: counter | ||||||
|     description: > |     description: > | ||||||
|  |  | ||||||
|  | @ -622,6 +622,7 @@ cbindgen-types = [ | ||||||
|     { gecko = "StyleAu", servo = "app_units::Au" }, |     { gecko = "StyleAu", servo = "app_units::Au" }, | ||||||
|     { gecko = "StyleAnchorName", servo = "crate::values::computed::position::AnchorName" }, |     { gecko = "StyleAnchorName", servo = "crate::values::computed::position::AnchorName" }, | ||||||
|     { gecko = "StyleAnchorScope", servo = "crate::values::computed::position::AnchorScope" }, |     { gecko = "StyleAnchorScope", servo = "crate::values::computed::position::AnchorScope" }, | ||||||
|  |     { gecko = "StylePositionAnchor", servo = "crate::values::computed::position::PositionAnchor" }, | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| mapped-generic-types = [ | mapped-generic-types = [ | ||||||
|  |  | ||||||
|  | @ -1051,6 +1051,7 @@ nsStylePosition::nsStylePosition() | ||||||
|       mHeight(StyleSize::Auto()), |       mHeight(StyleSize::Auto()), | ||||||
|       mMinHeight(StyleSize::Auto()), |       mMinHeight(StyleSize::Auto()), | ||||||
|       mMaxHeight(StyleMaxSize::None()), |       mMaxHeight(StyleMaxSize::None()), | ||||||
|  |       mPositionAnchor(StylePositionAnchor::Auto()), | ||||||
|       mFlexBasis(StyleFlexBasis::Size(StyleSize::Auto())), |       mFlexBasis(StyleFlexBasis::Size(StyleSize::Auto())), | ||||||
|       mAspectRatio(StyleAspectRatio::Auto()), |       mAspectRatio(StyleAspectRatio::Auto()), | ||||||
|       mGridAutoFlow(StyleGridAutoFlow::ROW), |       mGridAutoFlow(StyleGridAutoFlow::ROW), | ||||||
|  | @ -1099,6 +1100,7 @@ nsStylePosition::nsStylePosition(const nsStylePosition& aSource) | ||||||
|       mHeight(aSource.mHeight), |       mHeight(aSource.mHeight), | ||||||
|       mMinHeight(aSource.mMinHeight), |       mMinHeight(aSource.mMinHeight), | ||||||
|       mMaxHeight(aSource.mMaxHeight), |       mMaxHeight(aSource.mMaxHeight), | ||||||
|  |       mPositionAnchor(aSource.mPositionAnchor), | ||||||
|       mFlexBasis(aSource.mFlexBasis), |       mFlexBasis(aSource.mFlexBasis), | ||||||
|       mGridAutoColumns(aSource.mGridAutoColumns), |       mGridAutoColumns(aSource.mGridAutoColumns), | ||||||
|       mGridAutoRows(aSource.mGridAutoRows), |       mGridAutoRows(aSource.mGridAutoRows), | ||||||
|  | @ -1276,6 +1278,13 @@ nsChangeHint nsStylePosition::CalcDifference( | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   if (mPositionAnchor != aNewData.mPositionAnchor) { | ||||||
|  |     // 'position-anchor' provides a default anchor for other anchor positioning
 | ||||||
|  |     // properties in the event that they don't specify one explicitly.
 | ||||||
|  |     // TODO(jwatt): Re-evaluate what we're doing here.
 | ||||||
|  |     hint |= nsChangeHint_NeutralChange; | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   if (mAspectRatio != aNewData.mAspectRatio) { |   if (mAspectRatio != aNewData.mAspectRatio) { | ||||||
|     hint |= nsChangeHint_ReflowHintsForISizeChange | |     hint |= nsChangeHint_ReflowHintsForISizeChange | | ||||||
|             nsChangeHint_ReflowHintsForBSizeChange; |             nsChangeHint_ReflowHintsForBSizeChange; | ||||||
|  |  | ||||||
|  | @ -744,6 +744,11 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStylePosition { | ||||||
|   StyleSize mHeight; |   StyleSize mHeight; | ||||||
|   StyleSize mMinHeight; |   StyleSize mMinHeight; | ||||||
|   StyleMaxSize mMaxHeight; |   StyleMaxSize mMaxHeight; | ||||||
|  | 
 | ||||||
|  |   // 'auto' or a `<dashed-ident>` referencing an anchor positioning anchor
 | ||||||
|  |   // element.
 | ||||||
|  |   mozilla::StylePositionAnchor mPositionAnchor; | ||||||
|  | 
 | ||||||
|   mozilla::StyleFlexBasis mFlexBasis; |   mozilla::StyleFlexBasis mFlexBasis; | ||||||
|   StyleImplicitGridTracks mGridAutoColumns; |   StyleImplicitGridTracks mGridAutoColumns; | ||||||
|   StyleImplicitGridTracks mGridAutoRows; |   StyleImplicitGridTracks mGridAutoRows; | ||||||
|  |  | ||||||
|  | @ -13337,6 +13337,15 @@ if (IsCSSPropertyPrefEnabled("layout.css.anchor-positioning.enabled")) { | ||||||
|       "--foo,", |       "--foo,", | ||||||
|     ], |     ], | ||||||
|   }; |   }; | ||||||
|  | 
 | ||||||
|  |   gCSSProperties["position-anchor"] = { | ||||||
|  |     domProp: "positionAnchor", | ||||||
|  |     inherited: false, | ||||||
|  |     type: CSS_TYPE_LONGHAND, | ||||||
|  |     initial_values: ["auto"], | ||||||
|  |     other_values: ["--foo"], | ||||||
|  |     invalid_values: ["none", "--foo, auto", "auto, --bar", "foo"], | ||||||
|  |   }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| if (false) { | if (false) { | ||||||
|  |  | ||||||
|  | @ -331,6 +331,17 @@ ${helpers.predefined_type( | ||||||
|     )} |     )} | ||||||
| % endfor | % endfor | ||||||
| 
 | 
 | ||||||
|  | ${helpers.predefined_type( | ||||||
|  |     "position-anchor", | ||||||
|  |     "PositionAnchor", | ||||||
|  |     "computed::PositionAnchor::auto()", | ||||||
|  |     engines="gecko", | ||||||
|  |     animation_value_type="discrete", | ||||||
|  |     gecko_pref="layout.css.anchor-positioning.enabled", | ||||||
|  |     spec="https://drafts.csswg.org/css-anchor-position-1/#propdef-position-anchor", | ||||||
|  |     affects="layout", | ||||||
|  | )} | ||||||
|  | 
 | ||||||
| ${helpers.single_keyword( | ${helpers.single_keyword( | ||||||
|     "box-sizing", |     "box-sizing", | ||||||
|     "content-box border-box", |     "content-box border-box", | ||||||
|  |  | ||||||
|  | @ -90,6 +90,7 @@ pub use self::page::{PageName, PageOrientation, PageSize, PageSizeOrientation, P | ||||||
| pub use self::percentage::{NonNegativePercentage, Percentage}; | pub use self::percentage::{NonNegativePercentage, Percentage}; | ||||||
| pub use self::position::AnchorName; | pub use self::position::AnchorName; | ||||||
| pub use self::position::AnchorScope; | pub use self::position::AnchorScope; | ||||||
|  | pub use self::position::PositionAnchor; | ||||||
| pub use self::position::AspectRatio; | pub use self::position::AspectRatio; | ||||||
| pub use self::position::{ | pub use self::position::{ | ||||||
|     GridAutoFlow, GridTemplateAreas, MasonryAutoFlow, Position, PositionOrAuto, ZIndex, |     GridAutoFlow, GridTemplateAreas, MasonryAutoFlow, Position, PositionOrAuto, ZIndex, | ||||||
|  |  | ||||||
|  | @ -13,7 +13,8 @@ use crate::values::generics::position::Position as GenericPosition; | ||||||
| use crate::values::generics::position::PositionComponent as GenericPositionComponent; | use crate::values::generics::position::PositionComponent as GenericPositionComponent; | ||||||
| use crate::values::generics::position::PositionOrAuto as GenericPositionOrAuto; | use crate::values::generics::position::PositionOrAuto as GenericPositionOrAuto; | ||||||
| use crate::values::generics::position::ZIndex as GenericZIndex; | use crate::values::generics::position::ZIndex as GenericZIndex; | ||||||
| pub use crate::values::specified::position::{AnchorName, AnchorScope, GridAutoFlow, GridTemplateAreas, MasonryAutoFlow}; | pub use crate::values::specified::position::{GridAutoFlow, GridTemplateAreas, MasonryAutoFlow}; | ||||||
|  | pub use crate::values::specified::position::{AnchorName, AnchorScope, PositionAnchor}; | ||||||
| use crate::Zero; | use crate::Zero; | ||||||
| use std::fmt::{self, Write}; | use std::fmt::{self, Write}; | ||||||
| use style_traits::{CssWriter, ToCss}; | use style_traits::{CssWriter, ToCss}; | ||||||
|  |  | ||||||
|  | @ -83,6 +83,7 @@ pub use self::percentage::{NonNegativePercentage, Percentage}; | ||||||
| pub use self::position::AspectRatio; | pub use self::position::AspectRatio; | ||||||
| pub use self::position::AnchorName; | pub use self::position::AnchorName; | ||||||
| pub use self::position::AnchorScope; | pub use self::position::AnchorScope; | ||||||
|  | pub use self::position::PositionAnchor; | ||||||
| pub use self::position::{GridAutoFlow, GridTemplateAreas, Position, PositionOrAuto}; | pub use self::position::{GridAutoFlow, GridTemplateAreas, Position, PositionOrAuto}; | ||||||
| pub use self::position::{MasonryAutoFlow, MasonryItemOrder, MasonryPlacement}; | pub use self::position::{MasonryAutoFlow, MasonryItemOrder, MasonryPlacement}; | ||||||
| pub use self::position::{PositionComponent, ZIndex}; | pub use self::position::{PositionComponent, ZIndex}; | ||||||
|  |  | ||||||
|  | @ -456,6 +456,39 @@ impl Parse for AnchorScope { | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | /// https://drafts.csswg.org/css-anchor-position-1/#propdef-position-anchor
 | ||||||
|  | #[derive(
 | ||||||
|  |     Clone, | ||||||
|  |     Debug, | ||||||
|  |     MallocSizeOf, | ||||||
|  |     Parse, | ||||||
|  |     PartialEq, | ||||||
|  |     SpecifiedValueInfo, | ||||||
|  |     ToComputedValue, | ||||||
|  |     ToCss, | ||||||
|  |     ToResolvedValue, | ||||||
|  |     ToShmem, | ||||||
|  | )] | ||||||
|  | #[repr(u8)] | ||||||
|  | pub enum PositionAnchor { | ||||||
|  |     /// `auto`
 | ||||||
|  |     Auto, | ||||||
|  |     /// `<dashed-ident>`
 | ||||||
|  |     Ident(DashedIdent), | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | impl PositionAnchor { | ||||||
|  |     /// Return the `auto` value.
 | ||||||
|  |     pub fn auto() -> Self { | ||||||
|  |         Self::Auto | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /// Returns whether this is the `auto` value.
 | ||||||
|  |     pub fn is_auto(&self) -> bool { | ||||||
|  |         *self == Self::Auto | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /// Represents a side, either horizontal or vertical, of a CSS position.
 | /// Represents a side, either horizontal or vertical, of a CSS position.
 | ||||||
| pub trait Side { | pub trait Side { | ||||||
|     /// Returns the start side.
 |     /// Returns the start side.
 | ||||||
|  |  | ||||||
|  | @ -111,6 +111,7 @@ include = [ | ||||||
|   "DisplayInside", |   "DisplayInside", | ||||||
|   "DisplayMode", |   "DisplayMode", | ||||||
|   "Platform", |   "Platform", | ||||||
|  |   "PositionAnchor", | ||||||
|   "GtkThemeFamily", |   "GtkThemeFamily", | ||||||
|   "PrefersColorScheme", |   "PrefersColorScheme", | ||||||
|   "PrefersContrast", |   "PrefersContrast", | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Jonathan Watt
						Jonathan Watt