Skip to content

Commit a0c6075

Browse files
author
bors-servo
committed
auto merge of servo#1326 : brunoabinader/servo/rename-flowcontext, r=pcwalton
This patch is for: servo#1282
2 parents b564573 + bf277e6 commit a0c6075

File tree

7 files changed

+59
-59
lines changed

7 files changed

+59
-59
lines changed

src/components/main/layout/block.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use layout::box::{RenderBox, RenderBoxUtils};
88
use layout::context::LayoutContext;
99
use layout::display_list_builder::{DisplayListBuilder, ExtraDisplayListData};
10-
use layout::flow::{BlockFlowClass, FlowClass, FlowContext, FlowData, ImmutableFlowUtils};
10+
use layout::flow::{BlockFlowClass, FlowClass, Flow, FlowData, ImmutableFlowUtils};
1111
use layout::flow;
1212
use layout::model::{MaybeAuto, Specified, Auto, specified_or_none, specified};
1313
use layout::float_context::{FloatContext, Invalid};
@@ -304,7 +304,7 @@ impl BlockFlow {
304304
}
305305
}
306306

307-
impl FlowContext for BlockFlow {
307+
impl Flow for BlockFlow {
308308
fn class(&self) -> FlowClass {
309309
BlockFlowClass
310310
}

src/components/main/layout/construct.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use layout::box::{UnscannedTextRenderBox};
2727
use layout::context::LayoutContext;
2828
use layout::float::FloatFlow;
2929
use layout::float_context::FloatType;
30-
use layout::flow::{FlowContext, FlowData, MutableFlowUtils};
30+
use layout::flow::{Flow, FlowData, MutableFlowUtils};
3131
use layout::inline::InlineFlow;
3232
use layout::text::TextRunScanner;
3333
use layout::util::LayoutDataAccess;
@@ -49,15 +49,15 @@ pub enum ConstructionResult {
4949

5050
/// This node contributed a flow at the proper position in the tree. Nothing more needs to be
5151
/// done for this node.
52-
FlowConstructionResult(~FlowContext:),
52+
FlowConstructionResult(~Flow:),
5353

5454
/// This node contributed some object or objects that will be needed to construct a proper flow
5555
/// later up the tree, but these objects have not yet found their home.
5656
ConstructionItemConstructionResult(ConstructionItem),
5757
}
5858

5959
/// Represents the output of flow construction for a DOM node that has not yet resulted in a
60-
/// complete flow. Construction items bubble up the tree until they find a `FlowContext` to be
60+
/// complete flow. Construction items bubble up the tree until they find a `Flow` to be
6161
/// attached to.
6262
enum ConstructionItem {
6363
/// Inline boxes and associated {ib} splits that have not yet found flows.
@@ -104,7 +104,7 @@ struct InlineBlockSplit {
104104
predecessor_boxes: ~[@RenderBox],
105105

106106
/// The flow that caused this {ib} split.
107-
flow: ~FlowContext:,
107+
flow: ~Flow:,
108108
}
109109

110110
/// Methods on optional vectors.
@@ -247,11 +247,11 @@ impl<'self> FlowConstructor<'self> {
247247
#[inline(always)]
248248
fn flush_inline_boxes_to_flow(&self,
249249
boxes: ~[@RenderBox],
250-
flow: &mut ~FlowContext:,
250+
flow: &mut ~Flow:,
251251
node: AbstractNode<LayoutView>) {
252252
if boxes.len() > 0 {
253253
let inline_base = FlowData::new(self.next_flow_id(), node);
254-
let mut inline_flow = ~InlineFlow::from_boxes(inline_base, boxes) as ~FlowContext:;
254+
let mut inline_flow = ~InlineFlow::from_boxes(inline_base, boxes) as ~Flow:;
255255
TextRunScanner::new().scan_for_runs(self.layout_context, inline_flow);
256256
flow.add_new_child(inline_flow)
257257
}
@@ -261,7 +261,7 @@ impl<'self> FlowConstructor<'self> {
261261
/// the given flow.
262262
fn flush_inline_boxes_to_flow_if_necessary(&self,
263263
opt_boxes: &mut Option<~[@RenderBox]>,
264-
flow: &mut ~FlowContext:,
264+
flow: &mut ~Flow:,
265265
node: AbstractNode<LayoutView>) {
266266
let opt_boxes = util::replace(opt_boxes, None);
267267
if opt_boxes.len() > 0 {
@@ -273,7 +273,7 @@ impl<'self> FlowConstructor<'self> {
273273
/// other `BlockFlow`s or `InlineFlow`s will be populated underneath this node, depending on
274274
/// whether {ib} splits needed to happen.
275275
fn build_children_of_block_flow(&self,
276-
flow: &mut ~FlowContext:,
276+
flow: &mut ~Flow:,
277277
node: AbstractNode<LayoutView>) {
278278
// Gather up boxes for the inline flows we might need to create.
279279
let mut opt_boxes_for_inline_flow = None;
@@ -352,21 +352,21 @@ impl<'self> FlowConstructor<'self> {
352352
/// Builds a flow for a node with `display: block`. This yields a `BlockFlow` with possibly
353353
/// other `BlockFlow`s or `InlineFlow`s underneath it, depending on whether {ib} splits needed
354354
/// to happen.
355-
fn build_flow_for_block(&self, node: AbstractNode<LayoutView>) -> ~FlowContext: {
355+
fn build_flow_for_block(&self, node: AbstractNode<LayoutView>) -> ~Flow: {
356356
let base = FlowData::new(self.next_flow_id(), node);
357357
let box = self.build_box_for_node(node);
358-
let mut flow = ~BlockFlow::from_box(base, box) as ~FlowContext:;
358+
let mut flow = ~BlockFlow::from_box(base, box) as ~Flow:;
359359
self.build_children_of_block_flow(&mut flow, node);
360360
flow
361361
}
362362

363363
/// Builds the flow for a node with `float: {left|right}`. This yields a `FloatFlow` with a
364364
/// `BlockFlow` underneath it.
365365
fn build_flow_for_floated_block(&self, node: AbstractNode<LayoutView>, float_type: FloatType)
366-
-> ~FlowContext: {
366+
-> ~Flow: {
367367
let base = FlowData::new(self.next_flow_id(), node);
368368
let box = self.build_box_for_node(node);
369-
let mut flow = ~FloatFlow::from_box(base, float_type, box) as ~FlowContext:;
369+
let mut flow = ~FloatFlow::from_box(base, float_type, box) as ~Flow:;
370370
self.build_children_of_block_flow(&mut flow, node);
371371
flow
372372
}

src/components/main/layout/float.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use layout::box::{RenderBox, RenderBoxUtils};
66
use layout::context::LayoutContext;
77
use layout::display_list_builder::{DisplayListBuilder, ExtraDisplayListData};
8-
use layout::flow::{FloatFlowClass, FlowClass, FlowContext, FlowData};
8+
use layout::flow::{FloatFlowClass, FlowClass, Flow, FlowData};
99
use layout::flow;
1010
use layout::model::{MaybeAuto};
1111
use layout::float_context::{FloatContext, PlacementInfo, FloatType};
@@ -111,7 +111,7 @@ impl FloatFlow {
111111
}
112112
}
113113

114-
impl FlowContext for FloatFlow {
114+
impl Flow for FloatFlow {
115115
fn class(&self) -> FlowClass {
116116
FloatFlowClass
117117
}

src/components/main/layout/flow.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
//! Servo's experimental layout system builds a tree of `FlowContext` and `RenderBox` objects and
5+
//! Servo's experimental layout system builds a tree of `Flow` and `RenderBox` objects and
66
/// solves layout constraints to obtain positions and display attributes of tree nodes. Positions
77
/// are computed in several tree traversals driven by the fundamental data dependencies required by
88
/// inline and block layout.
@@ -50,7 +50,7 @@ use std::cell::Cell;
5050
///
5151
/// Note that virtual methods have a cost; we should not overuse them in Servo. Consider adding
5252
/// methods to `ImmutableFlowUtils` or `MutableFlowUtils` before adding more methods here.
53-
pub trait FlowContext {
53+
pub trait Flow {
5454
// RTTI
5555
//
5656
// TODO(pcwalton): Use Rust's RTTI, once that works.
@@ -124,33 +124,33 @@ pub trait FlowContext {
124124
// Base access
125125

126126
#[inline(always)]
127-
pub fn base<'a>(this: &'a FlowContext) -> &'a FlowData {
127+
pub fn base<'a>(this: &'a Flow) -> &'a FlowData {
128128
unsafe {
129129
let (_, ptr): (uint, &FlowData) = cast::transmute(this);
130130
ptr
131131
}
132132
}
133133

134134
/// Iterates over the children of this immutable flow.
135-
pub fn imm_child_iter<'a>(flow: &'a FlowContext) -> DListIterator<'a,~FlowContext:> {
135+
pub fn imm_child_iter<'a>(flow: &'a Flow) -> DListIterator<'a,~Flow:> {
136136
base(flow).children.iter()
137137
}
138138

139139
#[inline(always)]
140-
pub fn mut_base<'a>(this: &'a mut FlowContext) -> &'a mut FlowData {
140+
pub fn mut_base<'a>(this: &'a mut Flow) -> &'a mut FlowData {
141141
unsafe {
142142
let (_, ptr): (uint, &mut FlowData) = cast::transmute(this);
143143
ptr
144144
}
145145
}
146146

147147
/// Returns the last child of this flow.
148-
pub fn last_child<'a>(flow: &'a mut FlowContext) -> Option<&'a mut ~FlowContext:> {
148+
pub fn last_child<'a>(flow: &'a mut Flow) -> Option<&'a mut ~Flow:> {
149149
mut_base(flow).children.back_mut()
150150
}
151151

152152
/// Iterates over the children of this flow.
153-
pub fn child_iter<'a>(flow: &'a mut FlowContext) -> MutDListIterator<'a,~FlowContext:> {
153+
pub fn child_iter<'a>(flow: &'a mut Flow) -> MutDListIterator<'a,~Flow:> {
154154
mut_base(flow).children.mut_iter()
155155
}
156156

@@ -188,13 +188,13 @@ pub trait MutableFlowUtils {
188188
// Mutators
189189

190190
/// Adds a new flow as a child of this flow.
191-
fn add_new_child(self, new_child: ~FlowContext:);
191+
fn add_new_child(self, new_child: ~Flow:);
192192

193193
/// Invokes a closure with the first child of this flow.
194-
fn with_first_child<R>(self, f: &fn(Option<&mut ~FlowContext:>) -> R) -> R;
194+
fn with_first_child<R>(self, f: &fn(Option<&mut ~Flow:>) -> R) -> R;
195195

196196
/// Invokes a closure with the last child of this flow.
197-
fn with_last_child<R>(self, f: &fn(Option<&mut ~FlowContext:>) -> R) -> R;
197+
fn with_last_child<R>(self, f: &fn(Option<&mut ~Flow:>) -> R) -> R;
198198

199199
/// Removes the first child of this flow and destroys it.
200200
fn remove_first(self);
@@ -237,7 +237,7 @@ impl AbsoluteFlow {
237237
}
238238
}
239239

240-
impl FlowContext for AbsoluteFlow {
240+
impl Flow for AbsoluteFlow {
241241
fn class(&self) -> FlowClass {
242242
AbsoluteFlowClass
243243
}
@@ -255,7 +255,7 @@ impl InlineBlockFlow {
255255
}
256256
}
257257

258-
impl FlowContext for InlineBlockFlow {
258+
impl Flow for InlineBlockFlow {
259259
fn class(&self) -> FlowClass {
260260
InlineBlockFlowClass
261261
}
@@ -273,7 +273,7 @@ impl TableFlow {
273273
}
274274
}
275275

276-
impl FlowContext for TableFlow {
276+
impl Flow for TableFlow {
277277
fn class(&self) -> FlowClass {
278278
TableFlowClass
279279
}
@@ -282,32 +282,32 @@ impl FlowContext for TableFlow {
282282
/// A top-down traversal.
283283
pub trait PreorderFlowTraversal {
284284
/// The operation to perform. Return true to continue or false to stop.
285-
fn process(&mut self, flow: &mut FlowContext) -> bool;
285+
fn process(&mut self, flow: &mut Flow) -> bool;
286286

287287
/// Returns true if this node should be pruned. If this returns true, we skip the operation
288288
/// entirely and do not process any descendant nodes. This is called *before* child nodes are
289289
/// visited. The default implementation never prunes any nodes.
290-
fn should_prune(&mut self, _flow: &mut FlowContext) -> bool {
290+
fn should_prune(&mut self, _flow: &mut Flow) -> bool {
291291
false
292292
}
293293
}
294294

295295
/// A bottom-up traversal, with a optional in-order pass.
296296
pub trait PostorderFlowTraversal {
297297
/// The operation to perform. Return true to continue or false to stop.
298-
fn process(&mut self, flow: &mut FlowContext) -> bool;
298+
fn process(&mut self, flow: &mut Flow) -> bool;
299299

300300
/// Returns false if this node must be processed in-order. If this returns false, we skip the
301301
/// operation for this node, but continue processing the descendants. This is called *after*
302302
/// child nodes are visited.
303-
fn should_process(&mut self, _flow: &mut FlowContext) -> bool {
303+
fn should_process(&mut self, _flow: &mut Flow) -> bool {
304304
true
305305
}
306306

307307
/// Returns true if this node should be pruned. If this returns true, we skip the operation
308308
/// entirely and do not process any descendant nodes. This is called *before* child nodes are
309309
/// visited. The default implementation never prunes any nodes.
310-
fn should_prune(&mut self, _flow: &mut FlowContext) -> bool {
310+
fn should_prune(&mut self, _flow: &mut Flow) -> bool {
311311
false
312312
}
313313
}
@@ -320,7 +320,7 @@ pub struct FlowData {
320320
node: AbstractNode<LayoutView>,
321321
restyle_damage: RestyleDamage,
322322

323-
children: DList<~FlowContext:>,
323+
children: DList<~Flow:>,
324324

325325
/* TODO (Issue #87): debug only */
326326
id: int,
@@ -386,12 +386,12 @@ impl FlowData {
386386
}
387387
}
388388

389-
pub fn child_iter<'a>(&'a mut self) -> MutDListIterator<'a,~FlowContext:> {
389+
pub fn child_iter<'a>(&'a mut self) -> MutDListIterator<'a,~Flow:> {
390390
self.children.mut_iter()
391391
}
392392
}
393393

394-
impl<'self> ImmutableFlowUtils for &'self FlowContext {
394+
impl<'self> ImmutableFlowUtils for &'self Flow {
395395
/// Returns true if this flow is a block or a float flow.
396396
fn is_block_like(self) -> bool {
397397
match self.class() {
@@ -440,7 +440,7 @@ impl<'self> ImmutableFlowUtils for &'self FlowContext {
440440
}
441441
}
442442

443-
impl<'self> MutableFlowUtils for &'self mut FlowContext {
443+
impl<'self> MutableFlowUtils for &'self mut Flow {
444444
/// Traverses the tree in preorder.
445445
fn traverse_preorder<T:PreorderFlowTraversal>(self, traversal: &mut T) -> bool {
446446
if traversal.should_prune(self) {
@@ -480,17 +480,17 @@ impl<'self> MutableFlowUtils for &'self mut FlowContext {
480480
}
481481

482482
/// Adds a new flow as a child of this flow.
483-
fn add_new_child(self, new_child: ~FlowContext:) {
483+
fn add_new_child(self, new_child: ~Flow:) {
484484
mut_base(self).children.push_back(new_child)
485485
}
486486

487487
/// Invokes a closure with the first child of this flow.
488-
fn with_first_child<R>(self, f: &fn(Option<&mut ~FlowContext:>) -> R) -> R {
488+
fn with_first_child<R>(self, f: &fn(Option<&mut ~Flow:>) -> R) -> R {
489489
f(mut_base(self).children.front_mut())
490490
}
491491

492492
/// Invokes a closure with the last child of this flow.
493-
fn with_last_child<R>(self, f: &fn(Option<&mut ~FlowContext:>) -> R) -> R {
493+
fn with_last_child<R>(self, f: &fn(Option<&mut ~Flow:>) -> R) -> R {
494494
f(mut_base(self).children.back_mut())
495495
}
496496

@@ -521,7 +521,7 @@ impl<'self> MutableFlowUtils for &'self mut FlowContext {
521521
dirty: &Rect<Au>,
522522
list: &Cell<DisplayList<E>>)
523523
-> bool {
524-
debug!("FlowContext: building display list for f{}", base(self).id);
524+
debug!("Flow: building display list for f{}", base(self).id);
525525
match self.class() {
526526
BlockFlowClass => self.as_block().build_display_list_block(builder, dirty, list),
527527
InlineFlowClass => self.as_inline().build_display_list_inline(builder, dirty, list),

src/components/main/layout/inline.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use layout::box::{CannotSplit, GenericRenderBoxClass, ImageRenderBoxClass, Rende
77
use layout::box::{RenderBoxUtils, SplitDidFit, SplitDidNotFit, TextRenderBoxClass};
88
use layout::context::LayoutContext;
99
use layout::display_list_builder::{DisplayListBuilder, ExtraDisplayListData};
10-
use layout::flow::{FlowClass, FlowContext, FlowData, InlineFlowClass};
10+
use layout::flow::{FlowClass, Flow, FlowData, InlineFlowClass};
1111
use layout::flow;
1212
use layout::float_context::FloatContext;
1313
use layout::util::{ElementMapping};
@@ -501,7 +501,7 @@ impl InlineFlow {
501501

502502
// TODO(#228): Once we form line boxes and have their cached bounds, we can be smarter and
503503
// not recurse on a line if nothing in it can intersect the dirty region.
504-
debug!("FlowContext[{:d}]: building display list for {:u} inline boxes",
504+
debug!("Flow[{:d}]: building display list for {:u} inline boxes",
505505
self.base.id,
506506
self.boxes.len());
507507

@@ -517,7 +517,7 @@ impl InlineFlow {
517517
}
518518
}
519519

520-
impl FlowContext for InlineFlow {
520+
impl Flow for InlineFlow {
521521
fn class(&self) -> FlowClass {
522522
InlineFlowClass
523523
}
@@ -543,7 +543,7 @@ impl FlowContext for InlineFlow {
543543
let mut pref_width = Au::new(0);
544544

545545
for box in self.boxes.iter() {
546-
debug!("FlowContext[{:d}]: measuring {:s}", self.base.id, box.debug_str());
546+
debug!("Flow[{:d}]: measuring {:s}", self.base.id, box.debug_str());
547547
let (this_minimum_width, this_preferred_width) =
548548
box.minimum_and_preferred_widths();
549549
min_width = Au::max(min_width, this_minimum_width);

0 commit comments

Comments
 (0)