Handle clip-path in stylo

This commit is contained in:
Manish Goregaokar 2016-08-17 17:08:23 +05:30
parent 1d32422fe8
commit 3895b7118e
No known key found for this signature in database
GPG key ID: 3BBF4D3E2EF79F98
12 changed files with 432 additions and 49 deletions

View file

@ -7,12 +7,13 @@
use app_units::Au;
use cssparser::RGBA;
use gecko_bindings::structs::nsStyleCoord;
use gecko_bindings::structs::{NS_RADIUS_CLOSEST_SIDE, NS_RADIUS_FARTHEST_SIDE};
use gecko_bindings::sugar::ns_style_coord::{CoordDataValue, CoordData, CoordDataMut};
use std::cmp::max;
use values::computed::Angle;
use values::computed::basic_shape::ShapeRadius;
use values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
pub trait StyleCoordHelpers {
fn set<T: GeckoStyleCoordConvertible>(&mut self, val: T);
}
@ -94,6 +95,28 @@ impl GeckoStyleCoordConvertible for LengthOrPercentageOrNone {
}
}
impl GeckoStyleCoordConvertible for ShapeRadius {
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
match *self {
ShapeRadius::ClosestSide => {
coord.set_value(CoordDataValue::Enumerated(NS_RADIUS_CLOSEST_SIDE))
}
ShapeRadius::FarthestSide => {
coord.set_value(CoordDataValue::Enumerated(NS_RADIUS_FARTHEST_SIDE))
}
ShapeRadius::Length(lop) => lop.to_gecko_style_coord(coord),
}
}
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
match coord.as_value() {
CoordDataValue::Enumerated(NS_RADIUS_CLOSEST_SIDE) => Some(ShapeRadius::ClosestSide),
CoordDataValue::Enumerated(NS_RADIUS_FARTHEST_SIDE) => Some(ShapeRadius::FarthestSide),
_ => LengthOrPercentage::from_gecko_style_coord(coord).map(ShapeRadius::Length),
}
}
}
impl<T: GeckoStyleCoordConvertible> GeckoStyleCoordConvertible for Option<T> {
fn to_gecko_style_coord<U: CoordDataMut>(&self, coord: &mut U) {
if let Some(ref me) = *self {