mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
style: Use cbindgen for content property.
This cleans up and also allows us to keep the distinction between content: none and content: normal, which allows us to fix the computed style we return from getComputedStyle(). Do this last bit from the resolved value instead of StyleAdjuster, because otherwise we need to tweak every initial struct for ::before / ::after. Differential Revision: https://phabricator.services.mozilla.com/D58276
This commit is contained in:
parent
07d0eea5fb
commit
219c0f6328
13 changed files with 122 additions and 343 deletions
|
@ -767,9 +767,12 @@ impl AllowQuirks {
|
|||
ToShmem,
|
||||
)]
|
||||
#[css(function)]
|
||||
#[repr(C)]
|
||||
pub struct Attr {
|
||||
/// Optional namespace prefix and URL.
|
||||
pub namespace: Option<(Prefix, Namespace)>,
|
||||
/// Optional namespace prefix.
|
||||
pub namespace_prefix: Prefix,
|
||||
/// Optional namespace URL.
|
||||
pub namespace_url: Namespace,
|
||||
/// Attribute name
|
||||
pub attribute: Atom,
|
||||
}
|
||||
|
@ -814,7 +817,7 @@ impl Attr {
|
|||
ref t => return Err(location.new_unexpected_token_error(t.clone())),
|
||||
};
|
||||
|
||||
let prefix_and_ns = if let Some(ns) = first {
|
||||
let (namespace_prefix, namespace_url) = if let Some(ns) = first {
|
||||
let prefix = Prefix::from(ns.as_ref());
|
||||
let ns = match get_namespace_for_prefix(&prefix, context) {
|
||||
Some(ns) => ns,
|
||||
|
@ -823,17 +826,18 @@ impl Attr {
|
|||
.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
},
|
||||
};
|
||||
Some((prefix, ns))
|
||||
(prefix, ns)
|
||||
} else {
|
||||
None
|
||||
(Prefix::default(), Namespace::default())
|
||||
};
|
||||
return Ok(Attr {
|
||||
namespace: prefix_and_ns,
|
||||
namespace_prefix,
|
||||
namespace_url,
|
||||
attribute: Atom::from(second_token.as_ref()),
|
||||
});
|
||||
},
|
||||
// In the case of attr(foobar ) we don't want to error out
|
||||
// because of the trailing whitespace
|
||||
// because of the trailing whitespace.
|
||||
Token::WhiteSpace(..) => {},
|
||||
ref t => return Err(input.new_unexpected_token_error(t.clone())),
|
||||
}
|
||||
|
@ -841,7 +845,8 @@ impl Attr {
|
|||
|
||||
if let Some(first) = first {
|
||||
Ok(Attr {
|
||||
namespace: None,
|
||||
namespace_prefix: Prefix::default(),
|
||||
namespace_url: Namespace::default(),
|
||||
attribute: Atom::from(first.as_ref()),
|
||||
})
|
||||
} else {
|
||||
|
@ -856,8 +861,8 @@ impl ToCss for Attr {
|
|||
W: Write,
|
||||
{
|
||||
dest.write_str("attr(")?;
|
||||
if let Some((ref prefix, ref _url)) = self.namespace {
|
||||
serialize_atom_identifier(prefix, dest)?;
|
||||
if !self.namespace_prefix.is_empty() {
|
||||
serialize_atom_identifier(&self.namespace_prefix, dest)?;
|
||||
dest.write_str("|")?;
|
||||
}
|
||||
serialize_atom_identifier(&self.attribute, dest)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue