Backed out changeset 9f9a83173704 (bug 1893088) for causing talos related process-crashes.

This commit is contained in:
Stanca Serban 2024-05-01 11:58:20 +03:00
Родитель 686ce3fd94
Коммит 9dd6c7da25
14 изменённых файлов: 153 добавлений и 126 удалений

Просмотреть файл

@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use api::units::*;
use crate::intern::{Internable, InternDebug, Handle as InternHandle};
use crate::internal_types::LayoutPrimitiveInfo;
use crate::prim_store::{
@ -132,6 +133,7 @@ impl InternablePrimitive for BackdropCapture {
_key: BackdropCaptureKey,
data_handle: BackdropCaptureDataHandle,
_prim_store: &mut PrimitiveStore,
_reference_frame_relative_offset: LayoutVector2D,
) -> PrimitiveInstanceKind {
PrimitiveInstanceKind::BackdropCapture {
data_handle,
@ -151,6 +153,7 @@ impl InternablePrimitive for BackdropRender {
_key: BackdropRenderKey,
data_handle: BackdropRenderDataHandle,
_prim_store: &mut PrimitiveStore,
_reference_frame_relative_offset: LayoutVector2D,
) -> PrimitiveInstanceKind {
PrimitiveInstanceKind::BackdropRender {
data_handle,

Просмотреть файл

@ -166,6 +166,7 @@ impl InternablePrimitive for NormalBorderPrim {
_key: NormalBorderKey,
data_handle: NormalBorderDataHandle,
_: &mut PrimitiveStore,
_reference_frame_relative_offset: LayoutVector2D,
) -> PrimitiveInstanceKind {
PrimitiveInstanceKind::NormalBorder {
data_handle,
@ -353,6 +354,7 @@ impl InternablePrimitive for ImageBorder {
_key: ImageBorderKey,
data_handle: ImageBorderDataHandle,
_: &mut PrimitiveStore,
_reference_frame_relative_offset: LayoutVector2D,
) -> PrimitiveInstanceKind {
PrimitiveInstanceKind::ImageBorder {
data_handle

Просмотреть файл

@ -323,6 +323,7 @@ impl InternablePrimitive for ConicGradient {
_key: ConicGradientKey,
data_handle: ConicGradientDataHandle,
_prim_store: &mut PrimitiveStore,
_reference_frame_relative_offset: LayoutVector2D,
) -> PrimitiveInstanceKind {
PrimitiveInstanceKind::ConicGradient {
data_handle,

Просмотреть файл

@ -618,6 +618,7 @@ impl InternablePrimitive for LinearGradient {
key: LinearGradientKey,
data_handle: LinearGradientDataHandle,
_prim_store: &mut PrimitiveStore,
_reference_frame_relative_offset: LayoutVector2D,
) -> PrimitiveInstanceKind {
if key.cached {
PrimitiveInstanceKind::CachedLinearGradient {

Просмотреть файл

@ -289,6 +289,7 @@ impl InternablePrimitive for RadialGradient {
_key: RadialGradientKey,
data_handle: RadialGradientDataHandle,
_prim_store: &mut PrimitiveStore,
_reference_frame_relative_offset: LayoutVector2D,
) -> PrimitiveInstanceKind {
PrimitiveInstanceKind::RadialGradient {
data_handle,

Просмотреть файл

@ -440,6 +440,7 @@ impl InternablePrimitive for Image {
_key: ImageKey,
data_handle: ImageDataHandle,
prim_store: &mut PrimitiveStore,
_reference_frame_relative_offset: LayoutVector2D,
) -> PrimitiveInstanceKind {
// TODO(gw): Refactor this to not need a separate image
// instance (see ImageInstance struct).
@ -645,6 +646,7 @@ impl InternablePrimitive for YuvImage {
_key: YuvImageKey,
data_handle: YuvImageDataHandle,
_prim_store: &mut PrimitiveStore,
_reference_frame_relative_offset: LayoutVector2D,
) -> PrimitiveInstanceKind {
PrimitiveInstanceKind::YuvImage {
data_handle,

Просмотреть файл

@ -144,6 +144,7 @@ impl InternablePrimitive for LineDecoration {
_key: LineDecorationKey,
data_handle: LineDecorationDataHandle,
_: &mut PrimitiveStore,
_reference_frame_relative_offset: LayoutVector2D,
) -> PrimitiveInstanceKind {
PrimitiveInstanceKind::LineDecoration {
data_handle,

Просмотреть файл

@ -636,6 +636,7 @@ impl InternablePrimitive for PrimitiveKeyKind {
key: PrimitiveKey,
data_handle: PrimitiveDataHandle,
prim_store: &mut PrimitiveStore,
_reference_frame_relative_offset: LayoutVector2D,
) -> PrimitiveInstanceKind {
match key.kind {
PrimitiveKeyKind::Clear => {
@ -1468,6 +1469,7 @@ pub trait InternablePrimitive: intern::Internable<InternData = ()> + Sized {
key: Self::Key,
data_handle: intern::Handle<Self>,
prim_store: &mut PrimitiveStore,
reference_frame_relative_offset: LayoutVector2D,
) -> PrimitiveInstanceKind;
}

Просмотреть файл

@ -6,7 +6,7 @@ use api::{
ColorU, MixBlendMode, FilterPrimitiveInput, FilterPrimitiveKind, ColorSpace,
PropertyBinding, PropertyBindingId, CompositeOperator, RasterSpace,
};
use api::units::Au;
use api::units::{Au, LayoutVector2D};
use crate::scene_building::IsVisible;
use crate::filterdata::SFilterData;
use crate::intern::ItemUid;
@ -298,6 +298,7 @@ impl InternablePrimitive for Picture {
_key: PictureKey,
_: PictureDataHandle,
_: &mut PrimitiveStore,
_reference_frame_relative_offset: LayoutVector2D,
) -> PrimitiveInstanceKind {
// Should never be hit as this method should not be
// called for pictures.

Просмотреть файл

@ -24,7 +24,7 @@ use crate::util::PrimaryArc;
use std::ops;
use std::sync::Arc;
use super::{storage, VectorKey};
use super::storage;
/// A run of glyphs, with associated font information.
#[cfg_attr(feature = "capture", derive(Serialize))]
@ -36,7 +36,6 @@ pub struct TextRunKey {
pub glyphs: PrimaryArc<Vec<GlyphInstance>>,
pub shadow: bool,
pub requested_raster_space: RasterSpace,
pub reference_frame_relative_offset: VectorKey,
}
impl TextRunKey {
@ -50,7 +49,6 @@ impl TextRunKey {
glyphs: PrimaryArc(text_run.glyphs),
shadow: text_run.shadow,
requested_raster_space: text_run.requested_raster_space,
reference_frame_relative_offset: text_run.reference_frame_relative_offset.into(),
}
}
}
@ -148,7 +146,6 @@ pub struct TextRun {
pub glyphs: Arc<Vec<GlyphInstance>>,
pub shadow: bool,
pub requested_raster_space: RasterSpace,
pub reference_frame_relative_offset: LayoutVector2D,
}
impl intern::Internable for TextRun {
@ -173,9 +170,8 @@ impl InternablePrimitive for TextRun {
key: TextRunKey,
data_handle: TextRunDataHandle,
prim_store: &mut PrimitiveStore,
reference_frame_relative_offset: LayoutVector2D,
) -> PrimitiveInstanceKind {
let reference_frame_relative_offset = key.reference_frame_relative_offset.into();
let run_index = prim_store.text_runs.push(TextRunPrimitive {
used_font: key.font.clone(),
glyph_keys_range: storage::Range::empty(),
@ -216,7 +212,6 @@ impl CreateShadow for TextRun {
glyphs: self.glyphs.clone(),
shadow: true,
requested_raster_space,
reference_frame_relative_offset: self.reference_frame_relative_offset,
}
}
}
@ -496,8 +491,8 @@ fn test_struct_sizes() {
// test expectations and move on.
// (b) You made a structure larger. This is not necessarily a problem, but should only
// be done with care, and after checking if talos performance regresses badly.
assert_eq!(mem::size_of::<TextRun>(), 72, "TextRun size changed");
assert_eq!(mem::size_of::<TextRun>(), 64, "TextRun size changed");
assert_eq!(mem::size_of::<TextRunTemplate>(), 80, "TextRunTemplate size changed");
assert_eq!(mem::size_of::<TextRunKey>(), 88, "TextRunKey size changed");
assert_eq!(mem::size_of::<TextRunKey>(), 80, "TextRunKey size changed");
assert_eq!(mem::size_of::<TextRunPrimitive>(), 80, "TextRunPrimitive size changed");
}

Просмотреть файл

@ -41,7 +41,7 @@ use api::{DisplayItem, DisplayItemRef, ExtendMode, ExternalScrollId, FilterData}
use api::{FilterOp, FilterPrimitive, FontInstanceKey, FontSize, GlyphInstance, GlyphOptions, GradientStop};
use api::{IframeDisplayItem, ImageKey, ImageRendering, ItemRange, ColorDepth, QualitySettings};
use api::{LineOrientation, LineStyle, NinePatchBorderSource, PipelineId, MixBlendMode, StackingContextFlags};
use api::{PropertyBinding, ReferenceFrameKind, ScrollFrameDescriptor};
use api::{PropertyBinding, ReferenceFrameKind, ScrollFrameDescriptor, ReferenceFrameMapper};
use api::{APZScrollGeneration, HasScrollLinkedEffect, Shadow, SpatialId, StickyFrameDescriptor, ImageMask, ItemTag};
use api::{ClipMode, PrimitiveKeyKind, TransformStyle, YuvColorSpace, ColorRange, YuvData, TempFilterData};
use api::{ReferenceTransformBinding, Rotation, FillRule, SpatialTreeItem, ReferenceFrameDescriptor};
@ -471,6 +471,9 @@ pub struct SceneBuilder<'a> {
/// Reference to the set of data that is interned across display lists.
interners: &'a mut Interners,
/// Helper struct to map stacking context coords <-> reference frame coords.
rf_mapper: ReferenceFrameMapper,
/// Helper struct to map spatial nodes to external scroll offsets.
external_scroll_mapper: ScrollOffsetMapper,
@ -564,6 +567,7 @@ impl<'a> SceneBuilder<'a> {
prim_store: PrimitiveStore::new(&stats.prim_store_stats),
clip_store: ClipStore::new(),
interners,
rf_mapper: ReferenceFrameMapper::new(),
external_scroll_mapper: ScrollOffsetMapper::new(),
iframe_size: Vec::new(),
root_iframe_clip: None,
@ -779,17 +783,26 @@ impl<'a> SceneBuilder<'a> {
pictures[pic_index.0].prim_list = prim_list;
}
/// Retrieve the current external scroll offset on the provided spatial node.
fn current_external_scroll_offset(
/// Retrieve the current offset to allow converting a stacking context
/// relative coordinate to be relative to the owing reference frame,
/// also considering any external scroll offset on the provided
/// spatial node.
fn current_offset(
&mut self,
spatial_node_index: SpatialNodeIndex,
) -> LayoutVector2D {
// Get the current offset from stacking context <-> reference frame space.
let rf_offset = self.rf_mapper.current_offset();
// Get the external scroll offset, if applicable.
self.external_scroll_mapper
let scroll_offset = self
.external_scroll_mapper
.external_scroll_offset(
spatial_node_index,
self.spatial_tree,
)
);
rf_offset + scroll_offset
}
fn build_spatial_tree_for_display_list(
@ -909,6 +922,7 @@ impl<'a> SceneBuilder<'a> {
info.stacking_context.flags,
);
self.rf_mapper.push_offset(info.origin.to_vector());
let new_context = BuildContext {
pipeline_id: bc.pipeline_id,
kind: ContextKind::StackingContext {
@ -926,6 +940,7 @@ impl<'a> SceneBuilder<'a> {
profile_scope!("build_reference_frame");
let mut subtraversal = item.sub_iter();
self.rf_mapper.push_scope();
let new_context = BuildContext {
pipeline_id: bc.pipeline_id,
kind: ContextKind::ReferenceFrame,
@ -967,12 +982,15 @@ impl<'a> SceneBuilder<'a> {
match bc.kind {
ContextKind::Root => {}
ContextKind::StackingContext { sc_info } => {
self.rf_mapper.pop_offset();
self.pop_stacking_context(sc_info);
}
ContextKind::ReferenceFrame => {
self.rf_mapper.pop_scope();
}
ContextKind::Iframe { parent_traversal } => {
self.iframe_size.pop();
self.rf_mapper.pop_scope();
self.clip_tree_builder.pop_clip();
self.clip_tree_builder.pop_clip();
@ -1017,10 +1035,8 @@ impl<'a> SceneBuilder<'a> {
parent_node_index: SpatialNodeIndex,
instance_id: PipelineInstanceId,
) {
let external_scroll_offset = self.current_external_scroll_offset(parent_node_index);
let sticky_frame_info = StickyFrameInfo::new(
info.bounds.translate(external_scroll_offset),
info.bounds,
info.margins,
info.vertical_offset_bounds,
info.horizontal_offset_bounds,
@ -1094,8 +1110,6 @@ impl<'a> SceneBuilder<'a> {
},
};
let external_scroll_offset = self.current_external_scroll_offset(parent_space);
self.push_reference_frame(
info.reference_frame.id,
parent_space,
@ -1103,7 +1117,7 @@ impl<'a> SceneBuilder<'a> {
info.reference_frame.transform_style,
transform,
info.reference_frame.kind,
(info.origin + external_scroll_offset).to_vector(), // !!!!!!!!!
info.origin.to_vector(),
SpatialNodeUid::external(info.reference_frame.key, pipeline_id, instance_id),
);
}
@ -1119,14 +1133,13 @@ impl<'a> SceneBuilder<'a> {
// SpatialNode::scroll(..) API as well as for properly setting sticky
// positioning offsets.
let content_size = info.content_rect.size();
let external_scroll_offset = self.current_external_scroll_offset(parent_node_index);
self.add_scroll_frame(
info.scroll_frame_id,
parent_node_index,
info.external_id,
pipeline_id,
&info.frame_rect.translate(external_scroll_offset),
&info.frame_rect,
&content_size,
ScrollFrameKind::Explicit,
info.external_scroll_offset,
@ -1167,8 +1180,6 @@ impl<'a> SceneBuilder<'a> {
self.clip_tree_builder.push_clip_chain(Some(info.space_and_clip.clip_chain_id), false);
let external_scroll_offset = self.current_external_scroll_offset(spatial_node_index);
// TODO(gw): This is the only remaining call site that relies on ClipId parenting, remove me!
self.add_rect_clip_node(
ClipId::root(iframe_pipeline_id),
@ -1183,7 +1194,7 @@ impl<'a> SceneBuilder<'a> {
self.id_to_index_mapper_stack.push(NodeIdToIndexMapper::default());
let bounds = self.snap_rect(
&info.bounds.translate(external_scroll_offset),
&info.bounds,
spatial_node_index,
);
@ -1229,6 +1240,7 @@ impl<'a> SceneBuilder<'a> {
self.add_tile_cache_barrier_if_needed(SliceFlags::empty());
}
self.iframe_size.push(info.bounds.size());
self.rf_mapper.push_scope();
self.build_spatial_tree_for_display_list(
&pipeline.display_list.display_list,
@ -1261,7 +1273,7 @@ impl<'a> SceneBuilder<'a> {
bounds: Option<&LayoutRect>,
) -> (LayoutPrimitiveInfo, LayoutRect, SpatialNodeIndex, ClipNodeId) {
let spatial_node_index = self.get_space(common.spatial_id);
let current_offset = self.current_external_scroll_offset(spatial_node_index);
let current_offset = self.current_offset(spatial_node_index);
let unsnapped_clip_rect = common.clip_rect.translate(current_offset);
let unsnapped_rect = bounds.map(|bounds| {
@ -1415,7 +1427,6 @@ impl<'a> SceneBuilder<'a> {
&info.color,
item.glyphs(),
info.glyph_options,
info.ref_frame_offset,
);
}
DisplayItem::Rectangle(ref info) => {
@ -1444,7 +1455,7 @@ impl<'a> SceneBuilder<'a> {
profile_scope!("hit_test");
let spatial_node_index = self.get_space(info.spatial_id);
let current_offset = self.current_external_scroll_offset(spatial_node_index);
let current_offset = self.current_offset(spatial_node_index);
let unsnapped_rect = info.rect.translate(current_offset);
let rect = self.snap_rect(
@ -1859,6 +1870,7 @@ impl<'a> SceneBuilder<'a> {
fn create_primitive<P>(
&mut self,
info: &LayoutPrimitiveInfo,
spatial_node_index: SpatialNodeIndex,
clip_leaf_id: ClipLeafId,
prim: P,
) -> PrimitiveInstance
@ -1869,6 +1881,7 @@ impl<'a> SceneBuilder<'a> {
// Build a primitive key.
let prim_key = prim.into_key(info);
let current_offset = self.current_offset(spatial_node_index);
let interner = self.interners.as_mut();
let prim_data_handle = interner
.intern(&prim_key, || ());
@ -1877,6 +1890,7 @@ impl<'a> SceneBuilder<'a> {
prim_key,
prim_data_handle,
&mut self.prim_store,
current_offset,
);
PrimitiveInstance::new(
@ -2025,6 +2039,7 @@ impl<'a> SceneBuilder<'a> {
{
let prim_instance = self.create_primitive(
info,
spatial_node_index,
clip_leaf_id,
prim,
);
@ -2676,10 +2691,9 @@ impl<'a> SceneBuilder<'a> {
points_range: ItemRange<LayoutPoint>,
) {
let spatial_node_index = self.get_space(spatial_id);
let external_scroll_offset = self.current_external_scroll_offset(spatial_node_index);
let snapped_mask_rect = self.snap_rect(
&image_mask.rect.translate(external_scroll_offset),
&image_mask.rect,
spatial_node_index,
);
let points: Vec<LayoutPoint> = points_range.iter().collect();
@ -2724,10 +2738,9 @@ impl<'a> SceneBuilder<'a> {
clip_rect: &LayoutRect,
) {
let spatial_node_index = self.get_space(spatial_id);
let external_scroll_offset = self.current_external_scroll_offset(spatial_node_index);
let snapped_clip_rect = self.snap_rect(
&clip_rect.translate(external_scroll_offset),
clip_rect,
spatial_node_index,
);
@ -2757,10 +2770,9 @@ impl<'a> SceneBuilder<'a> {
clip: &ComplexClipRegion,
) {
let spatial_node_index = self.get_space(spatial_id);
let external_scroll_offset = self.current_external_scroll_offset(spatial_node_index);
let snapped_region_rect = self.snap_rect(
&clip.rect.translate(external_scroll_offset),
&clip.rect,
spatial_node_index,
);
let item = ClipItemKey {
@ -3051,6 +3063,7 @@ impl<'a> SceneBuilder<'a> {
// Construct and add a primitive for the given shadow.
let shadow_prim_instance = self.create_primitive(
&info,
pending_primitive.spatial_node_index,
clip_set,
pending_primitive.prim.create_shadow(
&pending_shadow.shadow,
@ -3426,9 +3439,8 @@ impl<'a> SceneBuilder<'a> {
text_color: &ColorF,
glyph_range: ItemRange<GlyphInstance>,
glyph_options: Option<GlyphOptions>,
ref_frame_offset: LayoutVector2D,
) {
let offset = self.current_external_scroll_offset(spatial_node_index) + ref_frame_offset;
let offset = self.current_offset(spatial_node_index);
let text_run = {
let shared_key = self.fonts.instance_keys.map_key(font_instance_key);
@ -3492,7 +3504,6 @@ impl<'a> SceneBuilder<'a> {
font,
shadow: false,
requested_raster_space,
reference_frame_relative_offset: offset,
}
};
@ -3623,6 +3634,7 @@ impl<'a> SceneBuilder<'a> {
// picture that reads from the backdrop root
let backdrop_capture_instance = self.create_primitive(
info,
spatial_node_index,
clip_leaf_id,
BackdropCapture {
},
@ -3721,6 +3733,7 @@ impl<'a> SceneBuilder<'a> {
// Add the prim that renders the result of the backdrop filter chain
let mut backdrop_render_instance = self.create_primitive(
info,
spatial_node_index,
clip_leaf_id,
BackdropRender {
},

Просмотреть файл

@ -428,7 +428,6 @@ pub struct TextDisplayItem {
pub font_key: font::FontInstanceKey,
pub color: ColorF,
pub glyph_options: Option<font::GlyphOptions>,
pub ref_frame_offset: LayoutVector2D,
} // IMPLICIT: glyphs: Vec<font::GlyphInstance>
#[derive(Clone, Copy, Debug, Default, Deserialize, MallocSizeOf, PartialEq, Serialize, PeekPoke)]

Просмотреть файл

@ -1038,6 +1038,23 @@ pub enum DisplayListSection {
Chunk,
}
/// A small portion of a normal spatial node that we store during DL construction to
/// enable snapping and reference frame <-> stacking context coord mapping. In future
/// we'll aim to remove this and have the full spatial tree available during DL build.
#[derive(Clone)]
pub struct SpatialNodeInfo {
/// The total external scroll offset applicable at this node
accumulated_external_scroll_offset: LayoutVector2D,
}
impl SpatialNodeInfo {
fn identity() -> Self {
SpatialNodeInfo {
accumulated_external_scroll_offset: LayoutVector2D::zero(),
}
}
}
pub struct DisplayListBuilder {
payload: DisplayListPayload,
pub pipeline_id: PipelineId,
@ -1058,6 +1075,9 @@ pub struct DisplayListBuilder {
/// Helper struct to map stacking context coords <-> reference frame coords.
rf_mapper: ReferenceFrameMapper,
/// Minimal info about encountered spatial nodes to allow snapping during DL building
spatial_nodes: Vec<SpatialNodeInfo>,
}
#[repr(C)]
@ -1096,6 +1116,7 @@ impl DisplayListBuilder {
state: BuildState::Idle,
rf_mapper: ReferenceFrameMapper::new(),
spatial_nodes: vec![SpatialNodeInfo::identity(); FIRST_SPATIAL_NODE_INDEX + 1],
}
}
@ -1113,6 +1134,7 @@ impl DisplayListBuilder {
self.serialized_content_buffer = None;
self.rf_mapper = ReferenceFrameMapper::new();
self.spatial_nodes = vec![SpatialNodeInfo::identity(); FIRST_SPATIAL_NODE_INDEX + 1];
}
/// Saves the current display list state, so it may be `restore()`'d.
@ -1303,43 +1325,14 @@ impl DisplayListBuilder {
Self::push_iter_impl(&mut buffer, iter);
}
// Remap a clip/bounds from stacking context coords to reference frame relative
fn remap_common_coordinates_and_bounds(
&self,
common: &di::CommonItemProperties,
bounds: LayoutRect,
) -> (di::CommonItemProperties, LayoutRect) {
let offset = self.rf_mapper.current_offset();
(
di::CommonItemProperties {
clip_rect: common.clip_rect.translate(offset),
..*common
},
bounds.translate(offset),
)
}
// Remap a bounds from stacking context coords to reference frame relative
fn remap_bounds(
&self,
bounds: LayoutRect,
) -> LayoutRect {
let offset = self.rf_mapper.current_offset();
bounds.translate(offset)
}
pub fn push_rect(
&mut self,
common: &di::CommonItemProperties,
bounds: LayoutRect,
color: ColorF,
) {
let (common, bounds) = self.remap_common_coordinates_and_bounds(common, bounds);
let item = di::DisplayItem::Rectangle(di::RectangleDisplayItem {
common,
common: *common,
color: PropertyBinding::Value(color),
bounds,
});
@ -1352,10 +1345,8 @@ impl DisplayListBuilder {
bounds: LayoutRect,
color: PropertyBinding<ColorF>,
) {
let (common, bounds) = self.remap_common_coordinates_and_bounds(common, bounds);
let item = di::DisplayItem::Rectangle(di::RectangleDisplayItem {
common,
common: *common,
color,
bounds,
});
@ -1367,10 +1358,8 @@ impl DisplayListBuilder {
common: &di::CommonItemProperties,
bounds: LayoutRect,
) {
let (common, bounds) = self.remap_common_coordinates_and_bounds(common, bounds);
let item = di::DisplayItem::ClearRectangle(di::ClearRectangleDisplayItem {
common,
common: *common,
bounds,
});
self.push_item(&item);
@ -1384,8 +1373,6 @@ impl DisplayListBuilder {
flags: di::PrimitiveFlags,
tag: di::ItemTag,
) {
let rect = self.remap_bounds(rect);
let item = di::DisplayItem::HitTest(di::HitTestDisplayItem {
rect,
clip_chain_id,
@ -1405,13 +1392,8 @@ impl DisplayListBuilder {
color: &ColorF,
style: di::LineStyle,
) {
let common = di::CommonItemProperties {
clip_rect: self.remap_bounds(common.clip_rect),
..*common
};
let item = di::DisplayItem::Line(di::LineDisplayItem {
common,
common: *common,
area: *area,
wavy_line_thickness,
orientation,
@ -1431,10 +1413,8 @@ impl DisplayListBuilder {
key: ImageKey,
color: ColorF,
) {
let (common, bounds) = self.remap_common_coordinates_and_bounds(common, bounds);
let item = di::DisplayItem::Image(di::ImageDisplayItem {
common,
common: *common,
bounds,
image_key: key,
image_rendering,
@ -1456,10 +1436,8 @@ impl DisplayListBuilder {
key: ImageKey,
color: ColorF,
) {
let (common, bounds) = self.remap_common_coordinates_and_bounds(common, bounds);
let item = di::DisplayItem::RepeatingImage(di::RepeatingImageDisplayItem {
common,
common: *common,
bounds,
image_key: key,
stretch_size,
@ -1483,10 +1461,8 @@ impl DisplayListBuilder {
color_range: di::ColorRange,
image_rendering: di::ImageRendering,
) {
let (common, bounds) = self.remap_common_coordinates_and_bounds(common, bounds);
let item = di::DisplayItem::YuvImage(di::YuvImageDisplayItem {
common,
common: *common,
bounds,
yuv_data,
color_depth,
@ -1506,16 +1482,12 @@ impl DisplayListBuilder {
color: ColorF,
glyph_options: Option<GlyphOptions>,
) {
let (common, bounds) = self.remap_common_coordinates_and_bounds(common, bounds);
let ref_frame_offset = self.rf_mapper.current_offset();
let item = di::DisplayItem::Text(di::TextDisplayItem {
common,
common: *common,
bounds,
color,
font_key,
glyph_options,
ref_frame_offset,
});
for split_glyphs in glyphs.chunks(MAX_TEXT_RUN_LENGTH) {
@ -1576,10 +1548,8 @@ impl DisplayListBuilder {
widths: LayoutSideOffsets,
details: di::BorderDetails,
) {
let (common, bounds) = self.remap_common_coordinates_and_bounds(common, bounds);
let item = di::DisplayItem::Border(di::BorderDisplayItem {
common,
common: *common,
bounds,
details,
widths,
@ -1599,10 +1569,8 @@ impl DisplayListBuilder {
border_radius: di::BorderRadius,
clip_mode: di::BoxShadowClipMode,
) {
let (common, box_bounds) = self.remap_common_coordinates_and_bounds(common, box_bounds);
let item = di::DisplayItem::BoxShadow(di::BoxShadowDisplayItem {
common,
common: *common,
box_bounds,
offset,
color,
@ -1637,10 +1605,8 @@ impl DisplayListBuilder {
tile_size: LayoutSize,
tile_spacing: LayoutSize,
) {
let (common, bounds) = self.remap_common_coordinates_and_bounds(common, bounds);
let item = di::DisplayItem::Gradient(di::GradientDisplayItem {
common,
common: *common,
bounds,
gradient,
tile_size,
@ -1661,10 +1627,8 @@ impl DisplayListBuilder {
tile_size: LayoutSize,
tile_spacing: LayoutSize,
) {
let (common, bounds) = self.remap_common_coordinates_and_bounds(common, bounds);
let item = di::DisplayItem::RadialGradient(di::RadialGradientDisplayItem {
common,
common: *common,
bounds,
gradient,
tile_size,
@ -1685,10 +1649,8 @@ impl DisplayListBuilder {
tile_size: LayoutSize,
tile_spacing: LayoutSize,
) {
let (common, bounds) = self.remap_common_coordinates_and_bounds(common, bounds);
let item = di::DisplayItem::ConicGradient(di::ConicGradientDisplayItem {
common,
common: *common,
bounds,
gradient,
tile_size,
@ -1709,9 +1671,14 @@ impl DisplayListBuilder {
) -> di::SpatialId {
let id = self.generate_spatial_index();
let current_offset = self.rf_mapper.current_offset();
let current_offset = self.current_offset(parent_spatial_id);
let origin = origin + current_offset;
self.add_spatial_node_info(
id,
LayoutVector2D::zero(),
);
let descriptor = di::SpatialTreeItem::ReferenceFrame(di::ReferenceFrameDescriptor {
parent_spatial_id,
origin,
@ -1747,7 +1714,7 @@ impl DisplayListBuilder {
) -> di::SpatialId {
let id = self.generate_spatial_index();
let current_offset = self.rf_mapper.current_offset();
let current_offset = self.current_offset(parent_spatial_id);
let origin = origin + current_offset;
let descriptor = di::SpatialTreeItem::ReferenceFrame(di::ReferenceFrameDescriptor {
@ -1880,15 +1847,10 @@ impl DisplayListBuilder {
filter_datas: &[di::FilterData],
filter_primitives: &[di::FilterPrimitive],
) {
let common = di::CommonItemProperties {
clip_rect: self.remap_bounds(common.clip_rect),
..*common
};
self.push_filters(filters, filter_datas, filter_primitives);
let item = di::DisplayItem::BackdropFilter(di::BackdropFilterDisplayItem {
common,
common: *common,
});
self.push_item(&item);
}
@ -1949,7 +1911,14 @@ impl DisplayListBuilder {
key: di::SpatialTreeItemKey,
) -> di::SpatialId {
let scroll_frame_id = self.generate_spatial_index();
let current_offset = self.rf_mapper.current_offset();
let current_offset = self.current_offset(parent_space);
let parent = self.spatial_nodes[parent_space.0].clone();
self.add_spatial_node_info(
scroll_frame_id,
parent.accumulated_external_scroll_offset + external_scroll_offset,
);
let descriptor = di::SpatialTreeItem::ScrollFrame(di::ScrollFrameDescriptor {
content_rect,
@ -1992,7 +1961,7 @@ impl DisplayListBuilder {
) -> di::ClipId {
let id = self.generate_clip_index();
let current_offset = self.rf_mapper.current_offset();
let current_offset = self.current_offset(spatial_id);
let image_mask = di::ImageMask {
rect: image_mask.rect.translate(current_offset),
@ -2025,7 +1994,7 @@ impl DisplayListBuilder {
) -> di::ClipId {
let id = self.generate_clip_index();
let current_offset = self.rf_mapper.current_offset();
let current_offset = self.current_offset(spatial_id);
let clip_rect = clip_rect.translate(current_offset);
let item = di::DisplayItem::RectClip(di::RectClipDisplayItem {
@ -2045,7 +2014,7 @@ impl DisplayListBuilder {
) -> di::ClipId {
let id = self.generate_clip_index();
let current_offset = self.rf_mapper.current_offset();
let current_offset = self.current_offset(spatial_id);
let clip = di::ComplexClipRegion {
rect: clip.rect.translate(current_offset),
@ -2073,7 +2042,13 @@ impl DisplayListBuilder {
key: di::SpatialTreeItemKey,
) -> di::SpatialId {
let id = self.generate_spatial_index();
let current_offset = self.rf_mapper.current_offset();
let current_offset = self.current_offset(parent_spatial_id);
let parent = self.spatial_nodes[parent_spatial_id.0].clone();
self.add_spatial_node_info(
id,
parent.accumulated_external_scroll_offset,
);
let descriptor = di::SpatialTreeItem::StickyFrame(di::StickyFrameDescriptor {
parent_spatial_id,
@ -2098,7 +2073,7 @@ impl DisplayListBuilder {
pipeline_id: PipelineId,
ignore_missing_pipeline: bool
) {
let current_offset = self.rf_mapper.current_offset();
let current_offset = self.current_offset(space_and_clip.spatial_id);
let bounds = bounds.translate(current_offset);
let clip_rect = clip_rect.translate(current_offset);
@ -2247,6 +2222,35 @@ impl DisplayListBuilder {
},
)
}
/// Retrieve the current offset to allow converting a stacking context
/// relative coordinate to be relative to the owing reference frame,
/// also considering any external scroll offset on the provided
/// spatial node.
fn current_offset(
&mut self,
spatial_id: di::SpatialId,
) -> LayoutVector2D {
// Get the current offset from stacking context <-> reference frame space.
let rf_offset = self.rf_mapper.current_offset();
// Get the external scroll offset, if applicable.
let scroll_offset = self.spatial_nodes[spatial_id.0].accumulated_external_scroll_offset;
rf_offset + scroll_offset
}
/// Add info about a spatial node that is needed during DL building.
fn add_spatial_node_info(
&mut self,
id: di::SpatialId,
accumulated_external_scroll_offset: LayoutVector2D,
) {
self.spatial_nodes.resize(id.0 + 1, SpatialNodeInfo::identity());
let info = &mut self.spatial_nodes[id.0];
info.accumulated_external_scroll_offset = accumulated_external_scroll_offset;
}
}
fn iter_spatial_tree<F>(spatial_tree: &[u8], mut f: F) where F: FnMut(&di::SpatialTreeItem) {

Просмотреть файл

@ -0,0 +1,2 @@
[selection-pseudo-with-decoration-invalidation-001.html]
expected: FAIL