From 80433f7ea0bfb3fe0963de87bea5ad60a5c3ea75 Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Tue, 23 Sep 2014 16:26:37 -0700 Subject: [PATCH] Properly size root layers Root layers should be sized to their frame rectangles and the root of the root layers should track the window size. This is important because layers need to be properly sized to scroll. --- Cargo.lock | 10 ++++----- components/compositing/compositor.rs | 31 +++++++++++++++++++--------- ports/cef/Cargo.lock | 12 +++++------ 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3c9746c4432..e04ebaa0b67 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -33,7 +33,7 @@ dependencies = [ "freetype 0.1.0 (git+https://github.com/servo/rust-freetype#0b03da276e4bdeae2300596dabc4ccb16733ad70)", "geom 0.1.0 (git+https://github.com/servo/rust-geom#50a294fd997f0c6eb43e9a58ad6e227fdc2a4692)", "glfw 0.0.1 (git+https://github.com/servo/glfw-rs?ref=servo#7ccfaca315a43d97914e1601c90ad348ef190edf)", - "layers 0.1.0 (git+https://github.com/servo/rust-layers#ef89918471815dfced7aaf2f1594d5469f03eab7)", + "layers 0.1.0 (git+https://github.com/servo/rust-layers#ed570335738913fb41fc62a024389dfa415962e8)", "opengles 0.1.0 (git+https://github.com/servo/rust-opengles#6776e9c07feb149d34b087039ecf6b2c143e3afc)", "skia-sys 0.0.20130412 (git+https://github.com/servo/skia#6d696712962fd0d41120b7a414a48417da8e6a92)", "xlib 0.1.0 (git+https://github.com/servo/rust-xlib#581d4faddec5188d3c3ae5307dbea28aab90644c)", @@ -66,7 +66,7 @@ dependencies = [ "gfx 0.0.1", "glfw 0.0.1 (git+https://github.com/servo/glfw-rs?ref=servo#7ccfaca315a43d97914e1601c90ad348ef190edf)", "glut 0.0.1 (git+https://github.com/servo/rust-glut#01af0162ea0322ad1a40d6adb023a39813605949)", - "layers 0.1.0 (git+https://github.com/servo/rust-layers#ef89918471815dfced7aaf2f1594d5469f03eab7)", + "layers 0.1.0 (git+https://github.com/servo/rust-layers#ed570335738913fb41fc62a024389dfa415962e8)", "layout_traits 0.0.1", "msg 0.0.1", "net 0.0.1", @@ -181,7 +181,7 @@ dependencies = [ "freetype 0.1.0 (git+https://github.com/servo/rust-freetype#0b03da276e4bdeae2300596dabc4ccb16733ad70)", "geom 0.1.0 (git+https://github.com/servo/rust-geom#50a294fd997f0c6eb43e9a58ad6e227fdc2a4692)", "harfbuzz 0.1.0 (git+https://github.com/servo/rust-harfbuzz#ad520942cc17232e1a40cdd8a99c2905623d35f6)", - "layers 0.1.0 (git+https://github.com/servo/rust-layers#ef89918471815dfced7aaf2f1594d5469f03eab7)", + "layers 0.1.0 (git+https://github.com/servo/rust-layers#ed570335738913fb41fc62a024389dfa415962e8)", "msg 0.0.1", "net 0.0.1", "plugins 0.0.1", @@ -265,7 +265,7 @@ dependencies = [ [[package]] name = "layers" version = "0.1.0" -source = "git+https://github.com/servo/rust-layers#ef89918471815dfced7aaf2f1594d5469f03eab7" +source = "git+https://github.com/servo/rust-layers#ed570335738913fb41fc62a024389dfa415962e8" dependencies = [ "core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation#166a601ff3e0fc3a64ca1a9090d02c8d4f22b61a)", "egl 0.1.0 (git+https://github.com/servo/rust-egl#88f2a13812ddbce2bf2317221663a61c31b3e220)", @@ -321,7 +321,7 @@ dependencies = [ "core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation#166a601ff3e0fc3a64ca1a9090d02c8d4f22b61a)", "geom 0.1.0 (git+https://github.com/servo/rust-geom#50a294fd997f0c6eb43e9a58ad6e227fdc2a4692)", "io_surface 0.1.0 (git+https://github.com/servo/rust-io-surface#7038341220bd7e86e21118fac2cbc6bd50890e47)", - "layers 0.1.0 (git+https://github.com/servo/rust-layers#ef89918471815dfced7aaf2f1594d5469f03eab7)", + "layers 0.1.0 (git+https://github.com/servo/rust-layers#ed570335738913fb41fc62a024389dfa415962e8)", "url 0.1.0 (git+https://github.com/servo/rust-url#bfdf809365600a7941a77524f9bb065886de3379)", "util 0.0.1", ] diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 316efce8c37..e752bc37a84 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -24,7 +24,7 @@ use azure::azure_hl; use std::cmp; use std::time::duration::Duration; use geom::point::{Point2D, TypedPoint2D}; -use geom::rect::Rect; +use geom::rect::{Rect, TypedRect}; use geom::size::TypedSize2D; use geom::scale_factor::ScaleFactor; use gfx::render_task::{RenderChan, RenderMsg, RenderRequest, UnusedBufferMsg}; @@ -413,7 +413,8 @@ impl IOCompositor { Some(ref mut layer) => CompositorData::clear_all_tiles(layer.clone()), None => { } } - self.scene.root = Some(self.create_frame_tree_root_layers(frame_tree)); + self.scene.root = Some(self.create_frame_tree_root_layers(frame_tree, None)); + self.scene.set_root_layer_size(self.window_size.as_f32()); // Initialize the new constellation channel by sending it the root window size. self.constellation_chan = new_constellation_chan; @@ -421,7 +422,8 @@ impl IOCompositor { } fn create_frame_tree_root_layers(&mut self, - frame_tree: &SendableFrameTree) + frame_tree: &SendableFrameTree, + frame_rect: Option>) -> Rc> { // Initialize the ReadyState and RenderState for this pipeline. self.ready_states.insert(frame_tree.pipeline.id, Blank); @@ -440,8 +442,15 @@ impl IOCompositor { WantsScrollEvents, self.opts.tile_size); + match frame_rect { + Some(ref frame_rect) => { + *root_layer.bounds.borrow_mut() = frame_rect * self.device_pixels_per_page_px(); + } + None => {} + } + for kid in frame_tree.children.iter() { - root_layer.add_child(self.create_frame_tree_root_layers(&kid.frame_tree)); + root_layer.add_child(self.create_frame_tree_root_layers(&kid.frame_tree, kid.rect)); } return root_layer; } @@ -701,13 +710,15 @@ impl IOCompositor { self.hidpi_factor = new_hidpi_factor; self.update_zoom_transform(); } - if self.window_size != new_size { - debug!("osmain: window resized to {:?}", new_size); - self.window_size = new_size; - self.send_window_size(); - } else { - debug!("osmain: dropping window resize since size is still {:?}", new_size); + + if self.window_size == new_size { + return; } + + debug!("osmain: window resized to {:?}", new_size); + self.window_size = new_size; + self.scene.set_root_layer_size(new_size.as_f32()); + self.send_window_size(); } fn on_load_url_window_event(&mut self, url_string: String) { diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index c4d77206c38..74fe836c0b3 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -11,7 +11,7 @@ dependencies = [ "glfw 0.0.1 (git+https://github.com/servo/glfw-rs?ref=servo#955dbe919870b0536f79123232d87c0efe3c552e)", "glut 0.0.1 (git+https://github.com/servo/rust-glut#01af0162ea0322ad1a40d6adb023a39813605949)", "js 0.1.0 (git+https://github.com/servo/rust-mozjs#41fb0d80a5ed5614ca13a120cdb3281e599d4e04)", - "layers 0.1.0 (git+https://github.com/servo/rust-layers#ef89918471815dfced7aaf2f1594d5469f03eab7)", + "layers 0.1.0 (git+https://github.com/servo/rust-layers#ed570335738913fb41fc62a024389dfa415962e8)", "plugins 0.0.1", "msg 0.0.1", "net 0.0.1", @@ -45,7 +45,7 @@ dependencies = [ "freetype 0.1.0 (git+https://github.com/servo/rust-freetype#0b03da276e4bdeae2300596dabc4ccb16733ad70)", "geom 0.1.0 (git+https://github.com/servo/rust-geom#50a294fd997f0c6eb43e9a58ad6e227fdc2a4692)", "glfw 0.0.1 (git+https://github.com/servo/glfw-rs?ref=servo#955dbe919870b0536f79123232d87c0efe3c552e)", - "layers 0.1.0 (git+https://github.com/servo/rust-layers#ef89918471815dfced7aaf2f1594d5469f03eab7)", + "layers 0.1.0 (git+https://github.com/servo/rust-layers#ed570335738913fb41fc62a024389dfa415962e8)", "opengles 0.1.0 (git+https://github.com/servo/rust-opengles#6776e9c07feb149d34b087039ecf6b2c143e3afc)", "skia-sys 0.0.20130412 (git+https://github.com/servo/skia#6d696712962fd0d41120b7a414a48417da8e6a92)", "xlib 0.1.0 (git+https://github.com/servo/rust-xlib#581d4faddec5188d3c3ae5307dbea28aab90644c)", @@ -78,7 +78,7 @@ dependencies = [ "gfx 0.0.1", "glfw 0.0.1 (git+https://github.com/servo/glfw-rs?ref=servo#955dbe919870b0536f79123232d87c0efe3c552e)", "glut 0.0.1 (git+https://github.com/servo/rust-glut#01af0162ea0322ad1a40d6adb023a39813605949)", - "layers 0.1.0 (git+https://github.com/servo/rust-layers#ef89918471815dfced7aaf2f1594d5469f03eab7)", + "layers 0.1.0 (git+https://github.com/servo/rust-layers#ed570335738913fb41fc62a024389dfa415962e8)", "layout_traits 0.0.1", "msg 0.0.1", "net 0.0.1", @@ -193,7 +193,7 @@ dependencies = [ "freetype 0.1.0 (git+https://github.com/servo/rust-freetype#0b03da276e4bdeae2300596dabc4ccb16733ad70)", "geom 0.1.0 (git+https://github.com/servo/rust-geom#50a294fd997f0c6eb43e9a58ad6e227fdc2a4692)", "harfbuzz 0.1.0 (git+https://github.com/servo/rust-harfbuzz#ad520942cc17232e1a40cdd8a99c2905623d35f6)", - "layers 0.1.0 (git+https://github.com/servo/rust-layers#ef89918471815dfced7aaf2f1594d5469f03eab7)", + "layers 0.1.0 (git+https://github.com/servo/rust-layers#ed570335738913fb41fc62a024389dfa415962e8)", "plugins 0.0.1", "msg 0.0.1", "net 0.0.1", @@ -277,7 +277,7 @@ dependencies = [ [[package]] name = "layers" version = "0.1.0" -source = "git+https://github.com/servo/rust-layers#ef89918471815dfced7aaf2f1594d5469f03eab7" +source = "git+https://github.com/servo/rust-layers#ed570335738913fb41fc62a024389dfa415962e8" dependencies = [ "core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation#166a601ff3e0fc3a64ca1a9090d02c8d4f22b61a)", "egl 0.1.0 (git+https://github.com/servo/rust-egl#88f2a13812ddbce2bf2317221663a61c31b3e220)", @@ -337,7 +337,7 @@ dependencies = [ "core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation#166a601ff3e0fc3a64ca1a9090d02c8d4f22b61a)", "geom 0.1.0 (git+https://github.com/servo/rust-geom#50a294fd997f0c6eb43e9a58ad6e227fdc2a4692)", "io_surface 0.1.0 (git+https://github.com/servo/rust-io-surface#7038341220bd7e86e21118fac2cbc6bd50890e47)", - "layers 0.1.0 (git+https://github.com/servo/rust-layers#ef89918471815dfced7aaf2f1594d5469f03eab7)", + "layers 0.1.0 (git+https://github.com/servo/rust-layers#ed570335738913fb41fc62a024389dfa415962e8)", "url 0.1.0 (git+https://github.com/servo/rust-url#bfdf809365600a7941a77524f9bb065886de3379)", "util 0.0.1", ]