Skip to content

Commit

Permalink
servo: Merge #1326 - s/FlowContext/Flow (from brunoabinader:rename-fl…
Browse files Browse the repository at this point in the history
…owcontext); r=pcwalton

This patch is for:
servo/servo#1282

Source-Repo: https://github.com/servo/servo
Source-Revision: a0c6075b4d766da8f0414405f9e1f76c8c90acc4

UltraBlame original commit: c19897ea35f82925d59433fa208ad8c562ed53f6
  • Loading branch information
marco-c committed Sep 30, 2019
1 parent 5946832 commit e83312e
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 58 deletions.
4 changes: 2 additions & 2 deletions servo/src/components/main/layout/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -304,7 +304,7 @@ impl BlockFlow {
}
}

impl FlowContext for BlockFlow {
impl Flow for BlockFlow {
fn class(&self) -> FlowClass {
BlockFlowClass
}
Expand Down
24 changes: 12 additions & 12 deletions servo/src/components/main/layout/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -49,15 +49,15 @@ pub enum ConstructionResult {



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.
ConstructionItemConstructionResult(ConstructionItem),
}

/// 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.
Expand Down Expand Up @@ -104,7 +104,7 @@ struct InlineBlockSplit {
predecessor_boxes: ~[@RenderBox],

/// The flow that caused this {ib} split.
flow: ~FlowContext:,
flow: ~Flow:,
}

/// Methods on optional vectors.
Expand Down Expand Up @@ -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)
}
Expand All @@ -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 {
Expand All @@ -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;
Expand Down Expand Up @@ -352,21 +352,21 @@ 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
}

/// 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
}
Expand Down
4 changes: 2 additions & 2 deletions servo/src/components/main/layout/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -111,7 +111,7 @@ impl FloatFlow {
}
}

impl FlowContext for FloatFlow {
impl Flow for FloatFlow {
fn class(&self) -> FlowClass {
FloatFlowClass
}
Expand Down
50 changes: 25 additions & 25 deletions servo/src/components/main/layout/flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ use std::cell::Cell;



pub trait FlowContext {
pub trait Flow {



Expand Down Expand Up @@ -124,33 +124,33 @@ 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
}
}

/// 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
}
}

/// 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()
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -237,7 +237,7 @@ impl AbsoluteFlow {
}
}

impl FlowContext for AbsoluteFlow {
impl Flow for AbsoluteFlow {
fn class(&self) -> FlowClass {
AbsoluteFlowClass
}
Expand All @@ -255,7 +255,7 @@ impl InlineBlockFlow {
}
}

impl FlowContext for InlineBlockFlow {
impl Flow for InlineBlockFlow {
fn class(&self) -> FlowClass {
InlineBlockFlowClass
}
Expand All @@ -273,7 +273,7 @@ impl TableFlow {
}
}

impl FlowContext for TableFlow {
impl Flow for TableFlow {
fn class(&self) -> FlowClass {
TableFlowClass
}
Expand All @@ -282,32 +282,32 @@ 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
}
}

/// 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
}
}
Expand All @@ -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,
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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())
}

Expand Down Expand Up @@ -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),
Expand Down
8 changes: 4 additions & 4 deletions servo/src/components/main/layout/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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());

Expand All @@ -517,7 +517,7 @@ impl InlineFlow {
}
}

impl FlowContext for InlineFlow {
impl Flow for InlineFlow {
fn class(&self) -> FlowClass {
InlineFlowClass
}
Expand All @@ -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);
Expand Down
Loading

0 comments on commit e83312e

Please sign in to comment.