mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Pass LayoutContext to DisplayListBuilder
This commit is contained in:
parent
c8cbc57b76
commit
40453ad7e1
2 changed files with 29 additions and 7 deletions
|
@ -2,6 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
use crate::context::LayoutContext;
|
||||||
use crate::fragments::{BoxFragment, Fragment};
|
use crate::fragments::{BoxFragment, Fragment};
|
||||||
use crate::geom::physical::{Rect, Vec2};
|
use crate::geom::physical::{Rect, Vec2};
|
||||||
use embedder_traits::Cursor;
|
use embedder_traits::Cursor;
|
||||||
|
@ -25,8 +26,9 @@ pub struct WebRenderImageInfo {
|
||||||
type ItemTag = (u64, u16);
|
type ItemTag = (u64, u16);
|
||||||
type HitInfo = Option<ItemTag>;
|
type HitInfo = Option<ItemTag>;
|
||||||
|
|
||||||
pub struct DisplayListBuilder {
|
pub struct DisplayListBuilder<'a> {
|
||||||
current_space_and_clip: wr::SpaceAndClipInfo,
|
current_space_and_clip: wr::SpaceAndClipInfo,
|
||||||
|
pub context: &'a LayoutContext<'a>,
|
||||||
pub wr: wr::DisplayListBuilder,
|
pub wr: wr::DisplayListBuilder,
|
||||||
|
|
||||||
/// Contentful paint, for the purpose of
|
/// Contentful paint, for the purpose of
|
||||||
|
@ -36,11 +38,16 @@ pub struct DisplayListBuilder {
|
||||||
pub is_contentful: bool,
|
pub is_contentful: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DisplayListBuilder {
|
impl<'a> DisplayListBuilder<'a> {
|
||||||
pub fn new(pipeline_id: wr::PipelineId, viewport_size: wr::units::LayoutSize) -> Self {
|
pub fn new(
|
||||||
|
pipeline_id: wr::PipelineId,
|
||||||
|
context: &'a LayoutContext,
|
||||||
|
viewport_size: wr::units::LayoutSize,
|
||||||
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
current_space_and_clip: wr::SpaceAndClipInfo::root_scroll(pipeline_id),
|
current_space_and_clip: wr::SpaceAndClipInfo::root_scroll(pipeline_id),
|
||||||
is_contentful: false,
|
is_contentful: false,
|
||||||
|
context,
|
||||||
wr: wr::DisplayListBuilder::new(pipeline_id, viewport_size),
|
wr: wr::DisplayListBuilder::new(pipeline_id, viewport_size),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1147,7 +1147,12 @@ impl LayoutThread {
|
||||||
|
|
||||||
// Perform post-style recalculation layout passes.
|
// Perform post-style recalculation layout passes.
|
||||||
if let Some(root) = &*self.fragment_tree_root.borrow() {
|
if let Some(root) = &*self.fragment_tree_root.borrow() {
|
||||||
self.perform_post_style_recalc_layout_passes(root, &data.reflow_goal, Some(&document));
|
self.perform_post_style_recalc_layout_passes(
|
||||||
|
root,
|
||||||
|
&data.reflow_goal,
|
||||||
|
Some(&document),
|
||||||
|
&mut layout_context,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.first_reflow.set(false);
|
self.first_reflow.set(false);
|
||||||
|
@ -1292,12 +1297,20 @@ impl LayoutThread {
|
||||||
let author_shared_lock = self.document_shared_lock.clone().unwrap();
|
let author_shared_lock = self.document_shared_lock.clone().unwrap();
|
||||||
let author_guard = author_shared_lock.read();
|
let author_guard = author_shared_lock.read();
|
||||||
let ua_or_user_guard = UA_STYLESHEETS.shared_lock.read();
|
let ua_or_user_guard = UA_STYLESHEETS.shared_lock.read();
|
||||||
let _guards = StylesheetGuards {
|
let guards = StylesheetGuards {
|
||||||
author: &author_guard,
|
author: &author_guard,
|
||||||
ua_or_user: &ua_or_user_guard,
|
ua_or_user: &ua_or_user_guard,
|
||||||
};
|
};
|
||||||
|
let snapshots = SnapshotMap::new();
|
||||||
|
let mut layout_context = self.build_layout_context(guards, false, &snapshots);
|
||||||
|
|
||||||
self.perform_post_style_recalc_layout_passes(root, &ReflowGoal::TickAnimations, None);
|
self.perform_post_style_recalc_layout_passes(
|
||||||
|
root,
|
||||||
|
&ReflowGoal::TickAnimations,
|
||||||
|
None,
|
||||||
|
&mut layout_context,
|
||||||
|
);
|
||||||
|
assert!(layout_context.pending_images.is_none());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1306,6 +1319,7 @@ impl LayoutThread {
|
||||||
fragment_tree: &layout::FragmentTreeRoot,
|
fragment_tree: &layout::FragmentTreeRoot,
|
||||||
reflow_goal: &ReflowGoal,
|
reflow_goal: &ReflowGoal,
|
||||||
document: Option<&ServoLayoutDocument>,
|
document: Option<&ServoLayoutDocument>,
|
||||||
|
context: &mut LayoutContext,
|
||||||
) {
|
) {
|
||||||
if !reflow_goal.needs_display() {
|
if !reflow_goal.needs_display() {
|
||||||
// Defer the paint step until the next ForDisplay.
|
// Defer the paint step until the next ForDisplay.
|
||||||
|
@ -1325,7 +1339,8 @@ impl LayoutThread {
|
||||||
self.viewport_size.width.to_f32_px(),
|
self.viewport_size.width.to_f32_px(),
|
||||||
self.viewport_size.height.to_f32_px(),
|
self.viewport_size.height.to_f32_px(),
|
||||||
));
|
));
|
||||||
let mut display_list = DisplayListBuilder::new(self.id.to_webrender(), viewport_size);
|
let mut display_list =
|
||||||
|
DisplayListBuilder::new(self.id.to_webrender(), context, viewport_size);
|
||||||
fragment_tree.build_display_list(&mut display_list, viewport_size);
|
fragment_tree.build_display_list(&mut display_list, viewport_size);
|
||||||
|
|
||||||
if self.dump_fragment_tree {
|
if self.dump_fragment_tree {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue