mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Added copies and pure functions to fix borrowck errors
This commit is contained in:
parent
61a615fb4d
commit
cdb910bd85
9 changed files with 18 additions and 16 deletions
|
@ -97,7 +97,7 @@ impl private_methods<T:send,A> for handle<T,A> {
|
|||
fn set_rd_aux(t: *A) unsafe { (**self).rd_aux = t; }
|
||||
fn set_next_dirty(+h: handle<T,A>) unsafe { (**self).next_dirty = h; }
|
||||
|
||||
fn is_null() -> bool { (*self).is_null() }
|
||||
pure fn is_null() -> bool { (*self).is_null() }
|
||||
fn is_not_null() -> bool { (*self).is_not_null() }
|
||||
}
|
||||
|
||||
|
|
|
@ -32,10 +32,10 @@ fn zero_size_au() -> size<au> {
|
|||
{width: au(0), height: au(0)}
|
||||
}
|
||||
|
||||
fn px_to_au(i: int) -> au {
|
||||
pure fn px_to_au(i: int) -> au {
|
||||
au(i * 60)
|
||||
}
|
||||
|
||||
fn au_to_px(au: au) -> int {
|
||||
pure fn au_to_px(au: au) -> int {
|
||||
*au / 60
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ impl layout_methods for @box {
|
|||
fn reflow_intrinsic(size: geom::size<au>) {
|
||||
self.bounds.size = copy size;
|
||||
|
||||
#debug["reflow_intrinsic size=%?", self.bounds];
|
||||
#debug["reflow_intrinsic size=%?", copy self.bounds];
|
||||
}
|
||||
|
||||
#[doc="Dumps the box tree, for debugging."]
|
||||
|
|
|
@ -30,7 +30,7 @@ impl block_layout_methods for @box {
|
|||
self.bounds.size = {width: available_width, // FIXME
|
||||
height: au(current_height)};
|
||||
|
||||
#debug["reflow_block size=%?", self.bounds];
|
||||
#debug["reflow_block size=%?", copy self.bounds];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import /*layout::*/base::{rd_tree_ops, wr_tree_ops};
|
|||
import /*layout::*/style::style::{style_methods};
|
||||
import /*layout::*/text::text_box;
|
||||
import util::tree;
|
||||
import option::is_none;
|
||||
|
||||
export box_builder_methods;
|
||||
|
||||
|
@ -130,7 +131,7 @@ impl methods for ctxt {
|
|||
}
|
||||
|
||||
self.finish_anonymous_box_if_necessary();
|
||||
assert self.anon_box.is_none();
|
||||
assert is_none(self.anon_box);
|
||||
}
|
||||
|
||||
#[doc="
|
||||
|
@ -138,7 +139,7 @@ impl methods for ctxt {
|
|||
anonymous box to the block.
|
||||
"]
|
||||
fn finish_anonymous_box_if_necessary() {
|
||||
alt self.anon_box {
|
||||
alt copy self.anon_box {
|
||||
none { /* Nothing to do. */ }
|
||||
some(b) { btree.add_child(self.parent_box, b); }
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ impl inline_layout_methods for @box {
|
|||
self.bounds.size = { width: available_width,
|
||||
height: au(current_height) };
|
||||
|
||||
#debug["reflow_inline size=%?", self.bounds];
|
||||
#debug["reflow_inline size=%?", copy self.bounds];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,19 +9,20 @@ import parser::lexer::css::{token, to_start_desc, to_end_desc,
|
|||
to_comma, to_elmt, to_attr, to_desc,
|
||||
to_eof};
|
||||
import comm::recv;
|
||||
import option::is_none;
|
||||
|
||||
type token_reader = {stream : port<token>, mut lookahead : option<token>};
|
||||
|
||||
impl methods for token_reader {
|
||||
fn get() -> token {
|
||||
alt self.lookahead {
|
||||
alt copy self.lookahead {
|
||||
some(tok) { self.lookahead = none; tok }
|
||||
none { recv(self.stream) }
|
||||
}
|
||||
}
|
||||
|
||||
fn unget(tok : token) {
|
||||
assert self.lookahead.is_none();
|
||||
assert is_none(self.lookahead);
|
||||
self.lookahead = some(tok);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import comm::{port, chan};
|
|||
import html::html_methods;
|
||||
import css::css_methods;
|
||||
import dom::style;
|
||||
import option::is_none;
|
||||
|
||||
enum parse_state {
|
||||
ps_html_normal,
|
||||
|
@ -43,7 +44,7 @@ impl u8_vec_methods for [u8] {
|
|||
|
||||
impl util_methods for parser {
|
||||
fn get() -> char_or_eof {
|
||||
alt self.lookahead {
|
||||
alt copy self.lookahead {
|
||||
some(coe) {
|
||||
let rv = coe;
|
||||
self.lookahead = none;
|
||||
|
@ -59,7 +60,7 @@ impl util_methods for parser {
|
|||
}
|
||||
|
||||
fn unget(ch: u8) {
|
||||
assert self.lookahead.is_none();
|
||||
assert is_none(self.lookahead);
|
||||
self.lookahead = some(coe_char(ch));
|
||||
}
|
||||
|
||||
|
@ -316,7 +317,7 @@ mod css {
|
|||
}
|
||||
|
||||
fn parse_css_element(c : u8) -> token {
|
||||
assert self.lookahead.is_none();
|
||||
assert is_none(self.lookahead);
|
||||
|
||||
/* Check for special attributes with an implied element,
|
||||
or a wildcard which is not a alphabet character.*/
|
||||
|
|
|
@ -23,7 +23,7 @@ fn each_child<T:copy,O:rd_tree_ops<T>>(
|
|||
|
||||
let mut p = ops.with_tree_fields(node) { |f| f.first_child };
|
||||
loop {
|
||||
alt p {
|
||||
alt copy p {
|
||||
none { ret; }
|
||||
some(c) {
|
||||
if !f(c) { ret; }
|
||||
|
@ -54,11 +54,10 @@ fn add_child<T:copy,O:wr_tree_ops<T>>(
|
|||
assert child_tf.next_sibling == none;
|
||||
|
||||
ops.with_tree_fields(parent) { |parent_tf|
|
||||
alt parent_tf.last_child {
|
||||
alt copy parent_tf.last_child {
|
||||
none {
|
||||
parent_tf.first_child = some(child);
|
||||
}
|
||||
|
||||
some(lc) {
|
||||
let lc = lc; // satisfy alias checker
|
||||
ops.with_tree_fields(lc) { |lc_tf|
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue