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

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

Issue 2829823002: [Textfield] Consider select all status for select all context menu (Closed)
Patch Set: Add test for empty text Created 3 years, 8 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/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/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 return model_->GetSelectedText(); 346 return model_->GetSelectedText();
347 } 347 }
348 348
349 void Textfield::SelectAll(bool reversed) { 349 void Textfield::SelectAll(bool reversed) {
350 model_->SelectAll(reversed); 350 model_->SelectAll(reversed);
351 if (HasSelection() && performing_user_action_) 351 if (HasSelection() && performing_user_action_)
352 UpdateSelectionClipboard(); 352 UpdateSelectionClipboard();
353 UpdateAfterChange(false, true); 353 UpdateAfterChange(false, true);
354 } 354 }
355 355
356 bool Textfield::IsAllSelected() const {
357 return !text().empty() && GetSelectedText().length() == text().length();
Peter Kasting 2017/04/20 00:08:30 It seems like it would be more efficient to see if
simonhong 2017/04/20 13:11:51 Done.
358 }
359
356 void Textfield::SelectWordAt(const gfx::Point& point) { 360 void Textfield::SelectWordAt(const gfx::Point& point) {
357 model_->MoveCursorTo(point, false); 361 model_->MoveCursorTo(point, false);
358 model_->SelectWord(); 362 model_->SelectWord();
359 UpdateAfterChange(false, true); 363 UpdateAfterChange(false, true);
360 } 364 }
361 365
362 void Textfield::ClearSelection() { 366 void Textfield::ClearSelection() {
363 model_->ClearSelection(); 367 model_->ClearSelection();
364 UpdateAfterChange(false, true); 368 UpdateAfterChange(false, true);
365 } 369 }
(...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1539 return editable && model_->CanRedo(); 1543 return editable && model_->CanRedo();
1540 case ui::TextEditCommand::CUT: 1544 case ui::TextEditCommand::CUT:
1541 return editable && readable && model_->HasSelection(); 1545 return editable && readable && model_->HasSelection();
1542 case ui::TextEditCommand::COPY: 1546 case ui::TextEditCommand::COPY:
1543 return readable && model_->HasSelection(); 1547 return readable && model_->HasSelection();
1544 case ui::TextEditCommand::PASTE: 1548 case ui::TextEditCommand::PASTE:
1545 ui::Clipboard::GetForCurrentThread()->ReadText( 1549 ui::Clipboard::GetForCurrentThread()->ReadText(
1546 ui::CLIPBOARD_TYPE_COPY_PASTE, &result); 1550 ui::CLIPBOARD_TYPE_COPY_PASTE, &result);
1547 return editable && !result.empty(); 1551 return editable && !result.empty();
1548 case ui::TextEditCommand::SELECT_ALL: 1552 case ui::TextEditCommand::SELECT_ALL:
1549 return !text().empty(); 1553 return !IsAllSelected();
1550 case ui::TextEditCommand::TRANSPOSE: 1554 case ui::TextEditCommand::TRANSPOSE:
1551 return editable && !model_->HasSelection() && 1555 return editable && !model_->HasSelection() &&
1552 !model_->HasCompositionText(); 1556 !model_->HasCompositionText();
1553 case ui::TextEditCommand::YANK: 1557 case ui::TextEditCommand::YANK:
1554 return editable; 1558 return editable;
1555 case ui::TextEditCommand::MOVE_DOWN: 1559 case ui::TextEditCommand::MOVE_DOWN:
1556 case ui::TextEditCommand::MOVE_DOWN_AND_MODIFY_SELECTION: 1560 case ui::TextEditCommand::MOVE_DOWN_AND_MODIFY_SELECTION:
1557 case ui::TextEditCommand::MOVE_PAGE_DOWN: 1561 case ui::TextEditCommand::MOVE_PAGE_DOWN:
1558 case ui::TextEditCommand::MOVE_PAGE_DOWN_AND_MODIFY_SELECTION: 1562 case ui::TextEditCommand::MOVE_PAGE_DOWN_AND_MODIFY_SELECTION:
1559 case ui::TextEditCommand::MOVE_PAGE_UP: 1563 case ui::TextEditCommand::MOVE_PAGE_UP:
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
2098 cursor_blink_timer_.Stop(); 2102 cursor_blink_timer_.Stop();
2099 } 2103 }
2100 2104
2101 void Textfield::OnCursorBlinkTimerFired() { 2105 void Textfield::OnCursorBlinkTimerFired() {
2102 DCHECK(ShouldBlinkCursor()); 2106 DCHECK(ShouldBlinkCursor());
2103 cursor_view_.SetVisible(!cursor_view_.visible()); 2107 cursor_view_.SetVisible(!cursor_view_.visible());
2104 UpdateCursorViewPosition(); 2108 UpdateCursorViewPosition();
2105 } 2109 }
2106 2110
2107 } // namespace views 2111 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698