Skip to content
This repository was archived by the owner on Jul 10, 2023. It is now read-only.

Commit 0d2d600

Browse files
committed
Update for language changes
1 parent bb49526 commit 0d2d600

File tree

9 files changed

+56
-277
lines changed

9 files changed

+56
-277
lines changed

color.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@ use float::round;
22
use libc::types::os::arch::c95::c_double;
33
use cmp::Eq;
44

5-
pub struct Color { red : u8, green : u8, blue : u8, alpha : float}
6-
7-
impl Color : Eq {
8-
pure fn eq(&self, other: &Color) -> bool {
9-
return self.red == other.red && self.green == other.green && self.blue == other.blue &&
10-
self.alpha == other.alpha;
11-
}
12-
pure fn ne(&self, other: &Color) -> bool {
13-
!self.eq(other)
14-
}
5+
#[deriving_eq]
6+
pub struct Color {
7+
red: u8,
8+
green: u8,
9+
blue: u8,
10+
alpha: float,
1511
}
1612

1713
pub fn rgba(r : u8, g : u8, b : u8, a : float) -> Color {

complete.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ pub struct CompleteSelectResults {
1212
pub impl CompleteSelectResults {
1313
static fn new_root(root: SelectResults) -> CompleteSelectResults {
1414
CompleteSelectResults {
15-
inner: move root
15+
inner: root
1616
}
1717
}
1818

1919
static fn new_from_parent(parent: &CompleteSelectResults,
2020
child: SelectResults) -> CompleteSelectResults {
21-
let mut child = move child;
21+
let mut child = child;
2222

2323
// New lifetime
2424
{
@@ -39,7 +39,7 @@ pub impl CompleteSelectResults {
3939
new_value *= n::u::css_fixed_to_float(child_em);
4040
let unit = parent_unit.modify(n::u::float_to_css_fixed(
4141
new_value));
42-
CssHintLength(move unit)
42+
CssHintLength(unit)
4343
}
4444
_ => n::h::CssHintLength(n::t::CssUnitEm(child_em)),
4545
}
@@ -58,7 +58,7 @@ pub impl CompleteSelectResults {
5858
}
5959

6060
CompleteSelectResults {
61-
inner: move child
61+
inner: child
6262
}
6363
}
6464

@@ -204,9 +204,9 @@ impl CompleteStyle {
204204
}
205205

206206
fn strip<T>(value: CSSValue<T>) -> T {
207-
match move value {
207+
match value {
208208
Inherit => fail!(~"unexpected 'inherit' value in complete style"),
209-
Specified(move v) => move v
209+
Specified(v) => v
210210
}
211211
}
212212

computed.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ fn convert_net_font_size_value(value: n::v::CssFontSizeValue) -> CSSValue<CSSFon
255255
n::v::CssFontSizeSmaller => Specified(CSSFontSizeRelativeSize(Smaller)),
256256
n::v::CssFontSizeDimension(size) => {
257257
match convert_net_unit_to_length_or_percent(size) {
258-
Left(move val) => Specified(CSSFontSizeLength(move val)),
259-
Right(move val) => Specified(CSSFontSizePercentage(move val))
258+
Left(val) => Specified(CSSFontSizeLength(val)),
259+
Right(val) => Specified(CSSFontSizePercentage(val))
260260
}
261261
}
262262
}
@@ -321,7 +321,7 @@ fn convert_net_line_height_value(value: n::v::CssLineHeightValue) -> CSSValue<CS
321321

322322
fn convert_net_unit_to_length(unit: n::t::CssUnit) -> Length {
323323
match convert_net_unit_to_length_or_percent(unit) {
324-
Left(move v) => v,
324+
Left(v) => v,
325325
Right(*) => fail!(~"unexpected percentage unit")
326326
}
327327
}

parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ pub fn parse_stylesheet(url: Url, input: DataStream) -> CssStylesheet {
3838

3939
loop {
4040
match input() {
41-
Some(move data) => {
41+
Some(data) => {
4242
sheet.append_data(data);
4343
}
4444
None => break
4545
}
4646
}
4747
sheet.data_done();
48-
return move sheet;
48+
return sheet;
4949
}
5050

5151
fn resolve_url(_base: &str, _rel: &LwcString) -> CssResult<LwcString> {

select.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ impl SelectCtx {
3838
during future selector matching
3939
*/
4040
fn append_sheet(&mut self, sheet: Stylesheet, origin: StylesheetOrigin) {
41-
let sheet = match move sheet {
42-
Stylesheet { inner: move inner } => move inner
41+
let sheet = match sheet {
42+
Stylesheet { inner: inner } => inner
4343
};
4444

45-
self.inner.append_sheet(move sheet, origin.to_net(), n::ll::t::CSS_MEDIA_SCREEN)
45+
self.inner.append_sheet(sheet, origin.to_net(), n::ll::t::CSS_MEDIA_SCREEN)
4646
}
4747

4848
/**
@@ -101,7 +101,7 @@ priv impl<N, H: SelectHandler<N>> SelectHandlerWrapper<N, H> {
101101
}
102102
}
103103

104-
impl<N, H: SelectHandler<N>> SelectHandlerWrapper<N, H>: n::s::CssSelectHandler<N> {
104+
impl<N, H: SelectHandler<N>> n::s::CssSelectHandler<N> for SelectHandlerWrapper<N, H> {
105105
fn node_name(node: &N) -> n::t::CssQName {
106106
do self.inner_ref().with_node_name(node) |name| {
107107
rust_str_to_net_qname(name)

stylesheet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub struct Stylesheet {
1414
pub impl Stylesheet {
1515
static fn new(url: Url, input: DataStream) -> Stylesheet {
1616
Stylesheet {
17-
inner: parse_stylesheet(move url, input)
17+
inner: parse_stylesheet(url, input)
1818
}
1919
}
2020
}

test.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ fn test_url() -> Url {
1818

1919
fn style_stream(style: &str) -> DataStream {
2020
let style = Cell(style.to_str());
21-
let d: DataStream = |move style| if !style.is_empty() {
22-
Some(str::to_bytes(style.take()))
23-
} else {
24-
None
21+
let d: DataStream = || {
22+
if !style.is_empty() {
23+
Some(str::to_bytes(style.take()))
24+
} else {
25+
None
26+
}
2527
};
2628
return d;
2729
}
@@ -35,7 +37,7 @@ struct NodeData {
3537
mut parent: Option<TestNode>
3638
}
3739

38-
impl TestNode: VoidPtrLike {
40+
impl VoidPtrLike for TestNode {
3941
static fn from_void_ptr(node: *libc::c_void) -> TestNode {
4042
assert node.is_not_null();
4143
TestNode(unsafe {
@@ -62,7 +64,7 @@ impl TestHandler {
6264
}
6365
}
6466

65-
impl TestHandler: SelectHandler<TestNode> {
67+
impl SelectHandler<TestNode> for TestHandler {
6668
fn with_node_name<R>(node: &TestNode, f: &fn(&str) -> R) -> R {
6769
f((*node).name)
6870
}
@@ -92,7 +94,7 @@ fn single_div_test(style: &str, f: &fn(&ComputedStyle)) {
9294
let sheet = Stylesheet::new(test_url(), style_stream(style));
9395
let mut select_ctx = SelectCtx::new();
9496
let handler = &TestHandler::new();
95-
select_ctx.append_sheet(move sheet, OriginAuthor);
97+
select_ctx.append_sheet(sheet, OriginAuthor);
9698
let dom = &TestNode(@NodeData {
9799
name: ~"div",
98100
id: ~"id1",
@@ -359,7 +361,7 @@ fn child_test(style: &str, f: &fn(&ComputedStyle)) {
359361
let sheet = Stylesheet::new(test_url(), style_stream(style));
360362
let mut select_ctx = SelectCtx::new();
361363
let handler = &TestHandler::new();
362-
select_ctx.append_sheet(move sheet, OriginAuthor);
364+
select_ctx.append_sheet(sheet, OriginAuthor);
363365
let child = TestNode(@NodeData {
364366
name: ~"span",
365367
id: ~"id1",
@@ -417,7 +419,7 @@ fn test_compose() {
417419
let sheet = Stylesheet::new(test_url(), style_stream(style));
418420
let mut select_ctx = SelectCtx::new();
419421
let handler = &TestHandler::new();
420-
select_ctx.append_sheet(move sheet, OriginAuthor);
422+
select_ctx.append_sheet(sheet, OriginAuthor);
421423
let child = TestNode(@NodeData {
422424
name: ~"span",
423425
id: ~"id1",
@@ -434,8 +436,9 @@ fn test_compose() {
434436
let parent_results = select_ctx.select_style(&parent, handler);
435437
let child_results = select_ctx.select_style(&child, handler);
436438

437-
let complete_parent_results = CompleteSelectResults::new_root(move parent_results);
438-
let complete_child_results = CompleteSelectResults::new_from_parent(&complete_parent_results, move child_results);
439+
let complete_parent_results = CompleteSelectResults::new_root(parent_results);
440+
let complete_child_results = CompleteSelectResults::new_from_parent(&complete_parent_results,
441+
child_results);
439442

440443
let computed = complete_child_results.computed_style();
441444

units.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Units used by CSS
33
*/
44

5+
#[deriving_eq]
56
pub enum Length {
67
Em(float), // normalized to 'em'
78
Px(float), // normalized to 'px'
@@ -23,12 +24,14 @@ impl Length {
2324
}
2425
}
2526

27+
#[deriving_eq]
2628
pub enum BoxSizing { // used by width, height, top, left, etc
2729
BoxLength(Length),
2830
BoxPercent(float),
2931
BoxAuto
3032
}
3133

34+
#[deriving_eq]
3235
pub enum AbsoluteSize {
3336
XXSmall,
3437
XSmall,
@@ -39,6 +42,7 @@ pub enum AbsoluteSize {
3942
XXLarge
4043
}
4144

45+
#[deriving_eq]
4246
pub enum RelativeSize {
4347
Larger,
4448
Smaller

0 commit comments

Comments
 (0)