mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
layout: Remove the old anonymous table object generation code.
This commit is contained in:
parent
bc2f5864bc
commit
a7f64f3d33
2 changed files with 3 additions and 162 deletions
|
@ -350,61 +350,6 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
|||
Fragment::new(node, specific_fragment_info, self.layout_context)
|
||||
}
|
||||
|
||||
/// Generates anonymous table objects per CSS 2.1 § 17.2.1.
|
||||
fn generate_anonymous_table_flows_if_necessary(&mut self,
|
||||
flow: &mut FlowRef,
|
||||
child: &mut FlowRef,
|
||||
child_node: &ConcreteThreadSafeLayoutNode) {
|
||||
if !flow.is_block_flow() {
|
||||
return
|
||||
}
|
||||
|
||||
let style_context = self.style_context();
|
||||
if child.is_table_cell() {
|
||||
let mut style = child_node.style(style_context);
|
||||
properties::modify_style_for_anonymous_table_object(&mut style, display::T::table_row);
|
||||
let fragment = Fragment::from_opaque_node_and_style(child_node.opaque(),
|
||||
PseudoElementType::Normal,
|
||||
style,
|
||||
child_node.selected_style(style_context),
|
||||
child_node.restyle_damage(),
|
||||
SpecificFragmentInfo::TableRow);
|
||||
let mut new_child: FlowRef = Arc::new(TableRowFlow::from_fragment(fragment));
|
||||
new_child.add_new_child(child.clone());
|
||||
child.finish();
|
||||
*child = new_child
|
||||
}
|
||||
if child.is_table_row() || child.is_table_rowgroup() {
|
||||
let mut style = child_node.style(style_context);
|
||||
properties::modify_style_for_anonymous_table_object(&mut style, display::T::table);
|
||||
let fragment = Fragment::from_opaque_node_and_style(child_node.opaque(),
|
||||
PseudoElementType::Normal,
|
||||
style,
|
||||
child_node.selected_style(style_context),
|
||||
child_node.restyle_damage(),
|
||||
SpecificFragmentInfo::Table);
|
||||
let mut new_child: FlowRef = Arc::new(TableFlow::from_fragment(fragment));
|
||||
new_child.add_new_child(child.clone());
|
||||
child.finish();
|
||||
*child = new_child
|
||||
}
|
||||
if child.is_table() {
|
||||
let mut style = child_node.style(style_context);
|
||||
properties::modify_style_for_anonymous_table_object(&mut style, display::T::table);
|
||||
let fragment =
|
||||
Fragment::from_opaque_node_and_style(child_node.opaque(),
|
||||
PseudoElementType::Normal,
|
||||
style,
|
||||
child_node.selected_style(style_context),
|
||||
child_node.restyle_damage(),
|
||||
SpecificFragmentInfo::TableWrapper);
|
||||
let mut new_child: FlowRef = Arc::new(TableWrapperFlow::from_fragment(fragment, None));
|
||||
new_child.add_new_child(child.clone());
|
||||
child.finish();
|
||||
*child = new_child
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates an inline flow from a set of inline fragments, then adds it as a child of the given
|
||||
/// flow or pushes it onto the given flow list.
|
||||
///
|
||||
|
@ -1071,35 +1016,6 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
|||
}
|
||||
}
|
||||
|
||||
/// Generates an anonymous table flow according to CSS 2.1 § 17.2.1, step 2.
|
||||
/// If necessary, generate recursively another anonymous table flow.
|
||||
fn generate_anonymous_missing_child(&mut self,
|
||||
child_flows: Vec<FlowRef>,
|
||||
flow: &mut FlowRef,
|
||||
node: &ConcreteThreadSafeLayoutNode) {
|
||||
let mut anonymous_flow = flow.generate_missing_child_flow(node, self.layout_context);
|
||||
let mut consecutive_siblings = vec!();
|
||||
for kid_flow in child_flows {
|
||||
if anonymous_flow.need_anonymous_flow(&*kid_flow) {
|
||||
consecutive_siblings.push(kid_flow);
|
||||
continue;
|
||||
}
|
||||
if !consecutive_siblings.is_empty() {
|
||||
self.generate_anonymous_missing_child(consecutive_siblings,
|
||||
&mut anonymous_flow,
|
||||
node);
|
||||
consecutive_siblings = vec!();
|
||||
}
|
||||
anonymous_flow.add_new_child(kid_flow);
|
||||
}
|
||||
if !consecutive_siblings.is_empty() {
|
||||
self.generate_anonymous_missing_child(consecutive_siblings, &mut anonymous_flow, node);
|
||||
}
|
||||
// The flow is done.
|
||||
anonymous_flow.finish();
|
||||
flow.add_new_child(anonymous_flow);
|
||||
}
|
||||
|
||||
/// Builds a flow for a node with `column-count` or `column-width` non-`auto`.
|
||||
/// This yields a `MulticolFlow` with a single `MulticolColumnFlow` underneath it.
|
||||
fn build_flow_for_multicol(&mut self, node: &ConcreteThreadSafeLayoutNode,
|
||||
|
|
|
@ -33,7 +33,7 @@ use euclid::{Point2D, Size2D};
|
|||
use floats::{Floats, SpeculatedFloatPlacement};
|
||||
use flow_list::{FlowList, MutFlowListIterator};
|
||||
use flow_ref::{self, FlowRef, WeakFlowRef};
|
||||
use fragment::{Fragment, FragmentBorderBoxIterator, Overflow, SpecificFragmentInfo};
|
||||
use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
|
||||
use gfx::display_list::{ClippingRegion, StackingContext};
|
||||
use gfx_traits::StackingContextId;
|
||||
use gfx_traits::print_tree::PrintTree;
|
||||
|
@ -44,17 +44,16 @@ use parallel::FlowParallelInfo;
|
|||
use rustc_serialize::{Encodable, Encoder};
|
||||
use script_layout_interface::restyle_damage::{RECONSTRUCT_FLOW, REFLOW, REFLOW_OUT_OF_FLOW};
|
||||
use script_layout_interface::restyle_damage::{REPAINT, REPOSITION, RestyleDamage};
|
||||
use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayoutNode};
|
||||
use std::{fmt, mem, raw};
|
||||
use std::iter::Zip;
|
||||
use std::slice::IterMut;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::Ordering;
|
||||
use style::computed_values::{clear, display, empty_cells, float, overflow_x, position, text_align};
|
||||
use style::computed_values::{clear, float, overflow_x, position, text_align};
|
||||
use style::context::SharedStyleContext;
|
||||
use style::dom::TRestyleDamage;
|
||||
use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
|
||||
use style::properties::{self, ServoComputedValues};
|
||||
use style::properties::ServoComputedValues;
|
||||
use style::values::computed::LengthOrPercentageOrAuto;
|
||||
use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, TableFlow};
|
||||
use table_caption::TableCaptionFlow;
|
||||
|
@ -470,12 +469,6 @@ pub trait ImmutableFlowUtils {
|
|||
/// Returns true if this flow is one of table-related flows.
|
||||
fn is_table_kind(self) -> bool;
|
||||
|
||||
/// Returns true if anonymous flow is needed between this flow and child flow.
|
||||
fn need_anonymous_flow(self, child: &Flow) -> bool;
|
||||
|
||||
/// Generates missing child flow of this flow.
|
||||
fn generate_missing_child_flow<N: ThreadSafeLayoutNode>(self, node: &N, ctx: &LayoutContext) -> FlowRef;
|
||||
|
||||
/// Returns true if this flow contains fragments that are roots of an absolute flow tree.
|
||||
fn contains_roots_of_absolute_flow_tree(&self) -> bool;
|
||||
|
||||
|
@ -1236,74 +1229,6 @@ impl<'a> ImmutableFlowUtils for &'a Flow {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns true if anonymous flow is needed between this flow and child flow.
|
||||
/// Spec: http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes
|
||||
fn need_anonymous_flow(self, child: &Flow) -> bool {
|
||||
match self.class() {
|
||||
FlowClass::Table => !child.is_proper_table_child(),
|
||||
FlowClass::TableRowGroup => !child.is_table_row(),
|
||||
FlowClass::TableRow => !child.is_table_cell(),
|
||||
// FIXME(zentner): According to spec, anonymous flex items are only needed for text.
|
||||
FlowClass::Flex => child.is_inline_flow(),
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
/// Generates missing child flow of this flow.
|
||||
///
|
||||
/// FIXME(pcwalton): This duplicates some logic in
|
||||
/// `generate_anonymous_table_flows_if_necessary()`. We should remove this function eventually,
|
||||
/// as it's harder to understand.
|
||||
fn generate_missing_child_flow<N: ThreadSafeLayoutNode>(self, node: &N, ctx: &LayoutContext) -> FlowRef {
|
||||
let style_context = ctx.style_context();
|
||||
let mut style = node.style(style_context);
|
||||
match self.class() {
|
||||
FlowClass::Table | FlowClass::TableRowGroup => {
|
||||
properties::modify_style_for_anonymous_table_object(
|
||||
&mut style,
|
||||
display::T::table_row);
|
||||
let fragment = Fragment::from_opaque_node_and_style(
|
||||
node.opaque(),
|
||||
PseudoElementType::Normal,
|
||||
style,
|
||||
node.selected_style(style_context),
|
||||
node.restyle_damage(),
|
||||
SpecificFragmentInfo::TableRow);
|
||||
Arc::new(TableRowFlow::from_fragment(fragment))
|
||||
},
|
||||
FlowClass::TableRow => {
|
||||
properties::modify_style_for_anonymous_table_object(
|
||||
&mut style,
|
||||
display::T::table_cell);
|
||||
let fragment = Fragment::from_opaque_node_and_style(
|
||||
node.opaque(),
|
||||
PseudoElementType::Normal,
|
||||
style,
|
||||
node.selected_style(style_context),
|
||||
node.restyle_damage(),
|
||||
SpecificFragmentInfo::TableCell);
|
||||
let hide = node.style(style_context).get_inheritedtable().empty_cells == empty_cells::T::hide;
|
||||
Arc::new(TableCellFlow::from_node_fragment_and_visibility_flag(node, fragment, !hide))
|
||||
},
|
||||
FlowClass::Flex => {
|
||||
properties::modify_style_for_anonymous_flow(
|
||||
&mut style,
|
||||
display::T::block);
|
||||
let fragment =
|
||||
Fragment::from_opaque_node_and_style(node.opaque(),
|
||||
PseudoElementType::Normal,
|
||||
style,
|
||||
node.selected_style(style_context),
|
||||
node.restyle_damage(),
|
||||
SpecificFragmentInfo::Generic);
|
||||
Arc::new(BlockFlow::from_fragment(fragment, None))
|
||||
},
|
||||
_ => {
|
||||
panic!("no need to generate a missing child")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if this flow contains fragments that are roots of an absolute flow tree.
|
||||
fn contains_roots_of_absolute_flow_tree(&self) -> bool {
|
||||
self.contains_relatively_positioned_fragments() || self.is_root()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue