Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 case ui::VKEY_INSERT: | 160 case ui::VKEY_INSERT: |
| 161 if (control && !shift) | 161 if (control && !shift) |
| 162 return ui::TextEditCommand::COPY; | 162 return ui::TextEditCommand::COPY; |
| 163 return (shift && !control) ? ui::TextEditCommand::PASTE | 163 return (shift && !control) ? ui::TextEditCommand::PASTE |
| 164 : ui::TextEditCommand::INVALID_COMMAND; | 164 : ui::TextEditCommand::INVALID_COMMAND; |
| 165 default: | 165 default: |
| 166 return ui::TextEditCommand::INVALID_COMMAND; | 166 return ui::TextEditCommand::INVALID_COMMAND; |
| 167 } | 167 } |
| 168 } | 168 } |
| 169 | 169 |
| 170 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 171 // Convert a custom text edit |command| to the equivalent views command ID. | |
| 172 ui::TextEditCommand GetViewsCommand(const ui::TextEditCommandAuraLinux& command, | |
| 173 bool rtl) { | |
| 174 const bool select = command.extend_selection(); | |
| 175 switch (command.command_id()) { | |
| 176 case ui::TextEditCommandAuraLinux::COPY: | |
| 177 return ui::TextEditCommand::COPY; | |
| 178 case ui::TextEditCommandAuraLinux::CUT: | |
| 179 return ui::TextEditCommand::CUT; | |
| 180 case ui::TextEditCommandAuraLinux::DELETE_BACKWARD: | |
| 181 return ui::TextEditCommand::DELETE_BACKWARD; | |
| 182 case ui::TextEditCommandAuraLinux::DELETE_FORWARD: | |
| 183 return ui::TextEditCommand::DELETE_FORWARD; | |
| 184 case ui::TextEditCommandAuraLinux::DELETE_TO_BEGINNING_OF_LINE: | |
| 185 case ui::TextEditCommandAuraLinux::DELETE_TO_BEGINNING_OF_PARAGRAPH: | |
| 186 return ui::TextEditCommand::DELETE_TO_BEGINNING_OF_LINE; | |
| 187 case ui::TextEditCommandAuraLinux::DELETE_TO_END_OF_LINE: | |
| 188 case ui::TextEditCommandAuraLinux::DELETE_TO_END_OF_PARAGRAPH: | |
| 189 return ui::TextEditCommand::DELETE_TO_END_OF_LINE; | |
| 190 case ui::TextEditCommandAuraLinux::DELETE_WORD_BACKWARD: | |
| 191 return ui::TextEditCommand::DELETE_WORD_BACKWARD; | |
| 192 case ui::TextEditCommandAuraLinux::DELETE_WORD_FORWARD: | |
| 193 return ui::TextEditCommand::DELETE_WORD_FORWARD; | |
| 194 case ui::TextEditCommandAuraLinux::INSERT_TEXT: | |
| 195 return ui::TextEditCommand::INVALID_COMMAND; | |
| 196 case ui::TextEditCommandAuraLinux::MOVE_BACKWARD: | |
| 197 if (rtl) | |
| 198 return select ? ui::TextEditCommand::MOVE_RIGHT_AND_MODIFY_SELECTION | |
| 199 : ui::TextEditCommand::MOVE_RIGHT; | |
| 200 return select ? ui::TextEditCommand::MOVE_LEFT_AND_MODIFY_SELECTION | |
| 201 : ui::TextEditCommand::MOVE_LEFT; | |
| 202 case ui::TextEditCommandAuraLinux::MOVE_DOWN: | |
| 203 return ui::TextEditCommand::MOVE_DOWN; | |
| 204 case ui::TextEditCommandAuraLinux::MOVE_FORWARD: | |
| 205 if (rtl) | |
| 206 return select ? ui::TextEditCommand::MOVE_LEFT_AND_MODIFY_SELECTION | |
| 207 : ui::TextEditCommand::MOVE_LEFT; | |
| 208 return select ? ui::TextEditCommand::MOVE_RIGHT_AND_MODIFY_SELECTION | |
| 209 : ui::TextEditCommand::MOVE_RIGHT; | |
| 210 case ui::TextEditCommandAuraLinux::MOVE_LEFT: | |
| 211 return select ? ui::TextEditCommand::MOVE_LEFT_AND_MODIFY_SELECTION | |
| 212 : ui::TextEditCommand::MOVE_LEFT; | |
| 213 case ui::TextEditCommandAuraLinux::MOVE_PAGE_DOWN: | |
| 214 case ui::TextEditCommandAuraLinux::MOVE_PAGE_UP: | |
| 215 return ui::TextEditCommand::INVALID_COMMAND; | |
| 216 case ui::TextEditCommandAuraLinux::MOVE_RIGHT: | |
| 217 return select ? ui::TextEditCommand::MOVE_RIGHT_AND_MODIFY_SELECTION | |
| 218 : ui::TextEditCommand::MOVE_RIGHT; | |
| 219 case ui::TextEditCommandAuraLinux::MOVE_TO_BEGINNING_OF_DOCUMENT: | |
| 220 case ui::TextEditCommandAuraLinux::MOVE_TO_BEGINNING_OF_LINE: | |
| 221 case ui::TextEditCommandAuraLinux::MOVE_TO_BEGINNING_OF_PARAGRAPH: | |
| 222 return select ? ui::TextEditCommand:: | |
| 223 MOVE_TO_BEGINNING_OF_LINE_AND_MODIFY_SELECTION | |
| 224 : ui::TextEditCommand::MOVE_TO_BEGINNING_OF_LINE; | |
| 225 case ui::TextEditCommandAuraLinux::MOVE_TO_END_OF_DOCUMENT: | |
| 226 case ui::TextEditCommandAuraLinux::MOVE_TO_END_OF_LINE: | |
| 227 case ui::TextEditCommandAuraLinux::MOVE_TO_END_OF_PARAGRAPH: | |
| 228 return select | |
| 229 ? ui::TextEditCommand::MOVE_TO_END_OF_LINE_AND_MODIFY_SELECTION | |
| 230 : ui::TextEditCommand::MOVE_TO_END_OF_LINE; | |
| 231 case ui::TextEditCommandAuraLinux::MOVE_UP: | |
| 232 return ui::TextEditCommand::MOVE_UP; | |
| 233 case ui::TextEditCommandAuraLinux::MOVE_WORD_BACKWARD: | |
| 234 if (rtl) { | |
| 235 return select | |
| 236 ? ui::TextEditCommand::MOVE_WORD_RIGHT_AND_MODIFY_SELECTION | |
| 237 : ui::TextEditCommand::MOVE_WORD_RIGHT; | |
| 238 } | |
| 239 return select ? ui::TextEditCommand::MOVE_WORD_LEFT_AND_MODIFY_SELECTION | |
| 240 : ui::TextEditCommand::MOVE_WORD_LEFT; | |
| 241 case ui::TextEditCommandAuraLinux::MOVE_WORD_FORWARD: | |
| 242 if (rtl) { | |
| 243 return select ? ui::TextEditCommand::MOVE_WORD_LEFT_AND_MODIFY_SELECTION | |
| 244 : ui::TextEditCommand::MOVE_WORD_LEFT; | |
| 245 } | |
| 246 return select ? ui::TextEditCommand::MOVE_WORD_RIGHT_AND_MODIFY_SELECTION | |
| 247 : ui::TextEditCommand::MOVE_WORD_RIGHT; | |
| 248 case ui::TextEditCommandAuraLinux::MOVE_WORD_LEFT: | |
| 249 return select ? ui::TextEditCommand::MOVE_WORD_LEFT_AND_MODIFY_SELECTION | |
| 250 : ui::TextEditCommand::MOVE_WORD_LEFT; | |
| 251 case ui::TextEditCommandAuraLinux::MOVE_WORD_RIGHT: | |
| 252 return select ? ui::TextEditCommand::MOVE_WORD_RIGHT_AND_MODIFY_SELECTION | |
| 253 : ui::TextEditCommand::MOVE_WORD_RIGHT; | |
| 254 case ui::TextEditCommandAuraLinux::PASTE: | |
| 255 return ui::TextEditCommand::PASTE; | |
| 256 case ui::TextEditCommandAuraLinux::SELECT_ALL: | |
| 257 return ui::TextEditCommand::SELECT_ALL; | |
| 258 case ui::TextEditCommandAuraLinux::SET_MARK: | |
| 259 case ui::TextEditCommandAuraLinux::UNSELECT: | |
| 260 case ui::TextEditCommandAuraLinux::INVALID_COMMAND: | |
| 261 return ui::TextEditCommand::INVALID_COMMAND; | |
| 262 } | |
| 263 NOTREACHED(); | |
| 264 return ui::TextEditCommand::INVALID_COMMAND; | |
| 265 } | |
| 266 #endif | |
| 267 | |
| 268 const gfx::FontList& GetDefaultFontList() { | 170 const gfx::FontList& GetDefaultFontList() { |
| 269 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 171 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 270 return rb.GetFontListWithDelta(ui::kLabelFontSizeDelta); | 172 return rb.GetFontListWithDelta(ui::kLabelFontSizeDelta); |
| 271 } | 173 } |
| 272 | 174 |
| 273 // Returns ui::TextEditCommand corresponding to |command_id| menu action. | 175 // Returns ui::TextEditCommand corresponding to |command_id| menu action. |
| 274 // |has_selection| is true if the textfield has an active selection. | 176 // |has_selection| is true if the textfield has an active selection. |
| 275 // Keep in sync with UpdateContextMenu. | 177 // Keep in sync with UpdateContextMenu. |
| 276 ui::TextEditCommand GetTextEditCommandFromMenuCommand(int command_id, | 178 ui::TextEditCommand GetTextEditCommandFromMenuCommand(int command_id, |
| 277 bool has_selection) { | 179 bool has_selection) { |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 750 bool handled = controller_ && controller_->HandleKeyEvent(this, event); | 652 bool handled = controller_ && controller_->HandleKeyEvent(this, event); |
| 751 | 653 |
| 752 if (!textfield) | 654 if (!textfield) |
| 753 return handled; | 655 return handled; |
| 754 | 656 |
| 755 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 657 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 756 ui::TextEditKeyBindingsDelegateAuraLinux* delegate = | 658 ui::TextEditKeyBindingsDelegateAuraLinux* delegate = |
| 757 ui::GetTextEditKeyBindingsDelegate(); | 659 ui::GetTextEditKeyBindingsDelegate(); |
| 758 std::vector<ui::TextEditCommandAuraLinux> commands; | 660 std::vector<ui::TextEditCommandAuraLinux> commands; |
| 759 if (!handled && delegate && delegate->MatchEvent(event, &commands)) { | 661 if (!handled && delegate && delegate->MatchEvent(event, &commands)) { |
| 760 const bool rtl = GetTextDirection() == base::i18n::RIGHT_TO_LEFT; | |
| 761 for (size_t i = 0; i < commands.size(); ++i) { | 662 for (size_t i = 0; i < commands.size(); ++i) { |
| 762 const ui::TextEditCommand command = GetViewsCommand(commands[i], rtl); | 663 const ui::TextEditCommand command = commands[i].command(); |
|
msw
2016/06/10 01:33:23
optional nit: inline this.
karandeepb
2016/06/15 08:13:34
Done.
| |
| 763 if (IsEditCommandEnabled(command)) { | 664 if (IsEditCommandEnabled(command)) { |
| 764 ExecuteEditCommand(command); | 665 ExecuteEditCommand(command); |
| 765 handled = true; | 666 handled = true; |
| 766 } | 667 } |
| 767 } | 668 } |
| 768 return handled; | 669 return handled; |
| 769 } | 670 } |
| 770 #endif | 671 #endif |
| 771 | 672 |
| 772 if (edit_command == ui::TextEditCommand::INVALID_COMMAND) | 673 if (edit_command == ui::TextEditCommand::INVALID_COMMAND) |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 889 SelectAll(false); | 790 SelectAll(false); |
| 890 } | 791 } |
| 891 | 792 |
| 892 bool Textfield::SkipDefaultKeyEventProcessing(const ui::KeyEvent& event) { | 793 bool Textfield::SkipDefaultKeyEventProcessing(const ui::KeyEvent& event) { |
| 893 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 794 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 894 // Skip any accelerator handling that conflicts with custom keybindings. | 795 // Skip any accelerator handling that conflicts with custom keybindings. |
| 895 ui::TextEditKeyBindingsDelegateAuraLinux* delegate = | 796 ui::TextEditKeyBindingsDelegateAuraLinux* delegate = |
| 896 ui::GetTextEditKeyBindingsDelegate(); | 797 ui::GetTextEditKeyBindingsDelegate(); |
| 897 std::vector<ui::TextEditCommandAuraLinux> commands; | 798 std::vector<ui::TextEditCommandAuraLinux> commands; |
| 898 if (delegate && delegate->MatchEvent(event, &commands)) { | 799 if (delegate && delegate->MatchEvent(event, &commands)) { |
| 899 const bool rtl = GetTextDirection() == base::i18n::RIGHT_TO_LEFT; | |
| 900 for (size_t i = 0; i < commands.size(); ++i) | 800 for (size_t i = 0; i < commands.size(); ++i) |
| 901 if (IsEditCommandEnabled(GetViewsCommand(commands[i], rtl))) | 801 if (IsEditCommandEnabled(commands[i].command())) |
| 902 return true; | 802 return true; |
| 903 } | 803 } |
| 904 #endif | 804 #endif |
| 905 | 805 |
| 906 // Skip backspace accelerator handling; editable textfields handle this key. | 806 // Skip backspace accelerator handling; editable textfields handle this key. |
| 907 // Also skip processing Windows [Alt]+<num-pad digit> Unicode alt-codes. | 807 // Also skip processing Windows [Alt]+<num-pad digit> Unicode alt-codes. |
| 908 const bool is_backspace = event.key_code() == ui::VKEY_BACK; | 808 const bool is_backspace = event.key_code() == ui::VKEY_BACK; |
| 909 return (is_backspace && !read_only()) || event.IsUnicodeKeyCode(); | 809 return (is_backspace && !read_only()) || event.IsUnicodeKeyCode(); |
| 910 } | 810 } |
| 911 | 811 |
| (...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1547 ui::CLIPBOARD_TYPE_COPY_PASTE, &result); | 1447 ui::CLIPBOARD_TYPE_COPY_PASTE, &result); |
| 1548 return editable && !result.empty(); | 1448 return editable && !result.empty(); |
| 1549 case ui::TextEditCommand::SELECT_ALL: | 1449 case ui::TextEditCommand::SELECT_ALL: |
| 1550 return !text().empty(); | 1450 return !text().empty(); |
| 1551 case ui::TextEditCommand::DELETE_FORWARD: | 1451 case ui::TextEditCommand::DELETE_FORWARD: |
| 1552 case ui::TextEditCommand::DELETE_BACKWARD: | 1452 case ui::TextEditCommand::DELETE_BACKWARD: |
| 1553 case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_LINE: | 1453 case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_LINE: |
| 1554 case ui::TextEditCommand::DELETE_TO_END_OF_LINE: | 1454 case ui::TextEditCommand::DELETE_TO_END_OF_LINE: |
| 1555 case ui::TextEditCommand::DELETE_WORD_BACKWARD: | 1455 case ui::TextEditCommand::DELETE_WORD_BACKWARD: |
| 1556 case ui::TextEditCommand::DELETE_WORD_FORWARD: | 1456 case ui::TextEditCommand::DELETE_WORD_FORWARD: |
| 1457 case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_PARAGRAPH: | |
| 1458 case ui::TextEditCommand::DELETE_TO_END_OF_PARAGRAPH: | |
| 1557 return editable; | 1459 return editable; |
| 1558 case ui::TextEditCommand::MOVE_LEFT: | 1460 case ui::TextEditCommand::MOVE_LEFT: |
| 1559 case ui::TextEditCommand::MOVE_LEFT_AND_MODIFY_SELECTION: | 1461 case ui::TextEditCommand::MOVE_LEFT_AND_MODIFY_SELECTION: |
| 1560 case ui::TextEditCommand::MOVE_RIGHT: | 1462 case ui::TextEditCommand::MOVE_RIGHT: |
| 1561 case ui::TextEditCommand::MOVE_RIGHT_AND_MODIFY_SELECTION: | 1463 case ui::TextEditCommand::MOVE_RIGHT_AND_MODIFY_SELECTION: |
| 1562 case ui::TextEditCommand::MOVE_WORD_LEFT: | 1464 case ui::TextEditCommand::MOVE_WORD_LEFT: |
| 1563 case ui::TextEditCommand::MOVE_WORD_LEFT_AND_MODIFY_SELECTION: | 1465 case ui::TextEditCommand::MOVE_WORD_LEFT_AND_MODIFY_SELECTION: |
| 1564 case ui::TextEditCommand::MOVE_WORD_RIGHT: | 1466 case ui::TextEditCommand::MOVE_WORD_RIGHT: |
| 1565 case ui::TextEditCommand::MOVE_WORD_RIGHT_AND_MODIFY_SELECTION: | 1467 case ui::TextEditCommand::MOVE_WORD_RIGHT_AND_MODIFY_SELECTION: |
| 1566 case ui::TextEditCommand::MOVE_TO_BEGINNING_OF_LINE: | 1468 case ui::TextEditCommand::MOVE_TO_BEGINNING_OF_LINE: |
| 1567 case ui::TextEditCommand::MOVE_TO_BEGINNING_OF_LINE_AND_MODIFY_SELECTION: | 1469 case ui::TextEditCommand::MOVE_TO_BEGINNING_OF_LINE_AND_MODIFY_SELECTION: |
| 1568 case ui::TextEditCommand::MOVE_TO_END_OF_LINE: | 1470 case ui::TextEditCommand::MOVE_TO_END_OF_LINE: |
| 1569 case ui::TextEditCommand::MOVE_TO_END_OF_LINE_AND_MODIFY_SELECTION: | 1471 case ui::TextEditCommand::MOVE_TO_END_OF_LINE_AND_MODIFY_SELECTION: |
| 1472 case ui::TextEditCommand::MOVE_FORWARD: | |
| 1473 case ui::TextEditCommand::MOVE_BACKWARD: | |
| 1474 case ui::TextEditCommand::MOVE_TO_BEGINNING_OF_DOCUMENT: | |
| 1475 case ui::TextEditCommand::MOVE_TO_BEGINNING_OF_PARAGRAPH: | |
| 1476 case ui::TextEditCommand::MOVE_TO_END_OF_DOCUMENT: | |
| 1477 case ui::TextEditCommand::MOVE_TO_END_OF_PARAGRAPH: | |
| 1478 case ui::TextEditCommand::MOVE_WORD_BACKWARD: | |
| 1479 case ui::TextEditCommand::MOVE_WORD_FORWARD: | |
| 1480 case ui::TextEditCommand::MOVE_BACKWARD_AND_MODIFY_SELECTION: | |
| 1481 case ui::TextEditCommand::MOVE_FORWARD_AND_MODIFY_SELECTION: | |
| 1482 case ui::TextEditCommand:: | |
| 1483 MOVE_TO_BEGINNING_OF_DOCUMENT_AND_MODIFY_SELECTION: | |
| 1484 case ui::TextEditCommand:: | |
| 1485 MOVE_TO_BEGINNING_OF_PARAGRAPH_AND_MODIFY_SELECTION: | |
| 1486 case ui::TextEditCommand::MOVE_TO_END_OF_DOCUMENT_AND_MODIFY_SELECTION: | |
| 1487 case ui::TextEditCommand::MOVE_TO_END_OF_PARAGRAPH_AND_MODIFY_SELECTION: | |
| 1488 case ui::TextEditCommand::MOVE_WORD_BACKWARD_AND_MODIFY_SELECTION: | |
| 1489 case ui::TextEditCommand::MOVE_WORD_FORWARD_AND_MODIFY_SELECTION: | |
| 1570 return true; | 1490 return true; |
| 1571 case ui::TextEditCommand::MOVE_UP: | 1491 case ui::TextEditCommand::MOVE_UP: |
| 1572 case ui::TextEditCommand::MOVE_DOWN: | 1492 case ui::TextEditCommand::MOVE_DOWN: |
| 1493 case ui::TextEditCommand::MOVE_UP_AND_MODIFY_SELECTION: | |
| 1494 case ui::TextEditCommand::MOVE_DOWN_AND_MODIFY_SELECTION: | |
| 1495 case ui::TextEditCommand::INSERT_TEXT: | |
| 1496 case ui::TextEditCommand::MOVE_PAGE_DOWN: | |
| 1497 case ui::TextEditCommand::MOVE_PAGE_UP: | |
| 1498 case ui::TextEditCommand::MOVE_PAGE_DOWN_AND_MODIFY_SELECTION: | |
| 1499 case ui::TextEditCommand::MOVE_PAGE_UP_AND_MODIFY_SELECTION: | |
| 1500 case ui::TextEditCommand::SET_MARK: | |
| 1501 case ui::TextEditCommand::UNSELECT: | |
| 1573 return false; | 1502 return false; |
| 1574 } | 1503 } |
| 1575 NOTREACHED(); | 1504 NOTREACHED(); |
| 1576 return false; | 1505 return false; |
| 1577 } | 1506 } |
| 1578 | 1507 |
| 1579 void Textfield::SetEditCommandForNextKeyEvent(ui::TextEditCommand command) { | 1508 void Textfield::SetEditCommandForNextKeyEvent(ui::TextEditCommand command) { |
| 1580 DCHECK(scheduled_edit_command_ == ui::TextEditCommand::INVALID_COMMAND); | 1509 DCHECK(scheduled_edit_command_ == ui::TextEditCommand::INVALID_COMMAND); |
| 1581 scheduled_edit_command_ = command; | 1510 scheduled_edit_command_ = command; |
| 1582 } | 1511 } |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 1608 return selection_clipboard_text; | 1537 return selection_clipboard_text; |
| 1609 } | 1538 } |
| 1610 | 1539 |
| 1611 void Textfield::ExecuteEditCommand(ui::TextEditCommand command) { | 1540 void Textfield::ExecuteEditCommand(ui::TextEditCommand command) { |
| 1612 DestroyTouchSelection(); | 1541 DestroyTouchSelection(); |
| 1613 | 1542 |
| 1614 // Some codepaths may bypass GetCommandForKeyEvent, so any selection-dependent | 1543 // Some codepaths may bypass GetCommandForKeyEvent, so any selection-dependent |
| 1615 // modifications of the command should happen here. | 1544 // modifications of the command should happen here. |
| 1616 if (HasSelection()) { | 1545 if (HasSelection()) { |
| 1617 switch (command) { | 1546 switch (command) { |
| 1618 case ui::TextEditCommand::DELETE_WORD_BACKWARD: | 1547 case ui::TextEditCommand::DELETE_WORD_BACKWARD: |
|
msw
2016/06/10 01:33:23
nit: reorder these to something a bit neater.
karandeepb
2016/06/15 08:13:34
Done.
| |
| 1619 case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_LINE: | 1548 case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_LINE: |
| 1620 command = ui::TextEditCommand::DELETE_BACKWARD; | |
| 1621 break; | |
| 1622 case ui::TextEditCommand::DELETE_WORD_FORWARD: | 1549 case ui::TextEditCommand::DELETE_WORD_FORWARD: |
| 1623 case ui::TextEditCommand::DELETE_TO_END_OF_LINE: | 1550 case ui::TextEditCommand::DELETE_TO_END_OF_LINE: |
| 1551 case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_PARAGRAPH: | |
| 1552 case ui::TextEditCommand::DELETE_TO_END_OF_PARAGRAPH: | |
| 1624 command = ui::TextEditCommand::DELETE_FORWARD; | 1553 command = ui::TextEditCommand::DELETE_FORWARD; |
| 1625 break; | 1554 break; |
| 1626 default: | 1555 default: |
| 1627 break; | 1556 break; |
| 1628 } | 1557 } |
| 1629 } | 1558 } |
| 1630 | 1559 |
| 1631 // We only execute the commands enabled in Textfield::IsEditCommandEnabled | 1560 // We only execute the commands enabled in Textfield::IsEditCommandEnabled |
| 1632 // below. Hence don't do a virtual IsEditCommandEnabled call. | 1561 // below. Hence don't do a virtual IsEditCommandEnabled call. |
| 1633 if (!Textfield::IsEditCommandEnabled(command)) | 1562 if (!Textfield::IsEditCommandEnabled(command)) |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 1660 case ui::TextEditCommand::SELECT_ALL: | 1589 case ui::TextEditCommand::SELECT_ALL: |
| 1661 SelectAll(false); | 1590 SelectAll(false); |
| 1662 break; | 1591 break; |
| 1663 case ui::TextEditCommand::DELETE_BACKWARD: | 1592 case ui::TextEditCommand::DELETE_BACKWARD: |
| 1664 text_changed = cursor_changed = model_->Backspace(); | 1593 text_changed = cursor_changed = model_->Backspace(); |
| 1665 break; | 1594 break; |
| 1666 case ui::TextEditCommand::DELETE_FORWARD: | 1595 case ui::TextEditCommand::DELETE_FORWARD: |
| 1667 text_changed = cursor_changed = model_->Delete(); | 1596 text_changed = cursor_changed = model_->Delete(); |
| 1668 break; | 1597 break; |
| 1669 case ui::TextEditCommand::DELETE_TO_END_OF_LINE: | 1598 case ui::TextEditCommand::DELETE_TO_END_OF_LINE: |
| 1599 case ui::TextEditCommand::DELETE_TO_END_OF_PARAGRAPH: | |
| 1670 model_->MoveCursor(gfx::LINE_BREAK, end, true); | 1600 model_->MoveCursor(gfx::LINE_BREAK, end, true); |
| 1671 text_changed = cursor_changed = model_->Delete(); | 1601 text_changed = cursor_changed = model_->Delete(); |
| 1672 break; | 1602 break; |
| 1673 case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_LINE: | 1603 case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_LINE: |
| 1604 case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_PARAGRAPH: | |
| 1674 model_->MoveCursor(gfx::LINE_BREAK, begin, true); | 1605 model_->MoveCursor(gfx::LINE_BREAK, begin, true); |
| 1675 text_changed = cursor_changed = model_->Backspace(); | 1606 text_changed = cursor_changed = model_->Backspace(); |
| 1676 break; | 1607 break; |
| 1677 case ui::TextEditCommand::DELETE_WORD_BACKWARD: | 1608 case ui::TextEditCommand::DELETE_WORD_BACKWARD: |
| 1678 model_->MoveCursor(gfx::WORD_BREAK, begin, true); | 1609 model_->MoveCursor(gfx::WORD_BREAK, begin, true); |
| 1679 text_changed = cursor_changed = model_->Backspace(); | 1610 text_changed = cursor_changed = model_->Backspace(); |
| 1680 break; | 1611 break; |
| 1681 case ui::TextEditCommand::DELETE_WORD_FORWARD: | 1612 case ui::TextEditCommand::DELETE_WORD_FORWARD: |
| 1682 model_->MoveCursor(gfx::WORD_BREAK, end, true); | 1613 model_->MoveCursor(gfx::WORD_BREAK, end, true); |
| 1683 text_changed = cursor_changed = model_->Delete(); | 1614 text_changed = cursor_changed = model_->Delete(); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1700 case ui::TextEditCommand::MOVE_WORD_LEFT_AND_MODIFY_SELECTION: | 1631 case ui::TextEditCommand::MOVE_WORD_LEFT_AND_MODIFY_SELECTION: |
| 1701 model_->MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_LEFT, true); | 1632 model_->MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_LEFT, true); |
| 1702 break; | 1633 break; |
| 1703 case ui::TextEditCommand::MOVE_WORD_RIGHT: | 1634 case ui::TextEditCommand::MOVE_WORD_RIGHT: |
| 1704 model_->MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_RIGHT, false); | 1635 model_->MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_RIGHT, false); |
| 1705 break; | 1636 break; |
| 1706 case ui::TextEditCommand::MOVE_WORD_RIGHT_AND_MODIFY_SELECTION: | 1637 case ui::TextEditCommand::MOVE_WORD_RIGHT_AND_MODIFY_SELECTION: |
| 1707 model_->MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_RIGHT, true); | 1638 model_->MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_RIGHT, true); |
| 1708 break; | 1639 break; |
| 1709 case ui::TextEditCommand::MOVE_TO_BEGINNING_OF_LINE: | 1640 case ui::TextEditCommand::MOVE_TO_BEGINNING_OF_LINE: |
| 1641 case ui::TextEditCommand::MOVE_TO_BEGINNING_OF_DOCUMENT: | |
| 1642 case ui::TextEditCommand::MOVE_TO_BEGINNING_OF_PARAGRAPH: | |
| 1710 model_->MoveCursor(gfx::LINE_BREAK, begin, false); | 1643 model_->MoveCursor(gfx::LINE_BREAK, begin, false); |
| 1711 break; | 1644 break; |
| 1712 case ui::TextEditCommand::MOVE_TO_BEGINNING_OF_LINE_AND_MODIFY_SELECTION: | 1645 case ui::TextEditCommand::MOVE_TO_BEGINNING_OF_LINE_AND_MODIFY_SELECTION: |
| 1646 case ui::TextEditCommand:: | |
| 1647 MOVE_TO_BEGINNING_OF_DOCUMENT_AND_MODIFY_SELECTION: | |
| 1648 case ui::TextEditCommand:: | |
| 1649 MOVE_TO_BEGINNING_OF_PARAGRAPH_AND_MODIFY_SELECTION: | |
| 1713 model_->MoveCursor(gfx::LINE_BREAK, begin, true); | 1650 model_->MoveCursor(gfx::LINE_BREAK, begin, true); |
| 1714 break; | 1651 break; |
| 1715 case ui::TextEditCommand::MOVE_TO_END_OF_LINE: | 1652 case ui::TextEditCommand::MOVE_TO_END_OF_LINE: |
| 1653 case ui::TextEditCommand::MOVE_TO_END_OF_DOCUMENT: | |
| 1654 case ui::TextEditCommand::MOVE_TO_END_OF_PARAGRAPH: | |
| 1716 model_->MoveCursor(gfx::LINE_BREAK, end, false); | 1655 model_->MoveCursor(gfx::LINE_BREAK, end, false); |
| 1717 break; | 1656 break; |
| 1718 case ui::TextEditCommand::MOVE_TO_END_OF_LINE_AND_MODIFY_SELECTION: | 1657 case ui::TextEditCommand::MOVE_TO_END_OF_LINE_AND_MODIFY_SELECTION: |
| 1658 case ui::TextEditCommand::MOVE_TO_END_OF_DOCUMENT_AND_MODIFY_SELECTION: | |
| 1659 case ui::TextEditCommand::MOVE_TO_END_OF_PARAGRAPH_AND_MODIFY_SELECTION: | |
| 1719 model_->MoveCursor(gfx::LINE_BREAK, end, true); | 1660 model_->MoveCursor(gfx::LINE_BREAK, end, true); |
| 1720 break; | 1661 break; |
| 1662 | |
| 1663 case ui::TextEditCommand::MOVE_BACKWARD: | |
| 1664 model_->MoveCursor(gfx::CHARACTER_BREAK, begin, false); | |
| 1665 break; | |
| 1666 case ui::TextEditCommand::MOVE_FORWARD: | |
| 1667 model_->MoveCursor(gfx::CHARACTER_BREAK, end, false); | |
| 1668 break; | |
| 1669 case ui::TextEditCommand::MOVE_WORD_BACKWARD: | |
| 1670 model_->MoveCursor(gfx::WORD_BREAK, begin, false); | |
| 1671 break; | |
| 1672 case ui::TextEditCommand::MOVE_WORD_FORWARD: | |
| 1673 model_->MoveCursor(gfx::WORD_BREAK, end, false); | |
| 1674 break; | |
| 1675 case ui::TextEditCommand::MOVE_BACKWARD_AND_MODIFY_SELECTION: | |
|
msw
2016/06/10 01:33:23
ditto nit: keep pairing ordering or follow some ot
karandeepb
2016/06/15 08:13:34
Done.
| |
| 1676 model_->MoveCursor(gfx::CHARACTER_BREAK, begin, true); | |
| 1677 break; | |
| 1678 case ui::TextEditCommand::MOVE_FORWARD_AND_MODIFY_SELECTION: | |
| 1679 model_->MoveCursor(gfx::CHARACTER_BREAK, end, true); | |
| 1680 break; | |
| 1681 case ui::TextEditCommand::MOVE_WORD_BACKWARD_AND_MODIFY_SELECTION: | |
| 1682 model_->MoveCursor(gfx::WORD_BREAK, begin, true); | |
| 1683 break; | |
| 1684 case ui::TextEditCommand::MOVE_WORD_FORWARD_AND_MODIFY_SELECTION: | |
| 1685 model_->MoveCursor(gfx::WORD_BREAK, end, true); | |
| 1686 break; | |
| 1687 | |
| 1721 case ui::TextEditCommand::MOVE_UP: | 1688 case ui::TextEditCommand::MOVE_UP: |
| 1722 case ui::TextEditCommand::MOVE_DOWN: | 1689 case ui::TextEditCommand::MOVE_DOWN: |
| 1690 case ui::TextEditCommand::MOVE_UP_AND_MODIFY_SELECTION: | |
| 1691 case ui::TextEditCommand::MOVE_DOWN_AND_MODIFY_SELECTION: | |
| 1692 case ui::TextEditCommand::INSERT_TEXT: | |
| 1693 case ui::TextEditCommand::MOVE_PAGE_DOWN: | |
| 1694 case ui::TextEditCommand::MOVE_PAGE_UP: | |
| 1695 case ui::TextEditCommand::MOVE_PAGE_DOWN_AND_MODIFY_SELECTION: | |
| 1696 case ui::TextEditCommand::MOVE_PAGE_UP_AND_MODIFY_SELECTION: | |
| 1697 case ui::TextEditCommand::SET_MARK: | |
| 1698 case ui::TextEditCommand::UNSELECT: | |
| 1723 case ui::TextEditCommand::INVALID_COMMAND: | 1699 case ui::TextEditCommand::INVALID_COMMAND: |
| 1724 NOTREACHED(); | 1700 NOTREACHED(); |
| 1725 break; | 1701 break; |
| 1726 } | 1702 } |
| 1727 | 1703 |
| 1728 cursor_changed |= GetSelectionModel() != selection_model; | 1704 cursor_changed |= GetSelectionModel() != selection_model; |
| 1729 if (cursor_changed) | 1705 if (cursor_changed) |
| 1730 UpdateSelectionClipboard(); | 1706 UpdateSelectionClipboard(); |
| 1731 UpdateAfterChange(text_changed, cursor_changed); | 1707 UpdateAfterChange(text_changed, cursor_changed); |
| 1732 OnAfterUserAction(); | 1708 OnAfterUserAction(); |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1987 RequestFocus(); | 1963 RequestFocus(); |
| 1988 model_->MoveCursorTo(mouse); | 1964 model_->MoveCursorTo(mouse); |
| 1989 if (!selection_clipboard_text.empty()) { | 1965 if (!selection_clipboard_text.empty()) { |
| 1990 model_->InsertText(selection_clipboard_text); | 1966 model_->InsertText(selection_clipboard_text); |
| 1991 UpdateAfterChange(true, true); | 1967 UpdateAfterChange(true, true); |
| 1992 } | 1968 } |
| 1993 OnAfterUserAction(); | 1969 OnAfterUserAction(); |
| 1994 } | 1970 } |
| 1995 | 1971 |
| 1996 } // namespace views | 1972 } // namespace views |
| OLD | NEW |