mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Upgrade to rustc d2b30f7d3 2014-09-23
This commit is contained in:
parent
a58324f25b
commit
b3245fa407
51 changed files with 227 additions and 197 deletions
|
@ -39,7 +39,7 @@ pub fn iter_font_face_rules_inner(rules: &[CSSRule], callback: |family: &str, so
|
|||
}
|
||||
|
||||
enum Source {
|
||||
UrlSource(UrlSource),
|
||||
UrlSource_(UrlSource),
|
||||
LocalSource(String),
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ pub fn parse_font_face_rule(rule: AtRule, parent_rules: &mut Vec<CSSRule>, base_
|
|||
match item {
|
||||
DeclAtRule(rule) => log_css_error(
|
||||
rule.location, format!("Unsupported at-rule in declaration list: @{:s}", rule.name).as_slice()),
|
||||
Declaration(Declaration{ location, name, value, important }) => {
|
||||
Declaration_(Declaration{ location, name, value, important }) => {
|
||||
if important {
|
||||
log_css_error(location, "!important is not allowed on @font-face descriptors");
|
||||
continue
|
||||
|
@ -120,7 +120,7 @@ pub fn parse_font_face_rule(rule: AtRule, parent_rules: &mut Vec<CSSRule>, base_
|
|||
/// local() is not supported yet
|
||||
fn parse_one_url_src(iter: ParserIter, base_url: &Url) -> Result<UrlSource, ()> {
|
||||
match parse_one_src(iter, base_url) {
|
||||
Ok(UrlSource(source)) => Ok(source),
|
||||
Ok(UrlSource_(source)) => Ok(source),
|
||||
_ => Err(())
|
||||
}
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ fn parse_one_src(iter: ParserIter, base_url: &Url) -> Result<Source, ()> {
|
|||
None => vec![],
|
||||
};
|
||||
|
||||
Ok(UrlSource(UrlSource {
|
||||
Ok(UrlSource_(UrlSource {
|
||||
url: url,
|
||||
format_hints: format_hints,
|
||||
}))
|
||||
|
@ -171,7 +171,7 @@ fn parse_one_src(iter: ParserIter, base_url: &Url) -> Result<Source, ()> {
|
|||
|
||||
fn parse_one_format(iter: ParserIter) -> Result<String, ()> {
|
||||
match iter.next() {
|
||||
Some(&String(ref value)) => {
|
||||
Some(&QuotedString(ref value)) => {
|
||||
if iter.next().is_none() {
|
||||
Ok(value.clone())
|
||||
} else {
|
||||
|
|
|
@ -33,7 +33,7 @@ pub struct MediaQuery {
|
|||
|
||||
pub enum MediaQueryType {
|
||||
All, // Always true
|
||||
MediaType(MediaType),
|
||||
MediaType_(MediaType),
|
||||
}
|
||||
|
||||
#[deriving(PartialEq)]
|
||||
|
@ -61,8 +61,8 @@ pub fn parse_media_rule(rule: AtRule, parent_rules: &mut Vec<CSSRule>,
|
|||
let mut rules = vec!();
|
||||
for rule in ErrorLoggerIterator(parse_rule_list(block.into_iter())) {
|
||||
match rule {
|
||||
QualifiedRule(rule) => parse_style_rule(rule, &mut rules, namespaces, base_url),
|
||||
AtRule(rule) => parse_nested_at_rule(
|
||||
QualifiedRule_(rule) => parse_style_rule(rule, &mut rules, namespaces, base_url),
|
||||
AtRule_(rule) => parse_nested_at_rule(
|
||||
rule.name.as_slice().to_ascii_lower().as_slice(), rule, &mut rules, namespaces, base_url),
|
||||
}
|
||||
}
|
||||
|
@ -84,8 +84,8 @@ pub fn parse_media_query_list(input: &[ComponentValue]) -> MediaQueryList {
|
|||
let mq = match next {
|
||||
Some(&Ident(ref value)) => {
|
||||
match value.as_slice().to_ascii_lower().as_slice() {
|
||||
"screen" => Some(MediaQuery{ media_type: MediaType(Screen) }),
|
||||
"print" => Some(MediaQuery{ media_type: MediaType(Print) }),
|
||||
"screen" => Some(MediaQuery{ media_type: MediaType_(Screen) }),
|
||||
"print" => Some(MediaQuery{ media_type: MediaType_(Print) }),
|
||||
"all" => Some(MediaQuery{ media_type: All }),
|
||||
_ => None
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ impl MediaQueryList {
|
|||
pub fn evaluate(&self, device: &Device) -> bool {
|
||||
self.media_queries.iter().any(|mq| {
|
||||
match mq.media_type {
|
||||
MediaType(media_type) => media_type == device.media_type,
|
||||
MediaType_(media_type) => media_type == device.media_type,
|
||||
All => true,
|
||||
}
|
||||
// TODO: match Level 3 expressions
|
||||
|
|
|
@ -38,7 +38,7 @@ pub fn parse_namespace_rule(rule: AtRule, namespaces: &mut NamespaceMap) {
|
|||
if prefix.is_some() { syntax_error!() }
|
||||
prefix = Some(value);
|
||||
},
|
||||
URL(value) | String(value) => {
|
||||
URL(value) | QuotedString(value) => {
|
||||
if ns.is_some() { syntax_error!() }
|
||||
ns = Some(Namespace::from_str(Some(value)));
|
||||
break
|
||||
|
|
|
@ -502,7 +502,7 @@ pub mod longhands {
|
|||
pub use super::computed_as_specified as to_computed_value;
|
||||
pub mod computed_value {
|
||||
#[deriving(PartialEq, Clone)]
|
||||
pub enum Content {
|
||||
pub enum ContentItem {
|
||||
StringContent(String),
|
||||
}
|
||||
#[allow(non_camel_case_types)]
|
||||
|
@ -510,7 +510,7 @@ pub mod longhands {
|
|||
pub enum T {
|
||||
normal,
|
||||
none,
|
||||
Content(Vec<Content>),
|
||||
Content(Vec<ContentItem>),
|
||||
}
|
||||
}
|
||||
pub type SpecifiedValue = computed_value::T;
|
||||
|
@ -532,7 +532,7 @@ pub mod longhands {
|
|||
let mut content = vec!();
|
||||
for component_value in input.skip_whitespace() {
|
||||
match component_value {
|
||||
&String(ref value)
|
||||
&QuotedString(ref value)
|
||||
=> content.push(StringContent(value.clone())),
|
||||
_ => return Err(()) // invalid/unsupported value
|
||||
}
|
||||
|
@ -546,7 +546,7 @@ pub mod longhands {
|
|||
|
||||
${new_style_struct("Background", is_inherited=False)}
|
||||
${predefined_type("background-color", "CSSColor",
|
||||
"RGBA(RGBA { red: 0., green: 0., blue: 0., alpha: 0. }) /* transparent */")}
|
||||
"RGBAColor(RGBA { red: 0., green: 0., blue: 0., alpha: 0. }) /* transparent */")}
|
||||
|
||||
<%self:single_component_value name="background-image">
|
||||
// The computed value is the same as the specified value.
|
||||
|
@ -697,7 +697,7 @@ pub mod longhands {
|
|||
pub fn parse_specified(input: &[ComponentValue], _base_url: &Url)
|
||||
-> Result<DeclaredValue<SpecifiedValue>, ()> {
|
||||
match one_component_value(input).and_then(Color::parse) {
|
||||
Ok(RGBA(rgba)) => Ok(SpecifiedValue(rgba)),
|
||||
Ok(RGBAColor(rgba)) => Ok(SpecifiedValue(rgba)),
|
||||
Ok(CurrentColor) => Ok(Inherit),
|
||||
Err(()) => Err(()),
|
||||
}
|
||||
|
@ -738,7 +738,7 @@ pub mod longhands {
|
|||
pub fn parse_one_family<'a>(iter: ParserIter) -> Result<FontFamily, ()> {
|
||||
// TODO: avoid copying strings?
|
||||
let mut idents = match iter.next() {
|
||||
Some(&String(ref value)) => return Ok(FamilyName(value.clone())),
|
||||
Some(&QuotedString(ref value)) => return Ok(FamilyName(value.clone())),
|
||||
Some(&Ident(ref value)) => {
|
||||
// match value.as_slice().to_ascii_lower().as_slice() {
|
||||
// "serif" => return Ok(Serif),
|
||||
|
@ -1461,7 +1461,7 @@ pub fn parse_property_declaration_list<I: Iterator<Node>>(input: I, base_url: &U
|
|||
match item {
|
||||
DeclAtRule(rule) => log_css_error(
|
||||
rule.location, format!("Unsupported at-rule in declaration list: @{:s}", rule.name).as_slice()),
|
||||
Declaration(Declaration{ location: l, name: n, value: v, important: i}) => {
|
||||
Declaration_(Declaration{ location: l, name: n, value: v, important: i}) => {
|
||||
// TODO: only keep the last valid declaration for a given name.
|
||||
let (list, seen) = if i {
|
||||
(&mut important_declarations, &mut important_seen)
|
||||
|
@ -1663,7 +1663,7 @@ impl ComputedValues {
|
|||
#[inline]
|
||||
pub fn resolve_color(&self, color: computed::CSSColor) -> RGBA {
|
||||
match color {
|
||||
RGBA(rgba) => rgba,
|
||||
RGBAColor(rgba) => rgba,
|
||||
CurrentColor => self.get_color().color,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -204,7 +204,7 @@ impl SelectorMap {
|
|||
}
|
||||
|
||||
match SelectorMap::get_local_name(&rule) {
|
||||
Some(LocalNameSelector { name, lower_name }) => {
|
||||
Some(LocalName { name, lower_name }) => {
|
||||
self.local_name_hash.find_push(name, rule.clone());
|
||||
self.lower_local_name_hash.find_push(lower_name, rule);
|
||||
return;
|
||||
|
@ -244,7 +244,7 @@ impl SelectorMap {
|
|||
}
|
||||
|
||||
/// Retrieve the name if it is a type selector, or None otherwise.
|
||||
fn get_local_name(rule: &Rule) -> Option<LocalNameSelector> {
|
||||
fn get_local_name(rule: &Rule) -> Option<LocalName> {
|
||||
let simple_selector_sequence = &rule.selector.simple_selectors;
|
||||
for ss in simple_selector_sequence.iter() {
|
||||
match *ss {
|
||||
|
@ -579,7 +579,7 @@ fn can_fast_reject<'a, E: TElement<'a>, N: TNode<'a, E>>(
|
|||
|
||||
for ss in selector.simple_selectors.iter() {
|
||||
match *ss {
|
||||
LocalNameSelector(LocalNameSelector { ref name, ref lower_name }) => {
|
||||
LocalNameSelector(LocalName { ref name, ref lower_name }) => {
|
||||
if bf.definitely_excludes(name)
|
||||
&& bf.definitely_excludes(lower_name) {
|
||||
return Some(NotMatchedGlobally);
|
||||
|
@ -693,7 +693,7 @@ pub fn matches_simple_selector<'a, E:TElement<'a>,
|
|||
shareable: &mut bool)
|
||||
-> bool {
|
||||
match *selector {
|
||||
LocalNameSelector(LocalNameSelector { ref name, ref lower_name }) => {
|
||||
LocalNameSelector(LocalName { ref name, ref lower_name }) => {
|
||||
let name = if element.is_html_element_in_html_document() { lower_name } else { name };
|
||||
let element = element.as_element();
|
||||
element.get_local_name() == name
|
||||
|
@ -1000,7 +1000,7 @@ mod tests {
|
|||
use servo_util::atom::Atom;
|
||||
use sync::Arc;
|
||||
use super::{DeclarationBlock, Rule, SelectorMap};
|
||||
use selectors::LocalNameSelector;
|
||||
use selectors::LocalName;
|
||||
|
||||
/// Helper method to get some Rules from selector strings.
|
||||
/// Each sublist of the result contains the Rules for one StyleRule.
|
||||
|
@ -1053,7 +1053,7 @@ mod tests {
|
|||
let rules_list = get_mock_rules(["img.foo", "#top", "IMG", "ImG"]);
|
||||
let check = |i, names: Option<(&str, &str)>| {
|
||||
assert!(SelectorMap::get_local_name(&rules_list[i][0])
|
||||
== names.map(|(name, lower_name)| LocalNameSelector {
|
||||
== names.map(|(name, lower_name)| LocalName {
|
||||
name: Atom::from_slice(name),
|
||||
lower_name: Atom::from_slice(lower_name) }))
|
||||
};
|
||||
|
|
|
@ -58,7 +58,7 @@ pub enum Combinator {
|
|||
pub enum SimpleSelector {
|
||||
IDSelector(Atom),
|
||||
ClassSelector(Atom),
|
||||
LocalNameSelector(LocalNameSelector),
|
||||
LocalNameSelector(LocalName),
|
||||
NamespaceSelector(Namespace),
|
||||
|
||||
// Attribute selectors
|
||||
|
@ -93,7 +93,7 @@ pub enum SimpleSelector {
|
|||
}
|
||||
|
||||
#[deriving(Eq, PartialEq, Clone, Hash)]
|
||||
pub struct LocalNameSelector {
|
||||
pub struct LocalName {
|
||||
pub name: Atom,
|
||||
pub lower_name: Atom,
|
||||
}
|
||||
|
@ -292,7 +292,7 @@ fn parse_type_selector<I: Iterator<ComponentValue>>(
|
|||
}
|
||||
match local_name {
|
||||
Some(name) => {
|
||||
simple_selectors.push(LocalNameSelector(LocalNameSelector {
|
||||
simple_selectors.push(LocalNameSelector(LocalName {
|
||||
name: Atom::from_slice(name.as_slice()),
|
||||
lower_name: Atom::from_slice(name.into_ascii_lower().as_slice())
|
||||
}))
|
||||
|
@ -451,7 +451,7 @@ fn parse_attribute_selector(content: Vec<ComponentValue>, namespaces: &Namespace
|
|||
macro_rules! get_value( () => {{
|
||||
skip_whitespace(iter);
|
||||
match iter.next() {
|
||||
Some(Ident(value)) | Some(String(value)) => value,
|
||||
Some(Ident(value)) | Some(QuotedString(value)) => value,
|
||||
_ => return Err(())
|
||||
}
|
||||
}};)
|
||||
|
@ -597,7 +597,7 @@ mod tests {
|
|||
assert!(parse("") == Err(()))
|
||||
assert!(parse("EeÉ") == Ok(vec!(Selector {
|
||||
compound_selectors: Arc::new(CompoundSelector {
|
||||
simple_selectors: vec!(LocalNameSelector(LocalNameSelector {
|
||||
simple_selectors: vec!(LocalNameSelector(LocalName {
|
||||
name: Atom::from_slice("EeÉ"),
|
||||
lower_name: Atom::from_slice("eeÉ") })),
|
||||
next: None,
|
||||
|
@ -623,7 +623,7 @@ mod tests {
|
|||
})))
|
||||
assert!(parse("e.foo#bar") == Ok(vec!(Selector {
|
||||
compound_selectors: Arc::new(CompoundSelector {
|
||||
simple_selectors: vec!(LocalNameSelector(LocalNameSelector {
|
||||
simple_selectors: vec!(LocalNameSelector(LocalName {
|
||||
name: Atom::from_slice("e"),
|
||||
lower_name: Atom::from_slice("e") }),
|
||||
ClassSelector(Atom::from_slice("foo")),
|
||||
|
@ -637,7 +637,7 @@ mod tests {
|
|||
compound_selectors: Arc::new(CompoundSelector {
|
||||
simple_selectors: vec!(IDSelector(Atom::from_slice("bar"))),
|
||||
next: Some((box CompoundSelector {
|
||||
simple_selectors: vec!(LocalNameSelector(LocalNameSelector {
|
||||
simple_selectors: vec!(LocalNameSelector(LocalName {
|
||||
name: Atom::from_slice("e"),
|
||||
lower_name: Atom::from_slice("e") }),
|
||||
ClassSelector(Atom::from_slice("foo"))),
|
||||
|
@ -682,7 +682,7 @@ mod tests {
|
|||
compound_selectors: Arc::new(CompoundSelector {
|
||||
simple_selectors: vec!(
|
||||
NamespaceSelector(namespace::MathML),
|
||||
LocalNameSelector(LocalNameSelector {
|
||||
LocalNameSelector(LocalName {
|
||||
name: Atom::from_slice("e"),
|
||||
lower_name: Atom::from_slice("e") }),
|
||||
),
|
||||
|
@ -704,7 +704,7 @@ mod tests {
|
|||
compound_selectors: Arc::new(CompoundSelector {
|
||||
simple_selectors: vec!(),
|
||||
next: Some((box CompoundSelector {
|
||||
simple_selectors: vec!(LocalNameSelector(LocalNameSelector {
|
||||
simple_selectors: vec!(LocalNameSelector(LocalName {
|
||||
name: Atom::from_slice("div"),
|
||||
lower_name: Atom::from_slice("div") })),
|
||||
next: None,
|
||||
|
|
|
@ -73,11 +73,11 @@ impl Stylesheet {
|
|||
for rule in ErrorLoggerIterator(parse_stylesheet_rules(tokenize(css))) {
|
||||
let next_state; // Unitialized to force each branch to set it.
|
||||
match rule {
|
||||
QualifiedRule(rule) => {
|
||||
QualifiedRule_(rule) => {
|
||||
next_state = STATE_BODY;
|
||||
parse_style_rule(rule, &mut rules, &namespaces, &base_url)
|
||||
},
|
||||
AtRule(rule) => {
|
||||
AtRule_(rule) => {
|
||||
let lower_name = rule.name.as_slice().to_ascii_lower();
|
||||
match lower_name.as_slice() {
|
||||
"charset" => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue