mirror of
https://github.com/servo/servo.git
synced 2025-08-11 16:35:33 +01:00
stylo: Use namespace ids for content: attr(..)
MozReview-Commit-ID: FZ9YEpHQCBh
This commit is contained in:
parent
7deeccf4cb
commit
25d193ba34
7 changed files with 57 additions and 16 deletions
|
@ -14,6 +14,8 @@
|
|||
use values::generics::CounterStyleOrNone;
|
||||
#[cfg(feature = "gecko")]
|
||||
use values::specified::url::SpecifiedUrl;
|
||||
#[cfg(feature = "gecko")]
|
||||
use gecko_string_cache::namespace::Namespace;
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
use super::list_style_type;
|
||||
|
@ -35,6 +37,8 @@
|
|||
type CounterStyleType = super::super::list_style_type::computed_value::T;
|
||||
#[cfg(feature = "gecko")]
|
||||
type CounterStyleType = ::values::generics::CounterStyleOrNone;
|
||||
#[cfg(feature = "gecko")]
|
||||
use gecko_string_cache::namespace::Namespace;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
|
@ -56,7 +60,7 @@
|
|||
|
||||
% if product == "gecko":
|
||||
/// `attr([namespace? `|`]? ident)`
|
||||
Attr(Option<String>, String),
|
||||
Attr(Option<(Namespace, u32)>, String),
|
||||
/// `url(url)`
|
||||
Url(SpecifiedUrl),
|
||||
% endif
|
||||
|
@ -93,7 +97,7 @@
|
|||
ContentItem::Attr(ref ns, ref attr) => {
|
||||
dest.write_str("attr(")?;
|
||||
if let Some(ref ns) = *ns {
|
||||
cssparser::Token::Ident((&**ns).into()).to_css(dest)?;
|
||||
cssparser::Token::Ident(ns.0.to_string().into()).to_css(dest)?;
|
||||
dest.write_str("|")?;
|
||||
}
|
||||
cssparser::Token::Ident((&**attr).into()).to_css(dest)?;
|
||||
|
@ -208,14 +212,29 @@
|
|||
// FIXME (bug 1346693) we should be checking that
|
||||
// this is a valid namespace and encoding it as a namespace
|
||||
// number from the map
|
||||
let first = input.try(|i| i.expect_ident()).ok().map(|i| i.into_owned());
|
||||
let first = input.try(|i| i.expect_ident()).ok();
|
||||
if let Ok(token) = input.try(|i| i.next_including_whitespace()) {
|
||||
match token {
|
||||
Token::Delim('|') => {
|
||||
// must be followed by an ident
|
||||
let tok2 = input.next_including_whitespace()?;
|
||||
if let Token::Ident(second) = tok2 {
|
||||
return Ok(ContentItem::Attr(first, second.into_owned()))
|
||||
let first: Option<Namespace> = first.map(|i| i.into());
|
||||
let first_with_id = match (first, context.namespaces) {
|
||||
(Some(prefix), Some(map)) => {
|
||||
let map = map.read();
|
||||
if let Some(ref entry) = map.prefixes.get(&prefix.0) {
|
||||
Some((prefix, entry.1))
|
||||
} else {
|
||||
return Err(())
|
||||
}
|
||||
}
|
||||
// if we don't have a namespace map (e.g. in CSSOM)
|
||||
// we can't parse namespaces
|
||||
(Some(_), None) => return Err(()),
|
||||
_ => None
|
||||
};
|
||||
return Ok(ContentItem::Attr(first_with_id, second.into_owned()))
|
||||
} else {
|
||||
return Err(())
|
||||
}
|
||||
|
@ -224,7 +243,7 @@
|
|||
}
|
||||
}
|
||||
if let Some(first) = first {
|
||||
Ok(ContentItem::Attr(None, first))
|
||||
Ok(ContentItem::Attr(None, first.into_owned()))
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue