Chromium Code Reviews| Index: chrome/browser/ui/views/autofill/card_unmask_prompt_views.cc |
| diff --git a/chrome/browser/ui/views/autofill/card_unmask_prompt_views.cc b/chrome/browser/ui/views/autofill/card_unmask_prompt_views.cc |
| index 5d7a6c0980a4ed647dd463a3de4e474efde2f593..fce3f57021aebfad7364c7924d562200d5a24774 100644 |
| --- a/chrome/browser/ui/views/autofill/card_unmask_prompt_views.cc |
| +++ b/chrome/browser/ui/views/autofill/card_unmask_prompt_views.cc |
| @@ -22,6 +22,7 @@ |
| #include "ui/compositor/compositing_recorder.h" |
| #include "ui/compositor/paint_context.h" |
| #include "ui/gfx/canvas.h" |
| +#include "ui/gfx/geometry/safe_integer_conversions.h" |
| #include "ui/views/background.h" |
| #include "ui/views/controls/button/checkbox.h" |
| #include "ui/views/controls/combobox/combobox.h" |
| @@ -456,29 +457,30 @@ void CardUnmaskPromptViews::ClosePrompt() { |
| } |
| CardUnmaskPromptViews::FadeOutView::FadeOutView() |
| - : fade_everything_(false), opacity_(1.0) { |
| + : fade_everything_(false), alpha_(255) { |
| } |
| CardUnmaskPromptViews::FadeOutView::~FadeOutView() { |
| } |
| void CardUnmaskPromptViews::FadeOutView::PaintChildren( |
| const ui::PaintContext& context) { |
| - int alpha = static_cast<int>(255 * opacity_); |
| - ui::CompositingRecorder recorder(context, alpha); |
| + ui::CompositingRecorder recorder(context, alpha_); |
| views::View::PaintChildren(context); |
| } |
| void CardUnmaskPromptViews::FadeOutView::OnPaint(gfx::Canvas* canvas) { |
| - if (!fade_everything_ || opacity_ > 0.99) |
| + if (!fade_everything_ || alpha_ == 255) |
| return views::View::OnPaint(canvas); |
| - canvas->SaveLayerAlpha(0xff * opacity_); |
| + canvas->SaveLayerAlpha(alpha_); |
| views::View::OnPaint(canvas); |
| canvas->Restore(); |
| } |
| void CardUnmaskPromptViews::FadeOutView::SetOpacity(double opacity) { |
| - opacity_ = opacity; |
| + DCHECK_GE(opacity, 0.0); |
| + DCHECK_LE(opacity, 1.0); |
| + alpha_ = gfx::ToRoundedInt(opacity * 255); |
|
Peter Kasting
2015/04/07 21:45:30
My intent was to make this function also take an i
|
| SchedulePaint(); |
| } |