From f34b9e2317df508f936739615a60551c5c7d19e7 Mon Sep 17 00:00:00 2001 From: Boris Chiou Date: Thu, 8 Jun 2017 11:54:49 +0800 Subject: [PATCH 1/5] Make -moz-tab-size animatable. --- components/style/properties/gecko.mako.rs | 11 +++++++++++ .../style/properties/longhand/inherited_text.mako.rs | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 3c0b57c9fe0..fe8b2de3499 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -3790,6 +3790,17 @@ fn static_assert() { } } + #[allow(non_snake_case)] + pub fn clone__moz_tab_size(&self) -> longhands::_moz_tab_size::computed_value::T { + use values::Either; + + match self.gecko.mTabSize.as_value() { + CoordDataValue::Coord(coord) => Either::First(Au(coord)), + CoordDataValue::Factor(number) => Either::Second(number), + _ => unreachable!(), + } + } + <%call expr="impl_coord_copy('_moz_tab_size', 'mTabSize')"> <% text_size_adjust_keyword = Keyword("text-size-adjust", "auto none") %> diff --git a/components/style/properties/longhand/inherited_text.mako.rs b/components/style/properties/longhand/inherited_text.mako.rs index 9b4004712ec..70a3710b161 100644 --- a/components/style/properties/longhand/inherited_text.mako.rs +++ b/components/style/properties/longhand/inherited_text.mako.rs @@ -698,7 +698,7 @@ ${helpers.predefined_type( "-moz-tab-size", "LengthOrNumber", "::values::Either::Second(8.0)", "parse_non_negative", - products="gecko", animation_value_type="none", + products="gecko", animation_value_type="ComputedValue", spec="https://drafts.csswg.org/css-text-3/#tab-size-property")} From b3f9cb55f68b7782a73b4ce5d13e366cb599cc22 Mon Sep 17 00:00:00 2001 From: Boris Chiou Date: Thu, 8 Jun 2017 12:53:18 +0800 Subject: [PATCH 2/5] Make -moz-box-flex animatable. --- components/style/properties/longhand/xul.mako.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/style/properties/longhand/xul.mako.rs b/components/style/properties/longhand/xul.mako.rs index 34b3de89e0b..9573a2a6c38 100644 --- a/components/style/properties/longhand/xul.mako.rs +++ b/components/style/properties/longhand/xul.mako.rs @@ -26,7 +26,7 @@ ${helpers.single_keyword("-moz-box-direction", "normal reverse", ${helpers.predefined_type("-moz-box-flex", "Number", "0.0", "parse_non_negative", products="gecko", gecko_ffi_name="mBoxFlex", - animation_value_type="none", + animation_value_type="ComputedValue", alias="-webkit-box-flex", spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/box-flex)")} From 4e78755303836beede24f475b31620e7ae6aa079 Mon Sep 17 00:00:00 2001 From: Boris Chiou Date: Thu, 8 Jun 2017 15:19:25 +0800 Subject: [PATCH 3/5] Make -moz-image-region animatable. --- components/style/properties/gecko.mako.rs | 32 +++++++++++++++++++ .../style/properties/longhand/list.mako.rs | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index fe8b2de3499..18f2e3fa27e 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -3333,6 +3333,38 @@ fn static_assert() { } } + #[allow(non_snake_case)] + pub fn clone__moz_image_region(&self) -> longhands::_moz_image_region::computed_value::T { + use values::{Auto, Either}; + use values::computed::ClipRect; + + // There is no ideal way to detect auto type for structs::nsRect and its components, so + // if all components are zero, we use Auto. + if self.gecko.mImageRegion.x == 0 && + self.gecko.mImageRegion.y == 0 && + self.gecko.mImageRegion.width == 0 && + self.gecko.mImageRegion.height == 0 { + return Either::Second(Auto); + } + + let get_clip_rect_component = |value: structs::nscoord| -> Option { + if value == 0 { + None + } else { + Some(Au(value)) + } + }; + + Either::First(ClipRect { + top: get_clip_rect_component(self.gecko.mImageRegion.y), + right: get_clip_rect_component(self.gecko.mImageRegion.width).map( + |v| v + Au(self.gecko.mImageRegion.x)), + bottom: get_clip_rect_component(self.gecko.mImageRegion.height).map( + |v| v + Au(self.gecko.mImageRegion.y)), + left: get_clip_rect_component(self.gecko.mImageRegion.x), + }) + } + ${impl_simple_copy('_moz_image_region', 'mImageRegion')} diff --git a/components/style/properties/longhand/list.mako.rs b/components/style/properties/longhand/list.mako.rs index 34f51b97b9d..620695f3eba 100644 --- a/components/style/properties/longhand/list.mako.rs +++ b/components/style/properties/longhand/list.mako.rs @@ -228,7 +228,7 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu ${helpers.predefined_type("-moz-image-region", "ClipRectOrAuto", "computed::ClipRectOrAuto::auto()", - animation_value_type="none", + animation_value_type="ComputedValue", products="gecko", boxed="True", spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-image-region)")} From e517d21de85697532dbb0b6da7484f723ff73559 Mon Sep 17 00:00:00 2001 From: Boris Chiou Date: Thu, 8 Jun 2017 18:21:40 +0800 Subject: [PATCH 4/5] Set zero to mImageRegion.{height,width} if {bottom,right} is auto. Let's follow how Gecko does for this part (in nsRuleNode::ComputeListData). We set mImageRegion.height or mImageRegion.width to zero if bottom or right is None (i.e. auto). --- components/style/properties/gecko.mako.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 18f2e3fa27e..7585b0e9c3d 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -3327,8 +3327,14 @@ fn static_assert() { Either::First(rect) => { self.gecko.mImageRegion.x = rect.left.unwrap_or(Au(0)).0; self.gecko.mImageRegion.y = rect.top.unwrap_or(Au(0)).0; - self.gecko.mImageRegion.height = rect.bottom.unwrap_or(Au(0)).0 - self.gecko.mImageRegion.y; - self.gecko.mImageRegion.width = rect.right.unwrap_or(Au(0)).0 - self.gecko.mImageRegion.x; + self.gecko.mImageRegion.height = match rect.bottom { + Some(value) => value.0 - self.gecko.mImageRegion.y, + None => 0, + }; + self.gecko.mImageRegion.width = match rect.right { + Some(value) => value.0 - self.gecko.mImageRegion.x, + None => 0, + }; } } } From 5c915bd4aebf936550ae7b8a3b4ea7a7dcd55b7c Mon Sep 17 00:00:00 2001 From: Boris Chiou Date: Fri, 9 Jun 2017 01:24:51 +0800 Subject: [PATCH 5/5] Make -moz-outline-radius-{*} animatable. --- components/style/properties/gecko.mako.rs | 5 +++-- components/style/properties/longhand/outline.mako.rs | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 7585b0e9c3d..33ba3c41443 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -574,7 +574,7 @@ fn color_to_nscolor_zero_currentcolor(color: Color) -> structs::nscolor { % endif -<%def name="impl_corner_style_coord(ident, gecko_ffi_name, x_index, y_index, need_clone=False)"> +<%def name="impl_corner_style_coord(ident, gecko_ffi_name, x_index, y_index, need_clone)"> #[allow(non_snake_case)] pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) { v.0.width.to_gecko_style_coord(&mut self.gecko.${gecko_ffi_name}.data_at_mut(${x_index})); @@ -1494,7 +1494,8 @@ fn static_assert() { <% impl_corner_style_coord("_moz_outline_radius_%s" % corner.ident.replace("_", ""), "mOutlineRadius", corner.x_index, - corner.y_index) %> + corner.y_index, + need_clone=True) %> % endfor pub fn outline_has_nonzero_width(&self) -> bool { diff --git a/components/style/properties/longhand/outline.mako.rs b/components/style/properties/longhand/outline.mako.rs index 1640953e305..bd0f8e5ecbd 100644 --- a/components/style/properties/longhand/outline.mako.rs +++ b/components/style/properties/longhand/outline.mako.rs @@ -70,13 +70,12 @@ ${helpers.predefined_type("outline-width", spec="https://drafts.csswg.org/css-ui/#propdef-outline-width")} // The -moz-outline-radius-* properties are non-standard and not on a standards track. -// TODO: Should they animate? % for corner in ["topleft", "topright", "bottomright", "bottomleft"]: ${helpers.predefined_type("-moz-outline-radius-" + corner, "BorderCornerRadius", "computed::LengthOrPercentage::zero().into()", products="gecko", boxed=True, - animation_value_type="none", + animation_value_type="ComputedValue", spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-outline-radius)")} % endfor