Chromium Code Reviews| Index: ui/views/bubble/bubble_border.cc |
| diff --git a/ui/views/bubble/bubble_border.cc b/ui/views/bubble/bubble_border.cc |
| index 673862d363929f1b43f9b8de146c5fbfbbfdf91e..16e5e1ac86f45777a38dcd4c1337623d4a086323 100644 |
| --- a/ui/views/bubble/bubble_border.cc |
| +++ b/ui/views/bubble/bubble_border.cc |
| @@ -363,11 +363,14 @@ void BubbleBorder::Paint(const views::View& view, gfx::Canvas* canvas) { |
| gfx::Insets BubbleBorder::GetInsets() const { |
| if (UseMd()) { |
| - gfx::Insets blur(kLargeShadowBlur); |
| - gfx::Insets offset(-kLargeShadowVerticalOffset, 0, |
| - kLargeShadowVerticalOffset, 0); |
| - gfx::Insets border(kBorderThicknessDip); |
| - return blur + offset; |
| + if (shadow_ == NO_ASSETS) |
| + return gfx::Insets(); |
| + |
| + gfx::Insets blur(kLargeShadowBlur); |
| + gfx::Insets offset(-kLargeShadowVerticalOffset, 0, |
| + kLargeShadowVerticalOffset, 0); |
| + gfx::Insets border(kBorderThicknessDip); |
| + return blur + offset; |
| } |
| // The insets contain the stroke and shadow pixels outside the bubble fill. |
| @@ -505,7 +508,19 @@ void BubbleBorder::DrawArrow(gfx::Canvas* canvas, |
| canvas->DrawPath(path, paint); |
| } |
| +SkRRect BubbleBorder::GetClientRect(const View& view) const { |
| + // Clip out a round rect so the fill and shadow don't draw over the contents |
|
msw
2016/11/22 18:27:22
nit: leave this comment in PaintMd (and PaintNoAss
tapted
2016/11/22 23:38:09
Done. Updated the header comment for GetClientRect
|
| + // of the bubble. |
| + gfx::RectF bounds(view.GetLocalBounds()); |
| + bounds.Inset(GetInsets()); |
| + return SkRRect::MakeRectXY(gfx::RectFToSkRect(bounds), |
| + GetBorderCornerRadius(), GetBorderCornerRadius()); |
| +} |
| + |
| void BubbleBorder::PaintMd(const View& view, gfx::Canvas* canvas) { |
| + if (shadow_ == NO_ASSETS) |
| + return PaintNoAssets(view, canvas); |
| + |
| gfx::ScopedCanvas scoped(canvas); |
| SkPaint paint; |
| @@ -521,13 +536,7 @@ void BubbleBorder::PaintMd(const View& view, gfx::Canvas* canvas) { |
| paint.setColor(SkColorSetA(SK_ColorBLACK, 0x26)); |
| paint.setAntiAlias(true); |
| - gfx::RectF bounds(view.GetLocalBounds()); |
| - bounds.Inset(GetInsets()); |
| - // Clip out a round rect so the fill and shadow don't draw over the contents |
| - // of the bubble. |
| - SkRRect clip_r_rect = |
| - SkRRect::MakeRectXY(gfx::RectFToSkRect(bounds), GetBorderCornerRadius(), |
| - GetBorderCornerRadius()); |
| + SkRRect clip_r_rect = GetClientRect(view); |
|
msw
2016/11/22 18:27:22
optional nit: rename |r_rect| and nix the copy bel
tapted
2016/11/22 23:38:09
Done.
|
| canvas->sk_canvas()->clipRRect(clip_r_rect, SkRegion::kDifference_Op, |
| true /*doAntiAlias*/); |
| @@ -539,6 +548,13 @@ void BubbleBorder::PaintMd(const View& view, gfx::Canvas* canvas) { |
| canvas->sk_canvas()->drawRRect(r_rect, paint); |
| } |
| +void BubbleBorder::PaintNoAssets(const View& view, gfx::Canvas* canvas) { |
| + gfx::ScopedCanvas scoped(canvas); |
| + canvas->sk_canvas()->clipRRect(GetClientRect(view), SkRegion::kDifference_Op, |
| + true /*doAntiAlias*/); |
| + canvas->sk_canvas()->drawColor(SK_ColorTRANSPARENT, SkBlendMode::kSrc); |
| +} |
| + |
| internal::BorderImages* BubbleBorder::GetImagesForTest() const { |
| return images_; |
| } |