Generate display lists for table cells during display list generation for their table parent

This commit is contained in:
Manish Goregaokar 2018-02-14 13:57:59 -08:00
parent 6232846699
commit db6ec58e6b
5 changed files with 83 additions and 38 deletions

View file

@ -1811,7 +1811,6 @@ impl BlockFlow {
DisplayListSection::BlockBackgroundsAndBorders
}
}
}
impl Flow for BlockFlow {

View file

@ -2330,6 +2330,12 @@ pub trait BlockFlowDisplayListBuilding {
border_painting_mode: BorderPaintingMode,
);
fn build_display_list_for_background_if_applicable_with_background(
&self,
state: &mut DisplayListBuildState,
background: &style_structs::Background,
background_color: RGBA);
fn block_stacking_context_type(
&self,
flags: StackingContextCollectionFlags,
@ -2892,6 +2898,22 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
state.processing_scrolling_overflow_element = false;
}
fn build_display_list_for_background_if_applicable_with_background(
&self,
state: &mut DisplayListBuildState,
background: &style_structs::Background,
background_color: RGBA) {
let stacking_relative_border_box =
self.base.stacking_relative_border_box_for_display_list(&self.fragment);
let background_border_section = self.background_border_section();
self.fragment.build_display_list_for_background_if_applicable_with_background(
state, self.fragment.style(), background, background_color,
background_border_section, &stacking_relative_border_box
)
}
#[inline]
fn block_stacking_context_type(
&self,

View file

@ -531,6 +531,13 @@ impl Flow for TableFlow {
};
self.block_flow.build_display_list_for_block(state, border_painting_mode);
let column_styles = self.column_styles();
let iter = TableCellStyleIterator::new(&mut self.block_flow.base, column_styles);
let cv = self.block_flow.fragment.style();
for mut style in iter {
style.build_display_list(state, cv)
}
}
fn collect_stacking_contexts(&mut self, state: &mut StackingContextCollectionState) {
@ -959,9 +966,8 @@ struct TableCellStyleIteratorRowInfo<'table> {
}
impl<'table> TableCellStyleIterator<'table> {
fn new(table: &'table mut TableFlow) -> Self {
let column_styles = table.column_styles();
let mut row_iterator = TableRowAndGroupIterator::new(&mut table.block_flow.base);
fn new(base: &'table mut BaseFlow, column_styles: Vec<ColumnStyle>) -> Self {
let mut row_iterator = TableRowAndGroupIterator::new(base);
let row_info = if let Some((group, row)) = row_iterator.next() {
Some(TableCellStyleIteratorRowInfo {
row: &row.block_flow.fragment,
@ -1000,7 +1006,7 @@ impl<'table> Iterator for TableCellStyleIterator<'table> {
self.column_styles.get(self.column_index_relative as usize) {
let styles = (column_style.col_style.clone(), column_style.colgroup_style.clone());
// FIXME incoming_rowspan
let cell_span = cell.fragment().column_span();
let cell_span = cell.column_span;
let mut current_col = column_style;
self.column_index_relative_offset += cell_span;
@ -1052,3 +1058,45 @@ impl<'table> Iterator for TableCellStyleIterator<'table> {
self.next()
}
}
impl<'table> TableCellStyleInfo<'table> {
fn build_display_list(&mut self, mut state: &mut DisplayListBuildState, table_style: &'table ComputedValues) {
if !self.cell.visible {
return
}
let border_painting_mode = match self.cell.block_flow
.fragment
.style
.get_inheritedtable()
.border_collapse {
border_collapse::T::Separate => BorderPaintingMode::Separate,
border_collapse::T::Collapse => BorderPaintingMode::Collapse(&self.cell.collapsed_borders),
};
{
let cell_flow = &self.cell.block_flow;
// XXXManishearth the color should be resolved relative to the style itself
// which we don't have here
let build_dl = |bg, state: &mut &mut DisplayListBuildState| {
cell_flow.build_display_list_for_background_if_applicable_with_background(
state, bg, table_style.resolve_color(bg.background_color)
)
};
build_dl(table_style.get_background(), &mut state);
if let Some(ref bg) = self.colgroup_style {
build_dl(&bg, &mut state);
}
if let Some(ref bg) = self.col_style {
build_dl(&bg, &mut state);
}
if let Some(ref bg) = self.rowgroup_style {
build_dl(bg, &mut state);
}
build_dl(self.row_style, &mut state);
}
self.cell.block_flow.build_display_list_for_block(state, border_painting_mode)
}
}

View file

@ -9,9 +9,8 @@
use app_units::Au;
use block::{BlockFlow, ISizeAndMarginsComputer, MarginsMayCollapseFlag};
use context::LayoutContext;
use display_list::{BlockFlowDisplayListBuilding, BorderPaintingMode};
use display_list::{DisplayListBuildState, StackingContextCollectionFlags};
use display_list::StackingContextCollectionState;
use display_list::{BlockFlowDisplayListBuilding, DisplayListBuildState};
use display_list::{StackingContextCollectionFlags, StackingContextCollectionState};
use euclid::{Point2D, Rect, SideOffsets2D, Size2D};
use flow::{Flow, FlowClass, FlowFlags, GetBaseFlow, OpaqueFlow};
use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
@ -20,7 +19,6 @@ use layout_debug;
use model::MaybeAuto;
use script_layout_interface::wrapper_traits::ThreadSafeLayoutNode;
use std::fmt;
use style::computed_values::border_collapse::T as BorderCollapse;
use style::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode};
use style::properties::ComputedValues;
use style::values::computed::Color;
@ -248,21 +246,9 @@ impl Flow for TableCellFlow {
self.block_flow.update_late_computed_block_position_if_necessary(block_position)
}
fn build_display_list(&mut self, state: &mut DisplayListBuildState) {
if !self.visible {
return
}
let border_painting_mode = match self.block_flow
.fragment
.style
.get_inheritedtable()
.border_collapse {
BorderCollapse::Separate => BorderPaintingMode::Separate,
BorderCollapse::Collapse => BorderPaintingMode::Collapse(&self.collapsed_borders),
};
self.block_flow.build_display_list_for_block(state, border_painting_mode)
fn build_display_list(&mut self, _: &mut DisplayListBuildState) {
// This is handled by TableCellStyleInfo::build_display_list()
// when the containing table builds its display list
}
fn collect_stacking_contexts(&mut self, state: &mut StackingContextCollectionState) {

View file

@ -9,9 +9,8 @@
use app_units::Au;
use block::{BlockFlow, ISizeAndMarginsComputer};
use context::LayoutContext;
use display_list::{BlockFlowDisplayListBuilding, BorderPaintingMode};
use display_list::{DisplayListBuildState, StackingContextCollectionFlags};
use display_list::StackingContextCollectionState;
use display_list::{BlockFlowDisplayListBuilding, DisplayListBuildState};
use display_list::{StackingContextCollectionFlags, StackingContextCollectionState};
use euclid::Point2D;
use flow::{EarlyAbsolutePositionInfo, Flow, FlowClass, ImmutableFlowUtils, GetBaseFlow, OpaqueFlow};
use flow_list::MutFlowListIterator;
@ -467,17 +466,8 @@ impl Flow for TableRowFlow {
self.block_flow.update_late_computed_block_position_if_necessary(block_position)
}
fn build_display_list(&mut self, state: &mut DisplayListBuildState) {
let border_painting_mode = match self.block_flow
.fragment
.style
.get_inheritedtable()
.border_collapse {
BorderCollapse::Separate => BorderPaintingMode::Separate,
BorderCollapse::Collapse => BorderPaintingMode::Hidden,
};
self.block_flow.build_display_list_for_block(state, border_painting_mode);
fn build_display_list(&mut self, _: &mut DisplayListBuildState) {
// handled in TableCellStyleInfo::build_display_list
}
fn collect_stacking_contexts(&mut self, state: &mut StackingContextCollectionState) {