Create a solid rectangle display list entry for the page background.

This commit is contained in:
Josh Matthews 2019-06-10 17:09:44 -04:00
parent e57e2121b2
commit 10ab466e5d
4 changed files with 37 additions and 11 deletions

8
Cargo.lock generated
View file

@ -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)",

View file

@ -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>,

View file

@ -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

View file

@ -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,