aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2017-05-11 17:39:09 +0200
committerAnthony Ramine <n.oxyde@gmail.com>2017-05-15 15:35:31 +0200
commitf2aaba685b81d7cf8311bbe791681d1ab55cfa78 (patch)
treede2d2ac6eebd7b5320943f3602eeb95d64ea1d70 /components
parent1c54758ad6b1279500921dd2661289f4f23ef44e (diff)
downloadservo-f2aaba685b81d7cf8311bbe791681d1ab55cfa78.tar.gz
servo-f2aaba685b81d7cf8311bbe791681d1ab55cfa78.zip
Kill side keywords from style::values::specified::image
Diffstat (limited to 'components')
-rw-r--r--components/layout/display_list_builder.rs10
-rw-r--r--components/style/gecko/conversions.rs11
-rw-r--r--components/style/values/computed/image.rs13
-rw-r--r--components/style/values/specified/image.rs23
-rw-r--r--components/style/values/specified/length.rs3
-rw-r--r--components/style/values/specified/mod.rs4
6 files changed, 31 insertions, 33 deletions
diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs
index 5ecae6d66de..14bffb0a1f6 100644
--- a/components/layout/display_list_builder.rs
+++ b/components/layout/display_list_builder.rs
@@ -63,7 +63,7 @@ use style::values::computed::{LengthOrPercentageOrAuto, LengthOrKeyword, LengthO
use style::values::computed::{NumberOrPercentage, Position};
use style::values::computed::image::{EndingShape, SizeKeyword};
use style::values::generics::image::{GradientItem as GenericGradientItem, Image};
-use style::values::specified::{HorizontalDirection, VerticalDirection};
+use style::values::specified::position::{X, Y};
use style_traits::CSSPixel;
use style_traits::cursor::Cursor;
use table_cell::CollapsedBordersForCell;
@@ -1111,13 +1111,13 @@ impl FragmentDisplayListBuilding for Fragment {
let atan = (bounds.size.height.to_f32_px() /
bounds.size.width.to_f32_px()).atan();
match (horizontal, vertical) {
- (HorizontalDirection::Right, VerticalDirection::Bottom)
+ (X::Right, Y::Bottom)
=> f32::consts::PI - atan,
- (HorizontalDirection::Left, VerticalDirection::Bottom)
+ (X::Left, Y::Bottom)
=> f32::consts::PI + atan,
- (HorizontalDirection::Right, VerticalDirection::Top)
+ (X::Right, Y::Top)
=> atan,
- (HorizontalDirection::Left, VerticalDirection::Top)
+ (X::Left, Y::Top)
=> -atan,
}
}
diff --git a/components/style/gecko/conversions.rs b/components/style/gecko/conversions.rs
index d3d74234c35..7dc333964e4 100644
--- a/components/style/gecko/conversions.rs
+++ b/components/style/gecko/conversions.rs
@@ -194,7 +194,8 @@ impl nsStyleImage {
use gecko_bindings::structs::nsStyleCoord;
use values::computed::{AngleOrCorner, GradientKind, GradientShape, LengthOrKeyword};
use values::computed::LengthOrPercentageOrKeyword;
- use values::specified::{HorizontalDirection, SizeKeyword, VerticalDirection};
+ use values::specified::SizeKeyword;
+ use values::specified::position::{X, Y};
let stop_count = gradient.items.len();
if stop_count >= ::std::u32::MAX as usize {
@@ -222,12 +223,12 @@ impl nsStyleImage {
},
AngleOrCorner::Corner(horiz, vert) => {
let percent_x = match horiz {
- HorizontalDirection::Left => 0.0,
- HorizontalDirection::Right => 1.0,
+ X::Left => 0.0,
+ X::Right => 1.0,
};
let percent_y = match vert {
- VerticalDirection::Top => 0.0,
- VerticalDirection::Bottom => 1.0,
+ Y::Top => 0.0,
+ Y::Bottom => 1.0,
};
unsafe {
diff --git a/components/style/values/computed/image.rs b/components/style/values/computed/image.rs
index 5140650d80e..b31da88d338 100644
--- a/components/style/values/computed/image.rs
+++ b/components/style/values/computed/image.rs
@@ -16,7 +16,8 @@ use values::generics::image::{Gradient as GenericGradient, GradientItem as Gener
use values::generics::image::{Image as GenericImage, ImageRect as GenericImageRect};
use values::computed::{Angle, Context, Length, LengthOrPercentage, NumberOrPercentage, ToComputedValue};
use values::computed::position::Position;
-use values::specified::{self, HorizontalDirection, VerticalDirection};
+use values::specified;
+use values::specified::position::{X, Y};
pub use values::specified::SizeKeyword;
@@ -320,7 +321,7 @@ impl ToComputedValue for specified::LengthOrPercentageOrKeyword {
#[allow(missing_docs)]
pub enum AngleOrCorner {
Angle(Angle),
- Corner(HorizontalDirection, VerticalDirection)
+ Corner(X, Y)
}
impl ToComputedValue for specified::AngleOrCorner {
@@ -337,16 +338,16 @@ impl ToComputedValue for specified::AngleOrCorner {
},
specified::AngleOrCorner::Corner(horizontal, vertical) => {
match (horizontal, vertical) {
- (None, Some(VerticalDirection::Top)) => {
+ (None, Some(Y::Top)) => {
AngleOrCorner::Angle(Angle::from_radians(0.0))
},
- (Some(HorizontalDirection::Right), None) => {
+ (Some(X::Right), None) => {
AngleOrCorner::Angle(Angle::from_radians(PI * 0.5))
},
- (None, Some(VerticalDirection::Bottom)) => {
+ (None, Some(Y::Bottom)) => {
AngleOrCorner::Angle(Angle::from_radians(PI))
},
- (Some(HorizontalDirection::Left), None) => {
+ (Some(X::Left), None) => {
AngleOrCorner::Angle(Angle::from_radians(PI * 1.5))
},
(Some(horizontal), Some(vertical)) => {
diff --git a/components/style/values/specified/image.rs b/components/style/values/specified/image.rs
index 62e971782f9..01352fc187c 100644
--- a/components/style/values/specified/image.rs
+++ b/components/style/values/specified/image.rs
@@ -18,7 +18,7 @@ use values::generics::image::{CompatMode, ColorStop as GenericColorStop};
use values::generics::image::{Gradient as GenericGradient, GradientItem as GenericGradientItem};
use values::generics::image::{Image as GenericImage, ImageRect as GenericImageRect};
use values::specified::{Angle, CSSColor, Length, LengthOrPercentage, NumberOrPercentage};
-use values::specified::position::Position;
+use values::specified::position::{Position, X, Y};
use values::specified::url::SpecifiedUrl;
/// Specified values for an image according to CSS-IMAGES.
@@ -222,11 +222,11 @@ impl GradientKind {
} else {
if input.try(|i| i.expect_ident_matching("to")).is_ok() {
let (horizontal, vertical) =
- if let Ok(value) = input.try(HorizontalDirection::parse) {
- (Some(value), input.try(VerticalDirection::parse).ok())
+ if let Ok(value) = input.try(X::parse) {
+ (Some(value), input.try(Y::parse).ok())
} else {
- let value = try!(VerticalDirection::parse(input));
- (input.try(HorizontalDirection::parse).ok(), Some(value))
+ let value = try!(Y::parse(input));
+ (input.try(X::parse).ok(), Some(value))
};
try!(input.expect_comma());
AngleOrCorner::Corner(horizontal, vertical)
@@ -241,11 +241,11 @@ impl GradientKind {
let direction = if let Ok(angle) = input.try(|i| Angle::parse_with_unitless(context, i)) {
AngleOrCorner::Angle(angle)
} else {
- if let Ok(value) = input.try(HorizontalDirection::parse) {
- AngleOrCorner::Corner(Some(value), input.try(VerticalDirection::parse).ok())
+ if let Ok(value) = input.try(X::parse) {
+ AngleOrCorner::Corner(Some(value), input.try(Y::parse).ok())
} else {
- if let Ok(value) = input.try(VerticalDirection::parse) {
- AngleOrCorner::Corner(input.try(HorizontalDirection::parse).ok(), Some(value))
+ if let Ok(value) = input.try(Y::parse) {
+ AngleOrCorner::Corner(input.try(X::parse).ok(), Some(value))
} else {
AngleOrCorner::None
}
@@ -408,7 +408,7 @@ fn parse_position(context: &ParserContext, input: &mut Parser) -> Result<Positio
#[allow(missing_docs)]
pub enum AngleOrCorner {
Angle(Angle),
- Corner(Option<HorizontalDirection>, Option<VerticalDirection>),
+ Corner(Option<X>, Option<Y>),
None,
}
@@ -438,9 +438,6 @@ impl AngleOrCorner {
}
}
-define_css_keyword_enum!(HorizontalDirection: "left" => Left, "right" => Right);
-define_css_keyword_enum!(VerticalDirection: "top" => Top, "bottom" => Bottom);
-
impl Parse for ColorStop {
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
Ok(ColorStop {
diff --git a/components/style/values/specified/length.rs b/components/style/values/specified/length.rs
index 2062786adf8..13eb17b6a6f 100644
--- a/components/style/values/specified/length.rs
+++ b/components/style/values/specified/length.rs
@@ -25,8 +25,7 @@ use values::specified::calc::CalcNode;
pub use values::specified::calc::CalcLengthOrPercentage;
pub use super::image::{AngleOrCorner, ColorStop, EndingShape as GradientEndingShape, Gradient};
-pub use super::image::{GradientKind, HorizontalDirection, Image, LengthOrKeyword, LengthOrPercentageOrKeyword};
-pub use super::image::{SizeKeyword, VerticalDirection};
+pub use super::image::{GradientKind, Image, LengthOrKeyword, LengthOrPercentageOrKeyword, SizeKeyword};
/// Number of app units per pixel
pub const AU_PER_PX: CSSFloat = 60.;
diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs
index aa8b791615b..d7245b25d2a 100644
--- a/components/style/values/specified/mod.rs
+++ b/components/style/values/specified/mod.rs
@@ -29,8 +29,8 @@ pub use self::align::{AlignItems, AlignJustifyContent, AlignJustifySelf, Justify
pub use self::color::Color;
pub use self::grid::{GridLine, TrackKeyword};
pub use self::image::{AngleOrCorner, ColorStop, EndingShape as GradientEndingShape, Gradient};
-pub use self::image::{GradientItem, GradientKind, HorizontalDirection, Image, ImageRect, LayerImage};
-pub use self::image::{LengthOrKeyword, LengthOrPercentageOrKeyword, SizeKeyword, VerticalDirection};
+pub use self::image::{GradientItem, GradientKind, Image, ImageRect, LayerImage};
+pub use self::image::{LengthOrKeyword, LengthOrPercentageOrKeyword, SizeKeyword};
pub use self::length::AbsoluteLength;
pub use self::length::{FontRelativeLength, ViewportPercentageLength, CharacterWidth, Length, CalcLengthOrPercentage};
pub use self::length::{Percentage, LengthOrNone, LengthOrNumber, LengthOrPercentage, LengthOrPercentageOrAuto};