mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Reduce channel cloning.
This commit is contained in:
parent
207be7d2e2
commit
897be5f6ee
13 changed files with 38 additions and 38 deletions
|
@ -74,7 +74,7 @@ impl<'a> GlobalRef<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a `mem::ProfilerChan` to send messages to the memory profiler thread.
|
/// Get a `mem::ProfilerChan` to send messages to the memory profiler thread.
|
||||||
pub fn mem_profiler_chan(&self) -> mem::ProfilerChan {
|
pub fn mem_profiler_chan(&self) -> &mem::ProfilerChan {
|
||||||
match *self {
|
match *self {
|
||||||
GlobalRef::Window(window) => window.mem_profiler_chan(),
|
GlobalRef::Window(window) => window.mem_profiler_chan(),
|
||||||
GlobalRef::Worker(worker) => worker.mem_profiler_chan(),
|
GlobalRef::Worker(worker) => worker.mem_profiler_chan(),
|
||||||
|
@ -82,7 +82,7 @@ impl<'a> GlobalRef<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a `ConstellationChan` to send messages to the constellation channel when available.
|
/// Get a `ConstellationChan` to send messages to the constellation channel when available.
|
||||||
pub fn constellation_chan(&self) -> ConstellationChan<ConstellationMsg> {
|
pub fn constellation_chan(&self) -> &ConstellationChan<ConstellationMsg> {
|
||||||
match *self {
|
match *self {
|
||||||
GlobalRef::Window(window) => window.constellation_chan(),
|
GlobalRef::Window(window) => window.constellation_chan(),
|
||||||
GlobalRef::Worker(worker) => worker.constellation_chan(),
|
GlobalRef::Worker(worker) => worker.constellation_chan(),
|
||||||
|
@ -90,7 +90,7 @@ impl<'a> GlobalRef<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the scheduler channel to request timer events.
|
/// Get the scheduler channel to request timer events.
|
||||||
pub fn scheduler_chan(&self) -> IpcSender<TimerEventRequest> {
|
pub fn scheduler_chan(&self) -> &IpcSender<TimerEventRequest> {
|
||||||
match *self {
|
match *self {
|
||||||
GlobalRef::Window(window) => window.scheduler_chan(),
|
GlobalRef::Window(window) => window.scheduler_chan(),
|
||||||
GlobalRef::Worker(worker) => worker.scheduler_chan(),
|
GlobalRef::Worker(worker) => worker.scheduler_chan(),
|
||||||
|
|
|
@ -401,7 +401,7 @@ impl Document {
|
||||||
self.quirks_mode.set(mode);
|
self.quirks_mode.set(mode);
|
||||||
|
|
||||||
if mode == Quirks {
|
if mode == Quirks {
|
||||||
let LayoutChan(ref layout_chan) = self.window.layout_chan();
|
let LayoutChan(ref layout_chan) = *self.window.layout_chan();
|
||||||
layout_chan.send(Msg::SetQuirksMode).unwrap();
|
layout_chan.send(Msg::SetQuirksMode).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -615,7 +615,7 @@ impl Document {
|
||||||
// Update the focus state for all elements in the focus chain.
|
// Update the focus state for all elements in the focus chain.
|
||||||
// https://html.spec.whatwg.org/multipage/#focus-chain
|
// https://html.spec.whatwg.org/multipage/#focus-chain
|
||||||
if focus_type == FocusType::Element {
|
if focus_type == FocusType::Element {
|
||||||
let ConstellationChan(ref chan) = self.window.constellation_chan();
|
let ConstellationChan(ref chan) = *self.window.constellation_chan();
|
||||||
let event = ConstellationMsg::Focus(self.window.pipeline());
|
let event = ConstellationMsg::Focus(self.window.pipeline());
|
||||||
chan.send(event).unwrap();
|
chan.send(event).unwrap();
|
||||||
}
|
}
|
||||||
|
@ -1260,7 +1260,7 @@ impl Document {
|
||||||
pub fn trigger_mozbrowser_event(&self, event: MozBrowserEvent) {
|
pub fn trigger_mozbrowser_event(&self, event: MozBrowserEvent) {
|
||||||
if htmliframeelement::mozbrowser_enabled() {
|
if htmliframeelement::mozbrowser_enabled() {
|
||||||
if let Some((containing_pipeline_id, subpage_id)) = self.window.parent_info() {
|
if let Some((containing_pipeline_id, subpage_id)) = self.window.parent_info() {
|
||||||
let ConstellationChan(ref chan) = self.window.constellation_chan();
|
let ConstellationChan(ref chan) = *self.window.constellation_chan();
|
||||||
let event = ConstellationMsg::MozBrowserEvent(containing_pipeline_id,
|
let event = ConstellationMsg::MozBrowserEvent(containing_pipeline_id,
|
||||||
subpage_id,
|
subpage_id,
|
||||||
event);
|
event);
|
||||||
|
@ -1277,7 +1277,7 @@ impl Document {
|
||||||
self.animation_frame_list.borrow_mut().insert(ident, callback);
|
self.animation_frame_list.borrow_mut().insert(ident, callback);
|
||||||
|
|
||||||
// TODO: Should tick animation only when document is visible
|
// TODO: Should tick animation only when document is visible
|
||||||
let ConstellationChan(ref chan) = self.window.constellation_chan();
|
let ConstellationChan(ref chan) = *self.window.constellation_chan();
|
||||||
let event = ConstellationMsg::ChangeRunningAnimationsState(self.window.pipeline(),
|
let event = ConstellationMsg::ChangeRunningAnimationsState(self.window.pipeline(),
|
||||||
AnimationState::AnimationCallbacksPresent);
|
AnimationState::AnimationCallbacksPresent);
|
||||||
chan.send(event).unwrap();
|
chan.send(event).unwrap();
|
||||||
|
@ -1289,7 +1289,7 @@ impl Document {
|
||||||
pub fn cancel_animation_frame(&self, ident: u32) {
|
pub fn cancel_animation_frame(&self, ident: u32) {
|
||||||
self.animation_frame_list.borrow_mut().remove(&ident);
|
self.animation_frame_list.borrow_mut().remove(&ident);
|
||||||
if self.animation_frame_list.borrow().is_empty() {
|
if self.animation_frame_list.borrow().is_empty() {
|
||||||
let ConstellationChan(ref chan) = self.window.constellation_chan();
|
let ConstellationChan(ref chan) = *self.window.constellation_chan();
|
||||||
let event = ConstellationMsg::ChangeRunningAnimationsState(self.window.pipeline(),
|
let event = ConstellationMsg::ChangeRunningAnimationsState(self.window.pipeline(),
|
||||||
AnimationState::NoAnimationCallbacksPresent);
|
AnimationState::NoAnimationCallbacksPresent);
|
||||||
chan.send(event).unwrap();
|
chan.send(event).unwrap();
|
||||||
|
@ -1313,7 +1313,7 @@ impl Document {
|
||||||
// the next frame (which is the common case), we won't send a NoAnimationCallbacksPresent
|
// the next frame (which is the common case), we won't send a NoAnimationCallbacksPresent
|
||||||
// message quickly followed by an AnimationCallbacksPresent message.
|
// message quickly followed by an AnimationCallbacksPresent message.
|
||||||
if self.animation_frame_list.borrow().is_empty() {
|
if self.animation_frame_list.borrow().is_empty() {
|
||||||
let ConstellationChan(ref chan) = self.window.constellation_chan();
|
let ConstellationChan(ref chan) = *self.window.constellation_chan();
|
||||||
let event = ConstellationMsg::ChangeRunningAnimationsState(self.window.pipeline(),
|
let event = ConstellationMsg::ChangeRunningAnimationsState(self.window.pipeline(),
|
||||||
AnimationState::NoAnimationCallbacksPresent);
|
AnimationState::NoAnimationCallbacksPresent);
|
||||||
chan.send(event).unwrap();
|
chan.send(event).unwrap();
|
||||||
|
@ -1473,7 +1473,7 @@ impl Document {
|
||||||
|
|
||||||
pub fn notify_constellation_load(&self) {
|
pub fn notify_constellation_load(&self) {
|
||||||
let pipeline_id = self.window.pipeline();
|
let pipeline_id = self.window.pipeline();
|
||||||
let ConstellationChan(ref chan) = self.window.constellation_chan();
|
let ConstellationChan(ref chan) = *self.window.constellation_chan();
|
||||||
let event = ConstellationMsg::DOMLoad(pipeline_id);
|
let event = ConstellationMsg::DOMLoad(pipeline_id);
|
||||||
chan.send(event).unwrap();
|
chan.send(event).unwrap();
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@ impl VirtualMethods for HTMLBodyElement {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
let document = window.Document();
|
let document = window.Document();
|
||||||
document.set_reflow_timeout(time::precise_time_ns() + INITIAL_REFLOW_DELAY);
|
document.set_reflow_timeout(time::precise_time_ns() + INITIAL_REFLOW_DELAY);
|
||||||
let ConstellationChan(ref chan) = window.constellation_chan();
|
let ConstellationChan(ref chan) = *window.constellation_chan();
|
||||||
let event = ConstellationMsg::HeadParsed;
|
let event = ConstellationMsg::HeadParsed;
|
||||||
chan.send(event).unwrap();
|
chan.send(event).unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,7 +124,7 @@ impl HTMLIFrameElement {
|
||||||
let new_pipeline_id = self.pipeline_id.get().unwrap();
|
let new_pipeline_id = self.pipeline_id.get().unwrap();
|
||||||
let private_iframe = self.privatebrowsing();
|
let private_iframe = self.privatebrowsing();
|
||||||
|
|
||||||
let ConstellationChan(ref chan) = window.constellation_chan();
|
let ConstellationChan(ref chan) = *window.constellation_chan();
|
||||||
let load_info = IFrameLoadInfo {
|
let load_info = IFrameLoadInfo {
|
||||||
url: url,
|
url: url,
|
||||||
containing_pipeline_id: window.pipeline(),
|
containing_pipeline_id: window.pipeline(),
|
||||||
|
@ -371,7 +371,7 @@ pub fn Navigate(iframe: &HTMLIFrameElement, direction: NavigationDirection) -> E
|
||||||
|
|
||||||
let pipeline_info = Some((window.pipeline(),
|
let pipeline_info = Some((window.pipeline(),
|
||||||
iframe.subpage_id().unwrap()));
|
iframe.subpage_id().unwrap()));
|
||||||
let ConstellationChan(ref chan) = window.constellation_chan();
|
let ConstellationChan(ref chan) = *window.constellation_chan();
|
||||||
let msg = ConstellationMsg::Navigate(pipeline_info, direction);
|
let msg = ConstellationMsg::Navigate(pipeline_info, direction);
|
||||||
chan.send(msg).unwrap();
|
chan.send(msg).unwrap();
|
||||||
}
|
}
|
||||||
|
@ -575,7 +575,7 @@ impl VirtualMethods for HTMLIFrameElement {
|
||||||
//
|
//
|
||||||
// Since most of this cleanup doesn't happen on same-origin
|
// Since most of this cleanup doesn't happen on same-origin
|
||||||
// iframes, and since that would cause a deadlock, don't do it.
|
// iframes, and since that would cause a deadlock, don't do it.
|
||||||
let ConstellationChan(ref chan) = window.constellation_chan();
|
let ConstellationChan(ref chan) = *window.constellation_chan();
|
||||||
let same_origin = if let Some(self_url) = self.get_url() {
|
let same_origin = if let Some(self_url) = self.get_url() {
|
||||||
let win_url = window_from_node(self).get_url();
|
let win_url = window_from_node(self).get_url();
|
||||||
UrlHelper::SameOrigin(&self_url, &win_url)
|
UrlHelper::SameOrigin(&self_url, &win_url)
|
||||||
|
|
|
@ -122,7 +122,7 @@ static DEFAULT_MAX_LENGTH: i32 = -1;
|
||||||
|
|
||||||
impl HTMLInputElement {
|
impl HTMLInputElement {
|
||||||
fn new_inherited(localName: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLInputElement {
|
fn new_inherited(localName: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLInputElement {
|
||||||
let chan = document.window().constellation_chan();
|
let chan = document.window().constellation_chan().clone();
|
||||||
HTMLInputElement {
|
HTMLInputElement {
|
||||||
htmlelement:
|
htmlelement:
|
||||||
HTMLElement::new_inherited_with_state(IN_ENABLED_STATE,
|
HTMLElement::new_inherited_with_state(IN_ENABLED_STATE,
|
||||||
|
|
|
@ -242,7 +242,7 @@ impl HTMLLinkElement {
|
||||||
let document = document_from_node(self);
|
let document = document_from_node(self);
|
||||||
match document.base_url().join(href) {
|
match document.base_url().join(href) {
|
||||||
Ok(url) => {
|
Ok(url) => {
|
||||||
let ConstellationChan(ref chan) = document.window().constellation_chan();
|
let ConstellationChan(ref chan) = *document.window().constellation_chan();
|
||||||
let event = ConstellationMsg::NewFavicon(url.clone());
|
let event = ConstellationMsg::NewFavicon(url.clone());
|
||||||
chan.send(event).unwrap();
|
chan.send(event).unwrap();
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ impl AsyncResponseListener for StylesheetContext {
|
||||||
let document = document.r();
|
let document = document.r();
|
||||||
|
|
||||||
let win = window_from_node(elem);
|
let win = window_from_node(elem);
|
||||||
let LayoutChan(ref layout_chan) = win.r().layout_chan();
|
let LayoutChan(ref layout_chan) = *win.layout_chan();
|
||||||
layout_chan.send(Msg::AddStylesheet(sheet.clone())).unwrap();
|
layout_chan.send(Msg::AddStylesheet(sheet.clone())).unwrap();
|
||||||
|
|
||||||
*elem.stylesheet.borrow_mut() = Some(sheet);
|
*elem.stylesheet.borrow_mut() = Some(sheet);
|
||||||
|
|
|
@ -66,7 +66,7 @@ impl HTMLStyleElement {
|
||||||
sheet.set_media(Some(media));
|
sheet.set_media(Some(media));
|
||||||
let sheet = Arc::new(sheet);
|
let sheet = Arc::new(sheet);
|
||||||
|
|
||||||
let LayoutChan(ref layout_chan) = win.layout_chan();
|
let LayoutChan(ref layout_chan) = *win.layout_chan();
|
||||||
layout_chan.send(Msg::AddStylesheet(sheet.clone())).unwrap();
|
layout_chan.send(Msg::AddStylesheet(sheet.clone())).unwrap();
|
||||||
*self.stylesheet.borrow_mut() = Some(sheet);
|
*self.stylesheet.borrow_mut() = Some(sheet);
|
||||||
let doc = document_from_node(self);
|
let doc = document_from_node(self);
|
||||||
|
|
|
@ -100,7 +100,7 @@ impl HTMLTextAreaElement {
|
||||||
fn new_inherited(localName: Atom,
|
fn new_inherited(localName: Atom,
|
||||||
prefix: Option<DOMString>,
|
prefix: Option<DOMString>,
|
||||||
document: &Document) -> HTMLTextAreaElement {
|
document: &Document) -> HTMLTextAreaElement {
|
||||||
let chan = document.window().constellation_chan();
|
let chan = document.window().constellation_chan().clone();
|
||||||
HTMLTextAreaElement {
|
HTMLTextAreaElement {
|
||||||
htmlelement:
|
htmlelement:
|
||||||
HTMLElement::new_inherited_with_state(IN_ENABLED_STATE,
|
HTMLElement::new_inherited_with_state(IN_ENABLED_STATE,
|
||||||
|
|
|
@ -195,7 +195,7 @@ impl OpaqueStyleAndLayoutData {
|
||||||
pub fn dispose(self, node: &Node) {
|
pub fn dispose(self, node: &Node) {
|
||||||
debug_assert!(thread_state::get().is_script());
|
debug_assert!(thread_state::get().is_script());
|
||||||
let win = window_from_node(node);
|
let win = window_from_node(node);
|
||||||
let LayoutChan(chan) = win.layout_chan();
|
let LayoutChan(ref chan) = *win.layout_chan();
|
||||||
node.style_and_layout_data.set(None);
|
node.style_and_layout_data.set(None);
|
||||||
chan.send(Msg::ReapStyleAndLayoutData(self)).unwrap();
|
chan.send(Msg::ReapStyleAndLayoutData(self)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1234,24 +1234,24 @@ impl Window {
|
||||||
(*self.resource_thread).clone()
|
(*self.resource_thread).clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mem_profiler_chan(&self) -> mem::ProfilerChan {
|
pub fn mem_profiler_chan(&self) -> &mem::ProfilerChan {
|
||||||
self.mem_profiler_chan.clone()
|
&self.mem_profiler_chan
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn devtools_chan(&self) -> Option<IpcSender<ScriptToDevtoolsControlMsg>> {
|
pub fn devtools_chan(&self) -> Option<IpcSender<ScriptToDevtoolsControlMsg>> {
|
||||||
self.devtools_chan.clone()
|
self.devtools_chan.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn layout_chan(&self) -> LayoutChan {
|
pub fn layout_chan(&self) -> &LayoutChan {
|
||||||
self.layout_chan.clone()
|
&self.layout_chan
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constellation_chan(&self) -> ConstellationChan<ConstellationMsg> {
|
pub fn constellation_chan(&self) -> &ConstellationChan<ConstellationMsg> {
|
||||||
self.constellation_chan.clone()
|
&self.constellation_chan
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn scheduler_chan(&self) -> IpcSender<TimerEventRequest> {
|
pub fn scheduler_chan(&self) -> &IpcSender<TimerEventRequest> {
|
||||||
self.scheduler_chan.clone()
|
&self.scheduler_chan
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn schedule_callback(&self, callback: OneshotTimerCallback, duration: MsDuration) -> OneshotTimerHandle {
|
pub fn schedule_callback(&self, callback: OneshotTimerCallback, duration: MsDuration) -> OneshotTimerHandle {
|
||||||
|
|
|
@ -75,8 +75,8 @@ impl Worker {
|
||||||
};
|
};
|
||||||
|
|
||||||
let resource_thread = global.resource_thread();
|
let resource_thread = global.resource_thread();
|
||||||
let constellation_chan = global.constellation_chan();
|
let constellation_chan = global.constellation_chan().clone();
|
||||||
let scheduler_chan = global.scheduler_chan();
|
let scheduler_chan = global.scheduler_chan().clone();
|
||||||
|
|
||||||
let (sender, receiver) = channel();
|
let (sender, receiver) = channel();
|
||||||
let closing = Arc::new(AtomicBool::new(false));
|
let closing = Arc::new(AtomicBool::new(false));
|
||||||
|
@ -103,7 +103,7 @@ impl Worker {
|
||||||
|
|
||||||
let init = WorkerGlobalScopeInit {
|
let init = WorkerGlobalScopeInit {
|
||||||
resource_thread: resource_thread,
|
resource_thread: resource_thread,
|
||||||
mem_profiler_chan: global.mem_profiler_chan(),
|
mem_profiler_chan: global.mem_profiler_chan().clone(),
|
||||||
to_devtools_sender: global.devtools_chan(),
|
to_devtools_sender: global.devtools_chan(),
|
||||||
from_devtools_sender: optional_sender,
|
from_devtools_sender: optional_sender,
|
||||||
constellation_chan: constellation_chan,
|
constellation_chan: constellation_chan,
|
||||||
|
|
|
@ -126,8 +126,8 @@ impl WorkerGlobalScope {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mem_profiler_chan(&self) -> mem::ProfilerChan {
|
pub fn mem_profiler_chan(&self) -> &mem::ProfilerChan {
|
||||||
self.mem_profiler_chan.clone()
|
&self.mem_profiler_chan
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn devtools_chan(&self) -> Option<IpcSender<ScriptToDevtoolsControlMsg>> {
|
pub fn devtools_chan(&self) -> Option<IpcSender<ScriptToDevtoolsControlMsg>> {
|
||||||
|
@ -142,12 +142,12 @@ impl WorkerGlobalScope {
|
||||||
&self.from_devtools_receiver
|
&self.from_devtools_receiver
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constellation_chan(&self) -> ConstellationChan<ConstellationMsg> {
|
pub fn constellation_chan(&self) -> &ConstellationChan<ConstellationMsg> {
|
||||||
self.constellation_chan.clone()
|
&self.constellation_chan
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn scheduler_chan(&self) -> IpcSender<TimerEventRequest> {
|
pub fn scheduler_chan(&self) -> &IpcSender<TimerEventRequest> {
|
||||||
self.scheduler_chan.clone()
|
&self.scheduler_chan
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn schedule_callback(&self, callback: OneshotTimerCallback, duration: MsDuration) -> OneshotTimerHandle {
|
pub fn schedule_callback(&self, callback: OneshotTimerCallback, duration: MsDuration) -> OneshotTimerHandle {
|
||||||
|
|
|
@ -1966,7 +1966,7 @@ fn shut_down_layout(page_tree: &Rc<Page>) {
|
||||||
// processed this message.
|
// processed this message.
|
||||||
let (response_chan, response_port) = channel();
|
let (response_chan, response_port) = channel();
|
||||||
let window = page.window();
|
let window = page.window();
|
||||||
let LayoutChan(chan) = window.layout_chan();
|
let LayoutChan(chan) = window.layout_chan().clone();
|
||||||
if chan.send(layout_interface::Msg::PrepareToExit(response_chan)).is_ok() {
|
if chan.send(layout_interface::Msg::PrepareToExit(response_chan)).is_ok() {
|
||||||
channels.push(chan);
|
channels.push(chan);
|
||||||
response_port.recv().unwrap();
|
response_port.recv().unwrap();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue