mirror of
https://github.com/servo/servo.git
synced 2025-10-04 02:29:12 +01:00
This reverts commit 8e15389cae
.
This commit is contained in:
parent
8e15389cae
commit
d6ae8dc112
152 changed files with 4622 additions and 5862 deletions
|
@ -232,8 +232,8 @@ impl ToComputedValue for TextOverflow {
|
|||
}
|
||||
|
||||
bitflags! {
|
||||
#[derive(MallocSizeOf, Parse, Serialize, SpecifiedValueInfo, ToCss, ToComputedValue, ToResolvedValue, ToShmem)]
|
||||
#[css(bitflags(single = "none", mixed = "underline,overline,line-through,blink"))]
|
||||
#[derive(MallocSizeOf, Serialize, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem)]
|
||||
#[value_info(other_values = "none,underline,overline,line-through,blink")]
|
||||
#[repr(C)]
|
||||
/// Specified keyword values for the text-decoration-line property.
|
||||
pub struct TextDecorationLine: u8 {
|
||||
|
@ -265,6 +265,94 @@ impl Default for TextDecorationLine {
|
|||
}
|
||||
}
|
||||
|
||||
impl Parse for TextDecorationLine {
|
||||
/// none | [ underline || overline || line-through || blink ]
|
||||
fn parse<'i, 't>(
|
||||
_context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
let mut result = TextDecorationLine::empty();
|
||||
|
||||
// NOTE(emilio): this loop has this weird structure because we run this
|
||||
// code to parse the text-decoration shorthand as well, so we need to
|
||||
// ensure we don't return an error if we don't consume the whole thing
|
||||
// because we find an invalid identifier or other kind of token.
|
||||
loop {
|
||||
let flag: Result<_, ParseError<'i>> = input.try_parse(|input| {
|
||||
let flag = try_match_ident_ignore_ascii_case! { input,
|
||||
"none" if result.is_empty() => TextDecorationLine::NONE,
|
||||
"underline" => TextDecorationLine::UNDERLINE,
|
||||
"overline" => TextDecorationLine::OVERLINE,
|
||||
"line-through" => TextDecorationLine::LINE_THROUGH,
|
||||
"blink" => TextDecorationLine::BLINK,
|
||||
};
|
||||
|
||||
Ok(flag)
|
||||
});
|
||||
|
||||
let flag = match flag {
|
||||
Ok(flag) => flag,
|
||||
Err(..) => break,
|
||||
};
|
||||
|
||||
if flag.is_empty() {
|
||||
return Ok(TextDecorationLine::NONE);
|
||||
}
|
||||
|
||||
if result.contains(flag) {
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
|
||||
result.insert(flag)
|
||||
}
|
||||
|
||||
if !result.is_empty() {
|
||||
Ok(result)
|
||||
} else {
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ToCss for TextDecorationLine {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
if self.is_empty() {
|
||||
return dest.write_str("none");
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
{
|
||||
if *self == TextDecorationLine::COLOR_OVERRIDE {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
let mut writer = SequenceWriter::new(dest, " ");
|
||||
let mut any = false;
|
||||
|
||||
macro_rules! maybe_write {
|
||||
($ident:ident => $str:expr) => {
|
||||
if self.contains(TextDecorationLine::$ident) {
|
||||
any = true;
|
||||
writer.raw_item($str)?;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
maybe_write!(UNDERLINE => "underline");
|
||||
maybe_write!(OVERLINE => "overline");
|
||||
maybe_write!(LINE_THROUGH => "line-through");
|
||||
maybe_write!(BLINK => "blink");
|
||||
|
||||
debug_assert!(any);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl TextDecorationLine {
|
||||
#[inline]
|
||||
/// Returns the initial value of text-decoration-line
|
||||
|
@ -311,7 +399,6 @@ impl TextTransform {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: This can be simplified by deriving it.
|
||||
impl Parse for TextTransform {
|
||||
fn parse<'i, 't>(
|
||||
_context: &ParserContext,
|
||||
|
@ -528,20 +615,11 @@ pub enum TextAlign {
|
|||
/// unlike other keywords.
|
||||
#[cfg(feature = "gecko")]
|
||||
MatchParent,
|
||||
/// This is how we implement the following HTML behavior from
|
||||
/// https://html.spec.whatwg.org/#tables-2:
|
||||
///
|
||||
/// User agents are expected to have a rule in their user agent style sheet
|
||||
/// that matches th elements that have a parent node whose computed value
|
||||
/// for the 'text-align' property is its initial value, whose declaration
|
||||
/// block consists of just a single declaration that sets the 'text-align'
|
||||
/// property to the value 'center'.
|
||||
///
|
||||
/// Since selectors can't depend on the ancestor styles, we implement it with a
|
||||
/// magic value that computes to the right thing. Since this is an
|
||||
/// implementation detail, it shouldn't be exposed to web content.
|
||||
/// `MozCenterOrInherit` value of text-align property. It cannot be parsed,
|
||||
/// only set directly on the elements and it has a different handling
|
||||
/// unlike other values.
|
||||
#[cfg(feature = "gecko")]
|
||||
#[parse(condition = "ParserContext::in_ua_or_chrome_sheet")]
|
||||
#[css(skip)]
|
||||
MozCenterOrInherit,
|
||||
}
|
||||
|
||||
|
@ -1116,7 +1194,6 @@ bitflags! {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: This can be derived with some care.
|
||||
impl Parse for TextUnderlinePosition {
|
||||
fn parse<'i, 't>(
|
||||
_context: &ParserContext,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue