diff options
author | Patrick Walton <pcwalton@mimiga.net> | 2012-10-04 11:02:53 -0700 |
---|---|---|
committer | Patrick Walton <pcwalton@mimiga.net> | 2012-10-04 15:28:10 -0700 |
commit | 994c47d22b0a3603978d4b6dcb8ffed72e65ac9a (patch) | |
tree | 6939083c1dd3a6cf070a92214573c95cdd1f1833 /src/servo/css | |
parent | e105f3b5571f0cbfae3fc6a96938d4d039bb660d (diff) | |
download | servo-994c47d22b0a3603978d4b6dcb8ffed72e65ac9a.tar.gz servo-994c47d22b0a3603978d4b6dcb8ffed72e65ac9a.zip |
Update for language changes; remove pipe protocols.
Diffstat (limited to 'src/servo/css')
-rw-r--r-- | src/servo/css/lexer.rs | 10 | ||||
-rw-r--r-- | src/servo/css/parser.rs | 20 | ||||
-rw-r--r-- | src/servo/css/parser_util.rs | 16 | ||||
-rw-r--r-- | src/servo/css/resolve/apply.rs | 5 | ||||
-rw-r--r-- | src/servo/css/resolve/matching.rs | 2 | ||||
-rw-r--r-- | src/servo/css/values.rs | 6 |
6 files changed, 30 insertions, 29 deletions
diff --git a/src/servo/css/lexer.rs b/src/servo/css/lexer.rs index dfe467ec04b..7c949e745c6 100644 --- a/src/servo/css/lexer.rs +++ b/src/servo/css/lexer.rs @@ -23,7 +23,7 @@ type CssLexer = { mut parser_state: ParserState }; -enum Token { +pub enum Token { StartDescription, EndDescription, Descendant, @@ -80,7 +80,7 @@ impl CssLexer : CssLexerMethods { } fn parse_css_element(c : u8) -> Token { - assert is_none(self.input_state.lookahead); + assert is_none(&self.input_state.lookahead); /* Check for special attributes with an implied element, or a wildcard which is not a alphabet character.*/ @@ -182,7 +182,7 @@ impl CssLexer : CssLexerMethods { break; } } else { - push(desc_name, ch); + push(&mut desc_name, ch); } match self.input_state.get() { @@ -217,7 +217,7 @@ impl CssLexer : CssLexerMethods { break; } } else { - push(desc_val, ch); + push(&mut desc_val, ch); } } @@ -267,7 +267,7 @@ fn spawn_css_lexer_from_string(-content : ~str) -> pipes::Port<Token> { } #[allow(non_implicitly_copyable_typarams)] -fn spawn_css_lexer_task(-url: Url, resource_task: ResourceTask) -> pipes::Port<Token> { +pub fn spawn_css_lexer_task(-url: Url, resource_task: ResourceTask) -> pipes::Port<Token> { let (result_chan, result_port) = pipes::stream(); do task::spawn || { diff --git a/src/servo/css/parser.rs b/src/servo/css/parser.rs index b1cad6a7ed8..7643dca9249 100644 --- a/src/servo/css/parser.rs +++ b/src/servo/css/parser.rs @@ -8,7 +8,7 @@ Constructs a list of css style rules from a token stream use css::values::*; // Disambiguate parsed Selector, Rule values from tokens use css = css::values; -use tok = lexer; +use mod tok = lexer; use lexer::Token; use comm::recv; use option::{map, is_none}; @@ -33,7 +33,7 @@ impl TokenReader : TokenReaderMethods { } fn unget(-tok : Token) { - assert is_none(self.lookahead); + assert is_none(&self.lookahead); self.lookahead = Some(tok); } } @@ -60,7 +60,7 @@ impl TokenReader : ParserMethods { loop { let token = self.get(); match token { - tok::Attr(attr) => { push(attr_list, copy attr); } + tok::Attr(attr) => { push(&mut attr_list, copy attr); } tok::StartDescription | tok::Descendant | tok::Child | tok::Sibling | tok::Comma => { self.unget(token); break; @@ -119,12 +119,12 @@ impl TokenReader : ParserMethods { } } tok::StartDescription => { - push(sel_list, built_sel); + push(&mut sel_list, built_sel); self.unget(tok::StartDescription); break; } tok::Comma => { - push(sel_list, built_sel); + push(&mut sel_list, built_sel); self.unget(tok::Comma); break; } @@ -159,8 +159,8 @@ impl TokenReader : ParserMethods { tok::Description(prop, val) => { let desc : Option<StyleDeclaration> = match prop { // TODO: have color parsing return a ParseResult instead of a real value - ~"background-color" => parse_color(val).map(|res| BackgroundColor(Specified(BgColor(res)))), - ~"color" => parse_color(val).map(|res| Color(Specified(TextColor(res)))), + ~"background-color" => parse_color(val).map(|res| BackgroundColor(Specified(BgColor(*res)))), + ~"color" => parse_color(val).map(|res| Color(Specified(TextColor(*res)))), ~"display" => parse_display_type(val).extract(|res| Display(res)), ~"font-size" => parse_font_size(val).extract(|res| FontSize(res)), ~"height" => parse_box_sizing(val).extract(|res| Height(res)), @@ -168,7 +168,7 @@ impl TokenReader : ParserMethods { _ => { #debug["Recieved unknown style property '%s'", val]; None } }; match desc { - Some(d) => push(desc_list, d), + Some(d) => push(&mut desc_list, d), None => { #debug["Couldn't parse value '%s' for property '%s'", val, prop] } } } @@ -204,13 +204,13 @@ impl TokenReader : ParserMethods { } } -fn build_stylesheet(+stream : pipes::Port<Token>) -> ~[~css::Rule] { +pub fn build_stylesheet(+stream : pipes::Port<Token>) -> ~[~css::Rule] { let mut rule_list = ~[]; let reader = {stream : stream, mut lookahead : None}; loop { match reader.parse_rule() { - Some(rule) => { push(rule_list, copy rule); } + Some(rule) => { push(&mut rule_list, copy rule); } None => { break; } } } diff --git a/src/servo/css/parser_util.rs b/src/servo/css/parser_util.rs index 0c680ec9137..fd6f476acb7 100644 --- a/src/servo/css/parser_util.rs +++ b/src/servo/css/parser_util.rs @@ -18,14 +18,14 @@ fn parse_length(str : ~str) -> Option<Length> { const PX_PER_PT: float = 1.0 / 0.75; match str { - s if s.ends_with(~"in") => from_str(str.substr(0, str.len() - 2)).map(|f| Px(1.0/0.75 * 72.0 * f)), - s if s.ends_with(~"cm") => from_str(str.substr(0, str.len() - 2)).map(|f| Px(f / 2.54 * 72.0 * 1.0/0.75)), - s if s.ends_with(~"mm") => from_str(str.substr(0, str.len() - 2)).map(|f| Px(f * 0.1 / 2.54 * 72.0 * 1.0/0.75)), - s if s.ends_with(~"pt") => from_str(str.substr(0, str.len() - 2)).map(|f| Px(1.0/0.75 * f)), - s if s.ends_with(~"pc") => from_str(str.substr(0, str.len() - 2)).map(|f| Px(1.0/0.75 * 12.0 * f)), - s if s.ends_with(~"px") => from_str(str.substr(0, str.len() - 2)).map(|f| Px(f)), - s if s.ends_with(~"em") => from_str(str.substr(0, str.len() - 2)).map(|f| Em(f)), - s if s.ends_with(~"ex") => from_str(str.substr(0, str.len() - 2)).map(|f| Em(0.5*f)), + s if s.ends_with(~"in") => from_str(str.substr(0, str.len() - 2)).map(|f| Px(1.0/0.75 * 72.0 * *f)), + s if s.ends_with(~"cm") => from_str(str.substr(0, str.len() - 2)).map(|f| Px(*f / 2.54 * 72.0 * 1.0/0.75)), + s if s.ends_with(~"mm") => from_str(str.substr(0, str.len() - 2)).map(|f| Px(*f * 0.1 / 2.54 * 72.0 * 1.0/0.75)), + s if s.ends_with(~"pt") => from_str(str.substr(0, str.len() - 2)).map(|f| Px(1.0/0.75 * *f)), + s if s.ends_with(~"pc") => from_str(str.substr(0, str.len() - 2)).map(|f| Px(1.0/0.75 * 12.0 * *f)), + s if s.ends_with(~"px") => from_str(str.substr(0, str.len() - 2)).map(|f| Px(*f)), + s if s.ends_with(~"em") => from_str(str.substr(0, str.len() - 2)).map(|f| Em(*f)), + s if s.ends_with(~"ex") => from_str(str.substr(0, str.len() - 2)).map(|f| Em(0.5 * *f)), _ => None, } } diff --git a/src/servo/css/resolve/apply.rs b/src/servo/css/resolve/apply.rs index 5f741b59955..0a3f198cf92 100644 --- a/src/servo/css/resolve/apply.rs +++ b/src/servo/css/resolve/apply.rs @@ -3,9 +3,10 @@ */ use au = gfx::geometry; +use css::styles::SpecifiedStyle; use dom::node::{Node, NodeTree}; use dom::element::*; -use layout::box::{RenderBox, SpecifiedStyle, RenderBoxTree}; +use layout::box::{RenderBox, RenderBoxTree}; use layout::context::LayoutContext; use layout::traverse_parallel::top_down_traversal; use image::ImageHolder; @@ -126,4 +127,4 @@ impl StyleApplicator { #[cfg(test)] mod test { /* TODO: rewrite once cascade and resolve written. */ -}
\ No newline at end of file +} diff --git a/src/servo/css/resolve/matching.rs b/src/servo/css/resolve/matching.rs index dcf9a9346c5..d1d058cf0c2 100644 --- a/src/servo/css/resolve/matching.rs +++ b/src/servo/css/resolve/matching.rs @@ -31,7 +31,7 @@ fn attrs_match(attr: Attr, elmt: ElementData) -> bool { if val == ~"" { return false; } match elmt.get_attr(name) { - Some(value) => value.split_char(' ').contains(val), + Some(value) => value.split_char(' ').contains(&val), None => false } } diff --git a/src/servo/css/values.rs b/src/servo/css/values.rs index 4f2bf80cfef..89044910348 100644 --- a/src/servo/css/values.rs +++ b/src/servo/css/values.rs @@ -168,21 +168,21 @@ enum StyleDeclaration { Width(CSSValue<BoxSizing>) } -enum Attr{ +pub enum Attr { Exists(~str), Exact(~str, ~str), Includes(~str, ~str), StartsWith(~str, ~str) } -enum Selector{ +pub enum Selector { Element(~str, ~[Attr]), Child(~Selector, ~Selector), Descendant(~Selector, ~Selector), Sibling(~Selector, ~Selector) } -type Rule = (~[~Selector], ~[StyleDeclaration]); +pub type Rule = (~[~Selector], ~[StyleDeclaration]); type Stylesheet = ~[~Rule]; |