mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Merge pull request #2798 from mrobinson/more-rust-layers-cleanup
More rust layers cleanup
This commit is contained in:
commit
d4e15697c2
4 changed files with 49 additions and 180 deletions
|
@ -368,15 +368,13 @@ impl IOCompositor {
|
||||||
};
|
};
|
||||||
let new_compositor_data = CompositorData::new_root(root_pipeline,
|
let new_compositor_data = CompositorData::new_root(root_pipeline,
|
||||||
layer_properties.epoch,
|
layer_properties.epoch,
|
||||||
layer_properties.rect.size,
|
|
||||||
self.opts.cpu_painting,
|
self.opts.cpu_painting,
|
||||||
layer_properties.background_color);
|
layer_properties.background_color);
|
||||||
let size = layer_properties.rect.size;
|
let new_root = Rc::new(Layer::new(layer_properties.rect,
|
||||||
let new_root = Rc::new(Layer::new(size,
|
|
||||||
self.opts.tile_size,
|
self.opts.tile_size,
|
||||||
new_compositor_data));
|
new_compositor_data));
|
||||||
|
|
||||||
CompositorData::add_child(new_root.clone(), layer_properties, size);
|
CompositorData::add_child(new_root.clone(), layer_properties);
|
||||||
|
|
||||||
// Release all tiles from the layer before dropping it.
|
// Release all tiles from the layer before dropping it.
|
||||||
match self.scene.root {
|
match self.scene.root {
|
||||||
|
@ -408,8 +406,7 @@ impl IOCompositor {
|
||||||
layer_properties.pipeline_id,
|
layer_properties.pipeline_id,
|
||||||
parent_layer_id) {
|
parent_layer_id) {
|
||||||
Some(ref mut parent_layer) => {
|
Some(ref mut parent_layer) => {
|
||||||
let page_size = root_layer.extra_data.borrow().page_size.unwrap();
|
CompositorData::add_child(parent_layer.clone(), layer_properties);
|
||||||
CompositorData::add_child(parent_layer.clone(), layer_properties, page_size);
|
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
fail!("Compositor: couldn't find parent layer");
|
fail!("Compositor: couldn't find parent layer");
|
||||||
|
@ -526,8 +523,7 @@ impl IOCompositor {
|
||||||
point: Point2D<f32>) {
|
point: Point2D<f32>) {
|
||||||
let page_window = self.page_window();
|
let page_window = self.page_window();
|
||||||
let (ask, move): (bool, bool) = match self.scene.root {
|
let (ask, move): (bool, bool) = match self.scene.root {
|
||||||
Some(ref layer) if layer.extra_data.borrow().pipeline.id == pipeline_id &&
|
Some(ref layer) if layer.extra_data.borrow().pipeline.id == pipeline_id => {
|
||||||
!layer.extra_data.borrow().hidden => {
|
|
||||||
(true,
|
(true,
|
||||||
events::move(layer.clone(), pipeline_id, layer_id, point, page_window))
|
events::move(layer.clone(), pipeline_id, layer_id, point, page_window))
|
||||||
}
|
}
|
||||||
|
@ -745,7 +741,7 @@ impl IOCompositor {
|
||||||
let scale = self.device_pixels_per_page_px();
|
let scale = self.device_pixels_per_page_px();
|
||||||
let page_window = self.page_window();
|
let page_window = self.page_window();
|
||||||
match self.scene.root {
|
match self.scene.root {
|
||||||
Some(ref mut layer) if !layer.extra_data.borrow().hidden => {
|
Some(ref mut layer) => {
|
||||||
let rect = Rect(Point2D(0f32, 0f32), page_window.to_untyped());
|
let rect = Rect(Point2D(0f32, 0f32), page_window.to_untyped());
|
||||||
let recomposite =
|
let recomposite =
|
||||||
CompositorData::send_buffer_requests_recursively(layer.clone(),
|
CompositorData::send_buffer_requests_recursively(layer.clone(),
|
||||||
|
@ -754,9 +750,6 @@ impl IOCompositor {
|
||||||
scale.get());
|
scale.get());
|
||||||
self.recomposite = self.recomposite || recomposite;
|
self.recomposite = self.recomposite || recomposite;
|
||||||
}
|
}
|
||||||
Some(_) => {
|
|
||||||
debug!("Compositor: root layer is hidden!");
|
|
||||||
}
|
|
||||||
None => { }
|
None => { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,12 +8,12 @@ use pipeline::CompositionPipeline;
|
||||||
|
|
||||||
use azure::azure_hl::Color;
|
use azure::azure_hl::Color;
|
||||||
use geom::matrix::identity;
|
use geom::matrix::identity;
|
||||||
use geom::point::{Point2D, TypedPoint2D};
|
use geom::point::TypedPoint2D;
|
||||||
use geom::rect::Rect;
|
use geom::rect::Rect;
|
||||||
use geom::size::{Size2D, TypedSize2D};
|
use geom::size::{Size2D, TypedSize2D};
|
||||||
use gfx::render_task::{ReRenderMsg, UnusedBufferMsg};
|
use gfx::render_task::{ReRenderMsg, UnusedBufferMsg};
|
||||||
use layers::layers::{Layer, Flip, LayerBuffer, LayerBufferSet, NoFlip, TextureLayer};
|
use layers::layers::{Layer, Flip, LayerBuffer, LayerBufferSet, NoFlip, TextureLayer};
|
||||||
use layers::quadtree::{Tile, Normal, Hidden};
|
use layers::quadtree::Tile;
|
||||||
use layers::platform::surface::{NativeCompositingGraphicsContext, NativeSurfaceMethods};
|
use layers::platform::surface::{NativeCompositingGraphicsContext, NativeSurfaceMethods};
|
||||||
use layers::texturegl::{Texture, TextureTarget};
|
use layers::texturegl::{Texture, TextureTarget};
|
||||||
use servo_msg::compositor_msg::{Epoch, FixedPosition, LayerId};
|
use servo_msg::compositor_msg::{Epoch, FixedPosition, LayerId};
|
||||||
|
@ -41,18 +41,6 @@ pub struct CompositorData {
|
||||||
/// top left corner of the page.
|
/// top left corner of the page.
|
||||||
pub scroll_offset: TypedPoint2D<PagePx, f32>,
|
pub scroll_offset: TypedPoint2D<PagePx, f32>,
|
||||||
|
|
||||||
/// The bounds of this layer in terms of its parent (a.k.a. the scissor box).
|
|
||||||
pub bounds: Rect<f32>,
|
|
||||||
|
|
||||||
/// The size of the underlying page in page coordinates. This is an option
|
|
||||||
/// because we may not know the size of the page until layout is finished completely.
|
|
||||||
/// if we have no size yet, the layer is hidden until a size message is recieved.
|
|
||||||
pub page_size: Option<Size2D<f32>>,
|
|
||||||
|
|
||||||
/// When set to true, this layer is ignored by its parents. This is useful for
|
|
||||||
/// soft deletion or when waiting on a page size.
|
|
||||||
pub hidden: bool,
|
|
||||||
|
|
||||||
/// The behavior of this layer when a scroll message is received.
|
/// The behavior of this layer when a scroll message is received.
|
||||||
pub wants_scroll_events: WantsScrollEventsFlag,
|
pub wants_scroll_events: WantsScrollEventsFlag,
|
||||||
|
|
||||||
|
@ -65,8 +53,6 @@ pub struct CompositorData {
|
||||||
/// The color to use for the unrendered-content void
|
/// The color to use for the unrendered-content void
|
||||||
pub unrendered_color: Color,
|
pub unrendered_color: Color,
|
||||||
|
|
||||||
pub scissor: Option<Rect<f32>>,
|
|
||||||
|
|
||||||
/// A monotonically increasing counter that keeps track of the current epoch.
|
/// A monotonically increasing counter that keeps track of the current epoch.
|
||||||
/// add_buffer() calls that don't match the current epoch will be ignored.
|
/// add_buffer() calls that don't match the current epoch will be ignored.
|
||||||
pub epoch: Epoch,
|
pub epoch: Epoch,
|
||||||
|
@ -82,8 +68,6 @@ impl CompositorData {
|
||||||
pub fn new(pipeline: CompositionPipeline,
|
pub fn new(pipeline: CompositionPipeline,
|
||||||
layer_id: LayerId,
|
layer_id: LayerId,
|
||||||
epoch: Epoch,
|
epoch: Epoch,
|
||||||
bounds: Rect<f32>,
|
|
||||||
page_size: Option<Size2D<f32>>,
|
|
||||||
cpu_painting: bool,
|
cpu_painting: bool,
|
||||||
wants_scroll_events: WantsScrollEventsFlag,
|
wants_scroll_events: WantsScrollEventsFlag,
|
||||||
scroll_policy: ScrollPolicy,
|
scroll_policy: ScrollPolicy,
|
||||||
|
@ -93,28 +77,21 @@ impl CompositorData {
|
||||||
pipeline: pipeline,
|
pipeline: pipeline,
|
||||||
id: layer_id,
|
id: layer_id,
|
||||||
scroll_offset: TypedPoint2D(0f32, 0f32),
|
scroll_offset: TypedPoint2D(0f32, 0f32),
|
||||||
bounds: bounds,
|
|
||||||
page_size: page_size,
|
|
||||||
hidden: false,
|
|
||||||
wants_scroll_events: wants_scroll_events,
|
wants_scroll_events: wants_scroll_events,
|
||||||
scroll_policy: scroll_policy,
|
scroll_policy: scroll_policy,
|
||||||
cpu_painting: cpu_painting,
|
cpu_painting: cpu_painting,
|
||||||
unrendered_color: unrendered_color,
|
unrendered_color: unrendered_color,
|
||||||
scissor: None,
|
|
||||||
epoch: epoch,
|
epoch: epoch,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_root(pipeline: CompositionPipeline,
|
pub fn new_root(pipeline: CompositionPipeline,
|
||||||
epoch: Epoch,
|
epoch: Epoch,
|
||||||
page_size: Size2D<f32>,
|
|
||||||
cpu_painting: bool,
|
cpu_painting: bool,
|
||||||
unrendered_color: Color) -> CompositorData {
|
unrendered_color: Color) -> CompositorData {
|
||||||
CompositorData::new(pipeline,
|
CompositorData::new(pipeline,
|
||||||
LayerId::null(),
|
LayerId::null(),
|
||||||
epoch,
|
epoch,
|
||||||
Rect(Point2D(0f32, 0f32), page_size),
|
|
||||||
Some(page_size),
|
|
||||||
cpu_painting,
|
cpu_painting,
|
||||||
WantsScrollEvents,
|
WantsScrollEvents,
|
||||||
FixedPosition,
|
FixedPosition,
|
||||||
|
@ -125,24 +102,18 @@ impl CompositorData {
|
||||||
/// exist yet. The child layer will have the same pipeline, tile size, memory limit, and CPU
|
/// exist yet. The child layer will have the same pipeline, tile size, memory limit, and CPU
|
||||||
/// painting status as its parent.
|
/// painting status as its parent.
|
||||||
pub fn add_child(layer: Rc<Layer<CompositorData>>,
|
pub fn add_child(layer: Rc<Layer<CompositorData>>,
|
||||||
layer_properties: LayerProperties,
|
layer_properties: LayerProperties) {
|
||||||
page_size: Size2D<f32>) {
|
|
||||||
let new_compositor_data = CompositorData::new(layer.extra_data.borrow().pipeline.clone(),
|
let new_compositor_data = CompositorData::new(layer.extra_data.borrow().pipeline.clone(),
|
||||||
layer_properties.id,
|
layer_properties.id,
|
||||||
layer_properties.epoch,
|
layer_properties.epoch,
|
||||||
layer_properties.rect,
|
|
||||||
Some(page_size),
|
|
||||||
layer.extra_data.borrow().cpu_painting,
|
layer.extra_data.borrow().cpu_painting,
|
||||||
DoesntWantScrollEvents,
|
DoesntWantScrollEvents,
|
||||||
layer_properties.scroll_policy,
|
layer_properties.scroll_policy,
|
||||||
layer_properties.background_color);
|
layer_properties.background_color);
|
||||||
let new_kid = Rc::new(Layer::new(page_size,
|
let new_kid = Rc::new(Layer::new(layer_properties.rect,
|
||||||
Layer::tile_size(layer.clone()),
|
Layer::tile_size(layer.clone()),
|
||||||
new_compositor_data));
|
new_compositor_data));
|
||||||
|
|
||||||
new_kid.extra_data.borrow_mut().scissor = Some(layer_properties.rect);
|
|
||||||
*new_kid.origin.borrow_mut() = layer_properties.rect.origin;
|
|
||||||
|
|
||||||
// Place the kid's layer in the container passed in.
|
// Place the kid's layer in the container passed in.
|
||||||
Layer::add_child(layer.clone(), new_kid.clone());
|
Layer::add_child(layer.clone(), new_kid.clone());
|
||||||
}
|
}
|
||||||
|
@ -178,41 +149,33 @@ impl CompositorData {
|
||||||
}
|
}
|
||||||
|
|
||||||
let send_child_buffer_request = |kid: &Rc<Layer<CompositorData>>| -> bool {
|
let send_child_buffer_request = |kid: &Rc<Layer<CompositorData>>| -> bool {
|
||||||
match kid.extra_data.borrow().scissor {
|
let mut new_rect = window_rect;
|
||||||
Some(scissor) => {
|
let offset = kid.extra_data.borrow().scroll_offset.to_untyped();
|
||||||
let mut new_rect = window_rect;
|
new_rect.origin.x = new_rect.origin.x - offset.x;
|
||||||
let offset = kid.extra_data.borrow().scroll_offset.to_untyped();
|
new_rect.origin.y = new_rect.origin.y - offset.y;
|
||||||
new_rect.origin.x = new_rect.origin.x - offset.x;
|
match new_rect.intersection(&*kid.bounds.borrow()) {
|
||||||
new_rect.origin.y = new_rect.origin.y - offset.y;
|
Some(new_rect) => {
|
||||||
match new_rect.intersection(&scissor) {
|
// Child layers act as if they are rendered at (0,0), so we
|
||||||
Some(new_rect) => {
|
// subtract the layer's (x,y) coords in its containing page
|
||||||
// Child layers act as if they are rendered at (0,0), so we
|
// to make the child_rect appear in coordinates local to it.
|
||||||
// subtract the layer's (x,y) coords in its containing page
|
let child_rect = Rect(new_rect.origin.sub(&kid.bounds.borrow().origin),
|
||||||
// to make the child_rect appear in coordinates local to it.
|
new_rect.size);
|
||||||
let child_rect = Rect(new_rect.origin.sub(&scissor.origin),
|
CompositorData::send_buffer_requests_recursively(kid.clone(),
|
||||||
new_rect.size);
|
graphics_context,
|
||||||
CompositorData::send_buffer_requests_recursively(kid.clone(),
|
child_rect,
|
||||||
graphics_context,
|
scale)
|
||||||
child_rect,
|
}
|
||||||
scale)
|
None => {
|
||||||
}
|
false // Layer is offscreen
|
||||||
None => {
|
|
||||||
false // Layer is offscreen
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
None => fail!("child layer not clipped!"),
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
layer.children().iter().filter(|x| !x.extra_data.borrow().hidden)
|
layer.children().iter().map(send_child_buffer_request).any(|b| b) || redisplay
|
||||||
.map(send_child_buffer_request)
|
|
||||||
.any(|b| b) || redisplay
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the sublayer to an absolute position in page coordinates relative to its parent,
|
// Move the sublayer to an absolute position in page coordinates relative to its parent,
|
||||||
// and clip the layer to the specified size in page coordinates.
|
// and clip the layer to the specified size in page coordinates.
|
||||||
// If the layer is hidden and has a defined page size, unhide it.
|
|
||||||
// This method returns false if the specified layer is not found.
|
// This method returns false if the specified layer is not found.
|
||||||
pub fn set_clipping_rect(layer: Rc<Layer<CompositorData>>,
|
pub fn set_clipping_rect(layer: Rc<Layer<CompositorData>>,
|
||||||
pipeline_id: PipelineId,
|
pipeline_id: PipelineId,
|
||||||
|
@ -225,24 +188,7 @@ impl CompositorData {
|
||||||
layer_id) {
|
layer_id) {
|
||||||
Some(child_node) => {
|
Some(child_node) => {
|
||||||
debug!("compositor_data: node found for set_clipping_rect()");
|
debug!("compositor_data: node found for set_clipping_rect()");
|
||||||
*child_node.origin.borrow_mut() = new_rect.origin;
|
*child_node.bounds.borrow_mut() = new_rect;
|
||||||
let old_rect = child_node.extra_data.borrow().scissor.clone();
|
|
||||||
child_node.extra_data.borrow_mut().scissor = Some(new_rect);
|
|
||||||
match old_rect {
|
|
||||||
Some(old_rect) => {
|
|
||||||
// Rect is unhidden
|
|
||||||
Layer::set_status_page(layer.clone(), old_rect, Normal, false);
|
|
||||||
}
|
|
||||||
None => {} // Nothing to do
|
|
||||||
}
|
|
||||||
// Hide the new rect
|
|
||||||
Layer::set_status_page(layer.clone(), new_rect, Hidden, false);
|
|
||||||
|
|
||||||
// If possible, unhide child
|
|
||||||
let mut child_data = child_node.extra_data.borrow_mut();
|
|
||||||
if child_data.hidden && child_data.page_size.is_some() {
|
|
||||||
child_data.hidden = false;
|
|
||||||
}
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
|
@ -253,45 +199,27 @@ impl CompositorData {
|
||||||
new_rect))
|
new_rect))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_layer(layer: Rc<Layer<CompositorData>>, layer_properties: LayerProperties) {
|
pub fn update_layer(layer: Rc<Layer<CompositorData>>, layer_properties: LayerProperties) {
|
||||||
layer.extra_data.borrow_mut().epoch = layer_properties.epoch;
|
layer.extra_data.borrow_mut().epoch = layer_properties.epoch;
|
||||||
layer.extra_data.borrow_mut().unrendered_color = layer_properties.background_color;
|
layer.extra_data.borrow_mut().unrendered_color = layer_properties.background_color;
|
||||||
CompositorData::resize(layer.clone(), layer_properties.rect.size);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resize and unhide a pre-existing layer. A new layer's size is set during creation.
|
let unused_buffers = Layer::resize(layer.clone(), layer_properties.rect.size);
|
||||||
fn resize(layer: Rc<Layer<CompositorData>>,
|
|
||||||
new_size: Size2D<f32>) {
|
|
||||||
debug!("compositor_data: starting resize_helper()");
|
|
||||||
|
|
||||||
debug!("compositor_data: layer found for resize_helper()");
|
|
||||||
layer.extra_data.borrow_mut().page_size = Some(new_size);
|
|
||||||
|
|
||||||
let unused_buffers = Layer::resize(layer.clone(), new_size);
|
|
||||||
if !unused_buffers.is_empty() {
|
if !unused_buffers.is_empty() {
|
||||||
let msg = UnusedBufferMsg(unused_buffers);
|
let msg = UnusedBufferMsg(unused_buffers);
|
||||||
let _ = layer.extra_data.borrow().pipeline.render_chan.send_opt(msg);
|
let _ = layer.extra_data.borrow().pipeline.render_chan.send_opt(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
let scissor_clone = layer.extra_data.borrow().scissor.clone();
|
// Call scroll for bounds checking if the page shrunk. Use (-1, -1) as the
|
||||||
match scissor_clone {
|
// cursor position to make sure the scroll isn't propagated downwards.
|
||||||
Some(scissor) => {
|
let size: TypedSize2D<PagePx, f32> = Size2D::from_untyped(&layer.bounds.borrow().size);
|
||||||
// Call scroll for bounds checking if the page shrunk. Use (-1, -1) as the
|
events::handle_scroll_event(layer.clone(),
|
||||||
// cursor position to make sure the scroll isn't propagated downwards.
|
|
||||||
let size: TypedSize2D<PagePx, f32> = Size2D::from_untyped(&scissor.size);
|
|
||||||
events::handle_scroll_event(layer.clone(),
|
|
||||||
TypedPoint2D(0f32, 0f32),
|
TypedPoint2D(0f32, 0f32),
|
||||||
TypedPoint2D(-1f32, -1f32),
|
TypedPoint2D(-1f32, -1f32),
|
||||||
size);
|
size);
|
||||||
layer.extra_data.borrow_mut().hidden = false;
|
|
||||||
}
|
|
||||||
None => {} // Nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
CompositorData::set_occlusions(layer.clone());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns whether the layer should be vertically flipped.
|
// Returns whether the layer should be vertically flipped.
|
||||||
|
@ -432,27 +360,6 @@ impl CompositorData {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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(layer: Rc<Layer<CompositorData>>) {
|
|
||||||
for kid in layer.children().iter() {
|
|
||||||
if !kid.extra_data.borrow().hidden {
|
|
||||||
match kid.extra_data.borrow().scissor {
|
|
||||||
None => {} // Nothing to do
|
|
||||||
Some(rect) => {
|
|
||||||
Layer::set_status_page(layer.clone(), rect, Hidden, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for kid in layer.children().iter() {
|
|
||||||
if !kid.extra_data.borrow().hidden {
|
|
||||||
CompositorData::set_occlusions(kid.clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Destroys all quadtree tiles, sending the buffers back to the renderer to be destroyed or
|
/// Destroys all quadtree tiles, sending the buffers back to the renderer to be destroyed or
|
||||||
/// reused.
|
/// reused.
|
||||||
fn clear(layer: Rc<Layer<CompositorData>>) {
|
fn clear(layer: Rc<Layer<CompositorData>>) {
|
||||||
|
|
|
@ -46,11 +46,6 @@ pub fn handle_scroll_event(layer: Rc<Layer<CompositorData>>,
|
||||||
cursor: TypedPoint2D<PagePx, f32>,
|
cursor: TypedPoint2D<PagePx, f32>,
|
||||||
window_size: TypedSize2D<PagePx, f32>)
|
window_size: TypedSize2D<PagePx, f32>)
|
||||||
-> bool {
|
-> bool {
|
||||||
// If this layer is hidden, neither it nor its children will scroll.
|
|
||||||
if layer.extra_data.borrow().hidden {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// If this layer doesn't want scroll events, neither it nor its children can handle scroll
|
// If this layer doesn't want scroll events, neither it nor its children can handle scroll
|
||||||
// events.
|
// events.
|
||||||
if layer.extra_data.borrow().wants_scroll_events != WantsScrollEvents {
|
if layer.extra_data.borrow().wants_scroll_events != WantsScrollEvents {
|
||||||
|
@ -60,20 +55,13 @@ pub fn handle_scroll_event(layer: Rc<Layer<CompositorData>>,
|
||||||
// Allow children to scroll.
|
// Allow children to scroll.
|
||||||
let cursor = cursor - layer.extra_data.borrow().scroll_offset;
|
let cursor = cursor - layer.extra_data.borrow().scroll_offset;
|
||||||
for child in layer.children().iter() {
|
for child in layer.children().iter() {
|
||||||
match child.extra_data.borrow().scissor {
|
let rect: TypedRect<PagePx, f32> = Rect::from_untyped(&*child.bounds.borrow());
|
||||||
None => {
|
if rect.contains(&cursor) &&
|
||||||
error!("CompositorData: unable to perform cursor hit test for layer");
|
handle_scroll_event(child.clone(),
|
||||||
}
|
delta,
|
||||||
Some(rect) => {
|
cursor - rect.origin,
|
||||||
let rect: TypedRect<PagePx, f32> = Rect::from_untyped(&rect);
|
rect.size) {
|
||||||
if rect.contains(&cursor) &&
|
return true
|
||||||
handle_scroll_event(child.clone(),
|
|
||||||
delta,
|
|
||||||
cursor - rect.origin,
|
|
||||||
rect.size) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,11 +71,7 @@ pub fn handle_scroll_event(layer: Rc<Layer<CompositorData>>,
|
||||||
layer.extra_data.borrow_mut().scroll_offset = old_origin + delta;
|
layer.extra_data.borrow_mut().scroll_offset = old_origin + delta;
|
||||||
|
|
||||||
// bounds checking
|
// bounds checking
|
||||||
let page_size = match layer.extra_data.borrow().page_size {
|
let page_size = layer.bounds.borrow().size;
|
||||||
Some(size) => size,
|
|
||||||
None => fail!("CompositorData: tried to scroll with no page size set"),
|
|
||||||
};
|
|
||||||
|
|
||||||
let window_size = window_size.to_untyped();
|
let window_size = window_size.to_untyped();
|
||||||
let scroll_offset = layer.extra_data.borrow().scroll_offset.to_untyped();
|
let scroll_offset = layer.extra_data.borrow().scroll_offset.to_untyped();
|
||||||
|
|
||||||
|
@ -137,21 +121,10 @@ pub fn send_mouse_event(layer: Rc<Layer<CompositorData>>,
|
||||||
event: MouseWindowEvent, cursor: TypedPoint2D<PagePx, f32>) {
|
event: MouseWindowEvent, cursor: TypedPoint2D<PagePx, f32>) {
|
||||||
let cursor = cursor - layer.extra_data.borrow().scroll_offset;
|
let cursor = cursor - layer.extra_data.borrow().scroll_offset;
|
||||||
for child in layer.children().iter() {
|
for child in layer.children().iter() {
|
||||||
if child.extra_data.borrow().hidden {
|
let rect: TypedRect<PagePx, f32> = Rect::from_untyped(&*child.bounds.borrow());
|
||||||
continue;
|
if rect.contains(&cursor) {
|
||||||
}
|
send_mouse_event(child.clone(), event, cursor - rect.origin);
|
||||||
|
return;
|
||||||
match child.extra_data.borrow().scissor {
|
|
||||||
None => {
|
|
||||||
error!("CompositorData: unable to perform cursor hit test for layer");
|
|
||||||
}
|
|
||||||
Some(rect) => {
|
|
||||||
let rect: TypedRect<PagePx, f32> = Rect::from_untyped(&rect);
|
|
||||||
if rect.contains(&cursor) {
|
|
||||||
send_mouse_event(child.clone(), event, cursor - rect.origin);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,10 +168,7 @@ pub fn move(layer: Rc<Layer<CompositorData>>,
|
||||||
layer.extra_data.borrow_mut().scroll_offset = Point2D::from_untyped(&(origin * -1.0));
|
layer.extra_data.borrow_mut().scroll_offset = Point2D::from_untyped(&(origin * -1.0));
|
||||||
|
|
||||||
// bounds checking
|
// bounds checking
|
||||||
let page_size = match layer.extra_data.borrow().page_size {
|
let page_size = layer.bounds.borrow().size;
|
||||||
Some(size) => size,
|
|
||||||
None => fail!("CompositorData: tried to scroll with no page size set"),
|
|
||||||
};
|
|
||||||
let window_size = window_size.to_untyped();
|
let window_size = window_size.to_untyped();
|
||||||
let scroll_offset = layer.extra_data.borrow().scroll_offset.to_untyped();
|
let scroll_offset = layer.extra_data.borrow().scroll_offset.to_untyped();
|
||||||
|
|
||||||
|
@ -215,4 +185,3 @@ pub fn move(layer: Rc<Layer<CompositorData>>,
|
||||||
let offset = layer.extra_data.borrow().scroll_offset.clone();
|
let offset = layer.extra_data.borrow().scroll_offset.clone();
|
||||||
scroll(layer.clone(), offset)
|
scroll(layer.clone(), offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit f49717435a375a1e3beb26777b7303204e0a1a8a
|
Subproject commit 3f116aef7db600654e6311aad2ac1968cbabf88a
|
Loading…
Add table
Add a link
Reference in a new issue