diff options
author | Martin Robinson <mrobinson@igalia.com> | 2023-09-09 19:43:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-09 17:43:09 +0000 |
commit | 56976efaa2ff0f11d954625c98841517830a5ae8 (patch) | |
tree | 1f8747e78c90cb71337da8d9788430fcfac7d244 | |
parent | 711dbbd4afe161fc334db198357d814e99e5ac57 (diff) | |
download | servo-56976efaa2ff0f11d954625c98841517830a5ae8.tar.gz servo-56976efaa2ff0f11d954625c98841517830a5ae8.zip |
Layout 2013: Don't make gradient display items for zero-sized gradients (#30321)
Before WebRender would ignore these, but newer version of WebRender have
issues with them. This change simply prevents legacy layout from
creating display items for these types of gradients. This is already the
behavior of non-legacy layout.
-rw-r--r-- | components/layout/display_list/background.rs | 17 | ||||
-rw-r--r-- | components/layout/display_list/builder.rs | 12 |
2 files changed, 22 insertions, 7 deletions
diff --git a/components/layout/display_list/background.rs b/components/layout/display_list/background.rs index 60fd72fd4c3..4f37dcf25c3 100644 --- a/components/layout/display_list/background.rs +++ b/components/layout/display_list/background.rs @@ -138,8 +138,10 @@ pub fn clip( /// Determines where to place an element background image or gradient. /// -/// Photos have their resolution as intrinsic size while gradients have +/// Images have their resolution as intrinsic size while gradients have /// no intrinsic size. +/// +/// Return `None` if the background size is zero, otherwise a [`BackgroundPlacement`]. pub fn placement( bg: &Background, viewport_size: Size2D<Au>, @@ -149,7 +151,7 @@ pub fn placement( border_padding: SideOffsets2D<Au>, border_radii: BorderRadius, index: usize, -) -> BackgroundPlacement { +) -> Option<BackgroundPlacement> { let bg_attachment = *get_cyclic(&bg.background_attachment.0, index); let bg_clip = *get_cyclic(&bg.background_clip.0, index); let bg_origin = *get_cyclic(&bg.background_origin.0, index); @@ -180,6 +182,9 @@ pub fn placement( }; let mut tile_size = compute_background_image_size(bg_size, bounds.size, intrinsic_size); + if tile_size.is_empty() { + return None; + } let mut tile_spacing = Size2D::zero(); let own_position = bounds.size - tile_size; @@ -206,14 +211,18 @@ pub fn placement( clip_rect.size.height, ); - BackgroundPlacement { + if tile_size.is_empty() { + return None; + } + + Some(BackgroundPlacement { bounds, tile_size, tile_spacing, clip_rect, clip_radii, fixed, - } + }) } fn tile_image_round( diff --git a/components/layout/display_list/builder.rs b/components/layout/display_list/builder.rs index e6980ebdd6a..bdd6142d781 100644 --- a/components/layout/display_list/builder.rs +++ b/components/layout/display_list/builder.rs @@ -831,9 +831,10 @@ impl Fragment { index, ); - if placement.tile_size.is_empty() { - return; - } + let placement = match placement { + Some(placement) => placement, + None => return, + }; state.clipping_and_scrolling_scope(|state| { if !placement.clip_radii.is_zero() { @@ -953,6 +954,11 @@ impl Fragment { index, ); + let placement = match placement { + Some(placement) => placement, + None => return, + }; + state.clipping_and_scrolling_scope(|state| { if !placement.clip_radii.is_zero() { let clip_id = |