aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Moffitt <jack@metajack.im>2013-05-10 14:54:15 -0600
committerJack Moffitt <jack@metajack.im>2013-05-10 15:41:20 -0600
commit7234635aa580c8a821003882e77d8e043d247687 (patch)
treed40c2483b77b802f68d6309b037c887bf1817f69
parent4d0c20246a6171d8e29a63ef79b827ad56cbb350 (diff)
downloadservo-7234635aa580c8a821003882e77d8e043d247687.tar.gz
servo-7234635aa580c8a821003882e77d8e043d247687.zip
Remove old borrow check workarounds and appease the new borrow checker.
-rw-r--r--src/servo/content/content_task.rs2
-rw-r--r--src/servo/layout/box.rs17
-rw-r--r--src/servo/layout/box_builder.rs19
-rw-r--r--src/servo/layout/flow.rs9
-rw-r--r--src/servo/layout/inline.rs80
5 files changed, 57 insertions, 70 deletions
diff --git a/src/servo/content/content_task.rs b/src/servo/content/content_task.rs
index d41c5e599ef..1ed62cc019c 100644
--- a/src/servo/content/content_task.rs
+++ b/src/servo/content/content_task.rs
@@ -186,7 +186,7 @@ pub impl Content {
}
fn handle_msg(&mut self) -> bool {
- match select2i(&self.control_port, &self.event_port) {
+ match select2i(&mut self.control_port, &mut self.event_port) {
either::Left(*) => {
let msg = self.control_port.recv();
self.handle_control_msg(msg)
diff --git a/src/servo/layout/box.rs b/src/servo/layout/box.rs
index 987c2851387..9cf69bdd7f0 100644
--- a/src/servo/layout/box.rs
+++ b/src/servo/layout/box.rs
@@ -168,15 +168,12 @@ pub impl RenderBox {
match *self {
GenericRenderBoxClass(generic_box) => callback(generic_box),
ImageRenderBoxClass(image_box) => {
- let image_box = &*image_box; // FIXME: Borrow check workaround.
callback(&image_box.base)
}
TextRenderBoxClass(text_box) => {
- let text_box = &*text_box; // FIXME: Borrow check workaround.
callback(&text_box.base)
}
UnscannedTextRenderBoxClass(unscanned_text_box) => {
- let unscanned_text_box = &*unscanned_text_box; // FIXME: Borrow check workaround.
callback(&unscanned_text_box.base)
}
}
@@ -188,16 +185,12 @@ pub impl RenderBox {
match *self {
GenericRenderBoxClass(generic_box) => callback(generic_box),
ImageRenderBoxClass(image_box) => {
- let image_box = &mut *image_box; // FIXME: Borrow check workaround.
callback(&mut image_box.base)
}
TextRenderBoxClass(text_box) => {
- let text_box = &mut *text_box; // FIXME: Borrow check workaround.
callback(&mut text_box.base)
}
UnscannedTextRenderBoxClass(unscanned_text_box) => {
- // FIXME: Borrow check workaround.
- let unscanned_text_box = &mut *unscanned_text_box;
callback(&mut unscanned_text_box.base)
}
}
@@ -238,7 +231,6 @@ pub impl RenderBox {
fn is_whitespace_only(&self) -> bool {
match *self {
UnscannedTextRenderBoxClass(unscanned_text_box) => {
- let mut unscanned_text_box = &mut *unscanned_text_box; // FIXME: Borrow check.
unscanned_text_box.text.is_whitespace()
}
_ => false
@@ -269,8 +261,6 @@ pub impl RenderBox {
}
TextRenderBoxClass(text_box) => {
- let text_box = &mut *text_box; // FIXME: Borrow check.
-
let mut pieces_processed_count: uint = 0;
let mut remaining_width: Au = max_width;
let mut left_range = Range::new(text_box.text_data.range.begin(), 0);
@@ -379,7 +369,6 @@ pub impl RenderBox {
}
TextRenderBoxClass(text_box) => {
- let mut text_box = &mut *text_box; // FIXME: Borrow check.
text_box.text_data.run.min_width_for_range(&text_box.text_data.range)
}
@@ -401,8 +390,6 @@ pub impl RenderBox {
}
TextRenderBoxClass(text_box) => {
- let mut text_box = &mut *text_box; // FIXME: Borrow check bug.
-
// A text box cannot span lines, so assume that this is an unsplit text box.
//
// TODO: If text boxes have been split to wrap lines, then they could report a
@@ -567,8 +554,6 @@ pub impl RenderBox {
match *self {
UnscannedTextRenderBoxClass(*) => fail!(~"Shouldn't see unscanned boxes here."),
TextRenderBoxClass(text_box) => {
- let text_box = &mut *text_box; // FIXME: Borrow check bug.
-
let nearest_ancestor_element = self.nearest_ancestor_element();
let color = nearest_ancestor_element.style().color().to_gfx_color();
@@ -783,13 +768,11 @@ impl DebugMethods for RenderBox {
GenericRenderBoxClass(*) => ~"GenericRenderBox",
ImageRenderBoxClass(*) => ~"ImageRenderBox",
TextRenderBoxClass(text_box) => {
- let mut text_box = &mut *text_box; // FIXME: Borrow check bug.
fmt!("TextRenderBox(text=%s)", str::substr(text_box.text_data.run.text,
text_box.text_data.range.begin(),
text_box.text_data.range.length()))
}
UnscannedTextRenderBoxClass(text_box) => {
- let mut text_box = &mut *text_box; // FIXME: Borrow check bug.
fmt!("UnscannedTextRenderBox(%s)", text_box.text)
}
};
diff --git a/src/servo/layout/box_builder.rs b/src/servo/layout/box_builder.rs
index 9a04148ced8..079231bc7ba 100644
--- a/src/servo/layout/box_builder.rs
+++ b/src/servo/layout/box_builder.rs
@@ -125,7 +125,6 @@ impl BoxGenerator {
// depending on flow, make a box for this node.
match self.flow {
InlineFlow(inline) => {
- let mut inline = &mut *inline;
let node_range_start = inline.boxes.len();
self.range_stack.push(node_range_start);
@@ -387,24 +386,38 @@ pub impl LayoutTreeBuilder {
// check first/last child for whitespace-ness
for first_child.each |first_flow| {
if first_flow.starts_inline_flow() {
- let boxes = &mut first_flow.inline().boxes;
+ // FIXME: workaround for rust#6393
+ let mut do_remove = false;
+ {
+ let boxes = &first_flow.inline().boxes;
if boxes.len() == 1 && boxes[0].is_whitespace_only() {
debug!("LayoutTreeBuilder: pruning whitespace-only first child flow \
f%d from parent f%d",
first_flow.id(),
parent_flow.id());
+ do_remove = true;
+ }
+ }
+ if (do_remove) {
parent_flow.remove_child(*first_flow);
}
}
}
for last_child.each |last_flow| {
if last_flow.starts_inline_flow() {
- let boxes = &mut last_flow.inline().boxes;
+ // FIXME: workaround for rust#6393
+ let mut do_remove = false;
+ {
+ let boxes = &last_flow.inline().boxes;
if boxes.len() == 1 && boxes.last().is_whitespace_only() {
debug!("LayoutTreeBuilder: pruning whitespace-only last child flow \
f%d from parent f%d",
last_flow.id(),
parent_flow.id());
+ do_remove = true;
+ }
+ }
+ if (do_remove) {
parent_flow.remove_child(*last_flow);
}
}
diff --git a/src/servo/layout/flow.rs b/src/servo/layout/flow.rs
index 231a5a09fd9..117d48b7ed5 100644
--- a/src/servo/layout/flow.rs
+++ b/src/servo/layout/flow.rs
@@ -76,17 +76,14 @@ impl TreeNodeRef<FlowData> for FlowContext {
match *self {
AbsoluteFlow(info) => callback(info),
BlockFlow(info) => {
- let info = &*info; // FIXME: Borrow check workaround.
callback(&info.common)
}
FloatFlow(info) => callback(info),
InlineBlockFlow(info) => callback(info),
InlineFlow(info) => {
- let info = &*info; // FIXME: Borrow check workaround.
callback(&info.common)
}
RootFlow(info) => {
- let info = &*info; // FIXME: Borrow check workaround.
callback(&info.common)
}
TableFlow(info) => callback(info),
@@ -96,17 +93,14 @@ impl TreeNodeRef<FlowData> for FlowContext {
match *self {
AbsoluteFlow(info) => callback(info),
BlockFlow(info) => {
- let info = &mut *info; // FIXME: Borrow check workaround.
callback(&mut info.common)
}
FloatFlow(info) => callback(info),
InlineBlockFlow(info) => callback(info),
InlineFlow(info) => {
- let info = &mut *info; // FIXME: Borrow check workaround.
callback(&mut info.common)
}
RootFlow(info) => {
- let info = &mut *info; // FIXME: Borrow check workaround.
callback(&mut info.common)
}
TableFlow(info) => callback(info),
@@ -388,7 +382,6 @@ impl DebugMethods for FlowContext {
fn debug_str(&self) -> ~str {
let repr = match *self {
InlineFlow(inline) => {
- let inline = &mut *inline;
let mut s = inline.boxes.foldl(~"InlineFlow(children=", |s, box| {
fmt!("%s b%d", *s, box.id())
});
@@ -396,14 +389,12 @@ impl DebugMethods for FlowContext {
s
},
BlockFlow(block) => {
- let block = &mut *block;
match block.box {
Some(box) => fmt!("BlockFlow(box=b%d)", box.id()),
None => ~"BlockFlow",
}
},
RootFlow(root) => {
- let root = &mut *root;
match root.box {
Some(box) => fmt!("RootFlow(box=b%d)", box.id()),
None => ~"RootFlow",
diff --git a/src/servo/layout/inline.rs b/src/servo/layout/inline.rs
index 6a0cf73fa34..b3cec67d5af 100644
--- a/src/servo/layout/inline.rs
+++ b/src/servo/layout/inline.rs
@@ -173,7 +173,7 @@ impl TextRunScanner {
impl TextRunScanner {
fn scan_for_runs(&mut self, ctx: &mut LayoutContext, flow: FlowContext) {
- let inline = &mut *flow.inline();
+ let inline = flow.inline();
assert!(inline.boxes.len() > 0);
debug!("TextRunScanner: scanning %u boxes for text runs...", inline.boxes.len());
@@ -334,8 +334,7 @@ impl TextRunScanner {
debug!("------------------");
debug!("--- Elem ranges: ---");
- let elems: &mut ElementMapping = &mut flow.inline().elems;
- for elems.eachi_mut |i: uint, nr: &NodeRange| {
+ for flow.inline().elems.eachi_mut |i: uint, nr: &NodeRange| {
debug!("%u: %? --> %s", i, nr.range, nr.node.debug_str()); ()
}
debug!("--------------------");
@@ -386,43 +385,46 @@ impl LineboxScanner {
pub fn scan_for_lines(&mut self, ctx: &LayoutContext) {
self.reset_scanner();
- let boxes = &mut self.flow.inline().boxes;
- let mut i = 0u;
-
- loop {
- // acquire the next box to lay out from work list or box list
- let cur_box = if self.work_list.is_empty() {
- if i == boxes.len() {
- break
+ { // FIXME: manually control borrow length
+ let inline: &InlineFlowData = self.flow.inline();
+ let mut i = 0u;
+
+ loop {
+ // acquire the next box to lay out from work list or box list
+ let cur_box = if self.work_list.is_empty() {
+ if i == inline.boxes.len() {
+ break
+ }
+ let box = inline.boxes[i]; i += 1;
+ debug!("LineboxScanner: Working with box from box list: b%d", box.id());
+ box
+ } else {
+ let box = self.work_list.pop_front();
+ debug!("LineboxScanner: Working with box from work list: b%d", box.id());
+ box
+ };
+
+ let box_was_appended = self.try_append_to_line(ctx, cur_box);
+ if !box_was_appended {
+ debug!("LineboxScanner: Box wasn't appended, because line %u was full.",
+ self.line_spans.len());
+ self.flush_current_line();
+ } else {
+ debug!("LineboxScanner: appended a box to line %u", self.line_spans.len());
}
- let box = boxes[i]; i += 1;
- debug!("LineboxScanner: Working with box from box list: b%d", box.id());
- box
- } else {
- let box = self.work_list.pop_front();
- debug!("LineboxScanner: Working with box from work list: b%d", box.id());
- box
- };
-
- let box_was_appended = self.try_append_to_line(ctx, cur_box);
- if !box_was_appended {
- debug!("LineboxScanner: Box wasn't appended, because line %u was full.",
+ }
+
+ if self.pending_line.range.length() > 0 {
+ debug!("LineboxScanner: Partially full linebox %u left at end of scanning.",
self.line_spans.len());
self.flush_current_line();
- } else {
- debug!("LineboxScanner: appended a box to line %u", self.line_spans.len());
}
}
-
- if self.pending_line.range.length() > 0 {
- debug!("LineboxScanner: Partially full linebox %u left at end of scanning.",
- self.line_spans.len());
- self.flush_current_line();
+
+ { // FIXME: scope the borrow
+ let inline: &mut InlineFlowData = self.flow.inline();
+ inline.elems.repair_for_box_changes(inline.boxes, self.new_boxes);
}
-
- let boxes = &mut self.flow.inline().boxes;
- let elems = &mut self.flow.inline().elems;
- elems.repair_for_box_changes(*boxes, self.new_boxes);
self.swap_out_results();
}
@@ -431,10 +433,9 @@ impl LineboxScanner {
self.line_spans.len(),
self.flow.id());
- let inline_boxes = &mut self.flow.inline().boxes;
- util::swap(inline_boxes, &mut self.new_boxes);
- let lines = &mut self.flow.inline().lines;
- util::swap(lines, &mut self.line_spans);
+ let inline: &mut InlineFlowData = self.flow.inline();
+ util::swap(&mut inline.boxes, &mut self.new_boxes);
+ util::swap(&mut inline.lines, &mut self.line_spans);
}
fn flush_current_line(&mut self) {
@@ -763,7 +764,6 @@ impl InlineFlowData {
// TODO: We can use font metrics directly instead of re-measuring for the
// bounding box.
TextRenderBoxClass(text_box) => {
- let text_box = &mut *text_box; // FIXME: borrow check workaround
let range = &text_box.text_data.range;
let run = &text_box.text_data.run;
let text_bounds = run.metrics_for_range(range).bounding_box;
@@ -814,7 +814,7 @@ impl InlineFlowData {
self.common.position.size.height = cur_y;
}
- pub fn build_display_list_inline(&mut self,
+ pub fn build_display_list_inline(&self,
builder: &DisplayListBuilder,
dirty: &Rect<Au>,
offset: &Point2D<Au>,