diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-05-25 06:10:17 -0500 |
---|---|---|
committer | bors-servo <lbergstrom+bors@mozilla.com> | 2016-05-25 06:10:17 -0500 |
commit | 1640ade0b3f703b54c2c2285271d44a037f7eabc (patch) | |
tree | 9b4a59fd83df807d940df1f788931beed8d43ff0 /components/script | |
parent | 52f17a88141c8a55de3816e1a7a169cced518b36 (diff) | |
parent | e7f75ca2983105fb9005616718f52b493210135f (diff) | |
download | servo-1640ade0b3f703b54c2c2285271d44a037f7eabc.tar.gz servo-1640ade0b3f703b54c2c2285271d44a037f7eabc.zip |
Auto merge of #11410 - Ms2ger:script-listener-thread, r=nox
Remove the script listener thread.
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 --faster` does not report any errors
- [ ] These changes fix #__ (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/11410)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/document.rs | 16 | ||||
-rw-r--r-- | components/script/dom/window.rs | 22 | ||||
-rw-r--r-- | components/script/script_thread.rs | 35 |
3 files changed, 30 insertions, 43 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 42708265325..89755564bb6 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -106,8 +106,8 @@ use parse::{ParserRoot, ParserRef, MutNullableParserField}; use script_thread::{MainThreadScriptMsg, Runnable}; use script_traits::UntrustedNodeAddress; use script_traits::{AnimationState, MouseButton, MouseEventType, MozBrowserEvent}; -use script_traits::{ScriptMsg as ConstellationMsg, ScriptToCompositorMsg}; -use script_traits::{TouchpadPressurePhase, TouchEventType, TouchId}; +use script_traits::{ScriptMsg as ConstellationMsg, TouchpadPressurePhase}; +use script_traits::{TouchEventType, TouchId}; use std::ascii::AsciiExt; use std::borrow::ToOwned; use std::boxed::FnBox; @@ -636,10 +636,10 @@ impl Document { /// Sends this document's title to the compositor. pub fn send_title_to_compositor(&self) { let window = self.window(); - let compositor = window.compositor(); - compositor.send(ScriptToCompositorMsg::SetTitle(window.pipeline(), - Some(String::from(self.Title())))) - .unwrap(); + window.constellation_chan() + .send(ConstellationMsg::SetTitle(window.pipeline(), + Some(String::from(self.Title())))) + .unwrap(); } pub fn dirty_all_nodes(&self) { @@ -1049,7 +1049,7 @@ impl Document { key: Key, state: KeyState, modifiers: KeyModifiers, - compositor: &IpcSender<ScriptToCompositorMsg>) { + constellation: &IpcSender<ConstellationMsg>) { let focused = self.get_focused_element(); let body = self.GetBody(); @@ -1124,7 +1124,7 @@ impl Document { } if !prevented { - compositor.send(ScriptToCompositorMsg::SendKeyEvent(key, state, modifiers)).unwrap(); + constellation.send(ConstellationMsg::SendKeyEvent(key, state, modifiers)).unwrap(); } // This behavior is unspecced diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index e5af0ebbf26..63a0ca2a36e 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -62,7 +62,7 @@ use script_runtime::{ScriptChan, ScriptPort}; use script_thread::SendableMainThreadScriptChan; use script_thread::{MainThreadScriptChan, MainThreadScriptMsg, RunnableWrapper}; use script_traits::{ConstellationControlMsg, UntrustedNodeAddress}; -use script_traits::{DocumentState, MsDuration, ScriptToCompositorMsg, TimerEvent, TimerEventId}; +use script_traits::{DocumentState, MsDuration, TimerEvent, TimerEventId}; use script_traits::{ScriptMsg as ConstellationMsg, TimerEventRequest, TimerSource}; use std::ascii::AsciiExt; use std::borrow::ToOwned; @@ -153,8 +153,6 @@ pub struct Window { image_cache_chan: ImageCacheChan, #[ignore_heap_size_of = "channels are hard"] custom_message_chan: IpcSender<CustomResponseSender>, - #[ignore_heap_size_of = "TODO(#6911) newtypes containing unmeasurable types are hard"] - compositor: IpcSender<ScriptToCompositorMsg>, browsing_context: MutNullableHeap<JS<BrowsingContext>>, performance: MutNullableHeap<JS<Performance>>, navigation_start: u64, @@ -340,10 +338,6 @@ impl Window { &self.image_cache_thread } - pub fn compositor(&self) -> &IpcSender<ScriptToCompositorMsg> { - &self.compositor - } - pub fn browsing_context(&self) -> Root<BrowsingContext> { self.browsing_context.get().unwrap() } @@ -775,7 +769,7 @@ impl WindowMethods for Window { // Step 1 //TODO determine if this operation is allowed let size = Size2D::new(x.to_u32().unwrap_or(1), y.to_u32().unwrap_or(1)); - self.compositor.send(ScriptToCompositorMsg::ResizeTo(size)).unwrap() + self.constellation_chan.send(ConstellationMsg::ResizeTo(size)).unwrap() } // https://drafts.csswg.org/cssom-view/#dom-window-resizeby @@ -790,7 +784,7 @@ impl WindowMethods for Window { // Step 1 //TODO determine if this operation is allowed let point = Point2D::new(x, y); - self.compositor.send(ScriptToCompositorMsg::MoveTo(point)).unwrap() + self.constellation_chan.send(ConstellationMsg::MoveTo(point)).unwrap() } // https://drafts.csswg.org/cssom-view/#dom-window-moveby @@ -976,13 +970,13 @@ impl Window { let size = self.current_viewport.get().size; self.current_viewport.set(Rect::new(Point2D::new(Au::from_f32_px(x), Au::from_f32_px(y)), size)); - self.compositor.send(ScriptToCompositorMsg::ScrollFragmentPoint( - self.pipeline(), layer_id, point, smooth)).unwrap() + let message = ConstellationMsg::ScrollFragmentPoint(self.pipeline(), layer_id, point, smooth); + self.constellation_chan.send(message).unwrap(); } pub fn client_window(&self) -> (Size2D<u32>, Point2D<i32>) { let (send, recv) = ipc::channel::<(Size2D<u32>, Point2D<i32>)>().unwrap(); - self.compositor.send(ScriptToCompositorMsg::GetClientWindow(send)).unwrap(); + self.constellation_chan.send(ConstellationMsg::GetClientWindow(send)).unwrap(); recv.recv().unwrap_or((Size2D::zero(), Point2D::zero())) } @@ -1180,7 +1174,7 @@ impl Window { let pipeline_id = self.id; let (send, recv) = ipc::channel::<Point2D<f32>>().unwrap(); - self.compositor.send(ScriptToCompositorMsg::GetScrollOffset(pipeline_id, layer_id, send)).unwrap(); + self.constellation_chan.send(ConstellationMsg::GetScrollOffset(pipeline_id, layer_id, send)).unwrap(); recv.recv().unwrap_or(Point2D::zero()) } @@ -1450,7 +1444,6 @@ impl Window { file_task_source: FileReadingTaskSource, image_cache_chan: ImageCacheChan, custom_message_chan: IpcSender<CustomResponseSender>, - compositor: IpcSender<ScriptToCompositorMsg>, image_cache_thread: ImageCacheThread, resource_threads: ResourceThreads, bluetooth_thread: IpcSender<BluetoothMethodMsg>, @@ -1490,7 +1483,6 @@ impl Window { custom_message_chan: custom_message_chan, console: Default::default(), crypto: Default::default(), - compositor: compositor, navigator: Default::default(), image_cache_thread: image_cache_thread, mem_profiler_chan: mem_profiler_chan, diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index e07e0ad64f7..ffb4125845b 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -81,7 +81,7 @@ use script_traits::CompositorEvent::{TouchEvent, TouchpadPressureEvent}; use script_traits::{CompositorEvent, ConstellationControlMsg, EventResult}; use script_traits::{InitialScriptState, MouseButton, MouseEventType, MozBrowserEvent, NewLayoutInfo}; use script_traits::{LayoutMsg, ScriptMsg as ConstellationMsg}; -use script_traits::{ScriptThreadFactory, ScriptToCompositorMsg, TimerEvent, TimerEventRequest, TimerSource}; +use script_traits::{ScriptThreadFactory, TimerEvent, TimerEventRequest, TimerSource}; use script_traits::{TouchEventType, TouchId}; use std::borrow::ToOwned; use std::cell::{Cell, RefCell}; @@ -350,9 +350,6 @@ pub struct ScriptThread { /// For communicating layout messages to the constellation layout_to_constellation_chan: IpcSender<LayoutMsg>, - /// A handle to the compositor for communicating ready state messages. - compositor: IpcSender<ScriptToCompositorMsg>, - /// The port on which we receive messages from the image cache image_cache_port: Receiver<ImageCacheResult>, @@ -465,7 +462,6 @@ impl ScriptThreadFactory for ScriptThread { let reporter_name = format!("script-reporter-{}", id); mem_profiler_chan.run_with_memory_reporting(|| { script_thread.start(); - let _ = script_thread.compositor.send(ScriptToCompositorMsg::Exited); let _ = script_thread.content_process_shutdown_chan.send(()); }, reporter_name, script_chan, CommonScriptMsg::CollectReports); @@ -577,7 +573,6 @@ impl ScriptThread { control_port: control_port, constellation_chan: state.constellation_chan, layout_to_constellation_chan: state.layout_to_constellation_chan, - compositor: state.compositor, time_profiler_chan: state.time_profiler_chan, mem_profiler_chan: state.mem_profiler_chan, panic_chan: state.panic_chan, @@ -1301,8 +1296,8 @@ impl ScriptThread { // TODO(tkuehn): currently there is only one window, // so this can afford to be naive and just shut down the - // compositor. In the future it'll need to be smarter. - self.compositor.send(ScriptToCompositorMsg::Exit).unwrap(); + // constellation. In the future it'll need to be smarter. + self.constellation_chan.send(ConstellationMsg::Exit).unwrap(); } /// We have received notification that the response associated with a load has completed. @@ -1459,7 +1454,6 @@ impl ScriptThread { FileReadingTaskSource(file_sender.clone()), self.image_cache_channel.clone(), self.custom_message_chan.clone(), - self.compositor.clone(), self.image_cache_thread.clone(), self.resource_threads.clone(), self.bluetooth_thread.clone(), @@ -1682,8 +1676,11 @@ impl ScriptThread { let point = Point2D::new(rect.origin.x.to_nearest_px() as f32, rect.origin.y.to_nearest_px() as f32); - self.compositor.send(ScriptToCompositorMsg::ScrollFragmentPoint( - pipeline_id, LayerId::null(), point, false)).unwrap(); + let message = ConstellationMsg::ScrollFragmentPoint(pipeline_id, + LayerId::null(), + point, + false); + self.constellation_chan.send(message).unwrap(); } /// Reflows non-incrementally, rebuilding the entire layout tree in the process. @@ -1768,16 +1765,14 @@ impl ScriptThread { let handled = self.handle_touch_event(pipeline_id, event_type, identifier, point); match event_type { TouchEventType::Down => { - if handled { + let result = if handled { // TODO: Wait to see if preventDefault is called on the first touchmove event. - self.compositor - .send(ScriptToCompositorMsg::TouchEventProcessed( - EventResult::DefaultAllowed)).unwrap(); + EventResult::DefaultAllowed } else { - self.compositor - .send(ScriptToCompositorMsg::TouchEventProcessed( - EventResult::DefaultPrevented)).unwrap(); - } + EventResult::DefaultPrevented + }; + let message = ConstellationMsg::TouchEventProcessed(result); + self.constellation_chan.send(message).unwrap(); } _ => { // TODO: Calling preventDefault on a touchup event should prevent clicks. @@ -1794,7 +1789,7 @@ impl ScriptThread { KeyEvent(key, state, modifiers) => { let context = get_browsing_context(&self.root_browsing_context(), pipeline_id); let document = context.active_document(); - document.dispatch_key_event(key, state, modifiers, &self.compositor); + document.dispatch_key_event(key, state, modifiers, &self.constellation_chan); } } } |