mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Update for language changes; stop crashing
This commit is contained in:
parent
b6ae82d05d
commit
157227e8c2
11 changed files with 36 additions and 25 deletions
|
@ -45,7 +45,7 @@ impl DisplayItem {
|
|||
fn draw_into_context(&self, ctx: &RenderContext) {
|
||||
match self {
|
||||
&SolidColor(_, color) => ctx.draw_solid_color(&self.d().bounds, color),
|
||||
&Text(_, run, ref range, color) => {
|
||||
&Text(_, ref run, ref range, color) => {
|
||||
let new_run = @run.deserialize(ctx.font_ctx);
|
||||
let font = new_run.font;
|
||||
let origin = self.d().bounds.origin;
|
||||
|
|
|
@ -199,7 +199,7 @@ pub enum FontSelector {
|
|||
pub impl FontSelector : cmp::Eq {
|
||||
pure fn eq(&self, other: &FontSelector) -> bool {
|
||||
match (self, other) {
|
||||
(&SelectorPlatformIdentifier(a), &SelectorPlatformIdentifier(b)) => a == b,
|
||||
(&SelectorPlatformIdentifier(ref a), &SelectorPlatformIdentifier(ref b)) => a == b,
|
||||
(&SelectorStubDummy, &SelectorStubDummy) => true,
|
||||
_ => false
|
||||
}
|
||||
|
|
|
@ -175,10 +175,14 @@ pub impl FontContext {
|
|||
Font::new_from_buffer(&self, test_font_bin(), &desc.style, self.backend)
|
||||
},
|
||||
// TODO(Issue #174): implement by-platform-name font selectors.
|
||||
&SelectorPlatformIdentifier(identifier) => {
|
||||
let result_handle = self.handle.create_font_from_identifier(copy identifier, copy desc.style);
|
||||
&SelectorPlatformIdentifier(ref identifier) => {
|
||||
let result_handle = self.handle.create_font_from_identifier(copy *identifier,
|
||||
copy desc.style);
|
||||
result::chain(move result_handle, |handle| {
|
||||
Ok(Font::new_from_adopted_handle(&self, move handle, &desc.style, self.backend))
|
||||
Ok(Font::new_from_adopted_handle(&self,
|
||||
move handle,
|
||||
&desc.style,
|
||||
self.backend))
|
||||
})
|
||||
}
|
||||
};
|
||||
|
|
|
@ -50,7 +50,7 @@ pub enum ImageResponseMsg {
|
|||
impl ImageResponseMsg {
|
||||
pure fn clone() -> ImageResponseMsg {
|
||||
match &self {
|
||||
&ImageReady(img) => ImageReady(unsafe { clone_arc(&img) }),
|
||||
&ImageReady(ref img) => ImageReady(unsafe { clone_arc(img) }),
|
||||
&ImageNotReady => ImageNotReady,
|
||||
&ImageFailed => ImageFailed
|
||||
}
|
||||
|
@ -376,10 +376,15 @@ impl ImageCache {
|
|||
|
||||
priv fn purge_waiters(url: Url, f: fn() -> ImageResponseMsg) {
|
||||
match self.wait_map.find(copy url) {
|
||||
Some(@waiters) => {
|
||||
for waiters.each |response| {
|
||||
Some(@ref mut waiters) => {
|
||||
let mut new_waiters = ~[];
|
||||
new_waiters <-> *waiters;
|
||||
|
||||
for new_waiters.each |response| {
|
||||
response.send(f());
|
||||
}
|
||||
|
||||
*waiters <-> new_waiters;
|
||||
self.wait_map.remove(move url);
|
||||
}
|
||||
None => ()
|
||||
|
|
|
@ -60,8 +60,8 @@ pub unsafe fn domstring_to_jsval(cx: *JSContext, string: &DOMString) -> JSVal {
|
|||
&null_string => {
|
||||
JSVAL_NULL
|
||||
}
|
||||
&str(s) => {
|
||||
str::as_buf(s, |buf, len| {
|
||||
&str(ref s) => {
|
||||
str::as_buf(*s, |buf, len| {
|
||||
let cbuf = cast::reinterpret_cast(&buf);
|
||||
RUST_STRING_TO_JSVAL(JS_NewStringCopyN(cx, cbuf, len as libc::size_t))
|
||||
})
|
||||
|
|
|
@ -222,11 +222,11 @@ pub fn parse_html(scope: NodeScope,
|
|||
// move all ~strs at once (blocked on Rust #3845, #3846, #3847)
|
||||
let public_id = match &doctype.public_id {
|
||||
&None => None,
|
||||
&Some(id) => Some(copy id)
|
||||
&Some(ref id) => Some(copy *id)
|
||||
};
|
||||
let system_id = match &doctype.system_id {
|
||||
&None => None,
|
||||
&Some(id) => Some(copy id)
|
||||
&Some(ref id) => Some(copy *id)
|
||||
};
|
||||
let data = DoctypeData(copy doctype.name, move public_id, move system_id,
|
||||
copy doctype.force_quirks);
|
||||
|
|
|
@ -141,7 +141,7 @@ impl RenderBox {
|
|||
|
||||
pure fn is_whitespace_only() -> bool {
|
||||
match &self {
|
||||
&UnscannedTextBox(_, raw_text) => raw_text.is_whitespace(),
|
||||
&UnscannedTextBox(_, ref raw_text) => raw_text.is_whitespace(),
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ impl RenderBox {
|
|||
(@UnscannedTextBox(*), @UnscannedTextBox(*)) => {
|
||||
self.font_style() == other.font_style()
|
||||
},
|
||||
(@TextBox(_,d1), @TextBox(_,d2)) => core::managed::ptr_eq(d1.run, d2.run),
|
||||
(@TextBox(_, ref d1), @TextBox(_, ref d2)) => core::managed::ptr_eq(d1.run, d2.run),
|
||||
(_, _) => false
|
||||
}
|
||||
}
|
||||
|
@ -244,7 +244,7 @@ impl RenderBox {
|
|||
&GenericBox(*) => Au(0),
|
||||
// TODO: consult CSS 'width', margin, border.
|
||||
// TODO: If image isn't available, consult 'width'.
|
||||
&ImageBox(_,i) => Au::from_px(i.get_size().get_default(Size2D(0,0)).width),
|
||||
&ImageBox(_, ref i) => Au::from_px(i.get_size().get_default(Size2D(0,0)).width),
|
||||
&TextBox(_,d) => d.run.min_width_for_range(&const d.range),
|
||||
&UnscannedTextBox(*) => fail ~"Shouldn't see unscanned boxes here."
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ impl RenderBox {
|
|||
// FlowContext will combine the width of this element and
|
||||
// that of its children to arrive at the context width.
|
||||
&GenericBox(*) => Au(0),
|
||||
&ImageBox(_,i) => Au::from_px(i.get_size().get_default(Size2D(0,0)).width),
|
||||
&ImageBox(_, ref i) => Au::from_px(i.get_size().get_default(Size2D(0,0)).width),
|
||||
|
||||
// a text box cannot span lines, so assume that this is an unsplit text box.
|
||||
|
||||
|
@ -304,7 +304,7 @@ impl RenderBox {
|
|||
Coordinates are relative to the owning flow. */
|
||||
pure fn content_box() -> Rect<Au> {
|
||||
match &self {
|
||||
&ImageBox(_,i) => {
|
||||
&ImageBox(_, ref i) => {
|
||||
let size = i.size();
|
||||
Rect {
|
||||
origin: copy self.d().position.origin,
|
||||
|
@ -426,7 +426,7 @@ impl RenderBox {
|
|||
// TODO: items for background, border, outline
|
||||
@GenericBox(_) => {
|
||||
},
|
||||
@ImageBox(_,i) => {
|
||||
@ImageBox(_, ref i) => {
|
||||
match i.get_image() {
|
||||
Some(image) => {
|
||||
debug!("(building display list) building image box");
|
||||
|
@ -581,7 +581,7 @@ impl RenderBox : BoxedDebugMethods {
|
|||
@GenericBox(*) => ~"GenericBox",
|
||||
@ImageBox(*) => ~"ImageBox",
|
||||
@TextBox(_,d) => fmt!("TextBox(text=%s)", str::substr(d.run.text, d.range.begin(), d.range.length())),
|
||||
@UnscannedTextBox(_,s) => fmt!("UnscannedTextBox(%s)", s)
|
||||
@UnscannedTextBox(_, ref s) => fmt!("UnscannedTextBox(%s)", *s)
|
||||
};
|
||||
|
||||
fmt!("box b%?: %?", self.d().id, repr)
|
||||
|
|
|
@ -458,7 +458,7 @@ impl LayoutTreeBuilder {
|
|||
~Text(*) => RenderBox_Text,
|
||||
~Element(ref element) => {
|
||||
match (&element.kind, display) {
|
||||
(&~HTMLImageElement(d), _) if d.image.is_some() => RenderBox_Image,
|
||||
(&~HTMLImageElement(ref d), _) if d.image.is_some() => RenderBox_Image,
|
||||
// (_, Specified(_)) => GenericBox,
|
||||
(_, _) => RenderBox_Generic // TODO: replace this with the commented lines
|
||||
// (_, _) => fail ~"Can't create box for Node with non-specified 'display' type"
|
||||
|
|
|
@ -621,7 +621,9 @@ impl FlowContext : InlineLayout {
|
|||
// over the box list, and/or put into RenderBox.
|
||||
for self.inline().boxes.each |box| {
|
||||
box.d().position.size.width = match *box {
|
||||
@ImageBox(_,img) => Au::from_px(img.get_size().get_default(Size2D(0,0)).width),
|
||||
@ImageBox(_, ref img) => {
|
||||
Au::from_px(img.get_size().get_default(Size2D(0,0)).width)
|
||||
}
|
||||
@TextBox(*) => { /* text boxes are initialized with dimensions */
|
||||
box.d().position.size.width
|
||||
},
|
||||
|
@ -661,7 +663,7 @@ impl FlowContext : InlineLayout {
|
|||
|
||||
// compute box height.
|
||||
cur_box.d().position.size.height = match cur_box {
|
||||
@ImageBox(_,img) => Au::from_px(img.size().height),
|
||||
@ImageBox(_, ref img) => Au::from_px(img.size().height),
|
||||
@TextBox(*) => { /* text boxes are initialized with dimensions */
|
||||
cur_box.d().position.size.height
|
||||
},
|
||||
|
|
|
@ -39,7 +39,7 @@ trait UnscannedMethods {
|
|||
impl RenderBox : UnscannedMethods {
|
||||
pure fn raw_text() -> ~str {
|
||||
match &self {
|
||||
&UnscannedTextBox(_, s) => copy s,
|
||||
&UnscannedTextBox(_, ref s) => copy *s,
|
||||
_ => fail ~"unsupported operation: box.raw_text() on non-unscanned text box."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,12 +150,12 @@ fn main() {
|
|||
fn run(opts: &Opts) {
|
||||
match &opts.render_mode {
|
||||
&Screen => run_pipeline_screen(opts),
|
||||
&Png(outfile) => {
|
||||
&Png(ref outfile) => {
|
||||
assert opts.urls.is_not_empty();
|
||||
if opts.urls.len() > 1u {
|
||||
fail ~"servo asks that you stick to a single URL in PNG output mode"
|
||||
}
|
||||
run_pipeline_png(opts, outfile)
|
||||
run_pipeline_png(opts, *outfile)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue