2
2
* License, v. 2.0. If a copy of the MPL was not distributed with this
3
3
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
4
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
6
6
/// solves layout constraints to obtain positions and display attributes of tree nodes. Positions
7
7
/// are computed in several tree traversals driven by the fundamental data dependencies required by
8
8
/// inline and block layout.
@@ -50,7 +50,7 @@ use std::cell::Cell;
50
50
///
51
51
/// Note that virtual methods have a cost; we should not overuse them in Servo. Consider adding
52
52
/// methods to `ImmutableFlowUtils` or `MutableFlowUtils` before adding more methods here.
53
- pub trait FlowContext {
53
+ pub trait Flow {
54
54
// RTTI
55
55
//
56
56
// TODO(pcwalton): Use Rust's RTTI, once that works.
@@ -124,33 +124,33 @@ pub trait FlowContext {
124
124
// Base access
125
125
126
126
#[ inline ( always ) ]
127
- pub fn base < ' a > ( this : & ' a FlowContext ) -> & ' a FlowData {
127
+ pub fn base < ' a > ( this : & ' a Flow ) -> & ' a FlowData {
128
128
unsafe {
129
129
let ( _, ptr) : ( uint , & FlowData ) = cast:: transmute ( this) ;
130
130
ptr
131
131
}
132
132
}
133
133
134
134
/// 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 : > {
136
136
base ( flow) . children . iter ( )
137
137
}
138
138
139
139
#[ 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 {
141
141
unsafe {
142
142
let ( _, ptr) : ( uint , & mut FlowData ) = cast:: transmute ( this) ;
143
143
ptr
144
144
}
145
145
}
146
146
147
147
/// 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 : > {
149
149
mut_base ( flow) . children . back_mut ( )
150
150
}
151
151
152
152
/// 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 : > {
154
154
mut_base ( flow) . children . mut_iter ( )
155
155
}
156
156
@@ -188,13 +188,13 @@ pub trait MutableFlowUtils {
188
188
// Mutators
189
189
190
190
/// 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 : ) ;
192
192
193
193
/// 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 ;
195
195
196
196
/// 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 ;
198
198
199
199
/// Removes the first child of this flow and destroys it.
200
200
fn remove_first ( self ) ;
@@ -237,7 +237,7 @@ impl AbsoluteFlow {
237
237
}
238
238
}
239
239
240
- impl FlowContext for AbsoluteFlow {
240
+ impl Flow for AbsoluteFlow {
241
241
fn class ( & self ) -> FlowClass {
242
242
AbsoluteFlowClass
243
243
}
@@ -255,7 +255,7 @@ impl InlineBlockFlow {
255
255
}
256
256
}
257
257
258
- impl FlowContext for InlineBlockFlow {
258
+ impl Flow for InlineBlockFlow {
259
259
fn class ( & self ) -> FlowClass {
260
260
InlineBlockFlowClass
261
261
}
@@ -273,7 +273,7 @@ impl TableFlow {
273
273
}
274
274
}
275
275
276
- impl FlowContext for TableFlow {
276
+ impl Flow for TableFlow {
277
277
fn class ( & self ) -> FlowClass {
278
278
TableFlowClass
279
279
}
@@ -282,32 +282,32 @@ impl FlowContext for TableFlow {
282
282
/// A top-down traversal.
283
283
pub trait PreorderFlowTraversal {
284
284
/// 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 ;
286
286
287
287
/// Returns true if this node should be pruned. If this returns true, we skip the operation
288
288
/// entirely and do not process any descendant nodes. This is called *before* child nodes are
289
289
/// 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 {
291
291
false
292
292
}
293
293
}
294
294
295
295
/// A bottom-up traversal, with a optional in-order pass.
296
296
pub trait PostorderFlowTraversal {
297
297
/// 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 ;
299
299
300
300
/// Returns false if this node must be processed in-order. If this returns false, we skip the
301
301
/// operation for this node, but continue processing the descendants. This is called *after*
302
302
/// child nodes are visited.
303
- fn should_process ( & mut self , _flow : & mut FlowContext ) -> bool {
303
+ fn should_process ( & mut self , _flow : & mut Flow ) -> bool {
304
304
true
305
305
}
306
306
307
307
/// Returns true if this node should be pruned. If this returns true, we skip the operation
308
308
/// entirely and do not process any descendant nodes. This is called *before* child nodes are
309
309
/// 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 {
311
311
false
312
312
}
313
313
}
@@ -320,7 +320,7 @@ pub struct FlowData {
320
320
node : AbstractNode < LayoutView > ,
321
321
restyle_damage : RestyleDamage ,
322
322
323
- children : DList < ~FlowContext : > ,
323
+ children : DList < ~Flow : > ,
324
324
325
325
/* TODO (Issue #87): debug only */
326
326
id : int ,
@@ -386,12 +386,12 @@ impl FlowData {
386
386
}
387
387
}
388
388
389
- pub fn child_iter< ' a > ( & ' a mut self ) -> MutDListIterator <' a , ~FlowContext : > {
389
+ pub fn child_iter< ' a > ( & ' a mut self ) -> MutDListIterator <' a , ~Flow : > {
390
390
self . children . mut_iter ( )
391
391
}
392
392
}
393
393
394
- impl <' self > ImmutableFlowUtils for & ' self FlowContext {
394
+ impl <' self > ImmutableFlowUtils for & ' self Flow {
395
395
/// Returns true if this flow is a block or a float flow.
396
396
fn is_block_like ( self ) -> bool {
397
397
match self . class ( ) {
@@ -440,7 +440,7 @@ impl<'self> ImmutableFlowUtils for &'self FlowContext {
440
440
}
441
441
}
442
442
443
- impl < ' self > MutableFlowUtils for & ' self mut FlowContext {
443
+ impl < ' self > MutableFlowUtils for & ' self mut Flow {
444
444
/// Traverses the tree in preorder.
445
445
fn traverse_preorder < T : PreorderFlowTraversal > ( self , traversal : & mut T ) -> bool {
446
446
if traversal. should_prune ( self ) {
@@ -480,17 +480,17 @@ impl<'self> MutableFlowUtils for &'self mut FlowContext {
480
480
}
481
481
482
482
/// 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 : ) {
484
484
mut_base ( self ) . children . push_back ( new_child)
485
485
}
486
486
487
487
/// 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 {
489
489
f ( mut_base ( self ) . children . front_mut ( ) )
490
490
}
491
491
492
492
/// 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 {
494
494
f ( mut_base ( self ) . children . back_mut ( ) )
495
495
}
496
496
@@ -521,7 +521,7 @@ impl<'self> MutableFlowUtils for &'self mut FlowContext {
521
521
dirty : & Rect < Au > ,
522
522
list : & Cell < DisplayList < E > > )
523
523
-> bool {
524
- debug ! ( "FlowContext : building display list for f{}" , base( self ) . id) ;
524
+ debug ! ( "Flow : building display list for f{}" , base( self ) . id) ;
525
525
match self . class ( ) {
526
526
BlockFlowClass => self . as_block ( ) . build_display_list_block ( builder, dirty, list) ,
527
527
InlineFlowClass => self . as_inline ( ) . build_display_list_inline ( builder, dirty, list) ,
0 commit comments