mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
layout: Eliminate the virtual is_float()
in favor of the flow flags
This commit is contained in:
parent
f5c6146de0
commit
be36fcd3b1
4 changed files with 20 additions and 26 deletions
|
@ -639,7 +639,7 @@ impl BlockFlow {
|
|||
} else {
|
||||
AbsoluteNonReplacedType
|
||||
}
|
||||
} else if self.is_float() {
|
||||
} else if self.base.flags.is_float() {
|
||||
if self.is_replaced_content() {
|
||||
FloatReplacedType
|
||||
} else {
|
||||
|
@ -877,7 +877,7 @@ impl BlockFlow {
|
|||
// Assign block-size now for the child if it was impacted by floats and we couldn't
|
||||
// before.
|
||||
flow::mut_base(kid).floats = floats.clone();
|
||||
if kid.is_float() {
|
||||
if flow::base(kid).flags.is_float() {
|
||||
flow::mut_base(kid).position.start.b = cur_b;
|
||||
{
|
||||
let kid_block = kid.as_block();
|
||||
|
@ -1225,7 +1225,7 @@ impl BlockFlow {
|
|||
pub fn propagate_and_compute_used_inline_size(&mut self, layout_context: &LayoutContext) {
|
||||
let containing_block_inline_size = self.base.block_container_inline_size;
|
||||
self.compute_used_inline_size(layout_context, containing_block_inline_size);
|
||||
if self.is_float() {
|
||||
if self.base.flags.is_float() {
|
||||
self.float.as_mut().unwrap().containing_inline_size = containing_block_inline_size;
|
||||
}
|
||||
}
|
||||
|
@ -1547,7 +1547,7 @@ impl Flow for BlockFlow {
|
|||
}
|
||||
|
||||
debug!("assign_inline_sizes({}): assigning inline_size for flow",
|
||||
if self.is_float() {
|
||||
if self.base.flags.is_float() {
|
||||
"float"
|
||||
} else {
|
||||
"block"
|
||||
|
@ -1612,7 +1612,7 @@ impl Flow for BlockFlow {
|
|||
fn assign_block_size_for_inorder_child_if_necessary<'a>(&mut self,
|
||||
layout_context: &'a LayoutContext<'a>)
|
||||
-> bool {
|
||||
if self.is_float() {
|
||||
if self.base.flags.is_float() {
|
||||
self.place_float();
|
||||
return true
|
||||
}
|
||||
|
@ -1655,7 +1655,7 @@ impl Flow for BlockFlow {
|
|||
if !self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) {
|
||||
self.base.position.size.block = self.fragment.border_box.size.block;
|
||||
}
|
||||
} else if self.is_root() || self.is_float() || self.is_inline_block() {
|
||||
} else if self.is_root() || self.base.flags.is_float() || self.is_inline_block() {
|
||||
// Root element margins should never be collapsed according to CSS § 8.3.1.
|
||||
debug!("assign_block_size: assigning block_size for root flow");
|
||||
self.assign_block_size_block_base(ctx, MarginsMayNotCollapse);
|
||||
|
@ -1772,10 +1772,6 @@ impl Flow for BlockFlow {
|
|||
self.flags.contains(IS_ROOT)
|
||||
}
|
||||
|
||||
fn is_float(&self) -> bool {
|
||||
self.float.is_some()
|
||||
}
|
||||
|
||||
/// The 'position' property of this flow.
|
||||
fn positioning(&self) -> position::T {
|
||||
self.fragment.style.get_box().position
|
||||
|
@ -1822,7 +1818,7 @@ impl Flow for BlockFlow {
|
|||
}
|
||||
|
||||
fn build_display_list(&mut self, layout_context: &LayoutContext) {
|
||||
if self.is_float() {
|
||||
if self.base.flags.is_float() {
|
||||
// TODO(#2009, pcwalton): This is a pseudo-stacking context. We need to merge `z-index:
|
||||
// auto` kids into the parent stacking context, when that is supported.
|
||||
self.build_display_list_for_floating_block(layout_context)
|
||||
|
|
|
@ -241,10 +241,6 @@ pub trait Flow: fmt::Show + ToString + Sync {
|
|||
false
|
||||
}
|
||||
|
||||
fn is_float(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
/// The 'position' property of this flow.
|
||||
fn positioning(&self) -> position::T {
|
||||
position::static_
|
||||
|
@ -570,6 +566,11 @@ impl FlowFlags {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_float(&self) -> bool {
|
||||
self.floats_left() || self.floats_right()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn clears_floats(&self) -> bool {
|
||||
self.contains(CLEARS_LEFT) || self.contains(CLEARS_RIGHT)
|
||||
|
|
|
@ -1116,7 +1116,8 @@ impl Flow for InlineFlow {
|
|||
|
||||
// Assign block sizes for any inline-block descendants.
|
||||
for kid in self.base.child_iter() {
|
||||
if flow::base(kid).flags.contains(IS_ABSOLUTELY_POSITIONED) || kid.is_float() {
|
||||
if flow::base(kid).flags.contains(IS_ABSOLUTELY_POSITIONED) ||
|
||||
flow::base(kid).flags.is_float() {
|
||||
continue
|
||||
}
|
||||
kid.assign_block_size_for_inorder_child_if_necessary(layout_context);
|
||||
|
|
|
@ -191,7 +191,7 @@ impl TableWrapperFlow {
|
|||
layout_context: &LayoutContext,
|
||||
parent_flow_inline_size: Au) {
|
||||
// Delegate to the appropriate inline size computer to find the constraint inputs.
|
||||
let input = if self.is_float() {
|
||||
let input = if self.block_flow.base.flags.is_float() {
|
||||
FloatNonReplaced.compute_inline_size_constraint_inputs(&mut self.block_flow,
|
||||
parent_flow_inline_size,
|
||||
layout_context)
|
||||
|
@ -202,7 +202,7 @@ impl TableWrapperFlow {
|
|||
};
|
||||
|
||||
// Delegate to the appropriate inline size computer to write the constraint solutions in.
|
||||
if self.is_float() {
|
||||
if self.block_flow.base.flags.is_float() {
|
||||
let solution = FloatNonReplaced.solve_inline_size_constraints(&mut self.block_flow,
|
||||
&input);
|
||||
FloatNonReplaced.set_inline_size_constraint_solutions(&mut self.block_flow, solution);
|
||||
|
@ -221,10 +221,6 @@ impl Flow for TableWrapperFlow {
|
|||
TableWrapperFlowClass
|
||||
}
|
||||
|
||||
fn is_float(&self) -> bool {
|
||||
self.block_flow.is_float()
|
||||
}
|
||||
|
||||
fn as_table_wrapper<'a>(&'a mut self) -> &'a mut TableWrapperFlow {
|
||||
self
|
||||
}
|
||||
|
@ -251,7 +247,7 @@ impl Flow for TableWrapperFlow {
|
|||
|
||||
fn assign_inline_sizes(&mut self, layout_context: &LayoutContext) {
|
||||
debug!("assign_inline_sizes({}): assigning inline_size for flow",
|
||||
if self.is_float() {
|
||||
if self.block_flow.base.flags.is_float() {
|
||||
"floated table_wrapper"
|
||||
} else {
|
||||
"table_wrapper"
|
||||
|
@ -267,7 +263,7 @@ impl Flow for TableWrapperFlow {
|
|||
// Our inline-size was set to the inline-size of the containing block by the flow's parent.
|
||||
// Now compute the real value.
|
||||
let containing_block_inline_size = self.block_flow.base.block_container_inline_size;
|
||||
if self.is_float() {
|
||||
if self.block_flow.base.flags.is_float() {
|
||||
self.block_flow.float.as_mut().unwrap().containing_inline_size =
|
||||
containing_block_inline_size;
|
||||
}
|
||||
|
@ -308,7 +304,7 @@ impl Flow for TableWrapperFlow {
|
|||
fn assign_block_size_for_inorder_child_if_necessary<'a>(&mut self,
|
||||
layout_context: &'a LayoutContext<'a>)
|
||||
-> bool {
|
||||
if self.block_flow.is_float() {
|
||||
if self.block_flow.base.flags.is_float() {
|
||||
self.block_flow.place_float();
|
||||
return true
|
||||
}
|
||||
|
@ -343,7 +339,7 @@ impl Flow for TableWrapperFlow {
|
|||
|
||||
impl fmt::Show for TableWrapperFlow {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
if self.is_float() {
|
||||
if self.block_flow.base.flags.is_float() {
|
||||
write!(f, "TableWrapperFlow(Float): {}", self.block_flow.fragment)
|
||||
} else {
|
||||
write!(f, "TableWrapperFlow: {}", self.block_flow.fragment)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue