зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1720554 Part 1 - Remove the paper size variant of GenericPageSize and add an implied default to the paper size and orientation variant. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D119915
This commit is contained in:
Родитель
a2311ccb80
Коммит
9651a4d2c2
|
@ -36,16 +36,14 @@ 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::PaperSizeAndOrientation(p, Orientation::Landscape) => PageSize::Size(Size2D {
|
||||
Self::PaperSize(p, Orientation::Landscape) => PageSize::Size(Size2D {
|
||||
width: p.long_edge().to_computed_value(ctx),
|
||||
height: p.short_edge().to_computed_value(ctx),
|
||||
}),
|
||||
Self::PaperSizeAndOrientation(p, Orientation::Portrait) | Self::PaperSize(p) => {
|
||||
PageSize::Size(Size2D {
|
||||
width: p.short_edge().to_computed_value(ctx),
|
||||
height: p.long_edge().to_computed_value(ctx),
|
||||
})
|
||||
},
|
||||
Self::PaperSize(p, Orientation::Portrait) => PageSize::Size(Size2D {
|
||||
width: p.short_edge().to_computed_value(ctx),
|
||||
height: p.long_edge().to_computed_value(ctx),
|
||||
}),
|
||||
Self::Orientation(o) => PageSize::Orientation(*o),
|
||||
Self::Auto => PageSize::Auto,
|
||||
}
|
||||
|
|
|
@ -94,22 +94,25 @@ pub enum Orientation {
|
|||
Landscape,
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_portrait(orientation: &Orientation) -> bool {
|
||||
*orientation == Orientation::Portrait
|
||||
}
|
||||
|
||||
/// Page size property
|
||||
///
|
||||
/// https://drafts.csswg.org/css-page-3/#page-size-prop
|
||||
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss, ToShmem)]
|
||||
#[repr(C, u8)]
|
||||
pub enum GenericPageSize<S> {
|
||||
/// Page dimensions.
|
||||
Size(S),
|
||||
/// Paper size with no orientation.
|
||||
PaperSize(PaperSize),
|
||||
/// An orientation with no size.
|
||||
Orientation(Orientation),
|
||||
/// Paper size by name, with an orientation.
|
||||
PaperSizeAndOrientation(PaperSize, Orientation),
|
||||
/// `auto` value.
|
||||
Auto,
|
||||
/// Page dimensions.
|
||||
Size(S),
|
||||
/// An orientation with no size.
|
||||
Orientation(Orientation),
|
||||
/// Paper size by name
|
||||
PaperSize(PaperSize, #[css(skip_if = "is_portrait")] Orientation),
|
||||
}
|
||||
|
||||
pub use self::GenericPageSize as PageSize;
|
||||
|
|
|
@ -23,15 +23,15 @@ impl Parse for PageSize {
|
|||
) -> Result<Self, ParseError<'i>> {
|
||||
// Try to parse as <page-size> [ <orientation> ]
|
||||
if let Ok(paper_size) = input.try_parse(PaperSize::parse) {
|
||||
if let Ok(orientation) = input.try_parse(Orientation::parse) {
|
||||
return Ok(PageSize::PaperSizeAndOrientation(paper_size, orientation));
|
||||
}
|
||||
return Ok(PageSize::PaperSize(paper_size));
|
||||
let orientation = input
|
||||
.try_parse(Orientation::parse)
|
||||
.unwrap_or(Orientation::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(paper_size) = input.try_parse(PaperSize::parse) {
|
||||
return Ok(PageSize::PaperSizeAndOrientation(paper_size, orientation));
|
||||
return Ok(PageSize::PaperSize(paper_size, orientation));
|
||||
}
|
||||
return Ok(PageSize::Orientation(orientation));
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче