Skip to content
Permalink
Browse files

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

  • Loading branch information...
jdm committed Jun 10, 2019
1 parent e57e212 commit 10ab466e5d25652ae4a062eb62fbe4f67585d400
Showing with 37 additions and 11 deletions.
  1. +4 −4 Cargo.lock
  2. +2 −2 components/layout/display_list/builder.rs
  3. +23 −2 components/layout/sequential.rs
  4. +8 −3 components/layout_thread/lib.rs

Some generated files are not rendered by default. Learn more.

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

0 comments on commit 10ab466

Please sign in to comment.
You can’t perform that action at this time.