style: Rename page::PageOrientation to page::PageSizeOrientation

The @page rule may contain both 'page-orientation' and 'size' properties. The
'size' property can contain an orientation component which was being
represented as 'PageOrientation' prior to this patch. This patch changes that
to 'PageSizeOrientation' so that 'PageOrientation' can be used for
'page-orientation' in a subsequent patch.

Differential Revision: https://phabricator.services.mozilla.com/D160790
This commit is contained in:
Jonathan Watt 2022-10-31 22:52:16 +00:00 committed by Martin Robinson
parent b2ab136cd9
commit 2c1799a8df
5 changed files with 15 additions and 15 deletions

View file

@ -81,7 +81,7 @@ pub use self::list::ListStyleType;
pub use self::list::Quotes; pub use self::list::Quotes;
pub use self::motion::{OffsetPath, OffsetRotate}; pub use self::motion::{OffsetPath, OffsetRotate};
pub use self::outline::OutlineStyle; pub use self::outline::OutlineStyle;
pub use self::page::{PageName, PageOrientation, PageSize, PaperSize}; pub use self::page::{PageName, PageSize, PageSizeOrientation, PaperSize};
pub use self::percentage::{NonNegativePercentage, Percentage}; pub use self::percentage::{NonNegativePercentage, Percentage};
pub use self::position::AspectRatio; pub use self::position::AspectRatio;
pub use self::position::{ pub use self::position::{

View file

@ -11,7 +11,7 @@ use crate::values::generics::size::Size2D;
use crate::values::specified::page as specified; use crate::values::specified::page as specified;
pub use generics::page::GenericPageSize; pub use generics::page::GenericPageSize;
pub use generics::page::PageOrientation; pub use generics::page::PageSizeOrientation;
pub use generics::page::PaperSize; pub use generics::page::PaperSize;
pub use specified::PageName; pub use specified::PageName;
@ -26,7 +26,7 @@ pub enum PageSize {
/// Specified size, paper size, or paper size and orientation. /// Specified size, paper size, or paper size and orientation.
Size(Size2D<NonNegativeLength>), Size(Size2D<NonNegativeLength>),
/// `landscape` or `portrait` value, no specified size. /// `landscape` or `portrait` value, no specified size.
Orientation(PageOrientation), Orientation(PageSizeOrientation),
/// `auto` value /// `auto` value
Auto, Auto,
} }
@ -37,11 +37,11 @@ impl ToComputedValue for specified::PageSize {
fn to_computed_value(&self, ctx: &Context) -> Self::ComputedValue { fn to_computed_value(&self, ctx: &Context) -> Self::ComputedValue {
match &*self { match &*self {
Self::Size(s) => PageSize::Size(s.to_computed_value(ctx)), Self::Size(s) => PageSize::Size(s.to_computed_value(ctx)),
Self::PaperSize(p, PageOrientation::Landscape) => PageSize::Size(Size2D { Self::PaperSize(p, PageSizeOrientation::Landscape) => PageSize::Size(Size2D {
width: p.long_edge().to_computed_value(ctx), width: p.long_edge().to_computed_value(ctx),
height: p.short_edge().to_computed_value(ctx), height: p.short_edge().to_computed_value(ctx),
}), }),
Self::PaperSize(p, PageOrientation::Portrait) => PageSize::Size(Size2D { Self::PaperSize(p, PageSizeOrientation::Portrait) => PageSize::Size(Size2D {
width: p.short_edge().to_computed_value(ctx), width: p.short_edge().to_computed_value(ctx),
height: p.long_edge().to_computed_value(ctx), height: p.long_edge().to_computed_value(ctx),
}), }),

View file

@ -87,7 +87,7 @@ impl PaperSize {
ToShmem, ToShmem,
)] )]
#[repr(u8)] #[repr(u8)]
pub enum PageOrientation { pub enum PageSizeOrientation {
/// Portrait orientation /// Portrait orientation
Portrait, Portrait,
/// Landscape orientation /// Landscape orientation
@ -95,8 +95,8 @@ pub enum PageOrientation {
} }
#[inline] #[inline]
fn is_portrait(orientation: &PageOrientation) -> bool { fn is_portrait(orientation: &PageSizeOrientation) -> bool {
*orientation == PageOrientation::Portrait *orientation == PageSizeOrientation::Portrait
} }
/// Page size property /// Page size property
@ -110,9 +110,9 @@ pub enum GenericPageSize<S> {
/// Page dimensions. /// Page dimensions.
Size(S), Size(S),
/// An orientation with no size. /// An orientation with no size.
Orientation(PageOrientation), Orientation(PageSizeOrientation),
/// Paper size by name /// Paper size by name
PaperSize(PaperSize, #[css(skip_if = "is_portrait")] PageOrientation), PaperSize(PaperSize, #[css(skip_if = "is_portrait")] PageSizeOrientation),
} }
pub use self::GenericPageSize as PageSize; pub use self::GenericPageSize as PageSize;

View file

@ -72,7 +72,7 @@ pub use self::list::ListStyleType;
pub use self::list::Quotes; pub use self::list::Quotes;
pub use self::motion::{OffsetPath, OffsetRotate}; pub use self::motion::{OffsetPath, OffsetRotate};
pub use self::outline::OutlineStyle; pub use self::outline::OutlineStyle;
pub use self::page::{PageName, PageOrientation, PageSize, PaperSize}; pub use self::page::{PageName, PageSize, PageSizeOrientation, PaperSize};
pub use self::percentage::{NonNegativePercentage, Percentage}; pub use self::percentage::{NonNegativePercentage, Percentage};
pub use self::position::AspectRatio; pub use self::position::AspectRatio;
pub use self::position::{ pub use self::position::{

View file

@ -11,7 +11,7 @@ use crate::values::{generics, CustomIdent};
use cssparser::Parser; use cssparser::Parser;
use style_traits::ParseError; use style_traits::ParseError;
pub use generics::page::PageOrientation; pub use generics::page::PageSizeOrientation;
pub use generics::page::PaperSize; pub use generics::page::PaperSize;
/// Specified value of the @page size descriptor /// Specified value of the @page size descriptor
pub type PageSize = generics::page::PageSize<Size2D<NonNegativeLength>>; pub type PageSize = generics::page::PageSize<Size2D<NonNegativeLength>>;
@ -24,12 +24,12 @@ impl Parse for PageSize {
// Try to parse as <page-size> [ <orientation> ] // Try to parse as <page-size> [ <orientation> ]
if let Ok(paper_size) = input.try_parse(PaperSize::parse) { if let Ok(paper_size) = input.try_parse(PaperSize::parse) {
let orientation = input let orientation = input
.try_parse(PageOrientation::parse) .try_parse(PageSizeOrientation::parse)
.unwrap_or(PageOrientation::Portrait); .unwrap_or(PageSizeOrientation::Portrait);
return Ok(PageSize::PaperSize(paper_size, orientation)); return Ok(PageSize::PaperSize(paper_size, orientation));
} }
// Try to parse as <orientation> [ <page-size> ] // Try to parse as <orientation> [ <page-size> ]
if let Ok(orientation) = input.try_parse(PageOrientation::parse) { if let Ok(orientation) = input.try_parse(PageSizeOrientation::parse) {
if let Ok(paper_size) = input.try_parse(PaperSize::parse) { if let Ok(paper_size) = input.try_parse(PaperSize::parse) {
return Ok(PageSize::PaperSize(paper_size, orientation)); return Ok(PageSize::PaperSize(paper_size, orientation));
} }