Bug 1386963 - Part 2: make image-orientation animatable. r?hiro
MozReview-Commit-ID: F2Pw7nlaH1n
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -4541,16 +4541,41 @@ fn static_assert() {
unsafe {
bindings::Gecko_CopyImageOrientationFrom(&mut self.gecko, &other.gecko);
}
}
pub fn reset_image_orientation(&mut self, other: &Self) {
self.copy_image_orientation_from(other)
}
+
+ pub fn clone_image_orientation(&self) -> longhands::image_orientation::computed_value::T {
+ use gecko_bindings::structs::{nsStyleImageOrientation_Bits, nsStyleImageOrientation_Angles};
+ use properties::longhands::image_orientation::computed_value::{Orientation, T};
+
+ let gecko_orientation = self.gecko.mImageOrientation.mOrientation;
+ if gecko_orientation & nsStyleImageOrientation_Bits::FROM_IMAGE_MASK as u8 != 0 {
+ T::FromImage
+ } else {
+ const ANGLE0: u8 = nsStyleImageOrientation_Angles::ANGLE_0 as u8;
+ const ANGLE90: u8 = nsStyleImageOrientation_Angles::ANGLE_90 as u8;
+ const ANGLE180: u8 = nsStyleImageOrientation_Angles::ANGLE_180 as u8;
+ const ANGLE270: u8 = nsStyleImageOrientation_Angles::ANGLE_270 as u8;
+
+ let flip = gecko_orientation & nsStyleImageOrientation_Bits::FLIP_MASK as u8 != 0;
+ let orientation = match gecko_orientation & nsStyleImageOrientation_Bits::ORIENTATION_MASK as u8 {
+ ANGLE0 => Orientation::Angle0,
+ ANGLE90 => Orientation::Angle90,
+ ANGLE180 => Orientation::Angle180,
+ ANGLE270 => Orientation::Angle270,
+ _ => unreachable!()
+ };
+ T::AngleWithFlipped(orientation, flip)
+ }
+ }
</%self:impl_trait>
<%self:impl_trait style_struct_name="InheritedTable"
skip_longhands="border-spacing">
pub fn set_border_spacing(&mut self, v: longhands::border_spacing::computed_value::T) {
self.gecko.mBorderSpacingCol = v.horizontal.0;
self.gecko.mBorderSpacingRow = v.vertical.0;
--- a/servo/components/style/properties/longhand/inherited_box.mako.rs
+++ b/servo/components/style/properties/longhand/inherited_box.mako.rs
@@ -54,17 +54,17 @@
extra_servo_values="pixelated crisp-edges",
custom_consts=image_rendering_custom_consts,
animation_value_type="discrete",
spec="https://drafts.csswg.org/css-images/#propdef-image-rendering")}
// Image Orientation
<%helpers:longhand name="image-orientation"
products="gecko"
- animation_value_type="none"
+ animation_value_type="discrete"
spec="https://drafts.csswg.org/css-images/#propdef-image-orientation, \
/// additional values in https://developer.mozilla.org/en-US/docs/Web/CSS/image-orientation">
use std::fmt;
use style_traits::ToCss;
use values::specified::Angle;
no_viewport_percentage!(SpecifiedValue);