aboutsummaryrefslogtreecommitdiffstats
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
parente57e2121b27b09ceb8c87d3463f09f9c227b0565 (diff)
downloadservo-10ab466e5d25652ae4a062eb62fbe4f67585d400.tar.gz
servo-10ab466e5d25652ae4a062eb62fbe4f67585d400.zip
Create a solid rectangle display list entry for the page background.
-rw-r--r--Cargo.lock8
-rw-r--r--components/layout/display_list/builder.rs4
-rw-r--r--components/layout/sequential.rs25
-rw-r--r--components/layout_thread/lib.rs11
4 files changed, 37 insertions, 11 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 76b4ceab2b7..90740083aa0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5405,7 +5405,7 @@ dependencies = [
[[package]]
name = "webrender"
version = "0.60.0"
-source = "git+https://github.com/servo/webrender#fb1c0cf5ee16724820d004ad77e9f72beeeb7181"
+source = "git+https://github.com/servo/webrender#81703c1274cd4935f82412d4e5819942934d0c96"
dependencies = [
"base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -5446,7 +5446,7 @@ dependencies = [
[[package]]
name = "webrender_api"
version = "0.60.0"
-source = "git+https://github.com/servo/webrender#fb1c0cf5ee16724820d004ad77e9f72beeeb7181"
+source = "git+https://github.com/servo/webrender#81703c1274cd4935f82412d4e5819942934d0c96"
dependencies = [
"app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -5468,7 +5468,7 @@ dependencies = [
[[package]]
name = "webrender_build"
version = "0.0.1"
-source = "git+https://github.com/servo/webrender#fb1c0cf5ee16724820d004ad77e9f72beeeb7181"
+source = "git+https://github.com/servo/webrender#81703c1274cd4935f82412d4e5819942934d0c96"
dependencies = [
"sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -5620,7 +5620,7 @@ dependencies = [
[[package]]
name = "wr_malloc_size_of"
version = "0.0.1"
-source = "git+https://github.com/servo/webrender#fb1c0cf5ee16724820d004ad77e9f72beeeb7181"
+source = "git+https://github.com/servo/webrender#81703c1274cd4935f82412d4e5819942934d0c96"
dependencies = [
"app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)",
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,