aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-06-01 14:06:41 -0500
committerbors-servo <lbergstrom+bors@mozilla.com>2016-06-01 14:06:41 -0500
commitc641ec97f02bf03a97f3562b9d138b14ebe1406c (patch)
treefc8f581748dd8dd6728b4aefaa82d23e0cd26e1d /components
parent4c8c57992b9addb8d45a1f1f5593f7490d975734 (diff)
parentf6682c2f96805aa24823c0be9bf904862f868ef1 (diff)
downloadservo-c641ec97f02bf03a97f3562b9d138b14ebe1406c.tar.gz
servo-c641ec97f02bf03a97f3562b9d138b14ebe1406c.zip
Auto merge of #11443 - kyleheadley:remove_trait_11339, r=asajeffrey
Remove CompositorEventListener trait <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #11339 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because refactoring <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11443) <!-- Reviewable:end -->
Diffstat (limited to 'components')
-rw-r--r--components/compositing/compositor.rs56
-rw-r--r--components/compositing/compositor_thread.rs17
-rw-r--r--components/compositing/lib.rs3
-rw-r--r--components/servo/lib.rs12
-rw-r--r--components/servo/main.rs2
5 files changed, 39 insertions, 51 deletions
diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs
index d25fdb4b7d2..89eb0bf29bc 100644
--- a/components/compositing/compositor.rs
+++ b/components/compositing/compositor.rs
@@ -6,8 +6,8 @@ use CompositionPipeline;
use SendableFrameTree;
use app_units::Au;
use compositor_layer::{CompositorData, CompositorLayer, RcCompositorLayer, WantsScrollEventsFlag};
-use compositor_thread::{CompositorEventListener, CompositorProxy};
-use compositor_thread::{CompositorReceiver, InitialCompositorState, Msg, RenderListener};
+use compositor_thread::{CompositorProxy, CompositorReceiver};
+use compositor_thread::{InitialCompositorState, Msg, RenderListener};
use delayed_composition::DelayedCompositionTimerProxy;
use euclid::point::TypedPoint2D;
use euclid::rect::TypedRect;
@@ -2501,31 +2501,8 @@ impl<Window: WindowMethods> IOCompositor<Window> {
webrender_api.tick_scrolling_bounce_animations()
}
}
-}
-
-fn find_layer_with_pipeline_and_layer_id_for_layer(layer: Rc<Layer<CompositorData>>,
- pipeline_id: PipelineId,
- layer_id: LayerId)
- -> Option<Rc<Layer<CompositorData>>> {
- if layer.extra_data.borrow().pipeline_id == pipeline_id &&
- layer.extra_data.borrow().id == layer_id {
- return Some(layer);
- }
-
- for kid in &*layer.children() {
- let result = find_layer_with_pipeline_and_layer_id_for_layer(kid.clone(),
- pipeline_id,
- layer_id);
- if result.is_some() {
- return result;
- }
- }
-
- None
-}
-impl<Window> CompositorEventListener for IOCompositor<Window> where Window: WindowMethods {
- fn handle_events(&mut self, messages: Vec<WindowEvent>) -> bool {
+ pub fn handle_events(&mut self, messages: Vec<WindowEvent>) -> bool {
// Check for new messages coming from the other threads in the system.
while let Some(msg) = self.port.try_recv_compositor_msg() {
if !self.handle_browser_message(msg) {
@@ -2568,7 +2545,7 @@ impl<Window> CompositorEventListener for IOCompositor<Window> where Window: Wind
/// paint is not scheduled the compositor will hang forever.
///
/// This is used when resizing the window.
- fn repaint_synchronously(&mut self) {
+ pub fn repaint_synchronously(&mut self) {
if self.webrender.is_none() {
while self.shutdown_state != ShutdownState::ShuttingDown {
let msg = self.port.recv_compositor_msg();
@@ -2604,11 +2581,11 @@ impl<Window> CompositorEventListener for IOCompositor<Window> where Window: Wind
}
}
- fn pinch_zoom_level(&self) -> f32 {
+ pub fn pinch_zoom_level(&self) -> f32 {
self.viewport_zoom.get() as f32
}
- fn title_for_main_frame(&self) {
+ pub fn title_for_main_frame(&self) {
let root_pipeline_id = match self.root_pipeline {
None => return,
Some(ref root_pipeline) => root_pipeline.id,
@@ -2620,6 +2597,27 @@ impl<Window> CompositorEventListener for IOCompositor<Window> where Window: Wind
}
}
+fn find_layer_with_pipeline_and_layer_id_for_layer(layer: Rc<Layer<CompositorData>>,
+ pipeline_id: PipelineId,
+ layer_id: LayerId)
+ -> Option<Rc<Layer<CompositorData>>> {
+ if layer.extra_data.borrow().pipeline_id == pipeline_id &&
+ layer.extra_data.borrow().id == layer_id {
+ return Some(layer);
+ }
+
+ for kid in &*layer.children() {
+ let result = find_layer_with_pipeline_and_layer_id_for_layer(kid.clone(),
+ pipeline_id,
+ layer_id);
+ if result.is_some() {
+ return result;
+ }
+ }
+
+ None
+}
+
/// Why we performed a composite. This is used for debugging.
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum CompositingReason {
diff --git a/components/compositing/compositor_thread.rs b/components/compositing/compositor_thread.rs
index e6a11d1cdcd..a51b11706ff 100644
--- a/components/compositing/compositor_thread.rs
+++ b/components/compositing/compositor_thread.rs
@@ -5,7 +5,7 @@
//! Communication with the compositor thread.
use SendableFrameTree;
-use compositor::{self, CompositingReason};
+use compositor::{CompositingReason, IOCompositor};
use euclid::point::Point2D;
use euclid::size::Size2D;
use gfx_traits::{Epoch, FrameTreeId, LayerId, LayerProperties, PaintListener};
@@ -24,7 +24,7 @@ use style_traits::viewport::ViewportConstraints;
use url::Url;
use webrender;
use webrender_traits;
-use windowing::{WindowEvent, WindowMethods};
+use windowing::WindowMethods;
/// Sends messages to the compositor. This is a trait supplied by the port because the method used
/// to communicate with the compositor may have to kick OS event loops awake, communicate cross-
@@ -236,21 +236,12 @@ pub struct CompositorThread;
impl CompositorThread {
pub fn create<Window>(window: Rc<Window>,
state: InitialCompositorState)
- -> Box<CompositorEventListener + 'static>
+ -> IOCompositor<Window>
where Window: WindowMethods + 'static {
- box compositor::IOCompositor::create(window, state)
- as Box<CompositorEventListener>
+ IOCompositor::create(window, state)
}
}
-pub trait CompositorEventListener {
- fn handle_events(&mut self, events: Vec<WindowEvent>) -> bool;
- fn repaint_synchronously(&mut self);
- fn pinch_zoom_level(&self) -> f32;
- /// Requests that the compositor send the title for the main frame as soon as possible.
- fn title_for_main_frame(&self);
-}
-
/// Data used to construct a compositor.
pub struct InitialCompositorState {
/// A channel to the compositor.
diff --git a/components/compositing/lib.rs b/components/compositing/lib.rs
index 4a58ea7b8e7..d18f9b28caa 100644
--- a/components/compositing/lib.rs
+++ b/components/compositing/lib.rs
@@ -36,7 +36,8 @@ extern crate util;
extern crate webrender;
extern crate webrender_traits;
-pub use compositor_thread::{CompositorEventListener, CompositorProxy, CompositorThread};
+pub use compositor_thread::{CompositorProxy, CompositorThread};
+pub use compositor::IOCompositor;
use euclid::size::TypedSize2D;
use gfx::paint_thread::ChromeToPaintMsg;
use ipc_channel::ipc::IpcSender;
diff --git a/components/servo/lib.rs b/components/servo/lib.rs
index 71a3bc77309..bb86a01080e 100644
--- a/components/servo/lib.rs
+++ b/components/servo/lib.rs
@@ -57,11 +57,10 @@ fn webdriver(port: u16, constellation: Sender<ConstellationMsg>) {
#[cfg(not(feature = "webdriver"))]
fn webdriver(_port: u16, _constellation: Sender<ConstellationMsg>) { }
-use compositing::CompositorEventListener;
use compositing::compositor_thread::InitialCompositorState;
use compositing::windowing::WindowEvent;
use compositing::windowing::WindowMethods;
-use compositing::{CompositorProxy, CompositorThread};
+use compositing::{CompositorProxy, CompositorThread, IOCompositor};
#[cfg(not(target_os = "windows"))]
use constellation::content_process_sandbox_profile;
use constellation::{Constellation, InitialConstellationState, UnprivilegedPipelineContent};
@@ -97,13 +96,12 @@ pub use gleam::gl;
/// application Servo is embedded in. Clients then create an event
/// loop to pump messages between the embedding application and
/// various browser components.
-pub struct Browser {
- compositor: Box<CompositorEventListener + 'static>,
+pub struct Browser<Window: WindowMethods + 'static> {
+ compositor: IOCompositor<Window>,
}
-impl Browser {
- pub fn new<Window>(window: Rc<Window>) -> Browser
- where Window: WindowMethods + 'static {
+impl<Window> Browser<Window> where Window: WindowMethods + 'static {
+ pub fn new(window: Rc<Window>) -> Browser<Window> {
// Global configuration options, parsed from the command line.
let opts = opts::get();
diff --git a/components/servo/main.rs b/components/servo/main.rs
index 214d9ee101d..361e0f01a75 100644
--- a/components/servo/main.rs
+++ b/components/servo/main.rs
@@ -98,7 +98,7 @@ fn unregister_glutin_resize_handler(window: &Rc<app::window::Window>) {
}
struct BrowserWrapper {
- browser: Browser,
+ browser: Browser<app::window::Window>,
}
impl app::NestedEventLoopListener for BrowserWrapper {