diff options
author | Ms2ger <Ms2ger@gmail.com> | 2016-05-25 09:23:57 +0200 |
---|---|---|
committer | Ms2ger <Ms2ger@gmail.com> | 2016-05-27 15:33:04 +0200 |
commit | e94f3d4fe056a12d561fbdee7e0af26ba738389c (patch) | |
tree | 7a776c66cd0776977399a7019fee3e5f41d29fae | |
parent | 2f9796fa696e9514280777398467696dd4f004b3 (diff) | |
download | servo-e94f3d4fe056a12d561fbdee7e0af26ba738389c.tar.gz servo-e94f3d4fe056a12d561fbdee7e0af26ba738389c.zip |
Remove the LayoutChan type.
It is a pointless abstraction.
-rw-r--r-- | components/script/dom/bindings/trace.rs | 3 | ||||
-rw-r--r-- | components/script/dom/document.rs | 5 | ||||
-rw-r--r-- | components/script/dom/htmllinkelement.rs | 5 | ||||
-rw-r--r-- | components/script/dom/htmlstyleelement.rs | 5 | ||||
-rw-r--r-- | components/script/dom/node.rs | 5 | ||||
-rw-r--r-- | components/script/dom/window.rs | 14 | ||||
-rw-r--r-- | components/script/layout_interface.rs | 13 | ||||
-rw-r--r-- | components/script/script_thread.rs | 21 |
8 files changed, 26 insertions, 45 deletions
diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index 4a1c781a293..65bed8b0bf1 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -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); diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 00dec5d995f..2ceffe97b21 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -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(); } } diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs index 81b516e0772..a69ec5b9aa5 100644 --- a/components/script/dom/htmllinkelement.rs +++ b/components/script/dom/htmllinkelement.rs @@ -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(); diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs index 62395b682d1..c972cb77bb5 100644 --- a/components/script/dom/htmlstyleelement.rs +++ b/components/script/dom/htmlstyleelement.rs @@ -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(); diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 711e0ba740c..b7f78eb9aa0 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -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(); } } diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 2cd6c4daf9e..a7d2dc608df 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -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 { diff --git a/components/script/layout_interface.rs b/components/script/layout_interface.rs index 7a75a6c846c..b0327305665 100644 --- a/components/script/layout_interface.rs +++ b/components/script/layout_interface.rs @@ -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, diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 5d70af5b059..5f83a467076 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -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(); |