mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
style: Update the syntax of scroll() to accept <scroller> and <axis> in any order
The order of <scroller> and <axis> doesn't matter in the parser. However, we serialize <scroller> first, if it is not the initial value. Differential Revision: https://phabricator.services.mozilla.com/D173906
This commit is contained in:
parent
a27f477c7d
commit
f96c75c8d0
1 changed files with 21 additions and 7 deletions
|
@ -283,12 +283,12 @@ impl Default for ScrollAxis {
|
||||||
#[css(function = "scroll")]
|
#[css(function = "scroll")]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct ScrollFunction {
|
pub struct ScrollFunction {
|
||||||
/// The axis of scrolling that drives the progress of the timeline.
|
|
||||||
#[css(skip_if = "ScrollAxis::is_default")]
|
|
||||||
pub axis: ScrollAxis,
|
|
||||||
/// The scroll container element whose scroll position drives the progress of the timeline.
|
/// The scroll container element whose scroll position drives the progress of the timeline.
|
||||||
#[css(skip_if = "Scroller::is_default")]
|
#[css(skip_if = "Scroller::is_default")]
|
||||||
pub scroller: Scroller,
|
pub scroller: Scroller,
|
||||||
|
/// The axis of scrolling that drives the progress of the timeline.
|
||||||
|
#[css(skip_if = "ScrollAxis::is_default")]
|
||||||
|
pub axis: ScrollAxis,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ScrollFunction {
|
impl ScrollFunction {
|
||||||
|
@ -296,11 +296,25 @@ impl ScrollFunction {
|
||||||
fn parse_arguments<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
fn parse_arguments<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||||
// <scroll()> = scroll( [ <scroller> || <axis> ]? )
|
// <scroll()> = scroll( [ <scroller> || <axis> ]? )
|
||||||
// https://drafts.csswg.org/scroll-animations-1/#funcdef-scroll
|
// https://drafts.csswg.org/scroll-animations-1/#funcdef-scroll
|
||||||
//
|
let mut scroller = None;
|
||||||
// FIXME: This doesn't match the spec. I will update it in Bug 1814444.
|
let mut axis = None;
|
||||||
|
loop {
|
||||||
|
if scroller.is_none() {
|
||||||
|
scroller = input.try_parse(Scroller::parse).ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
if axis.is_none() {
|
||||||
|
axis = input.try_parse(ScrollAxis::parse).ok();
|
||||||
|
if axis.is_some() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
axis: input.try_parse(ScrollAxis::parse).unwrap_or_default(),
|
scroller: scroller.unwrap_or_default(),
|
||||||
scroller: input.try_parse(Scroller::parse).unwrap_or_default(),
|
axis: axis.unwrap_or_default(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue