mirror of
https://github.com/servo/servo.git
synced 2025-06-24 17:14:33 +01:00
Update to rustc 0.8-pre (ecfc9a8 2013-08-12 04:29:11 -0700)
This commit is contained in:
parent
70c281fc25
commit
c1b7e157b7
6 changed files with 39 additions and 13 deletions
|
@ -6,5 +6,5 @@ based on [rust-cssparser](https://github.com/mozilla-servo/rust-cssparser)
|
|||
instead of [NetSurf’s libcss](https://github.com/mozilla-servo/libcss).
|
||||
|
||||
This is meant to go into Servo’s `src/components/script/style` directory,
|
||||
but is maintained here for now because I’m using a patched Rust.
|
||||
(See [pull request](https://github.com/mozilla/rust/pull/8396).)
|
||||
but is maintained here for now because it requires at least
|
||||
Rust ecfc9a8 (2013-08-12).
|
||||
|
|
|
@ -56,7 +56,7 @@ pub fn parse_media_rule(rule: AtRule, parent_rules: &mut ~[CSSRule],
|
|||
}
|
||||
};
|
||||
let mut rules = ~[];
|
||||
for rule in ErrorLoggerIterator(parse_rule_list(block.consume_iter())) {
|
||||
for rule in ErrorLoggerIterator(parse_rule_list(block.move_iter())) {
|
||||
match rule {
|
||||
QualifiedRule(rule) => parse_style_rule(rule, &mut rules, namespaces),
|
||||
AtRule(rule) => parse_nested_at_rule(
|
||||
|
|
|
@ -30,7 +30,7 @@ pub fn parse_namespace_rule(rule: AtRule, namespaces: &mut NamespaceMap) {
|
|||
if rule.block.is_some() { syntax_error!() }
|
||||
let mut prefix: Option<~str> = None;
|
||||
let mut url: Option<~str> = None;
|
||||
let mut iter = rule.prelude.consume_skip_whitespace();
|
||||
let mut iter = rule.prelude.move_skip_whitespace();
|
||||
for component_value in iter {
|
||||
match component_value {
|
||||
Ident(value) => {
|
||||
|
|
|
@ -2,13 +2,39 @@
|
|||
* 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::to_ascii_lower;
|
||||
use cssparser::*;
|
||||
use errors::{ErrorLoggerIterator, log_css_error};
|
||||
|
||||
|
||||
pub struct PropertyDeclarationBlock {
|
||||
important: ~[PropertyDeclaration],
|
||||
normal: ~[PropertyDeclaration],
|
||||
}
|
||||
|
||||
pub struct PropertyDeclaration; // TODO
|
||||
|
||||
|
||||
pub fn parse_property_declaration_list(input: &[Node]) -> ~[PropertyDeclaration] {
|
||||
let _ = input;
|
||||
~[]
|
||||
pub fn parse_property_declaration_list(input: ~[Node]) -> PropertyDeclarationBlock {
|
||||
let mut important = ~[];
|
||||
let mut normal = ~[];
|
||||
for item in ErrorLoggerIterator(parse_declaration_list(input.move_iter())) {
|
||||
match item {
|
||||
Decl_AtRule(rule) => log_css_error(
|
||||
rule.location, fmt!("Unsupported at-rule in declaration list: @%s", rule.name)),
|
||||
Declaration(Declaration{ location: l, name: n, value: v, important: i}) => {
|
||||
let list = if i { &mut important } else { &mut normal };
|
||||
if !parse_one_property_declaration(to_ascii_lower(n), v, list) {
|
||||
log_css_error(l, "Invalid property declaration")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
PropertyDeclarationBlock { important: important, normal: normal }
|
||||
}
|
||||
|
||||
|
||||
fn parse_one_property_declaration(name: &str, value: ~[ComponentValue],
|
||||
result_list: &mut ~[PropertyDeclaration]) -> bool {
|
||||
false
|
||||
}
|
||||
|
|
10
selectors.rs
10
selectors.rs
|
@ -68,13 +68,13 @@ pub struct AttrSelector {
|
|||
}
|
||||
|
||||
|
||||
type Iter = iterator::Peekable<ComponentValue, vec::ConsumeIterator<ComponentValue>>;
|
||||
type Iter = iterator::Peekable<ComponentValue, vec::MoveIterator<ComponentValue>>;
|
||||
|
||||
|
||||
// None means invalid selector
|
||||
pub fn parse_selector_list(input: ~[ComponentValue], namespaces: &NamespaceMap)
|
||||
-> Option<~[Selector]> {
|
||||
let iter = &mut input.consume_iter().peekable();
|
||||
let iter = &mut input.move_iter().peekable();
|
||||
let first = match parse_selector(iter, namespaces) {
|
||||
None => return None,
|
||||
Some(result) => result
|
||||
|
@ -359,7 +359,7 @@ fn parse_qualified_name(iter: &mut Iter, allow_universal: bool, namespaces: &Nam
|
|||
|
||||
fn parse_attribute_selector(content: ~[ComponentValue], namespaces: &NamespaceMap)
|
||||
-> Option<SimpleSelector> {
|
||||
let iter = &mut content.consume_iter().peekable();
|
||||
let iter = &mut content.move_iter().peekable();
|
||||
let attr = match parse_qualified_name(iter, /* allow_universal = */ false, namespaces) {
|
||||
None => return None, // invalid selector
|
||||
Some(None) => return None,
|
||||
|
@ -436,7 +436,7 @@ fn parse_pseudo_element(name: ~str) -> Option<PseudoElement> {
|
|||
|
||||
|
||||
fn parse_lang(arguments: ~[ComponentValue]) -> Option<SimpleSelector> {
|
||||
let mut iter = arguments.consume_skip_whitespace();
|
||||
let mut iter = arguments.move_skip_whitespace();
|
||||
match iter.next() {
|
||||
Some(Ident(value)) => {
|
||||
if "" == value || iter.next().is_some() { None }
|
||||
|
@ -450,7 +450,7 @@ fn parse_lang(arguments: ~[ComponentValue]) -> Option<SimpleSelector> {
|
|||
// Level 3: Parse ONE simple_selector
|
||||
fn parse_negation(arguments: ~[ComponentValue], namespaces: &NamespaceMap)
|
||||
-> Option<SimpleSelector> {
|
||||
let iter = &mut arguments.consume_iter().peekable();
|
||||
let iter = &mut arguments.move_iter().peekable();
|
||||
Some(Negation(match parse_type_selector(iter, namespaces) {
|
||||
None => return None, // invalid selector
|
||||
Some(Some(s)) => s,
|
||||
|
|
|
@ -27,7 +27,7 @@ pub enum CSSRule {
|
|||
|
||||
pub struct StyleRule {
|
||||
selectors: ~[selectors::Selector],
|
||||
declarations: ~[properties::PropertyDeclaration],
|
||||
declarations: properties::PropertyDeclarationBlock,
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue