mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: Derive parse for TextOverflowSide.
Depends on D76330 Differential Revision: https://phabricator.services.mozilla.com/D76331
This commit is contained in:
parent
396338816d
commit
e259c53c62
2 changed files with 7 additions and 24 deletions
|
@ -207,6 +207,12 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl Parse for crate::OwnedStr {
|
||||
fn parse<'i, 't>(_: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
Ok(input.expect_string()?.as_ref().to_owned().into())
|
||||
}
|
||||
}
|
||||
|
||||
impl Parse for UnicodeRange {
|
||||
fn parse<'i, 't>(_: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
Ok(UnicodeRange::parse(input)?)
|
||||
|
|
|
@ -128,6 +128,7 @@ impl ToComputedValue for LineHeight {
|
|||
Eq,
|
||||
MallocSizeOf,
|
||||
PartialEq,
|
||||
Parse,
|
||||
SpecifiedValueInfo,
|
||||
ToComputedValue,
|
||||
ToCss,
|
||||
|
@ -144,30 +145,6 @@ pub enum TextOverflowSide {
|
|||
String(crate::OwnedStr),
|
||||
}
|
||||
|
||||
impl Parse for TextOverflowSide {
|
||||
fn parse<'i, 't>(
|
||||
_context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<TextOverflowSide, ParseError<'i>> {
|
||||
let location = input.current_source_location();
|
||||
match *input.next()? {
|
||||
Token::Ident(ref ident) => {
|
||||
match_ignore_ascii_case! { ident,
|
||||
"clip" => Ok(TextOverflowSide::Clip),
|
||||
"ellipsis" => Ok(TextOverflowSide::Ellipsis),
|
||||
_ => Err(location.new_custom_error(
|
||||
SelectorParseErrorKind::UnexpectedIdent(ident.clone())
|
||||
))
|
||||
}
|
||||
},
|
||||
Token::QuotedString(ref v) => {
|
||||
Ok(TextOverflowSide::String(v.as_ref().to_owned().into()))
|
||||
},
|
||||
ref t => Err(location.new_unexpected_token_error(t.clone())),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss, ToShmem)]
|
||||
/// text-overflow. Specifies rendering when inline content overflows its line box edge.
|
||||
pub struct TextOverflow {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue