Bug 1607697 - Address clippy lints about nested branches. r=Gankro
authorNicolas Silva <nsilva@mozilla.com>
Fri, 10 Jan 2020 10:12:16 +0000
changeset 509684 6158f0a8c5b6b684298a37118bf16f6b4923f407
parent 509683 966cc16c3feb7ec46352e9ecff3fd65a3723ab8f
child 509685 596d83b7671291fb344924f7c434c428f6f28b04
push id37002
push userccoroiu@mozilla.com
push dateFri, 10 Jan 2020 21:49:10 +0000
treeherdermozilla-central@7fa78b1baf59 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGankro
bugs1607697
milestone74.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1607697 - Address clippy lints about nested branches. r=Gankro Differential Revision: https://phabricator.services.mozilla.com/D59115
gfx/wr/webrender/src/picture.rs
gfx/wr/webrender/src/prim_store/mod.rs
gfx/wr/webrender/src/render_backend.rs
gfx/wr/webrender/src/renderer.rs
gfx/wr/webrender/src/resource_cache.rs
gfx/wr/webrender/src/scene_builder_thread.rs
--- a/gfx/wr/webrender/src/picture.rs
+++ b/gfx/wr/webrender/src/picture.rs
@@ -2004,20 +2004,19 @@ impl TileCacheInstance {
         let clip_instances = &clip_store
             .clip_node_instances[prim_clip_chain.clips_range.to_range()];
         for clip_instance in clip_instances {
             prim_info.clips.push(clip_instance.handle.uid());
 
             // If the clip has the same spatial node, the relative transform
             // will always be the same, so there's no need to depend on it.
             let clip_node = &data_stores.clip[clip_instance.handle];
-            if clip_node.item.spatial_node_index != self.spatial_node_index {
-                if !prim_info.spatial_nodes.contains(&clip_node.item.spatial_node_index) {
-                    prim_info.spatial_nodes.push(clip_node.item.spatial_node_index);
-                }
+            if clip_node.item.spatial_node_index != self.spatial_node_index
+                && !prim_info.spatial_nodes.contains(&clip_node.item.spatial_node_index) {
+                prim_info.spatial_nodes.push(clip_node.item.spatial_node_index);
             }
         }
 
         // Certain primitives may select themselves to be a backdrop candidate, which is
         // then applied below.
         let mut backdrop_candidate = None;
 
         // For pictures, we don't (yet) know the valid clip rect, so we can't correctly
@@ -2118,20 +2117,20 @@ impl TileCacheInstance {
                     // text run doesn't get subpx for other reasons (e.g. glyph size).
                     let subpx_requested = match run_data.font.render_mode {
                         FontRenderMode::Subpixel => true,
                         FontRenderMode::Alpha | FontRenderMode::Mono => false,
                     };
 
                     // If a text run is on a child surface, the subpx mode will be
                     // correctly determined as we recurse through pictures in take_context.
-                    if on_picture_surface && subpx_requested {
-                        if !self.backdrop.rect.contains_rect(&pic_clip_rect) {
-                            self.subpixel_mode = SubpixelMode::Deny;
-                        }
+                    if on_picture_surface
+                        && subpx_requested
+                        && !self.backdrop.rect.contains_rect(&pic_clip_rect) {
+                        self.subpixel_mode = SubpixelMode::Deny;
                     }
                 }
             }
             PrimitiveInstanceKind::Clear { .. } => {
                 backdrop_candidate = Some(BackdropKind::Clear);
             }
             PrimitiveInstanceKind::LineDecoration { .. } |
             PrimitiveInstanceKind::NormalBorder { .. } |
@@ -2170,23 +2169,23 @@ impl TileCacheInstance {
 
                         prim_spatial_node.coordinate_system_id == surface_spatial_node.coordinate_system_id
                     };
 
                     same_coord_system && on_picture_surface
                 }
             };
 
-            if is_suitable_backdrop {
-                if !prim_clip_chain.needs_mask && pic_clip_rect.contains_rect(&self.backdrop.rect) {
-                    self.backdrop = BackdropInfo {
-                        rect: pic_clip_rect,
-                        kind: backdrop_candidate,
-                    }
-                }
+            if is_suitable_backdrop
+                && !prim_clip_chain.needs_mask
+                && pic_clip_rect.contains_rect(&self.backdrop.rect) {
+                self.backdrop = BackdropInfo {
+                    rect: pic_clip_rect,
+                    kind: backdrop_candidate,
+                };
             }
         }
 
         // Record any new spatial nodes in the used list.
         self.used_spatial_nodes.extend(&prim_info.spatial_nodes);
 
         // Truncate the lengths of dependency arrays to the max size we can handle.
         // Any arrays this size or longer will invalidate every frame.
@@ -4400,23 +4399,21 @@ impl PicturePrimitive {
 
             let mut surface_rect = surface.rect * Scale::new(1.0);
 
             // Pop this surface from the stack
             let surface_index = state.pop_surface();
             debug_assert_eq!(surface_index, raster_config.surface_index);
 
             // Check if any of the surfaces can't be rasterized in local space but want to.
-            if raster_config.establishes_raster_root {
-                if surface_rect.size.width > MAX_SURFACE_SIZE ||
-                    surface_rect.size.height > MAX_SURFACE_SIZE
-                {
-                    raster_config.establishes_raster_root = false;
-                    state.are_raster_roots_assigned = false;
-                }
+            if raster_config.establishes_raster_root
+                && (surface_rect.size.width > MAX_SURFACE_SIZE
+                    || surface_rect.size.height > MAX_SURFACE_SIZE) {
+                raster_config.establishes_raster_root = false;
+                state.are_raster_roots_assigned = false;
             }
 
             // Set the estimated and precise local rects. The precise local rect
             // may be changed again during frame visibility.
             self.estimated_local_rect = surface_rect;
             self.precise_local_rect = surface_rect;
 
             // Drop shadows draw both a content and shadow rect, so need to expand the local
--- a/gfx/wr/webrender/src/prim_store/mod.rs
+++ b/gfx/wr/webrender/src/prim_store/mod.rs
@@ -2013,20 +2013,18 @@ impl PrimitiveStore {
                         // so ensure that is kept up to date here.
                         // TODO(gw): It's unfortunate that the prim origin is duplicated
                         //           this way. In future, we could perhaps just store the
                         //           size in the picture primitive, to that there isn't
                         //           any duplicated data.
                         let pic = &self.pictures[pic_index.0];
                         prim_instance.prim_origin = pic.precise_local_rect.origin;
 
-                        if prim_instance.is_chased() {
-                            if pic.estimated_local_rect != pic.precise_local_rect {
-                                println!("\testimate {:?} adjusted to {:?}", pic.estimated_local_rect, pic.precise_local_rect);
-                            }
+                        if prim_instance.is_chased() && pic.estimated_local_rect != pic.precise_local_rect {
+                            println!("\testimate {:?} adjusted to {:?}", pic.estimated_local_rect, pic.precise_local_rect);
                         }
 
                         let mut shadow_rect = pic.precise_local_rect;
                         match pic.raster_config {
                             Some(ref rc) => match rc.composite_mode {
                                 // If we have a drop shadow filter, we also need to include the shadow in
                                 // our shadowed local rect for the purpose of calculating the size of the
                                 // picture.
@@ -2248,19 +2246,21 @@ impl PrimitiveStore {
                             PrimitiveInstanceKind::Clear { .. } => debug_colors::CYAN,
                             PrimitiveInstanceKind::Backdrop { .. } => debug_colors::MEDIUMAQUAMARINE,
                         };
                         if debug_color.a != 0.0 {
                             let debug_rect = clipped_world_rect * frame_context.global_device_pixel_scale;
                             frame_state.scratch.push_debug_rect(debug_rect, debug_color, debug_color.scale_alpha(0.5));
                         }
                     } else if frame_context.debug_flags.contains(::api::DebugFlags::OBSCURE_IMAGES) {
-                        if matches!(prim_instance.kind, PrimitiveInstanceKind::Image { .. } |
-                                                        PrimitiveInstanceKind::YuvImage { .. })
-                        {
+                        let is_image = matches!(
+                            prim_instance.kind,
+                            PrimitiveInstanceKind::Image { .. } | PrimitiveInstanceKind::YuvImage { .. }
+                        );
+                        if is_image {
                             // We allow "small" images, since they're generally UI elements.
                             let rect = clipped_world_rect * frame_context.global_device_pixel_scale;
                             if rect.size.width > 70.0 && rect.size.height > 70.0 {
                                 frame_state.scratch.push_debug_rect(rect, debug_colors::PURPLE, debug_colors::PURPLE);
                             }
                         }
                     }
 
--- a/gfx/wr/webrender/src/render_backend.rs
+++ b/gfx/wr/webrender/src/render_backend.rs
@@ -451,21 +451,20 @@ impl Document {
                         let test = HitTest::new(None, cursor, HitTestFlags::empty());
                         hit_tester.find_node_under_point(test)
                     }
                     None => {
                         None
                     }
                 };
 
-                if self.hit_tester.is_some() {
-                    if self.scroll_nearest_scrolling_ancestor(delta, node_index) {
-                        self.hit_tester_is_valid = false;
-                        self.frame_is_valid = false;
-                    }
+                if self.hit_tester.is_some()
+                    && self.scroll_nearest_scrolling_ancestor(delta, node_index) {
+                    self.hit_tester_is_valid = false;
+                    self.frame_is_valid = false;
                 }
 
                 return DocumentOps {
                     // TODO: Does it make sense to track this as a scrolling even if we
                     // ended up not scrolling anything?
                     scroll: true,
                     ..DocumentOps::nop()
                 };
--- a/gfx/wr/webrender/src/renderer.rs
+++ b/gfx/wr/webrender/src/renderer.rs
@@ -3126,17 +3126,17 @@ impl Renderer {
                 self.draw_frame(
                     frame,
                     device_size,
                     cpu_frame_id,
                     &mut results,
                     doc_index == 0,
                 );
 
-                if let Some(_) = device_size {
+                if device_size.is_some() {
                     self.draw_frame_debug_items(&frame.debug_items);
                 }
                 if self.debug_flags.contains(DebugFlags::PROFILER_DBG) {
                     frame_profiles.push(frame.profile_counters.clone());
                 }
 
                 let dirty_regions =
                     mem::replace(&mut frame.recorded_dirty_regions, Vec::new());
--- a/gfx/wr/webrender/src/resource_cache.rs
+++ b/gfx/wr/webrender/src/resource_cache.rs
@@ -781,27 +781,25 @@ impl ResourceCache {
                         };
                         if let Some(entry) = entries.try_get_mut(&cached_key) {
                             entry.dirty_rect = DirtyRect::All;
                         }
                     }
                     _ => {}
                 }
 
+            } else if let RasterizedBlob::NonTiled(ref mut queue) = *image {
+                // If our new rasterized rect overwrites items in the queue, discard them.
+                queue.retain(|img| {
+                    !data.rasterized_rect.contains_rect(&img.rasterized_rect)
+                });
+
+                queue.push(data);
             } else {
-                if let RasterizedBlob::NonTiled(ref mut queue) = *image {
-                    // If our new rasterized rect overwrites items in the queue, discard them.
-                    queue.retain(|img| {
-                        !data.rasterized_rect.contains_rect(&img.rasterized_rect)
-                    });
-
-                    queue.push(data);
-                } else {
-                    *image = RasterizedBlob::NonTiled(vec![data]);
-                }
+                *image = RasterizedBlob::NonTiled(vec![data]);
             }
         }
     }
 
     pub fn add_font_template(&mut self, font_key: FontKey, template: FontTemplate) {
         // Push the new font to the font renderer, and also store
         // it locally for glyph metric requests.
         self.glyph_rasterizer.add_font(font_key, template.clone());
--- a/gfx/wr/webrender/src/scene_builder_thread.rs
+++ b/gfx/wr/webrender/src/scene_builder_thread.rs
@@ -668,20 +668,18 @@ impl SceneBuilderThread {
                     resume_tx.send(()).ok();
                 },
                 _ => (),
             };
         } else if !have_resources_updates.is_empty() {
             if let &Some(ref hooks) = &self.hooks {
                 hooks.post_resource_update(&have_resources_updates);
             }
-        } else {
-            if let &Some(ref hooks) = &self.hooks {
-                hooks.post_empty_scene_build();
-            }
+        } else if let Some(ref hooks) = self.hooks {
+            hooks.post_empty_scene_build();
         }
     }
 
     /// Reports CPU heap memory used by the SceneBuilder.
     fn report_memory(&mut self) -> MemoryReport {
         let ops = self.size_of_ops.as_mut().unwrap();
         let mut report = MemoryReport::default();
         for doc in self.documents.values() {