flow::Flow should follow *_mut naming conventions

Fixes #7148
This commit is contained in:
Corey Farwell 2015-08-12 14:39:27 -04:00
parent 3d0951cf25
commit 6aaada64dc
15 changed files with 128 additions and 138 deletions

View file

@ -451,7 +451,7 @@ impl<'a> PreorderFlowTraversal for AbsoluteAssignBSizesTraversal<'a> {
} }
} }
let block = flow.as_block(); let block = flow.as_mut_block();
debug_assert!(block.base.flags.contains(IS_ABSOLUTELY_POSITIONED)); debug_assert!(block.base.flags.contains(IS_ABSOLUTELY_POSITIONED));
if !block.base.restyle_damage.intersects(REFLOW_OUT_OF_FLOW | REFLOW) { if !block.base.restyle_damage.intersects(REFLOW_OUT_OF_FLOW | REFLOW) {
return return
@ -845,7 +845,7 @@ impl BlockFlow {
if flow::base(kid).flags.is_float() { if flow::base(kid).flags.is_float() {
flow::mut_base(kid).position.start.b = cur_b; flow::mut_base(kid).position.start.b = cur_b;
{ {
let kid_block = kid.as_block(); let kid_block = kid.as_mut_block();
kid_block.float.as_mut().unwrap().float_ceiling = kid_block.float.as_mut().unwrap().float_ceiling =
margin_collapse_info.current_float_ceiling(); margin_collapse_info.current_float_ceiling();
} }
@ -1384,7 +1384,7 @@ impl BlockFlow {
} }
if kid.is_block_flow() { if kid.is_block_flow() {
let kid_block = kid.as_block(); let kid_block = kid.as_mut_block();
kid_block.inline_size_of_preceding_left_floats = kid_block.inline_size_of_preceding_left_floats =
inline_size_of_preceding_left_floats; inline_size_of_preceding_left_floats;
kid_block.inline_size_of_preceding_right_floats = kid_block.inline_size_of_preceding_right_floats =
@ -1409,7 +1409,7 @@ impl BlockFlow {
// necessary because any percentages are relative to the containing block, which only // necessary because any percentages are relative to the containing block, which only
// we know. // we know.
if kid.is_inline_flow() { if kid.is_inline_flow() {
kid.as_inline().first_line_indentation = kid.as_mut_inline().first_line_indentation =
specified(self.fragment.style().get_inheritedtext().text_indent, specified(self.fragment.style().get_inheritedtext().text_indent,
containing_block_size); containing_block_size);
} }
@ -1501,11 +1501,11 @@ impl Flow for BlockFlow {
FlowClass::Block FlowClass::Block
} }
fn as_block<'a>(&'a mut self) -> &'a mut BlockFlow { fn as_mut_block<'a>(&'a mut self) -> &'a mut BlockFlow {
self self
} }
fn as_immutable_block<'a>(&'a self) -> &'a BlockFlow { fn as_block<'a>(&'a self) -> &'a BlockFlow {
self self
} }
@ -2839,4 +2839,3 @@ impl ISizeAndMarginsComputer for FloatReplaced {
MaybeAuto::Specified(fragment.content_inline_size()) MaybeAuto::Specified(fragment.content_inline_size())
} }
} }

View file

@ -480,7 +480,7 @@ impl<'a> FlowConstructor<'a> {
absolute_descendants.push_descendants(fragments.absolute_descendants); absolute_descendants.push_descendants(fragments.absolute_descendants);
{ {
let inline_flow = inline_flow_ref.as_inline(); let inline_flow = inline_flow_ref.as_mut_inline();
let (ascent, descent) = let (ascent, descent) =
@ -802,7 +802,7 @@ impl<'a> FlowConstructor<'a> {
} }
match kid.swap_out_construction_result() { match kid.swap_out_construction_result() {
ConstructionResult::None => {} ConstructionResult::None => {}
ConstructionResult::Flow(mut flow, kid_abs_descendants) => { ConstructionResult::Flow(flow, kid_abs_descendants) => {
if !flow::base(&*flow).flags.contains(IS_ABSOLUTELY_POSITIONED) { if !flow::base(&*flow).flags.contains(IS_ABSOLUTELY_POSITIONED) {
// {ib} split. Flush the accumulator to our new split and make a new // {ib} split. Flush the accumulator to our new split and make a new
// accumulator to hold any subsequent fragments we come across. // accumulator to hold any subsequent fragments we come across.
@ -1015,7 +1015,7 @@ impl<'a> FlowConstructor<'a> {
// Only flows that are table captions are matched here. // Only flows that are table captions are matched here.
for kid in node.children() { for kid in node.children() {
match kid.swap_out_construction_result() { match kid.swap_out_construction_result() {
ConstructionResult::Flow(mut kid_flow, _) => { ConstructionResult::Flow(kid_flow, _) => {
if kid_flow.is_table_caption() && if kid_flow.is_table_caption() &&
kid_flow.as_block() kid_flow.as_block()
.fragment .fragment

View file

@ -76,95 +76,97 @@ pub trait Flow: fmt::Debug + Sync {
/// Returns the class of flow that this is. /// Returns the class of flow that this is.
fn class(&self) -> FlowClass; fn class(&self) -> FlowClass;
/// If this is a block flow, returns the underlying object, borrowed immutably. Fails
/// otherwise.
fn as_immutable_block<'a>(&'a self) -> &'a BlockFlow {
panic!("called as_immutable_block() on a non-block flow")
}
/// If this is a block flow, returns the underlying object. Fails otherwise. /// If this is a block flow, returns the underlying object. Fails otherwise.
fn as_block<'a>(&'a mut self) -> &'a mut BlockFlow { fn as_block<'a>(&'a self) -> &'a BlockFlow {
debug!("called as_block() on a flow of type {:?}", self.class());
panic!("called as_block() on a non-block flow") panic!("called as_block() on a non-block flow")
} }
/// If this is an inline flow, returns the underlying object, borrowed immutably. Fails /// If this is a block flow, returns the underlying object, borrowed mutably. Fails otherwise.
/// otherwise. fn as_mut_block<'a>(&'a mut self) -> &'a mut BlockFlow {
fn as_immutable_inline<'a>(&'a self) -> &'a InlineFlow { debug!("called as_mut_block() on a flow of type {:?}", self.class());
panic!("called as_immutable_inline() on a non-inline flow") panic!("called as_mut_block() on a non-block flow")
} }
/// If this is an inline flow, returns the underlying object. Fails otherwise. /// If this is an inline flow, returns the underlying object. Fails otherwise.
fn as_inline<'a>(&'a mut self) -> &'a mut InlineFlow { fn as_inline<'a>(&'a self) -> &'a InlineFlow {
panic!("called as_inline() on a non-inline flow") panic!("called as_inline() on a non-inline flow")
} }
/// If this is an inline flow, returns the underlying object, borrowed mutably. Fails
/// otherwise.
fn as_mut_inline<'a>(&'a mut self) -> &'a mut InlineFlow {
panic!("called as_mut_inline() on a non-inline flow")
}
/// If this is a table wrapper flow, returns the underlying object, borrowed mutably. Fails
/// otherwise.
fn as_mut_table_wrapper<'a>(&'a mut self) -> &'a mut TableWrapperFlow {
panic!("called as_mut_table_wrapper() on a non-tablewrapper flow")
}
/// If this is a table wrapper flow, returns the underlying object. Fails otherwise. /// If this is a table wrapper flow, returns the underlying object. Fails otherwise.
fn as_table_wrapper<'a>(&'a mut self) -> &'a mut TableWrapperFlow { fn as_table_wrapper<'a>(&'a self) -> &'a TableWrapperFlow {
panic!("called as_table_wrapper() on a non-tablewrapper flow") panic!("called as_table_wrapper() on a non-tablewrapper flow")
} }
/// If this is a table wrapper flow, returns the underlying object, borrowed immutably. Fails /// If this is a table flow, returns the underlying object, borrowed mutably. Fails otherwise.
/// otherwise. fn as_mut_table<'a>(&'a mut self) -> &'a mut TableFlow {
fn as_immutable_table_wrapper<'a>(&'a self) -> &'a TableWrapperFlow { panic!("called as_mut_table() on a non-table flow")
panic!("called as_immutable_table_wrapper() on a non-tablewrapper flow")
} }
/// If this is a table flow, returns the underlying object. Fails otherwise. /// If this is a table flow, returns the underlying object. Fails otherwise.
fn as_table<'a>(&'a mut self) -> &'a mut TableFlow { fn as_table<'a>(&'a self) -> &'a TableFlow {
panic!("called as_table() on a non-table flow") panic!("called as_table() on a non-table flow")
} }
/// If this is a table flow, returns the underlying object, borrowed immutably. Fails otherwise. /// If this is a table colgroup flow, returns the underlying object, borrowed mutably. Fails
fn as_immutable_table<'a>(&'a self) -> &'a TableFlow { /// otherwise.
panic!("called as_table() on a non-table flow") fn as_mut_table_colgroup<'a>(&'a mut self) -> &'a mut TableColGroupFlow {
panic!("called as_mut_table_colgroup() on a non-tablecolgroup flow")
} }
/// If this is a table colgroup flow, returns the underlying object. Fails otherwise. /// If this is a table rowgroup flow, returns the underlying object, borrowed mutably. Fails
fn as_table_colgroup<'a>(&'a mut self) -> &'a mut TableColGroupFlow { /// otherwise.
panic!("called as_table_colgroup() on a non-tablecolgroup flow") fn as_mut_table_rowgroup<'a>(&'a mut self) -> &'a mut TableRowGroupFlow {
panic!("called as_mut_table_rowgroup() on a non-tablerowgroup flow")
} }
/// If this is a table rowgroup flow, returns the underlying object. Fails otherwise. /// If this is a table rowgroup flow, returns the underlying object. Fails otherwise.
fn as_table_rowgroup<'a>(&'a mut self) -> &'a mut TableRowGroupFlow { fn as_table_rowgroup<'a>(&'a self) -> &'a TableRowGroupFlow {
panic!("called as_table_rowgroup() on a non-tablerowgroup flow") panic!("called as_table_rowgroup() on a non-tablerowgroup flow")
} }
/// If this is a table rowgroup flow, returns the underlying object, borrowed immutably. Fails /// If this is a table row flow, returns the underlying object, borrowed mutably. Fails
/// otherwise. /// otherwise.
fn as_immutable_table_rowgroup<'a>(&'a self) -> &'a TableRowGroupFlow { fn as_mut_table_row<'a>(&'a mut self) -> &'a mut TableRowFlow {
panic!("called as_table_rowgroup() on a non-tablerowgroup flow") panic!("called as_mut_table_row() on a non-tablerow flow")
} }
/// If this is a table row flow, returns the underlying object. Fails otherwise. /// If this is a table row flow, returns the underlying object. Fails otherwise.
fn as_table_row<'a>(&'a mut self) -> &'a mut TableRowFlow { fn as_table_row<'a>(&'a self) -> &'a TableRowFlow {
panic!("called as_table_row() on a non-tablerow flow") panic!("called as_table_row() on a non-tablerow flow")
} }
/// If this is a table row flow, returns the underlying object, borrowed immutably. Fails /// If this is a table cell flow, returns the underlying object, borrowed mutably. Fails
/// otherwise. /// otherwise.
fn as_immutable_table_row<'a>(&'a self) -> &'a TableRowFlow { fn as_mut_table_caption<'a>(&'a mut self) -> &'a mut TableCaptionFlow {
panic!("called as_table_row() on a non-tablerow flow") panic!("called as_mut_table_caption() on a non-tablecaption flow")
}
/// If this is a table cell flow, returns the underlying object, borrowed mutably. Fails
/// otherwise.
fn as_mut_table_cell<'a>(&'a mut self) -> &'a mut TableCellFlow {
panic!("called as_mut_table_cell() on a non-tablecell flow")
}
/// If this is a multicol flow, returns the underlying object, borrowed mutably. Fails
/// otherwise.
fn as_mut_multicol<'a>(&'a mut self) -> &'a mut MulticolFlow {
panic!("called as_mut_multicol() on a non-multicol flow")
} }
/// If this is a table cell flow, returns the underlying object. Fails otherwise. /// If this is a table cell flow, returns the underlying object. Fails otherwise.
fn as_table_caption<'a>(&'a mut self) -> &'a mut TableCaptionFlow { fn as_table_cell<'a>(&'a self) -> &'a TableCellFlow {
panic!("called as_table_caption() on a non-tablecaption flow")
}
/// If this is a table cell flow, returns the underlying object. Fails otherwise.
fn as_table_cell<'a>(&'a mut self) -> &'a mut TableCellFlow {
panic!("called as_table_cell() on a non-tablecell flow")
}
/// If this is a multicol flow, returns the underlying object. Fails otherwise.
fn as_multicol<'a>(&'a mut self) -> &'a mut MulticolFlow {
panic!("called as_multicol() on a non-multicol flow")
}
/// If this is a table cell flow, returns the underlying object, borrowed immutably. Fails
/// otherwise.
fn as_immutable_table_cell<'a>(&'a self) -> &'a TableCellFlow {
panic!("called as_table_cell() on a non-tablecell flow") panic!("called as_table_cell() on a non-tablecell flow")
} }
@ -938,21 +940,13 @@ impl Encodable for BaseFlow {
try!(e.emit_struct_field("class", 0, |e| c.class().encode(e))); try!(e.emit_struct_field("class", 0, |e| c.class().encode(e)));
e.emit_struct_field("data", 1, |e| { e.emit_struct_field("data", 1, |e| {
match c.class() { match c.class() {
FlowClass::Block => c.as_immutable_block().encode(e), FlowClass::Block => c.as_block().encode(e),
FlowClass::Inline => c.as_immutable_inline().encode(e), FlowClass::Inline => c.as_inline().encode(e),
FlowClass::Table => c.as_immutable_table().encode(e), FlowClass::Table => c.as_table().encode(e),
FlowClass::TableWrapper => { FlowClass::TableWrapper => c.as_table_wrapper().encode(e),
c.as_immutable_table_wrapper().encode(e) FlowClass::TableRowGroup => c.as_table_rowgroup().encode(e),
} FlowClass::TableRow => c.as_table_row().encode(e),
FlowClass::TableRowGroup => { FlowClass::TableCell => c.as_table_cell().encode(e),
c.as_immutable_table_rowgroup().encode(e)
}
FlowClass::TableRow => {
c.as_immutable_table_row().encode(e)
}
FlowClass::TableCell => {
c.as_immutable_table_cell().encode(e)
}
_ => { Ok(()) } // TODO: Support captions _ => { Ok(()) } // TODO: Support captions
} }
}) })
@ -1452,9 +1446,9 @@ impl ContainingBlockLink {
Some(ref link) => { Some(ref link) => {
let flow = link.upgrade().unwrap(); let flow = link.upgrade().unwrap();
if flow.is_block_like() { if flow.is_block_like() {
flow.as_immutable_block().explicit_block_containing_size(layout_context) flow.as_block().explicit_block_containing_size(layout_context)
} else if flow.is_inline_flow() { } else if flow.is_inline_flow() {
Some(flow.as_immutable_inline().minimum_block_size_above_baseline) Some(flow.as_inline().minimum_block_size_above_baseline)
} else { } else {
None None
} }

View file

@ -1637,7 +1637,7 @@ impl Fragment {
match self.specific { match self.specific {
SpecificFragmentInfo::InlineAbsoluteHypothetical(ref mut info) => { SpecificFragmentInfo::InlineAbsoluteHypothetical(ref mut info) => {
let block_flow = info.flow_ref.as_block(); let block_flow = info.flow_ref.as_mut_block();
block_flow.base.position.size.inline = block_flow.base.position.size.inline =
block_flow.base.intrinsic_inline_sizes.preferred_inline_size; block_flow.base.intrinsic_inline_sizes.preferred_inline_size;
@ -1645,7 +1645,7 @@ impl Fragment {
self.border_box.size.inline = Au(0); self.border_box.size.inline = Au(0);
} }
SpecificFragmentInfo::InlineBlock(ref mut info) => { SpecificFragmentInfo::InlineBlock(ref mut info) => {
let block_flow = info.flow_ref.as_block(); let block_flow = info.flow_ref.as_mut_block();
self.border_box.size.inline = self.border_box.size.inline =
max(block_flow.base.intrinsic_inline_sizes.minimum_inline_size, max(block_flow.base.intrinsic_inline_sizes.minimum_inline_size,
block_flow.base.intrinsic_inline_sizes.preferred_inline_size); block_flow.base.intrinsic_inline_sizes.preferred_inline_size);
@ -1653,7 +1653,7 @@ impl Fragment {
block_flow.base.block_container_writing_mode = self.style.writing_mode; block_flow.base.block_container_writing_mode = self.style.writing_mode;
} }
SpecificFragmentInfo::InlineAbsolute(ref mut info) => { SpecificFragmentInfo::InlineAbsolute(ref mut info) => {
let block_flow = info.flow_ref.as_block(); let block_flow = info.flow_ref.as_mut_block();
self.border_box.size.inline = self.border_box.size.inline =
max(block_flow.base.intrinsic_inline_sizes.minimum_inline_size, max(block_flow.base.intrinsic_inline_sizes.minimum_inline_size,
block_flow.base.intrinsic_inline_sizes.preferred_inline_size); block_flow.base.intrinsic_inline_sizes.preferred_inline_size);
@ -1810,7 +1810,7 @@ impl Fragment {
} }
SpecificFragmentInfo::InlineBlock(ref info) => { SpecificFragmentInfo::InlineBlock(ref info) => {
// See CSS 2.1 § 10.8.1. // See CSS 2.1 § 10.8.1.
let block_flow = info.flow_ref.as_immutable_block(); let block_flow = info.flow_ref.as_block();
let font_style = self.style.get_font_arc(); let font_style = self.style.get_font_arc();
let font_metrics = text::font_metrics_for_style(&mut layout_context.font_context(), let font_metrics = text::font_metrics_for_style(&mut layout_context.font_context(),
font_style); font_style);

View file

@ -1298,11 +1298,11 @@ impl Flow for InlineFlow {
FlowClass::Inline FlowClass::Inline
} }
fn as_immutable_inline<'a>(&'a self) -> &'a InlineFlow { fn as_inline<'a>(&'a self) -> &'a InlineFlow {
self self
} }
fn as_inline<'a>(&'a mut self) -> &'a mut InlineFlow { fn as_mut_inline<'a>(&'a mut self) -> &'a mut InlineFlow {
self self
} }
@ -1658,7 +1658,7 @@ impl Flow for InlineFlow {
SpecificFragmentInfo::InlineBlock(ref mut info) => { SpecificFragmentInfo::InlineBlock(ref mut info) => {
flow::mut_base(&mut *info.flow_ref).clip = clip; flow::mut_base(&mut *info.flow_ref).clip = clip;
let block_flow = info.flow_ref.as_block(); let block_flow = info.flow_ref.as_mut_block();
block_flow.base.absolute_position_info = self.base.absolute_position_info; block_flow.base.absolute_position_info = self.base.absolute_position_info;
let stacking_relative_position = self.base.stacking_relative_position; let stacking_relative_position = self.base.stacking_relative_position;
@ -1678,7 +1678,7 @@ impl Flow for InlineFlow {
SpecificFragmentInfo::InlineAbsoluteHypothetical(ref mut info) => { SpecificFragmentInfo::InlineAbsoluteHypothetical(ref mut info) => {
flow::mut_base(&mut *info.flow_ref).clip = clip; flow::mut_base(&mut *info.flow_ref).clip = clip;
let block_flow = info.flow_ref.as_block(); let block_flow = info.flow_ref.as_mut_block();
block_flow.base.absolute_position_info = self.base.absolute_position_info; block_flow.base.absolute_position_info = self.base.absolute_position_info;
block_flow.base.stacking_relative_position = block_flow.base.stacking_relative_position =
@ -1689,7 +1689,7 @@ impl Flow for InlineFlow {
SpecificFragmentInfo::InlineAbsolute(ref mut info) => { SpecificFragmentInfo::InlineAbsolute(ref mut info) => {
flow::mut_base(&mut *info.flow_ref).clip = clip; flow::mut_base(&mut *info.flow_ref).clip = clip;
let block_flow = info.flow_ref.as_block(); let block_flow = info.flow_ref.as_mut_block();
block_flow.base.absolute_position_info = self.base.absolute_position_info; block_flow.base.absolute_position_info = self.base.absolute_position_info;
let stacking_relative_position = self.base.stacking_relative_position; let stacking_relative_position = self.base.stacking_relative_position;

View file

@ -1541,7 +1541,7 @@ fn get_root_flow_background_color(flow: &mut Flow) -> AzColor {
return color::transparent() return color::transparent()
} }
let block_flow = flow.as_block(); let block_flow = flow.as_mut_block();
let kid = match block_flow.base.children.iter_mut().next() { let kid = match block_flow.base.children.iter_mut().next() {
None => return color::transparent(), None => return color::transparent(),
Some(kid) => kid, Some(kid) => kid,

View file

@ -68,11 +68,11 @@ impl Flow for ListItemFlow {
FlowClass::ListItem FlowClass::ListItem
} }
fn as_block<'a>(&'a mut self) -> &'a mut BlockFlow { fn as_mut_block<'a>(&'a mut self) -> &'a mut BlockFlow {
&mut self.block_flow &mut self.block_flow
} }
fn as_immutable_block<'a>(&'a self) -> &'a BlockFlow { fn as_block<'a>(&'a self) -> &'a BlockFlow {
&self.block_flow &self.block_flow
} }
@ -228,4 +228,3 @@ impl ListStyleTypeContent {
} }
} }
} }

View file

@ -36,15 +36,15 @@ impl Flow for MulticolFlow {
FlowClass::Multicol FlowClass::Multicol
} }
fn as_multicol<'a>(&'a mut self) -> &'a mut MulticolFlow { fn as_mut_multicol<'a>(&'a mut self) -> &'a mut MulticolFlow {
self self
} }
fn as_block<'a>(&'a mut self) -> &'a mut BlockFlow { fn as_mut_block<'a>(&'a mut self) -> &'a mut BlockFlow {
&mut self.block_flow &mut self.block_flow
} }
fn as_immutable_block<'a>(&'a self) -> &'a BlockFlow { fn as_block<'a>(&'a self) -> &'a BlockFlow {
&self.block_flow &self.block_flow
} }

View file

@ -191,19 +191,19 @@ impl Flow for TableFlow {
FlowClass::Table FlowClass::Table
} }
fn as_table<'a>(&'a mut self) -> &'a mut TableFlow { fn as_mut_table<'a>(&'a mut self) -> &'a mut TableFlow {
self self
} }
fn as_immutable_table<'a>(&'a self) -> &'a TableFlow { fn as_table<'a>(&'a self) -> &'a TableFlow {
self self
} }
fn as_block<'a>(&'a mut self) -> &'a mut BlockFlow { fn as_mut_block<'a>(&'a mut self) -> &'a mut BlockFlow {
&mut self.block_flow &mut self.block_flow
} }
fn as_immutable_block(&self) -> &BlockFlow { fn as_block(&self) -> &BlockFlow {
&self.block_flow &self.block_flow
} }
@ -263,7 +263,7 @@ impl Flow for TableFlow {
let mut iterator = self.block_flow.base.child_iter().peekable(); let mut iterator = self.block_flow.base.child_iter().peekable();
while let Some(kid) = iterator.next() { while let Some(kid) = iterator.next() {
if kid.is_table_colgroup() { if kid.is_table_colgroup() {
for specified_inline_size in &kid.as_table_colgroup().inline_sizes { for specified_inline_size in &kid.as_mut_table_colgroup().inline_sizes {
self.column_intrinsic_inline_sizes.push(ColumnIntrinsicInlineSize { self.column_intrinsic_inline_sizes.push(ColumnIntrinsicInlineSize {
minimum_length: match *specified_inline_size { minimum_length: match *specified_inline_size {
LengthOrPercentageOrAuto::Auto | LengthOrPercentageOrAuto::Auto |
@ -293,12 +293,12 @@ impl Flow for TableFlow {
Some(next_sibling) => { Some(next_sibling) => {
if next_sibling.is_table_rowgroup() { if next_sibling.is_table_rowgroup() {
NextBlockCollapsedBorders::FromNextRow( NextBlockCollapsedBorders::FromNextRow(
&next_sibling.as_immutable_table_rowgroup() &next_sibling.as_table_rowgroup()
.preliminary_collapsed_borders .preliminary_collapsed_borders
.block_start) .block_start)
} else { } else {
NextBlockCollapsedBorders::FromNextRow( NextBlockCollapsedBorders::FromNextRow(
&next_sibling.as_immutable_table_row() &next_sibling.as_table_row()
.preliminary_collapsed_borders .preliminary_collapsed_borders
.block_start) .block_start)
} }
@ -310,7 +310,7 @@ impl Flow for TableFlow {
} }
}; };
perform_border_collapse_for_row( perform_border_collapse_for_row(
kid.as_table_row(), kid.as_mut_table_row(),
table_inline_collapsed_borders.as_ref().unwrap(), table_inline_collapsed_borders.as_ref().unwrap(),
previous_collapsed_block_end_borders, previous_collapsed_block_end_borders,
next_collapsed_borders_in_block_direction, next_collapsed_borders_in_block_direction,
@ -330,12 +330,12 @@ impl Flow for TableFlow {
Some(grandkid_next_sibling) => { Some(grandkid_next_sibling) => {
if grandkid_next_sibling.is_table_rowgroup() { if grandkid_next_sibling.is_table_rowgroup() {
NextBlockCollapsedBorders::FromNextRow( NextBlockCollapsedBorders::FromNextRow(
&grandkid_next_sibling.as_immutable_table_rowgroup() &grandkid_next_sibling.as_table_rowgroup()
.preliminary_collapsed_borders .preliminary_collapsed_borders
.block_start) .block_start)
} else { } else {
NextBlockCollapsedBorders::FromNextRow( NextBlockCollapsedBorders::FromNextRow(
&grandkid_next_sibling.as_immutable_table_row() &grandkid_next_sibling.as_table_row()
.preliminary_collapsed_borders .preliminary_collapsed_borders
.block_start) .block_start)
} }
@ -359,7 +359,7 @@ impl Flow for TableFlow {
self.table_layout); self.table_layout);
if collapsing_borders { if collapsing_borders {
perform_border_collapse_for_row( perform_border_collapse_for_row(
grandkid.as_table_row(), grandkid.as_mut_table_row(),
table_inline_collapsed_borders.as_ref().unwrap(), table_inline_collapsed_borders.as_ref().unwrap(),
previous_collapsed_block_end_borders, previous_collapsed_block_end_borders,
next_collapsed_borders_in_block_direction, next_collapsed_borders_in_block_direction,
@ -480,12 +480,12 @@ impl Flow for TableFlow {
column_computed_inline_sizes, column_computed_inline_sizes,
&spacing_per_cell); &spacing_per_cell);
if child_flow.is_table_row() { if child_flow.is_table_row() {
let child_table_row = child_flow.as_table_row(); let child_table_row = child_flow.as_mut_table_row();
child_table_row.populate_collapsed_border_spacing( child_table_row.populate_collapsed_border_spacing(
collapsed_inline_direction_border_widths_for_table, collapsed_inline_direction_border_widths_for_table,
&mut collapsed_block_direction_border_widths_for_table); &mut collapsed_block_direction_border_widths_for_table);
} else if child_flow.is_table_rowgroup() { } else if child_flow.is_table_rowgroup() {
let child_table_rowgroup = child_flow.as_table_rowgroup(); let child_table_rowgroup = child_flow.as_mut_table_rowgroup();
child_table_rowgroup.populate_collapsed_border_spacing( child_table_rowgroup.populate_collapsed_border_spacing(
collapsed_inline_direction_border_widths_for_table, collapsed_inline_direction_border_widths_for_table,
&mut collapsed_block_direction_border_widths_for_table); &mut collapsed_block_direction_border_widths_for_table);

View file

@ -36,15 +36,15 @@ impl Flow for TableCaptionFlow {
FlowClass::TableCaption FlowClass::TableCaption
} }
fn as_table_caption<'a>(&'a mut self) -> &'a mut TableCaptionFlow { fn as_mut_table_caption<'a>(&'a mut self) -> &'a mut TableCaptionFlow {
self self
} }
fn as_block<'a>(&'a mut self) -> &'a mut BlockFlow { fn as_mut_block<'a>(&'a mut self) -> &'a mut BlockFlow {
&mut self.block_flow &mut self.block_flow
} }
fn as_immutable_block(&self) -> &BlockFlow { fn as_block(&self) -> &BlockFlow {
&self.block_flow &self.block_flow
} }
@ -108,4 +108,3 @@ impl fmt::Debug for TableCaptionFlow {
write!(f, "TableCaptionFlow: {:?}", self.block_flow) write!(f, "TableCaptionFlow: {:?}", self.block_flow)
} }
} }

View file

@ -84,19 +84,19 @@ impl Flow for TableCellFlow {
FlowClass::TableCell FlowClass::TableCell
} }
fn as_table_cell<'a>(&'a mut self) -> &'a mut TableCellFlow { fn as_mut_table_cell<'a>(&'a mut self) -> &'a mut TableCellFlow {
self self
} }
fn as_immutable_table_cell<'a>(&'a self) -> &'a TableCellFlow { fn as_table_cell<'a>(&'a self) -> &'a TableCellFlow {
self self
} }
fn as_block<'a>(&'a mut self) -> &'a mut BlockFlow { fn as_mut_block<'a>(&'a mut self) -> &'a mut BlockFlow {
&mut self.block_flow &mut self.block_flow
} }
fn as_immutable_block(&self) -> &BlockFlow { fn as_block(&self) -> &BlockFlow {
&self.block_flow &self.block_flow
} }
@ -354,4 +354,3 @@ impl CollapsedBordersForCell {
*border_styles = logical_border_styles.to_physical(writing_mode); *border_styles = logical_border_styles.to_physical(writing_mode);
} }
} }

View file

@ -56,7 +56,7 @@ impl Flow for TableColGroupFlow {
FlowClass::TableColGroup FlowClass::TableColGroup
} }
fn as_table_colgroup<'a>(&'a mut self) -> &'a mut TableColGroupFlow { fn as_mut_table_colgroup<'a>(&'a mut self) -> &'a mut TableColGroupFlow {
self self
} }

View file

@ -119,7 +119,7 @@ impl TableRowFlow {
} }
{ {
let child_fragment = kid.as_table_cell().fragment(); let child_fragment = kid.as_mut_table_cell().fragment();
// TODO: Percentage block-size // TODO: Percentage block-size
let child_specified_block_size = let child_specified_block_size =
MaybeAuto::from_style(child_fragment.style().content_block_size(), MaybeAuto::from_style(child_fragment.style().content_block_size(),
@ -153,7 +153,7 @@ impl TableRowFlow {
// Assign the block-size of kid fragments, which is the same value as own block-size. // Assign the block-size of kid fragments, which is the same value as own block-size.
for kid in self.block_flow.base.child_iter() { for kid in self.block_flow.base.child_iter() {
let child_table_cell = kid.as_table_cell(); let child_table_cell = kid.as_mut_table_cell();
{ {
let kid_fragment = child_table_cell.mut_fragment(); let kid_fragment = child_table_cell.mut_fragment();
let mut position = kid_fragment.border_box; let mut position = kid_fragment.border_box;
@ -194,19 +194,19 @@ impl Flow for TableRowFlow {
FlowClass::TableRow FlowClass::TableRow
} }
fn as_table_row<'a>(&'a mut self) -> &'a mut TableRowFlow { fn as_mut_table_row<'a>(&'a mut self) -> &'a mut TableRowFlow {
self self
} }
fn as_immutable_table_row<'a>(&'a self) -> &'a TableRowFlow { fn as_table_row<'a>(&'a self) -> &'a TableRowFlow {
self self
} }
fn as_block<'a>(&'a mut self) -> &'a mut BlockFlow { fn as_mut_block<'a>(&'a mut self) -> &'a mut BlockFlow {
&mut self.block_flow &mut self.block_flow
} }
fn as_immutable_block(&self) -> &BlockFlow { fn as_block(&self) -> &BlockFlow {
&self.block_flow &self.block_flow
} }
@ -249,7 +249,7 @@ impl Flow for TableRowFlow {
let child_specified_inline_size; let child_specified_inline_size;
let child_column_span; let child_column_span;
{ {
let child_table_cell = kid.as_table_cell(); let child_table_cell = kid.as_mut_table_cell();
child_specified_inline_size = child_table_cell.block_flow child_specified_inline_size = child_table_cell.block_flow
.fragment .fragment
.style .style
@ -685,18 +685,18 @@ pub fn propagate_column_inline_sizes_to_child(
// FIXME(pcwalton): This seems inefficient. Reference count it instead? // FIXME(pcwalton): This seems inefficient. Reference count it instead?
match child_flow.class() { match child_flow.class() {
FlowClass::Table => { FlowClass::Table => {
let child_table_flow = child_flow.as_table(); let child_table_flow = child_flow.as_mut_table();
child_table_flow.column_computed_inline_sizes = column_computed_inline_sizes.to_vec(); child_table_flow.column_computed_inline_sizes = column_computed_inline_sizes.to_vec();
} }
FlowClass::TableRowGroup => { FlowClass::TableRowGroup => {
let child_table_rowgroup_flow = child_flow.as_table_rowgroup(); let child_table_rowgroup_flow = child_flow.as_mut_table_rowgroup();
child_table_rowgroup_flow.column_computed_inline_sizes = child_table_rowgroup_flow.column_computed_inline_sizes =
column_computed_inline_sizes.to_vec(); column_computed_inline_sizes.to_vec();
child_table_rowgroup_flow.spacing = *border_spacing; child_table_rowgroup_flow.spacing = *border_spacing;
child_table_rowgroup_flow.table_writing_mode = table_writing_mode; child_table_rowgroup_flow.table_writing_mode = table_writing_mode;
} }
FlowClass::TableRow => { FlowClass::TableRow => {
let child_table_row_flow = child_flow.as_table_row(); let child_table_row_flow = child_flow.as_mut_table_row();
child_table_row_flow.column_computed_inline_sizes = child_table_row_flow.column_computed_inline_sizes =
column_computed_inline_sizes.to_vec(); column_computed_inline_sizes.to_vec();
child_table_row_flow.spacing = *border_spacing; child_table_row_flow.spacing = *border_spacing;
@ -725,7 +725,7 @@ fn set_inline_position_of_child_flow(
let reverse_column_order = table_writing_mode.is_bidi_ltr() != row_writing_mode.is_bidi_ltr(); let reverse_column_order = table_writing_mode.is_bidi_ltr() != row_writing_mode.is_bidi_ltr();
// Handle border collapsing, if necessary. // Handle border collapsing, if necessary.
let child_table_cell = child_flow.as_table_cell(); let child_table_cell = child_flow.as_mut_table_cell();
match *border_collapse_info { match *border_collapse_info {
Some(ref border_collapse_info) => { Some(ref border_collapse_info) => {
// Write in the child's border collapse state. // Write in the child's border collapse state.
@ -821,7 +821,7 @@ fn perform_inline_direction_border_collapse_for_row(
CollapsedBorderProvenance::FromPreviousTableCell)); CollapsedBorderProvenance::FromPreviousTableCell));
if let Some(&(_, ref next_child_flow)) = iterator.peek() { if let Some(&(_, ref next_child_flow)) = iterator.peek() {
let next_child_flow = next_child_flow.as_immutable_block(); let next_child_flow = next_child_flow.as_block();
inline_collapsed_border.combine( inline_collapsed_border.combine(
&CollapsedBorder::inline_start(&*next_child_flow.fragment.style, &CollapsedBorder::inline_start(&*next_child_flow.fragment.style,
CollapsedBorderProvenance::FromNextTableCell)) CollapsedBorderProvenance::FromNextTableCell))

View file

@ -112,19 +112,19 @@ impl Flow for TableRowGroupFlow {
FlowClass::TableRowGroup FlowClass::TableRowGroup
} }
fn as_table_rowgroup<'a>(&'a mut self) -> &'a mut TableRowGroupFlow { fn as_mut_table_rowgroup<'a>(&'a mut self) -> &'a mut TableRowGroupFlow {
self self
} }
fn as_immutable_table_rowgroup<'a>(&'a self) -> &'a TableRowGroupFlow { fn as_table_rowgroup<'a>(&'a self) -> &'a TableRowGroupFlow {
self self
} }
fn as_block<'a>(&'a mut self) -> &'a mut BlockFlow { fn as_mut_block<'a>(&'a mut self) -> &'a mut BlockFlow {
&mut self.block_flow &mut self.block_flow
} }
fn as_immutable_block(&self) -> &BlockFlow { fn as_block(&self) -> &BlockFlow {
&self.block_flow &self.block_flow
} }
@ -187,7 +187,7 @@ impl Flow for TableRowGroupFlow {
&border_spacing); &border_spacing);
if border_collapse == border_collapse::T::collapse { if border_collapse == border_collapse::T::collapse {
let child_table_row = child_flow.as_table_row(); let child_table_row = child_flow.as_mut_table_row();
child_table_row.populate_collapsed_border_spacing( child_table_row.populate_collapsed_border_spacing(
collapsed_inline_direction_border_widths_for_table, collapsed_inline_direction_border_widths_for_table,
&mut collapsed_block_direction_border_widths_for_table); &mut collapsed_block_direction_border_widths_for_table);

View file

@ -99,7 +99,7 @@ impl TableWrapperFlow {
continue continue
} }
let kid_table = kid.as_table(); let kid_table = kid.as_mut_table();
let kid_block_flow = &mut kid_table.block_flow; let kid_block_flow = &mut kid_table.block_flow;
kid_block_flow.fragment kid_block_flow.fragment
.compute_border_and_padding(available_inline_size, .compute_border_and_padding(available_inline_size,
@ -265,19 +265,19 @@ impl Flow for TableWrapperFlow {
FlowClass::TableWrapper FlowClass::TableWrapper
} }
fn as_table_wrapper<'a>(&'a mut self) -> &'a mut TableWrapperFlow { fn as_mut_table_wrapper<'a>(&'a mut self) -> &'a mut TableWrapperFlow {
self self
} }
fn as_immutable_table_wrapper<'a>(&'a self) -> &'a TableWrapperFlow { fn as_table_wrapper<'a>(&'a self) -> &'a TableWrapperFlow {
self self
} }
fn as_block<'a>(&'a mut self) -> &'a mut BlockFlow { fn as_mut_block<'a>(&'a mut self) -> &'a mut BlockFlow {
&mut self.block_flow &mut self.block_flow
} }
fn as_immutable_block<'a>(&'a self) -> &'a BlockFlow { fn as_block<'a>(&'a self) -> &'a BlockFlow {
&self.block_flow &self.block_flow
} }