Bug 1798323 - Style changes to support the 'page-orientation' property. r=AlaskanEmily

Differential Revision: https://phabricator.services.mozilla.com/D161800
This commit is contained in:
Jonathan Watt 2023-01-16 15:03:44 +00:00
parent f40dd158de
commit 43752f0573
15 changed files with 73 additions and 19 deletions

View File

@ -242,6 +242,7 @@ exports.ANIMATION_TYPE_FOR_LONGHANDS = [
"padding-block-start",
"padding-inline-end",
"padding-inline-start",
"page-orientation",
"math-depth",
"-moz-box-layout",
"-moz-top-layer",

View File

@ -9735,6 +9735,23 @@ exports.CSS_PROPERTIES = {
"unset"
]
},
"page-orientation": {
"isInherited": false,
"subproperties": [
"page-orientation"
],
"supports": [],
"values": [
"inherit",
"initial",
"revert",
"revert-layer",
"rotate-left",
"rotate-right",
"unset",
"upright"
]
},
"paint-order": {
"isInherited": true,
"subproperties": [
@ -11964,6 +11981,10 @@ exports.PREFERENCES = [
"overflow-anchor",
"layout.css.scroll-anchoring.enabled"
],
[
"page-orientation",
"layout.css.page-orientation.enabled"
],
[
"scrollbar-gutter",
"layout.css.scrollbar-gutter.enabled"

View File

@ -621,6 +621,7 @@ cbindgen-types = [
{ gecko = "StyleFontSizeKeyword", servo = "crate::values::specified::font::FontSizeKeyword" },
{ gecko = "StyleCaptionSide", servo = "crate::values::computed::table::CaptionSide" },
{ gecko = "StylePageName", servo = "crate::values::specified::page::PageName" },
{ gecko = "StylePageOrientation", servo = "crate::values::generics::page::PageOrientation" },
{ gecko = "StylePageSize", servo = "crate::values::computed::page::PageSize" },
{ gecko = "StyleDProperty", servo = "crate::values::specified::svg::DProperty" },
{ gecko = "StyleImageRendering", servo = "crate::values::computed::ImageRendering" },

View File

@ -1059,7 +1059,8 @@ bool nsStyleSVGReset::HasMask() const {
nsChangeHint nsStylePage::CalcDifference(const nsStylePage& aNewData) const {
// Page rule styling only matters when printing or using print preview.
if (aNewData.mSize != mSize || aNewData.mPage != mPage) {
if (aNewData.mSize != mSize || aNewData.mPage != mPage ||
aNewData.mPageOrientation != mPageOrientation) {
return nsChangeHint_NeutralChange;
}
return nsChangeHint_Empty;

View File

@ -728,12 +728,15 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleList {
};
struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStylePage {
using StylePageOrientation = mozilla::StylePageOrientation;
using StylePageSize = mozilla::StylePageSize;
using StylePageName = mozilla::StylePageName;
nsStylePage(const nsStylePage& aOther) = default;
nsStylePage& operator=(const nsStylePage& aOther) = default;
explicit nsStylePage(const mozilla::dom::Document&)
: mSize(StylePageSize::Auto()), mPage(StylePageName::Auto()) {}
: mSize(StylePageSize::Auto()),
mPage(StylePageName::Auto()),
mPageOrientation(StylePageOrientation::Upright) {}
static constexpr bool kHasTriggerImageLoads = false;
nsChangeHint CalcDifference(const nsStylePage& aNewData) const;
@ -742,6 +745,8 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStylePage {
StylePageSize mSize;
// page-name property.
StylePageName mPage;
// page-orientation property.
StylePageOrientation mPageOrientation;
};
struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStylePosition {

View File

@ -8555,6 +8555,13 @@
value: true
mirror: always
# Enables support for the page-orientation property inside of CSS @page rules.
- name: layout.css.page-orientation.enabled
type: RelaxedAtomicBool
value: @IS_NIGHTLY_BUILD@
mirror: always
rust: true
# Enables support for the size property inside of CSS @page rules.
- name: layout.css.page-size.enabled
type: RelaxedAtomicBool

View File

@ -495,6 +495,7 @@ class Longhand(Property):
"OverflowClipBox",
"OverflowWrap",
"OverscrollBehavior",
"PageOrientation",
"Percentage",
"PrintColorAdjust",
"Resize",

View File

@ -29,3 +29,15 @@ ${helpers.predefined_type(
spec="https://drafts.csswg.org/css-page-3/#using-named-pages",
animation_value_type="discrete",
)}
${helpers.predefined_type(
"page-orientation",
"PageOrientation",
"computed::PageOrientation::Upright",
engines="gecko",
gecko_pref="layout.css.page-orientation.enabled",
initial_specified_value="specified::PageOrientation::Upright",
spec="https://drafts.csswg.org/css-page-3/#page-orientation-prop",
animation_value_type="none",
rule_types_allowed=PAGE_RULE,
)}

View File

@ -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, PageSize, PageSizeOrientation, PaperSize};
pub use self::page::{PageName, PageOrientation, PageSize, PageSizeOrientation, PaperSize};
pub use self::percentage::{NonNegativePercentage, Percentage};
pub use self::position::AspectRatio;
pub use self::position::{

View File

@ -11,6 +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;

View File

@ -70,6 +70,22 @@ impl PaperSize {
}
}
/// Page orientation names.
///
/// https://drafts.csswg.org/css-page-3/#page-orientation-prop
#[derive(
Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem,
)]
#[repr(u8)]
pub enum PageOrientation {
/// upright
Upright,
/// rotate-left (counter-clockwise)
RotateLeft,
/// rotate-right (clockwise)
RotateRight,
}
/// Paper orientation
///
/// https://drafts.csswg.org/css-page-3/#page-size-prop

View File

@ -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, PageSize, PageSizeOrientation, PaperSize};
pub use self::page::{PageName, PageOrientation, PageSize, PageSizeOrientation, PaperSize};
pub use self::percentage::{NonNegativePercentage, Percentage};
pub use self::position::AspectRatio;
pub use self::position::{

View File

@ -11,6 +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

View File

@ -248,6 +248,7 @@ include = [
"DefaultFontSizes",
"RuleChangeKind",
"PageName",
"PageOrientation",
"PageSize",
"DProperty",
"ImageRendering",

View File

@ -1,18 +1,4 @@
[page-orientation.tentative.html]
[contents for selector [''\]]
expected: FAIL
[contents for selector ['named1'\]]
expected: FAIL
[contents for selector ['named3'\]]
expected: FAIL
[contents for selector ['named4'\]]
expected: FAIL
[contents for selector ['named5'\]]
expected: FAIL
prefs: [layout.css.page-orientation.enabled:true]
[contents for selector ['named6'\]]
expected: FAIL