mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Eliminate more warnings
This commit is contained in:
parent
7e8dd984e4
commit
495946b92b
10 changed files with 55 additions and 52 deletions
|
@ -237,7 +237,7 @@ fn parser(input_port: comm::Port<ProgressMsg>, state : ParserState) -> CssLexer
|
|||
};
|
||||
}
|
||||
|
||||
fn lex_css_from_bytes(+input_port: comm::Port<ProgressMsg>, result_chan : Chan<Token>) {
|
||||
fn lex_css_from_bytes(+input_port: comm::Port<ProgressMsg>, result_chan : &Chan<Token>) {
|
||||
let lexer = parser(input_port, CssElement);
|
||||
|
||||
loop {
|
||||
|
@ -252,7 +252,7 @@ fn lex_css_from_bytes(+input_port: comm::Port<ProgressMsg>, result_chan : Chan<T
|
|||
}
|
||||
}
|
||||
|
||||
fn spawn_css_lexer_from_string(-content : ~str) -> pipes::Port<Token> {
|
||||
fn spawn_css_lexer_from_string(+content : ~str) -> pipes::Port<Token> {
|
||||
let (result_chan, result_port) = pipes::stream();
|
||||
|
||||
do task::spawn {
|
||||
|
@ -260,14 +260,14 @@ fn spawn_css_lexer_from_string(-content : ~str) -> pipes::Port<Token> {
|
|||
input_port.send(Payload(str::to_bytes(content)));
|
||||
input_port.send(Done(Ok(())));
|
||||
|
||||
lex_css_from_bytes(input_port, result_chan);
|
||||
lex_css_from_bytes(input_port, &result_chan);
|
||||
}
|
||||
|
||||
return result_port;
|
||||
}
|
||||
|
||||
#[allow(non_implicitly_copyable_typarams)]
|
||||
pub 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 || {
|
||||
|
@ -276,7 +276,7 @@ pub fn spawn_css_lexer_task(-url: Url, resource_task: ResourceTask) -> pipes::Po
|
|||
// TODO: change copy to move once the compiler permits it
|
||||
resource_task.send(Load(copy url, input_port.chan()));
|
||||
|
||||
lex_css_from_bytes(input_port, result_chan);
|
||||
lex_css_from_bytes(input_port, &result_chan);
|
||||
};
|
||||
|
||||
return result_port;
|
||||
|
|
|
@ -21,7 +21,7 @@ type TokenReader = {stream : pipes::Port<Token>, mut lookahead : Option<Token>};
|
|||
|
||||
trait TokenReaderMethods {
|
||||
fn get() -> Token;
|
||||
fn unget(-tok : Token);
|
||||
fn unget(+tok : Token);
|
||||
}
|
||||
|
||||
impl TokenReader : TokenReaderMethods {
|
||||
|
@ -32,7 +32,7 @@ impl TokenReader : TokenReaderMethods {
|
|||
}
|
||||
}
|
||||
|
||||
fn unget(-tok : Token) {
|
||||
fn unget(+tok : Token) {
|
||||
assert is_none(&self.lookahead);
|
||||
self.lookahead = Some(tok);
|
||||
}
|
||||
|
|
|
@ -11,27 +11,28 @@ export parse_box_sizing;
|
|||
export parse_display_type;
|
||||
|
||||
|
||||
fn parse_length(str : ~str) -> Option<Length> {
|
||||
fn parse_length(str : &str) -> Option<Length> {
|
||||
// TODO: use these once we stop lexing below
|
||||
const PTS_PER_INCH: float = 72.0;
|
||||
const CM_PER_INCH: float = 2.54;
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_absolute_size(str : ~str) -> ParseResult<AbsoluteSize> {
|
||||
match str {
|
||||
fn parse_absolute_size(str : &str) -> ParseResult<AbsoluteSize> {
|
||||
// FIXME: Bad copy. Can't match &str
|
||||
match str.to_str() {
|
||||
~"xx-small" => Value(XXSmall),
|
||||
~"x-small" => Value(XSmall),
|
||||
~"small" => Value(Small),
|
||||
|
@ -43,30 +44,33 @@ fn parse_absolute_size(str : ~str) -> ParseResult<AbsoluteSize> {
|
|||
}
|
||||
}
|
||||
|
||||
fn parse_relative_size(str: ~str) -> ParseResult<RelativeSize> {
|
||||
match str {
|
||||
fn parse_relative_size(str: &str) -> ParseResult<RelativeSize> {
|
||||
// FIXME: Bad copy. Can't match &str
|
||||
match str.to_str() {
|
||||
~"smaller" => Value(Smaller),
|
||||
~"larger" => Value(Larger),
|
||||
_ => Fail
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_font_size(_str: ~str) -> ParseResult<CSSFontSize> {
|
||||
fn parse_font_size(_str: &str) -> ParseResult<CSSFontSize> {
|
||||
// TODO: complete me
|
||||
Value(LengthSize(Px(14.0)))
|
||||
}
|
||||
|
||||
// For width / height, and anything else with the same attribute values
|
||||
fn parse_box_sizing(str : ~str) -> ParseResult<BoxSizing> {
|
||||
match str {
|
||||
fn parse_box_sizing(str : &str) -> ParseResult<BoxSizing> {
|
||||
// FIXME: Bad copy. Can't match &str
|
||||
match str.to_str() {
|
||||
~"auto" => Value(BoxAuto),
|
||||
~"inherit" => CSSInherit,
|
||||
_ => Fail,
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_display_type(str : ~str) -> ParseResult<CSSDisplay> {
|
||||
match str {
|
||||
fn parse_display_type(str : &str) -> ParseResult<CSSDisplay> {
|
||||
// FIXME: Bad copy. Can't match &str
|
||||
match str.to_str() {
|
||||
~"inline" => Value(DisplayInline),
|
||||
~"block" => Value(DisplayBlock),
|
||||
~"none" => Value(DisplayNone),
|
||||
|
|
|
@ -41,7 +41,7 @@ struct StyleApplicator {
|
|||
}
|
||||
|
||||
// TODO: normalize this into a normal preorder tree traversal function
|
||||
fn apply_style(layout_ctx: &LayoutContext, node: Node, reflow: fn~()) {
|
||||
fn apply_style(layout_ctx: &LayoutContext, node: Node, +reflow: fn~()) {
|
||||
let applicator = StyleApplicator {
|
||||
node: node,
|
||||
reflow: reflow
|
||||
|
@ -55,7 +55,7 @@ fn apply_style(layout_ctx: &LayoutContext, node: Node, reflow: fn~()) {
|
|||
/** A wrapper around a set of functions that can be applied as a
|
||||
* top-down traversal of layout boxes.
|
||||
*/
|
||||
fn inheritance_wrapper(layout_ctx: &LayoutContext, node : Node, reflow: fn~()) {
|
||||
fn inheritance_wrapper(layout_ctx: &LayoutContext, node : Node, +reflow: fn~()) {
|
||||
let applicator = StyleApplicator {
|
||||
node: node,
|
||||
reflow: reflow
|
||||
|
|
|
@ -11,8 +11,8 @@ use styles::{SpecifiedStyle};
|
|||
/**
|
||||
Check if a CSS attribute matches the attribute of an HTML element.
|
||||
*/
|
||||
fn attrs_match(attr: Attr, elmt: ElementData) -> bool {
|
||||
match attr {
|
||||
fn attrs_match(attr: &Attr, elmt: &ElementData) -> bool {
|
||||
match *attr {
|
||||
Exists(name) => {
|
||||
match elmt.get_attr(name) {
|
||||
Some(_) => true,
|
||||
|
@ -55,8 +55,8 @@ fn attrs_match(attr: Attr, elmt: ElementData) -> bool {
|
|||
}
|
||||
|
||||
trait PrivMatchingMethods {
|
||||
fn matches_element(sel: ~Selector) -> bool;
|
||||
fn matches_selector(sel : ~Selector) -> bool;
|
||||
fn matches_element(sel: &Selector) -> bool;
|
||||
fn matches_selector(sel: &Selector) -> bool;
|
||||
}
|
||||
|
||||
impl Node : PrivMatchingMethods {
|
||||
|
@ -66,7 +66,7 @@ impl Node : PrivMatchingMethods {
|
|||
element with no relational information, describes the given HTML
|
||||
element.
|
||||
*/
|
||||
fn matches_element(sel: ~Selector) -> bool {
|
||||
fn matches_element(sel: &Selector) -> bool {
|
||||
match *sel {
|
||||
Child(_, _) | Descendant(_, _) | Sibling(_, _) => { return false; }
|
||||
Element(tag, attrs) => {
|
||||
|
@ -78,7 +78,7 @@ impl Node : PrivMatchingMethods {
|
|||
|
||||
let mut i = 0u;
|
||||
while i < attrs.len() {
|
||||
if !attrs_match(attrs[i], elmt) { return false; }
|
||||
if !attrs_match(&attrs[i], &elmt) { return false; }
|
||||
i += 1u;
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ impl Node : PrivMatchingMethods {
|
|||
/**
|
||||
Checks if a generic CSS selector matches a given HTML element
|
||||
*/
|
||||
fn matches_selector(sel : ~Selector) -> bool {
|
||||
fn matches_selector(sel : &Selector) -> bool {
|
||||
match *sel {
|
||||
Element(*) => { return self.matches_element(sel); }
|
||||
Child(sel1, sel2) => {
|
||||
|
@ -188,7 +188,7 @@ impl Node : PrivStyleMethods {
|
|||
}
|
||||
|
||||
trait MatchingMethods {
|
||||
fn match_css_style(styles : Stylesheet);
|
||||
fn match_css_style(styles : &Stylesheet);
|
||||
}
|
||||
|
||||
impl Node : MatchingMethods {
|
||||
|
@ -196,7 +196,7 @@ impl Node : MatchingMethods {
|
|||
Compare an html element to a list of css rules and update its
|
||||
style according to the rules matching it.
|
||||
*/
|
||||
fn match_css_style(styles : Stylesheet) {
|
||||
fn match_css_style(styles : &Stylesheet) {
|
||||
// Loop over each rule, see if our node matches what is
|
||||
// described in the rule. If it matches, update its style. As
|
||||
// we don't currently have priorities of style information,
|
||||
|
@ -225,7 +225,7 @@ mod test {
|
|||
use dvec::DVec;
|
||||
|
||||
#[allow(non_implicitly_copyable_typarams)]
|
||||
fn new_node_from_attr(scope: NodeScope, -name: ~str, -val: ~str) -> Node {
|
||||
fn new_node_from_attr(scope: NodeScope, +name: ~str, +val: ~str) -> Node {
|
||||
let elmt = ElementData(~"div", ~HTMLDivElement);
|
||||
let attr = ~Attr(name, val);
|
||||
elmt.attrs.push(attr);
|
||||
|
|
|
@ -72,7 +72,7 @@ impl NodeKind : DefaultStyleMethods {
|
|||
* style is computed so that it can be used to short-circuit selector matching to avoid computing
|
||||
* style for children of display:none objects.
|
||||
*/
|
||||
fn empty_style_for_node_kind(kind: NodeKind) -> SpecifiedStyle {
|
||||
fn empty_style_for_node_kind(kind: &NodeKind) -> SpecifiedStyle {
|
||||
let display_type = kind.default_display_type();
|
||||
|
||||
{mut background_color : Initial,
|
||||
|
@ -89,7 +89,7 @@ trait StyleMethods {
|
|||
|
||||
fn style() -> SpecifiedStyle;
|
||||
fn initialize_style_for_subtree(ctx: &LayoutContext, refs: &DVec<@LayoutData>);
|
||||
fn recompute_style_for_subtree(ctx: &LayoutContext, styles : ARC<Stylesheet>);
|
||||
fn recompute_style_for_subtree(ctx: &LayoutContext, styles : &ARC<Stylesheet>);
|
||||
}
|
||||
|
||||
impl Node : StyleMethods {
|
||||
|
@ -101,7 +101,7 @@ impl Node : StyleMethods {
|
|||
false => {
|
||||
let node_kind = self.read(|n| copy *n.kind);
|
||||
let data = @LayoutData({
|
||||
mut style : ~empty_style_for_node_kind(node_kind),
|
||||
mut style : ~empty_style_for_node_kind(&node_kind),
|
||||
mut flow : None
|
||||
});
|
||||
self.set_aux(data); Some(data)
|
||||
|
@ -142,17 +142,15 @@ impl Node : StyleMethods {
|
|||
* the node (the reader-auxiliary box in the RCU model) with the
|
||||
* computed style.
|
||||
*/
|
||||
fn recompute_style_for_subtree(ctx: &LayoutContext, styles : ARC<Stylesheet>) {
|
||||
fn recompute_style_for_subtree(ctx: &LayoutContext, styles : &ARC<Stylesheet>) {
|
||||
let mut i = 0u;
|
||||
|
||||
// Compute the styles of each of our children in parallel
|
||||
for NodeTree.each_child(&self) |kid| {
|
||||
i = i + 1u;
|
||||
let new_styles = clone(&styles);
|
||||
|
||||
kid.recompute_style_for_subtree(ctx, new_styles);
|
||||
kid.recompute_style_for_subtree(ctx, styles);
|
||||
}
|
||||
|
||||
self.match_css_style(*get(&styles));
|
||||
self.match_css_style(get(styles));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,11 +24,11 @@ enum CSSValue<T : Copy> {
|
|||
}
|
||||
|
||||
impl<T : Copy> ParseResult<T> {
|
||||
pure fn extract<U>(f: fn(CSSValue<T>) -> U) -> Option<U> { extract(self, f) }
|
||||
pure fn extract<U>(f: fn(+v: CSSValue<T>) -> U) -> Option<U> { extract(&self, f) }
|
||||
}
|
||||
|
||||
pure fn extract<T : Copy, U>(res: ParseResult<T>, f: fn(CSSValue<T>) -> U) -> Option<U> {
|
||||
match res {
|
||||
pure fn extract<T : Copy, U>(res: &ParseResult<T>, f: fn(+v: CSSValue<T>) -> U) -> Option<U> {
|
||||
match *res {
|
||||
Fail => None,
|
||||
CSSInitial => Some(f(Initial)),
|
||||
CSSInherit => Some(f(Inherit)),
|
||||
|
|
|
@ -50,7 +50,7 @@ impl LayoutTreeBuilder {
|
|||
|
||||
// TODO: remove this once UA styles work
|
||||
// TODO: handle interactions with 'float', 'position' (CSS 2.1, Section 9.7)
|
||||
let simulated_display = match self.simulate_UA_display_rules(cur_node, style) {
|
||||
let simulated_display = match self.simulate_UA_display_rules(cur_node, &style) {
|
||||
DisplayNone => return, // tree ends here if 'display: none'
|
||||
v => v
|
||||
};
|
||||
|
@ -151,7 +151,7 @@ impl LayoutTreeBuilder {
|
|||
fail ~"TODO: handle case where an inline is split by a block"
|
||||
}
|
||||
|
||||
priv fn simulate_UA_display_rules(node: Node, style: SpecifiedStyle) -> CSSDisplay {
|
||||
priv fn simulate_UA_display_rules(node: Node, style: &SpecifiedStyle) -> CSSDisplay {
|
||||
let resolved = match style.display_type {
|
||||
Inherit | Initial => DisplayInline, // TODO: remove once resolve works
|
||||
Specified(v) => v
|
||||
|
|
|
@ -170,7 +170,7 @@ impl FlowContext {
|
|||
|
||||
// Actual methods that do not require much flow-specific logic
|
||||
impl FlowContext {
|
||||
pure fn foldl_boxes_for_node<B: Copy>(node: Node, seed: B, blk: pure fn&(B,@RenderBox) -> B) -> B {
|
||||
pure fn foldl_boxes_for_node<B: Copy>(node: Node, +seed: B, blk: pure fn&(+a: B,@RenderBox) -> B) -> B {
|
||||
match self {
|
||||
RootFlow(*) => match self.root().box {
|
||||
Some(box) if box.d().node == node => { blk(seed, box) },
|
||||
|
@ -181,6 +181,7 @@ impl FlowContext {
|
|||
_ => seed
|
||||
},
|
||||
InlineFlow(*) => do self.inline().boxes.foldl(seed) |acc, box| {
|
||||
// FIXME: Bad copies. foldl's accumulator should be by-value
|
||||
if box.d().node == node { blk(*acc, *box) }
|
||||
else { *acc }
|
||||
},
|
||||
|
|
|
@ -144,7 +144,7 @@ impl Layout {
|
|||
do util::time::time(~"layout") {
|
||||
// TODO: this is dumb. we don't need 3 separate traversals.
|
||||
node.initialize_style_for_subtree(&layout_ctx, &self.layout_refs);
|
||||
node.recompute_style_for_subtree(&layout_ctx, styles);
|
||||
node.recompute_style_for_subtree(&layout_ctx, &styles);
|
||||
/* resolve styles (convert relative values) down the node tree */
|
||||
apply_style(&layout_ctx, node, layout_ctx.reflow_cb);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue