mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
style: Add support for parsing container-query-specific features
There are some mediaqueries-5 features that we still don't support and explain the remaining failures in at-container-{parsing,serialization}. Differential Revision: https://phabricator.services.mozilla.com/D144446
This commit is contained in:
parent
989f8d89c4
commit
1003d644aa
16 changed files with 205 additions and 79 deletions
|
@ -72,7 +72,7 @@ pub use self::list::ListStyleType;
|
|||
pub use self::list::Quotes;
|
||||
pub use self::motion::{OffsetPath, OffsetRotate};
|
||||
pub use self::outline::OutlineStyle;
|
||||
pub use self::page::{Orientation, PageName, PageSize, PaperSize};
|
||||
pub use self::page::{PageOrientation, PageName, PageSize, PaperSize};
|
||||
pub use self::percentage::{NonNegativePercentage, Percentage};
|
||||
pub use self::position::AspectRatio;
|
||||
pub use self::position::{
|
||||
|
|
|
@ -11,7 +11,7 @@ use crate::values::generics::size::Size2D;
|
|||
|
||||
use crate::values::specified::page as specified;
|
||||
pub use generics::page::GenericPageSize;
|
||||
pub use generics::page::Orientation;
|
||||
pub use generics::page::PageOrientation;
|
||||
pub use generics::page::PaperSize;
|
||||
pub use specified::PageName;
|
||||
|
||||
|
@ -26,7 +26,7 @@ pub enum PageSize {
|
|||
/// Specified size, paper size, or paper size and orientation.
|
||||
Size(Size2D<NonNegativeLength>),
|
||||
/// `landscape` or `portrait` value, no specified size.
|
||||
Orientation(Orientation),
|
||||
Orientation(PageOrientation),
|
||||
/// `auto` value
|
||||
Auto,
|
||||
}
|
||||
|
@ -37,11 +37,11 @@ impl ToComputedValue for specified::PageSize {
|
|||
fn to_computed_value(&self, ctx: &Context) -> Self::ComputedValue {
|
||||
match &*self {
|
||||
Self::Size(s) => PageSize::Size(s.to_computed_value(ctx)),
|
||||
Self::PaperSize(p, Orientation::Landscape) => PageSize::Size(Size2D {
|
||||
Self::PaperSize(p, PageOrientation::Landscape) => PageSize::Size(Size2D {
|
||||
width: p.long_edge().to_computed_value(ctx),
|
||||
height: p.short_edge().to_computed_value(ctx),
|
||||
}),
|
||||
Self::PaperSize(p, Orientation::Portrait) => PageSize::Size(Size2D {
|
||||
Self::PaperSize(p, PageOrientation::Portrait) => PageSize::Size(Size2D {
|
||||
width: p.short_edge().to_computed_value(ctx),
|
||||
height: p.long_edge().to_computed_value(ctx),
|
||||
}),
|
||||
|
|
|
@ -87,7 +87,7 @@ impl PaperSize {
|
|||
ToShmem,
|
||||
)]
|
||||
#[repr(u8)]
|
||||
pub enum Orientation {
|
||||
pub enum PageOrientation {
|
||||
/// Portrait orientation
|
||||
Portrait,
|
||||
/// Landscape orientation
|
||||
|
@ -95,8 +95,8 @@ pub enum Orientation {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn is_portrait(orientation: &Orientation) -> bool {
|
||||
*orientation == Orientation::Portrait
|
||||
fn is_portrait(orientation: &PageOrientation) -> bool {
|
||||
*orientation == PageOrientation::Portrait
|
||||
}
|
||||
|
||||
/// Page size property
|
||||
|
@ -110,9 +110,9 @@ pub enum GenericPageSize<S> {
|
|||
/// Page dimensions.
|
||||
Size(S),
|
||||
/// An orientation with no size.
|
||||
Orientation(Orientation),
|
||||
Orientation(PageOrientation),
|
||||
/// Paper size by name
|
||||
PaperSize(PaperSize, #[css(skip_if = "is_portrait")] Orientation),
|
||||
PaperSize(PaperSize, #[css(skip_if = "is_portrait")] PageOrientation),
|
||||
}
|
||||
|
||||
pub use self::GenericPageSize as PageSize;
|
||||
|
|
|
@ -69,7 +69,7 @@ pub use self::list::ListStyleType;
|
|||
pub use self::list::Quotes;
|
||||
pub use self::motion::{OffsetPath, OffsetRotate};
|
||||
pub use self::outline::OutlineStyle;
|
||||
pub use self::page::{Orientation, PageName, PageSize, PaperSize};
|
||||
pub use self::page::{PageOrientation, PageName, PageSize, PaperSize};
|
||||
pub use self::percentage::{NonNegativePercentage, Percentage};
|
||||
pub use self::position::AspectRatio;
|
||||
pub use self::position::{
|
||||
|
|
|
@ -11,7 +11,7 @@ use crate::values::{generics, CustomIdent};
|
|||
use cssparser::Parser;
|
||||
use style_traits::ParseError;
|
||||
|
||||
pub use generics::page::Orientation;
|
||||
pub use generics::page::PageOrientation;
|
||||
pub use generics::page::PaperSize;
|
||||
/// Specified value of the @page size descriptor
|
||||
pub type PageSize = generics::page::PageSize<Size2D<NonNegativeLength>>;
|
||||
|
@ -24,12 +24,12 @@ impl Parse for PageSize {
|
|||
// Try to parse as <page-size> [ <orientation> ]
|
||||
if let Ok(paper_size) = input.try_parse(PaperSize::parse) {
|
||||
let orientation = input
|
||||
.try_parse(Orientation::parse)
|
||||
.unwrap_or(Orientation::Portrait);
|
||||
.try_parse(PageOrientation::parse)
|
||||
.unwrap_or(PageOrientation::Portrait);
|
||||
return Ok(PageSize::PaperSize(paper_size, orientation));
|
||||
}
|
||||
// Try to parse as <orientation> [ <page-size> ]
|
||||
if let Ok(orientation) = input.try_parse(Orientation::parse) {
|
||||
if let Ok(orientation) = input.try_parse(PageOrientation::parse) {
|
||||
if let Ok(paper_size) = input.try_parse(PaperSize::parse) {
|
||||
return Ok(PageSize::PaperSize(paper_size, orientation));
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
use crate::gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
|
||||
use crate::media_queries::Device;
|
||||
use crate::parser::{Parse, ParserContext};
|
||||
use crate::queries::QueryCondition;
|
||||
use crate::queries::{QueryCondition, FeatureType};
|
||||
use crate::values::computed::{self, ToComputedValue};
|
||||
use crate::values::specified::{Length, NoCalcLength, ViewportPercentageLength};
|
||||
use app_units::Au;
|
||||
|
@ -30,7 +30,7 @@ impl Parse for SourceSize {
|
|||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
let condition = QueryCondition::parse(context, input)?;
|
||||
let condition = QueryCondition::parse(context, input, FeatureType::Media)?;
|
||||
let value = Length::parse_non_negative(context, input)?;
|
||||
Ok(Self { condition, value })
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue