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

Side by Side Diff: chrome/browser/ui/views/infobars/infobar_view.cc

Issue 1053143002: Make View::Paint use ui::PaintRecorder to access PaintContext's canvas (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: paintrecorder: . Created 5 years, 8 months 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/infobars/infobar_view.h" 5 #include "chrome/browser/ui/views/infobars/infobar_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/ui/infobar_container_delegate.h" 11 #include "chrome/browser/ui/infobar_container_delegate.h"
12 #include "chrome/browser/ui/views/infobars/infobar_background.h" 12 #include "chrome/browser/ui/views/infobars/infobar_background.h"
13 #include "chrome/grit/generated_resources.h" 13 #include "chrome/grit/generated_resources.h"
14 #include "components/infobars/core/infobar_delegate.h" 14 #include "components/infobars/core/infobar_delegate.h"
15 #include "grit/theme_resources.h" 15 #include "grit/theme_resources.h"
16 #include "third_party/skia/include/effects/SkGradientShader.h" 16 #include "third_party/skia/include/effects/SkGradientShader.h"
17 #include "ui/accessibility/ax_view_state.h" 17 #include "ui/accessibility/ax_view_state.h"
18 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
19 #include "ui/base/resource/resource_bundle.h" 19 #include "ui/base/resource/resource_bundle.h"
20 #include "ui/compositor/paint_context.h"
20 #include "ui/gfx/canvas.h" 21 #include "ui/gfx/canvas.h"
21 #include "ui/gfx/image/image.h" 22 #include "ui/gfx/image/image.h"
22 #include "ui/resources/grit/ui_resources.h" 23 #include "ui/resources/grit/ui_resources.h"
23 #include "ui/views/controls/button/image_button.h" 24 #include "ui/views/controls/button/image_button.h"
24 #include "ui/views/controls/button/label_button.h" 25 #include "ui/views/controls/button/label_button.h"
25 #include "ui/views/controls/button/label_button_border.h" 26 #include "ui/views/controls/button/label_button_border.h"
26 #include "ui/views/controls/button/menu_button.h" 27 #include "ui/views/controls/button/menu_button.h"
27 #include "ui/views/controls/image_view.h" 28 #include "ui/views/controls/image_view.h"
28 #include "ui/views/controls/label.h" 29 #include "ui/views/controls/label.h"
29 #include "ui/views/controls/link.h" 30 #include "ui/views/controls/link.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 // Ensure the infobar is tall enough to display its contents. 233 // Ensure the infobar is tall enough to display its contents.
233 const int kMinimumVerticalPadding = 6; 234 const int kMinimumVerticalPadding = 6;
234 int height = InfoBarContainerDelegate::kDefaultBarTargetHeight; 235 int height = InfoBarContainerDelegate::kDefaultBarTargetHeight;
235 for (int i = 0; i < child_count(); ++i) { 236 for (int i = 0; i < child_count(); ++i) {
236 const int child_height = child_at(i)->height(); 237 const int child_height = child_at(i)->height();
237 height = std::max(height, child_height + kMinimumVerticalPadding); 238 height = std::max(height, child_height + kMinimumVerticalPadding);
238 } 239 }
239 SetBarTargetHeight(height); 240 SetBarTargetHeight(height);
240 } 241 }
241 242
242 void InfoBarView::PaintChildren(const PaintContext& context) { 243 void InfoBarView::PaintChildren(const ui::PaintContext& context) {
243 gfx::Canvas* canvas = context.canvas(); 244 gfx::Canvas* canvas = context.canvas();
244 canvas->Save(); 245 canvas->Save();
245 246
246 // TODO(scr): This really should be the |fill_path_|, but the clipPath seems 247 // TODO(scr): This really should be the |fill_path_|, but the clipPath seems
247 // broken on non-Windows platforms (crbug.com/75154). For now, just clip to 248 // broken on non-Windows platforms (crbug.com/75154). For now, just clip to
248 // the bar bounds. 249 // the bar bounds.
249 // 250 //
250 // canvas->sk_canvas()->clipPath(fill_path_); 251 // canvas->sk_canvas()->clipPath(fill_path_);
251 DCHECK_EQ(total_height(), height()) 252 DCHECK_EQ(total_height(), height())
252 << "Infobar piecewise heights do not match overall height"; 253 << "Infobar piecewise heights do not match overall height";
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 void InfoBarView::OnWillChangeFocus(View* focused_before, View* focused_now) { 379 void InfoBarView::OnWillChangeFocus(View* focused_before, View* focused_now) {
379 views::ExternalFocusTracker::OnWillChangeFocus(focused_before, focused_now); 380 views::ExternalFocusTracker::OnWillChangeFocus(focused_before, focused_now);
380 381
381 // This will trigger some screen readers to read the entire contents of this 382 // This will trigger some screen readers to read the entire contents of this
382 // infobar. 383 // infobar.
383 if (focused_before && focused_now && !Contains(focused_before) && 384 if (focused_before && focused_now && !Contains(focused_before) &&
384 Contains(focused_now)) { 385 Contains(focused_now)) {
385 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); 386 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true);
386 } 387 }
387 } 388 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698