aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2019-06-10 17:09:44 -0400
committerJosh Matthews <josh@joshmatthews.net>2019-07-09 10:51:56 -0400
commit10ab466e5d25652ae4a062eb62fbe4f67585d400 (patch)
tree4111f6658a3e0a4f01f3079d550a400cac82c99b /components
parente57e2121b27b09ceb8c87d3463f09f9c227b0565 (diff)
downloadservo-10ab466e5d25652ae4a062eb62fbe4f67585d400.tar.gz
servo-10ab466e5d25652ae4a062eb62fbe4f67585d400.zip
Create a solid rectangle display list entry for the page background.
Diffstat (limited to 'components')
-rw-r--r--components/layout/display_list/builder.rs4
-rw-r--r--components/layout/sequential.rs25
-rw-r--r--components/layout_thread/lib.rs11
3 files changed, 33 insertions, 7 deletions
diff --git a/components/layout/display_list/builder.rs b/components/layout/display_list/builder.rs
index 02bde1f6741..bb2bbe58b34 100644
--- a/components/layout/display_list/builder.rs
+++ b/components/layout/display_list/builder.rs
@@ -345,7 +345,7 @@ impl<'a> DisplayListBuildState<'a> {
}
}
- fn add_display_item(&mut self, display_item: DisplayItem) {
+ pub fn add_display_item(&mut self, display_item: DisplayItem) {
let items = self
.items
.entry(display_item.stacking_context_id())
@@ -374,7 +374,7 @@ impl<'a> DisplayListBuildState<'a> {
self.processing_scrolling_overflow_element
}
- fn create_base_display_item(
+ pub fn create_base_display_item(
&self,
bounds: Rect<Au>,
clip_rect: Rect<Au>,
diff --git a/components/layout/sequential.rs b/components/layout/sequential.rs
index dfa8fddd82c..6a0b99dab8c 100644
--- a/components/layout/sequential.rs
+++ b/components/layout/sequential.rs
@@ -6,6 +6,7 @@
use crate::context::LayoutContext;
use crate::display_list::{DisplayListBuildState, StackingContextCollectionState};
+use crate::display_list::items::{self, CommonDisplayItem, DisplayItem, DisplayListSection};
use crate::floats::SpeculatedFloatPlacement;
use crate::flow::{Flow, FlowFlags, GetBaseFlow, ImmutableFlowUtils};
use crate::fragment::{CoordinateSystem, FragmentBorderBoxIterator};
@@ -14,7 +15,7 @@ use crate::incremental::RelayoutMode;
use crate::traversal::{AssignBSizes, AssignISizes, BubbleISizes, BuildDisplayList};
use crate::traversal::{InorderFlowTraversal, PostorderFlowTraversal, PreorderFlowTraversal};
use app_units::Au;
-use euclid::{Point2D, Vector2D};
+use euclid::{Point2D, Rect, Size2D, Vector2D};
use servo_config::opts;
use style::servo::restyle_damage::ServoRestyleDamage;
use webrender_api::units::LayoutPoint;
@@ -72,11 +73,31 @@ pub fn reflow(root: &mut dyn Flow, layout_context: &LayoutContext, relayout_mode
pub fn build_display_list_for_subtree<'a>(
flow_root: &mut dyn Flow,
layout_context: &'a LayoutContext,
+ background_color: webrender_api::ColorF,
+ client_size: Size2D<Au>,
) -> DisplayListBuildState<'a> {
let mut state = StackingContextCollectionState::new(layout_context.id);
flow_root.collect_stacking_contexts(&mut state);
- let state = DisplayListBuildState::new(layout_context, state);
+ let mut state = DisplayListBuildState::new(layout_context, state);
+
+ // Create a base rectangle for the page background based on the root
+ // background color.
+ let base = state.create_base_display_item(
+ Rect::new(Point2D::new(Au::new(0), Au::new(0)), client_size),
+ Rect::new(Point2D::new(Au::new(0), Au::new(0)), client_size),
+ flow_root.as_block().fragment.node,
+ None,
+ DisplayListSection::BackgroundAndBorders,
+ );
+ state.add_display_item(DisplayItem::Rectangle(CommonDisplayItem::new(
+ base,
+ webrender_api::RectangleDisplayItem {
+ color: background_color,
+ common: items::empty_common_item_properties(),
+ },
+ )));
+
let mut build_display_list = BuildDisplayList { state: state };
build_display_list.traverse(flow_root);
build_display_list.state
diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs
index 1afe8e37e9f..1d8448c6e74 100644
--- a/components/layout_thread/lib.rs
+++ b/components/layout_thread/lib.rs
@@ -1138,8 +1138,13 @@ impl LayoutThread {
rw_data.display_list.is_none()
{
if reflow_goal.needs_display_list() {
- let mut build_state =
- sequential::build_display_list_for_subtree(layout_root, layout_context);
+ let background_color = get_root_flow_background_color(layout_root);
+ let mut build_state = sequential::build_display_list_for_subtree(
+ layout_root,
+ layout_context,
+ background_color,
+ data.page_clip_rect.size,
+ );
debug!("Done building display list.");
@@ -1255,7 +1260,7 @@ impl LayoutThread {
let mut txn = webrender_api::Transaction::new();
txn.set_display_list(
webrender_api::Epoch(epoch.0),
- Some(get_root_flow_background_color(layout_root)),
+ None,
viewport_size,
builder.finalize(),
true,