aboutsummaryrefslogtreecommitdiffstats
path: root/components/compositing/compositor_layer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/compositing/compositor_layer.rs')
-rw-r--r--components/compositing/compositor_layer.rs24
1 files changed, 15 insertions, 9 deletions
diff --git a/components/compositing/compositor_layer.rs b/components/compositing/compositor_layer.rs
index 811f704f52d..8e1330b9344 100644
--- a/components/compositing/compositor_layer.rs
+++ b/components/compositing/compositor_layer.rs
@@ -12,7 +12,8 @@ use layers::color::Color;
use layers::geometry::LayerPixel;
use layers::layers::{Layer, LayerBufferSet};
use msg::compositor_msg::{Epoch, LayerId, LayerProperties, ScrollPolicy};
-use msg::constellation_msg::{PipelineId};
+use msg::constellation_msg::PipelineId;
+use script_traits::CompositorEvent;
use script_traits::CompositorEvent::{ClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent};
use script_traits::ConstellationControlMsg;
use std::rc::Rc;
@@ -132,6 +133,11 @@ pub trait CompositorLayer {
cursor: TypedPoint2D<LayerPixel, f32>)
where Window: WindowMethods;
+ fn send_event<Window>(&self,
+ compositor: &IOCompositor<Window>,
+ event: CompositorEvent)
+ where Window: WindowMethods;
+
fn clamp_scroll_offset_and_scroll_layer(&self,
new_offset: TypedPoint2D<LayerPixel, f32>)
-> ScrollEventResult;
@@ -372,22 +378,22 @@ impl CompositorLayer for Layer<CompositorData> {
MouseWindowEvent::MouseUp(button, _) =>
MouseUpEvent(button, event_point),
};
-
- if let Some(pipeline) = compositor.pipeline(self.pipeline_id()) {
- pipeline.script_chan
- .send(ConstellationControlMsg::SendEvent(pipeline.id.clone(), message))
- .unwrap();
- }
+ self.send_event(compositor, message);
}
fn send_mouse_move_event<Window>(&self,
compositor: &IOCompositor<Window>,
cursor: TypedPoint2D<LayerPixel, f32>)
where Window: WindowMethods {
- let message = MouseMoveEvent(cursor.to_untyped());
+ self.send_event(compositor, MouseMoveEvent(cursor.to_untyped()));
+ }
+
+ fn send_event<Window>(&self,
+ compositor: &IOCompositor<Window>,
+ event: CompositorEvent) where Window: WindowMethods {
if let Some(pipeline) = compositor.pipeline(self.pipeline_id()) {
let _ = pipeline.script_chan
- .send(ConstellationControlMsg::SendEvent(pipeline.id.clone(), message));
+ .send(ConstellationControlMsg::SendEvent(pipeline.id.clone(), event));
}
}