diff --git a/servo/src/compiler/rust-auto-clean-trigger b/servo/src/compiler/rust-auto-clean-trigger index 1a4b4b90bd63..f15fda47fc8f 100644 --- a/servo/src/compiler/rust-auto-clean-trigger +++ b/servo/src/compiler/rust-auto-clean-trigger @@ -1,4 +1,4 @@ # If this file is modified, then rust will be forcibly cleaned and then rebuilt. # The actual contents of this file do not matter, but to trigger a change on the # build bots then the contents should be changed so git updates the mtime. -2013-10-18 +2013-10-31 diff --git a/servo/src/components/gfx/display_list.rs b/servo/src/components/gfx/display_list.rs index 812773383fbc..7a7e3a72c30c 100644 --- a/servo/src/components/gfx/display_list.rs +++ b/servo/src/components/gfx/display_list.rs @@ -42,7 +42,7 @@ impl DisplayList { /// Appends the given item to the display list. pub fn append_item(&mut self, item: DisplayItem) { // FIXME(Issue #150): crashes - //debug!("Adding display item %u: %?", self.len(), item); + //debug!("Adding display item {:u}: {}", self.len(), item); self.list.push(item) } @@ -51,7 +51,7 @@ impl DisplayList { debug!("Beginning display list."); for item in self.list.iter() { // FIXME(Issue #150): crashes - //debug!("drawing %?", *item); + //debug!("drawing {}", *item); item.draw_into_context(render_context) } debug!("Ending display list.") @@ -120,7 +120,7 @@ impl DisplayItem { } TextDisplayItemClass(ref text) => { - debug!("Drawing text at %?.", text.base.bounds); + debug!("Drawing text at {:?}.", text.base.bounds); // FIXME(pcwalton): Allocating? Why? let new_run = @text.text_run.deserialize(render_context.font_ctx); @@ -161,7 +161,7 @@ impl DisplayItem { } ImageDisplayItemClass(ref image_item) => { - debug!("Drawing image at %?.", image_item.base.bounds); + debug!("Drawing image at {:?}.", image_item.base.bounds); render_context.draw_image(image_item.base.bounds, image_item.image.clone()) } diff --git a/servo/src/components/gfx/font.rs b/servo/src/components/gfx/font.rs index faecef299047..589d9dd363df 100644 --- a/servo/src/components/gfx/font.rs +++ b/servo/src/components/gfx/font.rs @@ -320,7 +320,7 @@ impl Font { let result = self.handle.get_table_for_tag(tag); let status = if result.is_some() { "Found" } else { "Didn't find" }; - debug!("%s font table[%s] with family=%s, face=%s", + debug!("{:s} font table[{:s}] with family={:s}, face={:s}", status, tag.tag_to_str(), self.handle.family_name(), self.handle.face_name()); diff --git a/servo/src/components/gfx/font_context.rs b/servo/src/components/gfx/font_context.rs index c0f5f85970aa..798e883acd17 100644 --- a/servo/src/components/gfx/font_context.rs +++ b/servo/src/components/gfx/font_context.rs @@ -113,7 +113,7 @@ impl<'self> FontContext { fn transform_family(&self, family: &str) -> ~str { // FIXME: Need a find_like() in HashMap. let family = family.to_str(); - debug!("(transform family) searching for `%s`", family); + debug!("(transform family) searching for `{:s}`", family); match self.generic_fonts.find(&family) { None => family, Some(mapped_family) => (*mapped_family).clone() @@ -129,7 +129,7 @@ impl<'self> FontContext { 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); + debug!("(create font group) transformed family is `{:s}`", transformed_family_name); let result = match self.font_list { Some(ref fl) => fl.find_font_in_family(transformed_family_name, style), @@ -150,7 +150,7 @@ impl<'self> FontContext { }; if !found { - debug!("(create font group) didn't find `%s`", transformed_family_name); + debug!("(create font group) didn't find `{:s}`", transformed_family_name); } } diff --git a/servo/src/components/gfx/font_list.rs b/servo/src/components/gfx/font_list.rs index ac3e23a6ae88..4c6c02710ec7 100644 --- a/servo/src/components/gfx/font_list.rs +++ b/servo/src/components/gfx/font_list.rs @@ -71,7 +71,7 @@ impl FontList { "Couldn't find" }; - debug!("FontList: %s font face in family[%s] matching style", decision, family_name); + debug!("FontList: {:s} font face in family[{:s}] matching style", decision, family_name); result } @@ -81,7 +81,7 @@ impl FontList { let family = self.family_map.find_equiv(&family_name); let decision = if family.is_some() { "Found" } else { "Couldn't find" }; - debug!("FontList: %s font family with name=%s", decision, family_name); + debug!("FontList: {:s} font family with name={:s}", decision, family_name); // TODO(Issue #188): look up localized font family names if canonical name not found family.map(|f| *f) diff --git a/servo/src/components/gfx/freetype_impl/font_context.rs b/servo/src/components/gfx/freetype_impl/font_context.rs index 35d09e4900a8..fd501cbed66b 100644 --- a/servo/src/components/gfx/freetype_impl/font_context.rs +++ b/servo/src/components/gfx/freetype_impl/font_context.rs @@ -55,9 +55,9 @@ impl FontContextHandleMethods for FreeTypeFontContextHandle { } fn create_font_from_identifier(&self, name: ~str, style: UsedFontStyle) -> Result { - debug!("Creating font handle for %s", name); + debug!("Creating font handle for {:s}", name); do path_from_identifier(name).chain |file_name| { - debug!("Opening font face %s", file_name); + debug!("Opening font face {:s}", file_name); FreeTypeFontHandle::new_from_file(self, file_name, &style) } } diff --git a/servo/src/components/gfx/gfx.rc b/servo/src/components/gfx/gfx.rc index 0a2f2ff7cc3a..e803ccd21924 100644 --- a/servo/src/components/gfx/gfx.rc +++ b/servo/src/components/gfx/gfx.rc @@ -8,7 +8,7 @@ url = "http://servo.org/")]; #[crate_type = "lib"]; -#[feature(globs)]; +#[feature(globs, managed_boxes)]; extern mod azure; extern mod extra; diff --git a/servo/src/components/gfx/platform/android/font.rs b/servo/src/components/gfx/platform/android/font.rs index 7da80b3d9cfd..f8f78eb11003 100644 --- a/servo/src/components/gfx/platform/android/font.rs +++ b/servo/src/components/gfx/platform/android/font.rs @@ -191,7 +191,7 @@ impl FontHandleMethods for FontHandle { return if idx != 0 as FT_UInt { Some(idx as GlyphIndex) } else { - debug!("Invalid codepoint: %?", codepoint); + debug!("Invalid codepoint: {}", codepoint); None }; } @@ -207,13 +207,13 @@ impl FontHandleMethods for FontHandle { let void_glyph = (*self.face).glyph; let slot: FT_GlyphSlot = cast::transmute(void_glyph); assert!(slot.is_not_null()); - debug!("metrics: %?", (*slot).metrics); + debug!("metrics: {}", (*slot).metrics); let advance = (*slot).metrics.horiAdvance; - debug!("h_advance for %? is %?", glyph, advance); + debug!("h_advance for {} is {}", glyph, advance); let advance = advance as i32; return Some(fixed_to_float_ft(advance) as FractionalPixel); } else { - debug!("Unable to load glyph %?. reason: %?", glyph, res); + debug!("Unable to load glyph {}. reason: {}", glyph, res); return None; } } diff --git a/servo/src/components/gfx/platform/android/font_context.rs b/servo/src/components/gfx/platform/android/font_context.rs index e2a97f55db69..c30f040040da 100644 --- a/servo/src/components/gfx/platform/android/font_context.rs +++ b/servo/src/components/gfx/platform/android/font_context.rs @@ -52,9 +52,9 @@ impl FontContextHandleMethods for FontContextHandle { fn create_font_from_identifier(&self, name: ~str, style: UsedFontStyle) -> Result { - debug!("Creating font handle for %s", name); + debug!("Creating font handle for {:s}", name); do path_from_identifier(name, &style).chain |file_name| { - debug!("Opening font face %s", file_name); + debug!("Opening font face {:s}", file_name); FontHandle::new_from_file(self, file_name, &style) } } diff --git a/servo/src/components/gfx/platform/android/font_list.rs b/servo/src/components/gfx/platform/android/font_list.rs index 13acbe465ce5..6f6b26064ee2 100644 --- a/servo/src/components/gfx/platform/android/font_list.rs +++ b/servo/src/components/gfx/platform/android/font_list.rs @@ -52,7 +52,7 @@ impl FontListHandle { do "family".to_c_str().with_ref |FC_FAMILY| { while FcPatternGetString(*font, FC_FAMILY, v, &family) == FcResultMatch { let family_name = str::raw::from_c_str(family as *c_char); - debug!("Creating new FontFamily for family: %s", family_name); + debug!("Creating new FontFamily for family: {:s}", family_name); let new_family = @mut FontFamily::new(family_name); family_map.insert(family_name, new_family); v += 1; @@ -65,7 +65,7 @@ impl FontListHandle { #[fixed_stack_segment] pub fn load_variations_for_family(&self, family: @mut FontFamily) { - debug!("getting variations for %?", family); + debug!("getting variations for {}", family); unsafe { let config = FcConfigGetCurrent(); let font_set = FcConfigGetFonts(config, FcSetSystem); @@ -91,7 +91,7 @@ impl FontListHandle { let matches = FcFontSetList(config, font_set_array_ptr, 1, pattern, object_set); - debug!("found %? variations", (*matches).nfont); + debug!("found {} variations", (*matches).nfont); for i in range(0, (*matches).nfont as int) { let font = (*matches).fonts.offset(i); @@ -112,14 +112,14 @@ impl FontListHandle { } }; - debug!("variation file: %?", file); - debug!("variation index: %?", index); + debug!("variation file: {}", file); + debug!("variation index: {}", index); let font_handle = FontHandle::new_from_file_unstyled(&self.fctx, file); let font_handle = font_handle.unwrap(); - debug!("Creating new FontEntry for face: %s", font_handle.face_name()); + debug!("Creating new FontEntry for face: {:s}", font_handle.face_name()); let entry = @FontEntry::new(font_handle); family.entries.push(entry); } diff --git a/servo/src/components/gfx/platform/linux/font.rs b/servo/src/components/gfx/platform/linux/font.rs index 0f33720d420b..29e81ddaaee0 100644 --- a/servo/src/components/gfx/platform/linux/font.rs +++ b/servo/src/components/gfx/platform/linux/font.rs @@ -189,7 +189,7 @@ impl FontHandleMethods for FontHandle { return if idx != 0 as FT_UInt { Some(idx as GlyphIndex) } else { - debug!("Invalid codepoint: %?", codepoint); + debug!("Invalid codepoint: {}", codepoint); None }; } @@ -205,13 +205,13 @@ impl FontHandleMethods for FontHandle { let void_glyph = (*self.face).glyph; let slot: FT_GlyphSlot = cast::transmute(void_glyph); assert!(slot.is_not_null()); - debug!("metrics: %?", (*slot).metrics); + debug!("metrics: {:?}", (*slot).metrics); let advance = (*slot).metrics.horiAdvance; - debug!("h_advance for %? is %?", glyph, advance); + debug!("h_advance for {} is {}", glyph, advance); let advance = advance as i32; return Some(fixed_to_float_ft(advance) as FractionalPixel); } else { - debug!("Unable to load glyph %?. reason: %?", glyph, res); + debug!("Unable to load glyph {}. reason: {}", glyph, res); return None; } } diff --git a/servo/src/components/gfx/platform/linux/font_context.rs b/servo/src/components/gfx/platform/linux/font_context.rs index 4cca68227375..313082309d54 100644 --- a/servo/src/components/gfx/platform/linux/font_context.rs +++ b/servo/src/components/gfx/platform/linux/font_context.rs @@ -52,9 +52,9 @@ impl FontContextHandleMethods for FontContextHandle { fn create_font_from_identifier(&self, name: ~str, style: UsedFontStyle) -> Result { - debug!("Creating font handle for %s", name); + debug!("Creating font handle for {:s}", name); do path_from_identifier(name, &style).and_then |file_name| { - debug!("Opening font face %s", file_name); + debug!("Opening font face {:s}", file_name); FontHandle::new_from_file(self, file_name.to_owned(), &style) } } diff --git a/servo/src/components/gfx/platform/linux/font_list.rs b/servo/src/components/gfx/platform/linux/font_list.rs index 2f9cd629886a..4d0c721c2721 100644 --- a/servo/src/components/gfx/platform/linux/font_list.rs +++ b/servo/src/components/gfx/platform/linux/font_list.rs @@ -52,7 +52,7 @@ impl FontListHandle { do "family".to_c_str().with_ref |FC_FAMILY| { while FcPatternGetString(*font, FC_FAMILY, v, &family) == FcResultMatch { let family_name = str::raw::from_c_str(family as *c_char); - debug!("Creating new FontFamily for family: %s", family_name); + debug!("Creating new FontFamily for family: {:s}", family_name); let new_family = @mut FontFamily::new(family_name); family_map.insert(family_name, new_family); v += 1; @@ -65,7 +65,7 @@ impl FontListHandle { #[fixed_stack_segment] pub fn load_variations_for_family(&self, family: @mut FontFamily) { - debug!("getting variations for %?", family); + debug!("getting variations for {:?}", family); unsafe { let config = FcConfigGetCurrent(); let font_set = FcConfigGetFonts(config, FcSetSystem); @@ -91,7 +91,7 @@ impl FontListHandle { let matches = FcFontSetList(config, font_set_array_ptr, 1, pattern, object_set); - debug!("found %? variations", (*matches).nfont); + debug!("found {} variations", (*matches).nfont); for i in range(0, (*matches).nfont as int) { let font = (*matches).fonts.offset(i); @@ -112,14 +112,14 @@ impl FontListHandle { } }; - debug!("variation file: %?", file); - debug!("variation index: %?", index); + debug!("variation file: {}", file); + debug!("variation index: {}", index); let font_handle = FontHandle::new_from_file_unstyled(&self.fctx, file); let font_handle = font_handle.unwrap(); - debug!("Creating new FontEntry for face: %s", font_handle.face_name()); + debug!("Creating new FontEntry for face: {:s}", font_handle.face_name()); let entry = @FontEntry::new(font_handle); family.entries.push(entry); } diff --git a/servo/src/components/gfx/platform/macos/font.rs b/servo/src/components/gfx/platform/macos/font.rs index 47b2fca99a32..9705bb298224 100644 --- a/servo/src/components/gfx/platform/macos/font.rs +++ b/servo/src/components/gfx/platform/macos/font.rs @@ -182,7 +182,7 @@ impl FontHandleMethods for FontHandle { max_advance: Au::from_pt(bounding_rect.size.width as f64) }; - debug!("Font metrics (@%f pt): %?", self.ctfont.pt_size() as f64, metrics); + debug!("Font metrics (@{:f} pt): {:?}", self.ctfont.pt_size() as f64, metrics); return metrics; } diff --git a/servo/src/components/gfx/platform/macos/font_list.rs b/servo/src/components/gfx/platform/macos/font_list.rs index 22016f18fe40..6b6fc33bdc5b 100644 --- a/servo/src/components/gfx/platform/macos/font_list.rs +++ b/servo/src/components/gfx/platform/macos/font_list.rs @@ -32,7 +32,7 @@ impl FontListHandle { let mut family_map: FontFamilyMap = HashMap::new(); for strref in family_names.iter() { let family_name = CFString::wrap_shared(strref).to_str(); - debug!("Creating new FontFamily for family: %s", family_name); + debug!("Creating new FontFamily for family: {:s}", family_name); let new_family = @mut FontFamily::new(family_name); family_map.insert(family_name, new_family); @@ -41,7 +41,7 @@ impl FontListHandle { } pub fn load_variations_for_family(&self, family: @mut FontFamily) { - debug!("Looking for faces of family: %s", family.family_name); + debug!("Looking for faces of family: {:s}", family.family_name); let family_collection = core_text::font_collection::create_for_family(family.family_name); let family_descriptors = family_collection.get_descriptors(); @@ -50,7 +50,7 @@ impl FontListHandle { let font = core_text::font::new_from_descriptor(&desc, 0.0); let handle = FontHandle::new_from_CTFont(&self.fctx, font).unwrap(); - debug!("Creating new FontEntry for face: %s", handle.face_name()); + debug!("Creating new FontEntry for face: {:s}", handle.face_name()); let entry = @FontEntry::new(handle); family.entries.push(entry) } diff --git a/servo/src/components/gfx/render_task.rs b/servo/src/components/gfx/render_task.rs index 3af08754e87f..4bc3d6e748ae 100644 --- a/servo/src/components/gfx/render_task.rs +++ b/servo/src/components/gfx/render_task.rs @@ -188,7 +188,7 @@ impl RenderTask { if self.epoch == epoch { self.render(tiles, scale); } else { - debug!("renderer epoch mismatch: %? != %?", self.epoch, epoch); + debug!("renderer epoch mismatch: {:?} != {:?}", self.epoch, epoch); } } UnusedBufferMsg(unused_buffers) => { @@ -329,7 +329,7 @@ impl RenderTask { do draw_target.snapshot().get_data_surface().with_data |data| { buffer.native_surface.upload(&self.native_graphics_context, data); - debug!("RENDERER uploading to native surface %d", + debug!("RENDERER uploading to native surface {:d}", buffer.native_surface.get_id() as int); } diff --git a/servo/src/components/gfx/text/glyph.rs b/servo/src/components/gfx/text/glyph.rs index 077a393d9c38..6a72582c4d1a 100644 --- a/servo/src/components/gfx/text/glyph.rs +++ b/servo/src/components/gfx/text/glyph.rs @@ -56,8 +56,8 @@ impl GlyphEntry { fn complex(starts_cluster: bool, starts_ligature: bool, glyph_count: uint) -> GlyphEntry { assert!(glyph_count <= u16::max_value as uint); - debug!("creating complex glyph entry: starts_cluster=%?, starts_ligature=%?, \ - glyph_count=%?", + debug!("creating complex glyph entry: starts_cluster={}, starts_ligature={}, \ + glyph_count={}", starts_cluster, starts_ligature, glyph_count); @@ -327,7 +327,7 @@ impl<'self> DetailedGlyphStore { detail_offset: self.detail_buffer.len() }; - debug!("Adding entry[off=%u] for detailed glyphs: %?", entry_offset, glyphs); + debug!("Adding entry[off={:u}] for detailed glyphs: {:?}", entry_offset, glyphs); /* TODO: don't actually assert this until asserts are compiled in/out based on severity, debug/release, etc. This assertion @@ -347,7 +347,7 @@ impl<'self> DetailedGlyphStore { fn get_detailed_glyphs_for_entry(&'self self, entry_offset: uint, count: u16) -> &'self [DetailedGlyph] { - debug!("Requesting detailed glyphs[n=%u] for entry[off=%u]", count as uint, entry_offset); + debug!("Requesting detailed glyphs[n={:u}] for entry[off={:u}]", count as uint, entry_offset); // FIXME: Is this right? --pcwalton // TODO: should fix this somewhere else @@ -591,7 +591,7 @@ impl<'self> GlyphStore { } }.adapt_character_flags_of_entry(self.entry_buffer[i]); - debug!("Adding multiple glyphs[idx=%u, count=%u]: %?", i, glyph_count, entry); + debug!("Adding multiple glyphs[idx={:u}, count={:u}]: {:?}", i, glyph_count, entry); self.entry_buffer[i] = entry; } @@ -601,7 +601,7 @@ impl<'self> GlyphStore { assert!(i < self.entry_buffer.len()); let entry = GlyphEntry::complex(cluster_start, ligature_start, 0); - debug!("adding spacer for chracter without associated glyph[idx=%u]", i); + debug!("adding spacer for chracter without associated glyph[idx={:u}]", i); self.entry_buffer[i] = entry; } diff --git a/servo/src/components/gfx/text/shaping/harfbuzz.rs b/servo/src/components/gfx/text/shaping/harfbuzz.rs index 314fc975de9a..0708ead5e2c3 100644 --- a/servo/src/components/gfx/text/shaping/harfbuzz.rs +++ b/servo/src/components/gfx/text/shaping/harfbuzz.rs @@ -249,7 +249,7 @@ impl Shaper { assert!(glyph_count <= char_max); - debug!("Shaped text[char count=%u], got back %u glyph info records.", + debug!("Shaped text[char count={:u}], got back {:u} glyph info records.", char_max, glyph_count); @@ -279,17 +279,17 @@ impl Shaper { assert!(byteToGlyph[loc] != CONTINUATION_BYTE); byteToGlyph[loc] = i as i32; } else { - debug!("ERROR: tried to set out of range byteToGlyph: idx=%u, glyph idx=%u", + debug!("ERROR: tried to set out of range byteToGlyph: idx={:u}, glyph idx={:u}", loc, i); } - debug!("%u -> %u", i, loc); + debug!("{:u} -> {:u}", i, loc); } - debug!("text: %s", text); + debug!("text: {:s}", text); debug!("(char idx): char->(glyph index):"); for (i, ch) in text.char_offset_iter() { - debug!("%u: %? --> %d", i, ch, byteToGlyph[i] as int); + debug!("{:u}: {} --> {:d}", i, ch, byteToGlyph[i] as int); } // some helpers @@ -305,7 +305,7 @@ impl Shaper { while glyph_span.begin() < glyph_count { // start by looking at just one glyph. glyph_span.extend_by(1); - debug!("Processing glyph at idx=%u", glyph_span.begin()); + debug!("Processing glyph at idx={:u}", glyph_span.begin()); let char_byte_start = glyph_data.byte_offset_of_glyph(glyph_span.begin()); char_byte_span.reset(char_byte_start, 0); @@ -317,12 +317,12 @@ impl Shaper { ignore(range.ch); char_byte_span.extend_to(range.next); - debug!("Processing char byte span: off=%u, len=%u for glyph idx=%u", + debug!("Processing char byte span: off={:u}, len={:u} for glyph idx={:u}", char_byte_span.begin(), char_byte_span.length(), glyph_span.begin()); while char_byte_span.end() != byte_max && byteToGlyph[char_byte_span.end()] == NO_GLYPH { - debug!("Extending char byte span to include byte offset=%u with no associated \ + debug!("Extending char byte span to include byte offset={:u} with no associated \ glyph", char_byte_span.end()); let range = text.char_range_at(char_byte_span.end()); ignore(range.ch); @@ -340,7 +340,7 @@ impl Shaper { if max_glyph_idx > glyph_span.end() { glyph_span.extend_to(max_glyph_idx); - debug!("Extended glyph span (off=%u, len=%u) to cover char byte span's max \ + debug!("Extended glyph span (off={:u}, len={:u}) to cover char byte span's max \ glyph index", glyph_span.begin(), glyph_span.length()); } @@ -364,7 +364,7 @@ impl Shaper { } } - debug!("All glyphs within char_byte_span cluster?: %?", + debug!("All glyphs within char_byte_span cluster?: {}", all_glyphs_are_within_cluster); // found a valid range; stop extending char_span. diff --git a/servo/src/components/gfx/text/text_run.rs b/servo/src/components/gfx/text/text_run.rs index 81df6f0ee3ae..e7193b7ee579 100644 --- a/servo/src/components/gfx/text/text_run.rs +++ b/servo/src/components/gfx/text/text_run.rs @@ -33,7 +33,7 @@ impl SendableTextRun { pub fn deserialize(&self, fctx: @mut FontContext) -> TextRun { let font = match fctx.get_font_by_descriptor(&self.font) { Ok(f) => f, - Err(_) => fail!(fmt!("Font descriptor deserialization failed! desc=%?", self.font)) + Err(_) => fail!("Font descriptor deserialization failed! desc={:?}", self.font) }; TextRun { @@ -171,7 +171,7 @@ impl<'self> TextRun { // Create a glyph store for this slice if it's nonempty. if can_break_before && byte_i > byte_last_boundary { let slice = text.slice(byte_last_boundary, byte_i).to_owned(); - debug!("creating glyph store for slice %? (ws? %?), %? - %? in run %?", + debug!("creating glyph store for slice {} (ws? {}), {} - {} in run {}", slice, !cur_slice_is_whitespace, byte_last_boundary, byte_i, text); glyphs.push(font.shape_text(slice, !cur_slice_is_whitespace)); byte_last_boundary = byte_i; @@ -183,7 +183,7 @@ impl<'self> TextRun { // Create a glyph store for the final slice if it's nonempty. if byte_i > byte_last_boundary { let slice = text.slice_from(byte_last_boundary).to_owned(); - debug!("creating glyph store for final slice %? (ws? %?), %? - %? in run %?", + debug!("creating glyph store for final slice {} (ws? {}), {} - {} in run {}", slice, cur_slice_is_whitespace, byte_last_boundary, text.len(), text); glyphs.push(font.shape_text(slice, cur_slice_is_whitespace)); } @@ -227,9 +227,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); + debug!("iterating outer range {:?}", range); for (glyphs, offset, slice_range) in self.iter_slices_for_range(range) { - debug!("iterated on %?[%?]", offset, slice_range); + debug!("iterated on {:?}[{:?}]", offset, slice_range); let metrics = self.font.measure_text_for_slice(glyphs, &slice_range); max_piece_width = Au::max(max_piece_width, metrics.advance_width); } diff --git a/servo/src/components/main/compositing/compositor_layer.rs b/servo/src/components/main/compositing/compositor_layer.rs index 6877052ef2e2..83d19deea8de 100644 --- a/servo/src/components/main/compositing/compositor_layer.rs +++ b/servo/src/components/main/compositing/compositor_layer.rs @@ -259,7 +259,7 @@ impl CompositorLayer { let mut redisplay: bool; { // block here to prevent double mutable borrow of self let quadtree = match self.quadtree { - NoTree(*) => fail!("CompositorLayer: cannot get buffer request for %?, + NoTree(*) => fail!("CompositorLayer: cannot get buffer request for {:?}, no quadtree initialized", self.pipeline.id), Tree(ref mut quadtree) => quadtree, }; @@ -452,14 +452,14 @@ impl CompositorLayer { // Add new tiles. let quadtree = match self.quadtree { - NoTree(*) => fail!("CompositorLayer: cannot build layer tree for %?, + NoTree(*) => fail!("CompositorLayer: cannot build layer tree for {:?}, no quadtree initialized", self.pipeline.id), Tree(ref mut quadtree) => quadtree, }; let all_tiles = quadtree.get_all_tiles(); for buffer in all_tiles.iter() { - debug!("osmain: compositing buffer rect %?", &buffer.rect); + debug!("osmain: compositing buffer rect {}", buffer.rect); let size = Size2D(buffer.screen_pos.size.width as int, buffer.screen_pos.size.height as int); @@ -478,7 +478,7 @@ impl CompositorLayer { // Make a new texture and bind the layer buffer's surface to it. let texture = Texture::new(target); - debug!("COMPOSITOR binding to native surface %d", + debug!("COMPOSITOR binding to native surface {:d}", buffer.native_surface.get_id() as int); buffer.native_surface.bind_to_texture(graphics_context, &texture, size); @@ -540,7 +540,7 @@ impl CompositorLayer { let cell = Cell::new(new_buffers); if self.pipeline.id == pipeline_id { if self.epoch != epoch { - debug!("compositor epoch mismatch: %? != %?, id: %?", + debug!("compositor epoch mismatch: {:?} != {:?}, id: {:?}", self.epoch, epoch, self.pipeline.id); diff --git a/servo/src/components/main/compositing/quadtree.rs b/servo/src/components/main/compositing/quadtree.rs index a46524e28f29..5ad48c1988ee 100644 --- a/servo/src/components/main/compositing/quadtree.rs +++ b/servo/src/components/main/compositing/quadtree.rs @@ -304,7 +304,7 @@ impl Quadtree { /// Generate html to visualize the tree. For debugging purposes only. pub fn get_html(&self) -> ~str { - fmt!("%s%s", HEADER, self.root.get_html()) + format!("{:s}{:s}", HEADER, self.root.get_html()) } } @@ -374,7 +374,7 @@ impl QuadtreeNode { /// Returns an the difference in tile memory between the new quadtree node and the old quadtree node, /// along with any deleted tiles. fn add_tile(&mut self, x: f32, y: f32, tile: T, tile_size: f32) -> (int, ~[T]) { - debug!("Quadtree: Adding: (%?, %?) size:%?px", self.origin.x, self.origin.y, self.size); + debug!("Quadtree: Adding: ({}, {}) size:{}px", self.origin.x, self.origin.y, self.size); if x >= self.origin.x + self.size || x < self.origin.x || y >= self.origin.y + self.size || y < self.origin.y { @@ -741,33 +741,33 @@ impl QuadtreeNode { let mut ret = ~""; match self.tile { Some(ref tile) => { - ret = fmt!("%s%?", ret, tile); + ret = format!("{:s}{:?}", ret, tile); } None => { - ret = fmt!("%sNO TILE", ret); + ret = format!("{:s}NO TILE", ret); } } match self.quadrants { [None, None, None, None] => {} _ => { - ret = fmt!("%s", ret); + ret = format!("{:s}
", ret); // FIXME: This should be inline, but currently won't compile let quads = [TL, TR, BL, BR]; for quad in quads.iter() { match self.quadrants[*quad as int] { Some(ref child) => { - ret = fmt!("%s", ret, child.get_html()); + ret = format!("{:s}", ret, child.get_html()); } None => { - ret = fmt!("%s", ret); + ret = format!("{:s}", ret); } } match *quad { - TR => ret = fmt!("%s", ret), + TR => ret = format!("{:s}", ret), _ => {} } } - ret = fmt!("%s
%s{:s}EMPTY CHILDEMPTY CHILD
\n", ret); + ret = format!("{:s}\n", ret); } } return ret; diff --git a/servo/src/components/main/compositing/run.rs b/servo/src/components/main/compositing/run.rs index 2b9e7a8cbbde..60f90359312b 100644 --- a/servo/src/components/main/compositing/run.rs +++ b/servo/src/components/main/compositing/run.rs @@ -226,19 +226,19 @@ pub fn run_compositor(compositor: &CompositorTask) { ResizeWindowEvent(width, height) => { let new_size = Size2D(width, height); if window_size != new_size { - debug!("osmain: window resized to %ux%u", width, height); + debug!("osmain: window resized to {:u}x{:u}", width, height); window_size = new_size; match constellation_chan { Some(ref chan) => chan.send(ResizedWindowMsg(new_size)), None => error!("Compositor: Received resize event without initialized layout chan"), } } else { - debug!("osmain: dropping window resize since size is still %ux%u", width, height); + debug!("osmain: dropping window resize since size is still {:u}x{:u}", width, height); } } LoadUrlWindowEvent(url_string) => { - debug!("osmain: loading URL `%s`", url_string); + debug!("osmain: loading URL `{:s}`", url_string); let root_pipeline_id = match compositor_layer { Some(ref layer) => layer.pipeline.id.clone(), None => fail!("Compositor: Received LoadUrlWindowEvent without initialized compositor layers"), diff --git a/servo/src/components/main/constellation.rs b/servo/src/components/main/constellation.rs index e242c74ba480..3d9abea485c6 100644 --- a/servo/src/components/main/constellation.rs +++ b/servo/src/components/main/constellation.rs @@ -212,7 +212,7 @@ impl NavigationContext { /// Loads a new set of page frames, returning all evicted frame trees pub fn load(&mut self, frame_tree: @mut FrameTree) -> ~[@mut FrameTree] { - debug!("navigating to %?", frame_tree.pipeline.id); + debug!("navigating to {:?}", frame_tree.pipeline.id); let evicted = replace(&mut self.next, ~[]); if self.current.is_some() { self.previous.push(self.current.take_unwrap()); @@ -419,7 +419,7 @@ impl Constellation { } fn handle_frame_rect_msg(&mut self, pipeline_id: PipelineId, subpage_id: SubpageId, rect: Rect) { - debug!("Received frame rect %? from %?, %?", rect, pipeline_id, subpage_id); + debug!("Received frame rect {} from {:?}, {:?}", rect, pipeline_id, subpage_id); let mut already_sent = HashSet::new(); // Returns true if a child frame tree's subpage id matches the given subpage id @@ -520,7 +520,7 @@ impl Constellation { source_url.port == url.port) && sandbox == IFrameUnsandboxed; // FIXME(tkuehn): Need to follow the standardized spec for checking same-origin let pipeline = @mut if same_script { - debug!("Constellation: loading same-origin iframe at %?", url); + debug!("Constellation: loading same-origin iframe at {:?}", url); // Reuse the script task if same-origin url's Pipeline::with_script(next_pipeline_id, Some(subpage_id), @@ -532,7 +532,7 @@ impl Constellation { source_pipeline, size_future) } else { - debug!("Constellation: loading cross-origin iframe at %?", url); + debug!("Constellation: loading cross-origin iframe at {:?}", url); // Create a new script task if not same-origin url's Pipeline::create(next_pipeline_id, Some(subpage_id), @@ -545,7 +545,7 @@ impl Constellation { size_future) }; - debug!("Constellation: sending load msg to pipeline %?", pipeline.id); + debug!("Constellation: sending load msg to pipeline {:?}", pipeline.id); pipeline.load(url); let rect = self.pending_sizes.pop(&(source_pipeline_id, subpage_id)); for frame_tree in frame_trees.iter() { @@ -562,7 +562,7 @@ impl Constellation { } fn handle_load_url_msg(&mut self, source_id: PipelineId, url: Url, size_future: Future>) { - debug!("Constellation: received message to load %s", url.to_str()); + debug!("Constellation: received message to load {:s}", url.to_str()); // Make sure no pending page would be overridden. let source_frame = self.current_frame().get_ref().find(source_id).expect( "Constellation: received a LoadUrlMsg from a pipeline_id associated @@ -613,7 +613,7 @@ impl Constellation { } fn handle_navigate_msg(&mut self, direction: constellation_msg::NavigationDirection) { - debug!("received message to navigate %?", direction); + debug!("received message to navigate {:?}", direction); // TODO(tkuehn): what is the "critical point" beyond which pending frames // should not be cleared? Currently, the behavior is that forward/back @@ -655,7 +655,7 @@ impl Constellation { } fn handle_renderer_ready_msg(&mut self, pipeline_id: PipelineId) { - debug!("Renderer %? ready to send paint msg", pipeline_id); + debug!("Renderer {:?} ready to send paint msg", pipeline_id); // This message could originate from a pipeline in the navigation context or // 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. @@ -691,7 +691,7 @@ impl Constellation { // If there are frames to revoke permission from, do so now. match frame_change.before { Some(revoke_id) => { - debug!("Constellation: revoking permission from %?", revoke_id); + debug!("Constellation: revoking permission from {:?}", revoke_id); let current_frame = self.current_frame().unwrap(); let to_revoke = current_frame.find(revoke_id).expect( @@ -705,7 +705,7 @@ impl Constellation { // If to_add is not the root frame, then replace revoked_frame with it. // This conveniently keeps scissor rect size intact. if to_add.parent.is_some() { - debug!("Constellation: replacing %? with %? in %?", + debug!("Constellation: replacing {:?} with {:?} in {:?}", revoke_id, to_add.pipeline.id, next_frame_tree.pipeline.id); next_frame_tree.replace_child(revoke_id, to_add); } diff --git a/servo/src/components/main/layout/block.rs b/servo/src/components/main/layout/block.rs index ba3b4746a636..7a852dbf117e 100644 --- a/servo/src/components/main/layout/block.rs +++ b/servo/src/components/main/layout/block.rs @@ -360,7 +360,7 @@ impl FlowContext for BlockFlow { /// Dual boxes consume some width first, and the remainder is assigned to all child (block) /// contexts. fn assign_widths(&mut self, ctx: &mut LayoutContext) { - debug!("assign_widths_block: assigning width for flow %?", self.base.id); + debug!("assign_widths_block: assigning width for flow {}", self.base.id); if self.is_root { debug!("Setting root position"); self.base.position.origin = Au::zero_point(); @@ -433,12 +433,12 @@ impl FlowContext for BlockFlow { } fn assign_height_inorder(&mut self, ctx: &mut LayoutContext) { - debug!("assign_height_inorder: assigning height for block %?", self.base.id); + debug!("assign_height_inorder: assigning height for block {}", self.base.id); self.assign_height_block_base(ctx, true); } fn assign_height(&mut self, ctx: &mut LayoutContext) { - debug!("assign_height: assigning height for block %?", self.base.id); + debug!("assign_height: assigning height for block {}", self.base.id); // This is the only case in which a block flow can start an inorder // subtraversal. if self.is_root && self.base.num_floats > 0 { diff --git a/servo/src/components/main/layout/box.rs b/servo/src/components/main/layout/box.rs index 364b6c03f708..5dc426d3af03 100644 --- a/servo/src/components/main/layout/box.rs +++ b/servo/src/components/main/layout/box.rs @@ -310,7 +310,7 @@ impl RenderBox for ImageRenderBox { let size = self.image.mutate().ptr.get_size(); let height = Au::from_px(size.unwrap_or(Size2D(0, 0)).height); self.base.position.mutate().ptr.size.height = height; - debug!("box_height: found image height: %?", height); + debug!("box_height: found image height: {}", height); height } @@ -343,7 +343,7 @@ impl TextRenderBox { /// /// FIXME(pcwalton): This API is confusing. pub fn new(base: RenderBoxBase, run: @TextRun, range: Range) -> TextRenderBox { - debug!("Creating textbox with span: (strlen=%u, off=%u, len=%u) of textrun (%s) (len=%u)", + debug!("Creating textbox with span: (strlen={:u}, off={:u}, len={:u}) of textrun ({:s}) (len={:u})", run.char_len(), range.begin(), range.length(), @@ -422,13 +422,13 @@ impl RenderBox for TextRenderBox { let mut left_range = Range::new(self.range.begin(), 0); let mut right_range: Option = None; - debug!("split_to_width: splitting text box (strlen=%u, range=%?, avail_width=%?)", + debug!("split_to_width: splitting text box (strlen={:u}, range={}, avail_width={})", self.run.text.get().len(), self.range, max_width); for (glyphs, offset, slice_range) in self.run.iter_slices_for_range(&self.range) { - debug!("split_to_width: considering slice (offset=%?, range=%?, remain_width=%?)", + debug!("split_to_width: considering slice (offset={}, range={}, remain_width={})", offset, slice_range, remaining_width); @@ -470,7 +470,7 @@ impl RenderBox for TextRenderBox { // the right chunk. let right_range_end = self.range.end() - slice_begin; right_range = Some(Range::new(slice_begin, right_range_end)); - debug!("split_to_width: case=splitting remainder with right range=%?", + debug!("split_to_width: case=splitting remainder with right range={:?}", right_range); } } @@ -728,7 +728,7 @@ impl RenderBoxBase { pub fn font_style(&self) -> FontStyle { let my_style = self.nearest_ancestor_element().style(); - debug!("(font style) start: %?", self.nearest_ancestor_element().type_id()); + debug!("(font style) start: {:?}", self.nearest_ancestor_element().type_id()); // FIXME: Too much allocation here. let font_families = do my_style.Font.font_family.map |family| { @@ -737,10 +737,10 @@ impl RenderBoxBase { } }; let font_families = font_families.connect(", "); - debug!("(font style) font families: `%s`", font_families); + debug!("(font style) font families: `{:s}`", font_families); let font_size = my_style.Font.font_size.to_f64().unwrap() / 60.0; - debug!("(font style) font size: `%fpx`", font_size); + debug!("(font style) font size: `{:f}px`", font_size); let (italic, oblique) = match my_style.Font.font_style { font_style::normal => (false, false), @@ -948,9 +948,9 @@ impl RenderBoxUtils for @RenderBox { let base = self.base(); let box_bounds = base.position.get(); let absolute_box_bounds = box_bounds.translate(offset); - debug!("RenderBox::build_display_list at rel=%?, abs=%?: %s", + debug!("RenderBox::build_display_list at rel={}, abs={}: {:s}", box_bounds, absolute_box_bounds, self.debug_str()); - debug!("RenderBox::build_display_list: dirty=%?, offset=%?", dirty, offset); + debug!("RenderBox::build_display_list: dirty={}, offset={}", *dirty, *offset); if absolute_box_bounds.intersects(dirty) { debug!("RenderBox::build_display_list: intersected. Adding display item..."); @@ -990,7 +990,7 @@ impl RenderBoxUtils for @RenderBox { // // FIXME(pcwalton): This is a bit of an abuse of the logging infrastructure. We // should have a real `SERVO_DEBUG` system. - debug!("%?", { + debug!("{:?}", { // Compute the text box bounds and draw a border surrounding them. let debug_border = SideOffsets2D::new_all_same(Au::from_px(1)); @@ -1039,7 +1039,7 @@ impl RenderBoxUtils for @RenderBox { // FIXME(pcwalton): This is a bit of an abuse of the logging infrastructure. We // should have a real `SERVO_DEBUG` system. - debug!("%?", { + debug!("{:?}", { let debug_border = SideOffsets2D::new_all_same(Au::from_px(1)); do list.with_mut_ref |list| { diff --git a/servo/src/components/main/layout/box_builder.rs b/servo/src/components/main/layout/box_builder.rs index e2cff941d97c..6b72794a121e 100644 --- a/servo/src/components/main/layout/box_builder.rs +++ b/servo/src/components/main/layout/box_builder.rs @@ -70,7 +70,7 @@ impl<'self> BoxGenerator<'self> { /* Debug ids only */ fn new(flow: &'self mut FlowContext) -> BoxGenerator<'self> { - debug!("Creating box generator for flow: %s", flow.debug_str()); + debug!("Creating box generator for flow: {:s}", flow.debug_str()); BoxGenerator { flow: flow, range_stack: @mut ~[] @@ -105,12 +105,12 @@ impl<'self> BoxGenerator<'self> { ctx: &LayoutContext, node: AbstractNode, builder: &mut LayoutTreeBuilder) { - debug!("BoxGenerator[f%d]: pushing node: %s", flow::base(self.flow).id, node.debug_str()); + debug!("BoxGenerator[f{:d}]: pushing node: {:s}", flow::base(self.flow).id, node.debug_str()); // TODO: remove this once UA styles work let box_type = self.decide_box_type(node); - debug!("BoxGenerator[f%d]: point a", flow::base(self.flow).id); + debug!("BoxGenerator[f{:d}]: point a", flow::base(self.flow).id); let range_stack = &mut self.range_stack; // depending on flow, make a box for this node. @@ -135,10 +135,10 @@ impl<'self> BoxGenerator<'self> { }, BlockFlowClass => { let block = self.flow.as_block(); - debug!("BoxGenerator[f%d]: point b", block.base.id); + debug!("BoxGenerator[f{:d}]: point b", block.base.id); let new_box = BoxGenerator::make_box(ctx, box_type, node, builder); - debug!("BoxGenerator[f%d]: attaching box[b%d] to block flow (node: %s)", + debug!("BoxGenerator[f{:d}]: attaching box[b{:d}] to block flow (node: {:s})", block.base.id, new_box.base().id(), node.debug_str()); @@ -148,11 +148,11 @@ impl<'self> BoxGenerator<'self> { } FloatFlowClass => { let float = self.flow.as_float(); - debug!("BoxGenerator[f%d]: point b", float.base.id); + debug!("BoxGenerator[f{:d}]: point b", float.base.id); let new_box = BoxGenerator::make_box(ctx, box_type, node, builder); - debug!("BoxGenerator[f%d]: attaching box[b%d] to float flow (node: %s)", + debug!("BoxGenerator[f{:d}]: attaching box[b{:d}] to float flow (node: {:s})", float.base.id, new_box.base().id(), node.debug_str()); @@ -160,12 +160,12 @@ impl<'self> BoxGenerator<'self> { assert!(float.box.is_none() && float.index.is_none()); float.box = Some(new_box); } - _ => warn!("push_node() not implemented for flow f%d", flow::base(self.flow).id), + _ => warn!("push_node() not implemented for flow f{:d}", flow::base(self.flow).id), } } pub fn pop_node(&mut self, ctx: &LayoutContext, node: AbstractNode) { - debug!("BoxGenerator[f%d]: popping node: %s", flow::base(self.flow).id, node.debug_str()); + debug!("BoxGenerator[f{:d}]: popping node: {:s}", flow::base(self.flow).id, node.debug_str()); match self.flow.class() { InlineFlowClass => { @@ -188,12 +188,12 @@ impl<'self> BoxGenerator<'self> { warn!("node range length is zero?!") } - debug!("BoxGenerator: adding element range=%?", node_range); + debug!("BoxGenerator: adding element range={}", node_range); inline.elems.add_mapping(node, &node_range); }, BlockFlowClass => assert!(self.range_stack.len() == 0), FloatFlowClass => assert!(self.range_stack.len() == 0), - _ => warn!("pop_node() not implemented for flow %?", flow::base(self.flow).id), + _ => warn!("pop_node() not implemented for flow {:?}", flow::base(self.flow).id), } } @@ -212,7 +212,7 @@ impl<'self> BoxGenerator<'self> { } ImageRenderBoxClass => BoxGenerator::make_image_box(layout_ctx, node, base), }; - debug!("BoxGenerator: created box: %s", result.debug_str()); + debug!("BoxGenerator: created box: {:s}", result.debug_str()); result } @@ -289,7 +289,7 @@ impl LayoutTreeBuilder { mut parent_generator: BoxGenerator<'a>, mut prev_sibling_generator: Option>) -> BoxConstructResult<'a> { - debug!("Considering node: %s", cur_node.debug_str()); + debug!("Considering node: {:s}", cur_node.debug_str()); let box_gen_result = { let grandparent_gen_ref = match grandparent_generator { Some(ref mut generator) => Some(generator), @@ -304,7 +304,7 @@ impl LayoutTreeBuilder { let mut reparent = false; - debug!("result from generator_for_node: %?", &box_gen_result); + debug!("result from generator_for_node: {:?}", &box_gen_result); // Skip over nodes that don't belong in the flow tree let (this_generator, next_generator) = match box_gen_result { NoGenerator => return Normal(prev_sibling_generator), @@ -332,9 +332,9 @@ impl LayoutTreeBuilder { let mut this_generator = this_generator; - debug!("point a: %s", cur_node.debug_str()); + debug!("point a: {:s}", cur_node.debug_str()); this_generator.push_node(layout_ctx, cur_node, self); - debug!("point b: %s", cur_node.debug_str()); + debug!("point b: {:s}", cur_node.debug_str()); // recurse on child nodes. let prev_gen_cell = Cell::new(Normal(None)); @@ -571,7 +571,7 @@ impl LayoutTreeBuilder { let first_box = boxes[0]; // FIXME(pcwalton): Rust bug if first_box.is_whitespace_only() { debug!("LayoutTreeBuilder: pruning whitespace-only first \ - child flow f%d from parent f%d", + child flow f{:d} from parent f{:d}", first_inline_flow.base.id, p_id); do_remove = true; @@ -599,7 +599,7 @@ impl LayoutTreeBuilder { let last_box = boxes.last(); // FIXME(pcwalton): Rust bug if last_box.is_whitespace_only() { debug!("LayoutTreeBuilder: pruning whitespace-only last \ - child flow f%d from parent f%d", + child flow f{:d} from parent f{:d}", last_inline_flow.base.id, p_id); do_remove = true; @@ -638,7 +638,7 @@ impl LayoutTreeBuilder { pub fn construct_trees(&mut self, layout_ctx: &LayoutContext, root: AbstractNode) -> Result<~FlowContext:, ()> { debug!("Constructing flow tree for DOM: "); - debug!("%?", root.dump()); + debug!("{:?}", root.dump()); let mut new_flow = self.make_flow(RootFlowType, root); { @@ -661,7 +661,7 @@ impl LayoutTreeBuilder { RootFlowType => ~BlockFlow::new_root(info) as ~FlowContext:, TableFlowType => ~TableFlow::new(info) as ~FlowContext:, }; - debug!("LayoutTreeBuilder: created flow: %s", result.debug_str()); + debug!("LayoutTreeBuilder: created flow: {:s}", result.debug_str()); result } } diff --git a/servo/src/components/main/layout/float.rs b/servo/src/components/main/layout/float.rs index 8aee9e4837a9..47f6dd12f9b3 100644 --- a/servo/src/components/main/layout/float.rs +++ b/servo/src/components/main/layout/float.rs @@ -137,7 +137,7 @@ impl FlowContext for FloatFlow { } fn assign_widths(&mut self, _: &mut LayoutContext) { - debug!("assign_widths_float: assigning width for flow %?", self.base.id); + debug!("assign_widths_float: assigning width for flow {}", self.base.id); // position.size.width is set by parent even though we don't know // position.origin yet. let mut remaining_width = self.base.position.size.width; @@ -174,7 +174,7 @@ impl FlowContext for FloatFlow { let width = MaybeAuto::from_style(style.Box.width, remaining_width).specified_or_default(shrink_to_fit); - debug!("assign_widths_float -- width: %?", width); + debug!("assign_widths_float -- width: {}", width); model.margin.top = margin_top; model.margin.right = margin_right; @@ -210,7 +210,7 @@ impl FlowContext for FloatFlow { } fn assign_height_inorder(&mut self, _: &mut LayoutContext) { - debug!("assign_height_inorder_float: assigning height for float %?", self.base.id); + debug!("assign_height_inorder_float: assigning height for float {}", self.base.id); // assign_height_float was already called by the traversal function // so this is well-defined @@ -250,7 +250,7 @@ impl FlowContext for FloatFlow { } fn assign_height(&mut self, ctx: &mut LayoutContext) { - debug!("assign_height_float: assigning height for float %?", self.base.id); + debug!("assign_height_float: assigning height for float {}", self.base.id); let has_inorder_children = self.base.num_floats > 0; if has_inorder_children { let mut float_ctx = FloatContext::new(self.floated_children); @@ -298,7 +298,7 @@ impl FlowContext for FloatFlow { Au::new(0)).specified_or_zero(); height = geometry::max(height, height_prop) + noncontent_height; - debug!("assign_height_float -- height: %?", height); + debug!("assign_height_float -- height: {}", height); position.size.height = height; } diff --git a/servo/src/components/main/layout/float_context.rs b/servo/src/components/main/layout/float_context.rs index 5786cf369ae5..45e142b24b9f 100644 --- a/servo/src/components/main/layout/float_context.rs +++ b/servo/src/components/main/layout/float_context.rs @@ -128,7 +128,7 @@ impl FloatContext { impl FloatContextBase{ fn new(num_floats: uint) -> FloatContextBase { - debug!("Creating float context of size %?", num_floats); + debug!("Creating float context of size {}", num_floats); FloatContextBase { float_data: if num_floats == 0 { None @@ -151,7 +151,7 @@ impl FloatContextBase{ match self.float_data.get_ref()[self.floats_used - 1] { None => fail!("FloatContext error: floats should never be None here"), Some(float) => { - debug!("Returning float position: %?", float.bounds.origin + self.offset); + debug!("Returning float position: {}", float.bounds.origin + self.offset); float.bounds.origin + self.offset } } @@ -168,7 +168,7 @@ impl FloatContextBase{ let top = top - self.offset.y; - debug!("available_rect: trying to find space at %?", top); + debug!("available_rect: trying to find space at {}", top); // Relevant dimensions for the right-most left float let mut max_left = Au(0) - self.offset.x; @@ -188,7 +188,7 @@ impl FloatContextBase{ Some(data) => { let float_pos = data.bounds.origin; let float_size = data.bounds.size; - debug!("float_pos: %?, float_size: %?", float_pos, float_size); + debug!("float_pos: {}, float_size: {}", float_pos, float_size); match data.f_type { FloatLeft => { if(float_pos.x + float_size.width > max_left && @@ -198,7 +198,7 @@ impl FloatContextBase{ l_top = Some(float_pos.y); l_bottom = Some(float_pos.y + float_size.height); - debug!("available_rect: collision with left float: new max_left is %?", + debug!("available_rect: collision with left float: new max_left is {}", max_left); } } @@ -209,7 +209,7 @@ impl FloatContextBase{ r_top = Some(float_pos.y); r_bottom = Some(float_pos.y + float_size.height); - debug!("available_rect: collision with right float: new min_right is %?", + debug!("available_rect: collision with right float: new min_right is {}", min_right); } } @@ -249,7 +249,7 @@ impl FloatContextBase{ fn add_float(&mut self, info: &PlacementInfo) { assert!(self.float_data.is_some()); - debug!("Floats_used: %?, Floats available: %?", + debug!("Floats_used: {}, Floats available: {}", self.floats_used, self.float_data.get_ref().len()); assert!(self.floats_used < self.float_data.get_ref().len() && @@ -263,7 +263,7 @@ impl FloatContextBase{ f_type: info.f_type }; - debug!("add_float: added float with info %?", new_info); + debug!("add_float: added float with info {:?}", new_info); let new_float = FloatData { bounds: Rect { @@ -325,13 +325,13 @@ impl FloatContextBase{ /// Given necessary info, finds the closest place a box can be positioned /// without colliding with any floats. fn place_between_floats(&self, info: &PlacementInfo) -> Rect{ - debug!("place_float: Placing float with width %? and height %?", info.width, info.height); + debug!("place_float: Placing float with width {} and height {}", info.width, info.height); // Can't go any higher than previous floats or // previous elements in the document. let mut float_y = info.ceiling; loop { let maybe_location = self.available_rect(float_y, info.height, info.max_width); - debug!("place_float: Got available rect: %? for y-pos: %?", maybe_location, float_y); + debug!("place_float: Got available rect: {:?} for y-pos: {}", maybe_location, float_y); match maybe_location { // If there are no floats blocking us, return the current location diff --git a/servo/src/components/main/layout/flow.rs b/servo/src/components/main/layout/flow.rs index 35e06902f8f6..abbc39a50d9a 100644 --- a/servo/src/components/main/layout/flow.rs +++ b/servo/src/components/main/layout/flow.rs @@ -496,12 +496,12 @@ impl<'self> MutableFlowUtils for &'self mut FlowContext { dirty: &Rect, list: &Cell>) -> bool { - debug!("FlowContext: building display list for f%?", base(self).id); + debug!("FlowContext: building display list for f{}", base(self).id); match self.class() { BlockFlowClass => self.as_block().build_display_list_block(builder, dirty, list), InlineFlowClass => self.as_inline().build_display_list_inline(builder, dirty, list), FloatFlowClass => self.as_float().build_display_list_float(builder, dirty, list), - _ => fail!("Tried to build_display_list_recurse of flow: %?", self), + _ => fail!("Tried to build_display_list_recurse of flow: {:?}", self), } } } diff --git a/servo/src/components/main/layout/inline.rs b/servo/src/components/main/layout/inline.rs index 037b782edf02..a15f739ba05f 100644 --- a/servo/src/components/main/layout/inline.rs +++ b/servo/src/components/main/layout/inline.rs @@ -103,7 +103,7 @@ impl LineboxScanner { } fn reset_scanner(&mut self, flow: &mut InlineFlow) { - debug!("Resetting line box scanner's state for flow f%d.", flow.base.id); + debug!("Resetting line box scanner's state for flow f{:d}.", flow.base.id); self.lines = ~[]; self.new_boxes = ~[]; self.cur_y = Au::new(0); @@ -128,26 +128,26 @@ impl LineboxScanner { break } let box = flow.boxes[i]; i += 1; - debug!("LineboxScanner: Working with box from box list: b%d", box.base().id()); + debug!("LineboxScanner: Working with box from box list: b{:d}", box.base().id()); box } else { let box = self.work_list.pop_front().unwrap(); - debug!("LineboxScanner: Working with box from work list: b%d", box.base().id()); + debug!("LineboxScanner: Working with box from work list: b{:d}", box.base().id()); box }; let box_was_appended = self.try_append_to_line(cur_box, flow); if !box_was_appended { - debug!("LineboxScanner: Box wasn't appended, because line %u was full.", + debug!("LineboxScanner: Box wasn't appended, because line {:u} was full.", self.lines.len()); self.flush_current_line(); } else { - debug!("LineboxScanner: appended a box to line %u", self.lines.len()); + debug!("LineboxScanner: appended a box to line {:u}", self.lines.len()); } } if self.pending_line.range.length() > 0 { - debug!("LineboxScanner: Partially full linebox %u left at end of scanning.", + debug!("LineboxScanner: Partially full linebox {:u} left at end of scanning.", self.lines.len()); self.flush_current_line(); } @@ -158,7 +158,7 @@ impl LineboxScanner { } fn swap_out_results(&mut self, flow: &mut InlineFlow) { - debug!("LineboxScanner: Propagating scanned lines[n=%u] to inline flow f%d", + debug!("LineboxScanner: Propagating scanned lines[n={:u}] to inline flow f{:d}", self.lines.len(), flow.base.id); @@ -167,11 +167,11 @@ impl LineboxScanner { } fn flush_current_line(&mut self) { - debug!("LineboxScanner: Flushing line %u: %?", + debug!("LineboxScanner: Flushing line {:u}: {:?}", self.lines.len(), self.pending_line); // clear line and add line mapping - debug!("LineboxScanner: Saving information for flushed line %u.", self.lines.len()); + debug!("LineboxScanner: Saving information for flushed line {:u}.", self.lines.len()); self.lines.push(self.pending_line); self.cur_y = self.pending_line.bounds.origin.y + self.pending_line.bounds.size.height; self.reset_linebox(); @@ -193,10 +193,10 @@ impl LineboxScanner { /// with the line's origin) and the actual width of the first box after splitting. fn initial_line_placement(&self, first_box: @RenderBox, ceiling: Au, flow: &mut InlineFlow) -> (Rect, Au) { - debug!("LineboxScanner: Trying to place first box of line %?", self.lines.len()); + debug!("LineboxScanner: Trying to place first box of line {}", self.lines.len()); let first_box_size = first_box.base().position.get().size; - debug!("LineboxScanner: box size: %?", first_box_size); + debug!("LineboxScanner: box size: {}", first_box_size); let splitable = first_box.can_split(); let line_is_empty: bool = self.pending_line.range.length() == 0; @@ -219,7 +219,7 @@ impl LineboxScanner { let line_bounds = self.floats.place_between_floats(&info); - debug!("LineboxScanner: found position for line: %? using placement_info: %?", + debug!("LineboxScanner: found position for line: {} using placement_info: {:?}", line_bounds, info); @@ -242,7 +242,7 @@ impl LineboxScanner { // try_append_to_line. match first_box.split_to_width(line_bounds.size.width, line_is_empty) { CannotSplit(_) => { - error!("LineboxScanner: Tried to split unsplittable render box! %s", + error!("LineboxScanner: Tried to split unsplittable render box! {:s}", first_box.debug_str()); return (line_bounds, first_box_size.width); } @@ -273,7 +273,7 @@ impl LineboxScanner { info.width = actual_box_width; let new_bounds = self.floats.place_between_floats(&info); - debug!("LineboxScanner: case=new line position: %?", new_bounds); + debug!("LineboxScanner: case=new line position: {}", new_bounds); return (new_bounds, actual_box_width); } } @@ -290,8 +290,8 @@ impl LineboxScanner { self.pending_line.green_zone = line_bounds.size; } - debug!("LineboxScanner: Trying to append box to line %u (box size: %?, green zone: \ - %?): %s", + debug!("LineboxScanner: Trying to append box to line {:u} (box size: {}, green zone: \ + {}): {:s}", self.lines.len(), in_box.base().position.get().size, self.pending_line.green_zone, @@ -361,7 +361,7 @@ impl LineboxScanner { if !in_box.can_split() { // TODO(Issue #224): signal that horizontal overflow happened? if line_is_empty { - debug!("LineboxScanner: case=box can't split and line %u is empty, so \ + debug!("LineboxScanner: case=box can't split and line {:u} is empty, so \ overflowing.", self.lines.len()); self.push_box_to_line(in_box); @@ -375,7 +375,7 @@ impl LineboxScanner { match in_box.split_to_width(available_width, line_is_empty) { CannotSplit(_) => { - error!("LineboxScanner: Tried to split unsplittable render box! %s", + error!("LineboxScanner: Tried to split unsplittable render box! {:s}", in_box.debug_str()); return false; } @@ -394,7 +394,7 @@ impl LineboxScanner { } SplitDidNotFit(left, right) => { if line_is_empty { - debug!("LineboxScanner: case=split box didn't fit and line %u is empty, so overflowing and deferring remainder box.", + debug!("LineboxScanner: case=split box didn't fit and line {:u} is empty, so overflowing and deferring remainder box.", self.lines.len()); // TODO(Issue #224): signal that horizontal overflow happened? match (left, right) { @@ -425,7 +425,7 @@ impl LineboxScanner { // unconditional push fn push_box_to_line(&mut self, box: @RenderBox) { - debug!("LineboxScanner: Pushing box b%d to line %u", box.base().id(), self.lines.len()); + debug!("LineboxScanner: Pushing box b{:d} to line {:u}", box.base().id(), self.lines.len()); if self.pending_line.range.length() == 0 { assert!(self.new_boxes.len() <= (u16::max_value as uint)); @@ -492,7 +492,7 @@ impl InlineFlow { // TODO(#228): Once we form line boxes and have their cached bounds, we can be smarter and // not recurse on a line if nothing in it can intersect the dirty region. - debug!("FlowContext[%d]: building display list for %u inline boxes", + debug!("FlowContext[{:d}]: building display list for {:u} inline boxes", self.base.id, self.boxes.len()); @@ -530,24 +530,20 @@ impl FlowContext for InlineFlow { child_base.floats_in = FloatContext::new(child_base.num_floats); } - { - let this = &mut *self; + let mut min_width = Au::new(0); + let mut pref_width = Au::new(0); - let mut min_width = Au::new(0); - let mut pref_width = Au::new(0); - - for box in this.boxes.iter() { - debug!("FlowContext[%d]: measuring %s", self.base.id, box.debug_str()); - let (this_minimum_width, this_preferred_width) = - box.minimum_and_preferred_widths(); - min_width = Au::max(min_width, this_minimum_width); - pref_width = Au::max(pref_width, this_preferred_width); - } - - this.base.min_width = min_width; - this.base.pref_width = pref_width; - this.base.num_floats = num_floats; + for box in self.boxes.iter() { + debug!("FlowContext[{:d}]: measuring {:s}", self.base.id, box.debug_str()); + let (this_minimum_width, this_preferred_width) = + box.minimum_and_preferred_widths(); + min_width = Au::max(min_width, this_minimum_width); + pref_width = Au::max(pref_width, this_preferred_width); } + + self.base.min_width = min_width; + self.base.pref_width = pref_width; + self.base.num_floats = num_floats; } /// Recursively (top-down) determines the actual width of child contexts and boxes. When called @@ -558,7 +554,7 @@ impl FlowContext for InlineFlow { // TODO: Combine this with `LineboxScanner`'s walk in the box list, or put this into // `RenderBox`. - debug!("assign_widths_inline: floats_in: %?", self.base.floats_in); + debug!("assign_widths_inline: floats_in: {:?}", self.base.floats_in); { let this = &mut *self; for &box in this.boxes.iter() { @@ -588,7 +584,7 @@ impl FlowContext for InlineFlow { } fn assign_height(&mut self, _: &mut LayoutContext) { - debug!("assign_height_inline: assigning height for flow %?", self.base.id); + debug!("assign_height_inline: assigning height for flow {}", self.base.id); // Divide the boxes into lines // TODO(#226): Get the CSS `line-height` property from the containing block's style to @@ -598,7 +594,7 @@ impl FlowContext for InlineFlow { // determine its height for computing linebox height. // // TODO(pcwalton): Cache the linebox scanner? - debug!("assign_height_inline: floats_in: %?", self.base.floats_in); + debug!("assign_height_inline: floats_in: {:?}", self.base.floats_in); let scanner_floats = self.base.floats_in.clone(); let mut scanner = LineboxScanner::new(scanner_floats); @@ -729,8 +725,8 @@ impl FlowContext for InlineFlow { }, // FIXME(pcwalton): This isn't very type safe! _ => { - fail!(fmt!("Tried to assign height to unknown Box variant: %s", - cur_box.debug_str())) + fail!("Tried to assign height to unknown Box variant: {:s}", + cur_box.debug_str()) } }; let mut top_from_base = top_from_base; diff --git a/servo/src/components/main/layout/layout_task.rs b/servo/src/components/main/layout/layout_task.rs index 046f2518ffea..a894ffc38963 100644 --- a/servo/src/components/main/layout/layout_task.rs +++ b/servo/src/components/main/layout/layout_task.rs @@ -330,10 +330,10 @@ impl LayoutTask { // FIXME: Bad copy! let doc_url = data.url.clone(); - debug!("layout: received layout request for: %s", doc_url.to_str()); - debug!("layout: damage is %?", data.damage); + debug!("layout: received layout request for: {:s}", doc_url.to_str()); + debug!("layout: damage is {:?}", data.damage); debug!("layout: parsed Node tree"); - debug!("%?", node.dump()); + debug!("{:?}", node.dump()); // Reset the image cache. self.local_image_cache.next_round(self.make_on_image_available_cb()); @@ -341,7 +341,7 @@ impl LayoutTask { let screen_size = Size2D(Au::from_px(data.window_size.width as int), Au::from_px(data.window_size.height as int)); let resized = self.screen_size != Some(screen_size); - debug!("resized: %?", resized); + debug!("resized: {}", resized); self.screen_size = Some(screen_size); // Create a layout context for use throughout the following passes. @@ -384,7 +384,7 @@ impl LayoutTask { layout_root.traverse_postorder(&mut ComputeDamageTraversal.clone()); debug!("layout: constructed Flow tree"); - debug!("%?", layout_root.dump()); + debug!("{:?}", layout_root.dump()); // Perform the primary layout passes over the flow tree to compute the locations of all // the boxes. diff --git a/servo/src/components/main/layout/text.rs b/servo/src/components/main/layout/text.rs index 77a8831d1375..e18538fe44ff 100644 --- a/servo/src/components/main/layout/text.rs +++ b/servo/src/components/main/layout/text.rs @@ -31,13 +31,13 @@ impl TextRunScanner { // FIXME: this assertion fails on wikipedia, but doesn't seem // to cause problems. // assert!(inline.boxes.len() > 0); - debug!("TextRunScanner: scanning %u boxes for text runs...", inline.boxes.len()); + debug!("TextRunScanner: scanning {:u} boxes for text runs...", inline.boxes.len()); } let mut last_whitespace = true; let mut out_boxes = ~[]; for box_i in range(0, flow.as_immutable_inline().boxes.len()) { - debug!("TextRunScanner: considering box: %u", box_i); + debug!("TextRunScanner: considering box: {:u}", box_i); if box_i > 0 && !can_coalesce_text_nodes(flow.as_immutable_inline().boxes, box_i - 1, box_i) { @@ -92,7 +92,7 @@ impl TextRunScanner { assert!(self.clump.length() > 0); - debug!("TextRunScanner: flushing boxes in range=%?", self.clump); + debug!("TextRunScanner: flushing boxes in range={}", self.clump); let is_singleton = self.clump.length() == 1; let possible_text_clump = in_boxes[self.clump.begin()]; // FIXME(pcwalton): Rust bug let is_text_clump = possible_text_clump.class() == UnscannedTextRenderBoxClass; @@ -104,7 +104,7 @@ impl TextRunScanner { fail!(~"WAT: can't coalesce non-text nodes in flush_clump_to_list()!") } (true, false) => { - debug!("TextRunScanner: pushing single non-text box in range: %?", self.clump); + debug!("TextRunScanner: pushing single non-text box in range: {}", self.clump); out_boxes.push(in_boxes[self.clump.begin()]); }, (true, true) => { @@ -126,7 +126,7 @@ impl TextRunScanner { let fontgroup = ctx.font_ctx.get_resolved_font_for_style(&font_style); let run = @fontgroup.create_textrun(transformed_text, decoration); - debug!("TextRunScanner: pushing single text box in range: %? (%?)", self.clump, text); + debug!("TextRunScanner: pushing single text box in range: {} ({})", self.clump, text); let range = Range::new(0, run.char_len()); let new_box = @TextRenderBox::new((*old_box.base()).clone(), run, range); @@ -185,12 +185,12 @@ impl TextRunScanner { }; // Make new boxes with the run and adjusted text indices. - debug!("TextRunScanner: pushing box(es) in range: %?", self.clump); + debug!("TextRunScanner: pushing box(es) in range: {}", self.clump); 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 \ - compression; %s", + compression; {:s}", in_boxes[i].debug_str()); continue } @@ -205,19 +205,19 @@ impl TextRunScanner { debug!("--- In boxes: ---"); for (i, box) in in_boxes.iter().enumerate() { - debug!("%u --> %s", i, box.debug_str()); + debug!("{:u} --> {:s}", i, box.debug_str()); } debug!("------------------"); debug!("--- Out boxes: ---"); for (i, box) in out_boxes.iter().enumerate() { - debug!("%u --> %s", i, box.debug_str()); + debug!("{:u} --> {:s}", i, box.debug_str()); } debug!("------------------"); debug!("--- Elem ranges: ---"); for (i, nr) in inline.elems.eachi() { - debug!("%u: %? --> %s", i, nr.range, nr.node.debug_str()); () + debug!("{:u}: {} --> {:s}", i, nr.range, nr.node.debug_str()); () } debug!("--------------------"); diff --git a/servo/src/components/main/layout/util.rs b/servo/src/components/main/layout/util.rs index 7701aa2bd66b..cf6d38ee7a06 100644 --- a/servo/src/components/main/layout/util.rs +++ b/servo/src/components/main/layout/util.rs @@ -51,19 +51,19 @@ impl ElementMapping { debug!("--- Old boxes: ---"); for (i, box) in old_boxes.iter().enumerate() { - debug!("%u --> %s", i, box.debug_str()); + debug!("{:u} --> {:s}", i, box.debug_str()); } debug!("------------------"); debug!("--- New boxes: ---"); for (i, box) in new_boxes.iter().enumerate() { - debug!("%u --> %s", i, box.debug_str()); + debug!("{:u} --> {:s}", i, box.debug_str()); } debug!("------------------"); debug!("--- Elem ranges before repair: ---"); for (i, nr) in entries.iter().enumerate() { - debug!("%u: %? --> %s", i, nr.range, nr.node.debug_str()); + debug!("{:u}: {} --> {:s}", i, nr.range, nr.node.debug_str()); } debug!("----------------------------------"); @@ -80,17 +80,17 @@ impl ElementMapping { let mut entries_k = 0; while old_i < old_boxes.len() { - debug!("repair_for_box_changes: Considering old box %u", old_i); + debug!("repair_for_box_changes: Considering old box {:u}", old_i); // possibly push several items while entries_k < entries.len() && old_i == entries[entries_k].range.begin() { let item = WorkItem {begin_idx: new_j, entry_idx: entries_k}; - debug!("repair_for_box_changes: Push work item for elem %u: %?", entries_k, item); + debug!("repair_for_box_changes: Push work item for elem {:u}: {:?}", entries_k, item); repair_stack.push(item); entries_k += 1; } while new_j < new_boxes.len() && old_boxes[old_i].base().node != new_boxes[new_j].base().node { - debug!("repair_for_box_changes: Slide through new box %u", new_j); + debug!("repair_for_box_changes: Slide through new box {:u}", new_j); new_j += 1; } @@ -99,14 +99,14 @@ impl ElementMapping { // possibly pop several items while repair_stack.len() > 0 && old_i == entries[repair_stack.last().entry_idx].range.end() { let item = repair_stack.pop(); - debug!("repair_for_box_changes: Set range for %u to %?", + debug!("repair_for_box_changes: Set range for {:u} to {}", item.entry_idx, Range::new(item.begin_idx, new_j - item.begin_idx)); entries[item.entry_idx].range = Range::new(item.begin_idx, new_j - item.begin_idx); } } debug!("--- Elem ranges after repair: ---"); for (i, nr) in entries.iter().enumerate() { - debug!("%u: %? --> %s", i, nr.range, nr.node.debug_str()); + debug!("{:u}: {} --> {:s}", i, nr.range, nr.node.debug_str()); } debug!("----------------------------------"); } diff --git a/servo/src/components/main/pipeline.rs b/servo/src/components/main/pipeline.rs index 9c89a07fb4e7..7b619de378ab 100644 --- a/servo/src/components/main/pipeline.rs +++ b/servo/src/components/main/pipeline.rs @@ -101,9 +101,8 @@ impl Pipeline { // Wrap task creation within a supervised task so that failure will // only tear down those tasks instead of ours. let failure_chan = constellation_chan.clone(); - let (task_port, task_chan) = stream::(); let mut supervised_task = task::task(); - supervised_task.opts.notify_chan = Some(task_chan); + let task_port = supervised_task.future_result(); supervised_task.supervised(); spawn_with!(supervised_task, [script_port, resource_task, size, render_port, @@ -138,8 +137,8 @@ impl Pipeline { spawn_with!(task::task(), [failure_chan], { match task_port.recv() { - task::Success => (), - task::Failure => { + Ok(*) => (), + Err(*) => { failure_chan.send(FailureMsg(id, subpage_id)); } } diff --git a/servo/src/components/main/platform/common/glfw_windowing.rs b/servo/src/components/main/platform/common/glfw_windowing.rs index 88032a221b47..023b816f892f 100644 --- a/servo/src/components/main/platform/common/glfw_windowing.rs +++ b/servo/src/components/main/platform/common/glfw_windowing.rs @@ -30,7 +30,7 @@ impl ApplicationMethods for Application { // Per GLFW docs it's safe to set the error callback before calling // glfwInit(), and this way we notice errors from init too. do glfw::set_error_callback |_error_code, description| { - error!("GLFW error: %s", description); + error!("GLFW error: {:s}", description); }; glfw::init(); Application @@ -190,18 +190,18 @@ impl Window { match self.ready_state { Blank => { - self.glfw_window.set_title(fmt!("blank — Servo")) + self.glfw_window.set_title("blank — Servo") } Loading => { - self.glfw_window.set_title(fmt!("Loading — Servo")) + self.glfw_window.set_title("Loading — Servo") } PerformingLayout => { - self.glfw_window.set_title(fmt!("Performing Layout — Servo")) + self.glfw_window.set_title("Performing Layout — Servo") } FinishedLoading => { match self.render_state { RenderingRenderState => { - self.glfw_window.set_title(fmt!("Rendering — Servo")) + self.glfw_window.set_title("Rendering — Servo") } IdleRenderState => { self.glfw_window.set_title("Servo") diff --git a/servo/src/components/main/platform/common/glut_windowing.rs b/servo/src/components/main/platform/common/glut_windowing.rs index 5f9c47853536..3fb0f055813f 100644 --- a/servo/src/components/main/platform/common/glut_windowing.rs +++ b/servo/src/components/main/platform/common/glut_windowing.rs @@ -162,18 +162,18 @@ impl Window { let throbber = THROBBER[self.throbber_frame]; match self.ready_state { Blank => { - glut::set_window_title(self.glut_window, fmt!("Blank")) + glut::set_window_title(self.glut_window, "Blank") } Loading => { - glut::set_window_title(self.glut_window, fmt!("%c Loading . Servo", throbber)) + glut::set_window_title(self.glut_window, format!("{:c} Loading . Servo", throbber)) } PerformingLayout => { - glut::set_window_title(self.glut_window, fmt!("%c Performing Layout . Servo", throbber)) + glut::set_window_title(self.glut_window, format!("{:c} Performing Layout . Servo", throbber)) } FinishedLoading => { match self.render_state { RenderingRenderState => { - glut::set_window_title(self.glut_window, fmt!("%c Rendering . Servo", throbber)) + glut::set_window_title(self.glut_window, format!("{:c} Rendering . Servo", throbber)) } IdleRenderState => glut::set_window_title(self.glut_window, "Servo"), } @@ -183,7 +183,7 @@ impl Window { /// Helper function to handle keyboard events. fn handle_key(&self, key: u8) { - debug!("got key: %?", key); + debug!("got key: {}", key); let modifiers = glut::get_modifiers(); match key { 42 => self.load_url(), diff --git a/servo/src/components/main/platform/common/shared_gl_windowing.rs b/servo/src/components/main/platform/common/shared_gl_windowing.rs index f77dfbed362c..820e8434a5f6 100644 --- a/servo/src/components/main/platform/common/shared_gl_windowing.rs +++ b/servo/src/components/main/platform/common/shared_gl_windowing.rs @@ -33,7 +33,7 @@ impl WindowingMethods for Window { /// Creates a new window. pub fn new(_: &Application) -> @mut Window { let share_context: Context = ShareContext::new(Size2D(800, 600)); - println(fmt!("Sharing ID is %d", share_context.id())); + println(format!("Sharing ID is {:d}", share_context.id())); @mut Window(share_context) } diff --git a/servo/src/components/main/servo.rc b/servo/src/components/main/servo.rc index f09114c4080a..268878167b0f 100755 --- a/servo/src/components/main/servo.rc +++ b/servo/src/components/main/servo.rc @@ -11,7 +11,7 @@ #[license = "MPL"]; #[crate_type = "lib"]; -#[feature(globs, macro_rules)]; +#[feature(globs, macro_rules, managed_boxes)]; extern mod alert; extern mod azure; diff --git a/servo/src/components/net/file_loader.rs b/servo/src/components/net/file_loader.rs index 40588cad275a..379cd3e5ffba 100644 --- a/servo/src/components/net/file_loader.rs +++ b/servo/src/components/net/file_loader.rs @@ -3,8 +3,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use resource_task::{Metadata, Payload, Done, LoaderTask, start_sending}; +use servo_util::io::ignoring_eof; -use std::io::{ReaderUtil, file_reader}; +use std::rt::io; +use std::rt::io::Reader; use std::task; static READ_SIZE: uint = 1024; @@ -14,15 +16,17 @@ pub fn factory() -> LoaderTask { assert!("file" == url.scheme); let progress_chan = start_sending(start_chan, Metadata::default(url.clone())); do task::spawn { - match file_reader(&from_str(url.path).unwrap()) { - Ok(reader) => { + match io::file::open(&url.path.as_slice(), io::Open, io::Read) { + Some(mut reader) => { while !reader.eof() { - let data = reader.read_bytes(READ_SIZE); - progress_chan.send(Payload(data)); + do ignoring_eof { + let data = reader.read_bytes(READ_SIZE); + progress_chan.send(Payload(data)); + } } progress_chan.send(Done(Ok(()))); } - Err(*) => { + None => { progress_chan.send(Done(Err(()))); } }; diff --git a/servo/src/components/net/http_loader.rs b/servo/src/components/net/http_loader.rs index 23763775a812..7529115d70dd 100644 --- a/servo/src/components/net/http_loader.rs +++ b/servo/src/components/net/http_loader.rs @@ -24,7 +24,7 @@ pub fn factory() -> LoaderTask { fn load(url: Url, start_chan: Chan) { assert!("http" == url.scheme); - info!("requesting %s", url.to_str()); + info!("requesting {:s}", url.to_str()); let request = ~RequestWriter::new(Get, url.clone()); let mut response = match request.read_response() { @@ -36,17 +36,17 @@ fn load(url: Url, start_chan: Chan) { }; // Dump headers, but only do the iteration if info!() is enabled. - info!("got HTTP response %s, headers:", response.status.to_str()); - info!("%?", + info!("got HTTP response {:s}, headers:", response.status.to_str()); + info!("{:?}", for header in response.headers.iter() { - info!(" - %s: %s", header.header_name(), header.header_value()); + info!(" - {:s}: {:s}", header.header_name(), header.header_value()); }); // FIXME: detect redirect loops if 3 == (response.status.code() / 100) { match response.headers.location { Some(url) => { - info!("redirecting to %s", url.to_str()); + info!("redirecting to {:s}", url.to_str()); return load(url, start_chan); } None => () diff --git a/servo/src/components/net/image/base.rs b/servo/src/components/net/image/base.rs index 69214cede156..7b2bbe2f22bc 100644 --- a/servo/src/components/net/image/base.rs +++ b/servo/src/components/net/image/base.rs @@ -14,10 +14,10 @@ pub fn Image(width: uint, height: uint, depth: uint, data: ~[u8]) -> Image { stb_image::new_image(width, height, depth, data) } -static TEST_IMAGE: [u8, ..4962] = include_bin!("test.jpeg"); +static TEST_IMAGE: &'static [u8] = include_bin!("test.jpeg"); pub fn test_image_bin() -> ~[u8] { - return vec::from_fn(4962, |i| TEST_IMAGE[i]); + TEST_IMAGE.into_owned() } pub fn load_from_memory(buffer: &[u8]) -> Option { diff --git a/servo/src/components/net/image/holder.rs b/servo/src/components/net/image/holder.rs index 096c07b2f19d..c394f0f147ab 100644 --- a/servo/src/components/net/image/holder.rs +++ b/servo/src/components/net/image/holder.rs @@ -26,7 +26,7 @@ pub struct ImageHolder { impl ImageHolder { pub fn new(url: Url, local_image_cache: @mut LocalImageCache) -> ImageHolder { - debug!("ImageHolder::new() %?", url.to_str()); + debug!("ImageHolder::new() {}", url.to_str()); let holder = ImageHolder { url: url, image: None, @@ -56,7 +56,7 @@ impl ImageHolder { /// Query and update the current image size. pub fn get_size(&mut self) -> Option> { - debug!("get_size() %?", self.url); + debug!("get_size() {}", self.url.to_str()); do self.get_image().map |img| { let img_ref = img.get(); self.cached_size = Size2D(img_ref.width as int, @@ -66,7 +66,7 @@ impl ImageHolder { } pub fn get_image(&mut self) -> Option> { - debug!("get_image() %?", self.url); + debug!("get_image() {}", self.url.to_str()); // If this is the first time we've called this function, load // the image and store it for the future @@ -76,10 +76,10 @@ impl ImageHolder { self.image = Some(image); } ImageNotReady => { - debug!("image not ready for %s", self.url.to_str()); + debug!("image not ready for {:s}", self.url.to_str()); } ImageFailed => { - debug!("image decoding failed for %s", self.url.to_str()); + debug!("image decoding failed for {:s}", self.url.to_str()); } } } diff --git a/servo/src/components/net/image_cache_task.rs b/servo/src/components/net/image_cache_task.rs index 299456ad44a3..bdf7e1d94045 100644 --- a/servo/src/components/net/image_cache_task.rs +++ b/servo/src/components/net/image_cache_task.rs @@ -188,7 +188,7 @@ impl ImageCache { (*handler)(&msg) } - debug!("image_cache_task: received: %?", msg); + debug!("image_cache_task: received: {:?}", msg); match msg { Prefetch(url) => self.prefetch(url), @@ -256,7 +256,7 @@ impl ImageCache { do spawn { let url = url_cell.take(); - debug!("image_cache_task: started fetch for %s", url.to_str()); + debug!("image_cache_task: started fetch for {:s}", url.to_str()); let image = load_image_data(url.clone(), resource_task.clone()); @@ -266,7 +266,7 @@ impl ImageCache { Err(()) }; to_cache.send(StorePrefetchedImageData(url.clone(), result)); - debug!("image_cache_task: ended fetch for %s", (url.clone()).to_str()); + debug!("image_cache_task: ended fetch for {:s}", (url.clone()).to_str()); } self.set_state(url, Prefetching(DoNotDecode)); @@ -330,7 +330,7 @@ impl ImageCache { do spawn { let url = url_cell.take(); - debug!("image_cache_task: started image decode for %s", url.to_str()); + debug!("image_cache_task: started image decode for {:s}", url.to_str()); let image = decode(data); let image = if image.is_some() { Some(Arc::new(~image.unwrap())) @@ -338,7 +338,7 @@ impl ImageCache { None }; to_cache.send(StoreImage(url.clone(), image)); - debug!("image_cache_task: ended image decode for %s", url.to_str()); + debug!("image_cache_task: ended image decode for {:s}", url.to_str()); } self.set_state(url, Decoding); diff --git a/servo/src/components/net/net.rc b/servo/src/components/net/net.rc index 623a530cecbe..b8df8855e318 100644 --- a/servo/src/components/net/net.rc +++ b/servo/src/components/net/net.rc @@ -8,7 +8,7 @@ url = "http://servo.org/")]; #[crate_type = "lib"]; -#[feature(globs)]; +#[feature(globs, managed_boxes)]; extern mod geom; extern mod http; diff --git a/servo/src/components/net/resource_task.rs b/servo/src/components/net/resource_task.rs index 02ae1c715d91..94d074e91b77 100644 --- a/servo/src/components/net/resource_task.rs +++ b/servo/src/components/net/resource_task.rs @@ -178,11 +178,11 @@ impl ResourceManager { fn load(&self, url: Url, start_chan: Chan) { match self.get_loader_factory(&url) { Some(loader_factory) => { - debug!("resource_task: loading url: %s", url.to_str()); + debug!("resource_task: loading url: {:s}", url.to_str()); loader_factory(url, start_chan); } None => { - debug!("resource_task: no loader for scheme %s", url.scheme); + debug!("resource_task: no loader for scheme {:s}", url.scheme); start_sending(start_chan, Metadata::default(url)).send(Done(Err(()))); } } diff --git a/servo/src/components/script/dom/bindings/codegen/CodegenRust.py b/servo/src/components/script/dom/bindings/codegen/CodegenRust.py index 18e590fc30d3..5734df036c6f 100644 --- a/servo/src/components/script/dom/bindings/codegen/CodegenRust.py +++ b/servo/src/components/script/dom/bindings/codegen/CodegenRust.py @@ -4025,7 +4025,7 @@ def finalizeHook(descriptor, hookName, context): assert descriptor.nativeIsISupports release = """let val = JS_GetReservedSlot(obj, dom_object_slot(obj)); let _: @mut %s = cast::transmute(RUST_JSVAL_TO_PRIVATE(val)); -debug!("%s finalize: %%p", this); +debug!("%s finalize: {:p}", this); """ % (descriptor.concreteType, descriptor.concreteType) #return clearWrapper + release return release diff --git a/servo/src/components/script/dom/bindings/node.rs b/servo/src/components/script/dom/bindings/node.rs index e2d10ec6387c..09f17770c56d 100644 --- a/servo/src/components/script/dom/bindings/node.rs +++ b/servo/src/components/script/dom/bindings/node.rs @@ -127,7 +127,7 @@ impl Traceable for Node { if node.is_none() { return; } - debug!("tracing %s", name); + debug!("tracing {:s}", name); let node = node.unwrap(); let obj = node.reflector().get_jsobject(); assert!(obj.is_not_null()); @@ -140,7 +140,7 @@ impl Traceable for Node { } } } - debug!("tracing %p?:", self.reflector_.get_jsobject()); + debug!("tracing {:p}?:", self.reflector_.get_jsobject()); trace_node(tracer, self.parent_node, "parent"); trace_node(tracer, self.first_child, "first child"); trace_node(tracer, self.last_child, "last child"); diff --git a/servo/src/components/script/dom/node.rs b/servo/src/components/script/dom/node.rs index 43178101e01a..725d69e711ff 100644 --- a/servo/src/components/script/dom/node.rs +++ b/servo/src/components/script/dom/node.rs @@ -425,7 +425,7 @@ impl<'self, View> AbstractNode { } s.push_str(self.debug_str()); - debug!("%s", s); + debug!("{:s}", s); // FIXME: this should have a pure version? for kid in self.children() { @@ -435,7 +435,7 @@ impl<'self, View> AbstractNode { /// Returns a string that describes this node. pub fn debug_str(&self) -> ~str { - fmt!("%?", self.type_id()) + format!("{:?}", self.type_id()) } pub fn children(&self) -> AbstractNodeChildrenIterator { diff --git a/servo/src/components/script/dom/window.rs b/servo/src/components/script/dom/window.rs index 8f9994458fbd..0a5bb19d3ecf 100644 --- a/servo/src/components/script/dom/window.rs +++ b/servo/src/components/script/dom/window.rs @@ -23,7 +23,6 @@ use std::cell::Cell; use std::comm; use std::comm::SharedChan; use std::hashmap::HashSet; -use std::io; use std::ptr; use std::int; use std::libc; @@ -74,7 +73,7 @@ pub struct TimerData { impl Window { pub fn Alert(&self, s: &DOMString) { // Right now, just print to the console - io::println(fmt!("ALERT: %s", null_str_as_empty(s))); + println(format!("ALERT: {:s}", null_str_as_empty(s))); } pub fn Close(&self) { diff --git a/servo/src/components/script/html/cssparse.rs b/servo/src/components/script/html/cssparse.rs index bfe1d984171e..ade3b58ed699 100644 --- a/servo/src/components/script/html/cssparse.rs +++ b/servo/src/components/script/html/cssparse.rs @@ -35,7 +35,7 @@ pub fn spawn_css_parser(provenance: StylesheetProvenance, let sheet = match provenance_cell.take() { UrlProvenance(url) => { - debug!("cssparse: loading style sheet at %s", url.to_str()); + debug!("cssparse: loading style sheet at {:s}", url.to_str()); let (input_port, input_chan) = comm::stream(); resource_task.send(Load(url, input_chan)); Stylesheet::from_iter(ProgressMsgPortIterator { diff --git a/servo/src/components/script/html/hubbub_html_parser.rs b/servo/src/components/script/html/hubbub_html_parser.rs index c0da70de9834..b1f8cc964841 100644 --- a/servo/src/components/script/html/hubbub_html_parser.rs +++ b/servo/src/components/script/html/hubbub_html_parser.rs @@ -118,7 +118,6 @@ pub enum HtmlDiscoveryMessage { pub struct HtmlParserResult { root: AbstractNode, discovery_port: Port, - url: Url, } trait NodeWrapping { @@ -183,7 +182,7 @@ fn js_script_listener(to_parent: SharedChan, JSTaskNewFile(url) => { match load_whole_resource(&resource_task, url.clone()) { Err(_) => { - error!("error loading script %s", url.to_str()); + error!("error loading script {:s}", url.to_str()); } Ok((metadata, bytes)) => { result_vec.push(JSFile { @@ -299,7 +298,7 @@ pub fn parse_html(cx: *JSContext, image_cache_task: ImageCacheTask, next_subpage_id: SubpageId, constellation_chan: ConstellationChan) -> HtmlParserResult { - debug!("Hubbub: parsing %?", url); + debug!("Hubbub: parsing {:?}", url); // Spawn a CSS parser to receive links to CSS style sheets. let resource_task2 = resource_task.clone(); @@ -330,11 +329,22 @@ pub fn parse_html(cx: *JSContext, resource_task.send(Load(url.clone(), input_chan)); let load_response = input_port.recv(); - debug!("Fetched page; metadata is %?", load_response.metadata); + debug!("Fetched page; metadata is {:?}", load_response.metadata); let url2 = load_response.metadata.final_url.clone(); let url3 = url2.clone(); + // Store the final URL before we start parsing, so that DOM routines + // (e.g. HTMLImageElement::update_image) can resolve relative URLs + // correctly. + // + // FIXME: is this safe? When we instead pass an &mut Page to parse_html, + // we crash with a dynamic borrow failure. + let page = page_from_context(cx); + unsafe { + (*page).url = Some((url2.clone(), true)); + } + // Build the root node. let root = @HTMLHtmlElement { htmlelement: HTMLElement::new(HTMLHtmlElementTypeId, ~"html", document) }; let root = unsafe { Node::as_abstract_node(cx, root) }; @@ -390,7 +400,7 @@ pub fn parse_html(cx: *JSContext, match (element.get_attr("rel"), element.get_attr("href")) { (Some(rel), Some(href)) => { if rel == "stylesheet" { - debug!("found CSS stylesheet: %s", href); + debug!("found CSS stylesheet: {:s}", href); let url = make_url(href.to_str(), Some(url2.clone())); css_chan2.send(CSSTaskNewFile(UrlProvenance(url))); } @@ -459,7 +469,7 @@ pub fn parse_html(cx: *JSContext, unref_node: |_| {}, append_child: |parent: hubbub::NodeDataPtr, child: hubbub::NodeDataPtr| { unsafe { - debug!("append child %x %x", cast::transmute(parent), cast::transmute(child)); + debug!("append child {:x} {:x}", parent, child); let parent: AbstractNode = NodeWrapping::from_hubbub_node(parent); let child: AbstractNode = NodeWrapping::from_hubbub_node(child); // FIXME this needs to be AppendChild. @@ -512,21 +522,21 @@ pub fn parse_html(cx: *JSContext, do scriptnode.with_imm_element |script| { match script.get_attr("src") { Some(src) => { - debug!("found script: %s", src); + debug!("found script: {:s}", src); let new_url = make_url(src.to_str(), Some(url3.clone())); js_chan2.send(JSTaskNewFile(new_url)); } None => { let mut data = ~[]; - debug!("iterating over children %?", scriptnode.first_child()); + debug!("iterating over children {:?}", scriptnode.first_child()); for child in scriptnode.children() { - debug!("child = %?", child); + debug!("child = {:?}", child); do child.with_imm_text() |text| { data.push(text.element.data.to_str()); // FIXME: Bad copy. } } - debug!("script data = %?", data); + debug!("script data = {:?}", data); js_chan2.send(JSTaskNewInlineScript(data.concat(), url3.clone())); } } @@ -542,15 +552,15 @@ pub fn parse_html(cx: *JSContext, let url_cell = Cell::new(url); let mut data = ~[]; - debug!("iterating over children %?", style.first_child()); + debug!("iterating over children {:?}", style.first_child()); for child in style.children() { - debug!("child = %?", child); + debug!("child = {:?}", child); do child.with_imm_text() |text| { data.push(text.element.data.to_str()); // FIXME: Bad copy. } } - debug!("style data = %?", data); + debug!("style data = {:?}", data); let provenance = InlineProvenance(url_cell.take().unwrap(), data.concat()); css_chan3.send(CSSTaskNewFile(provenance)); } @@ -566,7 +576,7 @@ pub fn parse_html(cx: *JSContext, parser.parse_chunk(data); } Done(Err(*)) => { - fail!("Failed to load page URL %s", url.to_str()); + fail!("Failed to load page URL {:s}", url.to_str()); } Done(*) => { break; @@ -580,7 +590,6 @@ pub fn parse_html(cx: *JSContext, HtmlParserResult { root: root, discovery_port: discovery_port, - url: load_response.metadata.final_url, } } diff --git a/servo/src/components/script/script.rc b/servo/src/components/script/script.rc index cf376f08fcd7..bef239a5ec9c 100644 --- a/servo/src/components/script/script.rc +++ b/servo/src/components/script/script.rc @@ -11,7 +11,7 @@ #[license = "MPL"]; #[crate_type = "lib"]; -#[feature(globs, macro_rules, struct_variant)]; +#[feature(globs, macro_rules, struct_variant, managed_boxes)]; extern mod geom; extern mod gfx (name = "gfx"); diff --git a/servo/src/components/script/script_task.rs b/servo/src/components/script/script_task.rs index b17449ab0ba9..fed211c1fce3 100644 --- a/servo/src/components/script/script_task.rs +++ b/servo/src/components/script/script_task.rs @@ -282,7 +282,7 @@ impl Page { match root { None => {}, Some(root) => { - debug!("script: performing reflow for goal %?", goal); + debug!("script: performing reflow for goal {:?}", goal); // Now, join the layout so that they will see the latest changes we have made. self.join_layout(); @@ -541,7 +541,7 @@ impl ScriptTask { } fn handle_new_layout(&mut self, new_layout_info: NewLayoutInfo) { - debug!("Script: new layout: %?", new_layout_info); + debug!("Script: new layout: {:?}", new_layout_info); let NewLayoutInfo { old_id, new_id, @@ -588,7 +588,7 @@ impl ScriptTask { /// Handles a notification that reflow completed. fn handle_reflow_complete_msg(&mut self, pipeline_id: PipelineId, reflow_id: uint) { - debug!("Script: Reflow %? complete for %?", reflow_id, pipeline_id); + debug!("Script: Reflow {:?} complete for {:?}", reflow_id, pipeline_id); let page_tree = self.page_tree.find(pipeline_id).expect( "ScriptTask: received a load message for a layout channel that is not associated \ with this script task. This is a bug."); @@ -656,7 +656,7 @@ impl ScriptTask { /// The entry point to document loading. Defines bindings, sets up the window and document /// objects, parses HTML and CSS, and kicks off initial layout. fn load(&mut self, pipeline_id: PipelineId, url: Url) { - debug!("ScriptTask: loading %? on page %?", url, pipeline_id); + debug!("ScriptTask: loading {:?} on page {:?}", url, pipeline_id); let page = self.page_tree.find(pipeline_id).expect("ScriptTask: received a load message for a layout channel that is not associated with this script task. This @@ -699,14 +699,13 @@ impl ScriptTask { self.constellation_chan.clone()); - let HtmlParserResult {root, discovery_port, url: final_url} = html_parsing_result; + let HtmlParserResult {root, discovery_port} = html_parsing_result; // Create the root frame. page.frame = Some(Frame { document: document, window: window, }); - page.url = Some((final_url, true)); // Send style sheets over to layout. // @@ -752,7 +751,7 @@ impl ScriptTask { // Receive the JavaScript scripts. assert!(js_scripts.is_some()); let js_scripts = js_scripts.take_unwrap(); - debug!("js_scripts: %?", js_scripts); + debug!("js_scripts: {:?}", js_scripts); // Define debug functions. let compartment = page.js_info.get_ref().js_compartment; @@ -778,7 +777,7 @@ impl ScriptTask { match event { ResizeEvent(new_width, new_height) => { - debug!("script got resize event: %u, %u", new_width, new_height); + debug!("script got resize event: {:u}, {:u}", new_width, new_height); page.window_size = Future::from_value(Size2D(new_width, new_height)); @@ -799,7 +798,7 @@ impl ScriptTask { } ClickEvent(_button, point) => { - debug!("ClickEvent: clicked at %?", point); + debug!("ClickEvent: clicked at {:?}", point); let document = page.frame.expect("root frame is None").document; let root = document.document().GetDocumentElement(); @@ -810,7 +809,7 @@ impl ScriptTask { match page.query_layout(HitTestQuery(root.unwrap(), point, chan), port) { Ok(node) => match node { HitTestResponse(node) => { - debug!("clicked on %s", node.debug_str()); + debug!("clicked on {:s}", node.debug_str()); let mut node = node; // traverse node generations until a node that is an element is found while !node.is_element() { @@ -831,7 +830,7 @@ impl ScriptTask { } }, Err(()) => { - debug!(fmt!("layout query error")); + debug!("layout query error"); } } } @@ -844,11 +843,11 @@ impl ScriptTask { // if the node's element is "a," load url from href attr let attr = element.get_attr("href"); for href in attr.iter() { - debug!("ScriptTask: clicked on link to %s", *href); + debug!("ScriptTask: clicked on link to {:s}", *href); let current_url = do page.url.as_ref().map |&(ref url, _)| { url.clone() }; - debug!("ScriptTask: current url is %?", current_url); + debug!("ScriptTask: current url is {:?}", current_url); let url = make_url(href.to_owned(), current_url); self.constellation_chan.send(LoadUrlMsg(page.id, url, Future::from_value(page.window_size.get()))); } diff --git a/servo/src/components/style/errors.rs b/servo/src/components/style/errors.rs index 2a60f66dca86..fdbf1c5167b6 100644 --- a/servo/src/components/style/errors.rs +++ b/servo/src/components/style/errors.rs @@ -12,7 +12,7 @@ impl>> Iterator for ErrorLoggerIterator for result in **self { match result { Ok(v) => return Some(v), - Err(error) => log_css_error(error.location, fmt!("%?", error.reason)) + Err(error) => log_css_error(error.location, format!("{:?}", error.reason)) } } None @@ -22,5 +22,5 @@ impl>> Iterator for ErrorLoggerIterator pub fn log_css_error(location: SourceLocation, message: &str) { // TODO eventually this will got into a "web console" or something. - info!("%u:%u %s", location.line, location.column, message) + info!("{:u}:{:u} {:s}", location.line, location.column, message) } diff --git a/servo/src/components/style/properties.rs.mako b/servo/src/components/style/properties.rs.mako index 540dac317e47..01bbb2f556fb 100644 --- a/servo/src/components/style/properties.rs.mako +++ b/servo/src/components/style/properties.rs.mako @@ -857,7 +857,7 @@ pub fn parse_property_declaration_list>(input: I) -> PropertyD for item in ErrorLoggerIterator(parse_declaration_list(input)) { match item { Decl_AtRule(rule) => log_css_error( - rule.location, fmt!("Unsupported at-rule in declaration list: @%s", rule.name)), + rule.location, format!("Unsupported at-rule in declaration list: @{:s}", rule.name)), Declaration(Declaration{ location: l, name: n, value: v, important: i}) => { // TODO: only keep the last valid declaration for a given name. let list = if i { &mut important } else { &mut normal }; diff --git a/servo/src/components/style/style.rc b/servo/src/components/style/style.rc index d005e81bd700..6fe31302f7cf 100644 --- a/servo/src/components/style/style.rc +++ b/servo/src/components/style/style.rc @@ -11,7 +11,7 @@ #[license = "MPL"]; #[crate_type = "lib"]; -#[feature(globs, macro_rules)]; +#[feature(globs, macro_rules, managed_boxes)]; extern mod extra; extern mod cssparser; diff --git a/servo/src/components/style/stylesheets.rs b/servo/src/components/style/stylesheets.rs index 7709e551549e..424d1c5b0d76 100644 --- a/servo/src/components/style/stylesheets.rs +++ b/servo/src/components/style/stylesheets.rs @@ -127,7 +127,7 @@ pub fn parse_nested_at_rule(lower_name: &str, rule: AtRule, parent_rules: &mut ~[CSSRule], namespaces: &NamespaceMap) { match lower_name { "media" => parse_media_rule(rule, parent_rules, namespaces), - _ => log_css_error(rule.location, fmt!("Unsupported at-rule: @%s", lower_name)) + _ => log_css_error(rule.location, format!("Unsupported at-rule: @{:s}", lower_name)) } } diff --git a/servo/src/components/util/debug.rs b/servo/src/components/util/debug.rs index 67a1d7d5f21b..5c9aa700d5be 100644 --- a/servo/src/components/util/debug.rs +++ b/servo/src/components/util/debug.rs @@ -2,30 +2,32 @@ * 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::io; +use std::rt::io; +use std::rt::io::Writer; use std::vec::raw::buf_as_slice; use std::cast::transmute; use std::mem::size_of; fn hexdump_slice(buf: &[u8]) { - let stderr = io::stderr(); - stderr.write_str(" "); + let mut stderr = io::stderr(); + stderr.write(bytes!(" ")); for (i, &v) in buf.iter().enumerate() { - stderr.write_str(fmt!("%02X ", v as uint)); + let output = format!("{:02X} ", v as uint); + stderr.write(output.as_bytes()); match i % 16 { - 15 => stderr.write_str("\n "), - 7 => stderr.write_str(" "), + 15 => stderr.write(bytes!("\n ")), + 7 => stderr.write(bytes!(" ")), _ => () } stderr.flush(); } - stderr.write_char('\n'); + stderr.write(bytes!("\n")); } pub fn hexdump(obj: &T) { unsafe { let buf: *u8 = transmute(obj); - debug!("dumping at %p", buf); + debug!("dumping at {:p}", buf); buf_as_slice(buf, size_of::(), hexdump_slice); } } diff --git a/servo/src/components/util/geometry.rs b/servo/src/components/util/geometry.rs index febb33660f46..ed0dcd5c4205 100644 --- a/servo/src/components/util/geometry.rs +++ b/servo/src/components/util/geometry.rs @@ -7,6 +7,7 @@ use geom::rect::Rect; use geom::size::Size2D; use std::num::{NumCast, One, Zero}; +use std::fmt; pub struct Au(i32); @@ -18,6 +19,12 @@ impl Clone for Au { } } +impl fmt::Default for Au { + fn fmt(obj: &Au, f: &mut fmt::Formatter) { + write!(f.buf, "Au({})", *obj); + } +} + impl Eq for Au { #[inline] fn eq(&self, other: &Au) -> bool { diff --git a/servo/src/components/util/io.rs b/servo/src/components/util/io.rs new file mode 100644 index 000000000000..9fa4dda4a4f4 --- /dev/null +++ b/servo/src/components/util/io.rs @@ -0,0 +1,14 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * 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::rt::io::{io_error, EndOfFile}; + +/// Ignore the end-of-file condition within a block of code. +pub fn ignoring_eof(cb: &fn() -> U) -> U { + io_error::cond.trap(|e| + match e.kind { + EndOfFile => (), + _ => io_error::cond.raise(e) + }).inside(cb) +} diff --git a/servo/src/components/util/range.rs b/servo/src/components/util/range.rs index e52dbae02abf..c256ce3d1c80 100644 --- a/servo/src/components/util/range.rs +++ b/servo/src/components/util/range.rs @@ -4,6 +4,7 @@ use std::cmp::{max, min}; use std::iter; +use std::fmt; enum RangeRelation { OverlapsBegin(/* overlap */ uint), @@ -21,6 +22,12 @@ pub struct Range { priv len: uint } +impl fmt::Default for Range { + fn fmt(obj: &Range, f: &mut fmt::Formatter) { + write!(f.buf, "[{} .. {})", obj.begin(), obj.end()); + } +} + impl Range { #[inline] pub fn new(off: uint, len: uint) -> Range { @@ -131,15 +138,15 @@ impl Range { let overlap = other.end() - self.begin(); return OverlapsEnd(overlap); } - fail!(fmt!("relation_to_range(): didn't classify self=%?, other=%?", - self, other)); + fail!("relation_to_range(): didn't classify self={:?}, other={:?}", + self, other); } #[inline] pub fn repair_after_coalesced_range(&mut self, other: &Range) { let relation = self.relation_to_range(other); - debug!("repair_after_coalesced_range: possibly repairing range %?", self); - debug!("repair_after_coalesced_range: relation of original range and coalesced range(%?): %?", + debug!("repair_after_coalesced_range: possibly repairing range {:?}", self); + debug!("repair_after_coalesced_range: relation of original range and coalesced range({:?}): {:?}", other, relation); match relation { EntirelyBefore => { }, @@ -152,6 +159,6 @@ impl Range { self.reset(other.begin(), len); } }; - debug!("repair_after_coalesced_range: new range: ---- %?", self); + debug!("repair_after_coalesced_range: new range: ---- {:?}", self); } } diff --git a/servo/src/components/util/time.rs b/servo/src/components/util/time.rs index 9937dbd40e06..bfc1a1bd43c9 100644 --- a/servo/src/components/util/time.rs +++ b/servo/src/components/util/time.rs @@ -86,7 +86,7 @@ impl ProfilerCategory { LayoutMainCategory | LayoutDispListBuildCategory | LayoutShapingCategory=> " - ", _ => "" }; - fmt!("%s%?", padding, self) + format!("{:s}{:?}", padding, self) } } @@ -159,7 +159,7 @@ impl Profiler { } fn print_buckets(&mut self) { - println(fmt!("%31s %15s %15s %15s %15s %15s", + println(format!("{:31s} {:15s} {:15s} {:15s} {:15s} {:15s}", "_category_", "_mean (ms)_", "_median (ms)_", "_min (ms)_", "_max (ms)_", "_bucket size_")); for (category, data) in self.buckets.iter() { @@ -173,7 +173,7 @@ impl Profiler { data[data_len / 2], data.iter().min().unwrap(), data.iter().max().unwrap()); - println(fmt!("%-30s: %15.4f %15.4f %15.4f %15.4f %15u", + println(format!("{:-30s}: {:15.4f} {:15.4f} {:15.4f} {:15.4f} {:15u}", category.format(), mean, median, min, max, data_len)); } } @@ -200,7 +200,7 @@ pub fn time(msg: &str, callback: &fn() -> T) -> T{ let end_time = precise_time_ns(); let ms = ((end_time - start_time) as f64 / 1000000f64); if ms >= 5f64 { - debug!("%s took %? ms", msg, ms); + debug!("{:s} took {} ms", msg, ms); } return val; } diff --git a/servo/src/components/util/url.rs b/servo/src/components/util/url.rs index 309117081ecc..29385decd582 100644 --- a/servo/src/components/util/url.rs +++ b/servo/src/components/util/url.rs @@ -34,7 +34,7 @@ pub fn make_url(str_url: ~str, current_url: Option) -> Url { } } else { let current_url = current_url.unwrap(); - debug!("make_url: current_url: %?", current_url); + debug!("make_url: current_url: {:?}", current_url); if str_url.starts_with("//") { current_url.scheme + ":" + str_url } else if current_url.path.is_empty() || @@ -94,7 +94,7 @@ mod make_url_tests { fn should_create_absolute_file_url_if_current_url_is_none_and_str_url_looks_filey() { let file = ~"local.html"; let url = make_url(file, None); - debug!("url: %?", url); + debug!("url: {:?}", url); assert!(url.scheme == ~"file"); let path = os::getcwd(); // FIXME (#1094): not the right way to transform a path diff --git a/servo/src/components/util/util.rc b/servo/src/components/util/util.rc index c84a87b13e59..fd2110c839e7 100644 --- a/servo/src/components/util/util.rc +++ b/servo/src/components/util/util.rc @@ -8,7 +8,7 @@ url = "http://servo.org/")]; #[crate_type = "lib"]; -#[feature(macro_rules)]; +#[feature(macro_rules, managed_boxes)]; extern mod extra; extern mod geom; @@ -22,3 +22,4 @@ pub mod tree; pub mod url; pub mod vec; pub mod debug; +pub mod io; diff --git a/servo/src/components/util/vec.rs b/servo/src/components/util/vec.rs index 76ddb5cd9789..7682eeab2ae1 100644 --- a/servo/src/components/util/vec.rs +++ b/servo/src/components/util/vec.rs @@ -51,7 +51,7 @@ fn test_miss_all_elems(arr: &[T], misses: &[T]) { let mut i = 0; while i < misses.len() { let res = arr.binary_search(&misses[i]); - debug!("%? == %? ?", misses[i], res); + debug!("{:?} == {:?} ?", misses[i], res); assert!(!test_match(&misses[i], arr.binary_search(&misses[i]))); i += 1; } diff --git a/servo/src/test/harness/contenttest/contenttest.rs b/servo/src/test/harness/contenttest/contenttest.rs index 81c12b3a06e3..f9b17badd2a0 100644 --- a/servo/src/test/harness/contenttest/contenttest.rs +++ b/servo/src/test/harness/contenttest/contenttest.rs @@ -12,7 +12,7 @@ extern mod extra; use extra::test::{TestOpts, run_tests_console, TestDesc, TestDescAndFn, DynTestFn, DynTestName}; use extra::getopts::{getopts, reqopt}; -use std::{os, run, io, str}; +use std::{os, run, str}; use std::cell::Cell; use std::os::list_dir_path; @@ -89,7 +89,7 @@ fn run_test(file: ~str) { let infile = ~"file://" + path.display().to_str(); let res = run::process_output("./servo", [~"-z", infile]); let out = str::from_utf8(res.output); - io::print(out); + print(out); let lines: ~[&str] = out.split_iter('\n').collect(); for &line in lines.iter() { if line.contains("TEST-UNEXPECTED-FAIL") { diff --git a/servo/src/test/harness/reftest/reftest.rs b/servo/src/test/harness/reftest/reftest.rs index b8cdf83fdb76..2f83cf885830 100644 --- a/servo/src/test/harness/reftest/reftest.rs +++ b/servo/src/test/harness/reftest/reftest.rs @@ -11,11 +11,12 @@ extern mod std; extern mod extra; use std::cell::Cell; -use std::io; +use std::rt::io; +use std::rt::io::file; +use std::rt::io::Reader; use std::os; use std::run; -use extra::digest::Digest; -use extra::sha1::Sha1; +use std::str; use extra::test::{DynTestName, DynTestFn, TestDesc, TestOpts, TestDescAndFn}; use extra::test::run_tests_console; @@ -55,29 +56,31 @@ struct Reftest { kind: ReftestKind, left: ~str, right: ~str, + id: uint, } fn parse_lists(filenames: &[~str]) -> ~[TestDescAndFn] { let mut tests: ~[TestDescAndFn] = ~[]; + let mut next_id = 0; for file in filenames.iter() { let file_path = Path::new(file.clone()); - let contents = match io::read_whole_file_str(&file_path) { - Ok(x) => x, - Err(s) => fail!(s) + let contents = match file::open(&file_path, io::Open, io::Read) { + Some(mut f) => str::from_utf8(f.read_to_end()), + None => fail!("Could not open file") }; for line in contents.line_iter() { let parts: ~[&str] = line.split_iter(' ').filter(|p| !p.is_empty()).collect(); if parts.len() != 3 { - fail!(fmt!("reftest line: '%s' doesn't match 'KIND LEFT RIGHT'", line)); + fail!("reftest line: '{:s}' doesn't match 'KIND LEFT RIGHT'", line); } let kind = match parts[0] { "==" => Same, "!=" => Different, - _ => fail!(fmt!("reftest line: '%s' has invalid kind '%s'", - line, parts[0])) + _ => fail!("reftest line: '{:s}' has invalid kind '{:s}'", + line, parts[0]) }; let src_path = file_path.dir_path(); let src_dir = src_path.display().to_str(); @@ -89,8 +92,11 @@ fn parse_lists(filenames: &[~str]) -> ~[TestDescAndFn] { kind: kind, left: file_left, right: file_right, + id: next_id, }; + next_id += 1; + tests.push(make_test(reftest)); } } @@ -113,11 +119,8 @@ fn make_test(reftest: Reftest) -> TestDescAndFn { } fn check_reftest(reftest: Reftest) { - let id = gen_id(&reftest); - let left_filename = fmt!("/tmp/%s-left.png", id); - let right_filename = fmt!("/tmp/%s-right.png", id); - let left_path = Path::new(left_filename.clone()); - let right_path = Path::new(right_filename.clone()); + let left_filename = format!("/tmp/servo-reftest-{:06u}-left.png", reftest.id); + let right_filename = format!("/tmp/servo-reftest-{:06u}-right.png", reftest.id); let args = ~[~"-o", left_filename.clone(), reftest.left.clone()]; let mut process = run::Process::new("./servo", args, run::ProcessOptions::new()); @@ -130,42 +133,12 @@ fn check_reftest(reftest: Reftest) { // assert!(retval == 0); // check the pngs are bit equal - let left_sha = calc_hash(&left_path); - os::remove_file(&left_path); + let args = ~[left_filename.clone(), right_filename.clone()]; + let mut process = run::Process::new("cmp", args, run::ProcessOptions::new()); + let retval = process.finish(); - let right_sha = calc_hash(&right_path); - os::remove_file(&right_path); - - assert!(left_sha.is_some()); - assert!(right_sha.is_some()); match reftest.kind { - Same => assert!(left_sha == right_sha), - Different => assert!(left_sha != right_sha), - } -} - -fn gen_id(reftest: &Reftest) -> ~str { - let mut sha = Sha1::new(); - match reftest.kind { - Same => sha.input_str("=="), - Different => sha.input_str("!="), - } - sha.input_str(reftest.left); - sha.input_str(reftest.right); - sha.result_str() -} - -fn calc_hash(path: &Path) -> Option<~str> { - match io::file_reader(path) { - Err(*) => None, - Ok(reader) => { - let mut sha = Sha1::new(); - loop { - let bytes = reader.read_bytes(4096); - sha.input(bytes); - if bytes.len() < 4096 { break; } - } - Some(sha.result_str()) - } + Same => assert!(retval == 0), + Different => assert!(retval != 0), } }