mirror of
https://github.com/servo/servo.git
synced 2025-08-07 22:45:34 +01:00
style: Implement basic column spans.
This patch provides some of the groundwork for column spans greater than 1. It implements the column-span CSS property (prefixed so as not to be exposed to content) as well as the corresponding colspan attribute; although the former is not well-specified outside of CSS multi-column layout, INTRINSIC refers to it. Although width is distributed to spanning columns, they do not yet contribute minimum and preferred widths; this will be implemented in a follow-up. Additionally, this patch cleans up some miscellaneous formatting issues and improves the handling of table rowgroups.
This commit is contained in:
parent
14bafb11be
commit
56b78de5bc
13 changed files with 269 additions and 129 deletions
|
@ -6,13 +6,12 @@
|
|||
|
||||
#![deny(unsafe_blocks)]
|
||||
|
||||
use block::{BlockFlow, ISizeAndMarginsComputer, MarginsMayNotCollapse};
|
||||
use block::{BlockFlow, ISizeAndMarginsComputer};
|
||||
use construct::FlowConstructor;
|
||||
use context::LayoutContext;
|
||||
use flow::{TableRowGroupFlowClass, FlowClass, Flow, ImmutableFlowUtils};
|
||||
use flow::{mod, Flow, FlowClass, TableRowGroupFlowClass};
|
||||
use fragment::{Fragment, FragmentBoundsIterator};
|
||||
use layout_debug;
|
||||
use model::IntrinsicISizesContribution;
|
||||
use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, InternalTable, TableFlow};
|
||||
use wrapper::ThreadSafeLayoutNode;
|
||||
|
||||
|
@ -24,6 +23,7 @@ use sync::Arc;
|
|||
/// A table formatting context.
|
||||
#[deriving(Encodable)]
|
||||
pub struct TableRowGroupFlow {
|
||||
/// Fields common to all block flows.
|
||||
pub block_flow: BlockFlow,
|
||||
|
||||
/// Information about the intrinsic inline-sizes of each column.
|
||||
|
@ -91,54 +91,11 @@ impl Flow for TableRowGroupFlow {
|
|||
&mut self.column_computed_inline_sizes
|
||||
}
|
||||
|
||||
|
||||
/// Recursively (bottom-up) determines the context's preferred and minimum inline-sizes. When
|
||||
/// called on this context, all child contexts have had their min/pref inline-sizes set. This
|
||||
/// function must decide min/pref inline-sizes based on child context inline-sizes and
|
||||
/// dimensions of any fragments it is responsible for flowing.
|
||||
///
|
||||
/// Min/pref inline-sizes set by this function are used in automatic table layout calculation.
|
||||
///
|
||||
/// Also, this function finds the specified column inline-sizes from the first row. These are
|
||||
/// used in fixed table layout calculation.
|
||||
fn bubble_inline_sizes(&mut self) {
|
||||
let _scope = layout_debug_scope!("table_rowgroup::bubble_inline_sizes {:x}",
|
||||
self.block_flow.base.debug_id());
|
||||
|
||||
let mut computation = IntrinsicISizesContribution::new();
|
||||
for kid in self.block_flow.base.child_iter() {
|
||||
assert!(kid.is_table_row());
|
||||
|
||||
// Calculate minimum and preferred inline sizes for automatic table layout.
|
||||
if self.column_intrinsic_inline_sizes.is_empty() {
|
||||
// We're the first row.
|
||||
self.column_intrinsic_inline_sizes = kid.column_intrinsic_inline_sizes().clone();
|
||||
} else {
|
||||
let mut child_intrinsic_sizes =
|
||||
TableFlow::update_column_inline_sizes(&mut self.column_intrinsic_inline_sizes,
|
||||
kid.column_intrinsic_inline_sizes());
|
||||
|
||||
// update the number of column inline-sizes from table-rows.
|
||||
let column_count = self.column_intrinsic_inline_sizes.len();
|
||||
let child_column_count = kid.column_intrinsic_inline_sizes().len();
|
||||
for i in range(column_count, child_column_count) {
|
||||
let this_column_inline_size = (*kid.column_intrinsic_inline_sizes())[i];
|
||||
|
||||
// FIXME(pcwalton): Ignoring the percentage here seems dubious.
|
||||
child_intrinsic_sizes.minimum_inline_size =
|
||||
child_intrinsic_sizes.minimum_inline_size +
|
||||
this_column_inline_size.minimum_length;
|
||||
child_intrinsic_sizes.preferred_inline_size =
|
||||
child_intrinsic_sizes.preferred_inline_size +
|
||||
this_column_inline_size.preferred;
|
||||
self.column_intrinsic_inline_sizes.push(this_column_inline_size);
|
||||
}
|
||||
|
||||
computation.union_block(&child_intrinsic_sizes)
|
||||
}
|
||||
}
|
||||
|
||||
self.block_flow.base.intrinsic_inline_sizes = computation.finish()
|
||||
// Proper calculation of intrinsic sizes in table layout requires access to the entire
|
||||
// table, which we don't have yet. Defer to our parent.
|
||||
}
|
||||
|
||||
/// Recursively (top-down) determines the actual inline-size of child contexts and fragments.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue