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

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

Issue 2639203007: Update SetPaintToLayer to accept LayerType (Closed)
Patch Set: Refactor Created 3 years, 11 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 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/browser/ui/infobar_container_delegate.h" 13 #include "chrome/browser/ui/infobar_container_delegate.h"
14 #include "chrome/browser/ui/views/infobars/infobar_background.h" 14 #include "chrome/browser/ui/views/infobars/infobar_background.h"
15 #include "chrome/grit/generated_resources.h" 15 #include "chrome/grit/generated_resources.h"
16 #include "chrome/grit/theme_resources.h" 16 #include "chrome/grit/theme_resources.h"
17 #include "components/infobars/core/infobar_delegate.h" 17 #include "components/infobars/core/infobar_delegate.h"
18 #include "components/strings/grit/components_strings.h" 18 #include "components/strings/grit/components_strings.h"
19 #include "third_party/skia/include/effects/SkGradientShader.h" 19 #include "third_party/skia/include/effects/SkGradientShader.h"
20 #include "ui/accessibility/ax_node_data.h" 20 #include "ui/accessibility/ax_node_data.h"
21 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
22 #include "ui/compositor/layer_type.h"
22 #include "ui/gfx/canvas.h" 23 #include "ui/gfx/canvas.h"
23 #include "ui/gfx/color_palette.h" 24 #include "ui/gfx/color_palette.h"
24 #include "ui/gfx/image/image.h" 25 #include "ui/gfx/image/image.h"
25 #include "ui/gfx/paint_vector_icon.h" 26 #include "ui/gfx/paint_vector_icon.h"
26 #include "ui/gfx/vector_icons_public.h" 27 #include "ui/gfx/vector_icons_public.h"
27 #include "ui/native_theme/common_theme.h" 28 #include "ui/native_theme/common_theme.h"
28 #include "ui/native_theme/native_theme.h" 29 #include "ui/native_theme/native_theme.h"
29 #include "ui/views/controls/button/image_button.h" 30 #include "ui/views/controls/button/image_button.h"
30 #include "ui/views/controls/button/label_button_border.h" 31 #include "ui/views/controls/button/label_button_border.h"
31 #include "ui/views/controls/button/md_text_button.h" 32 #include "ui/views/controls/button/md_text_button.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 child_container_(new views::View()), 74 child_container_(new views::View()),
74 icon_(nullptr), 75 icon_(nullptr),
75 close_button_(nullptr) { 76 close_button_(nullptr) {
76 set_owned_by_client(); // InfoBar deletes itself at the appropriate time. 77 set_owned_by_client(); // InfoBar deletes itself at the appropriate time.
77 set_background( 78 set_background(
78 new InfoBarBackground(infobars::InfoBar::delegate()->GetInfoBarType())); 79 new InfoBarBackground(infobars::InfoBar::delegate()->GetInfoBarType()));
79 SetEventTargeter(base::MakeUnique<views::ViewTargeter>(this)); 80 SetEventTargeter(base::MakeUnique<views::ViewTargeter>(this));
80 81
81 AddChildView(child_container_); 82 AddChildView(child_container_);
82 83
83 SetPaintToLayer(true); 84 SetPaintToLayer(ui::LAYER_TEXTURED);
84 layer()->SetFillsBoundsOpaquely(false); 85 layer()->SetFillsBoundsOpaquely(false);
85 86
86 child_container_->SetPaintToLayer(true); 87 child_container_->SetPaintToLayer(ui::LAYER_TEXTURED);
87 child_container_->layer()->SetMasksToBounds(true); 88 child_container_->layer()->SetMasksToBounds(true);
88 child_container_->set_background(views::Background::CreateSolidBackground( 89 child_container_->set_background(views::Background::CreateSolidBackground(
89 infobars::InfoBar::GetBackgroundColor( 90 infobars::InfoBar::GetBackgroundColor(
90 infobars::InfoBar::delegate()->GetInfoBarType()))); 91 infobars::InfoBar::delegate()->GetInfoBarType())));
91 } 92 }
92 93
93 const infobars::InfoBarContainer::Delegate* InfoBarView::container_delegate() 94 const infobars::InfoBarContainer::Delegate* InfoBarView::container_delegate()
94 const { 95 const {
95 const infobars::InfoBarContainer* infobar_container = container(); 96 const infobars::InfoBarContainer* infobar_container = container();
96 return infobar_container ? infobar_container->delegate() : NULL; 97 return infobar_container ? infobar_container->delegate() : NULL;
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 } 308 }
308 309
309 bool InfoBarView::DoesIntersectRect(const View* target, 310 bool InfoBarView::DoesIntersectRect(const View* target,
310 const gfx::Rect& rect) const { 311 const gfx::Rect& rect) const {
311 DCHECK_EQ(this, target); 312 DCHECK_EQ(this, target);
312 // Only events that intersect the portion below the arrow are interesting. 313 // Only events that intersect the portion below the arrow are interesting.
313 gfx::Rect non_arrow_bounds = GetLocalBounds(); 314 gfx::Rect non_arrow_bounds = GetLocalBounds();
314 non_arrow_bounds.Inset(0, arrow_height(), 0, 0); 315 non_arrow_bounds.Inset(0, arrow_height(), 0, 0);
315 return rect.Intersects(non_arrow_bounds); 316 return rect.Intersects(non_arrow_bounds);
316 } 317 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698