mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Handle clip-path in stylo
This commit is contained in:
parent
1d32422fe8
commit
3895b7118e
12 changed files with 432 additions and 49 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue