style: Ditch GeckoStyleCoordHelpers, and implement directly on nsStyleCoord.

This commit is contained in:
Emilio Cobos Álvarez 2017-01-02 04:53:00 +01:00
parent 9b6cf8dc1b
commit 7b4d3deae7
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
3 changed files with 10 additions and 11 deletions

View file

@ -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};

View file

@ -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 {

View file

@ -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};