mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
style: Ditch GeckoStyleCoordHelpers, and implement directly on nsStyleCoord.
This commit is contained in:
parent
9b6cf8dc1b
commit
7b4d3deae7
3 changed files with 10 additions and 11 deletions
|
@ -9,7 +9,7 @@
|
|||
#![allow(unsafe_code)]
|
||||
|
||||
use app_units::Au;
|
||||
use gecko::values::{convert_rgba_to_nscolor, StyleCoordHelpers};
|
||||
use gecko::values::convert_rgba_to_nscolor;
|
||||
use gecko_bindings::bindings::{Gecko_CreateGradient, Gecko_SetGradientImageValue, Gecko_SetUrlImageValue};
|
||||
use gecko_bindings::bindings::{RawServoStyleSheet, RawServoDeclarationBlock, RawServoStyleRule, RawServoImportRule};
|
||||
use gecko_bindings::bindings::{ServoComputedValues, ServoCssRules};
|
||||
|
|
|
@ -14,22 +14,22 @@ use values::computed::{Angle, LengthOrPercentageOrNone, Number};
|
|||
use values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||
use values::computed::basic_shape::ShapeRadius;
|
||||
|
||||
pub trait StyleCoordHelpers {
|
||||
fn set<T: GeckoStyleCoordConvertible>(&mut self, val: T);
|
||||
/// A trait that defines an interface to convert from and to `nsStyleCoord`s.
|
||||
pub trait GeckoStyleCoordConvertible : Sized {
|
||||
/// Convert this to a `nsStyleCoord`.
|
||||
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T);
|
||||
/// Given a `nsStyleCoord`, try to get a value of this type..
|
||||
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self>;
|
||||
}
|
||||
|
||||
impl StyleCoordHelpers for nsStyleCoord {
|
||||
impl nsStyleCoord {
|
||||
#[inline]
|
||||
fn set<T: GeckoStyleCoordConvertible>(&mut self, val: T) {
|
||||
/// Set this `nsStyleCoord` value to `val`.
|
||||
pub fn set<T: GeckoStyleCoordConvertible>(&mut self, val: T) {
|
||||
val.to_gecko_style_coord(self);
|
||||
}
|
||||
}
|
||||
|
||||
pub trait GeckoStyleCoordConvertible : Sized {
|
||||
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T);
|
||||
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self>;
|
||||
}
|
||||
|
||||
impl<A: GeckoStyleCoordConvertible, B: GeckoStyleCoordConvertible> GeckoStyleCoordConvertible for Either<A, B> {
|
||||
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
|
||||
match *self {
|
||||
|
|
|
@ -48,7 +48,6 @@ use gecko::values::convert_nscolor_to_rgba;
|
|||
use gecko::values::convert_rgba_to_nscolor;
|
||||
use gecko::values::GeckoStyleCoordConvertible;
|
||||
use gecko::values::round_border_to_device_pixels;
|
||||
use gecko::values::StyleCoordHelpers;
|
||||
use logical_geometry::WritingMode;
|
||||
use properties::longhands;
|
||||
use std::fmt::{self, Debug};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue