mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Rust upgrade to rustc hash b03a2755193cd756583bcf5831cf4545d75ecb8a
This commit is contained in:
parent
26045d7fcb
commit
d1b433a3b3
160 changed files with 1427 additions and 1162 deletions
|
@ -15,7 +15,7 @@ impl<T, I: Iterator<Result<T, SyntaxError>>> Iterator<T> for ErrorLoggerIterator
|
|||
match this.next() {
|
||||
Some(Ok(v)) => return Some(v),
|
||||
Some(Err(error)) => log_css_error(error.location,
|
||||
format!("{:?}", error.reason).as_slice()),
|
||||
format!("{}", error.reason).as_slice()),
|
||||
None => return None,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use cssparser::ast::*;
|
||||
use cssparser::parse_declaration_list;
|
||||
use errors::{ErrorLoggerIterator, log_css_error};
|
||||
use std::ascii::StrAsciiExt;
|
||||
use std::ascii::AsciiExt;
|
||||
use parsing_utils::{BufferedIter, ParserIter, parse_slice_comma_separated};
|
||||
use properties::longhands::font_family::parse_one_family;
|
||||
use properties::computed_values::font_family::FamilyName;
|
||||
|
|
|
@ -7,16 +7,15 @@
|
|||
|
||||
#![feature(globs, macro_rules)]
|
||||
|
||||
#![deny(unused_imports, unused_variable)]
|
||||
#![deny(unused_imports)]
|
||||
#![deny(unused_variables)]
|
||||
|
||||
#![feature(phase)]
|
||||
#[phase(plugin, link)] extern crate log;
|
||||
#[phase(plugin)] extern crate string_cache_macros;
|
||||
|
||||
extern crate debug;
|
||||
extern crate collections;
|
||||
extern crate geom;
|
||||
extern crate num;
|
||||
extern crate serialize;
|
||||
extern crate sync;
|
||||
extern crate url;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::ascii::StrAsciiExt;
|
||||
use std::ascii::AsciiExt;
|
||||
use cssparser::parse_rule_list;
|
||||
use cssparser::ast::*;
|
||||
|
||||
|
@ -28,7 +28,7 @@ pub struct MediaQueryList {
|
|||
pub enum Range<T> {
|
||||
Min(T),
|
||||
Max(T),
|
||||
Eq(T),
|
||||
//Eq(T), // FIXME: Implement parsing support for equality then re-enable this.
|
||||
}
|
||||
|
||||
impl<T: Ord> Range<T> {
|
||||
|
@ -36,7 +36,7 @@ impl<T: Ord> Range<T> {
|
|||
match *self {
|
||||
Min(ref width) => { value >= *width },
|
||||
Max(ref width) => { value <= *width },
|
||||
Eq(ref width) => { value == *width },
|
||||
//Eq(ref width) => { value == *width },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -479,7 +479,7 @@ mod tests {
|
|||
assert!(q.expressions.len() == 1, css.to_string());
|
||||
match q.expressions[0] {
|
||||
Width(Min(w)) => assert!(w == Au::from_px(100)),
|
||||
_ => fail!("wrong expression type"),
|
||||
_ => panic!("wrong expression type"),
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -491,7 +491,7 @@ mod tests {
|
|||
assert!(q.expressions.len() == 1, css.to_string());
|
||||
match q.expressions[0] {
|
||||
Width(Max(w)) => assert!(w == Au::from_px(43)),
|
||||
_ => fail!("wrong expression type"),
|
||||
_ => panic!("wrong expression type"),
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -506,7 +506,7 @@ mod tests {
|
|||
assert!(q.expressions.len() == 1, css.to_string());
|
||||
match q.expressions[0] {
|
||||
Width(Min(w)) => assert!(w == Au::from_px(100)),
|
||||
_ => fail!("wrong expression type"),
|
||||
_ => panic!("wrong expression type"),
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -518,7 +518,7 @@ mod tests {
|
|||
assert!(q.expressions.len() == 1, css.to_string());
|
||||
match q.expressions[0] {
|
||||
Width(Max(w)) => assert!(w == Au::from_px(43)),
|
||||
_ => fail!("wrong expression type"),
|
||||
_ => panic!("wrong expression type"),
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -530,7 +530,7 @@ mod tests {
|
|||
assert!(q.expressions.len() == 1, css.to_string());
|
||||
match q.expressions[0] {
|
||||
Width(Max(w)) => assert!(w == Au::from_px(52)),
|
||||
_ => fail!("wrong expression type"),
|
||||
_ => panic!("wrong expression type"),
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -545,11 +545,11 @@ mod tests {
|
|||
assert!(q.expressions.len() == 2, css.to_string());
|
||||
match q.expressions[0] {
|
||||
Width(Min(w)) => assert!(w == Au::from_px(100)),
|
||||
_ => fail!("wrong expression type"),
|
||||
_ => panic!("wrong expression type"),
|
||||
}
|
||||
match q.expressions[1] {
|
||||
Width(Max(w)) => assert!(w == Au::from_px(200)),
|
||||
_ => fail!("wrong expression type"),
|
||||
_ => panic!("wrong expression type"),
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -561,11 +561,11 @@ mod tests {
|
|||
assert!(q.expressions.len() == 2, css.to_string());
|
||||
match q.expressions[0] {
|
||||
Width(Min(w)) => assert!(w == Au::from_px(100)),
|
||||
_ => fail!("wrong expression type"),
|
||||
_ => panic!("wrong expression type"),
|
||||
}
|
||||
match q.expressions[1] {
|
||||
Width(Max(w)) => assert!(w == Au::from_px(200)),
|
||||
_ => fail!("wrong expression type"),
|
||||
_ => panic!("wrong expression type"),
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use cssparser::ast::*;
|
||||
use std::collections::hashmap::HashMap;
|
||||
use std::collections::HashMap;
|
||||
use servo_util::namespace;
|
||||
use errors::log_css_error;
|
||||
use string_cache::Namespace;
|
||||
|
@ -50,7 +50,7 @@ pub fn parse_namespace_rule(rule: AtRule, namespaces: &mut NamespaceMap) {
|
|||
if iter.next().is_some() { syntax_error!() }
|
||||
match (prefix, ns) {
|
||||
(Some(prefix), Some(ns)) => {
|
||||
if namespaces.prefix_map.swap(prefix, ns).is_some() {
|
||||
if namespaces.prefix_map.insert(prefix, ns).is_some() {
|
||||
log_css_error(location, "Duplicate @namespace rule");
|
||||
}
|
||||
},
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
use std::ascii::StrAsciiExt;
|
||||
use std::ascii::AsciiExt;
|
||||
use cssparser::ast::{ComponentValue, Ident, Comma, SkipWhitespaceIterable, SkipWhitespaceIterator};
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ pub type CSSFloat = f64;
|
|||
pub static DEFAULT_LINE_HEIGHT: CSSFloat = 1.14;
|
||||
|
||||
pub mod specified {
|
||||
use std::ascii::StrAsciiExt;
|
||||
use std::ascii::AsciiExt;
|
||||
use std::f64::consts::PI;
|
||||
use url::Url;
|
||||
use cssparser::ast;
|
||||
|
@ -42,12 +42,12 @@ pub mod specified {
|
|||
// Vmin(CSSFloat),
|
||||
// Vmax(CSSFloat),
|
||||
}
|
||||
static AU_PER_PX: CSSFloat = 60.;
|
||||
static AU_PER_IN: CSSFloat = AU_PER_PX * 96.;
|
||||
static AU_PER_CM: CSSFloat = AU_PER_IN / 2.54;
|
||||
static AU_PER_MM: CSSFloat = AU_PER_IN / 25.4;
|
||||
static AU_PER_PT: CSSFloat = AU_PER_IN / 72.;
|
||||
static AU_PER_PC: CSSFloat = AU_PER_PT * 12.;
|
||||
const AU_PER_PX: CSSFloat = 60.;
|
||||
const AU_PER_IN: CSSFloat = AU_PER_PX * 96.;
|
||||
const AU_PER_CM: CSSFloat = AU_PER_IN / 2.54;
|
||||
const AU_PER_MM: CSSFloat = AU_PER_IN / 25.4;
|
||||
const AU_PER_PT: CSSFloat = AU_PER_IN / 72.;
|
||||
const AU_PER_PC: CSSFloat = AU_PER_PT * 12.;
|
||||
impl Length {
|
||||
#[inline]
|
||||
fn parse_internal(input: &ComponentValue, negative_ok: bool) -> Result<Length, ()> {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
// This file is a Mako template: http://www.makotemplates.org/
|
||||
|
||||
pub use std::ascii::StrAsciiExt;
|
||||
pub use std::ascii::AsciiExt;
|
||||
|
||||
use servo_util::logical_geometry::{WritingMode, LogicalMargin};
|
||||
use sync::Arc;
|
||||
|
@ -160,7 +160,7 @@ pub mod longhands {
|
|||
${caller.body()}
|
||||
pub mod computed_value {
|
||||
#[allow(non_camel_case_types)]
|
||||
#[deriving(PartialEq, Clone, FromPrimitive)]
|
||||
#[deriving(PartialEq, Clone, FromPrimitive, Show)]
|
||||
pub enum T {
|
||||
% for value in values.split():
|
||||
${to_rust_ident(value)},
|
||||
|
@ -942,7 +942,7 @@ pub mod longhands {
|
|||
use super::super::Au;
|
||||
pub type T = Au;
|
||||
}
|
||||
static MEDIUM_PX: int = 16;
|
||||
const MEDIUM_PX: int = 16;
|
||||
#[inline] pub fn get_initial_value() -> computed_value::T {
|
||||
Au::from_px(MEDIUM_PX)
|
||||
}
|
||||
|
@ -999,7 +999,8 @@ pub mod longhands {
|
|||
}
|
||||
pub mod computed_value {
|
||||
pub type T = super::SpecifiedValue;
|
||||
pub static none: T = super::SpecifiedValue { underline: false, overline: false, line_through: false };
|
||||
#[allow(non_upper_case_globals)]
|
||||
pub const none: T = super::SpecifiedValue { underline: false, overline: false, line_through: false };
|
||||
}
|
||||
#[inline] pub fn get_initial_value() -> computed_value::T {
|
||||
none
|
||||
|
@ -1845,27 +1846,27 @@ fn get_writing_mode(inheritedbox_style: &style_structs::InheritedBox) -> Writing
|
|||
match inheritedbox_style.direction {
|
||||
computed_values::direction::ltr => {},
|
||||
computed_values::direction::rtl => {
|
||||
flags.insert(logical_geometry::FlagRTL);
|
||||
flags.insert(logical_geometry::FLAG_RTL);
|
||||
},
|
||||
}
|
||||
match inheritedbox_style.writing_mode {
|
||||
computed_values::writing_mode::horizontal_tb => {},
|
||||
computed_values::writing_mode::vertical_rl => {
|
||||
flags.insert(logical_geometry::FlagVertical);
|
||||
flags.insert(logical_geometry::FLAG_VERTICAL);
|
||||
},
|
||||
computed_values::writing_mode::vertical_lr => {
|
||||
flags.insert(logical_geometry::FlagVertical);
|
||||
flags.insert(logical_geometry::FlagVerticalLR);
|
||||
flags.insert(logical_geometry::FLAG_VERTICAL);
|
||||
flags.insert(logical_geometry::FLAG_VERTICAL_LR);
|
||||
},
|
||||
}
|
||||
match inheritedbox_style.text_orientation {
|
||||
computed_values::text_orientation::sideways_right => {},
|
||||
computed_values::text_orientation::sideways_left => {
|
||||
flags.insert(logical_geometry::FlagSidewaysLeft);
|
||||
flags.insert(logical_geometry::FLAG_VERTICAL_LR);
|
||||
},
|
||||
computed_values::text_orientation::sideways => {
|
||||
if flags.intersects(logical_geometry::FlagVerticalLR) {
|
||||
flags.insert(logical_geometry::FlagSidewaysLeft);
|
||||
if flags.intersects(logical_geometry::FLAG_VERTICAL_LR) {
|
||||
flags.insert(logical_geometry::FLAG_SIDEWAYS_LEFT);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::ascii::AsciiExt;
|
||||
use std::collections::hashmap::HashMap;
|
||||
use std::collections::HashMap;
|
||||
use std::hash::Hash;
|
||||
use std::num::div_rem;
|
||||
use sync::Arc;
|
||||
|
@ -155,7 +155,7 @@ impl SelectorMap {
|
|||
where E: TElement<'a> + TElementAttributes,
|
||||
N: TNode<'a,E>,
|
||||
V: VecLike<DeclarationBlock> {
|
||||
match hash.find(key) {
|
||||
match hash.get(key) {
|
||||
Some(rules) => {
|
||||
SelectorMap::get_matching_rules(node,
|
||||
parent_bf,
|
||||
|
@ -813,11 +813,11 @@ fn matches_compound_selector_internal<'a,E,N>(selector: &CompoundSelector,
|
|||
|
||||
bitflags! {
|
||||
flags CommonStyleAffectingAttributes: u8 {
|
||||
static HiddenAttribute = 0x01,
|
||||
static NoWrapAttribute = 0x02,
|
||||
static AlignLeftAttribute = 0x04,
|
||||
static AlignCenterAttribute = 0x08,
|
||||
static AlignRightAttribute = 0x10,
|
||||
const HIDDEN_ATTRIBUTE = 0x01,
|
||||
const NO_WRAP_ATTRIBUTE = 0x02,
|
||||
const ALIGN_LEFT_ATTRIBUTE = 0x04,
|
||||
const ALIGN_CENTER_ATTRIBUTE = 0x08,
|
||||
const ALIGN_RIGHT_ATTRIBUTE = 0x10,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -837,23 +837,23 @@ pub fn common_style_affecting_attributes() -> [CommonStyleAffectingAttributeInfo
|
|||
[
|
||||
CommonStyleAffectingAttributeInfo {
|
||||
atom: atom!("hidden"),
|
||||
mode: AttrIsPresentMode(HiddenAttribute),
|
||||
mode: AttrIsPresentMode(HIDDEN_ATTRIBUTE),
|
||||
},
|
||||
CommonStyleAffectingAttributeInfo {
|
||||
atom: atom!("nowrap"),
|
||||
mode: AttrIsPresentMode(NoWrapAttribute),
|
||||
mode: AttrIsPresentMode(NO_WRAP_ATTRIBUTE),
|
||||
},
|
||||
CommonStyleAffectingAttributeInfo {
|
||||
atom: atom!("align"),
|
||||
mode: AttrIsEqualMode("left", AlignLeftAttribute),
|
||||
mode: AttrIsEqualMode("left", ALIGN_LEFT_ATTRIBUTE),
|
||||
},
|
||||
CommonStyleAffectingAttributeInfo {
|
||||
atom: atom!("align"),
|
||||
mode: AttrIsEqualMode("center", AlignCenterAttribute),
|
||||
mode: AttrIsEqualMode("center", ALIGN_CENTER_ATTRIBUTE),
|
||||
},
|
||||
CommonStyleAffectingAttributeInfo {
|
||||
atom: atom!("align"),
|
||||
mode: AttrIsEqualMode("right", AlignRightAttribute),
|
||||
mode: AttrIsEqualMode("right", ALIGN_RIGHT_ATTRIBUTE),
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -1176,7 +1176,7 @@ trait FindPush<K, V> {
|
|||
|
||||
impl<K: Eq + Hash, V> FindPush<K, V> for HashMap<K, Vec<V>> {
|
||||
fn find_push(&mut self, key: K, value: V) {
|
||||
match self.find_mut(&key) {
|
||||
match self.get_mut(&key) {
|
||||
Some(vec) => {
|
||||
vec.push(value);
|
||||
return
|
||||
|
@ -1266,4 +1266,3 @@ mod tests {
|
|||
assert!(selector_map.class_hash.find(&Atom::from_slice("foo")).is_none());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::{cmp, iter};
|
||||
use std::ascii::{StrAsciiExt, OwnedStrAsciiExt};
|
||||
use std::ascii::{AsciiExt, OwnedAsciiExt};
|
||||
use sync::Arc;
|
||||
|
||||
use cssparser::ast::*;
|
||||
|
@ -14,14 +14,6 @@ use string_cache::{Atom, Namespace};
|
|||
use namespaces::NamespaceMap;
|
||||
|
||||
|
||||
// Only used in tests
|
||||
impl PartialEq for Arc<CompoundSelector> {
|
||||
fn eq(&self, other: &Arc<CompoundSelector>) -> bool {
|
||||
**self == **other
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[deriving(PartialEq, Clone)]
|
||||
pub struct Selector {
|
||||
pub compound_selectors: Arc<CompoundSelector>,
|
||||
|
@ -328,7 +320,7 @@ fn parse_one_simple_selector<I: Iterator<ComponentValue>>(
|
|||
Some(&IDHash(_)) => match iter.next() {
|
||||
Some(IDHash(id)) => Ok(Some(SimpleSelectorResult(
|
||||
IDSelector(Atom::from_slice(id.as_slice()))))),
|
||||
_ => fail!("Implementation error, this should not happen."),
|
||||
_ => panic!("Implementation error, this should not happen."),
|
||||
},
|
||||
Some(&Delim('.')) => {
|
||||
iter.next();
|
||||
|
@ -341,7 +333,7 @@ fn parse_one_simple_selector<I: Iterator<ComponentValue>>(
|
|||
Some(&SquareBracketBlock(_)) => match iter.next() {
|
||||
Some(SquareBracketBlock(content))
|
||||
=> Ok(Some(SimpleSelectorResult(try!(parse_attribute_selector(content, namespaces))))),
|
||||
_ => fail!("Implementation error, this should not happen."),
|
||||
_ => panic!("Implementation error, this should not happen."),
|
||||
},
|
||||
Some(&Colon) => {
|
||||
iter.next();
|
||||
|
@ -413,7 +405,7 @@ fn parse_qualified_name<I: Iterator<ComponentValue>>(
|
|||
let value = get_next_ident(iter);
|
||||
match iter.peek() {
|
||||
Some(&Delim('|')) => {
|
||||
let namespace = match namespaces.prefix_map.find(&value) {
|
||||
let namespace = match namespaces.prefix_map.get(&value) {
|
||||
None => return Err(()), // Undeclared namespace prefix
|
||||
Some(ref ns) => (*ns).clone(),
|
||||
};
|
||||
|
@ -445,7 +437,7 @@ fn parse_attribute_selector(content: Vec<ComponentValue>, namespaces: &Namespace
|
|||
let iter = &mut content.into_iter().peekable();
|
||||
let attr = match try!(parse_qualified_name(iter, /* in_attr_selector = */ true, namespaces)) {
|
||||
None => return Err(()),
|
||||
Some((_, None)) => fail!("Implementation error, this should not happen."),
|
||||
Some((_, None)) => panic!("Implementation error, this should not happen."),
|
||||
Some((namespace, Some(local_name))) => AttrSelector {
|
||||
namespace: namespace,
|
||||
lower_name: Atom::from_slice(local_name.as_slice().to_ascii_lower().as_slice()),
|
||||
|
@ -578,7 +570,7 @@ fn parse_negation(arguments: Vec<ComponentValue>, namespaces: &NamespaceMap)
|
|||
fn get_next_ident<I: Iterator<ComponentValue>>(iter: &mut Iter<I>) -> String {
|
||||
match iter.next() {
|
||||
Some(Ident(value)) => value,
|
||||
_ => fail!("Implementation error, this should not happen."),
|
||||
_ => panic!("Implementation error, this should not happen."),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::iter::Iterator;
|
||||
use std::ascii::StrAsciiExt;
|
||||
use std::ascii::AsciiExt;
|
||||
use url::Url;
|
||||
|
||||
use encoding::EncodingRef;
|
||||
|
@ -131,7 +131,7 @@ impl Stylesheet {
|
|||
|
||||
pub fn parse_style_rule(rule: QualifiedRule, parent_rules: &mut Vec<CSSRule>,
|
||||
namespaces: &NamespaceMap, base_url: &Url) {
|
||||
let QualifiedRule{location: location, prelude: prelude, block: block} = rule;
|
||||
let QualifiedRule { location, prelude, block} = rule;
|
||||
// FIXME: avoid doing this for valid selectors
|
||||
let serialized = prelude.iter().to_css();
|
||||
match selectors::parse_selector_list(prelude.into_iter(), namespaces) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue