зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1798312 - Rename page::PageOrientation to page::PageSizeOrientation. r=AlaskanEmily
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:
Родитель
1c6a6c7dd8
Коммит
0f1f88eea5
|
@ -604,12 +604,13 @@ nsSize nsPageFrame::ComputePageSize() const {
|
|||
}
|
||||
if (pageSize.IsOrientation()) {
|
||||
// Ensure the correct orientation is applied.
|
||||
if (pageSize.AsOrientation() == StylePageOrientation::Portrait) {
|
||||
if (pageSize.AsOrientation() == StylePageSizeOrientation::Portrait) {
|
||||
if (size.width > size.height) {
|
||||
std::swap(size.width, size.height);
|
||||
}
|
||||
} else {
|
||||
MOZ_ASSERT(pageSize.AsOrientation() == StylePageOrientation::Landscape);
|
||||
MOZ_ASSERT(pageSize.AsOrientation() ==
|
||||
StylePageSizeOrientation::Landscape);
|
||||
if (size.width < size.height) {
|
||||
std::swap(size.width, size.height);
|
||||
}
|
||||
|
|
|
@ -1336,15 +1336,15 @@ nsresult nsPrintJob::ReflowPrintObject(const UniquePtr<nsPrintObject>& aPO) {
|
|||
// FinishPrintPreview, so that the frontend can reflect this.
|
||||
// The new document has not yet been reflowed, so we have to query the
|
||||
// original document for any CSS page-size.
|
||||
if (const Maybe<StylePageOrientation> maybeOrientation =
|
||||
if (const Maybe<StylePageSizeOrientation> maybeOrientation =
|
||||
aPO->mDocument->GetPresShell()
|
||||
->StyleSet()
|
||||
->GetDefaultPageOrientation()) {
|
||||
if (maybeOrientation.value() == StylePageOrientation::Landscape &&
|
||||
->GetDefaultPageSizeOrientation()) {
|
||||
if (maybeOrientation.value() == StylePageSizeOrientation::Landscape &&
|
||||
pageSize.width < pageSize.height) {
|
||||
// Paper is in portrait, CSS page size is landscape.
|
||||
std::swap(pageSize.width, pageSize.height);
|
||||
} else if (maybeOrientation.value() == StylePageOrientation::Portrait &&
|
||||
} else if (maybeOrientation.value() == StylePageSizeOrientation::Portrait &&
|
||||
pageSize.width > pageSize.height) {
|
||||
// Paper is in landscape, CSS page size is portrait.
|
||||
std::swap(pageSize.width, pageSize.height);
|
||||
|
@ -1985,9 +1985,10 @@ nsresult nsPrintJob::FinishPrintPreview() {
|
|||
// Determine if there is a specified page size, and if we should set the
|
||||
// paper orientation to match it.
|
||||
const Maybe<bool> maybeLandscape =
|
||||
mPrintObject->mPresShell->StyleSet()->GetDefaultPageOrientation().map(
|
||||
[](StylePageOrientation o) -> bool {
|
||||
return o == StylePageOrientation::Landscape;
|
||||
mPrintObject->mPresShell->StyleSet()
|
||||
->GetDefaultPageSizeOrientation()
|
||||
.map([](StylePageSizeOrientation o) -> bool {
|
||||
return o == StylePageSizeOrientation::Landscape;
|
||||
});
|
||||
mPrintPreviewCallback(PrintPreviewResultInfo(
|
||||
GetPrintPreviewNumSheets(), GetRawNumPages(), GetIsEmpty(),
|
||||
|
|
|
@ -635,7 +635,7 @@ StyleSheet* ServoStyleSet::SheetAt(Origin aOrigin, size_t aIndex) const {
|
|||
Servo_StyleSet_GetSheetAt(mRawSet.get(), aOrigin, aIndex));
|
||||
}
|
||||
|
||||
Maybe<StylePageOrientation> ServoStyleSet::GetDefaultPageOrientation() {
|
||||
Maybe<StylePageSizeOrientation> ServoStyleSet::GetDefaultPageSizeOrientation() {
|
||||
const RefPtr<ComputedStyle> style =
|
||||
ResolveNonInheritingAnonymousBoxStyle(PseudoStyleType::pageContent);
|
||||
const StylePageSize& pageSize = style->StylePage()->mSize;
|
||||
|
@ -646,10 +646,10 @@ Maybe<StylePageOrientation> ServoStyleSet::GetDefaultPageOrientation() {
|
|||
const CSSCoord w = pageSize.AsSize().width.ToCSSPixels();
|
||||
const CSSCoord h = pageSize.AsSize().height.ToCSSPixels();
|
||||
if (w > h) {
|
||||
return Some(StylePageOrientation::Landscape);
|
||||
return Some(StylePageSizeOrientation::Landscape);
|
||||
}
|
||||
if (w < h) {
|
||||
return Some(StylePageOrientation::Portrait);
|
||||
return Some(StylePageSizeOrientation::Portrait);
|
||||
}
|
||||
} else {
|
||||
MOZ_ASSERT(pageSize.IsAuto(), "Impossible page size");
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
namespace mozilla {
|
||||
enum class MediaFeatureChangeReason : uint16_t;
|
||||
enum class StylePageOrientation : uint8_t;
|
||||
enum class StylePageSizeOrientation : uint8_t;
|
||||
enum class StyleRuleChangeKind : uint32_t;
|
||||
|
||||
template <typename Integer, typename Number, typename LinearStops>
|
||||
|
@ -250,7 +250,7 @@ class ServoStyleSet {
|
|||
// value to page-size, as well as for an explicit size or paper name which
|
||||
// is not square.
|
||||
// If the value is auto or square, then returns nothing.
|
||||
Maybe<StylePageOrientation> GetDefaultPageOrientation();
|
||||
Maybe<StylePageSizeOrientation> GetDefaultPageSizeOrientation();
|
||||
|
||||
void AppendAllNonDocumentAuthorSheets(nsTArray<StyleSheet*>& aArray) const;
|
||||
|
||||
|
|
|
@ -81,7 +81,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::{PageName, PageOrientation, PageSize, PaperSize};
|
||||
pub use self::page::{PageName, PageSize, PageSizeOrientation, 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::PageOrientation;
|
||||
pub use generics::page::PageSizeOrientation;
|
||||
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(PageOrientation),
|
||||
Orientation(PageSizeOrientation),
|
||||
/// `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, PageOrientation::Landscape) => PageSize::Size(Size2D {
|
||||
Self::PaperSize(p, PageSizeOrientation::Landscape) => PageSize::Size(Size2D {
|
||||
width: p.long_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),
|
||||
height: p.long_edge().to_computed_value(ctx),
|
||||
}),
|
||||
|
|
|
@ -87,7 +87,7 @@ impl PaperSize {
|
|||
ToShmem,
|
||||
)]
|
||||
#[repr(u8)]
|
||||
pub enum PageOrientation {
|
||||
pub enum PageSizeOrientation {
|
||||
/// Portrait orientation
|
||||
Portrait,
|
||||
/// Landscape orientation
|
||||
|
@ -95,8 +95,8 @@ pub enum PageOrientation {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn is_portrait(orientation: &PageOrientation) -> bool {
|
||||
*orientation == PageOrientation::Portrait
|
||||
fn is_portrait(orientation: &PageSizeOrientation) -> bool {
|
||||
*orientation == PageSizeOrientation::Portrait
|
||||
}
|
||||
|
||||
/// Page size property
|
||||
|
@ -110,9 +110,9 @@ pub enum GenericPageSize<S> {
|
|||
/// Page dimensions.
|
||||
Size(S),
|
||||
/// An orientation with no size.
|
||||
Orientation(PageOrientation),
|
||||
Orientation(PageSizeOrientation),
|
||||
/// 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;
|
||||
|
|
|
@ -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::{PageName, PageOrientation, PageSize, PaperSize};
|
||||
pub use self::page::{PageName, PageSize, PageSizeOrientation, 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::PageOrientation;
|
||||
pub use generics::page::PageSizeOrientation;
|
||||
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(PageOrientation::parse)
|
||||
.unwrap_or(PageOrientation::Portrait);
|
||||
.try_parse(PageSizeOrientation::parse)
|
||||
.unwrap_or(PageSizeOrientation::Portrait);
|
||||
return Ok(PageSize::PaperSize(paper_size, orientation));
|
||||
}
|
||||
// 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) {
|
||||
return Ok(PageSize::PaperSize(paper_size, orientation));
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче