Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync changes from mozilla-central #3826

Merged
merged 11 commits into from Jan 9, 2020

Bug 1607697 - Address unwrap_or_else(callback) and functions in callb…

…ack clippy lints. r=Gankro

I don't think it makes much of a difference but clippy is quite vocal about it.

Differential Revision: https://phabricator.services.mozilla.com/D59114

[wrupdater] From https://hg.mozilla.org/mozilla-central/rev/d70cc2bb33f62aab04ee8a5ae5a086bcee5ab974
  • Loading branch information
nical authored and moz-gfx committed Jan 8, 2020
commit a673e8e0054a0e5ec64195fe2a1d5f656eb21444
@@ -600,7 +600,7 @@ pub fn compute_valid_tiles_if_bounds_change(
return Some(TileRange::zero());
}

let intersection = intersection.unwrap_or(DeviceIntRect::zero());
let intersection = intersection.unwrap_or_else(DeviceIntRect::zero);

let left = prev_rect.min_x() != new_rect.min_x();
let right = prev_rect.max_x() != new_rect.max_x();
@@ -41,6 +41,9 @@ doesn't only contain trivial geometry, it can also store another
[stacking_contexts]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
*/

#![cfg_attr(feature = "cargo-clippy", allow(clippy::unreadable_literal, clippy::new_without_default, clippy::too_many_arguments))]


// Cribbed from the |matches| crate, for simplicity.
macro_rules! matches {
($expression:expr, $($pattern:tt)+) => {
@@ -742,7 +742,7 @@ impl Tile {
self.clipped_rect = self.rect
.intersection(&ctx.local_rect)
.and_then(|r| r.intersection(&ctx.local_clip_rect))
.unwrap_or(PictureRect::zero());
.unwrap_or_else(PictureRect::zero);

self.world_rect = ctx.pic_to_world_mapper
.map(&self.rect)
@@ -938,7 +938,7 @@ impl Tile {
// Ensure that the dirty rect doesn't extend outside the local tile rect.
self.dirty_rect = self.dirty_rect
.intersection(&self.rect)
.unwrap_or(PictureRect::zero());
.unwrap_or_else(PictureRect::zero);

// See if this tile is a simple color, in which case we can just draw
// it as a rect, and avoid allocating a texture surface and drawing it.
@@ -1828,7 +1828,7 @@ impl TileCacheInstance {

let needed_rect_in_pic_space = desired_rect_in_pic_space
.intersection(&pic_rect)
.unwrap_or(PictureRect::zero());
.unwrap_or_else(PictureRect::zero);

let p0 = needed_rect_in_pic_space.origin;
let p1 = needed_rect_in_pic_space.bottom_right();
@@ -3611,7 +3611,7 @@ impl PicturePrimitive {
// the tile rects below for occlusion testing to the relevant area.
let local_clip_rect = tile_cache.local_rect
.intersection(&tile_cache.local_clip_rect)
.unwrap_or(PictureRect::zero());
.unwrap_or_else(PictureRect::zero);

let world_clip_rect = map_pic_to_world
.map(&local_clip_rect)
@@ -1452,7 +1452,7 @@ impl RenderTask {
if let RenderTaskKind::SvgFilter(ref mut filter_task) = self.kind {
match filter_task.info {
SvgFilterInfo::ColorMatrix(ref matrix) => {
let handle = filter_task.extra_gpu_cache_handle.get_or_insert_with(|| GpuCacheHandle::new());
let handle = filter_task.extra_gpu_cache_handle.get_or_insert_with(GpuCacheHandle::new);
if let Some(mut request) = gpu_cache.request(handle) {
for i in 0..5 {
request.push([matrix[i*4], matrix[i*4+1], matrix[i*4+2], matrix[i*4+3]]);
@@ -1461,20 +1461,20 @@ impl RenderTask {
}
SvgFilterInfo::DropShadow(color) |
SvgFilterInfo::Flood(color) => {
let handle = filter_task.extra_gpu_cache_handle.get_or_insert_with(|| GpuCacheHandle::new());
let handle = filter_task.extra_gpu_cache_handle.get_or_insert_with(GpuCacheHandle::new);
if let Some(mut request) = gpu_cache.request(handle) {
request.push(color.to_array());
}
}
SvgFilterInfo::ComponentTransfer(ref data) => {
let handle = filter_task.extra_gpu_cache_handle.get_or_insert_with(|| GpuCacheHandle::new());
let handle = filter_task.extra_gpu_cache_handle.get_or_insert_with(GpuCacheHandle::new);
if let Some(request) = gpu_cache.request(handle) {
data.update(request);
}
}
SvgFilterInfo::Composite(ref operator) => {
if let CompositeOperator::Arithmetic(k_vals) = operator {
let handle = filter_task.extra_gpu_cache_handle.get_or_insert_with(|| GpuCacheHandle::new());
let handle = filter_task.extra_gpu_cache_handle.get_or_insert_with(GpuCacheHandle::new);
if let Some(mut request) = gpu_cache.request(handle) {
request.push(*k_vals);
}
@@ -937,7 +937,7 @@ impl ResourceCache {
tile,
).into();

rect.intersection(&tile_rect).unwrap_or(DeviceIntRect::zero())
rect.intersection(&tile_rect).unwrap_or_else(DeviceIntRect::zero)
})
}
(None, Some(..)) => DirtyRect::All,
@@ -1020,7 +1020,7 @@ impl ResourceCache {

match (image.valid_tiles_after_bounds_change, valid_tiles_after_bounds_change) {
(Some(old), Some(ref mut new)) => {
*new = new.intersection(&old).unwrap_or(TileRange::zero());
*new = new.intersection(&old).unwrap_or_else(TileRange::zero);
}
(Some(old), None) => {
valid_tiles_after_bounds_change = Some(old);
@@ -664,7 +664,7 @@ impl<'a> SceneBuilder<'a> {
scroll_root,
slice.prim_list,
background_color,
slice.shared_clips.unwrap_or(Vec::new()),
slice.shared_clips.unwrap_or_else(Vec::new),
&mut self.interners,
&mut self.prim_store,
&mut self.clip_store,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.