mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: Add some attributes for SpecifiedValueInfo to help deriving more from types.
Bug: 1434130 Reviewed-by: emilio MozReview-Commit-ID: IyohSTbUO31
This commit is contained in:
parent
0021c70c08
commit
0f7f9eebc0
17 changed files with 137 additions and 36 deletions
|
@ -9,7 +9,7 @@ use cssparser::Parser;
|
|||
use parser::{Parse, ParserContext};
|
||||
use selectors::parser::SelectorParseErrorKind;
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ParseError, SpecifiedValueInfo, StyleParseErrorKind, ToCss};
|
||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
||||
use values::{CustomIdent, KeyframesName};
|
||||
use values::generics::box_::AnimationIterationCount as GenericAnimationIterationCount;
|
||||
use values::generics::box_::Perspective as GenericPerspective;
|
||||
|
@ -298,6 +298,7 @@ impl AnimationIterationCount {
|
|||
/// A value for the `animation-name` property.
|
||||
#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, SpecifiedValueInfo,
|
||||
ToComputedValue)]
|
||||
#[value_info(other_values = "none")]
|
||||
pub struct AnimationName(pub Option<KeyframesName>);
|
||||
|
||||
impl AnimationName {
|
||||
|
@ -420,8 +421,9 @@ impl Parse for WillChange {
|
|||
|
||||
bitflags! {
|
||||
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
|
||||
#[derive(ToComputedValue)]
|
||||
#[derive(SpecifiedValueInfo, ToComputedValue)]
|
||||
/// These constants match Gecko's `NS_STYLE_TOUCH_ACTION_*` constants.
|
||||
#[value_info(other_values = "auto,none,manipulation,pan-x,pan-y")]
|
||||
pub struct TouchAction: u8 {
|
||||
/// `none` variant
|
||||
const TOUCH_ACTION_NONE = 1 << 0;
|
||||
|
@ -493,8 +495,6 @@ impl Parse for TouchAction {
|
|||
}
|
||||
}
|
||||
|
||||
impl SpecifiedValueInfo for TouchAction {}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
impl_bitflags_conversions!(TouchAction);
|
||||
|
||||
|
@ -522,7 +522,8 @@ pub fn assert_touch_action_matches() {
|
|||
}
|
||||
|
||||
bitflags! {
|
||||
#[derive(MallocSizeOf, ToComputedValue)]
|
||||
#[derive(MallocSizeOf, ToComputedValue, SpecifiedValueInfo)]
|
||||
#[value_info(other_values = "none,strict,layout,style,paint")]
|
||||
/// Constants for contain: https://drafts.csswg.org/css-contain/#contain-property
|
||||
pub struct Contain: u8 {
|
||||
/// `layout` variant, turns on layout containment
|
||||
|
@ -605,8 +606,6 @@ impl Parse for Contain {
|
|||
}
|
||||
}
|
||||
|
||||
impl SpecifiedValueInfo for Contain {}
|
||||
|
||||
/// A specified value for the `perspective` property.
|
||||
pub type Perspective = GenericPerspective<NonNegativeLength>;
|
||||
|
||||
|
|
|
@ -1945,9 +1945,11 @@ pub struct FontSynthesis {
|
|||
/// If a `font-weight` is requested that the font family does not contain,
|
||||
/// the user agent may synthesize the requested weight from the weights
|
||||
/// that do exist in the font family.
|
||||
#[value_info(represents_keyword)]
|
||||
pub weight: bool,
|
||||
/// If a font-style is requested that the font family does not contain,
|
||||
/// the user agent may synthesize the requested style from the normal face in the font family.
|
||||
#[value_info(represents_keyword)]
|
||||
pub style: bool,
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ pub struct ImageOrientation {
|
|||
pub angle: Option<Angle>,
|
||||
|
||||
/// Whether or not "flip" was specified
|
||||
#[value_info(other_values = "flip,from-image")]
|
||||
pub flipped: bool,
|
||||
}
|
||||
|
||||
|
|
|
@ -78,9 +78,10 @@ impl Parse for ListStyleType {
|
|||
///
|
||||
/// FIXME(emilio): It's a shame that this allocates all the time it's computed,
|
||||
/// probably should just be refcounted.
|
||||
/// FIXME This can probably derive ToCss.
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo,
|
||||
ToComputedValue)]
|
||||
pub struct Quotes(pub Box<[(Box<str>, Box<str>)]>);
|
||||
pub struct Quotes(#[css(if_empty = "none")] pub Box<[(Box<str>, Box<str>)]>);
|
||||
|
||||
impl ToCss for Quotes {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
|
|
|
@ -570,6 +570,7 @@ pub type GridTemplateComponent = GenericGridTemplateComponent<LengthOrPercentage
|
|||
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo)]
|
||||
/// rect(<top>, <left>, <bottom>, <right>) used by clip and image-region
|
||||
#[css(function = "rect")]
|
||||
pub struct ClipRect {
|
||||
/// <top> (<length> | <auto>)
|
||||
pub top: Option<Length>,
|
||||
|
@ -757,7 +758,9 @@ impl AllowQuirks {
|
|||
/// An attr(...) rule
|
||||
///
|
||||
/// `[namespace? `|`]? ident`
|
||||
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue)]
|
||||
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo,
|
||||
ToComputedValue)]
|
||||
#[css(function)]
|
||||
pub struct Attr {
|
||||
/// Optional namespace prefix and URL.
|
||||
pub namespace: Option<(Prefix, Namespace)>,
|
||||
|
@ -852,5 +855,3 @@ impl ToCss for Attr {
|
|||
dest.write_str(")")
|
||||
}
|
||||
}
|
||||
|
||||
impl SpecifiedValueInfo for Attr {}
|
||||
|
|
|
@ -431,6 +431,7 @@ pub struct GridAutoFlow {
|
|||
/// Specifiy how auto-placement algorithm fills each `row` or `column` in turn
|
||||
pub autoflow: AutoFlow,
|
||||
/// Specify use `dense` packing algorithm or not
|
||||
#[value_info(represents_keyword)]
|
||||
pub dense: bool,
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
use cssparser::Parser;
|
||||
use parser::{Parse, ParserContext};
|
||||
use selectors::parser::SelectorParseErrorKind;
|
||||
use style_traits::{CssType, ParseError, SpecifiedValueInfo, StyleParseErrorKind};
|
||||
use style_traits::{ParseError, StyleParseErrorKind};
|
||||
use values::computed::{Context, LengthOrPercentage as ComputedLengthOrPercentage};
|
||||
use values::computed::{Percentage as ComputedPercentage, ToComputedValue};
|
||||
use values::computed::transform::TimingFunction as ComputedTimingFunction;
|
||||
|
@ -246,10 +246,6 @@ pub enum OriginComponent<S> {
|
|||
/// A specified timing function.
|
||||
pub type TimingFunction = generic::TimingFunction<Integer, Number>;
|
||||
|
||||
impl SpecifiedValueInfo for TimingFunction {
|
||||
const SUPPORTED_TYPES: u8 = CssType::TIMING_FUNCTION;
|
||||
}
|
||||
|
||||
impl Parse for TransformOrigin {
|
||||
fn parse<'i, 't>(
|
||||
context: &ParserContext,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue