diff options
Diffstat (limited to 'src')
52 files changed, 263 insertions, 166 deletions
diff --git a/src/components/gfx/buffer_map.rs b/src/components/gfx/buffer_map.rs index b061362829c..4c9b8950d94 100644 --- a/src/components/gfx/buffer_map.rs +++ b/src/components/gfx/buffer_map.rs @@ -74,7 +74,7 @@ impl<T: Tile> BufferMap<T> { counter: 0u, } } - + /// Insert a new buffer into the map. pub fn insert(&mut self, graphics_context: &NativePaintingGraphicsContext, new_buffer: T) { let new_key = BufferKey::get(new_buffer.get_size_2d()); @@ -129,7 +129,7 @@ impl<T: Tile> BufferMap<T> { Some(ref mut buffer_val) => { buffer_val.last_action = self.counter; self.counter += 1; - + let buffer = buffer_val.buffers.pop().take_unwrap(); self.mem -= buffer.get_mem(); if buffer_val.buffers.is_empty() { @@ -139,7 +139,7 @@ impl<T: Tile> BufferMap<T> { } None => None, }; - + if flag { self.map.pop(&key); // Don't store empty vectors! } diff --git a/src/components/gfx/font.rs b/src/components/gfx/font.rs index 6149588d002..470e1bb49bb 100644 --- a/src/components/gfx/font.rs +++ b/src/components/gfx/font.rs @@ -273,9 +273,9 @@ impl<'a> Font { fn make_shaper(&'a mut self) -> &'a Shaper { // fast path: already created a shaper match self.shaper { - Some(ref shaper) => { + Some(ref shaper) => { let s: &'a Shaper = shaper; - return s; + return s; }, None => {} } @@ -385,7 +385,7 @@ impl Font { let glyphbuf = struct__AzGlyphBuffer { mGlyphs: azglyphs.as_ptr(), - mNumGlyphs: azglyph_buf_len as uint32_t + mNumGlyphs: azglyph_buf_len as uint32_t }; unsafe { diff --git a/src/components/gfx/font_list.rs b/src/components/gfx/font_list.rs index ae149918b2c..699d87e7063 100644 --- a/src/components/gfx/font_list.rs +++ b/src/components/gfx/font_list.rs @@ -53,7 +53,7 @@ impl FontList { } pub fn find_font_in_family<'a>(&'a mut self, - family_name: &~str, + family_name: &~str, style: &SpecifiedFontStyle) -> Option<&'a FontEntry> { // TODO(Issue #188): look up localized font family names if canonical name not found // look up canonical name @@ -81,7 +81,7 @@ impl FontList { } } -// Holds a specific font family, and the various +// Holds a specific font family, and the various pub struct FontFamily { family_name: ~str, entries: ~[FontEntry], diff --git a/src/components/gfx/freetype_impl/font_context.rs b/src/components/gfx/freetype_impl/font_context.rs index fd501cbed66..4ae11ea9ade 100644 --- a/src/components/gfx/freetype_impl/font_context.rs +++ b/src/components/gfx/freetype_impl/font_context.rs @@ -10,7 +10,7 @@ use self::freetype::freetype::{ FT_Library, }; use self::freetype::freetype::bindgen::{ - FT_Init_FreeType, + FT_Init_FreeType, FT_Done_FreeType }; use fontconfig::font_list::path_from_identifier; @@ -43,7 +43,7 @@ pub impl FreeTypeFontContextHandle { let result = FT_Init_FreeType(ptr::to_unsafe_ptr(&ctx)); if !result.succeeded() { fail!(); } - FreeTypeFontContextHandle { + FreeTypeFontContextHandle { ctx: @FreeTypeLibraryHandle { ctx: ctx }, } } diff --git a/src/components/gfx/platform/macos/font.rs b/src/components/gfx/platform/macos/font.rs index b294e8d3e59..38250651c24 100644 --- a/src/components/gfx/platform/macos/font.rs +++ b/src/components/gfx/platform/macos/font.rs @@ -94,7 +94,7 @@ impl FontHandleMethods for FontHandle { fn family_name(&self) -> ~str { self.ctfont.family_name() } - + fn face_name(&self) -> ~str { self.ctfont.face_name() } diff --git a/src/components/gfx/render_context.rs b/src/components/gfx/render_context.rs index 44529c057e3..e556c04d020 100644 --- a/src/components/gfx/render_context.rs +++ b/src/components/gfx/render_context.rs @@ -87,11 +87,11 @@ impl<'a> RenderContext<'a> { let path = path_builder.finish(); self.draw_target.push_clip(&path); - } - + } + pub fn draw_pop_clip(&self) { self.draw_target.pop_clip(); - } + } pub fn draw_image(&self, bounds: Rect<Au>, image: Arc<~Image>) { let image = image.get(); diff --git a/src/components/gfx/render_task.rs b/src/components/gfx/render_task.rs index 03c49adcd1f..c5cb216c1db 100644 --- a/src/components/gfx/render_task.rs +++ b/src/components/gfx/render_task.rs @@ -61,7 +61,7 @@ pub enum Msg { pub struct BufferRequest { // The rect in pixels that will be drawn to the screen screen_rect: Rect<uint>, - + // The rect in page coordinates that this tile represents page_rect: Rect<f32>, } diff --git a/src/components/gfx/text/glyph.rs b/src/components/gfx/text/glyph.rs index b9008d3e589..da3a58f6b05 100644 --- a/src/components/gfx/text/glyph.rs +++ b/src/components/gfx/text/glyph.rs @@ -146,7 +146,7 @@ static GLYPH_COUNT_SHIFT: u32 = 8; static FLAG_NOT_MISSING: u32 = 0x00000001; static FLAG_NOT_CLUSTER_START: u32 = 0x00000002; static FLAG_NOT_LIGATURE_GROUP_START: u32 = 0x00000004; - + static FLAG_CHAR_IS_TAB: u32 = 0x00000008; static FLAG_CHAR_IS_NEWLINE: u32 = 0x00000010; //static FLAG_CHAR_IS_LOW_SURROGATE: u32 = 0x00000020; @@ -183,7 +183,7 @@ impl GlyphEntry { fn is_cluster_start(&self) -> bool { self.has_flag(!FLAG_NOT_CLUSTER_START) } - + // True if original char was normal (U+0020) space. Other chars may // map to space glyph, but this does not account for them. fn char_is_space(&self) -> bool { diff --git a/src/components/gfx/text/mod.rs b/src/components/gfx/text/mod.rs index 13a07fa9dba..f705347c441 100644 --- a/src/components/gfx/text/mod.rs +++ b/src/components/gfx/text/mod.rs @@ -4,7 +4,7 @@ /* This file exists just to make it easier to import things inside of ./text/ without specifying the file they came out of imports. - + Note that you still must define each of the files as a module in servo.rc. This is not ideal and may be changed in the future. */ diff --git a/src/components/gfx/text/shaping/mod.rs b/src/components/gfx/text/shaping/mod.rs index db326727127..9dd15aa03c1 100644 --- a/src/components/gfx/text/shaping/mod.rs +++ b/src/components/gfx/text/shaping/mod.rs @@ -2,7 +2,7 @@ * 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/. */ -//! Shaper encapsulates a specific shaper, such as Harfbuzz, +//! Shaper encapsulates a specific shaper, such as Harfbuzz, /// Uniscribe, Pango, or Coretext. /// /// Currently, only harfbuzz bindings are implemented. diff --git a/src/components/gfx/text/util.rs b/src/components/gfx/text/util.rs index e80596bde87..76a1d669f20 100644 --- a/src/components/gfx/text/util.rs +++ b/src/components/gfx/text/util.rs @@ -10,12 +10,12 @@ enum CompressionMode { DiscardNewline } -// ported from Gecko's nsTextFrameUtils::TransformText. -// +// ported from Gecko's nsTextFrameUtils::TransformText. +// // High level TODOs: // // * Issue #113: consider incoming text state (arabic, etc) -// and propogate outgoing text state (dual of above) +// and propogate outgoing text state (dual of above) // // * Issue #114: record skipped and kept chars for mapping original to new text // @@ -42,7 +42,7 @@ pub fn transform_text(text: &str, mode: CompressionMode, incoming_whitespace: bo if ch != '\n' { new_line_index += 1; } - out_str.push_char(ch); + out_str.push_char(ch); } } text.len() > 0 && is_in_whitespace(text.char_at_reverse(0), mode) @@ -53,7 +53,7 @@ pub fn transform_text(text: &str, mode: CompressionMode, incoming_whitespace: bo for ch in text.chars() { // TODO: discard newlines between CJK chars let mut next_in_whitespace: bool = is_in_whitespace(ch, mode); - + if !next_in_whitespace { if is_always_discardable_char(ch) { // revert whitespace setting, since this char was discarded @@ -75,7 +75,7 @@ pub fn transform_text(text: &str, mode: CompressionMode, incoming_whitespace: bo in_whitespace = next_in_whitespace; } /* /for str::each_char */ in_whitespace - } + } }; return (out_str, out_whitespace); diff --git a/src/components/main/compositing/compositor.rs b/src/components/main/compositing/compositor.rs index 486c2256f6a..9ae6520c38a 100644 --- a/src/components/main/compositing/compositor.rs +++ b/src/components/main/compositing/compositor.rs @@ -107,7 +107,7 @@ pub struct IOCompositor { /// The channel on which messages can be sent to the profiler. profiler_chan: ProfilerChan, - /// Pending scroll to fragment event, if any + /// Pending scroll to fragment event, if any fragment_point: Option<Point2D<f32>> } @@ -751,7 +751,7 @@ impl IOCompositor { // Render to PNG. We must read from the back buffer (ie, before // self.window.present()) as OpenGL ES 2 does not have glReadBuffer(). - if self.load_complete && self.ready_state == FinishedLoading + if self.load_complete && self.ready_state == FinishedLoading && self.opts.output_file.is_some() { let (width, height) = (self.window_size.width as uint, self.window_size.height as uint); let path = from_str::<Path>(*self.opts.output_file.get_ref()).unwrap(); diff --git a/src/components/main/compositing/compositor_layer.rs b/src/components/main/compositing/compositor_layer.rs index c0477048e9f..678c8c03bd5 100644 --- a/src/components/main/compositing/compositor_layer.rs +++ b/src/components/main/compositing/compositor_layer.rs @@ -82,7 +82,7 @@ pub struct CompositorLayer { /// add_buffer() calls that don't match the current epoch will be ignored. epoch: Epoch, - /// The behavior of this layer when a scroll message is received. + /// The behavior of this layer when a scroll message is received. wants_scroll_events: WantsScrollEventsFlag, /// Whether an ancestor layer that receives scroll events moves this layer. @@ -188,7 +188,7 @@ impl CompositorLayer { unrendered_color: gfx::color::rgba(0.0, 0.0, 0.0, 0.0), } } - + /// Creates a new root `CompositorLayer` bound to a composition pipeline with an optional page /// size. If no page size is given, the layer is initially hidden and initialized without a /// quadtree. @@ -379,7 +379,7 @@ impl CompositorLayer { result } - // Takes in a MouseWindowEvent, determines if it should be passed to children, and + // Takes in a MouseWindowEvent, determines if it should be passed to children, and // sends the event off to the appropriate pipeline. NB: the cursor position is in // page coordinates. pub fn send_mouse_event(&self, event: MouseWindowEvent, cursor: Point2D<f32>) { @@ -398,7 +398,7 @@ impl CompositorLayer { } } } - + // This mouse event is mine! let message = match event { MouseWindowClickEvent(button, _) => ClickEvent(button, cursor), @@ -518,7 +518,7 @@ impl CompositorLayer { true } None => { - // ID does not match any of our immediate children, so recurse on + // ID does not match any of our immediate children, so recurse on // descendents (including hidden children) self.children .mut_iter() @@ -634,7 +634,7 @@ impl CompositorLayer { fn texture_flip_and_target(_: bool, _: Size2D<uint>) -> (Flip, TextureTarget) { (NoFlip, TextureTarget2D) } - + // A helper method to resize sublayers. fn resize_helper(&mut self, pipeline_id: PipelineId, @@ -679,8 +679,8 @@ impl CompositorLayer { true } None => false, - }; - + }; + if found { // Boolean flag to get around double borrow of self self.set_occlusions(); return true @@ -790,7 +790,7 @@ impl CompositorLayer { }; } } - + // Add LayerBuffers to the specified layer. Returns the layer buffer set back if the layer that // matches the given pipeline ID was not found; otherwise returns None and consumes the layer // buffer set. @@ -910,7 +910,7 @@ impl CompositorLayer { .any(|kid| kid.invalidate_rect(pipeline_id, layer_id, rect)) } } - + // Recursively sets occluded portions of quadtrees to Hidden, so that they do not ask for // tile requests. If layers are moved, resized, or deleted, these portions may be updated. fn set_occlusions(&mut self) { diff --git a/src/components/main/compositing/quadtree.rs b/src/components/main/compositing/quadtree.rs index f3570384095..6dbc65932b7 100644 --- a/src/components/main/compositing/quadtree.rs +++ b/src/components/main/compositing/quadtree.rs @@ -90,7 +90,7 @@ impl<T: Tile> Quadtree<T> { let num_tiles = div_ceil(longer, tile_size); let power_of_two = next_power_of_two(num_tiles); let size = power_of_two * tile_size; - + Quadtree { root: ~QuadtreeNode { tile: None, @@ -255,14 +255,14 @@ impl<T: Tile> QuadtreeNode<T> { /// Determine which child contains a given point in page coords. fn get_quadrant(&self, x: f32, y: f32) -> Quadrant { if x < self.origin.x + self.size / 2.0 { - if y < self.origin.y + self.size / 2.0 { + if y < self.origin.y + self.size / 2.0 { TL - } else { + } else { BL } - } else if y < self.origin.y + self.size / 2.0 { + } else if y < self.origin.y + self.size / 2.0 { TR - } else { + } else { BR } } @@ -282,7 +282,7 @@ impl<T: Tile> QuadtreeNode<T> { None => {} } } - + return ret; } @@ -297,7 +297,7 @@ impl<T: Tile> QuadtreeNode<T> { || y >= self.origin.y + self.size || y < self.origin.y { fail!("Quadtree: Tried to add tile to invalid region"); } - + if self.size <= tile_size { // We are the child let old_size = self.tile_mem; self.tile_mem = tile.get_mem(); @@ -316,7 +316,7 @@ impl<T: Tile> QuadtreeNode<T> { } self.status = Normal; (self.tile_mem as int - old_size as int, unused_tiles) - } else { // Send tile to children + } else { // Send tile to children let quad = self.get_quadrant(x, y); match self.quadrants[quad as int] { Some(ref mut child) => { @@ -324,7 +324,7 @@ impl<T: Tile> QuadtreeNode<T> { self.tile_mem = (self.tile_mem as int + delta) as uint; (delta, unused) } - None => { // Make new child + None => { // Make new child let new_size = self.size / 2.0; let new_x = match quad { TL | BL => self.origin.x, @@ -336,7 +336,7 @@ impl<T: Tile> QuadtreeNode<T> { }; let mut c = ~QuadtreeNode::new_child(new_x, new_y, new_size); let (delta, unused) = c.add_tile(x, y, tile, tile_size); - self.tile_mem = (self.tile_mem as int + delta) as uint; + self.tile_mem = (self.tile_mem as int + delta) as uint; self.quadrants[quad as int] = Some(c); (delta, unused) } @@ -351,7 +351,7 @@ impl<T: Tile> QuadtreeNode<T> { || y >= self.origin.y + self.size || y < self.origin.y { fail!("Quadtree: Tried to query a tile rect outside of range"); } - + if self.size <= tile_size { let pix_x = (self.origin.x * scale).ceil() as uint; let pix_y = (self.origin.y * scale).ceil() as uint; @@ -363,7 +363,7 @@ impl<T: Tile> QuadtreeNode<T> { return BufferRequest(Rect(Point2D(pix_x, pix_y), Size2D(pix_width, pix_height)), Rect(Point2D(self.origin.x, self.origin.y), Size2D(page_width, page_height))); } - + let quad = self.get_quadrant(x,y); match self.quadrants[quad as int] { None => { @@ -394,7 +394,7 @@ impl<T: Tile> QuadtreeNode<T> { if self.tile.is_some() { let ret = replace(&mut(self.tile), None); return match (ret, &self.quadrants) { - (Some(tile), &[None, None, None, None]) => { + (Some(tile), &[None, None, None, None]) => { let size = -(tile.get_mem() as int); (Some(tile), true, size) } @@ -405,19 +405,19 @@ impl<T: Tile> QuadtreeNode<T> { _ => fail!("Quadtree: tile query failure in remove_tile"), } } - + // This is a hacky heuristic to find a tile that is "far away". There are better methods. let quad = self.get_quadrant(x, y); let queue = match quad { - TL => [BR, BL, TR, TL], + TL => [BR, BL, TR, TL], TR => [BL, BR, TL, TR], - BL => [TR, TL, BR, BL], + BL => [TR, TL, BR, BL], BR => [TL, TR, BL, BR], }; let mut del_quad: Option<Quadrant> = None; let mut ret = (None, false, 0); - + for quad in queue.iter() { match self.quadrants[*quad as int] { Some(ref mut child) => { @@ -440,7 +440,7 @@ impl<T: Tile> QuadtreeNode<T> { None => {}, } } - + match del_quad { Some(quad) => { self.quadrants[quad as int] = None; @@ -453,7 +453,7 @@ impl<T: Tile> QuadtreeNode<T> { None => ret, } } - + /// Given a window rect in page coordinates, returns a BufferRequest array, /// an unused tile array, and the difference in tile memory between the new and old quadtree nodes. /// The override bool will be true if a parent node was marked as invalid; child nodes will be @@ -481,11 +481,11 @@ impl<T: Tile> QuadtreeNode<T> { || w_x >= clip.width || w_y >= clip.height { return (~[], ~[], 0); } - + // clip window to visible region let w_width = w_width.min(clip.width - w_x); let w_height = w_height.min(clip.height - w_y); - + if s_size <= tile_size { // We are the child return match self.tile { _ if self.status == Rendering || self.status == Hidden => (~[], ~[], 0), @@ -517,11 +517,11 @@ impl<T: Tile> QuadtreeNode<T> { _ => (~[self.get_tile_rect(s_x, s_y, clip.width, clip.height, scale, tile_size)], ~[], 0), } } - + // Otherwise, we either have children or will have children let w_tl_quad = self.get_quadrant(w_x, w_y); let w_br_quad = self.get_quadrant(w_x + w_width, w_y + w_height); - + // Figure out which quadrants the window is in let builder = |push: |Quadrant|| { match (w_tl_quad, w_br_quad) { @@ -545,13 +545,13 @@ impl<T: Tile> QuadtreeNode<T> { } } }; - + let quads_to_check = slice::build(Some(4), builder); - + let mut request = ~[]; let mut unused = ~[]; let mut delta = 0; - + for quad in quads_to_check.iter() { // Recurse into child let new_window = match *quad { @@ -570,7 +570,7 @@ impl<T: Tile> QuadtreeNode<T> { w_y.max(s_y + s_size / 2.0)), Size2D(w_width.min(w_x + w_width - (s_x + s_size / 2.0)), w_height.min(w_y + w_height - (s_y + s_size / 2.0)))), - + }; let override = override || self.status == Invalid; @@ -594,11 +594,11 @@ impl<T: Tile> QuadtreeNode<T> { ret } }; - + delta = delta + c_delta; request = request + c_request; unused.push_all_move(c_unused); - } + } self.tile_mem = (self.tile_mem as int + delta) as uint; (request, unused, delta) } @@ -662,12 +662,12 @@ pub fn test_resize() { struct T { a: int, } - + impl Tile for T { fn get_mem(&self) -> uint { 1 } - + fn is_valid(&self, _: f32) -> bool { true } @@ -677,7 +677,7 @@ pub fn test_resize() { fn mark_wont_leak(&mut self) {} fn destroy(self, _: &NativePaintingGraphicsContext) {} } - + let mut q = Quadtree::new(Size2D(6u, 6), 1, None); q.add_tile_pixel(0, 0, 1f32, T{a: 0}); q.add_tile_pixel(5, 5, 1f32, T{a: 1}); @@ -697,12 +697,12 @@ pub fn test() { struct T { a: int, } - + impl Tile for T { fn get_mem(&self) -> uint { 1 } - + fn is_valid(&self, _: f32) -> bool { true } @@ -712,9 +712,9 @@ pub fn test() { fn mark_wont_leak(&mut self) {} fn destroy(self, _: &NativePaintingGraphicsContext) {} } - + let mut q = Quadtree::new(Size2D(8u, 8), 2, Some(4)); - q.add_tile_pixel(0, 0, 1f32, T{a: 0}); + q.add_tile_pixel(0, 0, 1f32, T{a: 0}); q.add_tile_pixel(0, 0, 2f32, T{a: 1}); q.add_tile_pixel(0, 0, 2f32, T{a: 2}); q.add_tile_pixel(2, 0, 2f32, T{a: 3}); diff --git a/src/components/main/constellation.rs b/src/components/main/constellation.rs index 38efb084963..85fbc5eaf30 100644 --- a/src/components/main/constellation.rs +++ b/src/components/main/constellation.rs @@ -349,7 +349,7 @@ impl Constellation { self.handle_load_url_msg(source_id, url); } // A page loaded through one of several methods above has completed all parsing, - // script, and reflow messages have been sent. + // script, and reflow messages have been sent. LoadCompleteMsg(pipeline_id, url) => { debug!("constellation got load complete message"); self.compositor_chan.send(LoadComplete(pipeline_id, url)); @@ -473,7 +473,7 @@ impl Constellation { { // Update a child's frame rect and inform its script task of the change, - // if it hasn't been already. Optionally inform the compositor if + // if it hasn't been already. Optionally inform the compositor if // resize happens immediately. let update_child_rect = |child_frame_tree: &mut ChildFrameTree, is_active: bool| { child_frame_tree.rect = Some(rect.clone()); diff --git a/src/components/main/image.rs b/src/components/main/image.rs index d03b93b1a11..99d07a0f4ee 100644 --- a/src/components/main/image.rs +++ b/src/components/main/image.rs @@ -4,7 +4,7 @@ /* This file exists just to make it easier to import things inside of ./images/ without specifying the file they came out of imports. - + Note that you still must define each of the files as a module in servo.rc. This is not ideal and may be changed in the future. */ diff --git a/src/components/main/layout/floats.rs b/src/components/main/layout/floats.rs index e3cdf4f8b65..1ee060c2679 100644 --- a/src/components/main/layout/floats.rs +++ b/src/components/main/layout/floats.rs @@ -185,17 +185,17 @@ impl Floats { debug!("float_pos: {}, float_size: {}", float_pos, float_size); match float.kind { - FloatLeft if float_pos.x + float_size.width > max_left && + FloatLeft if float_pos.x + float_size.width > max_left && float_pos.y + float_size.height > top && float_pos.y < top + height => { max_left = float_pos.x + float_size.width; - + 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 {}", max_left); } - FloatRight if float_pos.x < min_right && + FloatRight if float_pos.x < min_right && float_pos.y + float_size.height > top && float_pos.y < top + height => { min_right = float_pos.x; @@ -213,7 +213,7 @@ impl Floats { // two areas. Also make sure we never return a top smaller than the // given upper bound. let (top, bottom) = match (r_top, r_bottom, l_top, l_bottom) { - (Some(r_top), Some(r_bottom), Some(l_top), Some(l_bottom)) => + (Some(r_top), Some(r_bottom), Some(l_top), Some(l_bottom)) => range_intersect(max(top, r_top), r_bottom, max(top, l_top), l_bottom), (None, None, Some(l_top), Some(l_bottom)) => (max(top, l_top), l_bottom), @@ -225,8 +225,8 @@ impl Floats { // FIXME(eatkinson): This assertion is too strong and fails in some cases. It is OK to // return negative widths since we check against that right away, but we should still // undersrtand why they occur and add a stronger assertion here. - // assert!(max_left < min_right); - + // assert!(max_left < min_right); + assert!(top <= bottom, "Float position error"); Some(Rect { @@ -317,25 +317,25 @@ impl Floats { // If there are no floats blocking us, return the current location // TODO(eatkinson): integrate with overflow None => { - return match info.kind { + return match info.kind { FloatLeft => { Rect(Point2D(Au(0), float_y), Size2D(info.max_width, Au(i32::MAX))) } FloatRight => { - Rect(Point2D(info.max_width - info.size.width, float_y), + Rect(Point2D(info.max_width - info.size.width, float_y), Size2D(info.max_width, Au(i32::MAX))) } } } Some(rect) => { - assert!(rect.origin.y + rect.size.height != float_y, + assert!(rect.origin.y + rect.size.height != float_y, "Non-terminating float placement"); - + // Place here if there is enough room if rect.size.width >= info.size.width { - let height = self.max_height_for_bounds(rect.origin.x, - rect.origin.y, + let height = self.max_height_for_bounds(rect.origin.x, + rect.origin.y, rect.size.width); let height = height.unwrap_or(Au(i32::MAX)); return match info.kind { diff --git a/src/components/main/pipeline.rs b/src/components/main/pipeline.rs index f61de1deba3..4c9af26edb8 100644 --- a/src/components/main/pipeline.rs +++ b/src/components/main/pipeline.rs @@ -21,7 +21,7 @@ use std::cell::RefCell; use std::rc::Rc; use url::Url; -/// A uniquely-identifiable pipeline of script task, layout task, and render task. +/// A uniquely-identifiable pipeline of script task, layout task, and render task. pub struct Pipeline { id: PipelineId, subpage_id: Option<SubpageId>, diff --git a/src/components/main/platform/common/glut_windowing.rs b/src/components/main/platform/common/glut_windowing.rs index 6a344e7f74b..2d59539a8d1 100644 --- a/src/components/main/platform/common/glut_windowing.rs +++ b/src/components/main/platform/common/glut_windowing.rs @@ -148,7 +148,7 @@ impl WindowMethods<Application> for Window { fn present(&self) { glut::swap_buffers(); } - + fn recv(&self) -> WindowEvent { if !self.event_queue.with_mut(|queue| queue.is_empty()) { return self.event_queue.with_mut(|queue| queue.shift().unwrap()) diff --git a/src/components/main/windowing.rs b/src/components/main/windowing.rs index 370cb48ae49..b376eb90d24 100644 --- a/src/components/main/windowing.rs +++ b/src/components/main/windowing.rs @@ -61,7 +61,7 @@ pub trait WindowMethods<A> { fn size(&self) -> Size2D<f32>; /// Presents the window to the screen (perhaps by page flipping). fn present(&self); - + /// Spins the event loop and returns the next event. fn recv(&self) -> WindowEvent; diff --git a/src/components/net/image_cache_task.rs b/src/components/net/image_cache_task.rs index 1544ce05f3b..622443ab2d8 100644 --- a/src/components/net/image_cache_task.rs +++ b/src/components/net/image_cache_task.rs @@ -442,7 +442,7 @@ impl ImageCacheTask { pub fn send(&self, msg: Msg) { self.chan.send(msg); } - + #[cfg(test)] fn wait_for_store(&self) -> Receiver<()> { let (chan, port) = channel(); diff --git a/src/components/script/dom/bindings/codegen/Bindings.conf b/src/components/script/dom/bindings/codegen/Bindings.conf index 2ba358e4753..a40dfdf1fe6 100644 --- a/src/components/script/dom/bindings/codegen/Bindings.conf +++ b/src/components/script/dom/bindings/codegen/Bindings.conf @@ -33,6 +33,7 @@ DOMInterfaces = { 'createComment', 'createDocumentFragment', 'createElement', + 'createElementNS', 'createProcessingInstruction', 'createTextNode', 'embeds', @@ -95,6 +96,7 @@ DOMInterfaces = { 'contains', 'insertBefore', 'isEqualNode', + 'namespaceURI', 'nodeName', 'nodeValue', 'normalize', diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py index 575cc7b8b13..d319ebe909e 100644 --- a/src/components/script/dom/bindings/codegen/CodegenRust.py +++ b/src/components/script/dom/bindings/codegen/CodegenRust.py @@ -1240,23 +1240,13 @@ class PropertyDefiner: if self.hasNonChromeOnly(): return "s" + self.name return "ptr::null()" - def usedForXrays(self, chrome): - # We only need Xrays for methods, attributes and constants. And we only - # need them for the non-chrome ones if we have no chromeonly things. - # Otherwise (we have chromeonly attributes) we need Xrays for the chrome - # methods/attributes/constants. - return ((self.name is "Methods" or self.name is "Attributes" or - self.name is "Constants") and - chrome == self.hasChromeOnly()) def __str__(self): # We only need to generate id arrays for things that will end # up used via ResolveProperty or EnumerateProperties. - str = self.generateArray(self.regular, self.variableName(False), - self.usedForXrays(False)) + str = self.generateArray(self.regular, self.variableName(False)) if self.hasChromeOnly(): - str += self.generateArray(self.chrome, self.variableName(True), - self.usedForXrays(True)) + str += self.generateArray(self.chrome, self.variableName(True)) return str @staticmethod @@ -1270,7 +1260,7 @@ class PropertyDefiner: return prefName[0] def generatePrefableArray(self, array, name, specTemplate, specTerminator, - specType, getPref, getDataTuple, doIdArrays): + specType, getPref, getDataTuple): """ This method generates our various arrays. @@ -1303,8 +1293,6 @@ class PropertyDefiner: # at the very front of the list. specs = [] prefableSpecs = [] - if doIdArrays: - prefableIds = [] prefableTemplate = ' { true, &%s[%d] }' prefCacheTemplate = '&%s[%d].enabled' @@ -1335,16 +1323,9 @@ class PropertyDefiner: specs.append(specTerminator) prefableSpecs.append(" { false, NULL }"); - arrays = (("static %s: [%s, ..%i] = [\n" + - ',\n'.join(specs) + "\n" + - "];\n\n") % (name, specType, len(specs))) - #+ - #"static Prefable<%s> %s[] = [\n" + - #',\n'.join(prefableSpecs) + "\n" + - #"];\n\n") - if doIdArrays: - arrays += ("static %s_ids: [jsid, ..%i] = [" % (name, len(specs))) + ", ".join(["JSID_VOID"] * len(specs)) + "];\n\n" - return arrays + return (("static %s: [%s, ..%i] = [\n" + + ",\n".join(specs) + "\n" + + "];\n\n") % (name, specType, len(specs))) # The length of a method is the maximum of the lengths of the # argument lists of all its overloads. @@ -1407,7 +1388,7 @@ class MethodDefiner(PropertyDefiner): # non-static methods go on the interface prototype object assert not self.hasChromeOnly() and not self.hasNonChromeOnly() - def generateArray(self, array, name, doIdArrays): + def generateArray(self, array, name): if len(array) == 0: return "" @@ -1433,7 +1414,7 @@ class MethodDefiner(PropertyDefiner): ' JSFunctionSpec {name: &%s_name as *u8 as *libc::c_char, call: JSNativeWrapper {op: Some(%s), info: %s}, nargs: %s, flags: %s as u16, selfHostedName: 0 as *libc::c_char }', ' JSFunctionSpec {name: 0 as *libc::c_char, call: JSNativeWrapper {op: None, info: 0 as *JSJitInfo}, nargs: 0, flags: 0, selfHostedName: 0 as *libc::c_char }', 'JSFunctionSpec', - pref, specData, doIdArrays) + pref, specData) class AttrDefiner(PropertyDefiner): def __init__(self, descriptor, name): @@ -1442,7 +1423,7 @@ class AttrDefiner(PropertyDefiner): self.chrome = [m for m in descriptor.interface.members if m.isAttr()] self.regular = [m for m in self.chrome if not isChromeOnly(m)] - def generateArray(self, array, name, doIdArrays): + def generateArray(self, array, name): if len(array) == 0: return "" @@ -1481,7 +1462,7 @@ class AttrDefiner(PropertyDefiner): ' JSPropertySpec { name: &%s_name as *u8 as *libc::c_char, tinyid: 0, flags: ((%s) & 0xFF) as u8, getter: %s, setter: %s }', ' JSPropertySpec { name: 0 as *libc::c_char, tinyid: 0, flags: 0, getter: JSPropertyOpWrapper {op: None, info: 0 as *JSJitInfo}, setter: JSStrictPropertyOpWrapper {op: None, info: 0 as *JSJitInfo} }', 'JSPropertySpec', - PropertyDefiner.getControllingPref, specData, doIdArrays) + PropertyDefiner.getControllingPref, specData) class ConstDefiner(PropertyDefiner): """ @@ -1493,7 +1474,7 @@ class ConstDefiner(PropertyDefiner): self.chrome = [m for m in descriptor.interface.members if m.isConst()] self.regular = [m for m in self.chrome if not isChromeOnly(m)] - def generateArray(self, array, name, doIdArrays): + def generateArray(self, array, name): if len(array) == 0: return "" @@ -1513,7 +1494,7 @@ class ConstDefiner(PropertyDefiner): ' ConstantSpec { name: &%s_name as *u8 as *libc::c_char, value: %s }', ' ConstantSpec { name: 0 as *libc::c_char, value: VoidVal }', 'ConstantSpec', - PropertyDefiner.getControllingPref, specData, doIdArrays) + PropertyDefiner.getControllingPref, specData) # We'll want to insert the indent at the beginnings of lines, but we # don't want to indent empty lines. So only indent lines that have a diff --git a/src/components/script/dom/characterdata.rs b/src/components/script/dom/characterdata.rs index 40b72f18faf..6bb25f6b5cb 100644 --- a/src/components/script/dom/characterdata.rs +++ b/src/components/script/dom/characterdata.rs @@ -37,7 +37,7 @@ impl CharacterData { data: data } } - + pub fn Data(&self) -> DOMString { self.data.clone() } diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs index e81394e6f18..a3a95277cc1 100644 --- a/src/components/script/dom/document.rs +++ b/src/components/script/dom/document.rs @@ -10,13 +10,13 @@ use dom::bindings::codegen::DocumentBinding; use dom::bindings::codegen::NodeBinding::NodeConstants::{DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_PRECEDING}; use dom::bindings::js::JS; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; -use dom::bindings::error::{ErrorResult, Fallible, NotSupported, InvalidCharacter, HierarchyRequest}; -use dom::bindings::utils::{xml_name_type, InvalidXMLName}; +use dom::bindings::error::{ErrorResult, Fallible, NotSupported, InvalidCharacter, HierarchyRequest, NamespaceError}; +use dom::bindings::utils::{xml_name_type, InvalidXMLName, Name, QName}; use dom::comment::Comment; use dom::documentfragment::DocumentFragment; use dom::documenttype::DocumentType; use dom::domimplementation::DOMImplementation; -use dom::element::{Element, AttributeHandlers}; +use dom::element::{Element, AttributeHandlers, get_attribute_parts}; use dom::element::{HTMLHtmlElementTypeId, HTMLHeadElementTypeId, HTMLTitleElementTypeId}; use dom::element::{HTMLBodyElementTypeId, HTMLFrameSetElementTypeId}; use dom::event::Event; @@ -38,8 +38,9 @@ use dom::location::Location; use html::hubbub_html_parser::build_element_from_tag; use hubbub::hubbub::{QuirksMode, NoQuirks, LimitedQuirks, FullQuirks}; use layout_interface::{DocumentDamageLevel, ContentChangedDocumentDamage}; +use servo_util::namespace; use servo_util::namespace::{Namespace, Null}; -use servo_util::str::DOMString; +use servo_util::str::{DOMString, null_str_as_empty_ref}; use collections::hashmap::HashMap; use js::jsapi::JSContext; @@ -264,6 +265,52 @@ impl Document { Ok(build_element_from_tag(local_name, abstract_self)) } + // http://dom.spec.whatwg.org/#dom-document-createelementns + pub fn CreateElementNS(&self, abstract_self: &JS<Document>, + namespace: Option<DOMString>, + qualified_name: DOMString) -> Fallible<JS<Element>> { + let ns = Namespace::from_str(null_str_as_empty_ref(&namespace)); + match xml_name_type(qualified_name) { + InvalidXMLName => { + debug!("Not a valid element name"); + return Err(InvalidCharacter); + }, + Name => { + debug!("Not a valid qualified element name"); + return Err(NamespaceError); + }, + QName => {} + } + + let (prefix_from_qname, local_name_from_qname) = get_attribute_parts(qualified_name); + match (&ns, prefix_from_qname, local_name_from_qname.as_slice()) { + // throw if prefix is not null and namespace is null + (&namespace::Null, Some(_), _) => { + debug!("Namespace can't be null with a non-null prefix"); + return Err(NamespaceError); + }, + // throw if prefix is "xml" and namespace is not the XML namespace + (_, Some(ref prefix), _) if "xml" == *prefix && ns != namespace::XML => { + debug!("Namespace must be the xml namespace if the prefix is 'xml'"); + return Err(NamespaceError); + }, + // throw if namespace is the XMLNS namespace and neither qualifiedName nor prefix is "xmlns" + (&namespace::XMLNS, Some(ref prefix), _) if "xmlns" == *prefix => {}, + (&namespace::XMLNS, _, "xmlns") => {}, + (&namespace::XMLNS, _, _) => { + debug!("The prefix or the qualified name must be 'xmlns' if namespace is the XMLNS namespace "); + return Err(NamespaceError); + }, + _ => {} + } + + if ns == namespace::HTML { + Ok(build_element_from_tag(local_name_from_qname, abstract_self)) + } else { + Ok(Element::new(local_name_from_qname, ns, abstract_self)) + } + } + // http://dom.spec.whatwg.org/#dom-document-createdocumentfragment pub fn CreateDocumentFragment(&self, abstract_self: &JS<Document>) -> JS<DocumentFragment> { DocumentFragment::new(abstract_self) diff --git a/src/components/script/dom/element.rs b/src/components/script/dom/element.rs index 3d578a4a793..3361765e3c0 100644 --- a/src/components/script/dom/element.rs +++ b/src/components/script/dom/element.rs @@ -6,6 +6,7 @@ use dom::attr::Attr; use dom::attrlist::AttrList; +use dom::bindings::codegen::ElementBinding; use dom::bindings::codegen::InheritTypes::{ElementDerived, HTMLImageElementCast}; use dom::bindings::codegen::InheritTypes::{HTMLIFrameElementCast, NodeCast}; use dom::bindings::codegen::InheritTypes::HTMLObjectElementCast; @@ -133,6 +134,8 @@ pub enum ElementTypeId { HTMLUListElementTypeId, HTMLVideoElementTypeId, HTMLUnknownElementTypeId, + + ElementTypeId, } // @@ -140,7 +143,7 @@ pub enum ElementTypeId { // impl Element { - pub fn new_inherited(type_id: ElementTypeId, tag_name: ~str, namespace: Namespace, document: JS<Document>) -> Element { + pub fn new_inherited(type_id: ElementTypeId, tag_name: DOMString, namespace: Namespace, document: JS<Document>) -> Element { Element { node: Node::new_inherited(ElementNodeTypeId(type_id), document), tag_name: tag_name, @@ -151,6 +154,11 @@ impl Element { } } + pub fn new(tag_name: DOMString, namespace: Namespace, document: &JS<Document>) -> JS<Element> { + let element = Element::new_inherited(ElementTypeId, tag_name, namespace, document.clone()); + Node::reflect_node(~element, document, ElementBinding::Wrap) + } + pub fn html_element_in_html_document(&self) -> bool { self.namespace == namespace::HTML && self.node.owner_doc().get().is_html_document @@ -198,6 +206,7 @@ pub trait AttributeHandlers { fn set_url_attribute(&mut self, name: &str, value: DOMString); fn get_string_attribute(&self, name: &str) -> DOMString; fn set_string_attribute(&mut self, name: &str, value: DOMString); + fn set_uint_attribute(&mut self, name: &str, value: u32); } pub trait AfterSetAttrListener { @@ -410,6 +419,11 @@ impl AttributeHandlers for JS<Element> { assert!(name == name.to_ascii_lower()); assert!(self.set_attribute(Null, name.to_owned(), value).is_ok()); } + + fn set_uint_attribute(&mut self, name: &str, value: u32) { + assert!(name == name.to_ascii_lower()); + assert!(self.set_attribute(Null, name.to_owned(), value.to_str()).is_ok()); + } } impl Element { @@ -647,7 +661,7 @@ impl IElement for JS<Element> { } } -fn get_attribute_parts(name: DOMString) -> (Option<~str>, ~str) { +pub fn get_attribute_parts(name: DOMString) -> (Option<~str>, ~str) { //FIXME: Throw for XML-invalid names //FIXME: Throw for XMLNS-invalid names let (prefix, local_name) = if name.contains(":") { diff --git a/src/components/script/dom/event.rs b/src/components/script/dom/event.rs index c54688626d3..dcd4fbe9ed5 100644 --- a/src/components/script/dom/event.rs +++ b/src/components/script/dom/event.rs @@ -14,7 +14,7 @@ use servo_util::str::DOMString; use geom::point::Point2D; pub enum Event_ { - ResizeEvent(uint, uint), + ResizeEvent(uint, uint), ReflowEvent, ClickEvent(uint, Point2D<f32>), MouseDownEvent(uint, Point2D<f32>), diff --git a/src/components/script/dom/htmlbuttonelement.rs b/src/components/script/dom/htmlbuttonelement.rs index 06614bd48f8..6e6a84bfb36 100644 --- a/src/components/script/dom/htmlbuttonelement.rs +++ b/src/components/script/dom/htmlbuttonelement.rs @@ -110,7 +110,7 @@ impl HTMLButtonElement { pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { Ok(()) } - + pub fn Type(&self) -> DOMString { ~"" } diff --git a/src/components/script/dom/htmlfontelement.rs b/src/components/script/dom/htmlfontelement.rs index b0c67b585c9..aad93fb79e7 100644 --- a/src/components/script/dom/htmlfontelement.rs +++ b/src/components/script/dom/htmlfontelement.rs @@ -56,7 +56,7 @@ impl HTMLFontElement { pub fn SetFace(&mut self, _face: DOMString) -> ErrorResult { Ok(()) } - + pub fn Size(&self) -> DOMString { ~"" } diff --git a/src/components/script/dom/htmlformelement.rs b/src/components/script/dom/htmlformelement.rs index cabb71cc1ea..9bbbb8089db 100644 --- a/src/components/script/dom/htmlformelement.rs +++ b/src/components/script/dom/htmlformelement.rs @@ -124,7 +124,7 @@ impl HTMLFormElement { pub fn Length(&self) -> i32 { 0 } - + pub fn Submit(&self) -> ErrorResult { Ok(()) } diff --git a/src/components/script/dom/htmlimageelement.rs b/src/components/script/dom/htmlimageelement.rs index f0ceeb89434..1fcd4a9a0a5 100644 --- a/src/components/script/dom/htmlimageelement.rs +++ b/src/components/script/dom/htmlimageelement.rs @@ -144,9 +144,9 @@ impl HTMLImageElement { to_px(rect.size.width) as u32 } - pub fn SetWidth(&mut self, abstract_self: &JS<HTMLImageElement>, width: u32) -> ErrorResult { + pub fn SetWidth(&mut self, abstract_self: &JS<HTMLImageElement>, width: u32) { let mut elem: JS<Element> = ElementCast::from(abstract_self); - elem.set_attr(~"width", width.to_str()) + elem.set_uint_attribute("width", width) } pub fn Height(&self, abstract_self: &JS<HTMLImageElement>) -> u32 { @@ -160,9 +160,9 @@ impl HTMLImageElement { to_px(rect.size.height) as u32 } - pub fn SetHeight(&mut self, abstract_self: &JS<HTMLImageElement>, height: u32) -> ErrorResult { + pub fn SetHeight(&mut self, abstract_self: &JS<HTMLImageElement>, height: u32) { let mut elem: JS<Element> = ElementCast::from(abstract_self); - elem.set_attr(~"height", height.to_str()) + elem.set_uint_attribute("height", height) } pub fn NaturalWidth(&self) -> u32 { diff --git a/src/components/script/dom/htmlsourceelement.rs b/src/components/script/dom/htmlsourceelement.rs index ecaa2d5f8df..5542d5bf038 100644 --- a/src/components/script/dom/htmlsourceelement.rs +++ b/src/components/script/dom/htmlsourceelement.rs @@ -44,7 +44,7 @@ impl HTMLSourceElement { pub fn Src(&self) -> DOMString { ~"" } - + pub fn SetSrc(&mut self, _src: DOMString) -> ErrorResult { Ok(()) } @@ -52,7 +52,7 @@ impl HTMLSourceElement { pub fn Type(&self) -> DOMString { ~"" } - + pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { Ok(()) } @@ -60,7 +60,7 @@ impl HTMLSourceElement { pub fn Media(&self) -> DOMString { ~"" } - + pub fn SetMedia(&mut self, _media: DOMString) -> ErrorResult { Ok(()) } diff --git a/src/components/script/dom/htmltablecaptionelement.rs b/src/components/script/dom/htmltablecaptionelement.rs index 980fb4199f6..d92e87dd199 100644 --- a/src/components/script/dom/htmltablecaptionelement.rs +++ b/src/components/script/dom/htmltablecaptionelement.rs @@ -44,7 +44,7 @@ impl HTMLTableCaptionElement { pub fn Align(&self) -> DOMString { ~"" } - + pub fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { Ok(()) } diff --git a/src/components/script/dom/htmltimeelement.rs b/src/components/script/dom/htmltimeelement.rs index d41916b7afb..5e6f3113842 100644 --- a/src/components/script/dom/htmltimeelement.rs +++ b/src/components/script/dom/htmltimeelement.rs @@ -44,7 +44,7 @@ impl HTMLTimeElement { pub fn DateTime(&self) -> DOMString { ~"" } - + pub fn SetDateTime(&mut self, _dateTime: DOMString) -> ErrorResult { Ok(()) } diff --git a/src/components/script/dom/htmlulistelement.rs b/src/components/script/dom/htmlulistelement.rs index e99dd6a7c44..207b0866b7c 100644 --- a/src/components/script/dom/htmlulistelement.rs +++ b/src/components/script/dom/htmlulistelement.rs @@ -44,7 +44,7 @@ impl HTMLUListElement { pub fn Compact(&self) -> bool { false } - + pub fn SetCompact(&mut self, _compact: bool) -> ErrorResult { Ok(()) } diff --git a/src/components/script/dom/node.rs b/src/components/script/dom/node.rs index 0a35b5b6b0d..77ca388be9e 100644 --- a/src/components/script/dom/node.rs +++ b/src/components/script/dom/node.rs @@ -1734,8 +1734,9 @@ impl Node { } // http://dom.spec.whatwg.org/#dom-node-namespaceuri - pub fn GetNamespaceURI(&self) -> Option<DOMString> { - None + pub fn GetNamespaceURI(&self, abstract_self: &JS<Node>) -> Option<DOMString> { + let element: Option<JS<Element>> = ElementCast::to(abstract_self); + element.map(|element| element.get().namespace.to_str().to_owned()) } // http://dom.spec.whatwg.org/#dom-node-prefix diff --git a/src/components/script/dom/webidls/Document.webidl b/src/components/script/dom/webidls/Document.webidl index 81a54021ee7..6dd0cb658a2 100644 --- a/src/components/script/dom/webidls/Document.webidl +++ b/src/components/script/dom/webidls/Document.webidl @@ -28,6 +28,8 @@ interface Document : Node { [Creator, Throws] Element createElement(DOMString localName); + [Creator, Throws] + Element createElementNS(DOMString? namespace, DOMString qualifiedName); [Creator] DocumentFragment createDocumentFragment(); [Creator] diff --git a/src/components/script/dom/webidls/HTMLImageElement.webidl b/src/components/script/dom/webidls/HTMLImageElement.webidl index 700bd20d949..2131124b856 100644 --- a/src/components/script/dom/webidls/HTMLImageElement.webidl +++ b/src/components/script/dom/webidls/HTMLImageElement.webidl @@ -23,9 +23,7 @@ interface HTMLImageElement : HTMLElement { attribute DOMString useMap; [SetterThrows] attribute boolean isMap; - [SetterThrows] attribute unsigned long width; - [SetterThrows] attribute unsigned long height; readonly attribute unsigned long naturalWidth; readonly attribute unsigned long naturalHeight; diff --git a/src/components/script/html/hubbub_html_parser.rs b/src/components/script/html/hubbub_html_parser.rs index e2a870c2bc9..438d28a4898 100644 --- a/src/components/script/html/hubbub_html_parser.rs +++ b/src/components/script/html/hubbub_html_parser.rs @@ -54,7 +54,7 @@ type JSResult = ~[JSFile]; enum CSSMessage { CSSTaskNewFile(StylesheetProvenance), - CSSTaskExit + CSSTaskExit } enum JSMessage { diff --git a/src/components/script/layout_interface.rs b/src/components/script/layout_interface.rs index 9dce53fc36e..197bd123e3f 100644 --- a/src/components/script/layout_interface.rs +++ b/src/components/script/layout_interface.rs @@ -73,7 +73,7 @@ pub struct ContentBoxesResponse(~[Rect<Au>]); pub struct HitTestResponse(UntrustedNodeAddress); pub struct MouseOverResponse(~[UntrustedNodeAddress]); -/// Determines which part of the +/// Determines which part of the #[deriving(Eq, Ord, TotalEq, TotalOrd)] pub enum DocumentDamageLevel { /// Reflow, but do not perform CSS selector matching. diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs index c1c3a717f1a..dcee911c46a 100644 --- a/src/components/script/script_task.rs +++ b/src/components/script/script_task.rs @@ -742,7 +742,7 @@ impl ScriptTask { // needs to be smarter about exiting pipelines. None => false, } - + } /// The entry point to document loading. Defines bindings, sets up the window and document @@ -878,10 +878,10 @@ impl ScriptTask { }; //FIXME: this should have some kind of error handling, or explicitly // drop an exception on the floor. - assert!(cx.evaluate_script(global_obj, - file.data.clone(), - file.url.to_str(), - 1).is_ok()); + match cx.evaluate_script(global_obj, file.data.clone(), file.url.to_str(), 1) { + Ok(_) => (), + Err(_) => println!("evaluate_script failed") + } }); } @@ -1096,7 +1096,7 @@ impl ScriptTask { } None => { target_compare = true; } } - + if target_compare { if mouse_over_targets.is_some() { page.damage(MatchSelectorsDocumentDamage); diff --git a/src/components/style/common_types.rs b/src/components/style/common_types.rs index 655646790bb..40bea8f7c70 100644 --- a/src/components/style/common_types.rs +++ b/src/components/style/common_types.rs @@ -55,7 +55,7 @@ pub mod specified { } pub fn parse_dimension(value: CSSFloat, unit: &str) -> Option<Length> { // FIXME: Workaround for https://github.com/mozilla/rust/issues/10683 - let unit_lower = unit.to_ascii_lower(); + let unit_lower = unit.to_ascii_lower(); match unit_lower.as_slice() { "px" => Some(Length::from_px(value)), "in" => Some(Au_(Au((value * AU_PER_IN) as i32))), diff --git a/src/components/style/media_queries.rs b/src/components/style/media_queries.rs index d939bf4d9a9..ebc19b0c80d 100644 --- a/src/components/style/media_queries.rs +++ b/src/components/style/media_queries.rs @@ -84,7 +84,7 @@ pub fn parse_media_query_list(input: &[ComponentValue]) -> MediaQueryList { let mq = match next { Some(&Ident(ref value)) => { // FIXME: Workaround for https://github.com/mozilla/rust/issues/10683 - let value_lower = value.to_ascii_lower(); + let value_lower = value.to_ascii_lower(); match value_lower.as_slice() { "screen" => Some(MediaQuery{ media_type: MediaType(Screen) }), "print" => Some(MediaQuery{ media_type: MediaType(Print) }), diff --git a/src/components/util/range.rs b/src/components/util/range.rs index 59e29876909..94c3e783df1 100644 --- a/src/components/util/range.rs +++ b/src/components/util/range.rs @@ -72,17 +72,17 @@ impl Range { } #[inline] - pub fn shift_by(&mut self, i: int) { + pub fn shift_by(&mut self, i: int) { self.off = ((self.off as int) + i) as uint; } #[inline] - pub fn extend_by(&mut self, i: int) { + pub fn extend_by(&mut self, i: int) { self.len = ((self.len as int) + i) as uint; } #[inline] - pub fn extend_to(&mut self, i: uint) { + pub fn extend_to(&mut self, i: uint) { self.len = i - self.off; } @@ -120,7 +120,7 @@ impl Range { } if self.begin() > other.end() { return EntirelyAfter; - } + } if self.begin() == other.begin() && self.end() == other.end() { return Coincides; } diff --git a/src/components/util/time.rs b/src/components/util/time.rs index 721befef754..0f5802c4d8b 100644 --- a/src/components/util/time.rs +++ b/src/components/util/time.rs @@ -212,7 +212,7 @@ impl Profiler { } -pub fn profile<T>(category: ProfilerCategory, +pub fn profile<T>(category: ProfilerCategory, profiler_chan: ProfilerChan, callback: || -> T) -> T { diff --git a/src/components/util/vec.rs b/src/components/util/vec.rs index 2fabf8455ef..aad8da7d04e 100644 --- a/src/components/util/vec.rs +++ b/src/components/util/vec.rs @@ -65,7 +65,7 @@ fn test_match<T: Eq>(b: &T, a: Option<&T>) -> bool { None => false, Some(t) => t == b } -} +} pub fn zip_copies<A: Clone, B: Clone>(avec: &[A], bvec: &[B]) -> ~[(A,B)] { avec.iter().map(|x| x.clone()) diff --git a/src/platform/linux/fontconfig b/src/platform/linux/fontconfig -Subproject b2cfb1f4b3561e01a58359cd18929457a0486db +Subproject 0450af3d92f1fb4f269cc64e58647871a5bf728 diff --git a/src/test/content/test_document_createElementNS.html b/src/test/content/test_document_createElementNS.html new file mode 100644 index 00000000000..6ff35d4d6c1 --- /dev/null +++ b/src/test/content/test_document_createElementNS.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<html> + <head> + <script src="harness.js"></script> + <script id="script"> + // test1: createElementNS + { + var htmlElt = document.createElementNS("http://www.w3.org/1999/xhtml", "p"); + is_not(htmlElt, null, "test1-0: createElementNS"); + is_a(htmlElt, Element, "test1-1: createElementNS"); + is_a(htmlElt, HTMLElement, "test1-2: createElementNS"); + is_a(htmlElt, HTMLParagraphElement, "test1-3: createElementNS"); + is(htmlElt.namespaceURI, "http://www.w3.org/1999/xhtml", "test1-4: createElementNS"); + + var otherNsElt = document.createElementNS("http://www.example.org/dummy", "p"); + is_not(otherNsElt, null, "test1-5: createElementNS"); + is_a(otherNsElt, Element, "test1-6: createElementNS"); + is_not_a(otherNsElt, HTMLElement, "test1-7: createElementNS"); + is(otherNsElt.namespaceURI, "http://www.example.org/dummy", "test1-8: createElementNS"); + } + // test2: Node.namespaceURI + { + is(document.namespaceURI, null, "test2.0: createElementNS"); + is(document.documentElement.namespaceURI, "http://www.w3.org/1999/xhtml", "test2.1: createElementNS"); + var scriptElt = document.getElementById("script"); + is(scriptElt.firstChild.namespaceURI, null, "test2.2: createElementNS"); + is(scriptElt.nextSibling.namespaceURI, null, "test2.3: createElementNS"); + } + + finish(); + </script><!-- this is a comment --> + </head> +</html> diff --git a/src/test/harness/reftest/reftest.rs b/src/test/harness/reftest/reftest.rs index 3b2a09eff88..e8f548323d7 100644 --- a/src/test/harness/reftest/reftest.rs +++ b/src/test/harness/reftest/reftest.rs @@ -99,7 +99,7 @@ fn parse_lists(filenames: &[~str], servo_args: &[~str]) -> Vec<TestDescAndFn> { let src_dir = src_path.display().to_str(); let file_left = src_dir + "/" + parts[1]; let file_right = src_dir + "/" + parts[2]; - + let reftest = Reftest { name: parts[1] + " / " + parts[2], kind: kind, @@ -151,7 +151,7 @@ fn check_reftest(reftest: Reftest) { let pixels: ~[u8] = left.pixels.iter().zip(right.pixels.iter()).map(|(&a, &b)| { if a as i8 - b as i8 == 0 { // White for correct - 0xFF + 0xFF } else { // "1100" in the RGBA channel with an error for an incorrect value // This results in some number of C0 and FFs, which is much more diff --git a/src/test/ref/basic.list b/src/test/ref/basic.list index 4df86c52e8b..d59e1fb229f 100644 --- a/src/test/ref/basic.list +++ b/src/test/ref/basic.list @@ -65,3 +65,4 @@ == background_repeat_y_a.html background_repeat_y_b.html == background_repeat_none_a.html background_repeat_none_b.html == background_repeat_both_a.html background_repeat_both_b.html +== setattribute_id_restyle_a.html setattribute_id_restyle_b.html diff --git a/src/test/ref/setattribute_id_restyle_a.html b/src/test/ref/setattribute_id_restyle_a.html new file mode 100644 index 00000000000..469ce797db7 --- /dev/null +++ b/src/test/ref/setattribute_id_restyle_a.html @@ -0,0 +1,12 @@ +<style> + #foo { background-color: #FF0000; } +</style> + +<div>hello</div> +<div id="">world</div> + +<script> + var divs = document.getElementsByTagName('div'); + divs[0].setAttribute('id', 'foo'); + divs[1].setAttribute('id', 'foo'); +</script> diff --git a/src/test/ref/setattribute_id_restyle_b.html b/src/test/ref/setattribute_id_restyle_b.html new file mode 100644 index 00000000000..f16fe454c50 --- /dev/null +++ b/src/test/ref/setattribute_id_restyle_b.html @@ -0,0 +1,6 @@ +<style> + #foo { background-color: #FF0000; } +</style> + +<div id="foo">hello</div> +<div id="foo">world</div> |