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

Side by Side Diff: chrome/browser/ui/views/location_bar/icon_label_bubble_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/location_bar/icon_label_bubble_view.h" 5 #include "chrome/browser/ui/views/location_bar/icon_label_bubble_view.h"
6 6
7 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 7 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
8 #include "ui/accessibility/ax_node_data.h" 8 #include "ui/accessibility/ax_node_data.h"
9 #include "ui/compositor/layer_type.h"
9 #include "ui/gfx/canvas.h" 10 #include "ui/gfx/canvas.h"
10 #include "ui/gfx/color_utils.h" 11 #include "ui/gfx/color_utils.h"
11 #include "ui/gfx/scoped_canvas.h" 12 #include "ui/gfx/scoped_canvas.h"
12 #include "ui/native_theme/native_theme.h" 13 #include "ui/native_theme/native_theme.h"
13 #include "ui/views/animation/ink_drop_highlight.h" 14 #include "ui/views/animation/ink_drop_highlight.h"
14 #include "ui/views/border.h" 15 #include "ui/views/border.h"
15 #include "ui/views/controls/image_view.h" 16 #include "ui/views/controls/image_view.h"
16 #include "ui/views/widget/widget.h" 17 #include "ui/views/widget/widget.h"
17 18
18 namespace { 19 namespace {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 137 }
137 138
138 void IconLabelBubbleView::OnNativeThemeChanged( 139 void IconLabelBubbleView::OnNativeThemeChanged(
139 const ui::NativeTheme* native_theme) { 140 const ui::NativeTheme* native_theme) {
140 label_->SetEnabledColor(GetTextColor()); 141 label_->SetEnabledColor(GetTextColor());
141 label_->SetBackgroundColor(GetParentBackgroundColor()); 142 label_->SetBackgroundColor(GetParentBackgroundColor());
142 SchedulePaint(); 143 SchedulePaint();
143 } 144 }
144 145
145 void IconLabelBubbleView::AddInkDropLayer(ui::Layer* ink_drop_layer) { 146 void IconLabelBubbleView::AddInkDropLayer(ui::Layer* ink_drop_layer) {
146 image()->SetPaintToLayer(true); 147 image()->SetPaintToLayer(ui::LAYER_TEXTURED);
147 image()->layer()->SetFillsBoundsOpaquely(false); 148 image()->layer()->SetFillsBoundsOpaquely(false);
148 InkDropHostView::AddInkDropLayer(ink_drop_layer); 149 InkDropHostView::AddInkDropLayer(ink_drop_layer);
149 } 150 }
150 151
151 void IconLabelBubbleView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { 152 void IconLabelBubbleView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) {
152 InkDropHostView::RemoveInkDropLayer(ink_drop_layer); 153 InkDropHostView::RemoveInkDropLayer(ink_drop_layer);
153 image()->SetPaintToLayer(false); 154 image()->SetPaintToLayer(ui::LAYER_NOT_DRAWN);
154 } 155 }
155 156
156 std::unique_ptr<views::InkDropHighlight> 157 std::unique_ptr<views::InkDropHighlight>
157 IconLabelBubbleView::CreateInkDropHighlight() const { 158 IconLabelBubbleView::CreateInkDropHighlight() const {
158 // Only show a highlight effect when the label is empty/invisible. 159 // Only show a highlight effect when the label is empty/invisible.
159 return label()->visible() ? nullptr 160 return label()->visible() ? nullptr
160 : InkDropHostView::CreateInkDropHighlight(); 161 : InkDropHostView::CreateInkDropHighlight();
161 } 162 }
162 163
163 SkColor IconLabelBubbleView::GetInkDropBaseColor() const { 164 SkColor IconLabelBubbleView::GetInkDropBaseColor() const {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 242
242 // Draw the 1 px separator. 243 // Draw the 1 px separator.
243 gfx::ScopedCanvas scoped_canvas(canvas); 244 gfx::ScopedCanvas scoped_canvas(canvas);
244 const float scale = canvas->UndoDeviceScaleFactor(); 245 const float scale = canvas->UndoDeviceScaleFactor();
245 // Keep the separator aligned on a pixel center. 246 // Keep the separator aligned on a pixel center.
246 const gfx::RectF pixel_aligned_bounds = 247 const gfx::RectF pixel_aligned_bounds =
247 gfx::ScaleRect(gfx::RectF(bounds), scale) - gfx::Vector2dF(0.5f, 0); 248 gfx::ScaleRect(gfx::RectF(bounds), scale) - gfx::Vector2dF(0.5f, 0);
248 canvas->DrawLine(pixel_aligned_bounds.top_right(), 249 canvas->DrawLine(pixel_aligned_bounds.top_right(),
249 pixel_aligned_bounds.bottom_right(), separator_color); 250 pixel_aligned_bounds.bottom_right(), separator_color);
250 } 251 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698