mirror of
https://github.com/servo/servo.git
synced 2025-08-08 06:55:31 +01:00
style: Cleanup shape-outside code.
This commit is contained in:
parent
57ebb2c8af
commit
d4b238bada
2 changed files with 18 additions and 15 deletions
|
@ -29,7 +29,7 @@ pub enum GeometryBox {
|
||||||
/// A float area shape, for `shape-outside`.
|
/// A float area shape, for `shape-outside`.
|
||||||
pub type FloatAreaShape<BasicShape, Image> = ShapeSource<BasicShape, ShapeBox, Image>;
|
pub type FloatAreaShape<BasicShape, Image> = ShapeSource<BasicShape, ShapeBox, Image>;
|
||||||
|
|
||||||
// https://drafts.csswg.org/css-shapes-1/#typedef-shape-box
|
/// https://drafts.csswg.org/css-shapes-1/#typedef-shape-box
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||||
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq)]
|
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq)]
|
||||||
|
|
|
@ -129,8 +129,10 @@ impl Parse for InsetRect {
|
||||||
|
|
||||||
impl InsetRect {
|
impl InsetRect {
|
||||||
/// Parse the inner function arguments of `inset()`
|
/// Parse the inner function arguments of `inset()`
|
||||||
pub fn parse_function_arguments<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
fn parse_function_arguments<'i, 't>(
|
||||||
-> Result<Self, ParseError<'i>> {
|
context: &ParserContext,
|
||||||
|
input: &mut Parser<'i, 't>,
|
||||||
|
) -> Result<Self, ParseError<'i>> {
|
||||||
let rect = Rect::parse_with(context, input, LengthOrPercentage::parse)?;
|
let rect = Rect::parse_with(context, input, LengthOrPercentage::parse)?;
|
||||||
let round = if input.try(|i| i.expect_ident_matching("round")).is_ok() {
|
let round = if input.try(|i| i.expect_ident_matching("round")).is_ok() {
|
||||||
Some(BorderRadius::parse(context, input)?)
|
Some(BorderRadius::parse(context, input)?)
|
||||||
|
@ -153,9 +155,10 @@ impl Parse for Circle {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Circle {
|
impl Circle {
|
||||||
#[allow(missing_docs)]
|
fn parse_function_arguments<'i, 't>(
|
||||||
pub fn parse_function_arguments<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
context: &ParserContext,
|
||||||
-> Result<Self, ParseError<'i>> {
|
input: &mut Parser<'i, 't>,
|
||||||
|
) -> Result<Self, ParseError<'i>> {
|
||||||
let radius = input.try(|i| ShapeRadius::parse(context, i)).unwrap_or_default();
|
let radius = input.try(|i| ShapeRadius::parse(context, i)).unwrap_or_default();
|
||||||
let position = if input.try(|i| i.expect_ident_matching("at")).is_ok() {
|
let position = if input.try(|i| i.expect_ident_matching("at")).is_ok() {
|
||||||
Position::parse(context, input)?
|
Position::parse(context, input)?
|
||||||
|
@ -163,10 +166,7 @@ impl Circle {
|
||||||
Position::center()
|
Position::center()
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(GenericCircle {
|
Ok(GenericCircle { radius, position })
|
||||||
radius: radius,
|
|
||||||
position: position,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,9 +195,10 @@ impl Parse for Ellipse {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Ellipse {
|
impl Ellipse {
|
||||||
#[allow(missing_docs)]
|
fn parse_function_arguments<'i, 't>(
|
||||||
pub fn parse_function_arguments<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
context: &ParserContext,
|
||||||
-> Result<Self, ParseError<'i>> {
|
input: &mut Parser<'i, 't>,
|
||||||
|
) -> Result<Self, ParseError<'i>> {
|
||||||
let (a, b) = input.try(|i| -> Result<_, ParseError> {
|
let (a, b) = input.try(|i| -> Result<_, ParseError> {
|
||||||
Ok((ShapeRadius::parse(context, i)?, ShapeRadius::parse(context, i)?))
|
Ok((ShapeRadius::parse(context, i)?, ShapeRadius::parse(context, i)?))
|
||||||
}).unwrap_or_default();
|
}).unwrap_or_default();
|
||||||
|
@ -331,8 +332,10 @@ impl Parse for Polygon {
|
||||||
|
|
||||||
impl Polygon {
|
impl Polygon {
|
||||||
/// Parse the inner arguments of a `polygon` function.
|
/// Parse the inner arguments of a `polygon` function.
|
||||||
pub fn parse_function_arguments<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
fn parse_function_arguments<'i, 't>(
|
||||||
-> Result<Self, ParseError<'i>> {
|
context: &ParserContext,
|
||||||
|
input: &mut Parser<'i, 't>,
|
||||||
|
) -> Result<Self, ParseError<'i>> {
|
||||||
let fill = input.try(|i| -> Result<_, ParseError> {
|
let fill = input.try(|i| -> Result<_, ParseError> {
|
||||||
let fill = FillRule::parse(i)?;
|
let fill = FillRule::parse(i)?;
|
||||||
i.expect_comma()?; // only eat the comma if there is something before it
|
i.expect_comma()?; // only eat the comma if there is something before it
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue