mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
For loops and misc changes
This commit is contained in:
parent
1bdaff0fad
commit
307f1074d3
42 changed files with 220 additions and 243 deletions
|
@ -48,7 +48,7 @@ impl<E> DisplayList<E> {
|
|||
/// Draws the display list into the given render context.
|
||||
pub fn draw_into_context(&self, render_context: &RenderContext) {
|
||||
debug!("Beginning display list.");
|
||||
for self.list.iter().advance |item| {
|
||||
for item in self.list.iter() {
|
||||
// FIXME(Issue #150): crashes
|
||||
//debug!("drawing %?", *item);
|
||||
item.draw_into_context(render_context)
|
||||
|
|
|
@ -390,8 +390,8 @@ impl Font {
|
|||
let mut azglyphs = ~[];
|
||||
azglyphs.reserve(range.length());
|
||||
|
||||
for run.iter_slices_for_range(range) |glyphs, _offset, slice_range| {
|
||||
for glyphs.iter_glyphs_for_char_range(slice_range) |_i, glyph| {
|
||||
for (glyphs, _offset, slice_range) in run.iter_slices_for_range(range) {
|
||||
for (_i, glyph) in glyphs.iter_glyphs_for_char_range(&slice_range) {
|
||||
let glyph_advance = glyph.advance_();
|
||||
let glyph_offset = glyph.offset().unwrap_or_default(Au::zero_point());
|
||||
|
||||
|
@ -430,8 +430,8 @@ impl Font {
|
|||
// TODO(Issue #199): alter advance direction for RTL
|
||||
// TODO(Issue #98): using inter-char and inter-word spacing settings when measuring text
|
||||
let mut advance = Au(0);
|
||||
for run.iter_slices_for_range(range) |glyphs, _offset, slice_range| {
|
||||
for glyphs.iter_glyphs_for_char_range(slice_range) |_i, glyph| {
|
||||
for (glyphs, _offset, slice_range) in run.iter_slices_for_range(range) {
|
||||
for (_i, glyph) in glyphs.iter_glyphs_for_char_range(&slice_range) {
|
||||
advance = advance + glyph.advance_();
|
||||
}
|
||||
}
|
||||
|
@ -443,7 +443,7 @@ impl Font {
|
|||
slice_range: &Range)
|
||||
-> RunMetrics {
|
||||
let mut advance = Au(0);
|
||||
for glyphs.iter_glyphs_for_char_range(slice_range) |_i, glyph| {
|
||||
for (_i, glyph) in glyphs.iter_glyphs_for_char_range(slice_range) {
|
||||
advance = advance + glyph.advance_();
|
||||
}
|
||||
RunMetrics::new(advance, self.metrics.ascent, self.metrics.descent)
|
||||
|
|
|
@ -126,7 +126,7 @@ impl<'self> FontContext {
|
|||
debug!("(create font group) --- starting ---");
|
||||
|
||||
// TODO(Issue #193): make iteration over 'font-family' more robust.
|
||||
for style.families.split_iter(',').advance |family| {
|
||||
for family in style.families.split_iter(',') {
|
||||
let family_name = family.trim();
|
||||
let transformed_family_name = self.transform_family(family_name);
|
||||
debug!("(create font group) transformed family is `%s`", transformed_family_name);
|
||||
|
@ -136,7 +136,7 @@ impl<'self> FontContext {
|
|||
};
|
||||
|
||||
let mut found = false;
|
||||
for result.iter().advance |font_entry| {
|
||||
for font_entry in result.iter() {
|
||||
found = true;
|
||||
|
||||
let font_id =
|
||||
|
@ -145,7 +145,7 @@ impl<'self> FontContext {
|
|||
|
||||
let instance = self.get_font_by_descriptor(&font_desc);
|
||||
|
||||
do result::iter(&instance) |font: &@mut Font| { fonts.push(*font); }
|
||||
for font in instance.iter() { fonts.push(*font); }
|
||||
};
|
||||
|
||||
if !found {
|
||||
|
@ -155,19 +155,19 @@ impl<'self> FontContext {
|
|||
|
||||
let last_resort = FontList::get_last_resort_font_families();
|
||||
|
||||
for last_resort.iter().advance |family| {
|
||||
for family in last_resort.iter() {
|
||||
let result = do self.font_list.chain_ref |fl| {
|
||||
fl.find_font_in_family(*family, style)
|
||||
};
|
||||
|
||||
for result.iter().advance |font_entry| {
|
||||
for font_entry in result.iter() {
|
||||
let font_id =
|
||||
SelectorPlatformIdentifier(font_entry.handle.face_identifier());
|
||||
let font_desc = FontDescriptor::new((*style).clone(), font_id);
|
||||
|
||||
let instance = self.get_font_by_descriptor(&font_desc);
|
||||
|
||||
do result::iter(&instance) |font: &@mut Font| {
|
||||
for font in instance.iter() {
|
||||
fonts.push(*font);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ impl FontList {
|
|||
|
||||
// if such family exists, try to match style to a font
|
||||
let mut result: Option<@FontEntry> = None;
|
||||
for family.iter().advance |fam| {
|
||||
for fam in family.iter() {
|
||||
result = fam.find_font_for_style(&self.handle, style);
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ impl FontFamily {
|
|||
// TODO(Issue #190): if not in the fast path above, do
|
||||
// expensive matching of weights, etc.
|
||||
let this: &mut FontFamily = self; // FIXME: borrow checker workaround
|
||||
for this.entries.iter().advance |entry| {
|
||||
for entry in this.entries.iter() {
|
||||
if (style.weight.is_bold() == entry.is_bold()) &&
|
||||
(style.italic == entry.is_italic()) {
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ impl FontListHandle {
|
|||
unsafe {
|
||||
let config = FcConfigGetCurrent();
|
||||
let fontSet = FcConfigGetFonts(config, FcSetSystem);
|
||||
for uint::range(0, (*fontSet).nfont as uint) |i| {
|
||||
for i in range(0, (*fontSet).nfont as int) {
|
||||
let font = (*fontSet).fonts.offset(i);
|
||||
let family: *FcChar8 = ptr::null();
|
||||
let mut v: c_int = 0;
|
||||
|
@ -91,7 +91,7 @@ impl FontListHandle {
|
|||
|
||||
debug!("found %? variations", (*matches).nfont);
|
||||
|
||||
for uint::range(0, (*matches).nfont as uint) |i| {
|
||||
for i in range(0, (*matches).nfont as int) {
|
||||
let font = (*matches).fonts.offset(i);
|
||||
let file = do "file".as_c_str |FC_FILE| {
|
||||
let file: *FcChar8 = ptr::null();
|
||||
|
|
|
@ -31,7 +31,7 @@ impl FontListHandle {
|
|||
pub fn get_available_families(&self) -> FontFamilyMap {
|
||||
let family_names: CFArray<CFStringRef> = core_text::font_collection::get_family_names();
|
||||
let mut family_map: FontFamilyMap = HashMap::new();
|
||||
for family_names.each |&strref: &CFStringRef| {
|
||||
for &strref in family_names.each() {
|
||||
let family_name = CFString::wrap_shared(strref).to_str();
|
||||
debug!("Creating new FontFamily for family: %s", family_name);
|
||||
|
||||
|
@ -45,7 +45,7 @@ impl FontListHandle {
|
|||
debug!("Looking for faces of family: %s", family.family_name);
|
||||
|
||||
let family_collection = core_text::font_collection::create_for_family(family.family_name);
|
||||
for family_collection.get_descriptors().each |descref: &CTFontDescriptorRef| {
|
||||
for &CTFontDescriptorRef in family_collection.get_descriptors().each() {
|
||||
let desc = CFWrapper::wrap_shared(*descref);
|
||||
let font = core_text::font::new_from_descriptor(&desc, 0.0);
|
||||
let handle = FontHandle::new_from_CTFont(&self.fctx, font).unwrap();
|
||||
|
|
|
@ -180,7 +180,7 @@ impl<C: RenderListener + Send> RenderTask<C> {
|
|||
|
||||
// Divide up the layer into tiles.
|
||||
do time::profile(time::RenderingPrepBuffCategory, self.profiler_chan.clone()) {
|
||||
for tiles.iter().advance |tile| {
|
||||
for tile in tiles.iter() {
|
||||
let width = tile.screen_rect.size.width;
|
||||
let height = tile.screen_rect.size.height;
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ use std::cmp::{Ord, Eq};
|
|||
use std::num::NumCast;
|
||||
use std::u16;
|
||||
use std::vec;
|
||||
use std::uint;
|
||||
use std::util;
|
||||
use std::iterator;
|
||||
use geom::point::Point2D;
|
||||
|
|
|
@ -271,7 +271,7 @@ impl Shaper {
|
|||
}
|
||||
|
||||
debug!("(glyph idx) -> (text byte offset)");
|
||||
for uint::range(0, glyph_data.len()) |i| {
|
||||
for i in range(0, glyph_data.len()) {
|
||||
// loc refers to a *byte* offset within the utf8 string.
|
||||
let loc = glyph_data.byte_offset_of_glyph(i);
|
||||
if loc < byte_max {
|
||||
|
@ -334,7 +334,7 @@ impl Shaper {
|
|||
// extend glyph range to max glyph index covered by char_span,
|
||||
// in cases where one char made several glyphs and left some unassociated chars.
|
||||
let mut max_glyph_idx = glyph_span.end();
|
||||
for char_byte_span.eachi |i| {
|
||||
for i in char_byte_span.eachi() {
|
||||
if byteToGlyph[i] > NO_GLYPH {
|
||||
max_glyph_idx = uint::max(byteToGlyph[i] as uint, max_glyph_idx);
|
||||
}
|
||||
|
@ -358,7 +358,7 @@ impl Shaper {
|
|||
probably doesn't work.");
|
||||
|
||||
let mut all_glyphs_are_within_cluster: bool = true;
|
||||
for glyph_span.eachi |j| {
|
||||
for j in glyph_span.eachi() {
|
||||
let loc = glyph_data.byte_offset_of_glyph(j);
|
||||
if !char_byte_span.contains(loc) {
|
||||
all_glyphs_are_within_cluster = false;
|
||||
|
@ -437,7 +437,7 @@ impl Shaper {
|
|||
// collect all glyphs to be assigned to the first character.
|
||||
let mut datas = ~[];
|
||||
|
||||
for glyph_span.eachi |glyph_i| {
|
||||
for glyph_i in glyph_span.eachi() {
|
||||
let shape = glyph_data.get_entry_for_glyph(glyph_i, &mut y_pos);
|
||||
datas.push(GlyphData::new(shape.codepoint,
|
||||
shape.advance,
|
||||
|
|
|
@ -205,7 +205,7 @@ impl<'self> TextRun {
|
|||
pub fn glyphs(&'self self) -> &'self ~[Arc<GlyphStore>] { &self.glyphs }
|
||||
|
||||
pub fn range_is_trimmable_whitespace(&self, range: &Range) -> bool {
|
||||
for self.iter_slices_for_range(range) |slice_glyphs, _, _| {
|
||||
for (slice_glyphs, _, _) in self.iter_slices_for_range(range) {
|
||||
if !slice_glyphs.is_whitespace() { return false; }
|
||||
}
|
||||
true
|
||||
|
@ -222,9 +222,9 @@ impl<'self> TextRun {
|
|||
pub fn min_width_for_range(&self, range: &Range) -> Au {
|
||||
let mut max_piece_width = Au(0);
|
||||
debug!("iterating outer range %?", range);
|
||||
for self.iter_slices_for_range(range) |glyphs, offset, slice_range| {
|
||||
for (glyphs, offset, slice_range) in self.iter_slices_for_range(range) {
|
||||
debug!("iterated on %?[%?]", offset, slice_range);
|
||||
let metrics = self.font.measure_text_for_slice(glyphs, slice_range);
|
||||
let metrics = self.font.measure_text_for_slice(glyphs, &slice_range);
|
||||
max_piece_width = Au::max(max_piece_width, metrics.advance_width);
|
||||
}
|
||||
max_piece_width
|
||||
|
|
|
@ -24,7 +24,7 @@ pub fn transform_text(text: &str, mode: CompressionMode, incoming_whitespace: bo
|
|||
let mut out_str: ~str = ~"";
|
||||
let out_whitespace = match mode {
|
||||
CompressNone | DiscardNewline => {
|
||||
for text.iter().advance |ch: char| {
|
||||
for ch in text.iter() {
|
||||
if is_discardable_char(ch, mode) {
|
||||
// TODO: record skipped char
|
||||
} else {
|
||||
|
@ -40,7 +40,7 @@ pub fn transform_text(text: &str, mode: CompressionMode, incoming_whitespace: bo
|
|||
|
||||
CompressWhitespace | CompressWhitespaceNewline => {
|
||||
let mut in_whitespace: bool = incoming_whitespace;
|
||||
for text.iter().advance |ch: char| {
|
||||
for ch in text.iter() {
|
||||
// TODO: discard newlines between CJK chars
|
||||
let mut next_in_whitespace: bool = is_in_whitespace(ch, mode);
|
||||
|
||||
|
@ -134,7 +134,7 @@ fn test_transform_compress_none() {
|
|||
~"foobarbaz\n\n"];
|
||||
let mode = CompressNone;
|
||||
|
||||
for uint::range(0, test_strs.len()) |i| {
|
||||
for i in range(0, test_strs.len()) {
|
||||
(trimmed_str, _out) = transform_text(test_strs[i], mode, true);
|
||||
assert!(trimmed_str == test_strs[i])
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ fn test_transform_discard_newline() {
|
|||
assert!(test_strs.len() == oracle_strs.len());
|
||||
let mode = DiscardNewline;
|
||||
|
||||
for uint::range(0, test_strs.len()) |i| {
|
||||
for i in range(0, test_strs.len()) {
|
||||
(trimmed_str, _out) = transform_text(test_strs[i], mode, true);
|
||||
assert!(trimmed_str == oracle_strs[i])
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ fn test_transform_compress_whitespace() {
|
|||
assert!(test_strs.len() == oracle_strs.len());
|
||||
let mode = CompressWhitespace;
|
||||
|
||||
for uint::range(0, test_strs.len()) |i| {
|
||||
for i in range(0, test_strs.len()) {
|
||||
(trimmed_str, _out) = transform_text(test_strs[i], mode, true);
|
||||
assert!(trimmed_str == oracle_strs[i])
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ fn test_transform_compress_whitespace_newline() {
|
|||
assert!(test_strs.len() == oracle_strs.len());
|
||||
let mode = CompressWhitespaceNewline;
|
||||
|
||||
for uint::range(0, test_strs.len()) |i| {
|
||||
for i in range(0, test_strs.len()) {
|
||||
(trimmed_str, _out) = transform_text(test_strs[i], mode, true);
|
||||
assert!(trimmed_str == oracle_strs[i])
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ fn test_transform_compress_whitespace_newline() {
|
|||
assert!(test_strs.len() == oracle_strs.len());
|
||||
let mode = CompressWhitespaceNewline;
|
||||
|
||||
for uint::range(0, test_strs.len()) |i| {
|
||||
for i in range(0, test_strs.len()) {
|
||||
(trimmed_str, _out) = transform_text(test_strs[i], mode, false);
|
||||
assert!(trimmed_str == oracle_strs[i])
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ impl CompositorLayer {
|
|||
// true; otherwise returns false, so a parent layer can scroll instead.
|
||||
pub fn scroll(&mut self, delta: Point2D<f32>, cursor: Point2D<f32>, window_size: Size2D<f32>) -> bool {
|
||||
let cursor = cursor - self.scroll_offset;
|
||||
for self.children.mut_iter().filter(|x| !x.child.hidden).advance |child| {
|
||||
for child in self.children.mut_iter().filter(|x| !x.child.hidden) {
|
||||
match child.container.scissor {
|
||||
None => {
|
||||
error!("CompositorLayer: unable to perform cursor hit test for layer");
|
||||
|
@ -131,7 +131,7 @@ impl CompositorLayer {
|
|||
// page coordinates.
|
||||
pub fn send_mouse_event(&self, event: MouseWindowEvent, cursor: Point2D<f32>) {
|
||||
let cursor = cursor - self.scroll_offset;
|
||||
for self.children.iter().filter(|&x| !x.child.hidden).advance |child| {
|
||||
for child in self.children.iter().filter(|&x| !x.child.hidden) {
|
||||
match child.container.scissor {
|
||||
None => {
|
||||
error!("CompositorLayer: unable to perform cursor hit test for layer");
|
||||
|
@ -206,7 +206,7 @@ impl CompositorLayer {
|
|||
// and clip the layer to the specified size in page coordinates.
|
||||
// This method returns false if the specified layer is not found.
|
||||
pub fn set_clipping_rect(&mut self, pipeline_id: PipelineId, new_rect: Rect<f32>) -> bool {
|
||||
for self.children.iter().advance |child_node| {
|
||||
for child_node in self.children.iter() {
|
||||
if pipeline_id != child_node.child.pipeline.id {
|
||||
loop;
|
||||
}
|
||||
|
@ -265,15 +265,15 @@ impl CompositorLayer {
|
|||
|
||||
// Delete old layer.
|
||||
while current_layer_child.is_some() {
|
||||
let trash = current_layer_child.get();
|
||||
do current_layer_child.get().with_common |common| {
|
||||
let trash = current_layer_child.unwrap();
|
||||
do current_layer_child.unwrap().with_common |common| {
|
||||
current_layer_child = common.next_sibling;
|
||||
}
|
||||
self.root_layer.remove_child(trash);
|
||||
}
|
||||
|
||||
// Add child layers.
|
||||
for self.children.mut_iter().filter(|x| !x.child.hidden).advance |child| {
|
||||
for child in self.children.mut_iter().filter(|x| !x.child.hidden) {
|
||||
current_layer_child = match current_layer_child {
|
||||
None => {
|
||||
child.container.common.parent = None;
|
||||
|
@ -295,7 +295,7 @@ impl CompositorLayer {
|
|||
};
|
||||
|
||||
let all_tiles = quadtree.get_all_tiles();
|
||||
for all_tiles.iter().advance |buffer| {
|
||||
for buffer in all_tiles.iter() {
|
||||
debug!("osmain: compositing buffer rect %?", &buffer.rect);
|
||||
|
||||
// Find or create a texture layer.
|
||||
|
@ -339,7 +339,7 @@ impl CompositorLayer {
|
|||
Tree(ref mut quadtree) => quadtree,
|
||||
};
|
||||
|
||||
for new_buffers.buffers.iter().advance |buffer| {
|
||||
for buffer in new_buffers.buffers.iter() {
|
||||
// TODO: This may return old buffers, which should be sent back to the renderer.
|
||||
quadtree.add_tile_pixel(buffer.screen_pos.origin.x, buffer.screen_pos.origin.y,
|
||||
buffer.resolution, ~buffer.clone());
|
||||
|
|
|
@ -25,7 +25,6 @@ use std::comm;
|
|||
use std::comm::{Chan, SharedChan, Port};
|
||||
use std::num::Orderable;
|
||||
use std::task;
|
||||
use std::uint;
|
||||
use std::vec;
|
||||
use extra::uv_global_loop;
|
||||
use extra::timer;
|
||||
|
@ -242,7 +241,7 @@ impl CompositorTask {
|
|||
let ask_for_tiles = || {
|
||||
let window_size_page = Size2D(window_size.width as f32 / world_zoom,
|
||||
window_size.height as f32 / world_zoom);
|
||||
for compositor_layer.mut_iter().advance |layer| {
|
||||
for layer in compositor_layer.mut_iter() {
|
||||
recomposite = layer.get_buffer_request(Rect(Point2D(0f32, 0f32), window_size_page),
|
||||
world_zoom) || recomposite;
|
||||
}
|
||||
|
@ -368,7 +367,7 @@ impl CompositorTask {
|
|||
MouseWindowMouseDownEvent(_, p) => Point2D(p.x / world_zoom, p.y / world_zoom),
|
||||
MouseWindowMouseUpEvent(_, p) => Point2D(p.x / world_zoom, p.y / world_zoom),
|
||||
};
|
||||
for compositor_layer.iter().advance |layer| {
|
||||
for layer in compositor_layer.iter() {
|
||||
layer.send_mouse_event(mouse_window_event, point);
|
||||
}
|
||||
}
|
||||
|
@ -380,7 +379,7 @@ impl CompositorTask {
|
|||
cursor.y as f32 / world_zoom);
|
||||
let page_window = Size2D(window_size.width as f32 / world_zoom,
|
||||
window_size.height as f32 / world_zoom);
|
||||
for compositor_layer.mut_iter().advance |layer| {
|
||||
for layer in compositor_layer.mut_iter() {
|
||||
recomposite = layer.scroll(page_delta, page_cursor, page_window) || recomposite;
|
||||
}
|
||||
ask_for_tiles();
|
||||
|
@ -402,7 +401,7 @@ impl CompositorTask {
|
|||
let page_cursor = Point2D(-1f32, -1f32); // Make sure this hits the base layer
|
||||
let page_window = Size2D(window_size.width as f32 / world_zoom,
|
||||
window_size.height as f32 / world_zoom);
|
||||
for compositor_layer.mut_iter().advance |layer| {
|
||||
for layer in compositor_layer.mut_iter() {
|
||||
layer.scroll(page_delta, page_cursor, page_window);
|
||||
}
|
||||
|
||||
|
@ -458,7 +457,7 @@ impl CompositorTask {
|
|||
// flip image vertically (texture is upside down)
|
||||
let orig_pixels = pixels.clone();
|
||||
let stride = width * 3;
|
||||
for uint::range(0, height) |y| {
|
||||
for y in range(0, height) {
|
||||
let dst_start = y * stride;
|
||||
let src_start = (height - y - 1) * stride;
|
||||
vec::bytes::copy_memory(pixels.mut_slice(dst_start, dst_start + stride),
|
||||
|
|
|
@ -212,7 +212,7 @@ impl<T: Tile> Quadtree<T> {
|
|||
let difference = (new_size as f32 / self.root.size as f32).log2() as int;
|
||||
if difference > 0 { // doubling
|
||||
let difference = difference as uint;
|
||||
for range(0, difference) |i| {
|
||||
for i in range(0, difference) {
|
||||
let new_root = ~QuadtreeNode {
|
||||
tile: None,
|
||||
origin: Point2D(0f32, 0f32),
|
||||
|
@ -225,7 +225,7 @@ impl<T: Tile> Quadtree<T> {
|
|||
}
|
||||
} else if difference < 0 { // halving
|
||||
let difference = difference.abs() as uint;
|
||||
for difference.times {
|
||||
for _ in range(0, difference) {
|
||||
let remove = replace(&mut self.root.quadrants[TL as int], None);
|
||||
match remove {
|
||||
Some(child) => self.root = child,
|
||||
|
@ -299,7 +299,7 @@ impl<T: Tile> QuadtreeNode<T> {
|
|||
fn get_all_tiles<'r>(&'r self) -> ~[&'r T] {
|
||||
let mut ret = ~[];
|
||||
|
||||
for self.quadrants.iter().advance |quad| {
|
||||
for quad in self.quadrants.iter() {
|
||||
match *quad {
|
||||
Some(ref child) => ret = ret + child.get_all_tiles(),
|
||||
None => {}
|
||||
|
@ -332,7 +332,7 @@ impl<T: Tile> QuadtreeNode<T> {
|
|||
self.tile = Some(tile);
|
||||
// FIXME: This should be inline, but currently won't compile
|
||||
let quads = [TL, TR, BL, BR];
|
||||
for quads.iter().advance |quad| {
|
||||
for quad in quads.iter() {
|
||||
self.quadrants[*quad as int] = None;
|
||||
}
|
||||
self.render_flag = false;
|
||||
|
@ -439,7 +439,7 @@ impl<T: Tile> QuadtreeNode<T> {
|
|||
let mut del_quad: Option<Quadrant> = None;
|
||||
let mut ret = (None, false, 0);
|
||||
|
||||
for queue.iter().advance |quad| {
|
||||
for quad in queue.iter() {
|
||||
match self.quadrants[*quad as int] {
|
||||
Some(ref mut child) => {
|
||||
let (tile, flag, delta) = child.remove_tile(x, y);
|
||||
|
@ -514,7 +514,7 @@ impl<T: Tile> QuadtreeNode<T> {
|
|||
let old_mem = self.tile_mem;
|
||||
// FIXME: This should be inline, but currently won't compile
|
||||
let quads = [TL, TR, BL, BR];
|
||||
for quads.iter().advance |quad| {
|
||||
for quad in quads.iter() {
|
||||
self.quadrants[*quad as int] = None;
|
||||
}
|
||||
self.tile_mem = tile.get_mem();
|
||||
|
@ -561,7 +561,7 @@ impl<T: Tile> QuadtreeNode<T> {
|
|||
let mut redisplay = false;
|
||||
let mut delta = 0;
|
||||
|
||||
for quads_to_check.iter().advance |quad| {
|
||||
for quad in quads_to_check.iter() {
|
||||
// Recurse into child
|
||||
let new_window = match *quad {
|
||||
TL => Rect(window.origin,
|
||||
|
@ -628,7 +628,7 @@ impl<T: Tile> QuadtreeNode<T> {
|
|||
ret = fmt!("%s<table border=1><tr>", ret);
|
||||
// FIXME: This should be inline, but currently won't compile
|
||||
let quads = [TL, TR, BL, BR];
|
||||
for quads.iter().advance |quad| {
|
||||
for quad in quads.iter() {
|
||||
match self.quadrants[*quad as int] {
|
||||
Some(ref child) => {
|
||||
ret = fmt!("%s<td>%s</td>", ret, child.get_html());
|
||||
|
|
|
@ -93,21 +93,21 @@ impl FrameTree {
|
|||
|
||||
/// Replaces a node of the frame tree in place. Returns the node that was removed or the original node
|
||||
/// if the node to replace could not be found.
|
||||
fn replace_child(&mut self, id: PipelineId, new_child: @mut FrameTree) -> Result<@mut FrameTree, @mut FrameTree> {
|
||||
fn replace_child(&mut self, id: PipelineId, new_child: @mut FrameTree) -> Either<@mut FrameTree, @mut FrameTree> {
|
||||
let new_child_cell = Cell::new(new_child);
|
||||
for self.children.mut_iter().advance |child| {
|
||||
for child in self.children.mut_iter() {
|
||||
let new_child = new_child_cell.take();
|
||||
if child.pipeline.id == id {
|
||||
new_child.parent = child.parent;
|
||||
return Ok(replace(child, new_child));
|
||||
return Left(replace(child, new_child));
|
||||
}
|
||||
let replaced = child.replace_child(id, new_child);
|
||||
if replaced.is_ok() {
|
||||
if replaced.is_left() {
|
||||
return replaced;
|
||||
}
|
||||
new_child_cell.put_back(replaced.get_err());
|
||||
new_child_cell.put_back(replaced.unwrap_right());
|
||||
}
|
||||
Err(new_child_cell.take())
|
||||
Right(new_child_cell.take())
|
||||
}
|
||||
|
||||
fn to_sendable(&self) -> SendableFrameTree {
|
||||
|
@ -283,7 +283,7 @@ impl Constellation {
|
|||
match request {
|
||||
|
||||
ExitMsg(sender) => {
|
||||
for self.pipelines.iter().advance |(_id, ref pipeline)| {
|
||||
for (_id, ref pipeline) in self.pipelines.iter() {
|
||||
pipeline.exit();
|
||||
}
|
||||
self.image_cache_task.exit();
|
||||
|
@ -389,7 +389,7 @@ impl Constellation {
|
|||
} else {
|
||||
pipeline.load(url, None);
|
||||
}
|
||||
for frame_trees.iter().advance |frame_tree| {
|
||||
for frame_tree in frame_trees.iter() {
|
||||
frame_tree.children.push(@mut FrameTree {
|
||||
pipeline: pipeline,
|
||||
parent: Some(source_pipeline),
|
||||
|
@ -410,7 +410,7 @@ impl Constellation {
|
|||
with a pipeline not in the active frame tree. This should be
|
||||
impossible.");
|
||||
|
||||
for self.pending_frames.iter().advance |frame_change| {
|
||||
for frame_change in self.pending_frames.iter() {
|
||||
let old_id = frame_change.before.expect("Constellation: Received load msg
|
||||
from pipeline, but there is no currently active page. This should
|
||||
be impossible.");
|
||||
|
@ -471,7 +471,7 @@ impl Constellation {
|
|||
return true
|
||||
} else {
|
||||
let old = self.current_frame().get_ref();
|
||||
for old.iter().advance |frame| {
|
||||
for frame in old.iter() {
|
||||
frame.pipeline.revoke_paint_permission();
|
||||
}
|
||||
}
|
||||
|
@ -483,7 +483,7 @@ impl Constellation {
|
|||
return true
|
||||
} else {
|
||||
let old = self.current_frame().get_ref();
|
||||
for old.iter().advance |frame| {
|
||||
for frame in old.iter() {
|
||||
frame.pipeline.revoke_paint_permission();
|
||||
}
|
||||
}
|
||||
|
@ -491,7 +491,7 @@ impl Constellation {
|
|||
}
|
||||
};
|
||||
|
||||
for destination_frame.iter().advance |frame| {
|
||||
for frame in destination_frame.iter() {
|
||||
let pipeline = &frame.pipeline;
|
||||
pipeline.reload(Some(constellation_msg::Navigate));
|
||||
}
|
||||
|
@ -505,7 +505,7 @@ impl Constellation {
|
|||
// from a pending frame. The only time that we will grant paint permission is
|
||||
// when the message originates from a pending frame or the current frame.
|
||||
|
||||
for self.current_frame().iter().advance |¤t_frame| {
|
||||
for ¤t_frame in self.current_frame().iter() {
|
||||
// Messages originating in the current frame are not navigations;
|
||||
// TODO(tkuehn): In fact, this kind of message might be provably
|
||||
// impossible to occur.
|
||||
|
@ -521,7 +521,7 @@ impl Constellation {
|
|||
let pending_index = do self.pending_frames.rposition |frame_change| {
|
||||
frame_change.after.pipeline.id == pipeline_id
|
||||
};
|
||||
for pending_index.iter().advance |&pending_index| {
|
||||
for &pending_index in pending_index.iter() {
|
||||
let frame_change = self.pending_frames.swap_remove(pending_index);
|
||||
let to_add = frame_change.after;
|
||||
|
||||
|
@ -540,7 +540,7 @@ impl Constellation {
|
|||
"Constellation: pending frame change refers to an old
|
||||
frame not contained in the current frame. This is a bug");
|
||||
|
||||
for to_revoke.iter().advance |frame| {
|
||||
for frame in to_revoke.iter() {
|
||||
frame.pipeline.revoke_paint_permission();
|
||||
}
|
||||
|
||||
|
@ -554,7 +554,7 @@ impl Constellation {
|
|||
// Add to_add to parent's children, if it is not the root
|
||||
let parent = &to_add.parent;
|
||||
let to_add = Cell::new(to_add);
|
||||
for parent.iter().advance |parent| {
|
||||
for parent in parent.iter() {
|
||||
let parent = next_frame_tree.find_mut(parent.id).expect(
|
||||
"Constellation: pending frame has a parent frame that is not
|
||||
active. This is a bug.");
|
||||
|
@ -569,13 +569,13 @@ impl Constellation {
|
|||
ResizedWindowBroadcast(new_size) => match *self.current_frame() {
|
||||
Some(ref current_frame) => {
|
||||
let current_frame_id = current_frame.pipeline.id.clone();
|
||||
for self.navigation_context.previous.iter().advance |frame_tree| {
|
||||
for frame_tree in self.navigation_context.previous.iter() {
|
||||
let pipeline = &frame_tree.pipeline;
|
||||
if current_frame_id != pipeline.id {
|
||||
pipeline.script_chan.send(ResizeInactiveMsg(new_size));
|
||||
}
|
||||
}
|
||||
for self.navigation_context.next.iter().advance |frame_tree| {
|
||||
for frame_tree in self.navigation_context.next.iter() {
|
||||
let pipeline = &frame_tree.pipeline;
|
||||
if current_frame_id != pipeline.id {
|
||||
pipeline.script_chan.send(ResizeInactiveMsg(new_size));
|
||||
|
@ -583,10 +583,10 @@ impl Constellation {
|
|||
}
|
||||
}
|
||||
None => {
|
||||
for self.navigation_context.previous.iter().advance |frame_tree| {
|
||||
for frame_tree in self.navigation_context.previous.iter() {
|
||||
frame_tree.pipeline.script_chan.send(ResizeInactiveMsg(new_size));
|
||||
}
|
||||
for self.navigation_context.next.iter().advance |frame_tree| {
|
||||
for frame_tree in self.navigation_context.next.iter() {
|
||||
frame_tree.pipeline.script_chan.send(ResizeInactiveMsg(new_size));
|
||||
}
|
||||
}
|
||||
|
@ -606,9 +606,9 @@ impl Constellation {
|
|||
match frame_tree.pipeline.navigation_type {
|
||||
Some(constellation_msg::Load) => {
|
||||
let evicted = self.navigation_context.load(frame_tree);
|
||||
for evicted.iter().advance |frame_tree| {
|
||||
for frame_tree in evicted.iter() {
|
||||
// exit any pipelines that don't exist outside the evicted frame trees
|
||||
for frame_tree.iter().advance |frame| {
|
||||
for frame in frame_tree.iter() {
|
||||
if !self.navigation_context.contains(frame.pipeline.id) {
|
||||
frame_tree.pipeline.exit();
|
||||
self.pipelines.remove(&frame_tree.pipeline.id);
|
||||
|
@ -624,7 +624,7 @@ impl Constellation {
|
|||
let (port, chan) = comm::stream();
|
||||
self.compositor_chan.send(SetIds(frame_tree.to_sendable(), chan));
|
||||
port.recv();
|
||||
for frame_tree.iter().advance |frame| {
|
||||
for frame in frame_tree.iter() {
|
||||
frame.pipeline.grant_paint_permission();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ impl MatchMethods for AbstractNode<LayoutView> {
|
|||
};
|
||||
}
|
||||
|
||||
for self.each_child |kid| {
|
||||
for kid in self.children() {
|
||||
kid.restyle_subtree(select_ctx);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ impl SelectHandler<AbstractNode<LayoutView>> for NodeSelectHandler {
|
|||
None => false,
|
||||
Some(existing_classes) => {
|
||||
let mut ret = false;
|
||||
for existing_classes.split_iter(' ').advance |s| {
|
||||
for s in existing_classes.split_iter(' ') {
|
||||
if s == class {
|
||||
ret = true;
|
||||
break;
|
||||
|
|
|
@ -84,7 +84,7 @@ impl LayoutAuxMethods for AbstractNode<LayoutView> {
|
|||
/// Initializes layout data and styles for a Node tree, if any nodes do not have
|
||||
/// this data already. Append created layout data to the task's GC roots.
|
||||
fn initialize_style_for_subtree(self, refs: &mut ~[@mut LayoutData]) {
|
||||
let _ = for self.traverse_preorder |n| {
|
||||
let _ = for n in self.traverse_preorder() {
|
||||
match n.initialize_layout_data() {
|
||||
Some(r) => refs.push(r),
|
||||
None => {}
|
||||
|
|
|
@ -50,7 +50,7 @@ impl BlockFlowData {
|
|||
|
||||
pub fn teardown(&mut self) {
|
||||
self.common.teardown();
|
||||
for self.box.iter().advance |box| {
|
||||
for box in self.box.iter() {
|
||||
box.teardown();
|
||||
}
|
||||
self.box = None;
|
||||
|
@ -94,7 +94,7 @@ impl BlockFlowData {
|
|||
let mut num_floats = 0;
|
||||
|
||||
/* find max width from child block contexts */
|
||||
for BlockFlow(self).each_child |child_ctx| {
|
||||
for child_ctx in BlockFlow(self).children() {
|
||||
assert!(child_ctx.starts_block_flow() || child_ctx.starts_inline_flow());
|
||||
|
||||
do child_ctx.with_mut_base |child_node| {
|
||||
|
@ -192,7 +192,7 @@ impl BlockFlowData {
|
|||
let mut remaining_width = self.common.position.size.width;
|
||||
let mut x_offset = Au(0);
|
||||
|
||||
for self.box.iter().advance |&box| {
|
||||
for &box in self.box.iter() {
|
||||
let style = box.style();
|
||||
do box.with_model |model| {
|
||||
// Can compute padding here since we know containing block width.
|
||||
|
@ -239,7 +239,7 @@ impl BlockFlowData {
|
|||
}
|
||||
|
||||
let has_inorder_children = self.common.is_inorder || self.common.num_floats > 0;
|
||||
for BlockFlow(self).each_child |kid| {
|
||||
for kid in BlockFlow(self).children() {
|
||||
assert!(kid.starts_block_flow() || kid.starts_inline_flow());
|
||||
|
||||
do kid.with_mut_base |child_node| {
|
||||
|
@ -278,7 +278,7 @@ impl BlockFlowData {
|
|||
let mut left_offset = Au(0);
|
||||
let mut float_ctx = Invalid;
|
||||
|
||||
for self.box.iter().advance |&box| {
|
||||
for &box in self.box.iter() {
|
||||
clearance = match box.clear() {
|
||||
None => Au(0),
|
||||
Some(clear) => {
|
||||
|
@ -303,7 +303,7 @@ impl BlockFlowData {
|
|||
// repeat until all children are visited.
|
||||
// last_child.floats_out -> self.floats_out (done at the end of this method)
|
||||
float_ctx = self.common.floats_in.translate(Point2D(-left_offset, -top_offset));
|
||||
for BlockFlow(self).each_child |kid| {
|
||||
for kid in BlockFlow(self).children() {
|
||||
do kid.with_mut_base |child_node| {
|
||||
child_node.floats_in = float_ctx.clone();
|
||||
}
|
||||
|
@ -311,10 +311,9 @@ impl BlockFlowData {
|
|||
do kid.with_mut_base |child_node| {
|
||||
float_ctx = child_node.floats_out.clone();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
for BlockFlow(self).each_child |kid| {
|
||||
for kid in BlockFlow(self).children() {
|
||||
do kid.with_mut_base |child_node| {
|
||||
child_node.position.origin.y = cur_y;
|
||||
cur_y = cur_y + child_node.position.size.height;
|
||||
|
@ -327,7 +326,7 @@ impl BlockFlowData {
|
|||
cur_y - top_offset
|
||||
};
|
||||
|
||||
for self.box.iter().advance |&box| {
|
||||
for &box in self.box.iter() {
|
||||
let style = box.style();
|
||||
let maybe_height = MaybeAuto::from_height(style.height(), Au(0), style.font_size());
|
||||
let maybe_height = maybe_height.specified_or_zero();
|
||||
|
@ -380,7 +379,7 @@ impl BlockFlowData {
|
|||
|
||||
// go deeper into the flow tree
|
||||
let flow = BlockFlow(self);
|
||||
for flow.each_child |child| {
|
||||
for child in flow.children() {
|
||||
do child.with_mut_base |base| {
|
||||
base.abs_position = self.common.abs_position + base.position.origin;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ use std::cell::Cell;
|
|||
use std::cmp::ApproxEq;
|
||||
use std::managed;
|
||||
use std::num::Zero;
|
||||
use std::uint;
|
||||
use geom::{Point2D, Rect, Size2D, SideOffsets2D};
|
||||
use gfx::display_list::{BaseDisplayItem, BorderDisplayItem, BorderDisplayItemClass};
|
||||
use gfx::display_list::{DisplayList, ImageDisplayItem, ImageDisplayItemClass};
|
||||
|
@ -292,14 +291,13 @@ impl RenderBox {
|
|||
text_box.range,
|
||||
max_width);
|
||||
|
||||
for text_box.run.iter_slices_for_range(&text_box.range)
|
||||
|glyphs, offset, slice_range| {
|
||||
for (glyphs, offset, slice_range) in text_box.run.iter_slices_for_range(&text_box.range) {
|
||||
debug!("split_to_width: considering slice (offset=%?, range=%?, remain_width=%?)",
|
||||
offset,
|
||||
slice_range,
|
||||
remaining_width);
|
||||
|
||||
let metrics = text_box.run.metrics_for_slice(glyphs, slice_range);
|
||||
let metrics = text_box.run.metrics_for_slice(glyphs, &slice_range);
|
||||
let advance = metrics.advance_width;
|
||||
let should_continue: bool;
|
||||
|
||||
|
@ -465,9 +463,8 @@ impl RenderBox {
|
|||
// report nothing and the parent flow can factor in minimum/preferred widths of any
|
||||
// text runs that it owns.
|
||||
let mut max_line_width = Au(0);
|
||||
for text_box.run.iter_natural_lines_for_range(&text_box.range)
|
||||
|line_range| {
|
||||
let line_metrics = text_box.run.metrics_for_range(line_range);
|
||||
for line_range in text_box.run.iter_natural_lines_for_range(&text_box.range) {
|
||||
let line_metrics = text_box.run.metrics_for_range(&line_range);
|
||||
max_line_width = Au::max(max_line_width, line_metrics.advance_width);
|
||||
}
|
||||
|
||||
|
@ -875,7 +872,7 @@ impl RenderBox {
|
|||
/// Dumps a render box for debugging, with indentation.
|
||||
pub fn dump_indent(&self, indent: uint) {
|
||||
let mut string = ~"";
|
||||
for uint::range(0u, indent) |_i| {
|
||||
for _ in range(0u, indent) {
|
||||
string.push_str(" ");
|
||||
}
|
||||
|
||||
|
|
|
@ -145,8 +145,7 @@ impl BoxGenerator {
|
|||
} else if self.inline_spacers_needed_for_node(node) {
|
||||
// else, maybe make a spacer for "left" margin, border, padding
|
||||
let inline_spacer = self.make_inline_spacer_for_node_side(ctx, node, LogicalBefore);
|
||||
for inline_spacer.iter().advance
|
||||
|spacer: &RenderBox| {
|
||||
for spacer in inline_spacer.iter() {
|
||||
inline.boxes.push(*spacer);
|
||||
}
|
||||
}
|
||||
|
@ -220,7 +219,7 @@ impl BoxGenerator {
|
|||
// If this non-leaf box generates extra horizontal spacing, add a SpacerBox for
|
||||
// it.
|
||||
let result = self.make_inline_spacer_for_node_side(ctx, node, LogicalAfter);
|
||||
for result.iter().advance |spacer| {
|
||||
for spacer in result.iter() {
|
||||
let boxes = &mut self.flow.inline().boxes;
|
||||
boxes.push(*spacer);
|
||||
}
|
||||
|
@ -328,7 +327,7 @@ impl LayoutTreeBuilder {
|
|||
|
||||
// recurse on child nodes.
|
||||
let mut prev_generator: Option<@mut BoxGenerator> = None;
|
||||
for cur_node.each_child |child_node| {
|
||||
for child_node in cur_node.children() {
|
||||
prev_generator = self.construct_recursively(layout_ctx, child_node, this_generator, prev_generator);
|
||||
}
|
||||
|
||||
|
@ -340,7 +339,7 @@ impl LayoutTreeBuilder {
|
|||
// eventually be elided or split, but the mapping between
|
||||
// nodes and FlowContexts should not change during layout.
|
||||
let flow: &FlowContext = &this_generator.flow;
|
||||
for flow.each_child |child_flow| {
|
||||
for child_flow in flow.children() {
|
||||
do child_flow.with_base |child_node| {
|
||||
let dom_node = child_node.node;
|
||||
assert!(dom_node.has_layout_data());
|
||||
|
@ -515,7 +514,7 @@ impl LayoutTreeBuilder {
|
|||
let mut found_child_block = false;
|
||||
|
||||
let flow = *parent_flow;
|
||||
for flow.each_child |child_ctx: FlowContext| {
|
||||
for child_ctx in flow.children() {
|
||||
match child_ctx {
|
||||
InlineFlow(*) | InlineBlockFlow(*) => found_child_inline = true,
|
||||
BlockFlow(*) => found_child_block = true,
|
||||
|
@ -535,7 +534,7 @@ impl LayoutTreeBuilder {
|
|||
let first_child = do parent_flow.with_base |parent_node| {
|
||||
parent_node.first_child
|
||||
};
|
||||
for first_child.iter().advance |&first_flow| {
|
||||
for &first_flow in first_child.iter() {
|
||||
if first_flow.starts_inline_flow() {
|
||||
// FIXME: workaround for rust#6393
|
||||
let mut do_remove = false;
|
||||
|
@ -558,7 +557,7 @@ impl LayoutTreeBuilder {
|
|||
let last_child = do parent_flow.with_base |parent_node| {
|
||||
parent_node.last_child
|
||||
};
|
||||
for last_child.iter().advance |&last_flow| {
|
||||
for &last_flow in last_child.iter() {
|
||||
if last_flow.starts_inline_flow() {
|
||||
// FIXME: workaround for rust#6393
|
||||
let mut do_remove = false;
|
||||
|
@ -580,7 +579,7 @@ impl LayoutTreeBuilder {
|
|||
|
||||
// Issue 543: We only need to do this if there are inline child
|
||||
// flows, but there's not a quick way to check at the moment.
|
||||
for (*parent_flow).each_child |child_flow: FlowContext| {
|
||||
for child_flow in (*parent_flow).children() {
|
||||
match child_flow {
|
||||
InlineFlow(*) | InlineBlockFlow(*) => {
|
||||
let mut scanner = TextRunScanner::new();
|
||||
|
|
|
@ -55,7 +55,7 @@ impl FloatFlowData {
|
|||
|
||||
pub fn teardown(&mut self) {
|
||||
self.common.teardown();
|
||||
for self.box.iter().advance |box| {
|
||||
for box in self.box.iter() {
|
||||
box.teardown();
|
||||
}
|
||||
self.box = None;
|
||||
|
@ -69,7 +69,7 @@ impl FloatFlowData {
|
|||
let mut pref_width = Au(0);
|
||||
let mut num_floats = 0;
|
||||
|
||||
for FloatFlow(self).each_child |child_ctx| {
|
||||
for child_ctx in FloatFlow(self).children() {
|
||||
//assert!(child_ctx.starts_block_flow() || child_ctx.starts_inline_flow());
|
||||
|
||||
do child_ctx.with_mut_base |child_node| {
|
||||
|
@ -108,7 +108,7 @@ impl FloatFlowData {
|
|||
// Parent usually sets this, but floats are never inorder
|
||||
self.common.is_inorder = false;
|
||||
|
||||
for self.box.iter().advance |&box| {
|
||||
for &box in self.box.iter() {
|
||||
let style = box.style();
|
||||
do box.with_model |model| {
|
||||
// Can compute padding here since we know containing block width.
|
||||
|
@ -162,7 +162,7 @@ impl FloatFlowData {
|
|||
self.common.position.size.width = remaining_width;
|
||||
|
||||
let has_inorder_children = self.common.num_floats > 0;
|
||||
for FloatFlow(self).each_child |kid| {
|
||||
for kid in FloatFlow(self).children() {
|
||||
//assert!(kid.starts_block_flow() || kid.starts_inline_flow());
|
||||
|
||||
do kid.with_mut_base |child_node| {
|
||||
|
@ -199,7 +199,6 @@ impl FloatFlowData {
|
|||
};
|
||||
|
||||
do box.with_base |base| {
|
||||
|
||||
let noncontent_width = base.model.padding.left + base.model.padding.right +
|
||||
base.model.border.left + base.model.border.right;
|
||||
let noncontent_height = base.model.padding.top + base.model.padding.bottom +
|
||||
|
@ -207,7 +206,6 @@ impl FloatFlowData {
|
|||
|
||||
full_noncontent_width = noncontent_width + base.model.margin.left + base.model.margin.right;
|
||||
full_noncontent_height = noncontent_height + base.model.margin.top + base.model.margin.bottom;
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -231,7 +229,7 @@ impl FloatFlowData {
|
|||
let has_inorder_children = self.common.num_floats > 0;
|
||||
if has_inorder_children {
|
||||
let mut float_ctx = FloatContext::new(self.floated_children);
|
||||
for FloatFlow(self).each_child |kid| {
|
||||
for kid in FloatFlow(self).children() {
|
||||
do kid.with_mut_base |child_node| {
|
||||
child_node.floats_in = float_ctx.clone();
|
||||
}
|
||||
|
@ -245,14 +243,14 @@ impl FloatFlowData {
|
|||
let mut cur_y = Au(0);
|
||||
let mut top_offset = Au(0);
|
||||
|
||||
for self.box.iter().advance |&box| {
|
||||
for &box in self.box.iter() {
|
||||
do box.with_model |model| {
|
||||
top_offset = model.margin.top + model.border.top + model.padding.top;
|
||||
cur_y = cur_y + top_offset;
|
||||
}
|
||||
}
|
||||
|
||||
for FloatFlow(self).each_child |kid| {
|
||||
for kid in FloatFlow(self).children() {
|
||||
do kid.with_mut_base |child_node| {
|
||||
child_node.position.origin.y = cur_y;
|
||||
cur_y = cur_y + child_node.position.size.height;
|
||||
|
@ -279,7 +277,7 @@ impl FloatFlowData {
|
|||
|
||||
|
||||
//TODO(eatkinson): compute heights properly using the 'height' property.
|
||||
for self.box.iter().advance |&box| {
|
||||
for &box in self.box.iter() {
|
||||
let height_prop =
|
||||
MaybeAuto::from_height(box.style().height(),
|
||||
Au(0),
|
||||
|
@ -316,7 +314,7 @@ impl FloatFlowData {
|
|||
|
||||
// go deeper into the flow tree
|
||||
let flow = FloatFlow(self);
|
||||
for flow.each_child |child| {
|
||||
for child in flow.children() {
|
||||
do child.with_mut_base |base| {
|
||||
base.abs_position = offset + base.position.origin;
|
||||
}
|
||||
|
|
|
@ -176,7 +176,7 @@ impl FloatContextBase{
|
|||
let mut r_bottom = None;
|
||||
|
||||
// Find the float collisions for the given vertical range.
|
||||
for self.float_data.iter().advance |float| {
|
||||
for float in self.float_data.iter() {
|
||||
debug!("available_rect: Checking for collision against float");
|
||||
match *float{
|
||||
None => (),
|
||||
|
@ -270,7 +270,7 @@ impl FloatContextBase{
|
|||
|
||||
/// Returns true if the given rect overlaps with any floats.
|
||||
fn collides_with_float(&self, bounds: &Rect<Au>) -> bool {
|
||||
for self.float_data.iter().advance |float| {
|
||||
for float in self.float_data.iter() {
|
||||
match *float{
|
||||
None => (),
|
||||
Some(data) => {
|
||||
|
@ -292,7 +292,7 @@ impl FloatContextBase{
|
|||
let left = left - self.offset.x;
|
||||
let mut max_height = None;
|
||||
|
||||
for self.float_data.iter().advance |float| {
|
||||
for float in self.float_data.iter() {
|
||||
match *float {
|
||||
None => (),
|
||||
Some(f_data) => {
|
||||
|
@ -361,7 +361,7 @@ impl FloatContextBase{
|
|||
|
||||
fn clearance(&self, clear: ClearType) -> Au {
|
||||
let mut clearance = Au(0);
|
||||
for self.float_data.iter().advance |float| {
|
||||
for float in self.float_data.iter() {
|
||||
match *float {
|
||||
None => (),
|
||||
Some(f_data) => {
|
||||
|
|
|
@ -36,7 +36,6 @@ use layout::incremental::RestyleDamage;
|
|||
use css::node_style::StyledNode;
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::uint;
|
||||
use std::io::stderr;
|
||||
use geom::point::Point2D;
|
||||
use geom::rect::Rect;
|
||||
|
@ -89,24 +88,20 @@ impl FlowContext {
|
|||
return;
|
||||
}
|
||||
|
||||
for self.each_child |kid| {
|
||||
for kid in self.children() {
|
||||
// FIXME: Work around rust#2202. We should be able to pass the callback directly.
|
||||
kid.partially_traverse_preorder(|a| callback(a));
|
||||
}
|
||||
}
|
||||
|
||||
fn traverse_bu_sub_inorder (&self, callback: &fn(FlowContext) -> bool) -> bool {
|
||||
for self.each_child |kid| {
|
||||
fn traverse_bu_sub_inorder (&self, callback: &fn(FlowContext)) {
|
||||
for kid in self.children() {
|
||||
// FIXME: Work around rust#2202. We should be able to pass the callback directly.
|
||||
if !kid.traverse_bu_sub_inorder(|a| callback(a)) {
|
||||
return false;
|
||||
}
|
||||
kid.traverse_bu_sub_inorder(|a| callback(a));
|
||||
}
|
||||
|
||||
if !self.is_inorder() {
|
||||
callback((*self).clone())
|
||||
} else {
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -119,14 +114,14 @@ impl FlowData {
|
|||
// or we risk dynamic borrow failures.
|
||||
self.parent = None;
|
||||
|
||||
for self.first_child.iter().advance |flow| {
|
||||
for flow in self.first_child.iter() {
|
||||
flow.teardown();
|
||||
}
|
||||
self.first_child = None;
|
||||
|
||||
self.last_child = None;
|
||||
|
||||
for self.next_sibling.iter().advance |flow| {
|
||||
for flow in self.next_sibling.iter() {
|
||||
flow.teardown();
|
||||
}
|
||||
self.next_sibling = None;
|
||||
|
@ -444,7 +439,7 @@ impl<'self> FlowContext {
|
|||
/// Dumps the flow tree, for debugging, with indentation.
|
||||
pub fn dump_indent(&self, indent: uint) {
|
||||
let mut s = ~"|";
|
||||
for uint::range(0, indent) |_i| {
|
||||
for _ in range(0, indent) {
|
||||
s.push_str("---- ");
|
||||
}
|
||||
|
||||
|
@ -452,7 +447,7 @@ impl<'self> FlowContext {
|
|||
stderr().write_line(s);
|
||||
|
||||
// FIXME: this should have a pure/const version?
|
||||
for self.each_child |child| {
|
||||
for child in self.children() {
|
||||
child.dump_indent(indent + 1)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -492,7 +492,7 @@ impl InlineFlowData {
|
|||
|
||||
pub fn teardown(&mut self) {
|
||||
self.common.teardown();
|
||||
for self.boxes.iter().advance |box| {
|
||||
for box in self.boxes.iter() {
|
||||
box.teardown();
|
||||
}
|
||||
self.boxes = ~[];
|
||||
|
@ -516,7 +516,7 @@ impl InlineFlowData {
|
|||
pub fn bubble_widths_inline(@mut self, ctx: &mut LayoutContext) {
|
||||
let mut num_floats = 0;
|
||||
|
||||
for InlineFlow(self).each_child |kid| {
|
||||
for kid in InlineFlow(self).children() {
|
||||
do kid.with_mut_base |base| {
|
||||
num_floats += base.num_floats;
|
||||
base.floats_in = FloatContext::new(base.num_floats);
|
||||
|
@ -529,7 +529,7 @@ impl InlineFlowData {
|
|||
let mut min_width = Au(0);
|
||||
let mut pref_width = Au(0);
|
||||
|
||||
for this.boxes.iter().advance |box| {
|
||||
for box in this.boxes.iter() {
|
||||
debug!("FlowContext[%d]: measuring %s", self.common.id, box.debug_str());
|
||||
min_width = Au::max(min_width, box.get_min_width(ctx));
|
||||
pref_width = Au::max(pref_width, box.get_pref_width(ctx));
|
||||
|
@ -550,7 +550,7 @@ impl InlineFlowData {
|
|||
// `RenderBox`.
|
||||
{
|
||||
let this = &mut *self;
|
||||
for this.boxes.iter().advance |&box| {
|
||||
for &box in this.boxes.iter() {
|
||||
match box {
|
||||
ImageRenderBoxClass(image_box) => {
|
||||
let size = image_box.image.get_size();
|
||||
|
@ -572,7 +572,7 @@ impl InlineFlowData {
|
|||
} // End of for loop.
|
||||
}
|
||||
|
||||
for InlineFlow(self).each_child |kid| {
|
||||
for kid in InlineFlow(self).children() {
|
||||
do kid.with_mut_base |base| {
|
||||
base.position.size.width = self.common.position.size.width;
|
||||
base.is_inorder = self.common.is_inorder;
|
||||
|
@ -588,7 +588,7 @@ impl InlineFlowData {
|
|||
}
|
||||
|
||||
pub fn assign_height_inorder_inline(@mut self, ctx: &mut LayoutContext) {
|
||||
for InlineFlow(self).each_child |kid| {
|
||||
for kid in InlineFlow(self).children() {
|
||||
kid.assign_height_inorder(ctx);
|
||||
}
|
||||
self.assign_height_inline(ctx);
|
||||
|
@ -608,7 +608,7 @@ impl InlineFlowData {
|
|||
scanner.scan_for_lines();
|
||||
|
||||
// Now, go through each line and lay out the boxes inside
|
||||
for self.lines.iter().advance |line| {
|
||||
for line in self.lines.iter() {
|
||||
// We need to distribute extra width based on text-align.
|
||||
let mut slack_width = line.green_zone.width - line.bounds.size.width;
|
||||
if slack_width < Au(0) {
|
||||
|
@ -634,7 +634,7 @@ impl InlineFlowData {
|
|||
// So sorry, but justified text is more complicated than shuffling linebox coordinates.
|
||||
// TODO(Issue #213): implement `text-align: justify`
|
||||
CSSTextAlignLeft | CSSTextAlignJustify => {
|
||||
for line.range.eachi |i| {
|
||||
for i in line.range.eachi() {
|
||||
do self.boxes[i].with_mut_base |base| {
|
||||
base.position.origin.x = offset_x;
|
||||
offset_x = offset_x + base.position.size.width;
|
||||
|
@ -643,7 +643,7 @@ impl InlineFlowData {
|
|||
}
|
||||
CSSTextAlignCenter => {
|
||||
offset_x = offset_x + slack_width.scale_by(0.5f);
|
||||
for line.range.eachi |i| {
|
||||
for i in line.range.eachi() {
|
||||
do self.boxes[i].with_mut_base |base| {
|
||||
base.position.origin.x = offset_x;
|
||||
offset_x = offset_x + base.position.size.width;
|
||||
|
@ -652,7 +652,7 @@ impl InlineFlowData {
|
|||
}
|
||||
CSSTextAlignRight => {
|
||||
offset_x = offset_x + slack_width;
|
||||
for line.range.eachi |i| {
|
||||
for i in line.range.eachi() {
|
||||
do self.boxes[i].with_mut_base |base| {
|
||||
base.position.origin.x = offset_x;
|
||||
offset_x = offset_x + base.position.size.width;
|
||||
|
@ -666,7 +666,7 @@ impl InlineFlowData {
|
|||
// the baseline.
|
||||
let mut baseline_offset = Au(0);
|
||||
let mut max_height = Au(0);
|
||||
for line.range.eachi |box_i| {
|
||||
for box_i in line.range.eachi() {
|
||||
let cur_box = self.boxes[box_i];
|
||||
|
||||
match cur_box {
|
||||
|
@ -719,7 +719,7 @@ impl InlineFlowData {
|
|||
}
|
||||
|
||||
// Now go back and adjust the Y coordinates to match the baseline we determined.
|
||||
for line.range.eachi |box_i| {
|
||||
for box_i in line.range.eachi() {
|
||||
let cur_box = self.boxes[box_i];
|
||||
|
||||
// TODO(#226): This is completely wrong. We need to use the element's `line-height`
|
||||
|
@ -766,7 +766,7 @@ impl InlineFlowData {
|
|||
self.common.id,
|
||||
self.boxes.len());
|
||||
|
||||
for self.boxes.iter().advance |box| {
|
||||
for box in self.boxes.iter() {
|
||||
box.build_display_list(builder, dirty, &self.common.abs_position, list)
|
||||
}
|
||||
|
||||
|
|
|
@ -232,7 +232,7 @@ impl LayoutTask {
|
|||
|
||||
// Propagate restyle damage up and down the tree, as appropriate.
|
||||
// FIXME: Merge this with flow tree building and/or the other traversals.
|
||||
for layout_root.traverse_preorder |flow| {
|
||||
for flow in layout_root.traverse_preorder() {
|
||||
// Also set any damage implied by resize.
|
||||
if resized {
|
||||
do flow.with_mut_base |base| {
|
||||
|
@ -242,7 +242,7 @@ impl LayoutTask {
|
|||
|
||||
let prop = flow.with_base(|base| base.restyle_damage.propagate_down());
|
||||
if prop.is_nonempty() {
|
||||
for flow.each_child |kid_ctx| {
|
||||
for kid_ctx in flow.children() {
|
||||
do kid_ctx.with_mut_base |kid| {
|
||||
kid.restyle_damage.union_in_place(prop);
|
||||
}
|
||||
|
@ -250,8 +250,8 @@ impl LayoutTask {
|
|||
}
|
||||
}
|
||||
|
||||
for layout_root.traverse_postorder |flow| {
|
||||
for flow.each_child |child| {
|
||||
for flow in layout_root.traverse_postorder() {
|
||||
for child in flow.children() {
|
||||
do child.with_base |child_base| {
|
||||
do flow.with_mut_base |base| {
|
||||
base.restyle_damage.union_in_place(child_base.restyle_damage);
|
||||
|
@ -266,20 +266,20 @@ impl LayoutTask {
|
|||
// Perform the primary layout passes over the flow tree to compute the locations of all
|
||||
// the boxes.
|
||||
do profile(time::LayoutMainCategory, self.profiler_chan.clone()) {
|
||||
for layout_root.traverse_postorder_prune(|f| f.restyle_damage().lacks(BubbleWidths)) |flow| {
|
||||
for flow in layout_root.traverse_postorder_prune(|f| f.restyle_damage().lacks(BubbleWidths)) {
|
||||
flow.bubble_widths(&mut layout_ctx);
|
||||
};
|
||||
|
||||
// FIXME: We want to do
|
||||
// for layout_root.traverse_preorder_prune(|f| f.restyle_damage().lacks(Reflow)) |flow| {
|
||||
// for flow in layout_root.traverse_preorder_prune(|f| f.restyle_damage().lacks(Reflow)) {
|
||||
// but FloatContext values can't be reused, so we need to recompute them every time.
|
||||
for layout_root.traverse_preorder |flow| {
|
||||
for flow in layout_root.traverse_preorder() {
|
||||
flow.assign_widths(&mut layout_ctx);
|
||||
};
|
||||
|
||||
// For now, this is an inorder traversal
|
||||
// FIXME: prune this traversal as well
|
||||
for layout_root.traverse_bu_sub_inorder |flow| {
|
||||
do layout_root.traverse_bu_sub_inorder |flow| {
|
||||
flow.assign_height(&mut layout_ctx);
|
||||
}
|
||||
}
|
||||
|
@ -366,9 +366,11 @@ impl LayoutTask {
|
|||
None => Err(()),
|
||||
Some(flow) => {
|
||||
let mut boxes = ~[];
|
||||
for flow.iter_boxes_for_node(node) |box| {
|
||||
for box in flow.iter_all_boxes() {
|
||||
if box.node() == node {
|
||||
boxes.push(box.content_box());
|
||||
}
|
||||
}
|
||||
|
||||
Ok(ContentBoxesResponse(boxes))
|
||||
}
|
||||
|
@ -382,7 +384,7 @@ impl LayoutTask {
|
|||
transmute(node)
|
||||
};
|
||||
let mut flow_node: AbstractNode<LayoutView> = node;
|
||||
for node.traverse_preorder |node| {
|
||||
for node in node.traverse_preorder() {
|
||||
if node.layout_data().flow.is_some() {
|
||||
flow_node = node;
|
||||
break;
|
||||
|
@ -413,7 +415,7 @@ impl LayoutTask {
|
|||
let mut resp = Err(());
|
||||
let display_list = &display_list.take().list;
|
||||
// iterate in reverse to ensure we have the most recently painted render box
|
||||
for display_list.rev_iter().advance |display_item| {
|
||||
for display_item in display_list.rev_iter() {
|
||||
let bounds = display_item.bounds();
|
||||
// TODO this check should really be performed by a method of DisplayItem
|
||||
if x <= bounds.origin.x + bounds.size.width &&
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
//! Text layout.
|
||||
|
||||
use std::uint;
|
||||
use std::vec;
|
||||
|
||||
use gfx::text::text_run::TextRun;
|
||||
|
@ -13,7 +12,6 @@ use layout::box::{RenderBox, RenderBoxBase, TextRenderBox};
|
|||
use layout::box::{TextRenderBoxClass, UnscannedTextRenderBoxClass};
|
||||
use layout::context::LayoutContext;
|
||||
use layout::flow::FlowContext;
|
||||
use layout::util::{NodeRange};
|
||||
use newcss::values::{CSSTextDecoration, CSSTextDecorationUnderline};
|
||||
use servo_util::range::Range;
|
||||
|
||||
|
@ -75,7 +73,7 @@ impl TextRunScanner {
|
|||
|
||||
let mut last_whitespace = true;
|
||||
let mut out_boxes = ~[];
|
||||
for uint::range(0, flow.inline().boxes.len()) |box_i| {
|
||||
for box_i in range(0, flow.inline().boxes.len()) {
|
||||
debug!("TextRunScanner: considering box: %?", flow.inline().boxes[box_i].debug_str());
|
||||
if box_i > 0 && !can_coalesce_text_nodes(flow.inline().boxes, box_i-1, box_i) {
|
||||
last_whitespace = self.flush_clump_to_list(ctx, flow, last_whitespace, &mut out_boxes);
|
||||
|
@ -204,7 +202,7 @@ impl TextRunScanner {
|
|||
let mut run_str: ~str = ~"";
|
||||
let mut new_ranges: ~[Range] = ~[];
|
||||
let mut char_total = 0;
|
||||
for uint::range(0, transformed_strs.len()) |i| {
|
||||
for i in range(0, transformed_strs.len()) {
|
||||
let added_chars = transformed_strs[i].char_len();
|
||||
new_ranges.push(Range::new(char_total, added_chars));
|
||||
run_str.push_str(transformed_strs[i]);
|
||||
|
@ -231,7 +229,7 @@ impl TextRunScanner {
|
|||
|
||||
// Make new boxes with the run and adjusted text indices.
|
||||
debug!("TextRunScanner: pushing box(es) in range: %?", self.clump);
|
||||
for clump.eachi |i| {
|
||||
for i in clump.eachi() {
|
||||
let range = new_ranges[i - self.clump.begin()];
|
||||
if range.length() == 0 {
|
||||
debug!("Elided an `UnscannedTextbox` because it was zero-length after \
|
||||
|
@ -249,19 +247,19 @@ impl TextRunScanner {
|
|||
} // End of match.
|
||||
|
||||
debug!("--- In boxes: ---");
|
||||
for in_boxes.iter().enumerate().advance |(i, box)| {
|
||||
for (i, box) in in_boxes.iter().enumerate() {
|
||||
debug!("%u --> %s", i, box.debug_str());
|
||||
}
|
||||
debug!("------------------");
|
||||
|
||||
debug!("--- Out boxes: ---");
|
||||
for out_boxes.iter().enumerate().advance |(i, box)| {
|
||||
for (i, box) in out_boxes.iter().enumerate() {
|
||||
debug!("%u --> %s", i, box.debug_str());
|
||||
}
|
||||
debug!("------------------");
|
||||
|
||||
debug!("--- Elem ranges: ---");
|
||||
for inline.elems.eachi_mut |i: uint, nr: &NodeRange| {
|
||||
for (i, nr) in inline.elems.eachi() {
|
||||
debug!("%u: %? --> %s", i, nr.range, nr.node.debug_str()); ()
|
||||
}
|
||||
debug!("--------------------");
|
||||
|
|
|
@ -34,7 +34,7 @@ impl ElementMapping {
|
|||
}
|
||||
|
||||
pub fn each(&self, callback: &fn(nr: &NodeRange) -> bool) -> bool {
|
||||
for self.entries.iter().advance |nr| {
|
||||
for nr in self.entries.iter() {
|
||||
if !callback(nr) {
|
||||
break
|
||||
}
|
||||
|
@ -50,19 +50,19 @@ impl ElementMapping {
|
|||
let entries = &mut self.entries;
|
||||
|
||||
debug!("--- Old boxes: ---");
|
||||
for old_boxes.iter().enumerate().advance |(i, box)| {
|
||||
for (i, box) in old_boxes.iter().enumerate() {
|
||||
debug!("%u --> %s", i, box.debug_str());
|
||||
}
|
||||
debug!("------------------");
|
||||
|
||||
debug!("--- New boxes: ---");
|
||||
for new_boxes.iter().enumerate().advance |(i, box)| {
|
||||
for (i, box) in new_boxes.iter().enumerate() {
|
||||
debug!("%u --> %s", i, box.debug_str());
|
||||
}
|
||||
debug!("------------------");
|
||||
|
||||
debug!("--- Elem ranges before repair: ---");
|
||||
for entries.iter().enumerate().advance |(i, nr)| {
|
||||
for (i, nr) in entries.iter().enumerate() {
|
||||
debug!("%u: %? --> %s", i, nr.range, nr.node.debug_str());
|
||||
}
|
||||
debug!("----------------------------------");
|
||||
|
@ -115,7 +115,7 @@ impl ElementMapping {
|
|||
}
|
||||
}
|
||||
debug!("--- Elem ranges after repair: ---");
|
||||
for entries.iter().enumerate().advance |(i, nr)| {
|
||||
for (i, nr) in entries.iter().enumerate() {
|
||||
debug!("%u: %? --> %s", i, nr.range, nr.node.debug_str());
|
||||
}
|
||||
debug!("----------------------------------");
|
||||
|
|
|
@ -133,7 +133,7 @@ fn run(opts: &Opts) {
|
|||
profiler_chan.clone());
|
||||
|
||||
// Send the URL command to the constellation.
|
||||
for opts.urls.iter().advance |filename| {
|
||||
for filename in opts.urls.iter() {
|
||||
constellation_chan.send(InitLoadUrlMsg(make_url(filename.clone(), None)))
|
||||
}
|
||||
|
||||
|
|
|
@ -180,7 +180,7 @@ impl ImageCache {
|
|||
loop {
|
||||
let msg = self.port.recv();
|
||||
|
||||
for msg_handlers.iter().advance |handler| {
|
||||
for handler in msg_handlers.iter() {
|
||||
(*handler)(&msg)
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,7 @@ impl ImageCache {
|
|||
// Wait until we have no outstanding requests and subtasks
|
||||
// before exiting
|
||||
let mut can_exit = true;
|
||||
for self.state_map.each_value |state| {
|
||||
for (_, state) in self.state_map.iter() {
|
||||
match *state {
|
||||
Prefetching(*) => can_exit = false,
|
||||
Decoding => can_exit = false,
|
||||
|
@ -376,7 +376,7 @@ impl ImageCache {
|
|||
priv fn purge_waiters(&self, url: Url, f: &fn() -> ImageResponseMsg) {
|
||||
match self.wait_map.pop(&url) {
|
||||
Some(waiters) => {
|
||||
for waiters.iter().advance |response| {
|
||||
for response in waiters.iter() {
|
||||
response.send(f());
|
||||
}
|
||||
}
|
||||
|
@ -661,7 +661,7 @@ fn should_return_decoded_image_data_for_multiple_requests() {
|
|||
// Wait until our mock resource task has sent the image to the image cache
|
||||
wait_for_image.recv();
|
||||
|
||||
for iter::repeat(2) {
|
||||
for _ in iter::repeat(2) {
|
||||
let (response_chan, response_port) = stream();
|
||||
image_cache_task.send(GetImage(url.clone(), response_chan));
|
||||
match response_port.recv() {
|
||||
|
|
|
@ -105,7 +105,7 @@ impl ResourceManager {
|
|||
}
|
||||
|
||||
fn get_loader_factory(&self, url: &Url) -> Option<LoaderTask> {
|
||||
for self.loaders.iter().advance |scheme_loader| {
|
||||
for scheme_loader in self.loaders.iter() {
|
||||
match *scheme_loader {
|
||||
(ref scheme, ref loader_factory) => {
|
||||
if (*scheme) == url.scheme {
|
||||
|
|
|
@ -76,10 +76,10 @@ pub fn _obj_toString(cx: *JSContext, className: *libc::c_char) -> *JSString {
|
|||
}
|
||||
|
||||
let result = ~"[object " + name + "]";
|
||||
for result.iter().enumerate().advance |(i, c)| {
|
||||
*chars.offset(i) = c as jschar;
|
||||
for (i, c) in result.iter().enumerate() {
|
||||
*chars.offset(i as int) = c as jschar;
|
||||
}
|
||||
*chars.offset(nchars) = 0;
|
||||
*chars.offset(nchars as int) = 0;
|
||||
let jsstr = JS_NewUCString(cx, cast::transmute(chars), nchars as u64);
|
||||
if jsstr.is_null() {
|
||||
JS_free(cx, cast::transmute(chars));
|
||||
|
|
|
@ -14,7 +14,6 @@ use std::libc;
|
|||
use std::ptr;
|
||||
use std::ptr::{null, to_unsafe_ptr};
|
||||
use std::str;
|
||||
use std::uint;
|
||||
use std::unstable::intrinsics;
|
||||
use js::glue::*;
|
||||
use js::glue::{DefineFunctionWithReserved, GetObjectJSClass, RUST_OBJECT_TO_JSVAL};
|
||||
|
@ -766,7 +765,7 @@ pub fn XrayResolveProperty(cx: *JSContext,
|
|||
unsafe {
|
||||
match attributes {
|
||||
Some(attrs) => {
|
||||
for attrs.iter().advance |&elem| {
|
||||
for &elem in attrs.iter() {
|
||||
let (attr, attr_id) = elem;
|
||||
if attr_id == JSID_VOID || attr_id != id {
|
||||
loop;
|
||||
|
@ -816,20 +815,18 @@ fn InternJSString(cx: *JSContext, chars: *libc::c_char) -> Option<jsid> {
|
|||
}
|
||||
|
||||
pub fn InitIds(cx: *JSContext, specs: &[JSPropertySpec], ids: &mut [jsid]) -> bool {
|
||||
let mut rval = true;
|
||||
for specs.iter().enumerate().advance |(i, spec)| {
|
||||
for (i, spec) in specs.iter().enumerate() {
|
||||
if spec.name.is_null() == true {
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
match InternJSString(cx, spec.name) {
|
||||
Some(id) => ids[i] = id,
|
||||
None => {
|
||||
rval = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
rval
|
||||
true
|
||||
}
|
||||
|
||||
pub trait DerivedWrapper {
|
||||
|
@ -879,12 +876,12 @@ pub fn FindEnumStringIndex(cx: *JSContext,
|
|||
if chars.is_null() {
|
||||
return Err(());
|
||||
}
|
||||
for values.iter().enumerate().advance |(i, value)| {
|
||||
for (i, value) in values.iter().enumerate() {
|
||||
if value.length != length as uint {
|
||||
loop;
|
||||
}
|
||||
let mut equal = true;
|
||||
for uint::iterate(0, length as uint) |j| {
|
||||
for j in range(0, length as int) {
|
||||
if value.value[j] as u16 != *chars.offset(j) {
|
||||
equal = false;
|
||||
break;
|
||||
|
|
|
@ -270,11 +270,11 @@ impl Document {
|
|||
fail!("no SVG document yet")
|
||||
},
|
||||
_ => {
|
||||
let _ = for self.root.traverse_preorder |node| {
|
||||
let _ = for node in self.root.traverse_preorder() {
|
||||
if node.type_id() != ElementNodeTypeId(HTMLTitleElementTypeId) {
|
||||
loop;
|
||||
}
|
||||
for node.children().advance |child| {
|
||||
for child in node.children() {
|
||||
if child.is_text() {
|
||||
do child.with_imm_text() |text| {
|
||||
let s = text.parent.Data();
|
||||
|
@ -299,17 +299,17 @@ impl Document {
|
|||
},
|
||||
_ => {
|
||||
let (_scope, cx) = self.get_scope_and_cx();
|
||||
let _ = for self.root.traverse_preorder |node| {
|
||||
let _ = for node in self.root.traverse_preorder() {
|
||||
if node.type_id() != ElementNodeTypeId(HTMLHeadElementTypeId) {
|
||||
loop;
|
||||
}
|
||||
let mut has_title = false;
|
||||
for node.children().advance |child| {
|
||||
for child in node.children() {
|
||||
if child.type_id() != ElementNodeTypeId(HTMLTitleElementTypeId) {
|
||||
loop;
|
||||
}
|
||||
has_title = true;
|
||||
for child.children().advance |title_child| {
|
||||
for title_child in child.children() {
|
||||
child.remove_child(title_child);
|
||||
}
|
||||
let new_text = unsafe {
|
||||
|
@ -427,7 +427,7 @@ impl Document {
|
|||
|
||||
pub fn createHTMLCollection(&self, callback: &fn(elem: &Element) -> bool) -> @mut HTMLCollection {
|
||||
let mut elements = ~[];
|
||||
let _ = for self.root.traverse_preorder |child| {
|
||||
let _ = for child in self.root.traverse_preorder() {
|
||||
if child.is_element() {
|
||||
do child.with_imm_element |elem| {
|
||||
if callback(elem) {
|
||||
|
@ -441,7 +441,7 @@ impl Document {
|
|||
}
|
||||
|
||||
pub fn content_changed(&self) {
|
||||
for self.window.iter().advance |window| {
|
||||
for window in self.window.iter() {
|
||||
window.content_changed()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -252,7 +252,7 @@ impl<'self> Element {
|
|||
|
||||
pub fn get_attr(&'self self, name: &str) -> Option<&'self str> {
|
||||
// FIXME: Need an each() that links lifetimes in Rust.
|
||||
for self.attrs.iter().advance |attr| {
|
||||
for attr in self.attrs.iter() {
|
||||
if eq_slice(attr.name, name) {
|
||||
let val: &str = attr.value;
|
||||
return Some(val);
|
||||
|
@ -265,7 +265,7 @@ impl<'self> Element {
|
|||
let name = name.to_str();
|
||||
let value_cell = Cell::new(value.to_str());
|
||||
let mut found = false;
|
||||
for self.attrs.mut_iter().advance |attr| {
|
||||
for attr in self.attrs.mut_iter() {
|
||||
if eq_slice(attr.name, name) {
|
||||
attr.value = value_cell.take().clone();
|
||||
found = true;
|
||||
|
|
|
@ -69,7 +69,7 @@ impl HTMLDocument {
|
|||
|
||||
pub fn GetHead(&self) -> Option<AbstractNode<ScriptView>> {
|
||||
let mut headNode: Option<AbstractNode<ScriptView>> = None;
|
||||
let _ = for self.parent.root.traverse_preorder |child| {
|
||||
let _ = for child in self.parent.root.traverse_preorder() {
|
||||
if child.type_id() == ElementNodeTypeId(HTMLHeadElementTypeId) {
|
||||
headNode = Some(child);
|
||||
break;
|
||||
|
|
|
@ -20,7 +20,6 @@ use dom::window::Window;
|
|||
use std::cast;
|
||||
use std::cast::transmute;
|
||||
use std::libc::c_void;
|
||||
use std::uint;
|
||||
use js::jsapi::{JSObject, JSContext};
|
||||
use js::rust::Compartment;
|
||||
use netsurfcss::util::VoidPtrLike;
|
||||
|
@ -438,7 +437,7 @@ impl<'self, View> AbstractNode<View> {
|
|||
/// Dumps the node tree, for debugging, with indentation.
|
||||
pub fn dump_indent(&self, indent: uint) {
|
||||
let mut s = ~"";
|
||||
for uint::range(0u, indent) |_i| {
|
||||
for _ in range(0, indent) {
|
||||
s.push_str(" ");
|
||||
}
|
||||
|
||||
|
@ -446,7 +445,7 @@ impl<'self, View> AbstractNode<View> {
|
|||
debug!("%s", s);
|
||||
|
||||
// FIXME: this should have a pure version?
|
||||
for self.each_child() |kid| {
|
||||
for kid in self.children() {
|
||||
kid.dump_indent(indent + 1u)
|
||||
}
|
||||
}
|
||||
|
@ -483,14 +482,14 @@ impl Node<ScriptView> {
|
|||
|
||||
pub fn add_to_doc(&mut self, doc: AbstractDocument) {
|
||||
self.owner_doc = Some(doc);
|
||||
let mut node = self.first_child;
|
||||
while node.is_some() {
|
||||
for node.get().traverse_preorder |node| {
|
||||
let mut cur_node = self.first_child;
|
||||
while cur_node.is_some() {
|
||||
for node in cur_node.unwrap().traverse_preorder() {
|
||||
do node.with_mut_base |node_base| {
|
||||
node_base.owner_doc = Some(doc);
|
||||
}
|
||||
};
|
||||
node = node.get().next_sibling();
|
||||
cur_node = cur_node.unwrap().next_sibling();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@ fn css_link_listener(to_parent: SharedChan<HtmlDiscoveryMessage>,
|
|||
|
||||
// Send the sheets back in order
|
||||
// FIXME: Shouldn't wait until after we've recieved CSSTaskExit to start sending these
|
||||
for result_vec.iter().advance |port| {
|
||||
for port in result_vec.iter() {
|
||||
to_parent.send(HtmlDiscoveredStyle(port.recv()));
|
||||
}
|
||||
}
|
||||
|
@ -346,7 +346,7 @@ pub fn parse_html(cx: *JSContext,
|
|||
|
||||
debug!("-- attach attrs");
|
||||
do node.as_mut_element |element| {
|
||||
for tag.attributes.iter().advance |attr| {
|
||||
for attr in tag.attributes.iter() {
|
||||
element.set_attr(&str(attr.name.clone()), &str(attr.value.clone()));
|
||||
}
|
||||
}
|
||||
|
@ -375,7 +375,7 @@ pub fn parse_html(cx: *JSContext,
|
|||
let iframe_chan = iframe_chan.take();
|
||||
let elem = &mut iframe_element.parent.parent;
|
||||
let src_opt = elem.get_attr("src").map(|x| x.to_str());
|
||||
for src_opt.iter().advance |src| {
|
||||
for src in src_opt.iter() {
|
||||
let iframe_url = make_url(src.clone(), Some(url2.clone()));
|
||||
iframe_element.frame = Some(iframe_url.clone());
|
||||
|
||||
|
@ -502,7 +502,7 @@ pub fn parse_html(cx: *JSContext,
|
|||
|
||||
let mut data = ~[];
|
||||
debug!("iterating over children %?", style.first_child());
|
||||
for style.children().advance |child| {
|
||||
for child in style.children() {
|
||||
debug!("child = %?", child);
|
||||
do child.with_imm_text() |text| {
|
||||
data.push(text.parent.data.to_str()); // FIXME: Bad copy.
|
||||
|
|
|
@ -161,7 +161,7 @@ impl PageTree {
|
|||
|
||||
pub fn find<'a> (&'a mut self, id: PipelineId) -> Option<&'a mut PageTree> {
|
||||
if self.page.id == id { return Some(self); }
|
||||
for self.inner.mut_iter().advance |page_tree| {
|
||||
for page_tree in self.inner.mut_iter() {
|
||||
let found = page_tree.find(id);
|
||||
if found.is_some() { return found; }
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ impl<'self> Iterator<@mut Page> for PageTreeIterator<'self> {
|
|||
if !self.stack.is_empty() {
|
||||
let next = self.stack.pop();
|
||||
{
|
||||
for next.inner.mut_iter().advance |child| {
|
||||
for child in next.inner.mut_iter() {
|
||||
self.stack.push(child);
|
||||
}
|
||||
}
|
||||
|
@ -548,14 +548,14 @@ impl ScriptTask {
|
|||
fn handle_resize_inactive_msg(&mut self, new_size: Size2D<uint>) {
|
||||
self.page_tree.page.window_size = from_value(new_size);
|
||||
let last_loaded_url = replace(&mut self.page_tree.page.url, None);
|
||||
for last_loaded_url.iter().advance |last_loaded_url| {
|
||||
self.page_tree.page.url = Some((last_loaded_url.first(), true));
|
||||
for url in last_loaded_url.iter() {
|
||||
self.page_tree.page.url = Some((url.first(), true));
|
||||
}
|
||||
}
|
||||
|
||||
/// Handles a request to exit the script task and shut down layout.
|
||||
fn handle_exit_msg(&mut self) {
|
||||
for self.page_tree.iter().advance |page| {
|
||||
for page in self.page_tree.iter() {
|
||||
page.join_layout();
|
||||
do page.frame.unwrap().document.with_mut_base |doc| {
|
||||
doc.teardown();
|
||||
|
@ -573,10 +573,10 @@ impl ScriptTask {
|
|||
message for a layout channel that is not associated with this script task. This
|
||||
is a bug.").page;
|
||||
let last_loaded_url = replace(&mut page.url, None);
|
||||
for last_loaded_url.iter().advance |last_loaded_url| {
|
||||
let (ref last_loaded_url, needs_reflow) = *last_loaded_url;
|
||||
if *last_loaded_url == url {
|
||||
page.url = Some((last_loaded_url.clone(), false));
|
||||
for loaded in last_loaded_url.iter() {
|
||||
let (ref loaded, needs_reflow) = *loaded;
|
||||
if *loaded == url {
|
||||
page.url = Some((loaded.clone(), false));
|
||||
if needs_reflow {
|
||||
page.reflow_all(ReflowForDisplay, self.chan.clone(), self.compositor);
|
||||
}
|
||||
|
@ -676,7 +676,7 @@ impl ScriptTask {
|
|||
js_info.js_compartment.define_functions(debug_fns);
|
||||
|
||||
// Evaluate every script in the document.
|
||||
for js_scripts.iter().advance |bytes| {
|
||||
for bytes in js_scripts.iter() {
|
||||
let _ = js_info.js_context.evaluate_script(js_info.js_compartment.global_obj,
|
||||
bytes.clone(),
|
||||
~"???",
|
||||
|
@ -758,8 +758,8 @@ impl ScriptTask {
|
|||
|
||||
priv fn load_url_from_element(&self, page: @mut Page, element: &Element) {
|
||||
// if the node's element is "a," load url from href attr
|
||||
let href = element.get_attr("href");
|
||||
for href.iter().advance |href| {
|
||||
let attr = element.get_attr("href");
|
||||
for href in attr.iter() {
|
||||
debug!("ScriptTask: clicked on link to %s", *href);
|
||||
let current_url = do page.url.map |&(ref url, _)| {
|
||||
url.clone()
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::uint;
|
||||
use std::cmp::{max, min};
|
||||
use std::iterator;
|
||||
|
||||
enum RangeRelation {
|
||||
OverlapsBegin(/* overlap */ uint),
|
||||
|
@ -36,13 +36,8 @@ impl Range {
|
|||
pub fn length(&self) -> uint { self.len }
|
||||
pub fn end(&self) -> uint { self.off + self.len }
|
||||
|
||||
pub fn eachi(&self, callback: &fn(uint) -> bool) -> bool {
|
||||
for uint::range(self.off, self.off + self.len) |i| {
|
||||
if !callback(i) {
|
||||
break
|
||||
}
|
||||
}
|
||||
true
|
||||
pub fn eachi(&self) -> iterator::Range<uint> {
|
||||
range(self.off, self.off + self.len)
|
||||
}
|
||||
|
||||
pub fn contains(&self, i: uint) -> bool {
|
||||
|
|
|
@ -93,7 +93,7 @@ impl ProfilerCategory {
|
|||
|
||||
// ensure that the order of the buckets matches the order of the enum categories
|
||||
priv fn check_order(vec: &ProfilerBuckets) {
|
||||
for vec.iter().advance |&(category, _)| {
|
||||
for &(category, _) in vec.iter() {
|
||||
if category != vec[category as uint].first() {
|
||||
fail!("Enum category does not match bucket index. This is a bug.");
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ impl Profiler {
|
|||
println(fmt!("%31s %15s %15s %15s %15s %15s",
|
||||
"_category_", "_mean (ms)_", "_median (ms)_",
|
||||
"_min (ms)_", "_max (ms)_", "_bucket size_"));
|
||||
for self.buckets.mut_iter().advance |bucket| {
|
||||
for bucket in self.buckets.mut_iter() {
|
||||
let (category, data) = match *bucket {
|
||||
(category, ref mut data) => (category, data),
|
||||
};
|
||||
|
|
|
@ -39,7 +39,7 @@ pub fn make_url(str_url: ~str, current_url: Option<Url>) -> Url {
|
|||
str_url.trim_left_chars(&'/')
|
||||
} else {
|
||||
let mut path = ~[];
|
||||
for current_url.path.split_iter('/').advance |p| {
|
||||
for p in current_url.path.split_iter('/') {
|
||||
path.push(p.to_str());
|
||||
}
|
||||
let path = path.init();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue