diff options
-rw-r--r-- | src/components/main/layout/block.rs | 4 | ||||
-rw-r--r-- | src/components/main/layout/construct.rs | 24 | ||||
-rw-r--r-- | src/components/main/layout/float.rs | 4 | ||||
-rw-r--r-- | src/components/main/layout/flow.rs | 52 | ||||
-rw-r--r-- | src/components/main/layout/inline.rs | 8 | ||||
-rw-r--r-- | src/components/main/layout/layout_task.rs | 20 | ||||
-rw-r--r-- | src/components/main/layout/text.rs | 6 |
7 files changed, 59 insertions, 59 deletions
diff --git a/src/components/main/layout/block.rs b/src/components/main/layout/block.rs index bae5add6f09..995c35397d4 100644 --- a/src/components/main/layout/block.rs +++ b/src/components/main/layout/block.rs @@ -7,7 +7,7 @@ use layout::box::{RenderBox, RenderBoxUtils}; use layout::context::LayoutContext; use layout::display_list_builder::{DisplayListBuilder, ExtraDisplayListData}; -use layout::flow::{BlockFlowClass, FlowClass, FlowContext, FlowData, ImmutableFlowUtils}; +use layout::flow::{BlockFlowClass, FlowClass, Flow, FlowData, ImmutableFlowUtils}; use layout::flow; use layout::model::{MaybeAuto, Specified, Auto, specified_or_none, specified}; use layout::float_context::{FloatContext, Invalid}; @@ -304,7 +304,7 @@ impl BlockFlow { } } -impl FlowContext for BlockFlow { +impl Flow for BlockFlow { fn class(&self) -> FlowClass { BlockFlowClass } diff --git a/src/components/main/layout/construct.rs b/src/components/main/layout/construct.rs index a190783f8d5..ea4f70af101 100644 --- a/src/components/main/layout/construct.rs +++ b/src/components/main/layout/construct.rs @@ -27,7 +27,7 @@ use layout::box::{UnscannedTextRenderBox}; use layout::context::LayoutContext; use layout::float::FloatFlow; use layout::float_context::FloatType; -use layout::flow::{FlowContext, FlowData, MutableFlowUtils}; +use layout::flow::{Flow, FlowData, MutableFlowUtils}; use layout::inline::InlineFlow; use layout::text::TextRunScanner; use layout::util::LayoutDataAccess; @@ -49,7 +49,7 @@ pub enum ConstructionResult { /// This node contributed a flow at the proper position in the tree. Nothing more needs to be /// done for this node. - FlowConstructionResult(~FlowContext:), + FlowConstructionResult(~Flow:), /// This node contributed some object or objects that will be needed to construct a proper flow /// later up the tree, but these objects have not yet found their home. @@ -57,7 +57,7 @@ pub enum ConstructionResult { } /// Represents the output of flow construction for a DOM node that has not yet resulted in a -/// complete flow. Construction items bubble up the tree until they find a `FlowContext` to be +/// complete flow. Construction items bubble up the tree until they find a `Flow` to be /// attached to. enum ConstructionItem { /// Inline boxes and associated {ib} splits that have not yet found flows. @@ -104,7 +104,7 @@ struct InlineBlockSplit { predecessor_boxes: ~[@RenderBox], /// The flow that caused this {ib} split. - flow: ~FlowContext:, + flow: ~Flow:, } /// Methods on optional vectors. @@ -247,11 +247,11 @@ impl<'self> FlowConstructor<'self> { #[inline(always)] fn flush_inline_boxes_to_flow(&self, boxes: ~[@RenderBox], - flow: &mut ~FlowContext:, + flow: &mut ~Flow:, node: AbstractNode<LayoutView>) { if boxes.len() > 0 { let inline_base = FlowData::new(self.next_flow_id(), node); - let mut inline_flow = ~InlineFlow::from_boxes(inline_base, boxes) as ~FlowContext:; + let mut inline_flow = ~InlineFlow::from_boxes(inline_base, boxes) as ~Flow:; TextRunScanner::new().scan_for_runs(self.layout_context, inline_flow); flow.add_new_child(inline_flow) } @@ -261,7 +261,7 @@ impl<'self> FlowConstructor<'self> { /// the given flow. fn flush_inline_boxes_to_flow_if_necessary(&self, opt_boxes: &mut Option<~[@RenderBox]>, - flow: &mut ~FlowContext:, + flow: &mut ~Flow:, node: AbstractNode<LayoutView>) { let opt_boxes = util::replace(opt_boxes, None); if opt_boxes.len() > 0 { @@ -273,7 +273,7 @@ impl<'self> FlowConstructor<'self> { /// other `BlockFlow`s or `InlineFlow`s will be populated underneath this node, depending on /// whether {ib} splits needed to happen. fn build_children_of_block_flow(&self, - flow: &mut ~FlowContext:, + flow: &mut ~Flow:, node: AbstractNode<LayoutView>) { // Gather up boxes for the inline flows we might need to create. let mut opt_boxes_for_inline_flow = None; @@ -352,10 +352,10 @@ impl<'self> FlowConstructor<'self> { /// Builds a flow for a node with `display: block`. This yields a `BlockFlow` with possibly /// other `BlockFlow`s or `InlineFlow`s underneath it, depending on whether {ib} splits needed /// to happen. - fn build_flow_for_block(&self, node: AbstractNode<LayoutView>) -> ~FlowContext: { + fn build_flow_for_block(&self, node: AbstractNode<LayoutView>) -> ~Flow: { let base = FlowData::new(self.next_flow_id(), node); let box = self.build_box_for_node(node); - let mut flow = ~BlockFlow::from_box(base, box) as ~FlowContext:; + let mut flow = ~BlockFlow::from_box(base, box) as ~Flow:; self.build_children_of_block_flow(&mut flow, node); flow } @@ -363,10 +363,10 @@ impl<'self> FlowConstructor<'self> { /// Builds the flow for a node with `float: {left|right}`. This yields a `FloatFlow` with a /// `BlockFlow` underneath it. fn build_flow_for_floated_block(&self, node: AbstractNode<LayoutView>, float_type: FloatType) - -> ~FlowContext: { + -> ~Flow: { let base = FlowData::new(self.next_flow_id(), node); let box = self.build_box_for_node(node); - let mut flow = ~FloatFlow::from_box(base, float_type, box) as ~FlowContext:; + let mut flow = ~FloatFlow::from_box(base, float_type, box) as ~Flow:; self.build_children_of_block_flow(&mut flow, node); flow } diff --git a/src/components/main/layout/float.rs b/src/components/main/layout/float.rs index be7ac50524b..b6d123844b1 100644 --- a/src/components/main/layout/float.rs +++ b/src/components/main/layout/float.rs @@ -5,7 +5,7 @@ use layout::box::{RenderBox, RenderBoxUtils}; use layout::context::LayoutContext; use layout::display_list_builder::{DisplayListBuilder, ExtraDisplayListData}; -use layout::flow::{FloatFlowClass, FlowClass, FlowContext, FlowData}; +use layout::flow::{FloatFlowClass, FlowClass, Flow, FlowData}; use layout::flow; use layout::model::{MaybeAuto}; use layout::float_context::{FloatContext, PlacementInfo, FloatType}; @@ -111,7 +111,7 @@ impl FloatFlow { } } -impl FlowContext for FloatFlow { +impl Flow for FloatFlow { fn class(&self) -> FlowClass { FloatFlowClass } diff --git a/src/components/main/layout/flow.rs b/src/components/main/layout/flow.rs index 16a68c0b8b3..2ad37fa0d82 100644 --- a/src/components/main/layout/flow.rs +++ b/src/components/main/layout/flow.rs @@ -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/. */ -//! Servo's experimental layout system builds a tree of `FlowContext` and `RenderBox` objects and +//! Servo's experimental layout system builds a tree of `Flow` and `RenderBox` objects and /// solves layout constraints to obtain positions and display attributes of tree nodes. Positions /// are computed in several tree traversals driven by the fundamental data dependencies required by /// inline and block layout. @@ -50,7 +50,7 @@ use std::cell::Cell; /// /// Note that virtual methods have a cost; we should not overuse them in Servo. Consider adding /// methods to `ImmutableFlowUtils` or `MutableFlowUtils` before adding more methods here. -pub trait FlowContext { +pub trait Flow { // RTTI // // TODO(pcwalton): Use Rust's RTTI, once that works. @@ -124,7 +124,7 @@ pub trait FlowContext { // Base access #[inline(always)] -pub fn base<'a>(this: &'a FlowContext) -> &'a FlowData { +pub fn base<'a>(this: &'a Flow) -> &'a FlowData { unsafe { let (_, ptr): (uint, &FlowData) = cast::transmute(this); ptr @@ -132,12 +132,12 @@ pub fn base<'a>(this: &'a FlowContext) -> &'a FlowData { } /// Iterates over the children of this immutable flow. -pub fn imm_child_iter<'a>(flow: &'a FlowContext) -> DListIterator<'a,~FlowContext:> { +pub fn imm_child_iter<'a>(flow: &'a Flow) -> DListIterator<'a,~Flow:> { base(flow).children.iter() } #[inline(always)] -pub fn mut_base<'a>(this: &'a mut FlowContext) -> &'a mut FlowData { +pub fn mut_base<'a>(this: &'a mut Flow) -> &'a mut FlowData { unsafe { let (_, ptr): (uint, &mut FlowData) = cast::transmute(this); ptr @@ -145,12 +145,12 @@ pub fn mut_base<'a>(this: &'a mut FlowContext) -> &'a mut FlowData { } /// Returns the last child of this flow. -pub fn last_child<'a>(flow: &'a mut FlowContext) -> Option<&'a mut ~FlowContext:> { +pub fn last_child<'a>(flow: &'a mut Flow) -> Option<&'a mut ~Flow:> { mut_base(flow).children.back_mut() } /// Iterates over the children of this flow. -pub fn child_iter<'a>(flow: &'a mut FlowContext) -> MutDListIterator<'a,~FlowContext:> { +pub fn child_iter<'a>(flow: &'a mut Flow) -> MutDListIterator<'a,~Flow:> { mut_base(flow).children.mut_iter() } @@ -188,13 +188,13 @@ pub trait MutableFlowUtils { // Mutators /// Adds a new flow as a child of this flow. - fn add_new_child(self, new_child: ~FlowContext:); + fn add_new_child(self, new_child: ~Flow:); /// Invokes a closure with the first child of this flow. - fn with_first_child<R>(self, f: &fn(Option<&mut ~FlowContext:>) -> R) -> R; + fn with_first_child<R>(self, f: &fn(Option<&mut ~Flow:>) -> R) -> R; /// Invokes a closure with the last child of this flow. - fn with_last_child<R>(self, f: &fn(Option<&mut ~FlowContext:>) -> R) -> R; + fn with_last_child<R>(self, f: &fn(Option<&mut ~Flow:>) -> R) -> R; /// Removes the first child of this flow and destroys it. fn remove_first(self); @@ -237,7 +237,7 @@ impl AbsoluteFlow { } } -impl FlowContext for AbsoluteFlow { +impl Flow for AbsoluteFlow { fn class(&self) -> FlowClass { AbsoluteFlowClass } @@ -255,7 +255,7 @@ impl InlineBlockFlow { } } -impl FlowContext for InlineBlockFlow { +impl Flow for InlineBlockFlow { fn class(&self) -> FlowClass { InlineBlockFlowClass } @@ -273,7 +273,7 @@ impl TableFlow { } } -impl FlowContext for TableFlow { +impl Flow for TableFlow { fn class(&self) -> FlowClass { TableFlowClass } @@ -282,12 +282,12 @@ impl FlowContext for TableFlow { /// A top-down traversal. pub trait PreorderFlowTraversal { /// The operation to perform. Return true to continue or false to stop. - fn process(&mut self, flow: &mut FlowContext) -> bool; + fn process(&mut self, flow: &mut Flow) -> bool; /// Returns true if this node should be pruned. If this returns true, we skip the operation /// entirely and do not process any descendant nodes. This is called *before* child nodes are /// visited. The default implementation never prunes any nodes. - fn should_prune(&mut self, _flow: &mut FlowContext) -> bool { + fn should_prune(&mut self, _flow: &mut Flow) -> bool { false } } @@ -295,19 +295,19 @@ pub trait PreorderFlowTraversal { /// A bottom-up traversal, with a optional in-order pass. pub trait PostorderFlowTraversal { /// The operation to perform. Return true to continue or false to stop. - fn process(&mut self, flow: &mut FlowContext) -> bool; + fn process(&mut self, flow: &mut Flow) -> bool; /// Returns false if this node must be processed in-order. If this returns false, we skip the /// operation for this node, but continue processing the descendants. This is called *after* /// child nodes are visited. - fn should_process(&mut self, _flow: &mut FlowContext) -> bool { + fn should_process(&mut self, _flow: &mut Flow) -> bool { true } /// Returns true if this node should be pruned. If this returns true, we skip the operation /// entirely and do not process any descendant nodes. This is called *before* child nodes are /// visited. The default implementation never prunes any nodes. - fn should_prune(&mut self, _flow: &mut FlowContext) -> bool { + fn should_prune(&mut self, _flow: &mut Flow) -> bool { false } } @@ -320,7 +320,7 @@ pub struct FlowData { node: AbstractNode<LayoutView>, restyle_damage: RestyleDamage, - children: DList<~FlowContext:>, + children: DList<~Flow:>, /* TODO (Issue #87): debug only */ id: int, @@ -386,12 +386,12 @@ impl FlowData { } } - pub fn child_iter<'a>(&'a mut self) -> MutDListIterator<'a,~FlowContext:> { + pub fn child_iter<'a>(&'a mut self) -> MutDListIterator<'a,~Flow:> { self.children.mut_iter() } } -impl<'self> ImmutableFlowUtils for &'self FlowContext { +impl<'self> ImmutableFlowUtils for &'self Flow { /// Returns true if this flow is a block or a float flow. fn is_block_like(self) -> bool { match self.class() { @@ -440,7 +440,7 @@ impl<'self> ImmutableFlowUtils for &'self FlowContext { } } -impl<'self> MutableFlowUtils for &'self mut FlowContext { +impl<'self> MutableFlowUtils for &'self mut Flow { /// Traverses the tree in preorder. fn traverse_preorder<T:PreorderFlowTraversal>(self, traversal: &mut T) -> bool { if traversal.should_prune(self) { @@ -480,17 +480,17 @@ impl<'self> MutableFlowUtils for &'self mut FlowContext { } /// Adds a new flow as a child of this flow. - fn add_new_child(self, new_child: ~FlowContext:) { + fn add_new_child(self, new_child: ~Flow:) { mut_base(self).children.push_back(new_child) } /// Invokes a closure with the first child of this flow. - fn with_first_child<R>(self, f: &fn(Option<&mut ~FlowContext:>) -> R) -> R { + fn with_first_child<R>(self, f: &fn(Option<&mut ~Flow:>) -> R) -> R { f(mut_base(self).children.front_mut()) } /// Invokes a closure with the last child of this flow. - fn with_last_child<R>(self, f: &fn(Option<&mut ~FlowContext:>) -> R) -> R { + fn with_last_child<R>(self, f: &fn(Option<&mut ~Flow:>) -> R) -> R { f(mut_base(self).children.back_mut()) } @@ -521,7 +521,7 @@ impl<'self> MutableFlowUtils for &'self mut FlowContext { dirty: &Rect<Au>, list: &Cell<DisplayList<E>>) -> bool { - debug!("FlowContext: building display list for f{}", base(self).id); + debug!("Flow: building display list for f{}", base(self).id); match self.class() { BlockFlowClass => self.as_block().build_display_list_block(builder, dirty, list), InlineFlowClass => self.as_inline().build_display_list_inline(builder, dirty, list), diff --git a/src/components/main/layout/inline.rs b/src/components/main/layout/inline.rs index 2a0c412fb32..a904f15707c 100644 --- a/src/components/main/layout/inline.rs +++ b/src/components/main/layout/inline.rs @@ -7,7 +7,7 @@ use layout::box::{CannotSplit, GenericRenderBoxClass, ImageRenderBoxClass, Rende use layout::box::{RenderBoxUtils, SplitDidFit, SplitDidNotFit, TextRenderBoxClass}; use layout::context::LayoutContext; use layout::display_list_builder::{DisplayListBuilder, ExtraDisplayListData}; -use layout::flow::{FlowClass, FlowContext, FlowData, InlineFlowClass}; +use layout::flow::{FlowClass, Flow, FlowData, InlineFlowClass}; use layout::flow; use layout::float_context::FloatContext; use layout::util::{ElementMapping}; @@ -501,7 +501,7 @@ impl InlineFlow { // TODO(#228): Once we form line boxes and have their cached bounds, we can be smarter and // not recurse on a line if nothing in it can intersect the dirty region. - debug!("FlowContext[{:d}]: building display list for {:u} inline boxes", + debug!("Flow[{:d}]: building display list for {:u} inline boxes", self.base.id, self.boxes.len()); @@ -517,7 +517,7 @@ impl InlineFlow { } } -impl FlowContext for InlineFlow { +impl Flow for InlineFlow { fn class(&self) -> FlowClass { InlineFlowClass } @@ -543,7 +543,7 @@ impl FlowContext for InlineFlow { let mut pref_width = Au::new(0); for box in self.boxes.iter() { - debug!("FlowContext[{:d}]: measuring {:s}", self.base.id, box.debug_str()); + debug!("Flow[{:d}]: measuring {:s}", self.base.id, box.debug_str()); let (this_minimum_width, this_preferred_width) = box.minimum_and_preferred_widths(); min_width = Au::max(min_width, this_minimum_width); diff --git a/src/components/main/layout/layout_task.rs b/src/components/main/layout/layout_task.rs index edd7c8475da..a0149bb00eb 100644 --- a/src/components/main/layout/layout_task.rs +++ b/src/components/main/layout/layout_task.rs @@ -12,7 +12,7 @@ use layout::construct::{FlowConstructionResult, FlowConstructor, NoConstructionR use layout::context::LayoutContext; use layout::display_list_builder::{DisplayListBuilder, ToGfxColor}; use layout::extra::LayoutAuxMethods; -use layout::flow::{FlowContext, ImmutableFlowUtils, MutableFlowUtils, PreorderFlowTraversal}; +use layout::flow::{Flow, ImmutableFlowUtils, MutableFlowUtils, PreorderFlowTraversal}; use layout::flow::{PostorderFlowTraversal}; use layout::flow; use layout::incremental::{RestyleDamage, BubbleWidths}; @@ -98,7 +98,7 @@ struct ComputeDamageTraversal; impl PostorderFlowTraversal for ComputeDamageTraversal { #[inline] - fn process(&mut self, flow: &mut FlowContext) -> bool { + fn process(&mut self, flow: &mut Flow) -> bool { let mut damage = flow::base(flow).restyle_damage; for child in flow::child_iter(flow) { damage.union_in_place(flow::base(*child).restyle_damage) @@ -117,7 +117,7 @@ struct PropagateDamageTraversal { impl PreorderFlowTraversal for PropagateDamageTraversal { #[inline] - fn process(&mut self, flow: &mut FlowContext) -> bool { + fn process(&mut self, flow: &mut Flow) -> bool { // Also set any damage implied by resize. if self.resized { flow::mut_base(flow).restyle_damage.union_in_place(RestyleDamage::for_resize()) @@ -139,13 +139,13 @@ struct BubbleWidthsTraversal<'self>(&'self mut LayoutContext); impl<'self> PostorderFlowTraversal for BubbleWidthsTraversal<'self> { #[inline] - fn process(&mut self, flow: &mut FlowContext) -> bool { + fn process(&mut self, flow: &mut Flow) -> bool { flow.bubble_widths(**self); true } #[inline] - fn should_prune(&mut self, flow: &mut FlowContext) -> bool { + fn should_prune(&mut self, flow: &mut Flow) -> bool { flow::mut_base(flow).restyle_damage.lacks(BubbleWidths) } } @@ -155,7 +155,7 @@ struct AssignWidthsTraversal<'self>(&'self mut LayoutContext); impl<'self> PreorderFlowTraversal for AssignWidthsTraversal<'self> { #[inline] - fn process(&mut self, flow: &mut FlowContext) -> bool { + fn process(&mut self, flow: &mut Flow) -> bool { flow.assign_widths(**self); true } @@ -168,14 +168,14 @@ struct AssignHeightsAndStoreOverflowTraversal<'self>(&'self mut LayoutContext); impl<'self> PostorderFlowTraversal for AssignHeightsAndStoreOverflowTraversal<'self> { #[inline] - fn process(&mut self, flow: &mut FlowContext) -> bool { + fn process(&mut self, flow: &mut Flow) -> bool { flow.assign_height(**self); flow.store_overflow(**self); true } #[inline] - fn should_process(&mut self, flow: &mut FlowContext) -> bool { + fn should_process(&mut self, flow: &mut Flow) -> bool { !flow::base(flow).is_inorder } } @@ -346,7 +346,7 @@ impl LayoutTask { /// marked `#[inline(never)]` to aid benchmarking in sampling profilers. #[inline(never)] fn construct_flow_tree(&self, layout_context: &LayoutContext, node: AbstractNode<LayoutView>) - -> ~FlowContext: { + -> ~Flow: { node.traverse_postorder(&FlowConstructor::init(layout_context)); let result = match *node.mutate_layout_data().ptr { @@ -369,7 +369,7 @@ impl LayoutTask { /// benchmarked against those two. It is marked `#[inline(never)]` to aid profiling. #[inline(never)] fn solve_constraints(&mut self, - layout_root: &mut FlowContext, + layout_root: &mut Flow, layout_context: &mut LayoutContext) { let _ = layout_root.traverse_postorder(&mut BubbleWidthsTraversal(layout_context)); diff --git a/src/components/main/layout/text.rs b/src/components/main/layout/text.rs index e18538fe44f..c5f56a10ef9 100644 --- a/src/components/main/layout/text.rs +++ b/src/components/main/layout/text.rs @@ -10,7 +10,7 @@ use gfx::text::text_run::TextRun; use gfx::text::util::{CompressWhitespaceNewline, transform_text}; use layout::box::{RenderBox, RenderBoxUtils, TextRenderBox, UnscannedTextRenderBoxClass}; use layout::context::LayoutContext; -use layout::flow::FlowContext; +use layout::flow::Flow; use servo_util::range::Range; /// A stack-allocated object for scanning an inline flow into `TextRun`-containing `TextBox`es. @@ -25,7 +25,7 @@ impl TextRunScanner { } } - pub fn scan_for_runs(&mut self, ctx: &LayoutContext, flow: &mut FlowContext) { + pub fn scan_for_runs(&mut self, ctx: &LayoutContext, flow: &mut Flow) { { let inline = flow.as_immutable_inline(); // FIXME: this assertion fails on wikipedia, but doesn't seem @@ -83,7 +83,7 @@ impl TextRunScanner { /// necessary. pub fn flush_clump_to_list(&mut self, ctx: &LayoutContext, - flow: &mut FlowContext, + flow: &mut Flow, last_whitespace: bool, out_boxes: &mut ~[@RenderBox]) -> bool { |