style: use the same type for overflow-clip-box longhands.

Needed to add the hacky padding_box scheme, will fix it up later.
This commit is contained in:
Emilio Cobos Álvarez 2017-12-05 19:00:14 +01:00
parent cdf7ae51b6
commit 35d0e7cf0f
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
7 changed files with 64 additions and 54 deletions

View file

@ -3098,6 +3098,7 @@ fn static_assert() {
scroll-snap-type-x scroll-snap-type-y scroll-snap-coordinate
perspective-origin -moz-binding will-change
overscroll-behavior-x overscroll-behavior-y
overflow-clip-box-inline overflow-clip-box-block
perspective-origin -moz-binding will-change
shape-outside contain touch-action""" %>
<%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}">
@ -3491,6 +3492,10 @@ fn static_assert() {
${impl_keyword('overscroll_behavior_x', 'mOverscrollBehaviorX', overscroll_behavior_keyword)}
${impl_keyword('overscroll_behavior_y', 'mOverscrollBehaviorY', overscroll_behavior_keyword)}
<% overflow_clip_box_keyword = Keyword("overflow-clip-box", "padding-box content-box") %>
${impl_keyword('overflow_clip_box_inline', 'mOverflowClipBoxInline', overflow_clip_box_keyword)}
${impl_keyword('overflow_clip_box_block', 'mOverflowClipBoxBlock', overflow_clip_box_keyword)}
pub fn set_perspective_origin(&mut self, v: longhands::perspective_origin::computed_value::T) {
self.gecko.mPerspectiveOrigin[0].set(v.horizontal);
self.gecko.mPerspectiveOrigin[1].set(v.vertical);

View file

@ -373,21 +373,21 @@ ${helpers.single_keyword("-servo-overflow-clip-box", "padding-box content-box",
spec="Internal, not web-exposed, \
may be standardized in the future (https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-clip-box)")}
${helpers.single_keyword("overflow-clip-box-block", "padding-box content-box",
products="gecko", animation_value_type="discrete", enabled_in="ua",
gecko_pref="layout.css.overflow-clip-box.enabled",
gecko_constant_prefix="NS_STYLE_OVERFLOW_CLIP_BOX",
% for direction in ["inline", "block"]:
${helpers.predefined_type(
"overflow-clip-box-" + direction,
"OverflowClipBox",
"computed::OverflowClipBox::padding_box",
products="gecko",
enabled_in="ua",
needs_context=False,
flags="APPLIES_TO_PLACEHOLDER",
spec="Internal, not web-exposed, \
may be standardized in the future (https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-clip-box)")}
${helpers.single_keyword("overflow-clip-box-inline", "padding-box content-box",
products="gecko", animation_value_type="discrete", enabled_in="ua",
gecko_pref="layout.css.overflow-clip-box.enabled",
gecko_constant_prefix="NS_STYLE_OVERFLOW_CLIP_BOX",
flags="APPLIES_TO_PLACEHOLDER",
spec="Internal, not web-exposed, \
may be standardized in the future (https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-clip-box)")}
gecko_pref="layout.css.overscroll-behavior.enabled",
animation_value_type="discrete",
spec="Internal, may be standardized in the future: \
https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-clip-box",
)}
% endfor
<%
overflow_custom_consts = { "-moz-hidden-unscrollable": "CLIP" }

View file

@ -58,27 +58,23 @@
}
</%helpers:shorthand>
<%helpers:shorthand name="overflow-clip-box" sub_properties="overflow-clip-box-block overflow-clip-box-inline"
enabled_in="ua" gecko_pref="layout.css.overflow-clip-box.enabled"
spec="Internal, not web-exposed, may be standardized in the future (https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-clip-box)"
products="gecko">
use properties::longhands::{overflow_clip_box_block, overflow_clip_box_inline};
pub fn to_inline_value(block_value: overflow_clip_box_block::SpecifiedValue)
-> overflow_clip_box_inline::SpecifiedValue {
match block_value {
overflow_clip_box_block::SpecifiedValue::padding_box =>
overflow_clip_box_inline::SpecifiedValue::padding_box,
overflow_clip_box_block::SpecifiedValue::content_box =>
overflow_clip_box_inline::SpecifiedValue::content_box
}
}
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
-> Result<Longhands, ParseError<'i>> {
let block_value = overflow_clip_box_block::parse(context, input)?;
let inline_value = input.try(|input| overflow_clip_box_inline::parse(context, input)).unwrap_or(
to_inline_value(block_value));
<%helpers:shorthand
name="overflow-clip-box"
sub_properties="overflow-clip-box-block overflow-clip-box-inline"
enabled_in="ua"
gecko_pref="layout.css.overflow-clip-box.enabled"
spec="Internal, may be standardized in the future "
"(https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-clip-box)"
products="gecko"
>
use values::specified::OverflowClipBox;
pub fn parse_value<'i, 't>(
_: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Longhands, ParseError<'i>> {
let block_value = OverflowClipBox::parse(input)?;
let inline_value =
input.try(|input| OverflowClipBox::parse(input)).unwrap_or(block_value);
Ok(expanded! {
overflow_clip_box_block: block_value,
@ -88,16 +84,16 @@
impl<'a> ToCss for LonghandsToSerialize<'a> {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
if to_inline_value(*self.overflow_clip_box_block) == *self.overflow_clip_box_inline {
self.overflow_clip_box_block.to_css(dest)
} else {
self.overflow_clip_box_block.to_css(dest)?;
if self.overflow_clip_box_block != self.overflow_clip_box_inline {
dest.write_str(" ")?;
self.overflow_clip_box_inline.to_css(dest)
}
}
self.overflow_clip_box_inline.to_css(dest)?;
}
Ok(())
}
}
</%helpers:shorthand>
macro_rules! try_parse_one {

View file

@ -9,7 +9,7 @@ use values::computed::length::LengthOrPercentage;
use values::generics::box_::AnimationIterationCount as GenericAnimationIterationCount;
use values::generics::box_::VerticalAlign as GenericVerticalAlign;
pub use values::specified::box_::{AnimationName, OverscrollBehavior, ScrollSnapType};
pub use values::specified::box_::{AnimationName, OverflowClipBox, OverscrollBehavior, ScrollSnapType};
/// A computed value for the `vertical-align` property.
pub type VerticalAlign = GenericVerticalAlign<LengthOrPercentage>;

View file

@ -40,7 +40,8 @@ pub use self::font::{FontSize, FontSizeAdjust, FontSynthesis, FontWeight, FontVa
pub use self::font::{FontFamily, FontLanguageOverride, FontVariantSettings, FontVariantEastAsian};
pub use self::font::{FontVariantLigatures, FontVariantNumeric, FontFeatureSettings};
pub use self::font::{MozScriptLevel, MozScriptMinSize, MozScriptSizeMultiplier, XTextZoom, XLang};
pub use self::box_::{AnimationIterationCount, AnimationName, OverscrollBehavior, ScrollSnapType, VerticalAlign};
pub use self::box_::{AnimationIterationCount, AnimationName, OverscrollBehavior};
pub use self::box_::{OverflowClipBox, ScrollSnapType, VerticalAlign};
pub use self::color::{Color, ColorPropertyValue, RGBAColor};
pub use self::effects::{BoxShadow, Filter, SimpleShadow};
pub use self::flex::FlexBasis;

View file

@ -124,3 +124,10 @@ define_css_keyword_enum! { OverscrollBehavior:
"none" => None,
}
add_impls_for_keyword_enum!(OverscrollBehavior);
// FIXME(emilio): Make all keywords CamelCase.
define_css_keyword_enum! { OverflowClipBox:
"padding-box" => padding_box,
"content-box" => content_box,
}
add_impls_for_keyword_enum!(OverflowClipBox);

View file

@ -34,7 +34,8 @@ pub use self::font::{FontSize, FontSizeAdjust, FontSynthesis, FontWeight, FontVa
pub use self::font::{FontFamily, FontLanguageOverride, FontVariantSettings, FontVariantEastAsian};
pub use self::font::{FontVariantLigatures, FontVariantNumeric, FontFeatureSettings};
pub use self::font::{MozScriptLevel, MozScriptMinSize, MozScriptSizeMultiplier, XTextZoom, XLang};
pub use self::box_::{AnimationIterationCount, AnimationName, OverscrollBehavior, ScrollSnapType, VerticalAlign};
pub use self::box_::{AnimationIterationCount, AnimationName, OverscrollBehavior};
pub use self::box_::{OverflowClipBox, ScrollSnapType, VerticalAlign};
pub use self::color::{Color, ColorPropertyValue, RGBAColor};
pub use self::effects::{BoxShadow, Filter, SimpleShadow};
pub use self::flex::FlexBasis;