Add gecko glue for perspective and perspective-origin.

This commit is contained in:
Nazım Can Altınova 2016-12-23 19:29:50 +03:00
parent aeb5d34394
commit ed7945e747
3 changed files with 28 additions and 4 deletions

View file

@ -10,7 +10,7 @@ use gecko_bindings::structs::{NS_RADIUS_CLOSEST_SIDE, NS_RADIUS_FARTHEST_SIDE};
use gecko_bindings::structs::nsStyleCoord;
use gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue};
use std::cmp::max;
use values::{Auto, Either};
use values::{Auto, Either, None_};
use values::computed::{Angle, LengthOrPercentageOrNone, Number};
use values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto};
use values::computed::basic_shape::ShapeRadius;
@ -201,6 +201,20 @@ impl GeckoStyleCoordConvertible for Auto {
}
}
impl GeckoStyleCoordConvertible for None_ {
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
coord.set_value(CoordDataValue::None)
}
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
if let CoordDataValue::None = coord.as_value() {
Some(None_)
} else {
None
}
}
}
pub fn convert_rgba_to_nscolor(rgba: &RGBA) -> u32 {
(((rgba.alpha * 255.0).round() as u32) << 24) |
(((rgba.blue * 255.0).round() as u32) << 16) |

View file

@ -505,6 +505,7 @@ impl Debug for ${style_struct.gecko_struct_name} {
"LengthOrPercentage": impl_style_coord,
"LengthOrPercentageOrAuto": impl_style_coord,
"LengthOrPercentageOrNone": impl_style_coord,
"LengthOrNone": impl_style_coord,
"Number": impl_simple,
"Opacity": impl_simple,
"CSSColor": impl_color,
@ -1053,7 +1054,7 @@ fn static_assert() {
<% skip_box_longhands= """display overflow-y vertical-align
-moz-binding page-break-before page-break-after
scroll-snap-points-x scroll-snap-points-y transform
scroll-snap-type-y""" %>
scroll-snap-type-y perspective-origin""" %>
<%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}">
// We manually-implement the |display| property until we get general
@ -1325,6 +1326,15 @@ fn static_assert() {
${impl_keyword('scroll_snap_type_y', 'mScrollSnapTypeY', scroll_snap_type_keyword, need_clone=False)}
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);
}
pub fn copy_perspective_origin_from(&mut self, other: &Self) {
self.gecko.mPerspectiveOrigin[0].copy_from(&other.gecko.mPerspectiveOrigin[0]);
self.gecko.mPerspectiveOrigin[1].copy_from(&other.gecko.mPerspectiveOrigin[1]);
}
</%self:impl_trait>
<%def name="simple_image_array_property(name, shorthand, field_name)">

View file

@ -1531,12 +1531,12 @@ ${helpers.single_keyword("resize",
${helpers.predefined_type("perspective",
"LengthOrNone",
"Either::Second(None_)",
products="servo",
gecko_ffi_name="mChildPerspective",
animatable=True)}
// FIXME: This prop should be animatable
// https://drafts.csswg.org/css-transforms/#perspective-origin-property
<%helpers:longhand name="perspective-origin" products="servo" animatable="False">
<%helpers:longhand name="perspective-origin" animatable="False">
use std::fmt;
use style_traits::ToCss;
use values::HasViewportPercentage;