mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
make use of ScriptToConstellationChan
This commit is contained in:
parent
817de15735
commit
d241389129
24 changed files with 285 additions and 280 deletions
|
@ -80,7 +80,7 @@ use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort, ScriptThreadEventC
|
|||
use script_thread::{ImageCacheMsg, MainThreadScriptChan, MainThreadScriptMsg, Runnable};
|
||||
use script_thread::{RunnableWrapper, ScriptThread, SendableMainThreadScriptChan};
|
||||
use script_traits::{ConstellationControlMsg, DocumentState, LoadData, MozBrowserEvent};
|
||||
use script_traits::{ScriptMsg as ConstellationMsg, ScrollState, TimerEvent, TimerEventId};
|
||||
use script_traits::{ScriptToConstellationChan, ScriptMsg, ScrollState, TimerEvent, TimerEventId};
|
||||
use script_traits::{TimerSchedulerMsg, UntrustedNodeAddress, WindowSizeData, WindowSizeType};
|
||||
use script_traits::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
|
||||
use selectors::attr::CaseSensitivity;
|
||||
|
@ -515,11 +515,7 @@ impl WindowMethods for Window {
|
|||
}
|
||||
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
let global_scope = self.upcast::<GlobalScope>();
|
||||
global_scope
|
||||
.constellation_chan()
|
||||
.send(ConstellationMsg::Alert(global_scope.pipeline_id(), s.to_string(), sender))
|
||||
.unwrap();
|
||||
self.send_to_constellation(ScriptMsg::Alert(s.to_string(), sender));
|
||||
|
||||
let should_display_alert_dialog = receiver.recv().unwrap();
|
||||
if should_display_alert_dialog {
|
||||
|
@ -918,10 +914,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.upcast::<GlobalScope>()
|
||||
.constellation_chan()
|
||||
.send(ConstellationMsg::ResizeTo(size))
|
||||
.unwrap()
|
||||
self.send_to_constellation(ScriptMsg::ResizeTo(size));
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-window-resizeby
|
||||
|
@ -936,10 +929,7 @@ impl WindowMethods for Window {
|
|||
// Step 1
|
||||
//TODO determine if this operation is allowed
|
||||
let point = Point2D::new(x, y);
|
||||
self.upcast::<GlobalScope>()
|
||||
.constellation_chan()
|
||||
.send(ConstellationMsg::MoveTo(point))
|
||||
.unwrap()
|
||||
self.send_to_constellation(ScriptMsg::MoveTo(point));
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-window-moveby
|
||||
|
@ -1159,9 +1149,8 @@ impl Window {
|
|||
scroll_offset: Vector2D::new(-x, -y),
|
||||
})).unwrap();
|
||||
|
||||
let global_scope = self.upcast::<GlobalScope>();
|
||||
let message = ConstellationMsg::ScrollFragmentPoint(scroll_root_id, point, smooth);
|
||||
global_scope.constellation_chan().send(message).unwrap();
|
||||
let message = ScriptMsg::ScrollFragmentPoint(scroll_root_id, point, smooth);
|
||||
self.send_to_constellation(message);
|
||||
}
|
||||
|
||||
pub fn update_viewport_for_scroll(&self, x: f32, y: f32) {
|
||||
|
@ -1172,10 +1161,7 @@ impl Window {
|
|||
|
||||
pub fn client_window(&self) -> (Size2D<u32>, Point2D<i32>) {
|
||||
let (send, recv) = ipc::channel::<(Size2D<u32>, Point2D<i32>)>().unwrap();
|
||||
self.upcast::<GlobalScope>()
|
||||
.constellation_chan()
|
||||
.send(ConstellationMsg::GetClientWindow(send))
|
||||
.unwrap();
|
||||
self.send_to_constellation(ScriptMsg::GetClientWindow(send));
|
||||
recv.recv().unwrap_or((Size2D::zero(), Point2D::zero()))
|
||||
}
|
||||
|
||||
|
@ -1371,9 +1357,8 @@ impl Window {
|
|||
|
||||
let pending_images = self.pending_layout_images.borrow().is_empty();
|
||||
if ready_state == DocumentReadyState::Complete && !reftest_wait && pending_images {
|
||||
let global_scope = self.upcast::<GlobalScope>();
|
||||
let event = ConstellationMsg::SetDocumentState(global_scope.pipeline_id(), DocumentState::Idle);
|
||||
global_scope.constellation_chan().send(event).unwrap();
|
||||
let event = ScriptMsg::SetDocumentState(DocumentState::Idle);
|
||||
self.send_to_constellation(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1779,6 +1764,13 @@ impl Window {
|
|||
self.navigation_start.set(now);
|
||||
self.navigation_start_precise.set(time::precise_time_ns() as f64);
|
||||
}
|
||||
|
||||
fn send_to_constellation(&self, msg: ScriptMsg) {
|
||||
self.upcast::<GlobalScope>()
|
||||
.script_to_constellation_chan()
|
||||
.send(msg)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
impl Window {
|
||||
|
@ -1797,7 +1789,7 @@ impl Window {
|
|||
mem_profiler_chan: MemProfilerChan,
|
||||
time_profiler_chan: TimeProfilerChan,
|
||||
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
|
||||
constellation_chan: IpcSender<ConstellationMsg>,
|
||||
constellation_chan: ScriptToConstellationChan,
|
||||
control_chan: IpcSender<ConstellationControlMsg>,
|
||||
scheduler_chan: IpcSender<TimerSchedulerMsg>,
|
||||
timer_event_chan: IpcSender<TimerEvent>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue