@@ -21,9 +21,8 @@ use crate::values::specified::angle::Angle;
2121use crate :: values:: specified:: border:: BorderRadius ;
2222use crate :: values:: specified:: image:: Image ;
2323use crate :: values:: specified:: length:: LengthPercentageOrAuto ;
24- use crate :: values:: specified:: position:: { Position , Side } ;
24+ use crate :: values:: specified:: position:: Position ;
2525use crate :: values:: specified:: url:: SpecifiedUrl ;
26- use crate :: values:: specified:: PositionComponent ;
2726use crate :: values:: specified:: { LengthPercentage , NonNegativeLengthPercentage , SVGPathData } ;
2827use crate :: values:: CSSFloat ;
2928use crate :: Zero ;
@@ -40,22 +39,17 @@ pub type ClipPath = generic::GenericClipPath<BasicShape, SpecifiedUrl>;
4039/// A specified `shape-outside` value.
4140pub type ShapeOutside = generic:: GenericShapeOutside < BasicShape , Image > ;
4241
43- /// A specified value for `at <position>` in circle() and ellipse().
44- // Note: its computed value is the same as computed::position::Position. We just want to always use
45- // LengthPercentage as the type of its components, for basic shapes.
46- pub type RadialPosition = generic:: ShapePosition < LengthPercentage > ;
47-
4842/// A specified basic shape.
4943pub type BasicShape = generic:: GenericBasicShape < Angle , Position , LengthPercentage , BasicShapeRect > ;
5044
5145/// The specified value of `inset()`.
5246pub type InsetRect = generic:: GenericInsetRect < LengthPercentage > ;
5347
5448/// A specified circle.
55- pub type Circle = generic:: Circle < LengthPercentage > ;
49+ pub type Circle = generic:: Circle < Position , LengthPercentage > ;
5650
5751/// A specified ellipse.
58- pub type Ellipse = generic:: Ellipse < LengthPercentage > ;
52+ pub type Ellipse = generic:: Ellipse < Position , LengthPercentage > ;
5953
6054/// The specified value of `ShapeRadius`.
6155pub type ShapeRadius = generic:: ShapeRadius < LengthPercentage > ;
@@ -390,60 +384,13 @@ impl InsetRect {
390384 }
391385}
392386
393- impl ToCss for RadialPosition {
394- fn to_css < W > ( & self , dest : & mut CssWriter < W > ) -> fmt:: Result
395- where
396- W : Write ,
397- {
398- self . horizontal . to_css ( dest) ?;
399- dest. write_char ( ' ' ) ?;
400- self . vertical . to_css ( dest)
401- }
402- }
403-
404- fn convert_to_length_percentage < S : Side > ( c : PositionComponent < S > ) -> LengthPercentage {
405- use crate :: values:: specified:: { AllowedNumericType , Percentage } ;
406- // Convert the value when parsing, to make sure we serialize it properly for both
407- // specified and computed values.
408- // https://drafts.csswg.org/css-shapes-1/#basic-shape-serialization
409- match c {
410- // Since <position> keywords stand in for percentages, keywords without an offset
411- // turn into percentages.
412- PositionComponent :: Center => LengthPercentage :: from ( Percentage :: new ( 0.5 ) ) ,
413- PositionComponent :: Side ( keyword, None ) => {
414- Percentage :: new ( if keyword. is_start ( ) { 0. } else { 1. } ) . into ( )
415- } ,
416- // Per spec issue, https://github.com/w3c/csswg-drafts/issues/8695, the part of
417- // "avoiding calc() expressions where possible" and "avoiding calc()
418- // transformations" will be removed from the spec, and we should follow the
419- // css-values-4 for position, i.e. we make it as length-percentage always.
420- // https://drafts.csswg.org/css-shapes-1/#basic-shape-serialization.
421- // https://drafts.csswg.org/css-values-4/#typedef-position
422- PositionComponent :: Side ( keyword, Some ( length) ) => {
423- if keyword. is_start ( ) {
424- length
425- } else {
426- length. hundred_percent_minus ( AllowedNumericType :: All )
427- }
428- } ,
429- PositionComponent :: Length ( length) => length,
430- }
431- }
432-
433387fn parse_at_position < ' i , ' t > (
434388 context : & ParserContext ,
435389 input : & mut Parser < ' i , ' t > ,
436- ) -> Result < GenericPositionOrAuto < RadialPosition > , ParseError < ' i > > {
437- use crate :: values:: specified:: position:: Position ;
390+ ) -> Result < GenericPositionOrAuto < Position > , ParseError < ' i > > {
438391 if input. try_parse ( |i| i. expect_ident_matching ( "at" ) ) . is_ok ( ) {
439- Position :: parse ( context, input) . map ( |pos| {
440- GenericPositionOrAuto :: Position ( RadialPosition :: new (
441- convert_to_length_percentage ( pos. horizontal ) ,
442- convert_to_length_percentage ( pos. vertical ) ,
443- ) )
444- } )
392+ Position :: parse ( context, input) . map ( GenericPositionOrAuto :: Position )
445393 } else {
446- // `at <position>` is omitted.
447394 Ok ( GenericPositionOrAuto :: Auto )
448395 }
449396}
0 commit comments