Skip to content

Commit

Permalink
implements u8 and array type properties animatable
Browse files Browse the repository at this point in the history
  • Loading branch information
dadaa committed Jul 5, 2017
1 parent 0107b3e commit b3def4a
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 5 deletions.
70 changes: 70 additions & 0 deletions components/style/properties/gecko.mako.rs
Expand Up @@ -2862,6 +2862,25 @@ fn static_assert() {
}
}

pub fn clone_will_change(&self) -> longhands::will_change::computed_value::T {
use properties::longhands::will_change::computed_value::T;
use gecko_bindings::structs::nsIAtom;
use gecko_string_cache::Atom;
use values::CustomIdent;

if self.gecko.mWillChange.mBuffer.len() == 0 {
T::Auto
} else {
T::AnimateableFeatures(
self.gecko.mWillChange.mBuffer.iter().map(|gecko_atom| {
CustomIdent(
unsafe { Atom::from_addrefed(*gecko_atom as *mut nsIAtom) }
)
}).collect()
)
}
}

<% impl_shape_source("shape_outside", "mShapeOutside") %>

pub fn set_contain(&mut self, v: longhands::contain::computed_value::T) {
Expand Down Expand Up @@ -3078,6 +3097,30 @@ fn static_assert() {
}
</%self:simple_image_array_property>

pub fn clone_${shorthand}_repeat(&self) -> longhands::${shorthand}_repeat::computed_value::T {
use properties::longhands::${shorthand}_repeat::single_value::computed_value::T;
use properties::longhands::${shorthand}_repeat::single_value::computed_value::RepeatKeyword;
use gecko_bindings::structs::StyleImageLayerRepeat;

fn to_servo(repeat: StyleImageLayerRepeat) -> RepeatKeyword {
match repeat {
StyleImageLayerRepeat::Repeat => RepeatKeyword::Repeat,
StyleImageLayerRepeat::Space => RepeatKeyword::Space,
StyleImageLayerRepeat::Round => RepeatKeyword::Round,
StyleImageLayerRepeat::NoRepeat => RepeatKeyword::NoRepeat,
x => panic!("Found unexpected value in style struct for ${shorthand}_repeat property: {:?}", x),
}
}

longhands::${shorthand}_repeat::computed_value::T (
self.gecko.${image_layers_field}.mLayers.iter()
.take(self.gecko.${image_layers_field}.mRepeatCount as usize)
.map(|ref layer| {
T(to_servo(layer.mRepeat.mXRepeat), to_servo(layer.mRepeat.mYRepeat))
}).collect()
)
}

<% impl_simple_image_array_property("clip", shorthand, image_layers_field, "mClip", struct_name) %>
<% impl_simple_image_array_property("origin", shorthand, image_layers_field, "mOrigin", struct_name) %>

Expand Down Expand Up @@ -3918,6 +3961,33 @@ fn static_assert() {
self.gecko.mTextEmphasisStyle = other.gecko.mTextEmphasisStyle;
}

pub fn clone_text_emphasis_style(&self) -> longhands::text_emphasis_style::computed_value::T {
use properties::longhands::text_emphasis_style::computed_value::{T, KeywordValue};
use properties::longhands::text_emphasis_style::ShapeKeyword;

if self.gecko.mTextEmphasisStyle == structs::NS_STYLE_TEXT_EMPHASIS_STYLE_NONE as u8 {
return T::None;
} else if self.gecko.mTextEmphasisStyle == structs::NS_STYLE_TEXT_EMPHASIS_STYLE_STRING as u8 {
return T::String(self.gecko.mTextEmphasisStyleString.to_string());
}

let fill = self.gecko.mTextEmphasisStyle & structs::NS_STYLE_TEXT_EMPHASIS_STYLE_OPEN as u8 == 0;
let shape =
match self.gecko.mTextEmphasisStyle as u32 & !structs::NS_STYLE_TEXT_EMPHASIS_STYLE_OPEN {
structs::NS_STYLE_TEXT_EMPHASIS_STYLE_DOT => ShapeKeyword::Dot,
structs::NS_STYLE_TEXT_EMPHASIS_STYLE_CIRCLE => ShapeKeyword::Circle,
structs::NS_STYLE_TEXT_EMPHASIS_STYLE_DOUBLE_CIRCLE => ShapeKeyword::DoubleCircle,
structs::NS_STYLE_TEXT_EMPHASIS_STYLE_TRIANGLE => ShapeKeyword::Triangle,
structs::NS_STYLE_TEXT_EMPHASIS_STYLE_SESAME => ShapeKeyword::Sesame,
x => panic!("Unexpected value in style struct for text-emphasis-style property: {:?}", x)
};

T::Keyword(KeywordValue {
fill: fill,
shape: shape
})
}

<%call expr="impl_app_units('_webkit_text_stroke_width', 'mWebkitTextStrokeWidth', need_clone=True)"></%call>

#[allow(non_snake_case)]
Expand Down
2 changes: 1 addition & 1 deletion components/style/properties/longhand/background.mako.rs
Expand Up @@ -31,7 +31,7 @@ ${helpers.predefined_type("background-image", "ImageLayer",
animation_value_type="ComputedValue", vector=True, delegate_animate=True)}
% endfor

<%helpers:vector_longhand name="background-repeat" animation_value_type="none"
<%helpers:vector_longhand name="background-repeat" animation_value_type="discrete"
spec="https://drafts.csswg.org/css-backgrounds/#the-background-repeat">
use std::fmt;
use style_traits::ToCss;
Expand Down
2 changes: 1 addition & 1 deletion components/style/properties/longhand/box.mako.rs
Expand Up @@ -1874,7 +1874,7 @@ ${helpers.single_keyword("-moz-orient",
gecko_inexhaustive="True",
animation_value_type="discrete")}

<%helpers:longhand name="will-change" products="gecko" animation_value_type="none"
<%helpers:longhand name="will-change" products="gecko" animation_value_type="discrete"
spec="https://drafts.csswg.org/css-will-change/#will-change">
use std::fmt;
use style_traits::ToCss;
Expand Down
4 changes: 2 additions & 2 deletions components/style/properties/longhand/inherited_text.mako.rs
Expand Up @@ -417,8 +417,8 @@ ${helpers.predefined_type(
spec="https://drafts.csswg.org/css-text-decor-3/#text-shadow-property",
)}

<%helpers:longhand name="text-emphasis-style" products="gecko" need_clone="True" boxed="True"
animation_value_type="none"
<%helpers:longhand name="text-emphasis-style" products="gecko" boxed="True"
animation_value_type="discrete"
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-emphasis-style">
use computed_values::writing_mode::T as writing_mode;
use std::fmt;
Expand Down
2 changes: 1 addition & 1 deletion components/style/properties/longhand/svg.mako.rs
Expand Up @@ -70,7 +70,7 @@ ${helpers.single_keyword("mask-mode",
animation_value_type="discrete",
spec="https://drafts.fxtf.org/css-masking/#propdef-mask-mode")}

<%helpers:vector_longhand name="mask-repeat" products="gecko" animation_value_type="none" extra_prefixes="webkit"
<%helpers:vector_longhand name="mask-repeat" products="gecko" animation_value_type="discrete" extra_prefixes="webkit"
spec="https://drafts.fxtf.org/css-masking/#propdef-mask-repeat">
pub use properties::longhands::background_repeat::single_value::parse;
pub use properties::longhands::background_repeat::single_value::SpecifiedValue;
Expand Down

0 comments on commit b3def4a

Please sign in to comment.