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

Side by Side Diff: ui/views/controls/combobox/combobox.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 "ui/views/controls/combobox/combobox.h" 5 #include "ui/views/controls/combobox/combobox.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "ui/accessibility/ax_node_data.h" 14 #include "ui/accessibility/ax_node_data.h"
15 #include "ui/base/default_style.h" 15 #include "ui/base/default_style.h"
16 #include "ui/base/ime/input_method.h" 16 #include "ui/base/ime/input_method.h"
17 #include "ui/base/material_design/material_design_controller.h" 17 #include "ui/base/material_design/material_design_controller.h"
18 #include "ui/base/models/combobox_model.h" 18 #include "ui/base/models/combobox_model.h"
19 #include "ui/base/models/combobox_model_observer.h" 19 #include "ui/base/models/combobox_model_observer.h"
20 #include "ui/base/resource/resource_bundle.h" 20 #include "ui/base/resource/resource_bundle.h"
21 #include "ui/compositor/layer_type.h"
21 #include "ui/events/event.h" 22 #include "ui/events/event.h"
22 #include "ui/gfx/animation/throb_animation.h" 23 #include "ui/gfx/animation/throb_animation.h"
23 #include "ui/gfx/canvas.h" 24 #include "ui/gfx/canvas.h"
24 #include "ui/gfx/color_palette.h" 25 #include "ui/gfx/color_palette.h"
25 #include "ui/gfx/scoped_canvas.h" 26 #include "ui/gfx/scoped_canvas.h"
26 #include "ui/gfx/text_utils.h" 27 #include "ui/gfx/text_utils.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/native_theme/native_theme_aura.h" 30 #include "ui/native_theme/native_theme_aura.h"
30 #include "ui/resources/grit/ui_resources.h" 31 #include "ui/resources/grit/ui_resources.h"
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 } 436 }
436 437
437 text_button_->SetVisible(true); 438 text_button_->SetVisible(true);
438 arrow_button_->SetVisible(true); 439 arrow_button_->SetVisible(true);
439 AddChildView(text_button_); 440 AddChildView(text_button_);
440 AddChildView(arrow_button_); 441 AddChildView(arrow_button_);
441 442
442 // A layer is applied to make sure that canvas bounds are snapped to pixel 443 // A layer is applied to make sure that canvas bounds are snapped to pixel
443 // boundaries (for the sake of drawing the arrow). 444 // boundaries (for the sake of drawing the arrow).
444 if (UseMd()) { 445 if (UseMd()) {
445 SetPaintToLayer(true); 446 SetPaintToLayer(ui::LAYER_TEXTURED);
446 layer()->SetFillsBoundsOpaquely(false); 447 layer()->SetFillsBoundsOpaquely(false);
447 } else { 448 } else {
448 arrow_image_ = PlatformStyle::CreateComboboxArrow(enabled(), style); 449 arrow_image_ = PlatformStyle::CreateComboboxArrow(enabled(), style);
449 } 450 }
450 } 451 }
451 452
452 Combobox::~Combobox() { 453 Combobox::~Combobox() {
453 if (GetInputMethod() && selector_.get()) { 454 if (GetInputMethod() && selector_.get()) {
454 // Combobox should have been blurred before destroy. 455 // Combobox should have been blurred before destroy.
455 DCHECK(selector_.get() != GetInputMethod()->GetTextInputClient()); 456 DCHECK(selector_.get() != GetInputMethod()->GetTextInputClient());
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 const int kMdPaddingWidth = 8; 1010 const int kMdPaddingWidth = 8;
1010 int arrow_pad = UseMd() ? kMdPaddingWidth 1011 int arrow_pad = UseMd() ? kMdPaddingWidth
1011 : PlatformStyle::kComboboxNormalArrowPadding; 1012 : PlatformStyle::kComboboxNormalArrowPadding;
1012 int padding = style_ == STYLE_NORMAL 1013 int padding = style_ == STYLE_NORMAL
1013 ? arrow_pad * 2 1014 ? arrow_pad * 2
1014 : kActionLeftPadding + kActionRightPadding; 1015 : kActionLeftPadding + kActionRightPadding;
1015 return ArrowSize().width() + padding; 1016 return ArrowSize().width() + padding;
1016 } 1017 }
1017 1018
1018 } // namespace views 1019 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698