Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1521)

Unified Diff: ui/wm/core/shadow.cc

Issue 2555373004: Apply new MD shadows to CrOS tray bubbles. (Closed)
Patch Set: comment Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/wm/core/shadow.cc
diff --git a/ui/wm/core/shadow.cc b/ui/wm/core/shadow.cc
index 83190954208d81601426d32d89684697b7b71fb6..5bdd69460a370259955cdf5280fdc0d5389b8a82 100644
--- a/ui/wm/core/shadow.cc
+++ b/ui/wm/core/shadow.cc
@@ -153,15 +153,6 @@ void Shadow::OnImplicitAnimationsCompleted() {
void Shadow::UpdateImagesForStyle() {
const ShadowDetails& details = GetDetailsForElevation(ElevationForStyle());
shadow_layer_->UpdateNinePatchLayerImage(details.ninebox_image);
- // The ninebox grid is defined in terms of the image size. The shadow blurs in
- // both inward and outward directions from the edge of the contents, so the
- // aperture goes further inside the image than the shadow margins (which
- // represent exterior blur).
- gfx::Rect aperture(details.ninebox_image.size());
- gfx::Insets blur_region = gfx::ShadowValue::GetBlurRegion(details.values) +
- gfx::Insets(kRoundedCornerRadius);
- aperture.Inset(blur_region);
- shadow_layer_->UpdateNinePatchLayerAperture(aperture);
UpdateLayerBounds();
}
@@ -193,6 +184,21 @@ void Shadow::UpdateLayerBounds() {
int border_y = border_h * blur_region.top() / blur_region.height();
shadow_layer_->UpdateNinePatchLayerBorder(
gfx::Rect(border_x, border_y, border_w, border_h));
+
+ // The ninebox grid is defined in terms of the image size. The shadow blurs in
+ // both inward and outward directions from the edge of the contents, so the
+ // aperture goes further inside the image than the shadow margins (which
+ // represent exterior blur).
+ gfx::Rect aperture(details.ninebox_image.size());
+ // The insets for the aperture are nominally |blur_region| but we need to
+ // resize them if the contents are too small.
+ // TODO(estade): by cutting out parts of ninebox, we lose the smooth
+ // horizontal or vertical transition. This isn't very noticeable, but we may
+ // need to address it by using a separate shadow layer for each ShadowValue,
+ // by adjusting the shadow for very small windows, or other means.
+ aperture.Inset(gfx::Insets(border_y, border_x, border_h - border_y,
+ border_w - border_x));
+ shadow_layer_->UpdateNinePatchLayerAperture(aperture);
}
int Shadow::ElevationForStyle() {

Powered by Google App Engine
This is Rietveld 408576698