-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
web/core: Parse "justify-self" property
- Loading branch information
1 parent
c545c16
commit cec761e
Showing
4 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use crate::{ | ||
css::{self, CSSParse}, | ||
static_interned, | ||
}; | ||
|
||
/// <https://drafts.csswg.org/css-align-3/#propdef-justify-self> | ||
#[derive(Clone, Copy, Debug, PartialEq, Eq)] | ||
pub enum JustifySelf { | ||
/// <https://drafts.csswg.org/css-align-3/#valdef-justify-self-normal> | ||
Normal, | ||
|
||
/// <https://drafts.csswg.org/css-align-3/#valdef-justify-self-stretch> | ||
Stretch, | ||
|
||
/// <https://drafts.csswg.org/css-align-3/#valdef-justify-self-first-baseline> | ||
FirstBaseline, | ||
|
||
/// <https://drafts.csswg.org/css-align-3/#valdef-justify-self-last-baseline> | ||
LastBaseline, | ||
// FIXME: There are more values here | ||
} | ||
|
||
impl<'a> CSSParse<'a> for JustifySelf { | ||
fn parse(parser: &mut css::Parser<'a>) -> Result<Self, css::ParseError> { | ||
let justify_self = match parser.expect_identifier()? { | ||
static_interned!("normal") => Self::Normal, | ||
static_interned!("stretch") => Self::Stretch, | ||
static_interned!("first") => { | ||
parser.skip_whitespace(); | ||
let static_interned!("baseline") = parser.expect_identifier()? else { | ||
return Err(css::ParseError); | ||
}; | ||
Self::FirstBaseline | ||
}, | ||
static_interned!("last") => { | ||
parser.skip_whitespace(); | ||
let static_interned!("baseline") = parser.expect_identifier()? else { | ||
return Err(css::ParseError); | ||
}; | ||
Self::LastBaseline | ||
}, | ||
_ => return Err(css::ParseError), | ||
}; | ||
|
||
Ok(justify_self) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters