mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Add gecko glue for perspective and perspective-origin.
This commit is contained in:
parent
aeb5d34394
commit
ed7945e747
3 changed files with 28 additions and 4 deletions
|
@ -10,7 +10,7 @@ use gecko_bindings::structs::{NS_RADIUS_CLOSEST_SIDE, NS_RADIUS_FARTHEST_SIDE};
|
||||||
use gecko_bindings::structs::nsStyleCoord;
|
use gecko_bindings::structs::nsStyleCoord;
|
||||||
use gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue};
|
use gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue};
|
||||||
use std::cmp::max;
|
use std::cmp::max;
|
||||||
use values::{Auto, Either};
|
use values::{Auto, Either, None_};
|
||||||
use values::computed::{Angle, LengthOrPercentageOrNone, Number};
|
use values::computed::{Angle, LengthOrPercentageOrNone, Number};
|
||||||
use values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto};
|
use values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||||
use values::computed::basic_shape::ShapeRadius;
|
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 {
|
pub fn convert_rgba_to_nscolor(rgba: &RGBA) -> u32 {
|
||||||
(((rgba.alpha * 255.0).round() as u32) << 24) |
|
(((rgba.alpha * 255.0).round() as u32) << 24) |
|
||||||
(((rgba.blue * 255.0).round() as u32) << 16) |
|
(((rgba.blue * 255.0).round() as u32) << 16) |
|
||||||
|
|
|
@ -505,6 +505,7 @@ impl Debug for ${style_struct.gecko_struct_name} {
|
||||||
"LengthOrPercentage": impl_style_coord,
|
"LengthOrPercentage": impl_style_coord,
|
||||||
"LengthOrPercentageOrAuto": impl_style_coord,
|
"LengthOrPercentageOrAuto": impl_style_coord,
|
||||||
"LengthOrPercentageOrNone": impl_style_coord,
|
"LengthOrPercentageOrNone": impl_style_coord,
|
||||||
|
"LengthOrNone": impl_style_coord,
|
||||||
"Number": impl_simple,
|
"Number": impl_simple,
|
||||||
"Opacity": impl_simple,
|
"Opacity": impl_simple,
|
||||||
"CSSColor": impl_color,
|
"CSSColor": impl_color,
|
||||||
|
@ -1053,7 +1054,7 @@ fn static_assert() {
|
||||||
<% skip_box_longhands= """display overflow-y vertical-align
|
<% skip_box_longhands= """display overflow-y vertical-align
|
||||||
-moz-binding page-break-before page-break-after
|
-moz-binding page-break-before page-break-after
|
||||||
scroll-snap-points-x scroll-snap-points-y transform
|
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}">
|
<%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}">
|
||||||
|
|
||||||
// We manually-implement the |display| property until we get general
|
// 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)}
|
${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>
|
</%self:impl_trait>
|
||||||
|
|
||||||
<%def name="simple_image_array_property(name, shorthand, field_name)">
|
<%def name="simple_image_array_property(name, shorthand, field_name)">
|
||||||
|
|
|
@ -1531,12 +1531,12 @@ ${helpers.single_keyword("resize",
|
||||||
${helpers.predefined_type("perspective",
|
${helpers.predefined_type("perspective",
|
||||||
"LengthOrNone",
|
"LengthOrNone",
|
||||||
"Either::Second(None_)",
|
"Either::Second(None_)",
|
||||||
products="servo",
|
gecko_ffi_name="mChildPerspective",
|
||||||
animatable=True)}
|
animatable=True)}
|
||||||
|
|
||||||
// FIXME: This prop should be animatable
|
// FIXME: This prop should be animatable
|
||||||
// https://drafts.csswg.org/css-transforms/#perspective-origin-property
|
// 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 std::fmt;
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
use values::HasViewportPercentage;
|
use values::HasViewportPercentage;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue