mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
task -> thread
This commit is contained in:
parent
f00532bab0
commit
1f02c4ebbb
119 changed files with 1209 additions and 1207 deletions
|
@ -47,7 +47,7 @@ use gfx::display_list::{ClippingRegion, DisplayList};
|
|||
use gfx_traits::LayerId;
|
||||
use incremental::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPAINT};
|
||||
use layout_debug;
|
||||
use layout_task::DISPLAY_PORT_SIZE_FACTOR;
|
||||
use layout_thread::DISPLAY_PORT_SIZE_FACTOR;
|
||||
use model::{CollapsibleMargins, MaybeAuto, specified, specified_or_none};
|
||||
use model::{IntrinsicISizes, MarginCollapseInfo};
|
||||
use rustc_serialize::{Encodable, Encoder};
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//! Data needed by the layout task.
|
||||
//! Data needed by the layout thread.
|
||||
|
||||
#![deny(unsafe_code)]
|
||||
|
||||
|
@ -10,13 +10,13 @@ use app_units::Au;
|
|||
use canvas_traits::CanvasMsg;
|
||||
use euclid::Rect;
|
||||
use fnv::FnvHasher;
|
||||
use gfx::font_cache_task::FontCacheTask;
|
||||
use gfx::font_cache_thread::FontCacheThread;
|
||||
use gfx::font_context::FontContext;
|
||||
use gfx_traits::LayerId;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use net_traits::image::base::Image;
|
||||
use net_traits::image_cache_task::{ImageCacheChan, ImageCacheTask, ImageResponse, ImageState};
|
||||
use net_traits::image_cache_task::{UsePlaceholder};
|
||||
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread, ImageResponse, ImageState};
|
||||
use net_traits::image_cache_thread::{UsePlaceholder};
|
||||
use std::cell::{RefCell, RefMut};
|
||||
use std::collections::HashMap;
|
||||
use std::collections::hash_state::DefaultState;
|
||||
|
@ -59,13 +59,13 @@ fn create_or_get_local_context(shared_layout_context: &SharedLayoutContext)
|
|||
}
|
||||
context
|
||||
} else {
|
||||
let font_cache_task = shared_layout_context.font_cache_task.lock().unwrap().clone();
|
||||
let font_cache_thread = shared_layout_context.font_cache_thread.lock().unwrap().clone();
|
||||
let context = Rc::new(LocalLayoutContext {
|
||||
style_context: LocalStyleContext {
|
||||
applicable_declarations_cache: RefCell::new(ApplicableDeclarationsCache::new()),
|
||||
style_sharing_candidate_cache: RefCell::new(StyleSharingCandidateCache::new()),
|
||||
},
|
||||
font_context: RefCell::new(FontContext::new(font_cache_task)),
|
||||
font_context: RefCell::new(FontContext::new(font_cache_thread)),
|
||||
});
|
||||
*r = Some(context.clone());
|
||||
context
|
||||
|
@ -78,19 +78,19 @@ pub struct SharedLayoutContext {
|
|||
/// Bits shared by the layout and style system.
|
||||
pub style_context: SharedStyleContext,
|
||||
|
||||
/// The shared image cache task.
|
||||
pub image_cache_task: ImageCacheTask,
|
||||
/// The shared image cache thread.
|
||||
pub image_cache_thread: ImageCacheThread,
|
||||
|
||||
/// A channel for the image cache to send responses to.
|
||||
pub image_cache_sender: Mutex<ImageCacheChan>,
|
||||
|
||||
/// Interface to the font cache task.
|
||||
pub font_cache_task: Mutex<FontCacheTask>,
|
||||
/// Interface to the font cache thread.
|
||||
pub font_cache_thread: Mutex<FontCacheThread>,
|
||||
|
||||
/// The URL.
|
||||
pub url: Url,
|
||||
|
||||
/// A channel to send canvas renderers to paint task, in order to correctly paint the layers
|
||||
/// A channel to send canvas renderers to paint thread, in order to correctly paint the layers
|
||||
pub canvas_layers_sender: Mutex<Sender<(LayerId, IpcSender<CanvasMsg>)>>,
|
||||
|
||||
/// The visible rects for each layer, as reported to us by the compositor.
|
||||
|
@ -131,7 +131,7 @@ impl<'a> LayoutContext<'a> {
|
|||
pub fn get_or_request_image(&self, url: Url, use_placeholder: UsePlaceholder)
|
||||
-> Option<Arc<Image>> {
|
||||
// See if the image is already available
|
||||
let result = self.shared.image_cache_task.find_image(url.clone(),
|
||||
let result = self.shared.image_cache_thread.find_image(url.clone(),
|
||||
use_placeholder);
|
||||
|
||||
match result {
|
||||
|
@ -148,7 +148,7 @@ impl<'a> LayoutContext<'a> {
|
|||
// Not loaded, test mode - load the image synchronously
|
||||
(_, true) => {
|
||||
let (sync_tx, sync_rx) = ipc::channel().unwrap();
|
||||
self.shared.image_cache_task.request_image(url,
|
||||
self.shared.image_cache_thread.request_image(url,
|
||||
ImageCacheChan(sync_tx),
|
||||
None);
|
||||
match sync_rx.recv().unwrap().image_response {
|
||||
|
@ -160,7 +160,7 @@ impl<'a> LayoutContext<'a> {
|
|||
// Not yet requested, async mode - request image from the cache
|
||||
(ImageState::NotRequested, false) => {
|
||||
let sender = self.shared.image_cache_sender.lock().unwrap().clone();
|
||||
self.shared.image_cache_task.request_image(url, sender, None);
|
||||
self.shared.image_cache_thread.request_image(url, sender, None);
|
||||
None
|
||||
}
|
||||
// Image has been requested, is still pending. Return no image
|
||||
|
|
|
@ -29,7 +29,7 @@ use gfx::display_list::{GradientDisplayItem};
|
|||
use gfx::display_list::{GradientStop, ImageDisplayItem, LayeredItem, LayerInfo};
|
||||
use gfx::display_list::{LineDisplayItem, OpaqueNode, SolidColorDisplayItem};
|
||||
use gfx::display_list::{StackingContext, TextDisplayItem, TextOrientation};
|
||||
use gfx::paint_task::THREAD_TINT_COLORS;
|
||||
use gfx::paint_thread::THREAD_TINT_COLORS;
|
||||
use gfx::text::glyph::CharIndex;
|
||||
use gfx_traits::{color, ScrollPolicy};
|
||||
use inline::{FIRST_FRAGMENT_OF_ELEMENT, InlineFlow, LAST_FRAGMENT_OF_ELEMENT};
|
||||
|
@ -37,7 +37,7 @@ use ipc_channel::ipc::{self, IpcSharedMemory};
|
|||
use list_item::ListItemFlow;
|
||||
use model::{self, MaybeAuto, ToGfxMatrix};
|
||||
use net_traits::image::base::{Image, PixelFormat};
|
||||
use net_traits::image_cache_task::UsePlaceholder;
|
||||
use net_traits::image_cache_thread::UsePlaceholder;
|
||||
use std::default::Default;
|
||||
use std::sync::Arc;
|
||||
use std::sync::mpsc::channel;
|
||||
|
@ -1141,7 +1141,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
FromLayoutMsg::SendPixelContents(sender))).unwrap();
|
||||
let data = receiver.recv().unwrap();
|
||||
|
||||
// Propagate the layer and the renderer to the paint task.
|
||||
// Propagate the layer and the renderer to the paint thread.
|
||||
layout_context.shared.canvas_layers_sender.lock().unwrap().send(
|
||||
(layer_id, (*ipc_renderer).clone())).unwrap();
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ use model::{self, IntrinsicISizes, IntrinsicISizesContribution, MaybeAuto, speci
|
|||
use msg::compositor_msg::LayerType;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use net_traits::image::base::Image;
|
||||
use net_traits::image_cache_task::UsePlaceholder;
|
||||
use net_traits::image_cache_thread::UsePlaceholder;
|
||||
use rustc_serialize::{Encodable, Encoder};
|
||||
use script::dom::htmlcanvaselement::HTMLCanvasData;
|
||||
use std::borrow::ToOwned;
|
||||
|
@ -575,7 +575,7 @@ impl ReplacedImageFragmentInfo {
|
|||
}
|
||||
|
||||
/// A fragment that represents an inline frame (iframe). This stores the pipeline ID so that the
|
||||
/// size of this iframe can be communicated via the constellation to the iframe's own layout task.
|
||||
/// size of this iframe can be communicated via the constellation to the iframe's own layout thread.
|
||||
#[derive(Clone)]
|
||||
pub struct IframeFragmentInfo {
|
||||
/// The pipeline ID of this iframe.
|
||||
|
|
|
@ -116,10 +116,10 @@ pub fn begin_trace(flow_root: FlowRef) {
|
|||
/// trace to disk in the current directory. The output
|
||||
/// file can then be viewed with an external tool.
|
||||
pub fn end_trace() {
|
||||
let mut task_state = STATE_KEY.with(|ref r| r.borrow_mut().take().unwrap());
|
||||
assert!(task_state.scope_stack.len() == 1);
|
||||
let mut root_scope = task_state.scope_stack.pop().unwrap();
|
||||
root_scope.post = json::encode(&flow::base(&*task_state.flow_root)).unwrap();
|
||||
let mut thread_state = STATE_KEY.with(|ref r| r.borrow_mut().take().unwrap());
|
||||
assert!(thread_state.scope_stack.len() == 1);
|
||||
let mut root_scope = thread_state.scope_stack.pop().unwrap();
|
||||
root_scope.post = json::encode(&flow::base(&*thread_state.flow_root)).unwrap();
|
||||
|
||||
let result = json::encode(&root_scope).unwrap();
|
||||
let mut file = File::create("layout_trace.json").unwrap();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//! The layout task. Performs layout on the DOM, builds display lists and sends them to be
|
||||
//! The layout thread. Performs layout on the DOM, builds display lists and sends them to be
|
||||
//! painted.
|
||||
|
||||
#![allow(unsafe_code)]
|
||||
|
@ -24,20 +24,20 @@ use flow_ref::{self, FlowRef};
|
|||
use fnv::FnvHasher;
|
||||
use gfx::display_list::{ClippingRegion, DisplayList, LayerInfo, OpaqueNode, StackingContext};
|
||||
use gfx::font;
|
||||
use gfx::font_cache_task::FontCacheTask;
|
||||
use gfx::font_cache_thread::FontCacheThread;
|
||||
use gfx::font_context;
|
||||
use gfx::paint_task::{LayoutToPaintMsg, PaintLayer};
|
||||
use gfx::paint_thread::{LayoutToPaintMsg, PaintLayer};
|
||||
use gfx_traits::{color, LayerId, ScrollPolicy};
|
||||
use incremental::{LayoutDamageComputation, REFLOW, REFLOW_ENTIRE_DOCUMENT, REPAINT};
|
||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||
use ipc_channel::router::ROUTER;
|
||||
use layout_debug;
|
||||
use layout_traits::LayoutTaskFactory;
|
||||
use layout_traits::LayoutThreadFactory;
|
||||
use log;
|
||||
use msg::ParseErrorReporter;
|
||||
use msg::compositor_msg::Epoch;
|
||||
use msg::constellation_msg::{ConstellationChan, Failure, PipelineId};
|
||||
use net_traits::image_cache_task::{ImageCacheChan, ImageCacheResult, ImageCacheTask};
|
||||
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheResult, ImageCacheThread};
|
||||
use parallel;
|
||||
use profile_traits::mem::{self, Report, ReportKind, ReportsChan};
|
||||
use profile_traits::time::{TimerMetadataFrameType, TimerMetadataReflowType};
|
||||
|
@ -47,7 +47,7 @@ use query::{process_node_geometry_request, process_offset_parent_query, process_
|
|||
use script::dom::node::OpaqueStyleAndLayoutData;
|
||||
use script::layout_interface::Animation;
|
||||
use script::layout_interface::{LayoutRPC, OffsetParentResponse};
|
||||
use script::layout_interface::{Msg, NewLayoutTaskInfo, Reflow, ReflowGoal, ReflowQueryType};
|
||||
use script::layout_interface::{Msg, NewLayoutThreadInfo, Reflow, ReflowGoal, ReflowQueryType};
|
||||
use script::layout_interface::{ScriptLayoutChan, ScriptReflow};
|
||||
use script::reporter::CSSErrorReporter;
|
||||
use script_traits::ConstellationControlMsg;
|
||||
|
@ -77,8 +77,8 @@ use util::ipc::OptionalIpcSender;
|
|||
use util::logical_geometry::LogicalPoint;
|
||||
use util::mem::HeapSizeOf;
|
||||
use util::opts;
|
||||
use util::task;
|
||||
use util::task_state;
|
||||
use util::thread;
|
||||
use util::thread_state;
|
||||
use util::workqueue::WorkQueue;
|
||||
use wrapper::{LayoutNode, NonOpaqueStyleAndLayoutData, ServoLayoutNode, ThreadSafeLayoutNode};
|
||||
|
||||
|
@ -88,10 +88,10 @@ pub const DISPLAY_PORT_SIZE_FACTOR: i32 = 8;
|
|||
/// The number of screens we have to traverse before we decide to generate new display lists.
|
||||
const DISPLAY_PORT_THRESHOLD_SIZE_FACTOR: i32 = 4;
|
||||
|
||||
/// Mutable data belonging to the LayoutTask.
|
||||
/// Mutable data belonging to the LayoutThread.
|
||||
///
|
||||
/// This needs to be protected by a mutex so we can do fast RPCs.
|
||||
pub struct LayoutTaskData {
|
||||
pub struct LayoutThreadData {
|
||||
/// The channel on which messages can be sent to the constellation.
|
||||
pub constellation_chan: ConstellationChan<ConstellationMsg>,
|
||||
|
||||
|
@ -117,8 +117,8 @@ pub struct LayoutTaskData {
|
|||
pub offset_parent_response: OffsetParentResponse,
|
||||
}
|
||||
|
||||
/// Information needed by the layout task.
|
||||
pub struct LayoutTask {
|
||||
/// Information needed by the layout thread.
|
||||
pub struct LayoutThread {
|
||||
/// The ID of the pipeline that we belong to.
|
||||
id: PipelineId,
|
||||
|
||||
|
@ -128,7 +128,7 @@ pub struct LayoutTask {
|
|||
/// Is the current reflow of an iframe, as opposed to a root window?
|
||||
is_iframe: bool,
|
||||
|
||||
/// The port on which we receive messages from the script task.
|
||||
/// The port on which we receive messages from the script thread.
|
||||
port: Receiver<Msg>,
|
||||
|
||||
/// The port on which we receive messages from the constellation.
|
||||
|
@ -140,7 +140,7 @@ pub struct LayoutTask {
|
|||
/// The channel on which the image cache can send messages to ourself.
|
||||
image_cache_sender: ImageCacheChan,
|
||||
|
||||
/// The port on which we receive messages from the font cache task.
|
||||
/// The port on which we receive messages from the font cache thread.
|
||||
font_cache_receiver: Receiver<()>,
|
||||
|
||||
/// The channel on which the font cache can send messages to us.
|
||||
|
@ -149,10 +149,10 @@ pub struct LayoutTask {
|
|||
/// The channel on which messages can be sent to the constellation.
|
||||
constellation_chan: ConstellationChan<ConstellationMsg>,
|
||||
|
||||
/// The channel on which messages can be sent to the script task.
|
||||
/// The channel on which messages can be sent to the script thread.
|
||||
script_chan: IpcSender<ConstellationControlMsg>,
|
||||
|
||||
/// The channel on which messages can be sent to the painting task.
|
||||
/// The channel on which messages can be sent to the painting thread.
|
||||
paint_chan: OptionalIpcSender<LayoutToPaintMsg>,
|
||||
|
||||
/// The channel on which messages can be sent to the time profiler.
|
||||
|
@ -162,12 +162,12 @@ pub struct LayoutTask {
|
|||
mem_profiler_chan: mem::ProfilerChan,
|
||||
|
||||
/// The channel on which messages can be sent to the image cache.
|
||||
image_cache_task: ImageCacheTask,
|
||||
image_cache_thread: ImageCacheThread,
|
||||
|
||||
/// Public interface to the font cache task.
|
||||
font_cache_task: FontCacheTask,
|
||||
/// Public interface to the font cache thread.
|
||||
font_cache_thread: FontCacheThread,
|
||||
|
||||
/// Is this the first reflow in this LayoutTask?
|
||||
/// Is this the first reflow in this LayoutThread?
|
||||
first_reflow: bool,
|
||||
|
||||
/// To receive a canvas renderer associated to a layer, this message is propagated
|
||||
|
@ -213,19 +213,19 @@ pub struct LayoutTask {
|
|||
viewport_size: Size2D<Au>,
|
||||
|
||||
/// A mutex to allow for fast, read-only RPC of layout's internal data
|
||||
/// structures, while still letting the LayoutTask modify them.
|
||||
/// structures, while still letting the LayoutThread modify them.
|
||||
///
|
||||
/// All the other elements of this struct are read-only.
|
||||
rw_data: Arc<Mutex<LayoutTaskData>>,
|
||||
rw_data: Arc<Mutex<LayoutThreadData>>,
|
||||
|
||||
/// The CSS error reporter for all CSS loaded in this layout thread
|
||||
error_reporter: CSSErrorReporter,
|
||||
|
||||
}
|
||||
|
||||
impl LayoutTaskFactory for LayoutTask {
|
||||
/// Spawns a new layout task.
|
||||
fn create(_phantom: Option<&mut LayoutTask>,
|
||||
impl LayoutThreadFactory for LayoutThread {
|
||||
/// Spawns a new layout thread.
|
||||
fn create(_phantom: Option<&mut LayoutThread>,
|
||||
id: PipelineId,
|
||||
url: Url,
|
||||
is_iframe: bool,
|
||||
|
@ -235,19 +235,19 @@ impl LayoutTaskFactory for LayoutTask {
|
|||
failure_msg: Failure,
|
||||
script_chan: IpcSender<ConstellationControlMsg>,
|
||||
paint_chan: OptionalIpcSender<LayoutToPaintMsg>,
|
||||
image_cache_task: ImageCacheTask,
|
||||
font_cache_task: FontCacheTask,
|
||||
image_cache_thread: ImageCacheThread,
|
||||
font_cache_thread: FontCacheThread,
|
||||
time_profiler_chan: time::ProfilerChan,
|
||||
mem_profiler_chan: mem::ProfilerChan,
|
||||
shutdown_chan: IpcSender<()>,
|
||||
content_process_shutdown_chan: IpcSender<()>) {
|
||||
let ConstellationChan(con_chan) = constellation_chan.clone();
|
||||
task::spawn_named_with_send_on_failure(format!("LayoutTask {:?}", id),
|
||||
task_state::LAYOUT,
|
||||
thread::spawn_named_with_send_on_failure(format!("LayoutThread {:?}", id),
|
||||
thread_state::LAYOUT,
|
||||
move || {
|
||||
{ // Ensures layout task is destroyed before we send shutdown message
|
||||
{ // Ensures layout thread is destroyed before we send shutdown message
|
||||
let sender = chan.sender();
|
||||
let layout = LayoutTask::new(id,
|
||||
let layout = LayoutThread::new(id,
|
||||
url,
|
||||
is_iframe,
|
||||
chan.receiver(),
|
||||
|
@ -255,8 +255,8 @@ impl LayoutTaskFactory for LayoutTask {
|
|||
constellation_chan,
|
||||
script_chan,
|
||||
paint_chan,
|
||||
image_cache_task,
|
||||
font_cache_task,
|
||||
image_cache_thread,
|
||||
font_cache_thread,
|
||||
time_profiler_chan,
|
||||
mem_profiler_chan.clone());
|
||||
|
||||
|
@ -271,20 +271,20 @@ impl LayoutTaskFactory for LayoutTask {
|
|||
}
|
||||
}
|
||||
|
||||
/// The `LayoutTask` `rw_data` lock must remain locked until the first reflow,
|
||||
/// The `LayoutThread` `rw_data` lock must remain locked until the first reflow,
|
||||
/// as RPC calls don't make sense until then. Use this in combination with
|
||||
/// `LayoutTask::lock_rw_data` and `LayoutTask::return_rw_data`.
|
||||
/// `LayoutThread::lock_rw_data` and `LayoutThread::return_rw_data`.
|
||||
pub enum RWGuard<'a> {
|
||||
/// If the lock was previously held, from when the task started.
|
||||
Held(MutexGuard<'a, LayoutTaskData>),
|
||||
/// If the lock was previously held, from when the thread started.
|
||||
Held(MutexGuard<'a, LayoutThreadData>),
|
||||
/// If the lock was just used, and has been returned since there has been
|
||||
/// a reflow already.
|
||||
Used(MutexGuard<'a, LayoutTaskData>),
|
||||
Used(MutexGuard<'a, LayoutThreadData>),
|
||||
}
|
||||
|
||||
impl<'a> Deref for RWGuard<'a> {
|
||||
type Target = LayoutTaskData;
|
||||
fn deref(&self) -> &LayoutTaskData {
|
||||
type Target = LayoutThreadData;
|
||||
fn deref(&self) -> &LayoutThreadData {
|
||||
match *self {
|
||||
RWGuard::Held(ref x) => &**x,
|
||||
RWGuard::Used(ref x) => &**x,
|
||||
|
@ -293,7 +293,7 @@ impl<'a> Deref for RWGuard<'a> {
|
|||
}
|
||||
|
||||
impl<'a> DerefMut for RWGuard<'a> {
|
||||
fn deref_mut(&mut self) -> &mut LayoutTaskData {
|
||||
fn deref_mut(&mut self) -> &mut LayoutThreadData {
|
||||
match *self {
|
||||
RWGuard::Held(ref mut x) => &mut **x,
|
||||
RWGuard::Used(ref mut x) => &mut **x,
|
||||
|
@ -302,8 +302,8 @@ impl<'a> DerefMut for RWGuard<'a> {
|
|||
}
|
||||
|
||||
struct RwData<'a, 'b: 'a> {
|
||||
rw_data: &'b Arc<Mutex<LayoutTaskData>>,
|
||||
possibly_locked_rw_data: &'a mut Option<MutexGuard<'b, LayoutTaskData>>,
|
||||
rw_data: &'b Arc<Mutex<LayoutThreadData>>,
|
||||
possibly_locked_rw_data: &'a mut Option<MutexGuard<'b, LayoutThreadData>>,
|
||||
}
|
||||
|
||||
impl<'a, 'b: 'a> RwData<'a, 'b> {
|
||||
|
@ -333,20 +333,20 @@ impl<'a, 'b: 'a> RwData<'a, 'b> {
|
|||
|
||||
fn add_font_face_rules(stylesheet: &Stylesheet,
|
||||
device: &Device,
|
||||
font_cache_task: &FontCacheTask,
|
||||
font_cache_thread: &FontCacheThread,
|
||||
font_cache_sender: &IpcSender<()>,
|
||||
outstanding_web_fonts_counter: &Arc<AtomicUsize>) {
|
||||
for font_face in stylesheet.effective_rules(&device).font_face() {
|
||||
for source in &font_face.sources {
|
||||
if opts::get().load_webfonts_synchronously {
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
font_cache_task.add_web_font(font_face.family.clone(),
|
||||
font_cache_thread.add_web_font(font_face.family.clone(),
|
||||
(*source).clone(),
|
||||
sender);
|
||||
receiver.recv().unwrap();
|
||||
} else {
|
||||
outstanding_web_fonts_counter.fetch_add(1, Ordering::SeqCst);
|
||||
font_cache_task.add_web_font(font_face.family.clone(),
|
||||
font_cache_thread.add_web_font(font_face.family.clone(),
|
||||
(*source).clone(),
|
||||
(*font_cache_sender).clone());
|
||||
}
|
||||
|
@ -354,8 +354,8 @@ fn add_font_face_rules(stylesheet: &Stylesheet,
|
|||
}
|
||||
}
|
||||
|
||||
impl LayoutTask {
|
||||
/// Creates a new `LayoutTask` structure.
|
||||
impl LayoutThread {
|
||||
/// Creates a new `LayoutThread` structure.
|
||||
fn new(id: PipelineId,
|
||||
url: Url,
|
||||
is_iframe: bool,
|
||||
|
@ -364,16 +364,16 @@ impl LayoutTask {
|
|||
constellation_chan: ConstellationChan<ConstellationMsg>,
|
||||
script_chan: IpcSender<ConstellationControlMsg>,
|
||||
paint_chan: OptionalIpcSender<LayoutToPaintMsg>,
|
||||
image_cache_task: ImageCacheTask,
|
||||
font_cache_task: FontCacheTask,
|
||||
image_cache_thread: ImageCacheThread,
|
||||
font_cache_thread: FontCacheThread,
|
||||
time_profiler_chan: time::ProfilerChan,
|
||||
mem_profiler_chan: mem::ProfilerChan)
|
||||
-> LayoutTask {
|
||||
-> LayoutThread {
|
||||
let device = Device::new(
|
||||
MediaType::Screen,
|
||||
opts::get().initial_window_size.as_f32() * ScaleFactor::new(1.0));
|
||||
let parallel_traversal = if opts::get().layout_threads != 1 {
|
||||
Some(WorkQueue::new("LayoutWorker", task_state::LAYOUT,
|
||||
Some(WorkQueue::new("LayoutWorker", thread_state::LAYOUT,
|
||||
opts::get().layout_threads))
|
||||
} else {
|
||||
None
|
||||
|
@ -386,12 +386,12 @@ impl LayoutTask {
|
|||
// Proxy IPC messages from the pipeline to the layout thread.
|
||||
let pipeline_receiver = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(pipeline_port);
|
||||
|
||||
// Ask the router to proxy IPC messages from the image cache task to the layout thread.
|
||||
// Ask the router to proxy IPC messages from the image cache thread to the layout thread.
|
||||
let (ipc_image_cache_sender, ipc_image_cache_receiver) = ipc::channel().unwrap();
|
||||
let image_cache_receiver =
|
||||
ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_image_cache_receiver);
|
||||
|
||||
// Ask the router to proxy IPC messages from the font cache task to the layout thread.
|
||||
// Ask the router to proxy IPC messages from the font cache thread to the layout thread.
|
||||
let (ipc_font_cache_sender, ipc_font_cache_receiver) = ipc::channel().unwrap();
|
||||
let font_cache_receiver =
|
||||
ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_font_cache_receiver);
|
||||
|
@ -401,12 +401,12 @@ impl LayoutTask {
|
|||
for stylesheet in &*USER_OR_USER_AGENT_STYLESHEETS {
|
||||
add_font_face_rules(stylesheet,
|
||||
&stylist.device,
|
||||
&font_cache_task,
|
||||
&font_cache_thread,
|
||||
&ipc_font_cache_sender,
|
||||
&outstanding_web_fonts_counter);
|
||||
}
|
||||
|
||||
LayoutTask {
|
||||
LayoutThread {
|
||||
id: id,
|
||||
url: RefCell::new(url),
|
||||
is_iframe: is_iframe,
|
||||
|
@ -417,8 +417,8 @@ impl LayoutTask {
|
|||
paint_chan: paint_chan,
|
||||
time_profiler_chan: time_profiler_chan,
|
||||
mem_profiler_chan: mem_profiler_chan,
|
||||
image_cache_task: image_cache_task,
|
||||
font_cache_task: font_cache_task,
|
||||
image_cache_thread: image_cache_thread,
|
||||
font_cache_thread: font_cache_thread,
|
||||
first_reflow: true,
|
||||
image_cache_receiver: image_cache_receiver,
|
||||
image_cache_sender: ImageCacheChan(ipc_image_cache_sender),
|
||||
|
@ -438,7 +438,7 @@ impl LayoutTask {
|
|||
epoch: Epoch(0),
|
||||
viewport_size: Size2D::new(Au(0), Au(0)),
|
||||
rw_data: Arc::new(Mutex::new(
|
||||
LayoutTaskData {
|
||||
LayoutThreadData {
|
||||
constellation_chan: constellation_chan,
|
||||
stacking_context: None,
|
||||
stylist: stylist,
|
||||
|
@ -467,7 +467,7 @@ impl LayoutTask {
|
|||
|
||||
// Create a layout context for use in building display lists, hit testing, &c.
|
||||
fn build_shared_layout_context(&self,
|
||||
rw_data: &LayoutTaskData,
|
||||
rw_data: &LayoutThreadData,
|
||||
screen_size_changed: bool,
|
||||
url: &Url,
|
||||
goal: ReflowGoal)
|
||||
|
@ -484,16 +484,16 @@ impl LayoutTask {
|
|||
expired_animations: self.expired_animations.clone(),
|
||||
error_reporter: self.error_reporter.clone(),
|
||||
},
|
||||
image_cache_task: self.image_cache_task.clone(),
|
||||
image_cache_thread: self.image_cache_thread.clone(),
|
||||
image_cache_sender: Mutex::new(self.image_cache_sender.clone()),
|
||||
font_cache_task: Mutex::new(self.font_cache_task.clone()),
|
||||
font_cache_thread: Mutex::new(self.font_cache_thread.clone()),
|
||||
canvas_layers_sender: Mutex::new(self.canvas_layers_sender.clone()),
|
||||
url: (*url).clone(),
|
||||
visible_rects: self.visible_rects.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Receives and dispatches messages from the script and constellation tasks
|
||||
/// Receives and dispatches messages from the script and constellation threads
|
||||
fn handle_request<'a, 'b>(&mut self, possibly_locked_rw_data: &mut RwData<'a, 'b>) -> bool {
|
||||
enum Request {
|
||||
FromPipeline(LayoutControlMsg),
|
||||
|
@ -584,7 +584,7 @@ impl LayoutTask {
|
|||
true
|
||||
}
|
||||
|
||||
/// Receives and dispatches messages from other tasks.
|
||||
/// Receives and dispatches messages from other threads.
|
||||
fn handle_request_helper<'a, 'b>(&mut self,
|
||||
request: Msg,
|
||||
possibly_locked_rw_data: &mut RwData<'a, 'b>)
|
||||
|
@ -628,8 +628,8 @@ impl LayoutTask {
|
|||
let outstanding_web_fonts = self.outstanding_web_fonts.load(Ordering::SeqCst);
|
||||
sender.send(outstanding_web_fonts != 0).unwrap();
|
||||
},
|
||||
Msg::CreateLayoutTask(info) => {
|
||||
self.create_layout_task(info)
|
||||
Msg::CreateLayoutThread(info) => {
|
||||
self.create_layout_thread(info)
|
||||
}
|
||||
Msg::SetFinalUrl(final_url) => {
|
||||
*self.url.borrow_mut() = final_url;
|
||||
|
@ -658,14 +658,14 @@ impl LayoutTask {
|
|||
let stacking_context = rw_data.stacking_context.as_ref();
|
||||
let formatted_url = &format!("url({})", *self.url.borrow());
|
||||
reports.push(Report {
|
||||
path: path![formatted_url, "layout-task", "display-list"],
|
||||
path: path![formatted_url, "layout-thread", "display-list"],
|
||||
kind: ReportKind::ExplicitJemallocHeapSize,
|
||||
size: stacking_context.map_or(0, |sc| sc.heap_size_of_children()),
|
||||
});
|
||||
|
||||
// The LayoutTask has a context in TLS...
|
||||
// The LayoutThread has a context in TLS...
|
||||
reports.push(Report {
|
||||
path: path![formatted_url, "layout-task", "local-context"],
|
||||
path: path![formatted_url, "layout-thread", "local-context"],
|
||||
kind: ReportKind::ExplicitJemallocHeapSize,
|
||||
size: heap_size_of_local_context(),
|
||||
});
|
||||
|
@ -686,8 +686,8 @@ impl LayoutTask {
|
|||
reports_chan.send(reports);
|
||||
}
|
||||
|
||||
fn create_layout_task(&self, info: NewLayoutTaskInfo) {
|
||||
LayoutTaskFactory::create(None::<&mut LayoutTask>,
|
||||
fn create_layout_thread(&self, info: NewLayoutThreadInfo) {
|
||||
LayoutThreadFactory::create(None::<&mut LayoutThread>,
|
||||
info.id,
|
||||
info.url.clone(),
|
||||
info.is_parent,
|
||||
|
@ -697,8 +697,8 @@ impl LayoutTask {
|
|||
info.failure,
|
||||
info.script_chan.clone(),
|
||||
info.paint_chan.to::<LayoutToPaintMsg>(),
|
||||
self.image_cache_task.clone(),
|
||||
self.font_cache_task.clone(),
|
||||
self.image_cache_thread.clone(),
|
||||
self.font_cache_thread.clone(),
|
||||
self.time_profiler_chan.clone(),
|
||||
self.mem_profiler_chan.clone(),
|
||||
info.layout_shutdown_chan,
|
||||
|
@ -717,7 +717,7 @@ impl LayoutTask {
|
|||
}
|
||||
}
|
||||
Msg::ExitNow => {
|
||||
debug!("layout task is exiting...");
|
||||
debug!("layout thread is exiting...");
|
||||
self.exit_now();
|
||||
break
|
||||
}
|
||||
|
@ -731,7 +731,7 @@ impl LayoutTask {
|
|||
}
|
||||
}
|
||||
|
||||
/// Shuts down the layout task now. If there are any DOM nodes left, layout will now (safely)
|
||||
/// Shuts down the layout thread now. If there are any DOM nodes left, layout will now (safely)
|
||||
/// crash.
|
||||
fn exit_now(&mut self) {
|
||||
if let Some(ref mut traversal) = self.parallel_traversal {
|
||||
|
@ -753,7 +753,7 @@ impl LayoutTask {
|
|||
if stylesheet.is_effective_for_device(&rw_data.stylist.device) {
|
||||
add_font_face_rules(&*stylesheet,
|
||||
&rw_data.stylist.device,
|
||||
&self.font_cache_task,
|
||||
&self.font_cache_thread,
|
||||
&self.font_cache_sender,
|
||||
&self.outstanding_web_fonts);
|
||||
}
|
||||
|
@ -829,7 +829,7 @@ impl LayoutTask {
|
|||
data: &Reflow,
|
||||
layout_root: &mut FlowRef,
|
||||
shared_layout_context: &mut SharedLayoutContext,
|
||||
rw_data: &mut LayoutTaskData) {
|
||||
rw_data: &mut LayoutThreadData) {
|
||||
let writing_mode = flow::base(&**layout_root).writing_mode;
|
||||
let (metadata, sender) = (self.profiler_metadata(), self.time_profiler_chan.clone());
|
||||
profile(time::ProfilerCategory::LayoutDispListBuild,
|
||||
|
@ -912,7 +912,7 @@ impl LayoutTask {
|
|||
});
|
||||
}
|
||||
|
||||
/// The high-level routine that performs layout tasks.
|
||||
/// The high-level routine that performs layout threads.
|
||||
fn handle_reflow<'a, 'b>(&mut self,
|
||||
data: &ScriptReflow,
|
||||
possibly_locked_rw_data: &mut RwData<'a, 'b>) {
|
||||
|
@ -994,12 +994,12 @@ impl LayoutTask {
|
|||
let needs_reflow = viewport_size_changed && !needs_dirtying;
|
||||
unsafe {
|
||||
if needs_dirtying {
|
||||
LayoutTask::dirty_all_nodes(node);
|
||||
LayoutThread::dirty_all_nodes(node);
|
||||
}
|
||||
}
|
||||
if needs_reflow {
|
||||
if let Some(mut flow) = self.try_get_layout_root(node) {
|
||||
LayoutTask::reflow_all_nodes(flow_ref::deref_mut(&mut flow));
|
||||
LayoutThread::reflow_all_nodes(flow_ref::deref_mut(&mut flow));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1052,7 +1052,7 @@ impl LayoutTask {
|
|||
self.root_flow = self.try_get_layout_root(node);
|
||||
}
|
||||
|
||||
// Send new canvas renderers to the paint task
|
||||
// Send new canvas renderers to the paint thread
|
||||
while let Ok((layer_id, renderer)) = self.canvas_layers_receiver.try_recv() {
|
||||
// Just send if there's an actual renderer
|
||||
self.paint_chan.send(LayoutToPaintMsg::CanvasLayer(layer_id, renderer)).unwrap();
|
||||
|
@ -1157,7 +1157,7 @@ impl LayoutTask {
|
|||
.unwrap();
|
||||
}
|
||||
|
||||
pub fn tick_animations(&mut self, rw_data: &mut LayoutTaskData) {
|
||||
pub fn tick_animations(&mut self, rw_data: &mut LayoutThreadData) {
|
||||
let reflow_info = Reflow {
|
||||
goal: ReflowGoal::ForDisplay,
|
||||
page_clip_rect: MAX_RECT,
|
||||
|
@ -1210,7 +1210,7 @@ impl LayoutTask {
|
|||
|
||||
fn perform_post_style_recalc_layout_passes(&mut self,
|
||||
data: &Reflow,
|
||||
rw_data: &mut LayoutTaskData,
|
||||
rw_data: &mut LayoutThreadData,
|
||||
layout_context: &mut SharedLayoutContext) {
|
||||
if let Some(mut root_flow) = self.root_flow.clone() {
|
||||
// Kick off animations if any were triggered, expire completed ones.
|
||||
|
@ -1251,11 +1251,11 @@ impl LayoutTask {
|
|||
match self.parallel_traversal {
|
||||
None => {
|
||||
// Sequential mode.
|
||||
LayoutTask::solve_constraints(&mut root_flow, &layout_context)
|
||||
LayoutThread::solve_constraints(&mut root_flow, &layout_context)
|
||||
}
|
||||
Some(ref mut parallel) => {
|
||||
// Parallel mode.
|
||||
LayoutTask::solve_constraints_parallel(parallel,
|
||||
LayoutThread::solve_constraints_parallel(parallel,
|
||||
&mut root_flow,
|
||||
profiler_metadata,
|
||||
self.time_profiler_chan.clone(),
|
||||
|
@ -1270,7 +1270,7 @@ impl LayoutTask {
|
|||
|
||||
fn perform_post_main_layout_passes(&mut self,
|
||||
data: &Reflow,
|
||||
rw_data: &mut LayoutTaskData,
|
||||
rw_data: &mut LayoutThreadData,
|
||||
layout_context: &mut SharedLayoutContext) {
|
||||
// Build the display list if necessary, and send it to the painter.
|
||||
if let Some(mut root_flow) = self.root_flow.clone() {
|
||||
|
@ -1307,11 +1307,11 @@ impl LayoutTask {
|
|||
flow::mut_base(flow).restyle_damage.insert(REFLOW | REPAINT);
|
||||
|
||||
for child in flow::child_iter(flow) {
|
||||
LayoutTask::reflow_all_nodes(child);
|
||||
LayoutThread::reflow_all_nodes(child);
|
||||
}
|
||||
}
|
||||
|
||||
/// Handles a message to destroy layout data. Layout data must be destroyed on *this* task
|
||||
/// Handles a message to destroy layout data. Layout data must be destroyed on *this* thread
|
||||
/// because the struct type is transmuted to a different type on the script side.
|
||||
unsafe fn handle_reap_style_and_layout_data(&self, data: OpaqueStyleAndLayoutData) {
|
||||
let non_opaque: NonOpaqueStyleAndLayoutData = transmute(data.ptr);
|
|
@ -78,7 +78,7 @@ mod fragment;
|
|||
mod generated_content;
|
||||
mod incremental;
|
||||
mod inline;
|
||||
pub mod layout_task;
|
||||
pub mod layout_thread;
|
||||
mod list_item;
|
||||
mod model;
|
||||
mod multicol;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//! Utilities for querying the layout, as needed by the layout task.
|
||||
//! Utilities for querying the layout, as needed by the layout thread.
|
||||
|
||||
use app_units::Au;
|
||||
use construct::ConstructionResult;
|
||||
|
@ -12,7 +12,7 @@ use flow;
|
|||
use flow_ref::FlowRef;
|
||||
use fragment::{Fragment, FragmentBorderBoxIterator, SpecificFragmentInfo};
|
||||
use gfx::display_list::{DisplayItemMetadata, OpaqueNode};
|
||||
use layout_task::LayoutTaskData;
|
||||
use layout_thread::LayoutThreadData;
|
||||
use msg::constellation_msg::ConstellationChan;
|
||||
use opaque_node::OpaqueNodeMethods;
|
||||
use script::layout_interface::{ContentBoxResponse, ContentBoxesResponse, NodeGeometryResponse};
|
||||
|
@ -32,7 +32,7 @@ use util::cursor::Cursor;
|
|||
use util::logical_geometry::WritingMode;
|
||||
use wrapper::{LayoutNode, ThreadSafeLayoutNode};
|
||||
|
||||
pub struct LayoutRPCImpl(pub Arc<Mutex<LayoutTaskData>>);
|
||||
pub struct LayoutRPCImpl(pub Arc<Mutex<LayoutThreadData>>);
|
||||
|
||||
impl LayoutRPC for LayoutRPCImpl {
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ use std::mem;
|
|||
use style::context::StyleContext;
|
||||
use style::matching::MatchMethods;
|
||||
use style::traversal::{DomTraversalContext, STYLE_BLOOM};
|
||||
use style::traversal::{put_task_local_bloom_filter, recalc_style_at};
|
||||
use style::traversal::{put_thread_local_bloom_filter, recalc_style_at};
|
||||
use util::opts;
|
||||
use util::tid::tid;
|
||||
use wrapper::{LayoutNode, ThreadSafeLayoutNode};
|
||||
|
@ -57,7 +57,7 @@ impl<'lc, 'ln, N: LayoutNode<'ln>> DomTraversalContext<'ln, N> for RecalcStyleAn
|
|||
//
|
||||
// [1] For example, the WorkQueue type needs to be parameterized on the concrete type of
|
||||
// DomTraversalContext::SharedContext, and the WorkQueue lifetime is similar to that of the
|
||||
// LayoutTask, generally much longer than that of a given SharedLayoutContext borrow.
|
||||
// LayoutThread, generally much longer than that of a given SharedLayoutContext borrow.
|
||||
let shared_lc: &'lc SharedLayoutContext = unsafe { mem::transmute(shared) };
|
||||
RecalcStyleAndConstructFlows {
|
||||
context: LayoutContext::new(shared_lc),
|
||||
|
@ -120,13 +120,13 @@ fn construct_flows_at<'a, 'ln, N: LayoutNode<'ln>>(context: &'a LayoutContext<'a
|
|||
match node.layout_parent_node(root) {
|
||||
None => {
|
||||
debug!("[{}] - {:X}, and deleting BF.", tid(), unsafe_layout_node.0);
|
||||
// If this is the reflow root, eat the task-local bloom filter.
|
||||
// If this is the reflow root, eat the thread-local bloom filter.
|
||||
}
|
||||
Some(parent) => {
|
||||
// Otherwise, put it back, but remove this node.
|
||||
node.remove_from_bloom_filter(&mut *bf);
|
||||
let unsafe_parent = parent.to_unsafe();
|
||||
put_task_local_bloom_filter(bf, &unsafe_parent, &context.shared_context());
|
||||
put_thread_local_bloom_filter(bf, &unsafe_parent, &context.shared_context());
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
//! onto these objects and cause use-after-free.
|
||||
//!
|
||||
//! When implementing wrapper functions, be careful that you do not touch the borrow flags, or you
|
||||
//! will race and cause spurious task failure. (Note that I do not believe these races are
|
||||
//! will race and cause spurious thread failure. (Note that I do not believe these races are
|
||||
//! exploitable, but they'll result in brokenness nonetheless.)
|
||||
//!
|
||||
//! Rules of the road for this file:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue