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