Remove the script listener thread (fixes #11345).

We needed a separate thread in the chrome process because communication to the
compositor is done through a trait object, and cross-process virtual calls are
forbidden.

Also, the fact that these messages are ultimately handled by the compositor is
an implementation detail; conceptually, the relevant constellation is supposed
to handle these messages.

So instead, the script thread will now send the messages to the constellation,
which will ask the compositor to handle them.
This commit is contained in:
Ms2ger 2016-05-25 10:33:28 +02:00
parent 586c0702a0
commit 4113eb6f72
8 changed files with 105 additions and 163 deletions

View file

@ -9,13 +9,13 @@ use compositor::{self, CompositingReason};
use euclid::point::Point2D;
use euclid::size::Size2D;
use gfx_traits::{Epoch, FrameTreeId, LayerId, LayerProperties, PaintListener};
use ipc_channel::ipc::{IpcReceiver, IpcSender};
use ipc_channel::ipc::IpcSender;
use layers::layers::{BufferRequest, LayerBufferSet};
use layers::platform::surface::{NativeDisplay, NativeSurface};
use msg::constellation_msg::{Image, Key, KeyModifiers, KeyState, PipelineId};
use profile_traits::mem;
use profile_traits::time;
use script_traits::{AnimationState, ConstellationMsg, EventResult, ScriptToCompositorMsg};
use script_traits::{AnimationState, ConstellationMsg, EventResult};
use std::fmt::{Debug, Error, Formatter};
use std::rc::Rc;
use std::sync::mpsc::{Receiver, Sender, channel};
@ -55,54 +55,6 @@ impl CompositorReceiver for Receiver<Msg> {
}
}
pub fn run_script_listener_thread(compositor_proxy: Box<CompositorProxy + 'static + Send>,
receiver: IpcReceiver<ScriptToCompositorMsg>) {
while let Ok(msg) = receiver.recv() {
match msg {
ScriptToCompositorMsg::ScrollFragmentPoint(pipeline_id, layer_id, point, smooth) => {
compositor_proxy.send(Msg::ScrollFragmentPoint(pipeline_id,
layer_id,
point,
smooth));
}
ScriptToCompositorMsg::GetClientWindow(send) => {
compositor_proxy.send(Msg::GetClientWindow(send));
}
ScriptToCompositorMsg::MoveTo(point) => {
compositor_proxy.send(Msg::MoveTo(point));
}
ScriptToCompositorMsg::ResizeTo(size) => {
compositor_proxy.send(Msg::ResizeTo(size));
}
ScriptToCompositorMsg::Exit => {
compositor_proxy.send(Msg::Exit);
}
ScriptToCompositorMsg::SetTitle(pipeline_id, title) => {
compositor_proxy.send(Msg::ChangePageTitle(pipeline_id, title))
}
ScriptToCompositorMsg::SendKeyEvent(key, key_state, key_modifiers) => {
compositor_proxy.send(Msg::KeyEvent(key, key_state, key_modifiers))
}
ScriptToCompositorMsg::TouchEventProcessed(result) => {
compositor_proxy.send(Msg::TouchEventProcessed(result))
}
ScriptToCompositorMsg::GetScrollOffset(pid, lid, send) => {
compositor_proxy.send(Msg::GetScrollOffset(pid, lid, send));
}
ScriptToCompositorMsg::Exited => break,
}
}
}
pub trait RenderListener {
fn recomposite(&mut self, reason: CompositingReason);
}