diff options
Diffstat (limited to 'components/layout')
-rw-r--r-- | components/layout/construct.rs | 37 | ||||
-rw-r--r-- | components/layout/context.rs | 4 | ||||
-rw-r--r-- | components/layout/layout_task.rs | 34 | ||||
-rw-r--r-- | components/layout/parallel.rs | 3 | ||||
-rw-r--r-- | components/layout/sequential.rs | 3 | ||||
-rw-r--r-- | components/layout/traversal.rs | 3 |
6 files changed, 38 insertions, 46 deletions
diff --git a/components/layout/construct.rs b/components/layout/construct.rs index fb550b6cf2a..5ebafbaba6b 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -58,6 +58,7 @@ use script::dom::node::{CommentNodeTypeId, DoctypeNodeTypeId, DocumentFragmentNo use script::dom::node::{DocumentNodeTypeId, ElementNodeTypeId, ProcessingInstructionNodeTypeId}; use script::dom::node::{TextNodeTypeId}; use script::dom::htmlobjectelement::is_image_data; +use servo_util::opts; use std::mem; use std::sync::atomics::Relaxed; use style::ComputedValues; @@ -83,8 +84,8 @@ pub enum ConstructionResult { } impl ConstructionResult { - pub fn swap_out(&mut self, layout_context: &LayoutContext) -> ConstructionResult { - if layout_context.shared.opts.incremental_layout { + pub fn swap_out(&mut self) -> ConstructionResult { + if opts::get().incremental_layout { return (*self).clone(); } @@ -352,7 +353,7 @@ impl<'a> FlowConstructor<'a> { inline_flow.minimum_depth_below_baseline = descent; } - inline_flow_ref.finish(self.layout_context); + inline_flow_ref.finish(); if flow.need_anonymous_flow(&*inline_flow_ref) { flow_list.push(inline_flow_ref) @@ -370,7 +371,7 @@ impl<'a> FlowConstructor<'a> { &mut InlineFragmentsAccumulator, abs_descendants: &mut Descendants, first_fragment: &mut bool) { - match kid.swap_out_construction_result(self.layout_context) { + match kid.swap_out_construction_result() { NoConstructionResult => {} FlowConstructionResult(kid_flow, kid_abs_descendants) => { // If kid_flow is TableCaptionFlow, kid_flow should be added under @@ -522,7 +523,7 @@ impl<'a> FlowConstructor<'a> { } // The flow is done. - flow.finish(self.layout_context); + flow.finish(); // Set up the absolute descendants. let is_positioned = flow.as_block().is_positioned(); @@ -573,7 +574,7 @@ impl<'a> FlowConstructor<'a> { if kid.get_pseudo_element_type() != Normal { self.process(&kid); } - match kid.swap_out_construction_result(self.layout_context) { + match kid.swap_out_construction_result() { NoConstructionResult => {} FlowConstructionResult(flow, kid_abs_descendants) => { // {ib} split. Flush the accumulator to our new split and make a new @@ -757,7 +758,7 @@ impl<'a> FlowConstructor<'a> { table_wrapper_flow: &mut FlowRef, node: &ThreadSafeLayoutNode) { for kid in node.children() { - match kid.swap_out_construction_result(self.layout_context) { + match kid.swap_out_construction_result() { NoConstructionResult | ConstructionItemConstructionResult(_) => {} FlowConstructionResult(kid_flow, _) => { // Only kid flows with table-caption are matched here. @@ -794,7 +795,7 @@ impl<'a> FlowConstructor<'a> { self.generate_anonymous_missing_child(consecutive_siblings, &mut anonymous_flow, node); } // The flow is done. - anonymous_flow.finish(self.layout_context); + anonymous_flow.finish(); flow.add_new_child(anonymous_flow); } @@ -836,7 +837,7 @@ impl<'a> FlowConstructor<'a> { } // The flow is done. - wrapper_flow.finish(self.layout_context); + wrapper_flow.finish(); let is_positioned = wrapper_flow.as_block().is_positioned(); let is_fixed_positioned = wrapper_flow.as_block().is_fixed(); let is_absolutely_positioned = wrapper_flow.as_block().is_absolutely_positioned(); @@ -918,7 +919,7 @@ impl<'a> FlowConstructor<'a> { for kid in node.children() { // CSS 2.1 § 17.2.1. Treat all non-column child fragments of `table-column-group` // as `display: none`. - match kid.swap_out_construction_result(self.layout_context) { + match kid.swap_out_construction_result() { ConstructionItemConstructionResult(TableColumnFragmentConstructionItem( fragment)) => { col_fragments.push(fragment); @@ -933,7 +934,7 @@ impl<'a> FlowConstructor<'a> { } let flow = box TableColGroupFlow::from_node_and_fragments(node, fragment, col_fragments); let mut flow = FlowRef::new(flow as Box<Flow>); - flow.finish(self.layout_context); + flow.finish(); FlowConstructionResult(flow, Descendants::new()) } @@ -987,7 +988,7 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> { // results of children. (display::none, _, _) => { for child in node.children() { - drop(child.swap_out_construction_result(self.layout_context)) + drop(child.swap_out_construction_result()) } } @@ -1099,7 +1100,7 @@ trait NodeUtils { /// Replaces the flow construction result in a node with `NoConstructionResult` and returns the /// old value. - fn swap_out_construction_result(self, layout_context: &LayoutContext) -> ConstructionResult; + fn swap_out_construction_result(self) -> ConstructionResult; } impl<'ln> NodeUtils for ThreadSafeLayoutNode<'ln> { @@ -1137,11 +1138,11 @@ impl<'ln> NodeUtils for ThreadSafeLayoutNode<'ln> { } #[inline(always)] - fn swap_out_construction_result(self, layout_context: &LayoutContext) -> ConstructionResult { + fn swap_out_construction_result(self) -> ConstructionResult { let mut layout_data_ref = self.mutate_layout_data(); let layout_data = layout_data_ref.as_mut().expect("no layout data"); - self.get_construction_result(layout_data).swap_out(layout_context) + self.get_construction_result(layout_data).swap_out() } } @@ -1189,7 +1190,7 @@ pub trait FlowConstructionUtils { /// /// All flows must be finished at some point, or they will not have their intrinsic inline-sizes /// properly computed. (This is not, however, a memory safety problem.) - fn finish(&mut self, context: &LayoutContext); + fn finish(&mut self); } impl FlowConstructionUtils for FlowRef { @@ -1216,8 +1217,8 @@ impl FlowConstructionUtils for FlowRef { /// properly computed. (This is not, however, a memory safety problem.) /// /// This must not be public because only the layout constructor can do this. - fn finish(&mut self, context: &LayoutContext) { - if !context.shared.opts.bubble_inline_sizes_separately { + fn finish(&mut self) { + if !opts::get().bubble_inline_sizes_separately { self.bubble_inline_sizes() } } diff --git a/components/layout/context.rs b/components/layout/context.rs index 6b0a61247d8..6d04c131b85 100644 --- a/components/layout/context.rs +++ b/components/layout/context.rs @@ -15,7 +15,6 @@ use script_traits::UntrustedNodeAddress; use servo_msg::constellation_msg::ConstellationChan; use servo_net::local_image_cache::LocalImageCache; use servo_util::geometry::Au; -use servo_util::opts::Opts; use sync::{Arc, Mutex}; use std::mem; use style::Stylist; @@ -75,9 +74,6 @@ pub struct SharedLayoutContext { /// The URL. pub url: Url, - /// The command line options. - pub opts: Opts, - /// The dirty rectangle, used during display list building. pub dirty: Rect<Au>, diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index 48df4f9c460..8504e94fe0d 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -7,7 +7,7 @@ use css::node_style::StyledNode; use construct::FlowConstructionResult; -use context::{LayoutContext, SharedLayoutContext}; +use context::SharedLayoutContext; use flow::{Flow, ImmutableFlowUtils, MutableFlowUtils, MutableOwnedFlowUtils}; use flow; use flow_ref::FlowRef; @@ -50,7 +50,7 @@ use servo_net::resource_task::{ResourceTask, load_bytes_iter}; use servo_util::geometry::Au; use servo_util::geometry; use servo_util::logical_geometry::LogicalPoint; -use servo_util::opts::Opts; +use servo_util::opts; use servo_util::smallvec::{SmallVec, SmallVec1, VecLike}; use servo_util::task::spawn_named_with_send_on_failure; use servo_util::time::{TimeProfilerChan, profile}; @@ -130,9 +130,6 @@ pub struct LayoutTask { /// Public interface to the font cache task. pub font_cache_task: FontCacheTask, - /// The command-line options. - pub opts: Opts, - /// Is this the first reflow in this LayoutTask? pub first_reflow: Cell<bool>, @@ -181,7 +178,6 @@ impl LayoutTaskFactory for LayoutTask { resource_task: ResourceTask, img_cache_task: ImageCacheTask, font_cache_task: FontCacheTask, - opts: Opts, time_profiler_chan: TimeProfilerChan, shutdown_chan: Sender<()>) { let ConstellationChan(con_chan) = constellation_chan.clone(); @@ -200,7 +196,6 @@ impl LayoutTaskFactory for LayoutTask { resource_task, img_cache_task, font_cache_task, - &opts, time_profiler_chan); layout.start(); } @@ -250,14 +245,13 @@ impl LayoutTask { resource_task: ResourceTask, image_cache_task: ImageCacheTask, font_cache_task: FontCacheTask, - opts: &Opts, time_profiler_chan: TimeProfilerChan) -> LayoutTask { let local_image_cache = Arc::new(Mutex::new(LocalImageCache::new(image_cache_task.clone()))); let screen_size = Size2D(Au(0), Au(0)); - let device = Device::new(Screen, opts.initial_window_size.as_f32()); - let parallel_traversal = if opts.layout_threads != 1 { - Some(WorkQueue::new("LayoutWorker", opts.layout_threads, ptr::null())) + let device = Device::new(Screen, opts::get().initial_window_size.as_f32()); + let parallel_traversal = if opts::get().layout_threads != 1 { + Some(WorkQueue::new("LayoutWorker", opts::get().layout_threads, ptr::null())) } else { None }; @@ -274,7 +268,6 @@ impl LayoutTask { resource_task: resource_task, image_cache_task: image_cache_task.clone(), font_cache_task: font_cache_task, - opts: opts.clone(), first_reflow: Cell::new(true), device: device, rw_data: Arc::new(Mutex::new( @@ -315,7 +308,6 @@ impl LayoutTask { stylist: &*rw_data.stylist, url: (*url).clone(), reflow_root: OpaqueNodeMethods::from_layout_node(reflow_root), - opts: self.opts.clone(), dirty: Rect::zero(), generation: rw_data.generation, } @@ -484,11 +476,11 @@ impl LayoutTask { } /// Retrieves the flow tree root from the root node. - fn get_layout_root(&self, node: LayoutNode, layout_context: &LayoutContext) -> FlowRef { + fn get_layout_root(&self, node: LayoutNode) -> FlowRef { let mut layout_data_ref = node.mutate_layout_data(); let layout_data = layout_data_ref.as_mut().expect("no layout data for root node"); - let result = layout_data.data.flow_construction_result.swap_out(layout_context); + let result = layout_data.data.flow_construction_result.swap_out(); let mut flow = match result { FlowConstructionResult(mut flow, abs_descendants) => { @@ -628,7 +620,7 @@ impl LayoutTask { } } - self.get_layout_root((*node).clone(), &LayoutContext::new(&shared_layout_ctx)) + self.get_layout_root((*node).clone()) }); profile(time::LayoutRestyleDamagePropagation, @@ -642,7 +634,7 @@ impl LayoutTask { Some((&data.url, data.iframe, self.first_reflow.get())), self.time_profiler_chan.clone(), || { - if shared_layout_ctx.opts.incremental_layout { + if opts::get().incremental_layout { layout_root.nonincremental_reset(); } }); @@ -652,7 +644,7 @@ impl LayoutTask { // memory safety but is a useful debugging tool.) self.verify_flow_tree(&mut layout_root); - if self.opts.trace_layout { + if opts::get().trace_layout { layout_debug::begin_trace(layout_root.clone()); } @@ -673,7 +665,7 @@ impl LayoutTask { } }); - if self.opts.dump_flow_tree { + if opts::get().dump_flow_tree { layout_root.dump(); } @@ -772,11 +764,11 @@ impl LayoutTask { self.first_reflow.set(false); - if self.opts.trace_layout { + if opts::get().trace_layout { layout_debug::end_trace(); } - if self.opts.dump_flow_tree { + if opts::get().dump_flow_tree { layout_root.dump(); } diff --git a/components/layout/parallel.rs b/components/layout/parallel.rs index df3b340810c..42008396cab 100644 --- a/components/layout/parallel.rs +++ b/components/layout/parallel.rs @@ -19,6 +19,7 @@ use wrapper::{layout_node_to_unsafe_layout_node, layout_node_from_unsafe_layout_ use wrapper::{PostorderNodeMutTraversal, UnsafeLayoutNode}; use wrapper::{PreorderDomTraversal, PostorderDomTraversal}; +use servo_util::opts; use servo_util::time::{TimeProfilerChan, profile}; use servo_util::time; use servo_util::workqueue::{WorkQueue, WorkUnit, WorkerProxy}; @@ -427,7 +428,7 @@ pub fn traverse_flow_tree_preorder(root: &mut FlowRef, time_profiler_chan: TimeProfilerChan, shared_layout_context: &SharedLayoutContext, queue: &mut WorkQueue<*const SharedLayoutContext,UnsafeFlow>) { - if shared_layout_context.opts.bubble_inline_sizes_separately { + if opts::get().bubble_inline_sizes_separately { let layout_context = LayoutContext::new(shared_layout_context); let bubble_inline_sizes = BubbleISizes { layout_context: &layout_context }; root.traverse_postorder(&bubble_inline_sizes); diff --git a/components/layout/sequential.rs b/components/layout/sequential.rs index e0448435088..20f41ff58cb 100644 --- a/components/layout/sequential.rs +++ b/components/layout/sequential.rs @@ -8,6 +8,7 @@ use context::{LayoutContext, SharedLayoutContext}; use flow::{Flow, MutableFlowUtils, PreorderFlowTraversal, PostorderFlowTraversal}; use flow; use flow_ref::FlowRef; +use servo_util::opts; use traversal::{BubbleISizes, RecalcStyleForNode, ConstructFlows}; use traversal::{AssignBSizesAndStoreOverflow, AssignISizes}; use traversal::{ComputeAbsolutePositions, BuildDisplayList}; @@ -54,7 +55,7 @@ pub fn traverse_flow_tree_preorder(root: &mut FlowRef, let root = root.deref_mut(); - if layout_context.shared.opts.bubble_inline_sizes_separately { + if opts::get().bubble_inline_sizes_separately { let bubble_inline_sizes = BubbleISizes { layout_context: &layout_context }; root.traverse_postorder(&bubble_inline_sizes); } diff --git a/components/layout/traversal.rs b/components/layout/traversal.rs index cb2f4a245fa..ac217c46185 100644 --- a/components/layout/traversal.rs +++ b/components/layout/traversal.rs @@ -16,6 +16,7 @@ use wrapper::{PostorderNodeMutTraversal, ThreadSafeLayoutNode, UnsafeLayoutNode} use wrapper::{PreorderDomTraversal, PostorderDomTraversal}; use servo_util::bloom::BloomFilter; +use servo_util::opts; use servo_util::tid::tid; use style::TNode; @@ -204,7 +205,7 @@ impl<'a> PostorderDomTraversal for ConstructFlows<'a> { let tnode = ThreadSafeLayoutNode::new(&node); // Always re-construct if incremental layout is turned off. - if !self.layout_context.shared.opts.incremental_layout { + if !opts::get().incremental_layout { unsafe { node.set_dirty_descendants(true); } |