diff options
Diffstat (limited to 'components/layout')
-rw-r--r-- | components/layout/display_list/builder.rs | 36 | ||||
-rw-r--r-- | components/layout/display_list/conversions.rs | 2 | ||||
-rw-r--r-- | components/layout/display_list/items.rs | 8 | ||||
-rw-r--r-- | components/layout/display_list/webrender_helpers.rs | 37 |
4 files changed, 29 insertions, 54 deletions
diff --git a/components/layout/display_list/builder.rs b/components/layout/display_list/builder.rs index 6decaf26011..0e799f4b66f 100644 --- a/components/layout/display_list/builder.rs +++ b/components/layout/display_list/builder.rs @@ -46,11 +46,10 @@ use style::values::specified::ui::CursorKind; use style::values::RGBA; use style_traits::{CSSPixel, ToCss}; use webrender_api::units::{LayoutRect, LayoutTransform, LayoutVector2D}; -use webrender_api::{ - self, BorderDetails, BorderRadius, BorderSide, BoxShadowClipMode, ColorF, ColorU, - ExternalScrollId, FilterOp, GlyphInstance, ImageRendering, LineStyle, NinePatchBorder, - NinePatchBorderSource, NormalBorder, PropertyBinding, ScrollSensitivity, StickyOffsetBounds, -}; +use webrender_api::{self, BorderDetails, BorderRadius, BorderSide, BoxShadowClipMode, ColorF}; +use webrender_api::{ColorU, ExternalScrollId, FilterOp, GlyphInstance, ImageRendering, LineStyle}; +use webrender_api::{NinePatchBorder, NinePatchBorderSource, NormalBorder, PropertyBinding}; +use webrender_api::{ScrollSensitivity, StickyOffsetBounds}; use crate::block::BlockFlow; use crate::context::LayoutContext; @@ -2113,7 +2112,7 @@ impl Fragment { } // Text - let (largest_advance, mut glyphs) = convert_text_run_to_glyphs( + let mut glyphs = convert_text_run_to_glyphs( text_fragment.run.clone(), text_fragment.range, baseline_origin, @@ -2127,22 +2126,6 @@ impl Fragment { }; state.indexable_text.insert(self.node, indexable_text); - // FIXME(mrobinson, #30313): This is a serious hack to enable a WebRender upgrade. - // Servo is not calculating glyph boundaries and is instead relying on the - // measured size of the content box here -- which is based on the positioning - // of the text. The issue is that glyphs can extend beyond the boundaries - // established by their brush origin and advance. Servo should be measuring - // the ink boundary rectangle based on the brush origin and the glyph extents - // instead. - // - // We don't yet have that information here, so in the meantime simply expand - // the boundary rectangle of the text by the largest character advance of the - // painted text run in all directions. This is used as a heuristic for a - // reasonable amount of "fudge" space to include the entire text run. - let inflated_bounds = stacking_relative_content_box - .inflate(largest_advance, largest_advance) - .to_layout(); - // Process glyphs in chunks to avoid overflowing WebRender's internal limits (#17230). while !glyphs.is_empty() { let mut rest_of_glyphs = vec![]; @@ -2154,7 +2137,7 @@ impl Fragment { state.add_display_item(DisplayItem::Text(CommonDisplayItem::with_data( base.clone(), webrender_api::TextDisplayItem { - bounds: inflated_bounds, + bounds: stacking_relative_content_box.to_layout(), common: items::empty_common_item_properties(), font_key: text_fragment.run.font_key, color: text_color.to_layout(), @@ -3025,8 +3008,7 @@ fn convert_text_run_to_glyphs( text_run: Arc<TextRun>, range: Range<ByteIndex>, mut origin: Point2D<Au>, -) -> (Au, Vec<GlyphInstance>) { - let mut largest_advance = Au(0); +) -> Vec<GlyphInstance> { let mut glyphs = vec![]; for slice in text_run.natural_word_slices_in_visual_order(&range) { @@ -3036,8 +3018,6 @@ fn convert_text_run_to_glyphs( } else { glyph.advance() }; - largest_advance = largest_advance.max(glyph.advance()); - if !slice.glyphs.is_whitespace() { let glyph_offset = glyph.offset().unwrap_or(Point2D::zero()); let point = origin + glyph_offset.to_vector(); @@ -3050,7 +3030,7 @@ fn convert_text_run_to_glyphs( origin.x += glyph_advance; } } - (largest_advance, glyphs) + return glyphs; } pub struct IndexableTextItem { diff --git a/components/layout/display_list/conversions.rs b/components/layout/display_list/conversions.rs index d081f40a10f..ecf20be3869 100644 --- a/components/layout/display_list/conversions.rs +++ b/components/layout/display_list/conversions.rs @@ -39,7 +39,7 @@ impl ToLayout for Filter { type Type = wr::FilterOp; fn to_layout(&self) -> Self::Type { match *self { - Filter::Blur(radius) => wr::FilterOp::Blur(radius.px(), radius.px()), + Filter::Blur(radius) => wr::FilterOp::Blur(radius.px()), Filter::Brightness(amount) => wr::FilterOp::Brightness(amount.0), Filter::Contrast(amount) => wr::FilterOp::Contrast(amount.0), Filter::Grayscale(amount) => wr::FilterOp::Grayscale(amount.0), diff --git a/components/layout/display_list/items.rs b/components/layout/display_list/items.rs index 58a90447849..53e08fff1cb 100644 --- a/components/layout/display_list/items.rs +++ b/components/layout/display_list/items.rs @@ -30,10 +30,11 @@ pub use style::dom::OpaqueNode; use webrender_api as wr; use webrender_api::units::{LayoutPixel, LayoutRect, LayoutTransform}; use webrender_api::{ - BorderRadius, ClipChainId, ClipId, ClipMode, CommonItemProperties, ComplexClipRegion, - ExternalScrollId, FilterOp, GlyphInstance, GradientStop, ImageKey, MixBlendMode, - PrimitiveFlags, ScrollSensitivity, Shadow, SpatialId, StickyOffsetBounds, TransformStyle, + BorderRadius, ClipId, ClipMode, CommonItemProperties, ComplexClipRegion, ExternalScrollId, + FilterOp, GlyphInstance, GradientStop, ImageKey, MixBlendMode, PrimitiveFlags, + ScrollSensitivity, Shadow, SpatialId, StickyOffsetBounds, TransformStyle, }; +use wr::ClipChainId; /// The factor that we multiply the blur radius by in order to inflate the boundaries of display /// items that involve a blur. This ensures that the display item boundaries include all the ink. @@ -495,6 +496,7 @@ pub fn empty_common_item_properties() -> CommonItemProperties { clip_rect: LayoutRect::max_rect(), clip_id: ClipId::root(wr::PipelineId::dummy()), spatial_id: SpatialId::root_scroll_node(wr::PipelineId::dummy()), + hit_info: None, flags: PrimitiveFlags::empty(), } } diff --git a/components/layout/display_list/webrender_helpers.rs b/components/layout/display_list/webrender_helpers.rs index 1e584c0c06f..a8130a15936 100644 --- a/components/layout/display_list/webrender_helpers.rs +++ b/components/layout/display_list/webrender_helpers.rs @@ -49,7 +49,6 @@ impl<'a> ClipScrollState<'a> { let root_clip_chain = builder.define_clip_chain(None, [ClipId::root(state.compositor_info.pipeline_id)]); - state.add_clip_node_mapping(0, root_clip_chain); state.add_clip_node_mapping(1, root_clip_chain); @@ -115,7 +114,11 @@ impl DisplayList { epoch: Epoch, ) -> (DisplayListBuilder, CompositorDisplayListInfo, IsContentful) { let webrender_pipeline = pipeline_id.to_webrender(); - let mut builder = DisplayListBuilder::new(webrender_pipeline); + let mut builder = DisplayListBuilder::with_capacity( + webrender_pipeline, + self.bounds().size, + 1024 * 1024, // 1 MB of space + ); let content_size = self.bounds().size; let mut state = ClipScrollState::new( @@ -153,16 +156,17 @@ impl DisplayItem { let internal_clip_id = clip_and_scroll_indices .clipping .unwrap_or(clip_and_scroll_indices.scrolling); - let current_clip_chain_id = state.webrender_clip_id_for_index(internal_clip_id.to_index()); + let current_clip_id = state.webrender_clip_id_for_index(internal_clip_id.to_index()); let hit_test_bounds = self.bounds().intersection(&self.base().clip_rect); let build_common_item_properties = |base: &BaseDisplayItem| { CommonItemProperties { clip_rect: base.clip_rect, spatial_id: current_scroll_node_id.spatial_id, - clip_id: ClipId::ClipChain(current_clip_chain_id), + clip_id: ClipId::ClipChain(current_clip_id), // TODO(gw): Make use of the WR backface visibility functionality. flags: PrimitiveFlags::default(), + hit_info: None, } }; @@ -183,15 +187,10 @@ impl DisplayItem { current_scroll_node_id, ); - builder.push_hit_test( - &CommonItemProperties { - clip_rect: bounds, - spatial_id: current_scroll_node_id.spatial_id, - clip_id: ClipId::ClipChain(current_clip_chain_id), - flags: PrimitiveFlags::default(), - }, - (hit_test_index as u64, 0u16), - ); + let mut common = build_common_item_properties(base); + common.hit_info = Some((hit_test_index as u64, 0u16)); + common.clip_rect = bounds; + builder.push_hit_test(&common); }; match *self { @@ -303,13 +302,7 @@ impl DisplayItem { scrolling_relative_to: None, }, ), - (Some(t), None) => ( - t, - ReferenceFrameKind::Transform { - is_2d_scale_translation: false, - should_snap: false, - }, - ), + (Some(t), None) => (t, ReferenceFrameKind::Transform), (Some(t), Some(p)) => ( p.then(&t), ReferenceFrameKind::Perspective { @@ -328,7 +321,7 @@ impl DisplayItem { ); let index = frame_index.to_index(); - state.add_clip_node_mapping(index, current_clip_chain_id); + state.add_clip_node_mapping(index, current_clip_id); state.register_spatial_node( index, new_spatial_id, @@ -415,7 +408,7 @@ impl DisplayItem { let spatial_id = builder .define_scroll_frame( &parent_space_and_clip_info, - external_id, + Some(external_id), node.content_rect, item_rect, scroll_sensitivity, |