CrOS shelf: extend background to handle overdrag in any condition

Before this CL, we already extend the shelf's opaque background a
bit off screen, so that "over-drag" events don't appear to be tearing
off the shelf from the screen edge.

This CL extends this behavior to "fullscreen" mode (shelf is a little
darker, and has square corners) so that there too we prevent a tearing
effect.

Bug: 911880
Change-Id: I0e91c83824417027060c75ccdd8fdcf1bdb3ffb5
Reviewed-on: https://chromium-review.googlesource.com/c/1382446
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Manu Cornet <manucornet@chromium.org>
Cr-Commit-Position: refs/heads/master@{#617514}
diff --git a/ash/shelf/shelf_widget.cc b/ash/shelf/shelf_widget.cc
index 551cdd4..5014171 100644
--- a/ash/shelf/shelf_widget.cc
+++ b/ash/shelf/shelf_widget.cc
@@ -223,23 +223,27 @@
   if (!opaque_background_.visible())
     opaque_background_.SetVisible(true);
 
+  // Extend the opaque layer a little bit to handle "overshoot" gestures
+  // gracefully (the user drags the shelf further than it can actually go).
+  // That way:
+  // 1) When the shelf has rounded corners, only two of them are visible,
+  // 2) Even when the shelf is squared, it doesn't tear off the screen edge
+  // when dragged away.
+  // To achieve this, we extend the layer in the same direction where the shelf
+  // is aligned (downwards for a bottom shelf, etc.).
+  const int radius = kShelfRoundedCornerRadius;
+  const int safety_margin = 3 * radius;
+  opaque_background_bounds.Inset(
+      -shelf->SelectValueForShelfAlignment(0, safety_margin, 0), 0,
+      -shelf->SelectValueForShelfAlignment(0, 0, safety_margin),
+      -shelf->SelectValueForShelfAlignment(safety_margin, 0, 0));
+
   // Show rounded corners except in maximized and split modes.
   if (background_type == SHELF_BACKGROUND_MAXIMIZED ||
       background_type == SHELF_BACKGROUND_SPLIT_VIEW) {
     mask_ = nullptr;
     opaque_background_.SetMaskLayer(nullptr);
   } else {
-    const int radius = kShelfRoundedCornerRadius;
-    // Extend the opaque layer a little bit so that only two rounded
-    // corners are visible, even when gestures to show the shelf "overshoot"
-    // the standard shelf size a little bit. Extend the layer in the same
-    // direction where the shelf is aligned (downwards for a bottom
-    // shelf, etc.).
-    const int safety_margin = 3 * radius;
-    opaque_background_bounds.Inset(
-        -shelf->SelectValueForShelfAlignment(0, safety_margin, 0), 0,
-        -shelf->SelectValueForShelfAlignment(0, 0, safety_margin),
-        -shelf->SelectValueForShelfAlignment(safety_margin, 0, 0));
     if (!mask_) {
       mask_ = views::Painter::CreatePaintedLayer(
           views::Painter::CreateSolidRoundRectPainter(SK_ColorBLACK, radius));