mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Kill side keywords from style::values::specified::image
This commit is contained in:
parent
1c54758ad6
commit
f2aaba685b
6 changed files with 31 additions and 33 deletions
|
@ -63,7 +63,7 @@ use style::values::computed::{LengthOrPercentageOrAuto, LengthOrKeyword, LengthO
|
||||||
use style::values::computed::{NumberOrPercentage, Position};
|
use style::values::computed::{NumberOrPercentage, Position};
|
||||||
use style::values::computed::image::{EndingShape, SizeKeyword};
|
use style::values::computed::image::{EndingShape, SizeKeyword};
|
||||||
use style::values::generics::image::{GradientItem as GenericGradientItem, Image};
|
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::CSSPixel;
|
||||||
use style_traits::cursor::Cursor;
|
use style_traits::cursor::Cursor;
|
||||||
use table_cell::CollapsedBordersForCell;
|
use table_cell::CollapsedBordersForCell;
|
||||||
|
@ -1111,13 +1111,13 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
let atan = (bounds.size.height.to_f32_px() /
|
let atan = (bounds.size.height.to_f32_px() /
|
||||||
bounds.size.width.to_f32_px()).atan();
|
bounds.size.width.to_f32_px()).atan();
|
||||||
match (horizontal, vertical) {
|
match (horizontal, vertical) {
|
||||||
(HorizontalDirection::Right, VerticalDirection::Bottom)
|
(X::Right, Y::Bottom)
|
||||||
=> f32::consts::PI - atan,
|
=> f32::consts::PI - atan,
|
||||||
(HorizontalDirection::Left, VerticalDirection::Bottom)
|
(X::Left, Y::Bottom)
|
||||||
=> f32::consts::PI + atan,
|
=> f32::consts::PI + atan,
|
||||||
(HorizontalDirection::Right, VerticalDirection::Top)
|
(X::Right, Y::Top)
|
||||||
=> atan,
|
=> atan,
|
||||||
(HorizontalDirection::Left, VerticalDirection::Top)
|
(X::Left, Y::Top)
|
||||||
=> -atan,
|
=> -atan,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,7 +194,8 @@ impl nsStyleImage {
|
||||||
use gecko_bindings::structs::nsStyleCoord;
|
use gecko_bindings::structs::nsStyleCoord;
|
||||||
use values::computed::{AngleOrCorner, GradientKind, GradientShape, LengthOrKeyword};
|
use values::computed::{AngleOrCorner, GradientKind, GradientShape, LengthOrKeyword};
|
||||||
use values::computed::LengthOrPercentageOrKeyword;
|
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();
|
let stop_count = gradient.items.len();
|
||||||
if stop_count >= ::std::u32::MAX as usize {
|
if stop_count >= ::std::u32::MAX as usize {
|
||||||
|
@ -222,12 +223,12 @@ impl nsStyleImage {
|
||||||
},
|
},
|
||||||
AngleOrCorner::Corner(horiz, vert) => {
|
AngleOrCorner::Corner(horiz, vert) => {
|
||||||
let percent_x = match horiz {
|
let percent_x = match horiz {
|
||||||
HorizontalDirection::Left => 0.0,
|
X::Left => 0.0,
|
||||||
HorizontalDirection::Right => 1.0,
|
X::Right => 1.0,
|
||||||
};
|
};
|
||||||
let percent_y = match vert {
|
let percent_y = match vert {
|
||||||
VerticalDirection::Top => 0.0,
|
Y::Top => 0.0,
|
||||||
VerticalDirection::Bottom => 1.0,
|
Y::Bottom => 1.0,
|
||||||
};
|
};
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -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::generics::image::{Image as GenericImage, ImageRect as GenericImageRect};
|
||||||
use values::computed::{Angle, Context, Length, LengthOrPercentage, NumberOrPercentage, ToComputedValue};
|
use values::computed::{Angle, Context, Length, LengthOrPercentage, NumberOrPercentage, ToComputedValue};
|
||||||
use values::computed::position::Position;
|
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;
|
pub use values::specified::SizeKeyword;
|
||||||
|
|
||||||
|
@ -320,7 +321,7 @@ impl ToComputedValue for specified::LengthOrPercentageOrKeyword {
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub enum AngleOrCorner {
|
pub enum AngleOrCorner {
|
||||||
Angle(Angle),
|
Angle(Angle),
|
||||||
Corner(HorizontalDirection, VerticalDirection)
|
Corner(X, Y)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToComputedValue for specified::AngleOrCorner {
|
impl ToComputedValue for specified::AngleOrCorner {
|
||||||
|
@ -337,16 +338,16 @@ impl ToComputedValue for specified::AngleOrCorner {
|
||||||
},
|
},
|
||||||
specified::AngleOrCorner::Corner(horizontal, vertical) => {
|
specified::AngleOrCorner::Corner(horizontal, vertical) => {
|
||||||
match (horizontal, vertical) {
|
match (horizontal, vertical) {
|
||||||
(None, Some(VerticalDirection::Top)) => {
|
(None, Some(Y::Top)) => {
|
||||||
AngleOrCorner::Angle(Angle::from_radians(0.0))
|
AngleOrCorner::Angle(Angle::from_radians(0.0))
|
||||||
},
|
},
|
||||||
(Some(HorizontalDirection::Right), None) => {
|
(Some(X::Right), None) => {
|
||||||
AngleOrCorner::Angle(Angle::from_radians(PI * 0.5))
|
AngleOrCorner::Angle(Angle::from_radians(PI * 0.5))
|
||||||
},
|
},
|
||||||
(None, Some(VerticalDirection::Bottom)) => {
|
(None, Some(Y::Bottom)) => {
|
||||||
AngleOrCorner::Angle(Angle::from_radians(PI))
|
AngleOrCorner::Angle(Angle::from_radians(PI))
|
||||||
},
|
},
|
||||||
(Some(HorizontalDirection::Left), None) => {
|
(Some(X::Left), None) => {
|
||||||
AngleOrCorner::Angle(Angle::from_radians(PI * 1.5))
|
AngleOrCorner::Angle(Angle::from_radians(PI * 1.5))
|
||||||
},
|
},
|
||||||
(Some(horizontal), Some(vertical)) => {
|
(Some(horizontal), Some(vertical)) => {
|
||||||
|
|
|
@ -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::{Gradient as GenericGradient, GradientItem as GenericGradientItem};
|
||||||
use values::generics::image::{Image as GenericImage, ImageRect as GenericImageRect};
|
use values::generics::image::{Image as GenericImage, ImageRect as GenericImageRect};
|
||||||
use values::specified::{Angle, CSSColor, Length, LengthOrPercentage, NumberOrPercentage};
|
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;
|
use values::specified::url::SpecifiedUrl;
|
||||||
|
|
||||||
/// Specified values for an image according to CSS-IMAGES.
|
/// Specified values for an image according to CSS-IMAGES.
|
||||||
|
@ -222,11 +222,11 @@ impl GradientKind {
|
||||||
} else {
|
} else {
|
||||||
if input.try(|i| i.expect_ident_matching("to")).is_ok() {
|
if input.try(|i| i.expect_ident_matching("to")).is_ok() {
|
||||||
let (horizontal, vertical) =
|
let (horizontal, vertical) =
|
||||||
if let Ok(value) = input.try(HorizontalDirection::parse) {
|
if let Ok(value) = input.try(X::parse) {
|
||||||
(Some(value), input.try(VerticalDirection::parse).ok())
|
(Some(value), input.try(Y::parse).ok())
|
||||||
} else {
|
} else {
|
||||||
let value = try!(VerticalDirection::parse(input));
|
let value = try!(Y::parse(input));
|
||||||
(input.try(HorizontalDirection::parse).ok(), Some(value))
|
(input.try(X::parse).ok(), Some(value))
|
||||||
};
|
};
|
||||||
try!(input.expect_comma());
|
try!(input.expect_comma());
|
||||||
AngleOrCorner::Corner(horizontal, vertical)
|
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)) {
|
let direction = if let Ok(angle) = input.try(|i| Angle::parse_with_unitless(context, i)) {
|
||||||
AngleOrCorner::Angle(angle)
|
AngleOrCorner::Angle(angle)
|
||||||
} else {
|
} else {
|
||||||
if let Ok(value) = input.try(HorizontalDirection::parse) {
|
if let Ok(value) = input.try(X::parse) {
|
||||||
AngleOrCorner::Corner(Some(value), input.try(VerticalDirection::parse).ok())
|
AngleOrCorner::Corner(Some(value), input.try(Y::parse).ok())
|
||||||
} else {
|
} else {
|
||||||
if let Ok(value) = input.try(VerticalDirection::parse) {
|
if let Ok(value) = input.try(Y::parse) {
|
||||||
AngleOrCorner::Corner(input.try(HorizontalDirection::parse).ok(), Some(value))
|
AngleOrCorner::Corner(input.try(X::parse).ok(), Some(value))
|
||||||
} else {
|
} else {
|
||||||
AngleOrCorner::None
|
AngleOrCorner::None
|
||||||
}
|
}
|
||||||
|
@ -408,7 +408,7 @@ fn parse_position(context: &ParserContext, input: &mut Parser) -> Result<Positio
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub enum AngleOrCorner {
|
pub enum AngleOrCorner {
|
||||||
Angle(Angle),
|
Angle(Angle),
|
||||||
Corner(Option<HorizontalDirection>, Option<VerticalDirection>),
|
Corner(Option<X>, Option<Y>),
|
||||||
None,
|
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 {
|
impl Parse for ColorStop {
|
||||||
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
|
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
|
||||||
Ok(ColorStop {
|
Ok(ColorStop {
|
||||||
|
|
|
@ -25,8 +25,7 @@ use values::specified::calc::CalcNode;
|
||||||
|
|
||||||
pub use values::specified::calc::CalcLengthOrPercentage;
|
pub use values::specified::calc::CalcLengthOrPercentage;
|
||||||
pub use super::image::{AngleOrCorner, ColorStop, EndingShape as GradientEndingShape, Gradient};
|
pub use super::image::{AngleOrCorner, ColorStop, EndingShape as GradientEndingShape, Gradient};
|
||||||
pub use super::image::{GradientKind, HorizontalDirection, Image, LengthOrKeyword, LengthOrPercentageOrKeyword};
|
pub use super::image::{GradientKind, Image, LengthOrKeyword, LengthOrPercentageOrKeyword, SizeKeyword};
|
||||||
pub use super::image::{SizeKeyword, VerticalDirection};
|
|
||||||
|
|
||||||
/// Number of app units per pixel
|
/// Number of app units per pixel
|
||||||
pub const AU_PER_PX: CSSFloat = 60.;
|
pub const AU_PER_PX: CSSFloat = 60.;
|
||||||
|
|
|
@ -29,8 +29,8 @@ pub use self::align::{AlignItems, AlignJustifyContent, AlignJustifySelf, Justify
|
||||||
pub use self::color::Color;
|
pub use self::color::Color;
|
||||||
pub use self::grid::{GridLine, TrackKeyword};
|
pub use self::grid::{GridLine, TrackKeyword};
|
||||||
pub use self::image::{AngleOrCorner, ColorStop, EndingShape as GradientEndingShape, Gradient};
|
pub use self::image::{AngleOrCorner, ColorStop, EndingShape as GradientEndingShape, Gradient};
|
||||||
pub use self::image::{GradientItem, GradientKind, HorizontalDirection, Image, ImageRect, LayerImage};
|
pub use self::image::{GradientItem, GradientKind, Image, ImageRect, LayerImage};
|
||||||
pub use self::image::{LengthOrKeyword, LengthOrPercentageOrKeyword, SizeKeyword, VerticalDirection};
|
pub use self::image::{LengthOrKeyword, LengthOrPercentageOrKeyword, SizeKeyword};
|
||||||
pub use self::length::AbsoluteLength;
|
pub use self::length::AbsoluteLength;
|
||||||
pub use self::length::{FontRelativeLength, ViewportPercentageLength, CharacterWidth, Length, CalcLengthOrPercentage};
|
pub use self::length::{FontRelativeLength, ViewportPercentageLength, CharacterWidth, Length, CalcLengthOrPercentage};
|
||||||
pub use self::length::{Percentage, LengthOrNone, LengthOrNumber, LengthOrPercentage, LengthOrPercentageOrAuto};
|
pub use self::length::{Percentage, LengthOrNone, LengthOrNumber, LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue