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

Side by Side Diff: ui/views/controls/textfield/textfield.cc

Issue 2228593002: Implement Harmony textfield border (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tapted to the resuce Created 4 years, 4 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
« no previous file with comments | « ui/views/controls/focusable_border.cc ('k') | ui/views/examples/textfield_example.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/textfield/textfield.h" 5 #include "ui/views/controls/textfield/textfield.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "ui/accessibility/ax_view_state.h" 12 #include "ui/accessibility/ax_view_state.h"
13 #include "ui/base/clipboard/scoped_clipboard_writer.h" 13 #include "ui/base/clipboard/scoped_clipboard_writer.h"
14 #include "ui/base/cursor/cursor.h" 14 #include "ui/base/cursor/cursor.h"
15 #include "ui/base/default_style.h" 15 #include "ui/base/default_style.h"
16 #include "ui/base/dragdrop/drag_drop_types.h" 16 #include "ui/base/dragdrop/drag_drop_types.h"
17 #include "ui/base/dragdrop/drag_utils.h" 17 #include "ui/base/dragdrop/drag_utils.h"
18 #include "ui/base/ime/input_method.h" 18 #include "ui/base/ime/input_method.h"
19 #include "ui/base/ime/text_edit_commands.h" 19 #include "ui/base/ime/text_edit_commands.h"
20 #include "ui/base/material_design/material_design_controller.h"
20 #include "ui/base/resource/resource_bundle.h" 21 #include "ui/base/resource/resource_bundle.h"
21 #include "ui/base/ui_base_switches_util.h" 22 #include "ui/base/ui_base_switches_util.h"
22 #include "ui/compositor/canvas_painter.h" 23 #include "ui/compositor/canvas_painter.h"
23 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 24 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
24 #include "ui/display/display.h" 25 #include "ui/display/display.h"
25 #include "ui/display/screen.h" 26 #include "ui/display/screen.h"
26 #include "ui/events/base_event_utils.h" 27 #include "ui/events/base_event_utils.h"
27 #include "ui/events/event.h" 28 #include "ui/events/event.h"
28 #include "ui/events/keycodes/keyboard_codes.h" 29 #include "ui/events/keycodes/keyboard_codes.h"
29 #include "ui/gfx/canvas.h" 30 #include "ui/gfx/canvas.h"
(...skipping 1695 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 1726
1726 void Textfield::AccessibilitySetValue(const base::string16& new_value) { 1727 void Textfield::AccessibilitySetValue(const base::string16& new_value) {
1727 if (!read_only()) { 1728 if (!read_only()) {
1728 SetText(new_value); 1729 SetText(new_value);
1729 ClearSelection(); 1730 ClearSelection();
1730 } 1731 }
1731 } 1732 }
1732 1733
1733 void Textfield::UpdateBackgroundColor() { 1734 void Textfield::UpdateBackgroundColor() {
1734 const SkColor color = GetBackgroundColor(); 1735 const SkColor color = GetBackgroundColor();
1735 set_background(Background::CreateSolidBackground(color)); 1736 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
1737 set_background(Background::CreateBackgroundPainter(
1738 true, Painter::CreateSolidRoundRectPainter(
1739 color, FocusableBorder::kCornerRadiusDp)));
1740 } else {
1741 set_background(Background::CreateSolidBackground(color));
1742 }
1736 // Disable subpixel rendering when the background color is transparent 1743 // Disable subpixel rendering when the background color is transparent
1737 // because it draws incorrect colors around the glyphs in that case. 1744 // because it draws incorrect colors around the glyphs in that case.
1738 // See crbug.com/115198 1745 // See crbug.com/115198
1739 GetRenderText()->set_subpixel_rendering_suppressed( 1746 GetRenderText()->set_subpixel_rendering_suppressed(
1740 SkColorGetA(color) != 0xFF); 1747 SkColorGetA(color) != SK_AlphaOPAQUE);
1741 SchedulePaint(); 1748 SchedulePaint();
1742 } 1749 }
1743 1750
1744 void Textfield::UpdateAfterChange(bool text_changed, bool cursor_changed) { 1751 void Textfield::UpdateAfterChange(bool text_changed, bool cursor_changed) {
1745 if (text_changed) { 1752 if (text_changed) {
1746 if (controller_) 1753 if (controller_)
1747 controller_->ContentsChanged(this, text()); 1754 controller_->ContentsChanged(this, text());
1748 NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_CHANGED, true); 1755 NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_CHANGED, true);
1749 } 1756 }
1750 if (cursor_changed) { 1757 if (cursor_changed) {
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1976 RequestFocus(); 1983 RequestFocus();
1977 model_->MoveCursorTo(mouse); 1984 model_->MoveCursorTo(mouse);
1978 if (!selection_clipboard_text.empty()) { 1985 if (!selection_clipboard_text.empty()) {
1979 model_->InsertText(selection_clipboard_text); 1986 model_->InsertText(selection_clipboard_text);
1980 UpdateAfterChange(true, true); 1987 UpdateAfterChange(true, true);
1981 } 1988 }
1982 OnAfterUserAction(); 1989 OnAfterUserAction();
1983 } 1990 }
1984 1991
1985 } // namespace views 1992 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/focusable_border.cc ('k') | ui/views/examples/textfield_example.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698