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

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

Issue 1054783003: views: Access the Canvas through recorders not through PaintContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/clip_transform_recorder.h"
20 #include "ui/compositor/paint_context.h" 21 #include "ui/compositor/paint_context.h"
21 #include "ui/gfx/canvas.h" 22 #include "ui/gfx/canvas.h"
22 #include "ui/gfx/image/image.h" 23 #include "ui/gfx/image/image.h"
23 #include "ui/resources/grit/ui_resources.h" 24 #include "ui/resources/grit/ui_resources.h"
24 #include "ui/views/controls/button/image_button.h" 25 #include "ui/views/controls/button/image_button.h"
25 #include "ui/views/controls/button/label_button.h" 26 #include "ui/views/controls/button/label_button.h"
26 #include "ui/views/controls/button/label_button_border.h" 27 #include "ui/views/controls/button/label_button_border.h"
27 #include "ui/views/controls/button/menu_button.h" 28 #include "ui/views/controls/button/menu_button.h"
28 #include "ui/views/controls/image_view.h" 29 #include "ui/views/controls/image_view.h"
29 #include "ui/views/controls/label.h" 30 #include "ui/views/controls/label.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 const int kMinimumVerticalPadding = 6; 235 const int kMinimumVerticalPadding = 6;
235 int height = InfoBarContainerDelegate::kDefaultBarTargetHeight; 236 int height = InfoBarContainerDelegate::kDefaultBarTargetHeight;
236 for (int i = 0; i < child_count(); ++i) { 237 for (int i = 0; i < child_count(); ++i) {
237 const int child_height = child_at(i)->height(); 238 const int child_height = child_at(i)->height();
238 height = std::max(height, child_height + kMinimumVerticalPadding); 239 height = std::max(height, child_height + kMinimumVerticalPadding);
239 } 240 }
240 SetBarTargetHeight(height); 241 SetBarTargetHeight(height);
241 } 242 }
242 243
243 void InfoBarView::PaintChildren(const ui::PaintContext& context) { 244 void InfoBarView::PaintChildren(const ui::PaintContext& context) {
244 gfx::Canvas* canvas = context.canvas();
245 canvas->Save();
246
247 // TODO(scr): This really should be the |fill_path_|, but the clipPath seems 245 // TODO(scr): This really should be the |fill_path_|, but the clipPath seems
248 // broken on non-Windows platforms (crbug.com/75154). For now, just clip to 246 // broken on non-Windows platforms (crbug.com/75154). For now, just clip to
249 // the bar bounds. 247 // the bar bounds.
250 // 248 //
251 // canvas->sk_canvas()->clipPath(fill_path_); 249 // canvas->sk_canvas()->clipPath(fill_path_);
252 DCHECK_EQ(total_height(), height()) 250 DCHECK_EQ(total_height(), height())
253 << "Infobar piecewise heights do not match overall height"; 251 << "Infobar piecewise heights do not match overall height";
254 canvas->ClipRect(gfx::Rect(0, arrow_height(), width(), bar_height())); 252 ui::ClipTransformRecorder clip_transform_recorder(context);
253 clip_transform_recorder.ClipRect(
254 gfx::Rect(0, arrow_height(), width(), bar_height()));
255 views::View::PaintChildren(context); 255 views::View::PaintChildren(context);
256 canvas->Restore();
257 } 256 }
258 257
259 void InfoBarView::ButtonPressed(views::Button* sender, 258 void InfoBarView::ButtonPressed(views::Button* sender,
260 const ui::Event& event) { 259 const ui::Event& event) {
261 if (!owner()) 260 if (!owner())
262 return; // We're closing; don't call anything, it might access the owner. 261 return; // We're closing; don't call anything, it might access the owner.
263 if (sender == close_button_) { 262 if (sender == close_button_) {
264 delegate()->InfoBarDismissed(); 263 delegate()->InfoBarDismissed();
265 RemoveSelf(); 264 RemoveSelf();
266 } 265 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 void InfoBarView::OnWillChangeFocus(View* focused_before, View* focused_now) { 378 void InfoBarView::OnWillChangeFocus(View* focused_before, View* focused_now) {
380 views::ExternalFocusTracker::OnWillChangeFocus(focused_before, focused_now); 379 views::ExternalFocusTracker::OnWillChangeFocus(focused_before, focused_now);
381 380
382 // This will trigger some screen readers to read the entire contents of this 381 // This will trigger some screen readers to read the entire contents of this
383 // infobar. 382 // infobar.
384 if (focused_before && focused_now && !Contains(focused_before) && 383 if (focused_before && focused_now && !Contains(focused_before) &&
385 Contains(focused_now)) { 384 Contains(focused_now)) {
386 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); 385 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true);
387 } 386 }
388 } 387 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698