Reduce channel cloning.

This commit is contained in:
Ms2ger 2016-04-29 14:55:38 +02:00
parent 207be7d2e2
commit 897be5f6ee
13 changed files with 38 additions and 38 deletions

View file

@ -74,7 +74,7 @@ impl<'a> GlobalRef<'a> {
}
/// 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 {
GlobalRef::Window(window) => window.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.
pub fn constellation_chan(&self) -> ConstellationChan<ConstellationMsg> {
pub fn constellation_chan(&self) -> &ConstellationChan<ConstellationMsg> {
match *self {
GlobalRef::Window(window) => window.constellation_chan(),
GlobalRef::Worker(worker) => worker.constellation_chan(),
@ -90,7 +90,7 @@ impl<'a> GlobalRef<'a> {
}
/// Get the scheduler channel to request timer events.
pub fn scheduler_chan(&self) -> IpcSender<TimerEventRequest> {
pub fn scheduler_chan(&self) -> &IpcSender<TimerEventRequest> {
match *self {
GlobalRef::Window(window) => window.scheduler_chan(),
GlobalRef::Worker(worker) => worker.scheduler_chan(),

View file

@ -401,7 +401,7 @@ impl Document {
self.quirks_mode.set(mode);
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();
}
}
@ -615,7 +615,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 ConstellationChan(ref chan) = self.window.constellation_chan();
let ConstellationChan(ref chan) = *self.window.constellation_chan();
let event = ConstellationMsg::Focus(self.window.pipeline());
chan.send(event).unwrap();
}
@ -1260,7 +1260,7 @@ impl Document {
pub fn trigger_mozbrowser_event(&self, event: MozBrowserEvent) {
if htmliframeelement::mozbrowser_enabled() {
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,
subpage_id,
event);
@ -1277,7 +1277,7 @@ impl Document {
self.animation_frame_list.borrow_mut().insert(ident, callback);
// 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(),
AnimationState::AnimationCallbacksPresent);
chan.send(event).unwrap();
@ -1289,7 +1289,7 @@ impl Document {
pub fn cancel_animation_frame(&self, ident: u32) {
self.animation_frame_list.borrow_mut().remove(&ident);
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(),
AnimationState::NoAnimationCallbacksPresent);
chan.send(event).unwrap();
@ -1313,7 +1313,7 @@ impl Document {
// the next frame (which is the common case), we won't send a NoAnimationCallbacksPresent
// message quickly followed by an AnimationCallbacksPresent message.
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(),
AnimationState::NoAnimationCallbacksPresent);
chan.send(event).unwrap();
@ -1473,7 +1473,7 @@ impl Document {
pub fn notify_constellation_load(&self) {
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);
chan.send(event).unwrap();

View file

@ -154,7 +154,7 @@ impl VirtualMethods for HTMLBodyElement {
let window = window_from_node(self);
let document = window.Document();
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;
chan.send(event).unwrap();
}

View file

@ -124,7 +124,7 @@ impl HTMLIFrameElement {
let new_pipeline_id = self.pipeline_id.get().unwrap();
let private_iframe = self.privatebrowsing();
let ConstellationChan(ref chan) = window.constellation_chan();
let ConstellationChan(ref chan) = *window.constellation_chan();
let load_info = IFrameLoadInfo {
url: url,
containing_pipeline_id: window.pipeline(),
@ -371,7 +371,7 @@ pub fn Navigate(iframe: &HTMLIFrameElement, direction: NavigationDirection) -> E
let pipeline_info = Some((window.pipeline(),
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);
chan.send(msg).unwrap();
}
@ -575,7 +575,7 @@ impl VirtualMethods for HTMLIFrameElement {
//
// Since most of this cleanup doesn't happen on same-origin
// 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 win_url = window_from_node(self).get_url();
UrlHelper::SameOrigin(&self_url, &win_url)

View file

@ -122,7 +122,7 @@ static DEFAULT_MAX_LENGTH: i32 = -1;
impl 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 {
htmlelement:
HTMLElement::new_inherited_with_state(IN_ENABLED_STATE,

View file

@ -242,7 +242,7 @@ impl HTMLLinkElement {
let document = document_from_node(self);
match document.base_url().join(href) {
Ok(url) => {
let ConstellationChan(ref chan) = document.window().constellation_chan();
let ConstellationChan(ref chan) = *document.window().constellation_chan();
let event = ConstellationMsg::NewFavicon(url.clone());
chan.send(event).unwrap();
@ -318,7 +318,7 @@ impl AsyncResponseListener for StylesheetContext {
let document = document.r();
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();
*elem.stylesheet.borrow_mut() = Some(sheet);

View file

@ -66,7 +66,7 @@ impl HTMLStyleElement {
sheet.set_media(Some(media));
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();
*self.stylesheet.borrow_mut() = Some(sheet);
let doc = document_from_node(self);

View file

@ -100,7 +100,7 @@ impl HTMLTextAreaElement {
fn new_inherited(localName: Atom,
prefix: Option<DOMString>,
document: &Document) -> HTMLTextAreaElement {
let chan = document.window().constellation_chan();
let chan = document.window().constellation_chan().clone();
HTMLTextAreaElement {
htmlelement:
HTMLElement::new_inherited_with_state(IN_ENABLED_STATE,

View file

@ -195,7 +195,7 @@ impl OpaqueStyleAndLayoutData {
pub fn dispose(self, node: &Node) {
debug_assert!(thread_state::get().is_script());
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);
chan.send(Msg::ReapStyleAndLayoutData(self)).unwrap();
}

View file

@ -1234,24 +1234,24 @@ impl Window {
(*self.resource_thread).clone()
}
pub fn mem_profiler_chan(&self) -> mem::ProfilerChan {
self.mem_profiler_chan.clone()
pub fn mem_profiler_chan(&self) -> &mem::ProfilerChan {
&self.mem_profiler_chan
}
pub fn devtools_chan(&self) -> Option<IpcSender<ScriptToDevtoolsControlMsg>> {
self.devtools_chan.clone()
}
pub fn layout_chan(&self) -> LayoutChan {
self.layout_chan.clone()
pub fn layout_chan(&self) -> &LayoutChan {
&self.layout_chan
}
pub fn constellation_chan(&self) -> ConstellationChan<ConstellationMsg> {
self.constellation_chan.clone()
pub fn constellation_chan(&self) -> &ConstellationChan<ConstellationMsg> {
&self.constellation_chan
}
pub fn scheduler_chan(&self) -> IpcSender<TimerEventRequest> {
self.scheduler_chan.clone()
pub fn scheduler_chan(&self) -> &IpcSender<TimerEventRequest> {
&self.scheduler_chan
}
pub fn schedule_callback(&self, callback: OneshotTimerCallback, duration: MsDuration) -> OneshotTimerHandle {

View file

@ -75,8 +75,8 @@ impl Worker {
};
let resource_thread = global.resource_thread();
let constellation_chan = global.constellation_chan();
let scheduler_chan = global.scheduler_chan();
let constellation_chan = global.constellation_chan().clone();
let scheduler_chan = global.scheduler_chan().clone();
let (sender, receiver) = channel();
let closing = Arc::new(AtomicBool::new(false));
@ -103,7 +103,7 @@ impl Worker {
let init = WorkerGlobalScopeInit {
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(),
from_devtools_sender: optional_sender,
constellation_chan: constellation_chan,

View file

@ -126,8 +126,8 @@ impl WorkerGlobalScope {
}
}
pub fn mem_profiler_chan(&self) -> mem::ProfilerChan {
self.mem_profiler_chan.clone()
pub fn mem_profiler_chan(&self) -> &mem::ProfilerChan {
&self.mem_profiler_chan
}
pub fn devtools_chan(&self) -> Option<IpcSender<ScriptToDevtoolsControlMsg>> {
@ -142,12 +142,12 @@ impl WorkerGlobalScope {
&self.from_devtools_receiver
}
pub fn constellation_chan(&self) -> ConstellationChan<ConstellationMsg> {
self.constellation_chan.clone()
pub fn constellation_chan(&self) -> &ConstellationChan<ConstellationMsg> {
&self.constellation_chan
}
pub fn scheduler_chan(&self) -> IpcSender<TimerEventRequest> {
self.scheduler_chan.clone()
pub fn scheduler_chan(&self) -> &IpcSender<TimerEventRequest> {
&self.scheduler_chan
}
pub fn schedule_callback(&self, callback: OneshotTimerCallback, duration: MsDuration) -> OneshotTimerHandle {

View file

@ -1966,7 +1966,7 @@ fn shut_down_layout(page_tree: &Rc<Page>) {
// processed this message.
let (response_chan, response_port) = channel();
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() {
channels.push(chan);
response_port.recv().unwrap();