mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
make use of ScriptToConstellationChan
This commit is contained in:
parent
817de15735
commit
d241389129
24 changed files with 285 additions and 280 deletions
|
@ -115,7 +115,7 @@ use script_runtime::{CommonScriptMsg, ScriptThreadEventCategory};
|
|||
use script_thread::{MainThreadScriptMsg, Runnable, ScriptThread};
|
||||
use script_traits::{AnimationState, CompositorEvent, DocumentActivity};
|
||||
use script_traits::{MouseButton, MouseEventType, MozBrowserEvent};
|
||||
use script_traits::{MsDuration, ScriptMsg as ConstellationMsg, TouchpadPressurePhase};
|
||||
use script_traits::{MsDuration, ScriptMsg, TouchpadPressurePhase};
|
||||
use script_traits::{TouchEventType, TouchId};
|
||||
use script_traits::UntrustedNodeAddress;
|
||||
use servo_arc::Arc;
|
||||
|
@ -795,9 +795,7 @@ impl Document {
|
|||
// Update the focus state for all elements in the focus chain.
|
||||
// https://html.spec.whatwg.org/multipage/#focus-chain
|
||||
if focus_type == FocusType::Element {
|
||||
let global_scope = self.window.upcast::<GlobalScope>();
|
||||
let event = ConstellationMsg::Focus(global_scope.pipeline_id());
|
||||
global_scope.constellation_chan().send(event).unwrap();
|
||||
self.send_to_constellation(ScriptMsg::Focus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -808,19 +806,14 @@ impl Document {
|
|||
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowsertitlechange
|
||||
self.trigger_mozbrowser_event(MozBrowserEvent::TitleChange(String::from(self.Title())));
|
||||
|
||||
self.send_title_to_compositor();
|
||||
self.send_title_to_constellation();
|
||||
}
|
||||
}
|
||||
|
||||
/// Sends this document's title to the compositor.
|
||||
pub fn send_title_to_compositor(&self) {
|
||||
let window = self.window();
|
||||
let global_scope = window.upcast::<GlobalScope>();
|
||||
global_scope
|
||||
.constellation_chan()
|
||||
.send(ConstellationMsg::SetTitle(global_scope.pipeline_id(),
|
||||
Some(String::from(self.Title()))))
|
||||
.unwrap();
|
||||
/// Sends this document's title to the constellation.
|
||||
pub fn send_title_to_constellation(&self) {
|
||||
let title = Some(String::from(self.Title()));
|
||||
self.send_to_constellation(ScriptMsg::SetTitle(title));
|
||||
}
|
||||
|
||||
pub fn dirty_all_nodes(&self) {
|
||||
|
@ -872,8 +865,8 @@ impl Document {
|
|||
let child_point = client_point - child_origin;
|
||||
|
||||
let event = CompositorEvent::MouseButtonEvent(mouse_event_type, button, child_point);
|
||||
let event = ConstellationMsg::ForwardEvent(pipeline_id, event);
|
||||
self.window.upcast::<GlobalScope>().constellation_chan().send(event).unwrap();
|
||||
let event = ScriptMsg::ForwardEvent(pipeline_id, event);
|
||||
self.send_to_constellation(event);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1029,8 +1022,8 @@ impl Document {
|
|||
let event = CompositorEvent::TouchpadPressureEvent(child_point,
|
||||
pressure,
|
||||
phase_now);
|
||||
let event = ConstellationMsg::ForwardEvent(pipeline_id, event);
|
||||
self.window.upcast::<GlobalScope>().constellation_chan().send(event).unwrap();
|
||||
let event = ScriptMsg::ForwardEvent(pipeline_id, event);
|
||||
self.send_to_constellation(event);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1131,8 +1124,8 @@ impl Document {
|
|||
let child_point = client_point - child_origin;
|
||||
|
||||
let event = CompositorEvent::MouseMoveEvent(Some(child_point));
|
||||
let event = ConstellationMsg::ForwardEvent(pipeline_id, event);
|
||||
self.window.upcast::<GlobalScope>().constellation_chan().send(event).unwrap();
|
||||
let event = ScriptMsg::ForwardEvent(pipeline_id, event);
|
||||
self.send_to_constellation(event);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1238,8 +1231,8 @@ impl Document {
|
|||
let child_point = point - child_origin;
|
||||
|
||||
let event = CompositorEvent::TouchEvent(event_type, touch_id, child_point);
|
||||
let event = ConstellationMsg::ForwardEvent(pipeline_id, event);
|
||||
self.window.upcast::<GlobalScope>().constellation_chan().send(event).unwrap();
|
||||
let event = ScriptMsg::ForwardEvent(pipeline_id, event);
|
||||
self.send_to_constellation(event);
|
||||
}
|
||||
return TouchEventResult::Forwarded;
|
||||
}
|
||||
|
@ -1330,8 +1323,7 @@ impl Document {
|
|||
ch: Option<char>,
|
||||
key: Key,
|
||||
state: KeyState,
|
||||
modifiers: KeyModifiers,
|
||||
constellation: &IpcSender<ConstellationMsg>) {
|
||||
modifiers: KeyModifiers) {
|
||||
let focused = self.get_focused_element();
|
||||
let body = self.GetBody();
|
||||
|
||||
|
@ -1407,7 +1399,8 @@ impl Document {
|
|||
}
|
||||
|
||||
if cancel_state == EventDefault::Allowed {
|
||||
constellation.send(ConstellationMsg::SendKeyEvent(ch, key, state, modifiers)).unwrap();
|
||||
let msg = ScriptMsg::SendKeyEvent(ch, key, state, modifiers);
|
||||
self.send_to_constellation(msg);
|
||||
|
||||
// This behavior is unspecced
|
||||
// We are supposed to dispatch synthetic click activation for Space and/or Return,
|
||||
|
@ -1525,11 +1518,8 @@ impl Document {
|
|||
pub fn trigger_mozbrowser_event(&self, event: MozBrowserEvent) {
|
||||
if PREFS.is_mozbrowser_enabled() {
|
||||
if let Some((parent_pipeline_id, _)) = self.window.parent_info() {
|
||||
let top_level_browsing_context_id = self.window.window_proxy().top_level_browsing_context_id();
|
||||
let event = ConstellationMsg::MozBrowserEvent(parent_pipeline_id,
|
||||
top_level_browsing_context_id,
|
||||
event);
|
||||
self.window.upcast::<GlobalScope>().constellation_chan().send(event).unwrap();
|
||||
let event = ScriptMsg::MozBrowserEvent(parent_pipeline_id, event);
|
||||
self.send_to_constellation(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1559,11 +1549,8 @@ impl Document {
|
|||
// This reduces CPU usage by avoiding needless thread wakeups in the common case of
|
||||
// repeated rAF.
|
||||
|
||||
let global_scope = self.window.upcast::<GlobalScope>();
|
||||
let event = ConstellationMsg::ChangeRunningAnimationsState(
|
||||
global_scope.pipeline_id(),
|
||||
AnimationState::AnimationCallbacksPresent);
|
||||
global_scope.constellation_chan().send(event).unwrap();
|
||||
let event = ScriptMsg::ChangeRunningAnimationsState(AnimationState::AnimationCallbacksPresent);
|
||||
self.send_to_constellation(event);
|
||||
}
|
||||
|
||||
ident
|
||||
|
@ -1629,11 +1616,8 @@ impl Document {
|
|||
(!was_faking_animation_frames && self.is_faking_animation_frames()) {
|
||||
mem::swap(&mut *self.animation_frame_list.borrow_mut(),
|
||||
&mut *animation_frame_list);
|
||||
let global_scope = self.window.upcast::<GlobalScope>();
|
||||
let event = ConstellationMsg::ChangeRunningAnimationsState(
|
||||
global_scope.pipeline_id(),
|
||||
AnimationState::NoAnimationCallbacksPresent);
|
||||
global_scope.constellation_chan().send(event).unwrap();
|
||||
let event = ScriptMsg::ChangeRunningAnimationsState(AnimationState::NoAnimationCallbacksPresent);
|
||||
self.send_to_constellation(event);
|
||||
}
|
||||
|
||||
// Update the counter of spurious animation frames.
|
||||
|
@ -1896,10 +1880,7 @@ impl Document {
|
|||
}
|
||||
|
||||
pub fn notify_constellation_load(&self) {
|
||||
let global_scope = self.window.upcast::<GlobalScope>();
|
||||
let pipeline_id = global_scope.pipeline_id();
|
||||
let load_event = ConstellationMsg::LoadComplete(pipeline_id);
|
||||
global_scope.constellation_chan().send(load_event).unwrap();
|
||||
self.send_to_constellation(ScriptMsg::LoadComplete);
|
||||
}
|
||||
|
||||
pub fn set_current_parser(&self, script: Option<&ServoParser>) {
|
||||
|
@ -2018,6 +1999,11 @@ impl Document {
|
|||
|
||||
registry.lookup_definition(local_name, is)
|
||||
}
|
||||
|
||||
fn send_to_constellation(&self, msg: ScriptMsg) {
|
||||
let global_scope = self.window.upcast::<GlobalScope>();
|
||||
global_scope.script_to_constellation_chan().send(msg).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, HeapSizeOf)]
|
||||
|
@ -2519,8 +2505,8 @@ impl Document {
|
|||
let window = self.window();
|
||||
// Step 6
|
||||
if !error {
|
||||
let event = ConstellationMsg::SetFullscreenState(true);
|
||||
window.upcast::<GlobalScope>().constellation_chan().send(event).unwrap();
|
||||
let event = ScriptMsg::SetFullscreenState(true);
|
||||
self.send_to_constellation(event);
|
||||
}
|
||||
|
||||
// Step 7
|
||||
|
@ -2552,8 +2538,8 @@ impl Document {
|
|||
|
||||
let window = self.window();
|
||||
// Step 8
|
||||
let event = ConstellationMsg::SetFullscreenState(false);
|
||||
window.upcast::<GlobalScope>().constellation_chan().send(event).unwrap();
|
||||
let event = ScriptMsg::SetFullscreenState(false);
|
||||
self.send_to_constellation(event);
|
||||
|
||||
// Step 9
|
||||
let trusted_element = Trusted::new(element.r());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue