mirror of
https://github.com/servo/servo.git
synced 2025-06-08 00:23:30 +00:00
Remove the LayoutChan type.
It is a pointless abstraction.
This commit is contained in:
parent
2f9796fa69
commit
e94f3d4fe0
8 changed files with 26 additions and 45 deletions
|
@ -54,7 +54,7 @@ use js::glue::{CallObjectTracer, CallUnbarrieredObjectTracer, CallValueTracer};
|
||||||
use js::jsapi::{GCTraceKindToAscii, Heap, TraceKind, JSObject, JSTracer};
|
use js::jsapi::{GCTraceKindToAscii, Heap, TraceKind, JSObject, JSTracer};
|
||||||
use js::jsval::JSVal;
|
use js::jsval::JSVal;
|
||||||
use js::rust::Runtime;
|
use js::rust::Runtime;
|
||||||
use layout_interface::{LayoutChan, LayoutRPC};
|
use layout_interface::LayoutRPC;
|
||||||
use libc;
|
use libc;
|
||||||
use msg::constellation_msg::{FrameType, PipelineId, SubpageId, WindowSizeData, WindowSizeType, ReferrerPolicy};
|
use msg::constellation_msg::{FrameType, PipelineId, SubpageId, WindowSizeData, WindowSizeType, ReferrerPolicy};
|
||||||
use net_traits::image::base::{Image, ImageMetadata};
|
use net_traits::image::base::{Image, ImageMetadata};
|
||||||
|
@ -296,7 +296,6 @@ no_jsmanaged_fields!(WorkerId);
|
||||||
no_jsmanaged_fields!(QuirksMode);
|
no_jsmanaged_fields!(QuirksMode);
|
||||||
no_jsmanaged_fields!(Runtime);
|
no_jsmanaged_fields!(Runtime);
|
||||||
no_jsmanaged_fields!(Headers, Method);
|
no_jsmanaged_fields!(Headers, Method);
|
||||||
no_jsmanaged_fields!(LayoutChan);
|
|
||||||
no_jsmanaged_fields!(WindowProxyHandler);
|
no_jsmanaged_fields!(WindowProxyHandler);
|
||||||
no_jsmanaged_fields!(UntrustedNodeAddress);
|
no_jsmanaged_fields!(UntrustedNodeAddress);
|
||||||
no_jsmanaged_fields!(LengthOrPercentageOrAuto);
|
no_jsmanaged_fields!(LengthOrPercentageOrAuto);
|
||||||
|
|
|
@ -92,7 +92,7 @@ use html5ever::tree_builder::{LimitedQuirks, NoQuirks, Quirks, QuirksMode};
|
||||||
use ipc_channel::ipc::{self, IpcSender};
|
use ipc_channel::ipc::{self, IpcSender};
|
||||||
use js::jsapi::JS_GetRuntime;
|
use js::jsapi::JS_GetRuntime;
|
||||||
use js::jsapi::{JSContext, JSObject, JSRuntime};
|
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::{ALT, CONTROL, SHIFT, SUPER};
|
||||||
use msg::constellation_msg::{Key, KeyModifiers, KeyState};
|
use msg::constellation_msg::{Key, KeyModifiers, KeyState};
|
||||||
use msg::constellation_msg::{PipelineId, ReferrerPolicy, SubpageId};
|
use msg::constellation_msg::{PipelineId, ReferrerPolicy, SubpageId};
|
||||||
|
@ -404,8 +404,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();
|
self.window.layout_chan().send(Msg::SetQuirksMode).unwrap();
|
||||||
layout_chan.send(Msg::SetQuirksMode).unwrap();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ use hyper::header::ContentType;
|
||||||
use hyper::mime::{Mime, TopLevel, SubLevel};
|
use hyper::mime::{Mime, TopLevel, SubLevel};
|
||||||
use ipc_channel::ipc;
|
use ipc_channel::ipc;
|
||||||
use ipc_channel::router::ROUTER;
|
use ipc_channel::router::ROUTER;
|
||||||
use layout_interface::{LayoutChan, Msg};
|
use layout_interface::Msg;
|
||||||
use net_traits::{AsyncResponseListener, AsyncResponseTarget, Metadata, NetworkError};
|
use net_traits::{AsyncResponseListener, AsyncResponseTarget, Metadata, NetworkError};
|
||||||
use network_listener::{NetworkListener, PreInvoke};
|
use network_listener::{NetworkListener, PreInvoke};
|
||||||
use script_traits::{MozBrowserEvent, ScriptMsg as ConstellationMsg};
|
use script_traits::{MozBrowserEvent, ScriptMsg as ConstellationMsg};
|
||||||
|
@ -318,8 +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.layout_chan();
|
win.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);
|
||||||
document.invalidate_stylesheets();
|
document.invalidate_stylesheets();
|
||||||
|
|
|
@ -14,7 +14,7 @@ use dom::element::Element;
|
||||||
use dom::htmlelement::HTMLElement;
|
use dom::htmlelement::HTMLElement;
|
||||||
use dom::node::{ChildrenMutation, Node, document_from_node, window_from_node};
|
use dom::node::{ChildrenMutation, Node, document_from_node, window_from_node};
|
||||||
use dom::virtualmethods::VirtualMethods;
|
use dom::virtualmethods::VirtualMethods;
|
||||||
use layout_interface::{LayoutChan, Msg};
|
use layout_interface::Msg;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use string_cache::Atom;
|
use string_cache::Atom;
|
||||||
use style::media_queries::parse_media_query_list;
|
use style::media_queries::parse_media_query_list;
|
||||||
|
@ -68,8 +68,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();
|
win.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);
|
||||||
doc.r().invalidate_stylesheets();
|
doc.r().invalidate_stylesheets();
|
||||||
|
|
|
@ -54,7 +54,7 @@ use euclid::size::Size2D;
|
||||||
use heapsize::{HeapSizeOf, heap_size_of};
|
use heapsize::{HeapSizeOf, heap_size_of};
|
||||||
use html5ever::tree_builder::QuirksMode;
|
use html5ever::tree_builder::QuirksMode;
|
||||||
use js::jsapi::{JSContext, JSObject, JSRuntime};
|
use js::jsapi::{JSContext, JSObject, JSRuntime};
|
||||||
use layout_interface::{LayoutChan, Msg};
|
use layout_interface::Msg;
|
||||||
use libc::{self, c_void, uintptr_t};
|
use libc::{self, c_void, uintptr_t};
|
||||||
use parse::html::parse_html_fragment;
|
use parse::html::parse_html_fragment;
|
||||||
use ref_slice::ref_slice;
|
use ref_slice::ref_slice;
|
||||||
|
@ -195,9 +195,8 @@ 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(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();
|
win.layout_chan().send(Msg::ReapStyleAndLayoutData(self)).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ use js::jsapi::{JS_GetRuntime, JS_GC, MutableHandleValue, SetWindowProxy};
|
||||||
use js::rust::CompileOptionsWrapper;
|
use js::rust::CompileOptionsWrapper;
|
||||||
use js::rust::Runtime;
|
use js::rust::Runtime;
|
||||||
use layout_interface::{ContentBoxResponse, ContentBoxesResponse, ResolvedStyleResponse, ScriptReflow};
|
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 libc;
|
||||||
use msg::constellation_msg::{LoadData, PanicMsg, PipelineId, SubpageId};
|
use msg::constellation_msg::{LoadData, PanicMsg, PipelineId, SubpageId};
|
||||||
use msg::constellation_msg::{WindowSizeData, WindowSizeType};
|
use msg::constellation_msg::{WindowSizeData, WindowSizeType};
|
||||||
|
@ -209,7 +209,7 @@ pub struct Window {
|
||||||
|
|
||||||
/// A handle for communicating messages to the layout thread.
|
/// A handle for communicating messages to the layout thread.
|
||||||
#[ignore_heap_size_of = "channels are hard"]
|
#[ignore_heap_size_of = "channels are hard"]
|
||||||
layout_chan: LayoutChan,
|
layout_chan: Sender<Msg>,
|
||||||
|
|
||||||
/// A handle to perform RPC calls into the layout, quickly.
|
/// A handle to perform RPC calls into the layout, quickly.
|
||||||
#[ignore_heap_size_of = "trait objects are hard"]
|
#[ignore_heap_size_of = "trait objects are hard"]
|
||||||
|
@ -1057,8 +1057,7 @@ impl Window {
|
||||||
query_type: query_type,
|
query_type: query_type,
|
||||||
};
|
};
|
||||||
|
|
||||||
let LayoutChan(ref chan) = self.layout_chan;
|
self.layout_chan.send(Msg::Reflow(reflow)).unwrap();
|
||||||
chan.send(Msg::Reflow(reflow)).unwrap();
|
|
||||||
|
|
||||||
debug!("script: layout forked");
|
debug!("script: layout forked");
|
||||||
|
|
||||||
|
@ -1300,7 +1299,7 @@ impl Window {
|
||||||
self.devtools_chan.clone()
|
self.devtools_chan.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn layout_chan(&self) -> &LayoutChan {
|
pub fn layout_chan(&self) -> &Sender<Msg> {
|
||||||
&self.layout_chan
|
&self.layout_chan
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1484,15 +1483,14 @@ impl Window {
|
||||||
scheduler_chan: IpcSender<TimerEventRequest>,
|
scheduler_chan: IpcSender<TimerEventRequest>,
|
||||||
panic_chan: IpcSender<PanicMsg>,
|
panic_chan: IpcSender<PanicMsg>,
|
||||||
timer_event_chan: IpcSender<TimerEvent>,
|
timer_event_chan: IpcSender<TimerEvent>,
|
||||||
layout_chan: LayoutChan,
|
layout_chan: Sender<Msg>,
|
||||||
id: PipelineId,
|
id: PipelineId,
|
||||||
parent_info: Option<(PipelineId, SubpageId)>,
|
parent_info: Option<(PipelineId, SubpageId)>,
|
||||||
window_size: Option<WindowSizeData>)
|
window_size: Option<WindowSizeData>)
|
||||||
-> Root<Window> {
|
-> Root<Window> {
|
||||||
let layout_rpc: Box<LayoutRPC> = {
|
let layout_rpc: Box<LayoutRPC> = {
|
||||||
let (rpc_send, rpc_recv) = channel();
|
let (rpc_send, rpc_recv) = channel();
|
||||||
let LayoutChan(ref lchan) = layout_chan;
|
layout_chan.send(Msg::GetRPC(rpc_send)).unwrap();
|
||||||
lchan.send(Msg::GetRPC(rpc_send)).unwrap();
|
|
||||||
rpc_recv.recv().unwrap()
|
rpc_recv.recv().unwrap()
|
||||||
};
|
};
|
||||||
let error_reporter = CSSErrorReporter {
|
let error_reporter = CSSErrorReporter {
|
||||||
|
|
|
@ -18,7 +18,7 @@ use profile_traits::mem::ReportsChan;
|
||||||
use script_traits::UntrustedNodeAddress;
|
use script_traits::UntrustedNodeAddress;
|
||||||
use script_traits::{ConstellationControlMsg, LayoutControlMsg, LayoutMsg as ConstellationMsg};
|
use script_traits::{ConstellationControlMsg, LayoutControlMsg, LayoutMsg as ConstellationMsg};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::mpsc::{Receiver, Sender, channel};
|
use std::sync::mpsc::{Receiver, Sender};
|
||||||
use string_cache::Atom;
|
use string_cache::Atom;
|
||||||
use style::context::ReflowGoal;
|
use style::context::ReflowGoal;
|
||||||
use style::properties::longhands::{margin_top, margin_right, margin_bottom, margin_left, overflow_x};
|
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 struct NewLayoutThreadInfo {
|
||||||
pub id: PipelineId,
|
pub id: PipelineId,
|
||||||
pub url: Url,
|
pub url: Url,
|
||||||
|
|
|
@ -57,8 +57,7 @@ use js::jsapi::{DOMProxyShadowsResult, HandleId, HandleObject, RootedValue};
|
||||||
use js::jsapi::{JSContext, JS_SetWrapObjectCallbacks, JSTracer, SetWindowProxyClass};
|
use js::jsapi::{JSContext, JS_SetWrapObjectCallbacks, JSTracer, SetWindowProxyClass};
|
||||||
use js::jsval::UndefinedValue;
|
use js::jsval::UndefinedValue;
|
||||||
use js::rust::Runtime;
|
use js::rust::Runtime;
|
||||||
use layout_interface::ReflowQueryType;
|
use layout_interface::{self, NewLayoutThreadInfo, ReflowQueryType};
|
||||||
use layout_interface::{self, LayoutChan, NewLayoutThreadInfo};
|
|
||||||
use mem::heap_size_of_self_and_children;
|
use mem::heap_size_of_self_and_children;
|
||||||
use msg::constellation_msg::{LoadData, PanicMsg, PipelineId, PipelineNamespace};
|
use msg::constellation_msg::{LoadData, PanicMsg, PipelineId, PipelineNamespace};
|
||||||
use msg::constellation_msg::{SubpageId, WindowSizeData, WindowSizeType};
|
use msg::constellation_msg::{SubpageId, WindowSizeData, WindowSizeType};
|
||||||
|
@ -132,7 +131,7 @@ struct InProgressLoad {
|
||||||
/// The current window size associated with this pipeline.
|
/// The current window size associated with this pipeline.
|
||||||
window_size: Option<WindowSizeData>,
|
window_size: Option<WindowSizeData>,
|
||||||
/// Channel to the layout thread associated with this pipeline.
|
/// 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.
|
/// The current viewport clipping rectangle applying to this pipeline, if any.
|
||||||
clip_rect: Option<Rect<f32>>,
|
clip_rect: Option<Rect<f32>>,
|
||||||
/// Window is frozen (navigated away while loading for example).
|
/// Window is frozen (navigated away while loading for example).
|
||||||
|
@ -145,7 +144,7 @@ impl InProgressLoad {
|
||||||
/// Create a new InProgressLoad object.
|
/// Create a new InProgressLoad object.
|
||||||
fn new(id: PipelineId,
|
fn new(id: PipelineId,
|
||||||
parent_info: Option<(PipelineId, SubpageId)>,
|
parent_info: Option<(PipelineId, SubpageId)>,
|
||||||
layout_chan: LayoutChan,
|
layout_chan: Sender<layout_interface::Msg>,
|
||||||
window_size: Option<WindowSizeData>,
|
window_size: Option<WindowSizeData>,
|
||||||
url: Url) -> InProgressLoad {
|
url: Url) -> InProgressLoad {
|
||||||
InProgressLoad {
|
InProgressLoad {
|
||||||
|
@ -431,7 +430,7 @@ impl ScriptThreadFactory for ScriptThread {
|
||||||
let (script_chan, script_port) = channel();
|
let (script_chan, script_port) = channel();
|
||||||
|
|
||||||
let (sender, receiver) = channel();
|
let (sender, receiver) = channel();
|
||||||
let layout_chan = LayoutChan(sender.clone());
|
let layout_chan = sender.clone();
|
||||||
let pipeline_id = state.id;
|
let pipeline_id = state.id;
|
||||||
thread::spawn_named_with_send_on_panic(format!("ScriptThread {:?}", state.id),
|
thread::spawn_named_with_send_on_panic(format!("ScriptThread {:?}", state.id),
|
||||||
thread_state::SCRIPT,
|
thread_state::SCRIPT,
|
||||||
|
@ -1092,7 +1091,7 @@ impl ScriptThread {
|
||||||
} = new_layout_info;
|
} = new_layout_info;
|
||||||
|
|
||||||
let layout_pair = channel();
|
let layout_pair = channel();
|
||||||
let layout_chan = LayoutChan(layout_pair.0.clone());
|
let layout_chan = layout_pair.0.clone();
|
||||||
|
|
||||||
let layout_creation_info = NewLayoutThreadInfo {
|
let layout_creation_info = NewLayoutThreadInfo {
|
||||||
id: new_pipeline_id,
|
id: new_pipeline_id,
|
||||||
|
@ -1117,7 +1116,6 @@ impl ScriptThread {
|
||||||
|
|
||||||
// Tell layout to actually spawn the thread.
|
// Tell layout to actually spawn the thread.
|
||||||
parent_window.layout_chan()
|
parent_window.layout_chan()
|
||||||
.0
|
|
||||||
.send(layout_interface::Msg::CreateLayoutThread(layout_creation_info))
|
.send(layout_interface::Msg::CreateLayoutThread(layout_creation_info))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -1342,7 +1340,7 @@ impl ScriptThread {
|
||||||
// Tell the layout thread to begin shutting down, and wait until it
|
// Tell the layout thread to begin shutting down, and wait until it
|
||||||
// processed this message.
|
// processed this message.
|
||||||
let (response_chan, response_port) = channel();
|
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() {
|
if chan.send(layout_interface::Msg::PrepareToExit(response_chan)).is_ok() {
|
||||||
debug!("shutting down layout for page {:?}", id);
|
debug!("shutting down layout for page {:?}", id);
|
||||||
response_port.recv().unwrap();
|
response_port.recv().unwrap();
|
||||||
|
@ -1401,8 +1399,9 @@ impl ScriptThread {
|
||||||
let final_url = metadata.final_url.clone();
|
let final_url = metadata.final_url.clone();
|
||||||
{
|
{
|
||||||
// send the final url to the layout thread.
|
// send the final url to the layout thread.
|
||||||
let LayoutChan(ref chan) = incomplete.layout_chan;
|
incomplete.layout_chan
|
||||||
chan.send(layout_interface::Msg::SetFinalUrl(final_url.clone())).unwrap();
|
.send(layout_interface::Msg::SetFinalUrl(final_url.clone()))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
// update the pipeline url
|
// update the pipeline url
|
||||||
self.constellation_chan
|
self.constellation_chan
|
||||||
|
@ -2000,7 +1999,7 @@ fn shut_down_layout(context_tree: &BrowsingContext) {
|
||||||
// processed this message.
|
// processed this message.
|
||||||
let (response_chan, response_port) = channel();
|
let (response_chan, response_port) = channel();
|
||||||
let window = context.active_window();
|
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() {
|
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