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

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

Issue 1999773002: views::Textfield: Implement transpose editing command. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments. Created 4 years, 5 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/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after
1481 case ui::TextEditCommand::CUT: 1481 case ui::TextEditCommand::CUT:
1482 return editable && readable && model_->HasSelection(); 1482 return editable && readable && model_->HasSelection();
1483 case ui::TextEditCommand::COPY: 1483 case ui::TextEditCommand::COPY:
1484 return readable && model_->HasSelection(); 1484 return readable && model_->HasSelection();
1485 case ui::TextEditCommand::PASTE: 1485 case ui::TextEditCommand::PASTE:
1486 ui::Clipboard::GetForCurrentThread()->ReadText( 1486 ui::Clipboard::GetForCurrentThread()->ReadText(
1487 ui::CLIPBOARD_TYPE_COPY_PASTE, &result); 1487 ui::CLIPBOARD_TYPE_COPY_PASTE, &result);
1488 return editable && !result.empty(); 1488 return editable && !result.empty();
1489 case ui::TextEditCommand::SELECT_ALL: 1489 case ui::TextEditCommand::SELECT_ALL:
1490 return !text().empty(); 1490 return !text().empty();
1491 case ui::TextEditCommand::TRANSPOSE:
1492 return editable && !model_->HasSelection() &&
1493 !model_->HasCompositionText();
1491 case ui::TextEditCommand::MOVE_DOWN: 1494 case ui::TextEditCommand::MOVE_DOWN:
1492 case ui::TextEditCommand::MOVE_DOWN_AND_MODIFY_SELECTION: 1495 case ui::TextEditCommand::MOVE_DOWN_AND_MODIFY_SELECTION:
1493 case ui::TextEditCommand::MOVE_PAGE_DOWN: 1496 case ui::TextEditCommand::MOVE_PAGE_DOWN:
1494 case ui::TextEditCommand::MOVE_PAGE_DOWN_AND_MODIFY_SELECTION: 1497 case ui::TextEditCommand::MOVE_PAGE_DOWN_AND_MODIFY_SELECTION:
1495 case ui::TextEditCommand::MOVE_PAGE_UP: 1498 case ui::TextEditCommand::MOVE_PAGE_UP:
1496 case ui::TextEditCommand::MOVE_PAGE_UP_AND_MODIFY_SELECTION: 1499 case ui::TextEditCommand::MOVE_PAGE_UP_AND_MODIFY_SELECTION:
1497 case ui::TextEditCommand::MOVE_UP: 1500 case ui::TextEditCommand::MOVE_UP:
1498 case ui::TextEditCommand::MOVE_UP_AND_MODIFY_SELECTION: 1501 case ui::TextEditCommand::MOVE_UP_AND_MODIFY_SELECTION:
1499 case ui::TextEditCommand::INSERT_TEXT: 1502 case ui::TextEditCommand::INSERT_TEXT:
1500 case ui::TextEditCommand::SET_MARK: 1503 case ui::TextEditCommand::SET_MARK:
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1674 break; 1677 break;
1675 case ui::TextEditCommand::COPY: 1678 case ui::TextEditCommand::COPY:
1676 Copy(); 1679 Copy();
1677 break; 1680 break;
1678 case ui::TextEditCommand::PASTE: 1681 case ui::TextEditCommand::PASTE:
1679 text_changed = cursor_changed = Paste(); 1682 text_changed = cursor_changed = Paste();
1680 break; 1683 break;
1681 case ui::TextEditCommand::SELECT_ALL: 1684 case ui::TextEditCommand::SELECT_ALL:
1682 SelectAll(false); 1685 SelectAll(false);
1683 break; 1686 break;
1687 case ui::TextEditCommand::TRANSPOSE:
1688 text_changed = cursor_changed = model_->Transpose();
1689 break;
1684 case ui::TextEditCommand::MOVE_DOWN: 1690 case ui::TextEditCommand::MOVE_DOWN:
1685 case ui::TextEditCommand::MOVE_DOWN_AND_MODIFY_SELECTION: 1691 case ui::TextEditCommand::MOVE_DOWN_AND_MODIFY_SELECTION:
1686 case ui::TextEditCommand::MOVE_PAGE_DOWN: 1692 case ui::TextEditCommand::MOVE_PAGE_DOWN:
1687 case ui::TextEditCommand::MOVE_PAGE_DOWN_AND_MODIFY_SELECTION: 1693 case ui::TextEditCommand::MOVE_PAGE_DOWN_AND_MODIFY_SELECTION:
1688 case ui::TextEditCommand::MOVE_PAGE_UP: 1694 case ui::TextEditCommand::MOVE_PAGE_UP:
1689 case ui::TextEditCommand::MOVE_PAGE_UP_AND_MODIFY_SELECTION: 1695 case ui::TextEditCommand::MOVE_PAGE_UP_AND_MODIFY_SELECTION:
1690 case ui::TextEditCommand::MOVE_UP: 1696 case ui::TextEditCommand::MOVE_UP:
1691 case ui::TextEditCommand::MOVE_UP_AND_MODIFY_SELECTION: 1697 case ui::TextEditCommand::MOVE_UP_AND_MODIFY_SELECTION:
1692 case ui::TextEditCommand::INSERT_TEXT: 1698 case ui::TextEditCommand::INSERT_TEXT:
1693 case ui::TextEditCommand::SET_MARK: 1699 case ui::TextEditCommand::SET_MARK:
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
1960 RequestFocus(); 1966 RequestFocus();
1961 model_->MoveCursorTo(mouse); 1967 model_->MoveCursorTo(mouse);
1962 if (!selection_clipboard_text.empty()) { 1968 if (!selection_clipboard_text.empty()) {
1963 model_->InsertText(selection_clipboard_text); 1969 model_->InsertText(selection_clipboard_text);
1964 UpdateAfterChange(true, true); 1970 UpdateAfterChange(true, true);
1965 } 1971 }
1966 OnAfterUserAction(); 1972 OnAfterUserAction();
1967 } 1973 }
1968 1974
1969 } // namespace views 1975 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/cocoa/bridged_native_widget_unittest.mm ('k') | ui/views/controls/textfield/textfield_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698