mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
parent
7c63c7d7c1
commit
14ac1ef75a
7 changed files with 24 additions and 70 deletions
|
@ -16,7 +16,6 @@ use gfx::font_cache_task::FontCacheTask;
|
||||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||||
use ipc_channel::router::ROUTER;
|
use ipc_channel::router::ROUTER;
|
||||||
use layers::geometry::DevicePixel;
|
use layers::geometry::DevicePixel;
|
||||||
use msg::compositor_msg::ScriptListener;
|
|
||||||
use msg::constellation_msg::{ConstellationChan, Failure, FrameId, PipelineId, SubpageId};
|
use msg::constellation_msg::{ConstellationChan, Failure, FrameId, PipelineId, SubpageId};
|
||||||
use msg::constellation_msg::{LoadData, WindowSizeData, PipelineExitType, MozBrowserEvent};
|
use msg::constellation_msg::{LoadData, WindowSizeData, PipelineExitType, MozBrowserEvent};
|
||||||
use profile_traits::mem as profile_mem;
|
use profile_traits::mem as profile_mem;
|
||||||
|
@ -323,7 +322,7 @@ impl PipelineContent {
|
||||||
ScriptTaskFactory::create(None::<&mut STF>,
|
ScriptTaskFactory::create(None::<&mut STF>,
|
||||||
self.id,
|
self.id,
|
||||||
self.parent_info,
|
self.parent_info,
|
||||||
ScriptListener::new(script_to_compositor_chan),
|
script_to_compositor_chan,
|
||||||
&layout_pair,
|
&layout_pair,
|
||||||
self.script_chan.clone(),
|
self.script_chan.clone(),
|
||||||
mem::replace(&mut self.script_port, None).unwrap(),
|
mem::replace(&mut self.script_port, None).unwrap(),
|
||||||
|
|
|
@ -7,7 +7,6 @@ use constellation_msg::{Key, KeyState, KeyModifiers};
|
||||||
use euclid::point::Point2D;
|
use euclid::point::Point2D;
|
||||||
use euclid::rect::Rect;
|
use euclid::rect::Rect;
|
||||||
use euclid::Matrix4;
|
use euclid::Matrix4;
|
||||||
use ipc_channel::ipc::IpcSender;
|
|
||||||
use layers::platform::surface::NativeDisplay;
|
use layers::platform::surface::NativeDisplay;
|
||||||
use layers::layers::{BufferRequest, LayerBufferSet};
|
use layers::layers::{BufferRequest, LayerBufferSet};
|
||||||
use std::fmt::{Formatter, Debug};
|
use std::fmt::{Formatter, Debug};
|
||||||
|
@ -126,39 +125,3 @@ pub enum ScriptToCompositorMsg {
|
||||||
Exit,
|
Exit,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The interface used by the script task to tell the compositor to update its ready state,
|
|
||||||
/// which is used in displaying the appropriate message in the window's title.
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct ScriptListener(IpcSender<ScriptToCompositorMsg>);
|
|
||||||
|
|
||||||
impl ScriptListener {
|
|
||||||
pub fn new(sender: IpcSender<ScriptToCompositorMsg>) -> ScriptListener {
|
|
||||||
ScriptListener(sender)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn scroll_fragment_point(&mut self,
|
|
||||||
pipeline_id: PipelineId,
|
|
||||||
layer_id: LayerId,
|
|
||||||
point: Point2D<f32>) {
|
|
||||||
self.0
|
|
||||||
.send(ScriptToCompositorMsg::ScrollFragmentPoint(pipeline_id, layer_id, point))
|
|
||||||
.unwrap()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn close(&mut self) {
|
|
||||||
self.0.send(ScriptToCompositorMsg::Exit).unwrap()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn dup(&mut self) -> ScriptListener {
|
|
||||||
self.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_title(&mut self, pipeline_id: PipelineId, title: Option<String>) {
|
|
||||||
self.0.send(ScriptToCompositorMsg::SetTitle(pipeline_id, title)).unwrap()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn send_key_event(&mut self, key: Key, state: KeyState, modifiers: KeyModifiers) {
|
|
||||||
self.0.send(ScriptToCompositorMsg::SendKeyEvent(key, state, modifiers)).unwrap()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,6 @@ use net_traits::storage_task::StorageType;
|
||||||
use script_traits::UntrustedNodeAddress;
|
use script_traits::UntrustedNodeAddress;
|
||||||
use serde::{Serialize, Deserialize};
|
use serde::{Serialize, Deserialize};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use msg::compositor_msg::ScriptListener;
|
|
||||||
use msg::constellation_msg::ConstellationChan;
|
use msg::constellation_msg::ConstellationChan;
|
||||||
use net_traits::image::base::Image;
|
use net_traits::image::base::Image;
|
||||||
use profile_traits::mem::ProfilerChan;
|
use profile_traits::mem::ProfilerChan;
|
||||||
|
@ -342,13 +341,6 @@ impl<T> JSTraceable for IpcSender<T> where T: Deserialize + Serialize {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl JSTraceable for ScriptListener {
|
|
||||||
#[inline]
|
|
||||||
fn trace(&self, _: *mut JSTracer) {
|
|
||||||
// Do nothing
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl JSTraceable for Box<LayoutRPC+'static> {
|
impl JSTraceable for Box<LayoutRPC+'static> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn trace(&self, _: *mut JSTracer) {
|
fn trace(&self, _: *mut JSTracer) {
|
||||||
|
|
|
@ -69,7 +69,7 @@ use dom::uievent::UIEvent;
|
||||||
use dom::window::{Window, WindowHelpers, ReflowReason};
|
use dom::window::{Window, WindowHelpers, ReflowReason};
|
||||||
|
|
||||||
use layout_interface::{HitTestResponse, MouseOverResponse};
|
use layout_interface::{HitTestResponse, MouseOverResponse};
|
||||||
use msg::compositor_msg::ScriptListener;
|
use msg::compositor_msg::ScriptToCompositorMsg;
|
||||||
use msg::constellation_msg::AnimationState;
|
use msg::constellation_msg::AnimationState;
|
||||||
use msg::constellation_msg::Msg as ConstellationMsg;
|
use msg::constellation_msg::Msg as ConstellationMsg;
|
||||||
use msg::constellation_msg::{ConstellationChan, FocusType, Key, KeyState, KeyModifiers, MozBrowserEvent, SubpageId};
|
use msg::constellation_msg::{ConstellationChan, FocusType, Key, KeyState, KeyModifiers, MozBrowserEvent, SubpageId};
|
||||||
|
@ -85,7 +85,7 @@ use layout_interface::{ReflowGoal, ReflowQueryType};
|
||||||
|
|
||||||
use euclid::point::Point2D;
|
use euclid::point::Point2D;
|
||||||
use html5ever::tree_builder::{QuirksMode, NoQuirks, LimitedQuirks, Quirks};
|
use html5ever::tree_builder::{QuirksMode, NoQuirks, LimitedQuirks, Quirks};
|
||||||
use ipc_channel::ipc;
|
use ipc_channel::ipc::{self, IpcSender};
|
||||||
use layout_interface::{LayoutChan, Msg};
|
use layout_interface::{LayoutChan, Msg};
|
||||||
use string_cache::{Atom, QualName};
|
use string_cache::{Atom, QualName};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
@ -272,7 +272,7 @@ pub trait DocumentHelpers<'a> {
|
||||||
key: Key,
|
key: Key,
|
||||||
state: KeyState,
|
state: KeyState,
|
||||||
modifiers: KeyModifiers,
|
modifiers: KeyModifiers,
|
||||||
compositor: &mut ScriptListener);
|
compositor: &mut IpcSender<ScriptToCompositorMsg>);
|
||||||
fn node_from_nodes_and_strings(self, nodes: Vec<NodeOrString>)
|
fn node_from_nodes_and_strings(self, nodes: Vec<NodeOrString>)
|
||||||
-> Fallible<Root<Node>>;
|
-> Fallible<Root<Node>>;
|
||||||
fn get_body_attribute(self, local_name: &Atom) -> DOMString;
|
fn get_body_attribute(self, local_name: &Atom) -> DOMString;
|
||||||
|
@ -637,8 +637,8 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
||||||
let window = self.window();
|
let window = self.window();
|
||||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||||
let window = window.r();
|
let window = window.r();
|
||||||
let mut compositor = window.compositor();
|
let compositor = window.compositor();
|
||||||
compositor.set_title(window.pipeline(), Some(self.Title()));
|
compositor.send(ScriptToCompositorMsg::SetTitle(window.pipeline(), Some(self.Title()))).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dirty_all_nodes(self) {
|
fn dirty_all_nodes(self) {
|
||||||
|
@ -813,7 +813,7 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
||||||
key: Key,
|
key: Key,
|
||||||
state: KeyState,
|
state: KeyState,
|
||||||
modifiers: KeyModifiers,
|
modifiers: KeyModifiers,
|
||||||
compositor: &mut ScriptListener) {
|
compositor: &mut IpcSender<ScriptToCompositorMsg>) {
|
||||||
let window = self.window.root();
|
let window = self.window.root();
|
||||||
let focused = self.get_focused_element();
|
let focused = self.get_focused_element();
|
||||||
let body = self.GetBody();
|
let body = self.GetBody();
|
||||||
|
@ -864,7 +864,7 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !prevented {
|
if !prevented {
|
||||||
compositor.send_key_event(key, state, modifiers);
|
compositor.send(ScriptToCompositorMsg::SendKeyEvent(key, state, modifiers)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This behavior is unspecced
|
// This behavior is unspecced
|
||||||
|
|
|
@ -42,7 +42,7 @@ use webdriver_handlers::jsval_to_webdriver;
|
||||||
|
|
||||||
use devtools_traits::{ScriptToDevtoolsControlMsg, TimelineMarker, TimelineMarkerType};
|
use devtools_traits::{ScriptToDevtoolsControlMsg, TimelineMarker, TimelineMarkerType};
|
||||||
use devtools_traits::{TracingMetadata};
|
use devtools_traits::{TracingMetadata};
|
||||||
use msg::compositor_msg::ScriptListener;
|
use msg::compositor_msg::ScriptToCompositorMsg;
|
||||||
use msg::constellation_msg::{LoadData, PipelineId, SubpageId, ConstellationChan, WindowSizeData, WorkerId};
|
use msg::constellation_msg::{LoadData, PipelineId, SubpageId, ConstellationChan, WindowSizeData, WorkerId};
|
||||||
use msg::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
|
use msg::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
|
||||||
use net_traits::ResourceTask;
|
use net_traits::ResourceTask;
|
||||||
|
@ -121,7 +121,7 @@ pub struct Window {
|
||||||
#[ignore_heap_size_of = "channels are hard"]
|
#[ignore_heap_size_of = "channels are hard"]
|
||||||
image_cache_chan: ImageCacheChan,
|
image_cache_chan: ImageCacheChan,
|
||||||
#[ignore_heap_size_of = "TODO(#6911) newtypes containing unmeasurable types are hard"]
|
#[ignore_heap_size_of = "TODO(#6911) newtypes containing unmeasurable types are hard"]
|
||||||
compositor: DOMRefCell<ScriptListener>,
|
compositor: DOMRefCell<IpcSender<ScriptToCompositorMsg>>,
|
||||||
browsing_context: DOMRefCell<Option<BrowsingContext>>,
|
browsing_context: DOMRefCell<Option<BrowsingContext>>,
|
||||||
page: Rc<Page>,
|
page: Rc<Page>,
|
||||||
performance: MutNullableHeap<JS<Performance>>,
|
performance: MutNullableHeap<JS<Performance>>,
|
||||||
|
@ -273,7 +273,7 @@ impl Window {
|
||||||
&self.image_cache_task
|
&self.image_cache_task
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn compositor<'a>(&'a self) -> RefMut<'a, ScriptListener> {
|
pub fn compositor<'a>(&'a self) -> RefMut<'a, IpcSender<ScriptToCompositorMsg>> {
|
||||||
self.compositor.borrow_mut()
|
self.compositor.borrow_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1073,7 +1073,7 @@ impl Window {
|
||||||
script_chan: MainThreadScriptChan,
|
script_chan: MainThreadScriptChan,
|
||||||
image_cache_chan: ImageCacheChan,
|
image_cache_chan: ImageCacheChan,
|
||||||
control_chan: Sender<ConstellationControlMsg>,
|
control_chan: Sender<ConstellationControlMsg>,
|
||||||
compositor: ScriptListener,
|
compositor: IpcSender<ScriptToCompositorMsg>,
|
||||||
image_cache_task: ImageCacheTask,
|
image_cache_task: ImageCacheTask,
|
||||||
resource_task: Arc<ResourceTask>,
|
resource_task: Arc<ResourceTask>,
|
||||||
storage_task: StorageTask,
|
storage_task: StorageTask,
|
||||||
|
|
|
@ -62,7 +62,7 @@ use script_traits::{CompositorEvent, MouseButton};
|
||||||
use script_traits::ConstellationControlMsg;
|
use script_traits::ConstellationControlMsg;
|
||||||
use script_traits::{NewLayoutInfo, OpaqueScriptLayoutChannel};
|
use script_traits::{NewLayoutInfo, OpaqueScriptLayoutChannel};
|
||||||
use script_traits::{ScriptState, ScriptTaskFactory};
|
use script_traits::{ScriptState, ScriptTaskFactory};
|
||||||
use msg::compositor_msg::{LayerId, ScriptListener};
|
use msg::compositor_msg::{LayerId, ScriptToCompositorMsg};
|
||||||
use msg::constellation_msg::{ConstellationChan, FocusType};
|
use msg::constellation_msg::{ConstellationChan, FocusType};
|
||||||
use msg::constellation_msg::{LoadData, PipelineId, SubpageId, MozBrowserEvent, WorkerId};
|
use msg::constellation_msg::{LoadData, PipelineId, SubpageId, MozBrowserEvent, WorkerId};
|
||||||
use msg::constellation_msg::{Failure, WindowSizeData, PipelineExitType};
|
use msg::constellation_msg::{Failure, WindowSizeData, PipelineExitType};
|
||||||
|
@ -97,7 +97,7 @@ use url::{Url, UrlParser};
|
||||||
use libc;
|
use libc;
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell, RefMut};
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::io::{stdout, Write};
|
use std::io::{stdout, Write};
|
||||||
use std::mem as std_mem;
|
use std::mem as std_mem;
|
||||||
|
@ -361,7 +361,7 @@ pub struct ScriptTask {
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
|
|
||||||
/// A handle to the compositor for communicating ready state messages.
|
/// A handle to the compositor for communicating ready state messages.
|
||||||
compositor: DOMRefCell<ScriptListener>,
|
compositor: DOMRefCell<IpcSender<ScriptToCompositorMsg>>,
|
||||||
|
|
||||||
/// The port on which we receive messages from the image cache
|
/// The port on which we receive messages from the image cache
|
||||||
image_cache_port: Receiver<ImageCacheResult>,
|
image_cache_port: Receiver<ImageCacheResult>,
|
||||||
|
@ -443,7 +443,7 @@ impl ScriptTaskFactory for ScriptTask {
|
||||||
fn create(_phantom: Option<&mut ScriptTask>,
|
fn create(_phantom: Option<&mut ScriptTask>,
|
||||||
id: PipelineId,
|
id: PipelineId,
|
||||||
parent_info: Option<(PipelineId, SubpageId)>,
|
parent_info: Option<(PipelineId, SubpageId)>,
|
||||||
compositor: ScriptListener,
|
compositor: IpcSender<ScriptToCompositorMsg>,
|
||||||
layout_chan: &OpaqueScriptLayoutChannel,
|
layout_chan: &OpaqueScriptLayoutChannel,
|
||||||
control_chan: Sender<ConstellationControlMsg>,
|
control_chan: Sender<ConstellationControlMsg>,
|
||||||
control_port: Receiver<ConstellationControlMsg>,
|
control_port: Receiver<ConstellationControlMsg>,
|
||||||
|
@ -579,7 +579,7 @@ impl ScriptTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new script task.
|
/// Creates a new script task.
|
||||||
pub fn new(compositor: ScriptListener,
|
pub fn new(compositor: IpcSender<ScriptToCompositorMsg>,
|
||||||
port: Receiver<MainThreadScriptMsg>,
|
port: Receiver<MainThreadScriptMsg>,
|
||||||
chan: MainThreadScriptChan,
|
chan: MainThreadScriptChan,
|
||||||
control_chan: Sender<ConstellationControlMsg>,
|
control_chan: Sender<ConstellationControlMsg>,
|
||||||
|
@ -1329,7 +1329,7 @@ impl ScriptTask {
|
||||||
// TODO(tkuehn): currently there is only one window,
|
// TODO(tkuehn): currently there is only one window,
|
||||||
// so this can afford to be naive and just shut down the
|
// so this can afford to be naive and just shut down the
|
||||||
// compositor. In the future it'll need to be smarter.
|
// compositor. In the future it'll need to be smarter.
|
||||||
self.compositor.borrow_mut().close();
|
(*(RefMut::map(self.compositor.borrow_mut(), |t| t))).send(ScriptToCompositorMsg::Exit).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// We have received notification that the response associated with a load has completed.
|
/// We have received notification that the response associated with a load has completed.
|
||||||
|
@ -1506,7 +1506,7 @@ impl ScriptTask {
|
||||||
MainThreadScriptChan(sender.clone()),
|
MainThreadScriptChan(sender.clone()),
|
||||||
self.image_cache_channel.clone(),
|
self.image_cache_channel.clone(),
|
||||||
self.control_chan.clone(),
|
self.control_chan.clone(),
|
||||||
self.compositor.borrow_mut().dup(),
|
(*(RefMut::map(self.compositor.borrow_mut(), |t| t))).clone(),
|
||||||
self.image_cache_task.clone(),
|
self.image_cache_task.clone(),
|
||||||
self.resource_task.clone(),
|
self.resource_task.clone(),
|
||||||
self.storage_task.clone(),
|
self.storage_task.clone(),
|
||||||
|
@ -1601,7 +1601,8 @@ impl ScriptTask {
|
||||||
// Really what needs to happen is that this needs to go through layout to ask which
|
// Really what needs to happen is that this needs to go through layout to ask which
|
||||||
// layer the element belongs to, and have it send the scroll message to the
|
// layer the element belongs to, and have it send the scroll message to the
|
||||||
// compositor.
|
// compositor.
|
||||||
self.compositor.borrow_mut().scroll_fragment_point(pipeline_id, LayerId::null(), point);
|
(*(RefMut::map(self.compositor.borrow_mut(), |t| t))).send(
|
||||||
|
ScriptToCompositorMsg::ScrollFragmentPoint(pipeline_id, LayerId::null(), point)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reflows non-incrementally, rebuilding the entire layout tree in the process.
|
/// Reflows non-incrementally, rebuilding the entire layout tree in the process.
|
||||||
|
@ -1699,7 +1700,7 @@ impl ScriptTask {
|
||||||
let page = get_page(&self.root_page(), pipeline_id);
|
let page = get_page(&self.root_page(), pipeline_id);
|
||||||
let document = page.document();
|
let document = page.document();
|
||||||
document.r().dispatch_key_event(
|
document.r().dispatch_key_event(
|
||||||
key, state, modifiers, &mut *self.compositor.borrow_mut());
|
key, state, modifiers, &mut *(RefMut::map(self.compositor.borrow_mut(), |t| t)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,11 +24,10 @@ extern crate url;
|
||||||
use devtools_traits::ScriptToDevtoolsControlMsg;
|
use devtools_traits::ScriptToDevtoolsControlMsg;
|
||||||
use ipc_channel::ipc::{IpcReceiver, IpcSender};
|
use ipc_channel::ipc::{IpcReceiver, IpcSender};
|
||||||
use libc::c_void;
|
use libc::c_void;
|
||||||
use msg::compositor_msg::{Epoch, LayerId};
|
use msg::compositor_msg::{Epoch, LayerId, ScriptToCompositorMsg};
|
||||||
use msg::constellation_msg::{ConstellationChan, PipelineId, Failure, WindowSizeData};
|
use msg::constellation_msg::{ConstellationChan, PipelineId, Failure, WindowSizeData};
|
||||||
use msg::constellation_msg::{LoadData, SubpageId, Key, KeyState, KeyModifiers};
|
use msg::constellation_msg::{LoadData, SubpageId, Key, KeyState, KeyModifiers};
|
||||||
use msg::constellation_msg::{MozBrowserEvent, PipelineExitType};
|
use msg::constellation_msg::{MozBrowserEvent, PipelineExitType};
|
||||||
use msg::compositor_msg::ScriptListener;
|
|
||||||
use msg::webdriver_msg::WebDriverScriptCommand;
|
use msg::webdriver_msg::WebDriverScriptCommand;
|
||||||
use net_traits::ResourceTask;
|
use net_traits::ResourceTask;
|
||||||
use net_traits::image_cache_task::ImageCacheTask;
|
use net_traits::image_cache_task::ImageCacheTask;
|
||||||
|
@ -179,7 +178,7 @@ pub trait ScriptTaskFactory {
|
||||||
fn create(_phantom: Option<&mut Self>,
|
fn create(_phantom: Option<&mut Self>,
|
||||||
id: PipelineId,
|
id: PipelineId,
|
||||||
parent_info: Option<(PipelineId, SubpageId)>,
|
parent_info: Option<(PipelineId, SubpageId)>,
|
||||||
compositor: ScriptListener,
|
compositor: IpcSender<ScriptToCompositorMsg>,
|
||||||
layout_chan: &OpaqueScriptLayoutChannel,
|
layout_chan: &OpaqueScriptLayoutChannel,
|
||||||
control_chan: Sender<ConstellationControlMsg>,
|
control_chan: Sender<ConstellationControlMsg>,
|
||||||
control_port: Receiver<ConstellationControlMsg>,
|
control_port: Receiver<ConstellationControlMsg>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue