style: Move clear CSS property outside mako

closes #21155
This commit is contained in:
Philipp Klein 2018-07-10 09:13:20 +02:00
parent 2bc70e738b
commit 85af4145c3
5 changed files with 82 additions and 56 deletions

View file

@ -67,60 +67,16 @@ ${helpers.predefined_type(
gecko_ffi_name="mFloat" gecko_ffi_name="mFloat"
)} )}
<%helpers:single_keyword ${helpers.predefined_type(
name="clear" "clear",
values="none left right both" "Clear",
// https://drafts.csswg.org/css-logical-props/#float-clear "computed::Clear::None",
extra_specified="inline-start inline-end" animation_value_type="discrete",
needs_conversion="True" needs_context=False,
gecko_inexhaustive="True" gecko_ffi_name="mBreakType",
animation_value_type="discrete" spec="https://drafts.csswg.org/css-box/#propdef-clear",
gecko_enum_prefix="StyleClear"
gecko_ffi_name="mBreakType"
spec="https://drafts.csswg.org/css-box/#propdef-clear"
servo_restyle_damage="rebuild_and_reflow" servo_restyle_damage="rebuild_and_reflow"
> )}
impl ToComputedValue for SpecifiedValue {
type ComputedValue = computed_value::T;
#[inline]
fn to_computed_value(&self, context: &Context) -> computed_value::T {
let ltr = context.style().writing_mode.is_bidi_ltr();
// https://drafts.csswg.org/css-logical-props/#float-clear
match *self {
SpecifiedValue::InlineStart => {
context.rule_cache_conditions.borrow_mut()
.set_writing_mode_dependency(context.builder.writing_mode);
if ltr {
computed_value::T::Left
} else {
computed_value::T::Right
}
}
SpecifiedValue::InlineEnd => {
context.rule_cache_conditions.borrow_mut()
.set_writing_mode_dependency(context.builder.writing_mode);
if ltr {
computed_value::T::Right
} else {
computed_value::T::Left
}
}
% for value in "None Left Right Both".split():
SpecifiedValue::${value} => computed_value::T::${value},
% endfor
}
}
#[inline]
fn from_computed_value(computed: &computed_value::T) -> SpecifiedValue {
match *computed {
% for value in "None Left Right Both".split():
computed_value::T::${value} => SpecifiedValue::${value},
% endfor
}
}
}
</%helpers:single_keyword>
${helpers.predefined_type( ${helpers.predefined_type(
"vertical-align", "vertical-align",

View file

@ -11,7 +11,7 @@ use values::generics::box_::Perspective as GenericPerspective;
use values::generics::box_::VerticalAlign as GenericVerticalAlign; use values::generics::box_::VerticalAlign as GenericVerticalAlign;
pub use values::specified::box_::{AnimationName, Contain, Display, OverflowClipBox}; pub use values::specified::box_::{AnimationName, Contain, Display, OverflowClipBox};
pub use values::specified::box_::Float as SpecifiedFloat; pub use values::specified::box_::{Clear as SpecifiedClear, Float as SpecifiedFloat};
pub use values::specified::box_::{OverscrollBehavior, ScrollSnapType, TouchAction, TransitionProperty, WillChange}; pub use values::specified::box_::{OverscrollBehavior, ScrollSnapType, TouchAction, TransitionProperty, WillChange};
/// A computed value for the `vertical-align` property. /// A computed value for the `vertical-align` property.
@ -83,3 +83,59 @@ impl ToComputedValue for SpecifiedFloat {
} }
} }
} }
#[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq,
SpecifiedValueInfo, ToCss)]
/// A computed value for the `clear` property.
pub enum Clear {
None,
Left,
Right,
Both
}
impl ToComputedValue for SpecifiedClear {
type ComputedValue = Clear;
#[inline]
fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
let ltr = context.style().writing_mode.is_bidi_ltr();
// https://drafts.csswg.org/css-logical-props/#float-clear
match *self {
SpecifiedClear::InlineStart => {
context.rule_cache_conditions.borrow_mut()
.set_writing_mode_dependency(context.builder.writing_mode);
if ltr {
Clear::Left
} else {
Clear::Right
}
},
SpecifiedClear::InlineEnd => {
context.rule_cache_conditions.borrow_mut()
.set_writing_mode_dependency(context.builder.writing_mode);
if ltr {
Clear::Right
} else {
Clear::Left
}
},
SpecifiedClear::None => Clear::None,
SpecifiedClear::Left => Clear::Left,
SpecifiedClear::Right => Clear::Right,
SpecifiedClear::Both => Clear::Both
}
}
#[inline]
fn from_computed_value(computed: &Self::ComputedValue) -> SpecifiedClear {
match *computed {
Clear::None => SpecifiedClear::None,
Clear::Left => SpecifiedClear::Left,
Clear::Right => SpecifiedClear::Right,
Clear::Both => SpecifiedClear::Both,
}
}
}

View file

@ -43,7 +43,7 @@ pub use self::font::{FontFamily, FontLanguageOverride, FontStyle, FontVariantEas
pub use self::font::{FontFeatureSettings, FontVariantLigatures, FontVariantNumeric}; pub use self::font::{FontFeatureSettings, FontVariantLigatures, FontVariantNumeric};
pub use self::font::{MozScriptLevel, MozScriptMinSize, MozScriptSizeMultiplier, XLang, XTextZoom}; pub use self::font::{MozScriptLevel, MozScriptMinSize, MozScriptSizeMultiplier, XLang, XTextZoom};
pub use self::box_::{AnimationIterationCount, AnimationName, Contain, Display, TransitionProperty}; pub use self::box_::{AnimationIterationCount, AnimationName, Contain, Display, TransitionProperty};
pub use self::box_::Float; pub use self::box_::{Clear, Float};
pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective}; pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective};
pub use self::box_::{ScrollSnapType, TouchAction, VerticalAlign, WillChange}; pub use self::box_::{ScrollSnapType, TouchAction, VerticalAlign, WillChange};
pub use self::color::{Color, ColorPropertyValue, RGBAColor}; pub use self::color::{Color, ColorPropertyValue, RGBAColor};

View file

@ -841,3 +841,17 @@ pub enum Float {
InlineStart, InlineStart,
InlineEnd InlineEnd
} }
#[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq,
SpecifiedValueInfo, ToCss)]
pub enum Clear {
None,
Left,
Right,
Both,
// https://drafts.csswg.org/css-logical-props/#float-clear
InlineStart,
InlineEnd
}

View file

@ -38,7 +38,7 @@ pub use self::font::{FontFamily, FontLanguageOverride, FontStyle, FontVariantEas
pub use self::font::{FontFeatureSettings, FontVariantLigatures, FontVariantNumeric}; pub use self::font::{FontFeatureSettings, FontVariantLigatures, FontVariantNumeric};
pub use self::font::{MozScriptLevel, MozScriptMinSize, MozScriptSizeMultiplier, XLang, XTextZoom}; pub use self::font::{MozScriptLevel, MozScriptMinSize, MozScriptSizeMultiplier, XLang, XTextZoom};
pub use self::box_::{AnimationIterationCount, AnimationName, Contain, Display}; pub use self::box_::{AnimationIterationCount, AnimationName, Contain, Display};
pub use self::box_::Float; pub use self::box_::{Clear, Float};
pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective}; pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective};
pub use self::box_::{ScrollSnapType, TouchAction, TransitionProperty, VerticalAlign, WillChange}; pub use self::box_::{ScrollSnapType, TouchAction, TransitionProperty, VerticalAlign, WillChange};
pub use self::color::{Color, ColorPropertyValue, RGBAColor}; pub use self::color::{Color, ColorPropertyValue, RGBAColor};