mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
gfx: Add elliptical border-radius shorthand parsing
Adds elliptical border-radius shorthand parsing, e.g.: /* The syntax of the second radius allows one to four values */ /* (first radius values) / radius */ border-radius: 10px 5% / 20px; /* (first radius values) / top-left-and-bottom-right | top-right-and-bottom-left */ border-radius: 10px 5% / 20px 30px; /* (first radius values) / top-left | top-right-and-bottom-left | bottom-right */ border-radius: 10px 5px 2em / 20px 25px 30%; /* (first radius values) / top-left | top-right | bottom-right | bottom-left */ border-radius: 10px 5% / 20px 25em 30px 35em;
This commit is contained in:
parent
67cf241acd
commit
48f1159845
5 changed files with 83 additions and 27 deletions
|
@ -842,6 +842,21 @@ pub mod specified {
|
|||
let zero = LengthOrPercentage::Length(Length::Absolute(Au(0)));
|
||||
BorderRadiusSize(Size2D::new(zero, zero))
|
||||
}
|
||||
|
||||
pub fn new(width: LengthOrPercentage, height: LengthOrPercentage) -> BorderRadiusSize {
|
||||
BorderRadiusSize(Size2D::new(width, height))
|
||||
}
|
||||
|
||||
pub fn circle(radius: LengthOrPercentage) -> BorderRadiusSize {
|
||||
BorderRadiusSize(Size2D::new(radius, radius))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn parse(input: &mut Parser) -> Result<BorderRadiusSize, ()> {
|
||||
let first = try!(LengthOrPercentage::parse_non_negative(input));
|
||||
let second = input.try(LengthOrPercentage::parse_non_negative).unwrap_or(first);
|
||||
Ok(BorderRadiusSize(Size2D::new(first, second)))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToCss for BorderRadiusSize {
|
||||
|
@ -852,27 +867,6 @@ pub mod specified {
|
|||
size.height.to_css(dest)
|
||||
}
|
||||
}
|
||||
impl BorderRadiusSize {
|
||||
pub fn circle(radius: LengthOrPercentage) -> BorderRadiusSize {
|
||||
BorderRadiusSize(Size2D::new(radius, radius))
|
||||
}
|
||||
|
||||
pub fn parse_one_radii(input: &mut Parser) -> Result<BorderRadiusSize, ()> {
|
||||
if let Ok(first) = LengthOrPercentage::parse_non_negative(input) {
|
||||
Ok(BorderRadiusSize(Size2D::new(first, first)))
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[inline]
|
||||
pub fn parse(input: &mut Parser) -> Result<BorderRadiusSize, ()> {
|
||||
let first = try!(LengthOrPercentage::parse_non_negative(input));
|
||||
let second = input.try(LengthOrPercentage::parse_non_negative).unwrap_or(first);
|
||||
Ok(BorderRadiusSize(Size2D::new(first, second)))
|
||||
}
|
||||
}
|
||||
|
||||
// http://dev.w3.org/csswg/css2/colors.html#propdef-background-position
|
||||
#[derive(Clone, PartialEq, Copy)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue