mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: Formatting nits in gradient parsing.
This commit is contained in:
parent
45bbbac9d9
commit
25ae329156
1 changed files with 32 additions and 23 deletions
|
@ -261,8 +261,10 @@ impl Parse for Gradient {
|
|||
}
|
||||
|
||||
impl Gradient {
|
||||
fn parse_webkit_gradient_argument<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Self, ParseError<'i>> {
|
||||
fn parse_webkit_gradient_argument<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
type Point = GenericPosition<Component<X>, Component<Y>>;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
|
@ -518,10 +520,11 @@ impl Gradient {
|
|||
impl GradientKind {
|
||||
/// Parses a linear gradient.
|
||||
/// CompatMode can change during `-moz-` prefixed gradient parsing if it come across a `to` keyword.
|
||||
fn parse_linear<'i, 't>(context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
compat_mode: &mut CompatMode)
|
||||
-> Result<Self, ParseError<'i>> {
|
||||
fn parse_linear<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
compat_mode: &mut CompatMode,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
let direction = if let Ok(d) = input.try(|i| LineDirection::parse(context, i, compat_mode)) {
|
||||
input.expect_comma()?;
|
||||
d
|
||||
|
@ -534,10 +537,11 @@ impl GradientKind {
|
|||
Ok(GenericGradientKind::Linear(direction))
|
||||
}
|
||||
|
||||
fn parse_radial<'i, 't>(context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
compat_mode: &mut CompatMode)
|
||||
-> Result<Self, ParseError<'i>> {
|
||||
fn parse_radial<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
compat_mode: &mut CompatMode,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
let (shape, position, angle, moz_position) = match *compat_mode {
|
||||
CompatMode::Modern => {
|
||||
let shape = input.try(|i| EndingShape::parse(context, i, *compat_mode));
|
||||
|
@ -702,10 +706,11 @@ impl GenericsLineDirection for LineDirection {
|
|||
}
|
||||
|
||||
impl LineDirection {
|
||||
fn parse<'i, 't>(context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
compat_mode: &mut CompatMode)
|
||||
-> Result<Self, ParseError<'i>> {
|
||||
fn parse<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
compat_mode: &mut CompatMode,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
let mut _angle = if *compat_mode == CompatMode::Moz {
|
||||
input.try(|i| Angle::parse(context, i)).ok()
|
||||
} else {
|
||||
|
@ -780,10 +785,11 @@ impl ToComputedValue for GradientPosition {
|
|||
}
|
||||
|
||||
impl EndingShape {
|
||||
fn parse<'i, 't>(context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
compat_mode: CompatMode)
|
||||
-> Result<Self, ParseError<'i>> {
|
||||
fn parse<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
compat_mode: CompatMode,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
if let Ok(extent) = input.try(|i| ShapeExtent::parse_with_compat_mode(i, compat_mode)) {
|
||||
if input.try(|i| i.expect_ident_matching("circle")).is_ok() {
|
||||
return Ok(GenericEndingShape::Circle(Circle::Extent(extent)));
|
||||
|
@ -861,9 +867,10 @@ impl EndingShape {
|
|||
}
|
||||
|
||||
impl ShapeExtent {
|
||||
fn parse_with_compat_mode<'i, 't>(input: &mut Parser<'i, 't>,
|
||||
compat_mode: CompatMode)
|
||||
-> Result<Self, ParseError<'i>> {
|
||||
fn parse_with_compat_mode<'i, 't>(
|
||||
input: &mut Parser<'i, 't>,
|
||||
compat_mode: CompatMode,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
match Self::parse(input)? {
|
||||
ShapeExtent::Contain | ShapeExtent::Cover if compat_mode == CompatMode::Modern => {
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
|
@ -876,8 +883,10 @@ impl ShapeExtent {
|
|||
}
|
||||
|
||||
impl GradientItem {
|
||||
fn parse_comma_separated<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Vec<Self>, ParseError<'i>> {
|
||||
fn parse_comma_separated<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Vec<Self>, ParseError<'i>> {
|
||||
let mut seen_stop = false;
|
||||
let items = input.parse_comma_separated(|input| {
|
||||
if seen_stop {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue