mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Implement parsing of the page property
Differential Revision: https://phabricator.services.mozilla.com/D131531
This commit is contained in:
parent
4fe31d5d84
commit
d1bb131acc
6 changed files with 56 additions and 6 deletions
|
@ -38,7 +38,6 @@ COUNTED_UNKNOWN_PROPERTIES = [
|
|||
"-webkit-writing-mode",
|
||||
"baseline-shift",
|
||||
"-webkit-hyphenate-character",
|
||||
"page",
|
||||
"-webkit-highlight",
|
||||
"background-repeat-x",
|
||||
"-webkit-padding-end",
|
||||
|
|
|
@ -19,3 +19,13 @@ ${helpers.predefined_type(
|
|||
animation_value_type="none",
|
||||
rule_types_allowed=PAGE_RULE,
|
||||
)}
|
||||
|
||||
${helpers.predefined_type(
|
||||
"page",
|
||||
"PageName",
|
||||
"computed::PageName::auto()",
|
||||
engines="gecko",
|
||||
gecko_pref="layout.css.named-pages.enabled",
|
||||
spec="https://drafts.csswg.org/css-page-3/#using-named-pages",
|
||||
animation_value_type="discrete",
|
||||
)}
|
||||
|
|
|
@ -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::{Orientation, PageSize, PaperSize};
|
||||
pub use self::page::{Orientation, PageName, PageSize, PaperSize};
|
||||
pub use self::percentage::{NonNegativePercentage, Percentage};
|
||||
pub use self::position::AspectRatio;
|
||||
pub use self::position::{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* 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/. */
|
||||
|
||||
//! Computed @page at-rule properties
|
||||
//! Computed @page at-rule properties and named-page style properties
|
||||
|
||||
use crate::values::computed::length::NonNegativeLength;
|
||||
use crate::values::computed::{Context, ToComputedValue};
|
||||
|
@ -13,6 +13,7 @@ use crate::values::specified::page as specified;
|
|||
pub use generics::page::GenericPageSize;
|
||||
pub use generics::page::Orientation;
|
||||
pub use generics::page::PaperSize;
|
||||
pub use specified::PageName;
|
||||
|
||||
/// Computed value of the @page size descriptor
|
||||
///
|
||||
|
|
|
@ -69,7 +69,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::{Orientation, PageSize, PaperSize};
|
||||
pub use self::page::{Orientation, PageName, PageSize, PaperSize};
|
||||
pub use self::percentage::{NonNegativePercentage, Percentage};
|
||||
pub use self::position::AspectRatio;
|
||||
pub use self::position::{
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
* 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/. */
|
||||
|
||||
//! Specified @page at-rule properties
|
||||
//! Specified @page at-rule properties and named-page style properties
|
||||
|
||||
use crate::parser::{Parse, ParserContext};
|
||||
use crate::values::generics;
|
||||
use crate::values::{generics, CustomIdent};
|
||||
use crate::values::generics::size::Size2D;
|
||||
use crate::values::specified::length::NonNegativeLength;
|
||||
use cssparser::Parser;
|
||||
|
@ -46,3 +46,43 @@ impl Parse for PageSize {
|
|||
Ok(PageSize::Auto)
|
||||
}
|
||||
}
|
||||
|
||||
/// Page name value.
|
||||
///
|
||||
/// https://drafts.csswg.org/css-page-3/#using-named-pages
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss, ToComputedValue, ToResolvedValue, ToShmem)]
|
||||
#[repr(C, u8)]
|
||||
pub enum PageName {
|
||||
/// `auto` value.
|
||||
Auto,
|
||||
/// Page name value
|
||||
PageName(CustomIdent),
|
||||
}
|
||||
|
||||
impl Parse for PageName {
|
||||
fn parse<'i, 't>(
|
||||
_context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
let location = input.current_source_location();
|
||||
let ident = input.expect_ident()?;
|
||||
Ok(match_ignore_ascii_case! { ident,
|
||||
"auto" => PageName::auto(),
|
||||
_ => PageName::PageName(CustomIdent::from_ident(location, ident, &[])?),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl PageName {
|
||||
/// `auto` value.
|
||||
#[inline]
|
||||
pub fn auto() -> Self {
|
||||
PageName::Auto
|
||||
}
|
||||
|
||||
/// Whether this is the `auto` value.
|
||||
#[inline]
|
||||
pub fn is_auto(&self) -> bool {
|
||||
matches!(*self, PageName::Auto)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue