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",
|
"-webkit-writing-mode",
|
||||||
"baseline-shift",
|
"baseline-shift",
|
||||||
"-webkit-hyphenate-character",
|
"-webkit-hyphenate-character",
|
||||||
"page",
|
|
||||||
"-webkit-highlight",
|
"-webkit-highlight",
|
||||||
"background-repeat-x",
|
"background-repeat-x",
|
||||||
"-webkit-padding-end",
|
"-webkit-padding-end",
|
||||||
|
|
|
@ -19,3 +19,13 @@ ${helpers.predefined_type(
|
||||||
animation_value_type="none",
|
animation_value_type="none",
|
||||||
rule_types_allowed=PAGE_RULE,
|
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::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::{Orientation, PageSize, PaperSize};
|
pub use self::page::{Orientation, PageName, PageSize, 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::{
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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::length::NonNegativeLength;
|
||||||
use crate::values::computed::{Context, ToComputedValue};
|
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::GenericPageSize;
|
||||||
pub use generics::page::Orientation;
|
pub use generics::page::Orientation;
|
||||||
pub use generics::page::PaperSize;
|
pub use generics::page::PaperSize;
|
||||||
|
pub use specified::PageName;
|
||||||
|
|
||||||
/// Computed value of the @page size descriptor
|
/// Computed value of the @page size descriptor
|
||||||
///
|
///
|
||||||
|
|
|
@ -69,7 +69,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::{Orientation, PageSize, PaperSize};
|
pub use self::page::{Orientation, PageName, PageSize, 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::{
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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::parser::{Parse, ParserContext};
|
||||||
use crate::values::generics;
|
use crate::values::{generics, CustomIdent};
|
||||||
use crate::values::generics::size::Size2D;
|
use crate::values::generics::size::Size2D;
|
||||||
use crate::values::specified::length::NonNegativeLength;
|
use crate::values::specified::length::NonNegativeLength;
|
||||||
use cssparser::Parser;
|
use cssparser::Parser;
|
||||||
|
@ -46,3 +46,43 @@ impl Parse for PageSize {
|
||||||
Ok(PageSize::Auto)
|
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