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

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

Issue 2413223003: Views:: Make Labels support text selection. (Closed)
Patch Set: Fix text selection background color on Windows. Created 4 years, 1 month 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/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"
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 drag_start_display_offset_(0), 250 drag_start_display_offset_(0),
251 touch_handles_hidden_due_to_scroll_(false), 251 touch_handles_hidden_due_to_scroll_(false),
252 use_focus_ring_(ui::MaterialDesignController::IsSecondaryUiMaterial()), 252 use_focus_ring_(ui::MaterialDesignController::IsSecondaryUiMaterial()),
253 weak_ptr_factory_(this) { 253 weak_ptr_factory_(this) {
254 set_context_menu_controller(this); 254 set_context_menu_controller(this);
255 set_drag_controller(this); 255 set_drag_controller(this);
256 GetRenderText()->SetFontList(GetDefaultFontList()); 256 GetRenderText()->SetFontList(GetDefaultFontList());
257 View::SetBorder(std::unique_ptr<Border>(new FocusableBorder())); 257 View::SetBorder(std::unique_ptr<Border>(new FocusableBorder()));
258 SetFocusBehavior(FocusBehavior::ALWAYS); 258 SetFocusBehavior(FocusBehavior::ALWAYS);
259 259
260 // On Linux, middle click should update or paste the selection clipboard.
261 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
262 selection_controller_.set_handles_selection_clipboard(true);
263 #endif
264
265 // These allow BrowserView to pass edit commands from the Chrome menu to us 260 // These allow BrowserView to pass edit commands from the Chrome menu to us
266 // when we're focused by simply asking the FocusManager to 261 // when we're focused by simply asking the FocusManager to
267 // ProcessAccelerator() with the relevant accelerators. 262 // ProcessAccelerator() with the relevant accelerators.
268 AddAccelerator(ui::Accelerator(ui::VKEY_X, ui::EF_CONTROL_DOWN)); 263 AddAccelerator(ui::Accelerator(ui::VKEY_X, ui::EF_CONTROL_DOWN));
269 AddAccelerator(ui::Accelerator(ui::VKEY_C, ui::EF_CONTROL_DOWN)); 264 AddAccelerator(ui::Accelerator(ui::VKEY_C, ui::EF_CONTROL_DOWN));
270 AddAccelerator(ui::Accelerator(ui::VKEY_V, ui::EF_CONTROL_DOWN)); 265 AddAccelerator(ui::Accelerator(ui::VKEY_V, ui::EF_CONTROL_DOWN));
271 } 266 }
272 267
273 Textfield::~Textfield() { 268 Textfield::~Textfield() {
274 if (GetInputMethod()) { 269 if (GetInputMethod()) {
(...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after
1755 // Textfield, SelectionControllerDelegate overrides: 1750 // Textfield, SelectionControllerDelegate overrides:
1756 1751
1757 gfx::RenderText* Textfield::GetRenderTextForSelectionController() { 1752 gfx::RenderText* Textfield::GetRenderTextForSelectionController() {
1758 return GetRenderText(); 1753 return GetRenderText();
1759 } 1754 }
1760 1755
1761 bool Textfield::IsReadOnly() const { 1756 bool Textfield::IsReadOnly() const {
1762 return read_only(); 1757 return read_only();
1763 } 1758 }
1764 1759
1760 bool Textfield::SupportsDrag() const {
1761 return true;
1762 }
1763
1765 void Textfield::SetTextBeingDragged(bool value) { 1764 void Textfield::SetTextBeingDragged(bool value) {
1766 initiating_drag_ = value; 1765 initiating_drag_ = value;
1767 } 1766 }
1768 1767
1769 int Textfield::GetViewHeight() const { 1768 int Textfield::GetViewHeight() const {
1770 return height(); 1769 return height();
1771 } 1770 }
1772 1771
1773 int Textfield::GetViewWidth() const { 1772 int Textfield::GetViewWidth() const {
1774 return width(); 1773 return width();
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
2045 } 2044 }
2046 2045
2047 void Textfield::OnCursorBlinkTimerFired() { 2046 void Textfield::OnCursorBlinkTimerFired() {
2048 DCHECK(ShouldBlinkCursor()); 2047 DCHECK(ShouldBlinkCursor());
2049 gfx::RenderText* render_text = GetRenderText(); 2048 gfx::RenderText* render_text = GetRenderText();
2050 render_text->set_cursor_visible(!render_text->cursor_visible()); 2049 render_text->set_cursor_visible(!render_text->cursor_visible());
2051 RepaintCursor(); 2050 RepaintCursor();
2052 } 2051 }
2053 2052
2054 } // namespace views 2053 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698