mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +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`.
|
||||
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)]
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq)]
|
||||
|
|
|
@ -129,8 +129,10 @@ impl Parse for InsetRect {
|
|||
|
||||
impl InsetRect {
|
||||
/// Parse the inner function arguments of `inset()`
|
||||
pub fn parse_function_arguments<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Self, ParseError<'i>> {
|
||||
fn parse_function_arguments<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
let rect = Rect::parse_with(context, input, LengthOrPercentage::parse)?;
|
||||
let round = if input.try(|i| i.expect_ident_matching("round")).is_ok() {
|
||||
Some(BorderRadius::parse(context, input)?)
|
||||
|
@ -153,9 +155,10 @@ impl Parse for Circle {
|
|||
}
|
||||
|
||||
impl Circle {
|
||||
#[allow(missing_docs)]
|
||||
pub fn parse_function_arguments<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Self, ParseError<'i>> {
|
||||
fn parse_function_arguments<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
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() {
|
||||
Position::parse(context, input)?
|
||||
|
@ -163,10 +166,7 @@ impl Circle {
|
|||
Position::center()
|
||||
};
|
||||
|
||||
Ok(GenericCircle {
|
||||
radius: radius,
|
||||
position: position,
|
||||
})
|
||||
Ok(GenericCircle { radius, position })
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -195,9 +195,10 @@ impl Parse for Ellipse {
|
|||
}
|
||||
|
||||
impl Ellipse {
|
||||
#[allow(missing_docs)]
|
||||
pub fn parse_function_arguments<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Self, ParseError<'i>> {
|
||||
fn parse_function_arguments<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
let (a, b) = input.try(|i| -> Result<_, ParseError> {
|
||||
Ok((ShapeRadius::parse(context, i)?, ShapeRadius::parse(context, i)?))
|
||||
}).unwrap_or_default();
|
||||
|
@ -331,8 +332,10 @@ impl Parse for Polygon {
|
|||
|
||||
impl Polygon {
|
||||
/// Parse the inner arguments of a `polygon` function.
|
||||
pub fn parse_function_arguments<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Self, ParseError<'i>> {
|
||||
fn parse_function_arguments<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
let fill = input.try(|i| -> Result<_, ParseError> {
|
||||
let fill = FillRule::parse(i)?;
|
||||
i.expect_comma()?; // only eat the comma if there is something before it
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue