mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
style: Part 2 - Add page-size attribute to nsStyleStruct and property parsing
This parsing is hidden behind the pref layout.css.page-size.enabled. It isn't ideal that we parse this as a property, but we can't treat it as a descriptor because of compatibility issues with other browsers. There are also outstanding spec issues related to how descriptors like page-size are cascaded, and whether the !important specifier is valid or not. Differential Revision: https://phabricator.services.mozilla.com/D103958
This commit is contained in:
parent
cdce0d3b34
commit
3b2eef3d7d
6 changed files with 29 additions and 3 deletions
|
@ -37,6 +37,7 @@ STYLE_STRUCT_LIST = [
|
|||
"list",
|
||||
"margin",
|
||||
"outline",
|
||||
"page",
|
||||
"padding",
|
||||
"position",
|
||||
"svg",
|
||||
|
|
|
@ -19,7 +19,6 @@ COUNTED_UNKNOWN_PROPERTIES = [
|
|||
"text-size-adjust",
|
||||
"-webkit-font-feature-settings",
|
||||
"-webkit-user-drag",
|
||||
"size",
|
||||
"-webkit-clip-path",
|
||||
"orphans",
|
||||
"widows",
|
||||
|
|
|
@ -781,6 +781,9 @@ fn static_assert() {
|
|||
% endfor
|
||||
</%self:impl_trait>
|
||||
|
||||
<%self:impl_trait style_struct_name="Page">
|
||||
</%self:impl_trait>
|
||||
|
||||
<% skip_position_longhands = " ".join(x.ident for x in SIDES) %>
|
||||
<%self:impl_trait style_struct_name="Position"
|
||||
skip_longhands="${skip_position_longhands}
|
||||
|
|
21
components/style/properties/longhands/page.mako.rs
Normal file
21
components/style/properties/longhands/page.mako.rs
Normal file
|
@ -0,0 +1,21 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
<%namespace name="helpers" file="/helpers.mako.rs" />
|
||||
<% from data import PAGE_RULE %>
|
||||
|
||||
<% data.new_style_struct("Page", inherited=False) %>
|
||||
|
||||
${helpers.predefined_type(
|
||||
"size",
|
||||
"PageSize",
|
||||
"computed::PageSize::auto()",
|
||||
engines="gecko",
|
||||
gecko_pref="layout.css.page-size.enabled",
|
||||
initial_specified_value="specified::PageSize::auto()",
|
||||
spec="https://drafts.csswg.org/css-page-3/#page-size-prop",
|
||||
boxed=True,
|
||||
animation_value_type="none",
|
||||
rule_types_allowed=PAGE_RULE,
|
||||
)}
|
|
@ -11,4 +11,4 @@ use crate::values::generics::size::Size2D;
|
|||
pub use generics::page::Orientation;
|
||||
pub use generics::page::PaperSize;
|
||||
/// Computed value of the @page size descriptor
|
||||
pub type PageSize = generics::page::PageSize<Size2D<NonNegativeLength>>;
|
||||
pub type PageSize = generics::page::GenericPageSize<Size2D<NonNegativeLength>>;
|
||||
|
|
|
@ -86,7 +86,7 @@ pub enum Orientation {
|
|||
ToShmem,
|
||||
)]
|
||||
#[repr(C, u8)]
|
||||
pub enum PageSize<S> {
|
||||
pub enum GenericPageSize<S> {
|
||||
/// Page dimensions.
|
||||
Size(S),
|
||||
/// Paper size with no orientation.
|
||||
|
@ -99,6 +99,8 @@ pub enum PageSize<S> {
|
|||
Auto,
|
||||
}
|
||||
|
||||
pub use self::GenericPageSize as PageSize;
|
||||
|
||||
impl<S> PageSize<S> {
|
||||
/// `auto` value.
|
||||
#[inline]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue