aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2018-02-14 13:57:59 -0800
committerManish Goregaokar <manishsmail@gmail.com>2018-02-16 16:01:46 -0800
commitdb6ec58e6b971aa040739f0dc77701c02a889e1c (patch)
tree8c2d8c0b76e51dd3d597e7a9f0b5d2939df76bc4 /components/layout
parent62328466990e3ea436e5d05486eb26bc4ce0d799 (diff)
downloadservo-db6ec58e6b971aa040739f0dc77701c02a889e1c.tar.gz
servo-db6ec58e6b971aa040739f0dc77701c02a889e1c.zip
Generate display lists for table cells during display list generation for their table parent
Diffstat (limited to 'components/layout')
-rw-r--r--components/layout/block.rs1
-rw-r--r--components/layout/display_list/builder.rs22
-rw-r--r--components/layout/table.rs56
-rw-r--r--components/layout/table_cell.rs24
-rw-r--r--components/layout/table_row.rs18
5 files changed, 83 insertions, 38 deletions
diff --git a/components/layout/block.rs b/components/layout/block.rs
index 2eb7f76857f..7b809ce879e 100644
--- a/components/layout/block.rs
+++ b/components/layout/block.rs
@@ -1811,7 +1811,6 @@ impl BlockFlow {
DisplayListSection::BlockBackgroundsAndBorders
}
}
-
}
impl Flow for BlockFlow {
diff --git a/components/layout/display_list/builder.rs b/components/layout/display_list/builder.rs
index c1bbfe70a72..d391fbcbb1a 100644
--- a/components/layout/display_list/builder.rs
+++ b/components/layout/display_list/builder.rs
@@ -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,
diff --git a/components/layout/table.rs b/components/layout/table.rs
index daea0bd600e..b888df65fe5 100644
--- a/components/layout/table.rs
+++ b/components/layout/table.rs
@@ -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)
+ }
+}
diff --git a/components/layout/table_cell.rs b/components/layout/table_cell.rs
index 438e30d96fe..9fe04eb149f 100644
--- a/components/layout/table_cell.rs
+++ b/components/layout/table_cell.rs
@@ -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) {
diff --git a/components/layout/table_row.rs b/components/layout/table_row.rs
index a1c91417cd7..be83f6321e3 100644
--- a/components/layout/table_row.rs
+++ b/components/layout/table_row.rs
@@ -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) {