Remove the LayoutChan type.

It is a pointless abstraction.
This commit is contained in:
Ms2ger 2016-05-25 09:23:57 +02:00
parent 2f9796fa69
commit e94f3d4fe0
8 changed files with 26 additions and 45 deletions

View file

@ -54,7 +54,7 @@ use js::glue::{CallObjectTracer, CallUnbarrieredObjectTracer, CallValueTracer};
use js::jsapi::{GCTraceKindToAscii, Heap, TraceKind, JSObject, JSTracer};
use js::jsval::JSVal;
use js::rust::Runtime;
use layout_interface::{LayoutChan, LayoutRPC};
use layout_interface::LayoutRPC;
use libc;
use msg::constellation_msg::{FrameType, PipelineId, SubpageId, WindowSizeData, WindowSizeType, ReferrerPolicy};
use net_traits::image::base::{Image, ImageMetadata};
@ -296,7 +296,6 @@ no_jsmanaged_fields!(WorkerId);
no_jsmanaged_fields!(QuirksMode);
no_jsmanaged_fields!(Runtime);
no_jsmanaged_fields!(Headers, Method);
no_jsmanaged_fields!(LayoutChan);
no_jsmanaged_fields!(WindowProxyHandler);
no_jsmanaged_fields!(UntrustedNodeAddress);
no_jsmanaged_fields!(LengthOrPercentageOrAuto);

View file

@ -92,7 +92,7 @@ use html5ever::tree_builder::{LimitedQuirks, NoQuirks, Quirks, QuirksMode};
use ipc_channel::ipc::{self, IpcSender};
use js::jsapi::JS_GetRuntime;
use js::jsapi::{JSContext, JSObject, JSRuntime};
use layout_interface::{LayoutChan, Msg, ReflowQueryType};
use layout_interface::{Msg, ReflowQueryType};
use msg::constellation_msg::{ALT, CONTROL, SHIFT, SUPER};
use msg::constellation_msg::{Key, KeyModifiers, KeyState};
use msg::constellation_msg::{PipelineId, ReferrerPolicy, SubpageId};
@ -404,8 +404,7 @@ impl Document {
self.quirks_mode.set(mode);
if mode == Quirks {
let LayoutChan(ref layout_chan) = *self.window.layout_chan();
layout_chan.send(Msg::SetQuirksMode).unwrap();
self.window.layout_chan().send(Msg::SetQuirksMode).unwrap();
}
}

View file

@ -25,7 +25,7 @@ use hyper::header::ContentType;
use hyper::mime::{Mime, TopLevel, SubLevel};
use ipc_channel::ipc;
use ipc_channel::router::ROUTER;
use layout_interface::{LayoutChan, Msg};
use layout_interface::Msg;
use net_traits::{AsyncResponseListener, AsyncResponseTarget, Metadata, NetworkError};
use network_listener::{NetworkListener, PreInvoke};
use script_traits::{MozBrowserEvent, ScriptMsg as ConstellationMsg};
@ -318,8 +318,7 @@ impl AsyncResponseListener for StylesheetContext {
let document = document.r();
let win = window_from_node(elem);
let LayoutChan(ref layout_chan) = *win.layout_chan();
layout_chan.send(Msg::AddStylesheet(sheet.clone())).unwrap();
win.layout_chan().send(Msg::AddStylesheet(sheet.clone())).unwrap();
*elem.stylesheet.borrow_mut() = Some(sheet);
document.invalidate_stylesheets();

View file

@ -14,7 +14,7 @@ use dom::element::Element;
use dom::htmlelement::HTMLElement;
use dom::node::{ChildrenMutation, Node, document_from_node, window_from_node};
use dom::virtualmethods::VirtualMethods;
use layout_interface::{LayoutChan, Msg};
use layout_interface::Msg;
use std::sync::Arc;
use string_cache::Atom;
use style::media_queries::parse_media_query_list;
@ -68,8 +68,7 @@ impl HTMLStyleElement {
sheet.set_media(Some(media));
let sheet = Arc::new(sheet);
let LayoutChan(ref layout_chan) = *win.layout_chan();
layout_chan.send(Msg::AddStylesheet(sheet.clone())).unwrap();
win.layout_chan().send(Msg::AddStylesheet(sheet.clone())).unwrap();
*self.stylesheet.borrow_mut() = Some(sheet);
let doc = document_from_node(self);
doc.r().invalidate_stylesheets();

View file

@ -54,7 +54,7 @@ use euclid::size::Size2D;
use heapsize::{HeapSizeOf, heap_size_of};
use html5ever::tree_builder::QuirksMode;
use js::jsapi::{JSContext, JSObject, JSRuntime};
use layout_interface::{LayoutChan, Msg};
use layout_interface::Msg;
use libc::{self, c_void, uintptr_t};
use parse::html::parse_html_fragment;
use ref_slice::ref_slice;
@ -195,9 +195,8 @@ impl OpaqueStyleAndLayoutData {
pub fn dispose(self, node: &Node) {
debug_assert!(thread_state::get().is_script());
let win = window_from_node(node);
let LayoutChan(ref chan) = *win.layout_chan();
node.style_and_layout_data.set(None);
chan.send(Msg::ReapStyleAndLayoutData(self)).unwrap();
win.layout_chan().send(Msg::ReapStyleAndLayoutData(self)).unwrap();
}
}

View file

@ -42,7 +42,7 @@ use js::jsapi::{JS_GetRuntime, JS_GC, MutableHandleValue, SetWindowProxy};
use js::rust::CompileOptionsWrapper;
use js::rust::Runtime;
use layout_interface::{ContentBoxResponse, ContentBoxesResponse, ResolvedStyleResponse, ScriptReflow};
use layout_interface::{LayoutChan, LayoutRPC, Msg, Reflow, ReflowQueryType, MarginStyleResponse};
use layout_interface::{LayoutRPC, Msg, Reflow, ReflowQueryType, MarginStyleResponse};
use libc;
use msg::constellation_msg::{LoadData, PanicMsg, PipelineId, SubpageId};
use msg::constellation_msg::{WindowSizeData, WindowSizeType};
@ -209,7 +209,7 @@ pub struct Window {
/// A handle for communicating messages to the layout thread.
#[ignore_heap_size_of = "channels are hard"]
layout_chan: LayoutChan,
layout_chan: Sender<Msg>,
/// A handle to perform RPC calls into the layout, quickly.
#[ignore_heap_size_of = "trait objects are hard"]
@ -1057,8 +1057,7 @@ impl Window {
query_type: query_type,
};
let LayoutChan(ref chan) = self.layout_chan;
chan.send(Msg::Reflow(reflow)).unwrap();
self.layout_chan.send(Msg::Reflow(reflow)).unwrap();
debug!("script: layout forked");
@ -1300,7 +1299,7 @@ impl Window {
self.devtools_chan.clone()
}
pub fn layout_chan(&self) -> &LayoutChan {
pub fn layout_chan(&self) -> &Sender<Msg> {
&self.layout_chan
}
@ -1484,15 +1483,14 @@ impl Window {
scheduler_chan: IpcSender<TimerEventRequest>,
panic_chan: IpcSender<PanicMsg>,
timer_event_chan: IpcSender<TimerEvent>,
layout_chan: LayoutChan,
layout_chan: Sender<Msg>,
id: PipelineId,
parent_info: Option<(PipelineId, SubpageId)>,
window_size: Option<WindowSizeData>)
-> Root<Window> {
let layout_rpc: Box<LayoutRPC> = {
let (rpc_send, rpc_recv) = channel();
let LayoutChan(ref lchan) = layout_chan;
lchan.send(Msg::GetRPC(rpc_send)).unwrap();
layout_chan.send(Msg::GetRPC(rpc_send)).unwrap();
rpc_recv.recv().unwrap()
};
let error_reporter = CSSErrorReporter {

View file

@ -18,7 +18,7 @@ use profile_traits::mem::ReportsChan;
use script_traits::UntrustedNodeAddress;
use script_traits::{ConstellationControlMsg, LayoutControlMsg, LayoutMsg as ConstellationMsg};
use std::sync::Arc;
use std::sync::mpsc::{Receiver, Sender, channel};
use std::sync::mpsc::{Receiver, Sender};
use string_cache::Atom;
use style::context::ReflowGoal;
use style::properties::longhands::{margin_top, margin_right, margin_bottom, margin_left, overflow_x};
@ -218,17 +218,6 @@ impl Drop for ScriptReflow {
}
}
/// Encapsulates a channel to the layout thread.
#[derive(Clone)]
pub struct LayoutChan(pub Sender<Msg>);
impl LayoutChan {
pub fn new() -> (Receiver<Msg>, LayoutChan) {
let (chan, port) = channel();
(port, LayoutChan(chan))
}
}
pub struct NewLayoutThreadInfo {
pub id: PipelineId,
pub url: Url,

View file

@ -57,8 +57,7 @@ use js::jsapi::{DOMProxyShadowsResult, HandleId, HandleObject, RootedValue};
use js::jsapi::{JSContext, JS_SetWrapObjectCallbacks, JSTracer, SetWindowProxyClass};
use js::jsval::UndefinedValue;
use js::rust::Runtime;
use layout_interface::ReflowQueryType;
use layout_interface::{self, LayoutChan, NewLayoutThreadInfo};
use layout_interface::{self, NewLayoutThreadInfo, ReflowQueryType};
use mem::heap_size_of_self_and_children;
use msg::constellation_msg::{LoadData, PanicMsg, PipelineId, PipelineNamespace};
use msg::constellation_msg::{SubpageId, WindowSizeData, WindowSizeType};
@ -132,7 +131,7 @@ struct InProgressLoad {
/// The current window size associated with this pipeline.
window_size: Option<WindowSizeData>,
/// Channel to the layout thread associated with this pipeline.
layout_chan: LayoutChan,
layout_chan: Sender<layout_interface::Msg>,
/// The current viewport clipping rectangle applying to this pipeline, if any.
clip_rect: Option<Rect<f32>>,
/// Window is frozen (navigated away while loading for example).
@ -145,7 +144,7 @@ impl InProgressLoad {
/// Create a new InProgressLoad object.
fn new(id: PipelineId,
parent_info: Option<(PipelineId, SubpageId)>,
layout_chan: LayoutChan,
layout_chan: Sender<layout_interface::Msg>,
window_size: Option<WindowSizeData>,
url: Url) -> InProgressLoad {
InProgressLoad {
@ -431,7 +430,7 @@ impl ScriptThreadFactory for ScriptThread {
let (script_chan, script_port) = channel();
let (sender, receiver) = channel();
let layout_chan = LayoutChan(sender.clone());
let layout_chan = sender.clone();
let pipeline_id = state.id;
thread::spawn_named_with_send_on_panic(format!("ScriptThread {:?}", state.id),
thread_state::SCRIPT,
@ -1092,7 +1091,7 @@ impl ScriptThread {
} = new_layout_info;
let layout_pair = channel();
let layout_chan = LayoutChan(layout_pair.0.clone());
let layout_chan = layout_pair.0.clone();
let layout_creation_info = NewLayoutThreadInfo {
id: new_pipeline_id,
@ -1117,7 +1116,6 @@ impl ScriptThread {
// Tell layout to actually spawn the thread.
parent_window.layout_chan()
.0
.send(layout_interface::Msg::CreateLayoutThread(layout_creation_info))
.unwrap();
@ -1342,7 +1340,7 @@ impl ScriptThread {
// Tell the layout thread to begin shutting down, and wait until it
// processed this message.
let (response_chan, response_port) = channel();
let LayoutChan(chan) = load.layout_chan;
let chan = &load.layout_chan;
if chan.send(layout_interface::Msg::PrepareToExit(response_chan)).is_ok() {
debug!("shutting down layout for page {:?}", id);
response_port.recv().unwrap();
@ -1401,8 +1399,9 @@ impl ScriptThread {
let final_url = metadata.final_url.clone();
{
// send the final url to the layout thread.
let LayoutChan(ref chan) = incomplete.layout_chan;
chan.send(layout_interface::Msg::SetFinalUrl(final_url.clone())).unwrap();
incomplete.layout_chan
.send(layout_interface::Msg::SetFinalUrl(final_url.clone()))
.unwrap();
// update the pipeline url
self.constellation_chan
@ -2000,7 +1999,7 @@ fn shut_down_layout(context_tree: &BrowsingContext) {
// processed this message.
let (response_chan, response_port) = channel();
let window = context.active_window();
let LayoutChan(chan) = window.layout_chan().clone();
let chan = window.layout_chan().clone();
if chan.send(layout_interface::Msg::PrepareToExit(response_chan)).is_ok() {
channels.push(chan);
response_port.recv().unwrap();