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/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 876 // Adjust the drop destination if it is on or after the current selection. | 876 // Adjust the drop destination if it is on or after the current selection. |
| 877 size_t pos = drop_destination_model.caret_pos(); | 877 size_t pos = drop_destination_model.caret_pos(); |
| 878 pos -= render_text->selection().Intersect(gfx::Range(0, pos)).length(); | 878 pos -= render_text->selection().Intersect(gfx::Range(0, pos)).length(); |
| 879 model_->DeleteSelectionAndInsertTextAt(new_text, pos); | 879 model_->DeleteSelectionAndInsertTextAt(new_text, pos); |
| 880 } else { | 880 } else { |
| 881 model_->MoveCursorTo(drop_destination_model); | 881 model_->MoveCursorTo(drop_destination_model); |
| 882 // Drop always inserts text even if the textfield is not in insert mode. | 882 // Drop always inserts text even if the textfield is not in insert mode. |
| 883 model_->InsertText(new_text); | 883 model_->InsertText(new_text); |
| 884 } | 884 } |
| 885 skip_input_method_cancel_composition_ = false; | 885 skip_input_method_cancel_composition_ = false; |
| 886 OnAfterUserAction(); | |
| 886 UpdateAfterChange(true, true); | 887 UpdateAfterChange(true, true); |
| 887 OnAfterUserAction(); | |
| 888 return move ? ui::DragDropTypes::DRAG_MOVE : ui::DragDropTypes::DRAG_COPY; | 888 return move ? ui::DragDropTypes::DRAG_MOVE : ui::DragDropTypes::DRAG_COPY; |
| 889 } | 889 } |
| 890 | 890 |
| 891 void Textfield::OnDragDone() { | 891 void Textfield::OnDragDone() { |
| 892 initiating_drag_ = false; | 892 initiating_drag_ = false; |
| 893 drop_cursor_visible_ = false; | 893 drop_cursor_visible_ = false; |
| 894 } | 894 } |
| 895 | 895 |
| 896 void Textfield::GetAccessibleNodeData(ui::AXNodeData* node_data) { | 896 void Textfield::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
| 897 node_data->role = ui::AX_ROLE_TEXT_FIELD; | 897 node_data->role = ui::AX_ROLE_TEXT_FIELD; |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1256 // Textfield, ui::TextInputClient overrides: | 1256 // Textfield, ui::TextInputClient overrides: |
| 1257 | 1257 |
| 1258 void Textfield::SetCompositionText(const ui::CompositionText& composition) { | 1258 void Textfield::SetCompositionText(const ui::CompositionText& composition) { |
| 1259 if (GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE) | 1259 if (GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE) |
| 1260 return; | 1260 return; |
| 1261 | 1261 |
| 1262 OnBeforeUserAction(); | 1262 OnBeforeUserAction(); |
| 1263 skip_input_method_cancel_composition_ = true; | 1263 skip_input_method_cancel_composition_ = true; |
| 1264 model_->SetCompositionText(composition); | 1264 model_->SetCompositionText(composition); |
| 1265 skip_input_method_cancel_composition_ = false; | 1265 skip_input_method_cancel_composition_ = false; |
| 1266 OnAfterUserAction(); | |
| 1266 UpdateAfterChange(true, true); | 1267 UpdateAfterChange(true, true); |
| 1267 OnAfterUserAction(); | |
| 1268 } | 1268 } |
| 1269 | 1269 |
| 1270 void Textfield::ConfirmCompositionText() { | 1270 void Textfield::ConfirmCompositionText() { |
| 1271 if (!model_->HasCompositionText()) | 1271 if (!model_->HasCompositionText()) |
| 1272 return; | 1272 return; |
| 1273 | 1273 |
| 1274 OnBeforeUserAction(); | 1274 OnBeforeUserAction(); |
| 1275 skip_input_method_cancel_composition_ = true; | 1275 skip_input_method_cancel_composition_ = true; |
| 1276 model_->ConfirmCompositionText(); | 1276 model_->ConfirmCompositionText(); |
| 1277 skip_input_method_cancel_composition_ = false; | 1277 skip_input_method_cancel_composition_ = false; |
| 1278 OnAfterUserAction(); | |
| 1278 UpdateAfterChange(true, true); | 1279 UpdateAfterChange(true, true); |
| 1279 OnAfterUserAction(); | |
| 1280 } | 1280 } |
| 1281 | 1281 |
| 1282 void Textfield::ClearCompositionText() { | 1282 void Textfield::ClearCompositionText() { |
| 1283 if (!model_->HasCompositionText()) | 1283 if (!model_->HasCompositionText()) |
| 1284 return; | 1284 return; |
| 1285 | 1285 |
| 1286 OnBeforeUserAction(); | 1286 OnBeforeUserAction(); |
| 1287 skip_input_method_cancel_composition_ = true; | 1287 skip_input_method_cancel_composition_ = true; |
| 1288 model_->CancelCompositionText(); | 1288 model_->CancelCompositionText(); |
| 1289 skip_input_method_cancel_composition_ = false; | 1289 skip_input_method_cancel_composition_ = false; |
| 1290 OnAfterUserAction(); | |
| 1290 UpdateAfterChange(true, true); | 1291 UpdateAfterChange(true, true); |
| 1291 OnAfterUserAction(); | |
| 1292 } | 1292 } |
| 1293 | 1293 |
| 1294 void Textfield::InsertText(const base::string16& new_text) { | 1294 void Textfield::InsertText(const base::string16& new_text) { |
| 1295 // TODO(suzhe): Filter invalid characters. | 1295 // TODO(suzhe): Filter invalid characters. |
| 1296 if (GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE || new_text.empty()) | 1296 if (GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE || new_text.empty()) |
| 1297 return; | 1297 return; |
| 1298 | 1298 |
| 1299 OnBeforeUserAction(); | 1299 OnBeforeUserAction(); |
| 1300 skip_input_method_cancel_composition_ = true; | 1300 skip_input_method_cancel_composition_ = true; |
| 1301 model_->InsertText(new_text); | 1301 model_->InsertText(new_text); |
| 1302 skip_input_method_cancel_composition_ = false; | 1302 skip_input_method_cancel_composition_ = false; |
| 1303 OnAfterUserAction(); | |
| 1303 UpdateAfterChange(true, true); | 1304 UpdateAfterChange(true, true); |
| 1304 OnAfterUserAction(); | |
| 1305 } | 1305 } |
| 1306 | 1306 |
| 1307 void Textfield::InsertChar(const ui::KeyEvent& event) { | 1307 void Textfield::InsertChar(const ui::KeyEvent& event) { |
| 1308 if (read_only()) { | 1308 if (read_only()) { |
| 1309 OnEditFailed(); | 1309 OnEditFailed(); |
| 1310 return; | 1310 return; |
| 1311 } | 1311 } |
| 1312 | 1312 |
| 1313 // Filter out all control characters, including tab and new line characters, | 1313 // Filter out all control characters, including tab and new line characters, |
| 1314 // and all characters with Alt modifier (and Search on ChromeOS, Ctrl on | 1314 // and all characters with Alt modifier (and Search on ChromeOS, Ctrl on |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1422 } | 1422 } |
| 1423 | 1423 |
| 1424 bool Textfield::DeleteRange(const gfx::Range& range) { | 1424 bool Textfield::DeleteRange(const gfx::Range& range) { |
| 1425 if (!ImeEditingAllowed() || range.is_empty()) | 1425 if (!ImeEditingAllowed() || range.is_empty()) |
| 1426 return false; | 1426 return false; |
| 1427 | 1427 |
| 1428 OnBeforeUserAction(); | 1428 OnBeforeUserAction(); |
| 1429 model_->SelectRange(range); | 1429 model_->SelectRange(range); |
| 1430 if (model_->HasSelection()) { | 1430 if (model_->HasSelection()) { |
| 1431 model_->DeleteSelection(); | 1431 model_->DeleteSelection(); |
| 1432 UpdateAfterChange(true, true); | 1432 UpdateAfterChange(true, true); |
|
msw
2017/03/09 17:07:45
I really don't understand this change well enough.
sadrul
2017/03/09 18:55:05
I missed this. Thanks for catching this.
I think
| |
| 1433 } | 1433 } |
| 1434 OnAfterUserAction(); | 1434 OnAfterUserAction(); |
| 1435 return true; | 1435 return true; |
| 1436 } | 1436 } |
| 1437 | 1437 |
| 1438 bool Textfield::GetTextFromRange(const gfx::Range& range, | 1438 bool Textfield::GetTextFromRange(const gfx::Range& range, |
| 1439 base::string16* range_text) const { | 1439 base::string16* range_text) const { |
| 1440 if (!ImeEditingAllowed() || !range.IsValid()) | 1440 if (!ImeEditingAllowed() || !range.IsValid()) |
| 1441 return false; | 1441 return false; |
| 1442 | 1442 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1576 | 1576 |
| 1577 //////////////////////////////////////////////////////////////////////////////// | 1577 //////////////////////////////////////////////////////////////////////////////// |
| 1578 // Textfield, protected: | 1578 // Textfield, protected: |
| 1579 | 1579 |
| 1580 void Textfield::DoInsertChar(base::char16 ch) { | 1580 void Textfield::DoInsertChar(base::char16 ch) { |
| 1581 OnBeforeUserAction(); | 1581 OnBeforeUserAction(); |
| 1582 skip_input_method_cancel_composition_ = true; | 1582 skip_input_method_cancel_composition_ = true; |
| 1583 model_->InsertChar(ch); | 1583 model_->InsertChar(ch); |
| 1584 skip_input_method_cancel_composition_ = false; | 1584 skip_input_method_cancel_composition_ = false; |
| 1585 | 1585 |
| 1586 OnAfterUserAction(); | |
| 1586 UpdateAfterChange(true, true); | 1587 UpdateAfterChange(true, true); |
| 1587 OnAfterUserAction(); | |
| 1588 } | 1588 } |
| 1589 | 1589 |
| 1590 gfx::RenderText* Textfield::GetRenderText() const { | 1590 gfx::RenderText* Textfield::GetRenderText() const { |
| 1591 return model_->render_text(); | 1591 return model_->render_text(); |
| 1592 } | 1592 } |
| 1593 | 1593 |
| 1594 gfx::Point Textfield::GetLastClickLocation() const { | 1594 gfx::Point Textfield::GetLastClickLocation() const { |
| 1595 return selection_controller_.last_click_location(); | 1595 return selection_controller_.last_click_location(); |
| 1596 } | 1596 } |
| 1597 | 1597 |
| 1598 base::string16 Textfield::GetSelectionClipboardText() const { | 1598 base::string16 Textfield::GetSelectionClipboardText() const { |
| 1599 base::string16 selection_clipboard_text; | 1599 base::string16 selection_clipboard_text; |
| 1600 ui::Clipboard::GetForCurrentThread()->ReadText( | 1600 ui::Clipboard::GetForCurrentThread()->ReadText( |
| 1601 ui::CLIPBOARD_TYPE_SELECTION, &selection_clipboard_text); | 1601 ui::CLIPBOARD_TYPE_SELECTION, &selection_clipboard_text); |
| 1602 return selection_clipboard_text; | 1602 return selection_clipboard_text; |
| 1603 } | 1603 } |
| 1604 | 1604 |
| 1605 void Textfield::ExecuteTextEditCommand(ui::TextEditCommand command) { | 1605 void Textfield::ExecuteTextEditCommand(ui::TextEditCommand command) { |
| 1606 DestroyTouchSelection(); | 1606 DestroyTouchSelection(); |
| 1607 | 1607 |
| 1608 bool add_to_kill_buffer = false; | 1608 // We only execute the commands enabled in Textfield::IsTextEditCommandEnabled |
| 1609 // below. Hence don't do a virtual IsTextEditCommandEnabled call. | |
| 1610 if (!Textfield::IsTextEditCommandEnabled(command)) | |
| 1611 return; | |
| 1612 | |
| 1613 gfx::SelectionModel selection_model = GetSelectionModel(); | |
| 1614 OnBeforeUserAction(); | |
| 1609 | 1615 |
| 1610 // Some codepaths may bypass GetCommandForKeyEvent, so any selection-dependent | 1616 // Some codepaths may bypass GetCommandForKeyEvent, so any selection-dependent |
| 1611 // modifications of the command should happen here. | 1617 // modifications of the command should happen here. |
| 1612 switch (command) { | 1618 switch (command) { |
| 1613 case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_LINE: | 1619 case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_LINE: |
| 1614 case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_PARAGRAPH: | 1620 case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_PARAGRAPH: |
| 1615 case ui::TextEditCommand::DELETE_TO_END_OF_LINE: | 1621 case ui::TextEditCommand::DELETE_TO_END_OF_LINE: |
| 1616 case ui::TextEditCommand::DELETE_TO_END_OF_PARAGRAPH: | 1622 case ui::TextEditCommand::DELETE_TO_END_OF_PARAGRAPH: |
| 1617 add_to_kill_buffer = text_input_type_ != ui::TEXT_INPUT_TYPE_PASSWORD; | |
| 1618 // Fall through. | |
| 1619 case ui::TextEditCommand::DELETE_WORD_BACKWARD: | 1623 case ui::TextEditCommand::DELETE_WORD_BACKWARD: |
| 1620 case ui::TextEditCommand::DELETE_WORD_FORWARD: | 1624 case ui::TextEditCommand::DELETE_WORD_FORWARD: |
| 1621 if (HasSelection()) | 1625 if (HasSelection()) |
| 1622 command = ui::TextEditCommand::DELETE_FORWARD; | 1626 command = ui::TextEditCommand::DELETE_FORWARD; |
| 1623 break; | 1627 break; |
| 1624 default: | 1628 default: |
| 1625 break; | 1629 break; |
| 1626 } | 1630 } |
| 1631 bool text_changed = ExecuteTextEditCommandImpl(command); | |
| 1632 bool cursor_changed = text_changed; | |
| 1633 | |
| 1634 cursor_changed |= GetSelectionModel() != selection_model; | |
| 1635 if (cursor_changed && HasSelection()) | |
| 1636 UpdateSelectionClipboard(); | |
| 1637 OnAfterUserAction(); | |
| 1638 UpdateAfterChange(text_changed, cursor_changed); | |
| 1639 } | |
| 1640 | |
| 1641 bool Textfield::ExecuteTextEditCommandImpl(ui::TextEditCommand command) { | |
| 1642 bool add_to_kill_buffer = false; | |
| 1643 | |
| 1644 // Some codepaths may bypass GetCommandForKeyEvent, so any selection-dependent | |
| 1645 // modifications of the command should happen here. | |
| 1646 switch (command) { | |
| 1647 case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_LINE: | |
| 1648 case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_PARAGRAPH: | |
| 1649 case ui::TextEditCommand::DELETE_TO_END_OF_LINE: | |
| 1650 case ui::TextEditCommand::DELETE_TO_END_OF_PARAGRAPH: | |
| 1651 add_to_kill_buffer = text_input_type_ != ui::TEXT_INPUT_TYPE_PASSWORD; | |
| 1652 break; | |
| 1653 default: | |
| 1654 break; | |
| 1655 } | |
| 1627 | 1656 |
| 1628 // We only execute the commands enabled in Textfield::IsTextEditCommandEnabled | |
| 1629 // below. Hence don't do a virtual IsTextEditCommandEnabled call. | |
| 1630 if (!Textfield::IsTextEditCommandEnabled(command)) | |
| 1631 return; | |
| 1632 | |
| 1633 bool text_changed = false; | |
| 1634 bool cursor_changed = false; | |
| 1635 bool rtl = GetTextDirection() == base::i18n::RIGHT_TO_LEFT; | 1657 bool rtl = GetTextDirection() == base::i18n::RIGHT_TO_LEFT; |
| 1636 gfx::VisualCursorDirection begin = rtl ? gfx::CURSOR_RIGHT : gfx::CURSOR_LEFT; | 1658 gfx::VisualCursorDirection begin = rtl ? gfx::CURSOR_RIGHT : gfx::CURSOR_LEFT; |
| 1637 gfx::VisualCursorDirection end = rtl ? gfx::CURSOR_LEFT : gfx::CURSOR_RIGHT; | 1659 gfx::VisualCursorDirection end = rtl ? gfx::CURSOR_LEFT : gfx::CURSOR_RIGHT; |
| 1638 gfx::SelectionModel selection_model = GetSelectionModel(); | 1660 bool is_text_changed = false; |
| 1639 | 1661 |
| 1640 OnBeforeUserAction(); | |
| 1641 switch (command) { | 1662 switch (command) { |
| 1642 case ui::TextEditCommand::DELETE_BACKWARD: | 1663 case ui::TextEditCommand::DELETE_BACKWARD: |
| 1643 text_changed = cursor_changed = model_->Backspace(add_to_kill_buffer); | 1664 is_text_changed = model_->Backspace(add_to_kill_buffer); |
| 1644 break; | 1665 break; |
| 1645 case ui::TextEditCommand::DELETE_FORWARD: | 1666 case ui::TextEditCommand::DELETE_FORWARD: |
| 1646 text_changed = cursor_changed = model_->Delete(add_to_kill_buffer); | 1667 is_text_changed = model_->Delete(add_to_kill_buffer); |
| 1647 break; | 1668 break; |
| 1648 case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_LINE: | 1669 case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_LINE: |
| 1649 case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_PARAGRAPH: | 1670 case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_PARAGRAPH: |
| 1650 model_->MoveCursor(gfx::LINE_BREAK, begin, gfx::SELECTION_RETAIN); | 1671 model_->MoveCursor(gfx::LINE_BREAK, begin, gfx::SELECTION_RETAIN); |
| 1651 text_changed = cursor_changed = model_->Backspace(add_to_kill_buffer); | 1672 is_text_changed = model_->Backspace(add_to_kill_buffer); |
| 1652 break; | 1673 break; |
| 1653 case ui::TextEditCommand::DELETE_TO_END_OF_LINE: | 1674 case ui::TextEditCommand::DELETE_TO_END_OF_LINE: |
| 1654 case ui::TextEditCommand::DELETE_TO_END_OF_PARAGRAPH: | 1675 case ui::TextEditCommand::DELETE_TO_END_OF_PARAGRAPH: |
| 1655 model_->MoveCursor(gfx::LINE_BREAK, end, gfx::SELECTION_RETAIN); | 1676 model_->MoveCursor(gfx::LINE_BREAK, end, gfx::SELECTION_RETAIN); |
| 1656 text_changed = cursor_changed = model_->Delete(add_to_kill_buffer); | 1677 is_text_changed = model_->Delete(add_to_kill_buffer); |
| 1657 break; | 1678 break; |
| 1658 case ui::TextEditCommand::DELETE_WORD_BACKWARD: | 1679 case ui::TextEditCommand::DELETE_WORD_BACKWARD: |
| 1659 model_->MoveCursor(gfx::WORD_BREAK, begin, gfx::SELECTION_RETAIN); | 1680 model_->MoveCursor(gfx::WORD_BREAK, begin, gfx::SELECTION_RETAIN); |
| 1660 text_changed = cursor_changed = model_->Backspace(add_to_kill_buffer); | 1681 is_text_changed = model_->Backspace(add_to_kill_buffer); |
| 1661 break; | 1682 break; |
| 1662 case ui::TextEditCommand::DELETE_WORD_FORWARD: | 1683 case ui::TextEditCommand::DELETE_WORD_FORWARD: |
| 1663 model_->MoveCursor(gfx::WORD_BREAK, end, gfx::SELECTION_RETAIN); | 1684 model_->MoveCursor(gfx::WORD_BREAK, end, gfx::SELECTION_RETAIN); |
| 1664 text_changed = cursor_changed = model_->Delete(add_to_kill_buffer); | 1685 is_text_changed = model_->Delete(add_to_kill_buffer); |
| 1665 break; | 1686 break; |
| 1666 case ui::TextEditCommand::MOVE_BACKWARD: | 1687 case ui::TextEditCommand::MOVE_BACKWARD: |
| 1667 model_->MoveCursor(gfx::CHARACTER_BREAK, begin, gfx::SELECTION_NONE); | 1688 model_->MoveCursor(gfx::CHARACTER_BREAK, begin, gfx::SELECTION_NONE); |
| 1668 break; | 1689 break; |
| 1669 case ui::TextEditCommand::MOVE_BACKWARD_AND_MODIFY_SELECTION: | 1690 case ui::TextEditCommand::MOVE_BACKWARD_AND_MODIFY_SELECTION: |
| 1670 model_->MoveCursor(gfx::CHARACTER_BREAK, begin, gfx::SELECTION_RETAIN); | 1691 model_->MoveCursor(gfx::CHARACTER_BREAK, begin, gfx::SELECTION_RETAIN); |
| 1671 break; | 1692 break; |
| 1672 case ui::TextEditCommand::MOVE_FORWARD: | 1693 case ui::TextEditCommand::MOVE_FORWARD: |
| 1673 model_->MoveCursor(gfx::CHARACTER_BREAK, end, gfx::SELECTION_NONE); | 1694 model_->MoveCursor(gfx::CHARACTER_BREAK, end, gfx::SELECTION_NONE); |
| 1674 break; | 1695 break; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1754 break; | 1775 break; |
| 1755 case ui::TextEditCommand::MOVE_WORD_RIGHT: | 1776 case ui::TextEditCommand::MOVE_WORD_RIGHT: |
| 1756 model_->MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_RIGHT, | 1777 model_->MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_RIGHT, |
| 1757 gfx::SELECTION_NONE); | 1778 gfx::SELECTION_NONE); |
| 1758 break; | 1779 break; |
| 1759 case ui::TextEditCommand::MOVE_WORD_RIGHT_AND_MODIFY_SELECTION: | 1780 case ui::TextEditCommand::MOVE_WORD_RIGHT_AND_MODIFY_SELECTION: |
| 1760 model_->MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_RIGHT, | 1781 model_->MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_RIGHT, |
| 1761 kWordSelectionBehavior); | 1782 kWordSelectionBehavior); |
| 1762 break; | 1783 break; |
| 1763 case ui::TextEditCommand::UNDO: | 1784 case ui::TextEditCommand::UNDO: |
| 1764 text_changed = cursor_changed = model_->Undo(); | 1785 is_text_changed = model_->Undo(); |
| 1765 break; | 1786 break; |
| 1766 case ui::TextEditCommand::REDO: | 1787 case ui::TextEditCommand::REDO: |
| 1767 text_changed = cursor_changed = model_->Redo(); | 1788 is_text_changed = model_->Redo(); |
| 1768 break; | 1789 break; |
| 1769 case ui::TextEditCommand::CUT: | 1790 case ui::TextEditCommand::CUT: |
| 1770 text_changed = cursor_changed = Cut(); | 1791 is_text_changed = Cut(); |
| 1771 break; | 1792 break; |
| 1772 case ui::TextEditCommand::COPY: | 1793 case ui::TextEditCommand::COPY: |
| 1773 Copy(); | 1794 Copy(); |
| 1774 break; | 1795 break; |
| 1775 case ui::TextEditCommand::PASTE: | 1796 case ui::TextEditCommand::PASTE: |
| 1776 text_changed = cursor_changed = Paste(); | 1797 is_text_changed = Paste(); |
| 1777 break; | 1798 break; |
| 1778 case ui::TextEditCommand::SELECT_ALL: | 1799 case ui::TextEditCommand::SELECT_ALL: |
| 1779 SelectAll(false); | 1800 SelectAll(false); |
| 1780 break; | 1801 break; |
| 1781 case ui::TextEditCommand::TRANSPOSE: | 1802 case ui::TextEditCommand::TRANSPOSE: |
| 1782 text_changed = cursor_changed = model_->Transpose(); | 1803 is_text_changed = model_->Transpose(); |
| 1783 break; | 1804 break; |
| 1784 case ui::TextEditCommand::YANK: | 1805 case ui::TextEditCommand::YANK: |
| 1785 text_changed = cursor_changed = model_->Yank(); | 1806 is_text_changed = model_->Yank(); |
| 1786 break; | 1807 break; |
| 1787 case ui::TextEditCommand::INSERT_TEXT: | 1808 case ui::TextEditCommand::INSERT_TEXT: |
| 1788 case ui::TextEditCommand::SET_MARK: | 1809 case ui::TextEditCommand::SET_MARK: |
| 1789 case ui::TextEditCommand::UNSELECT: | 1810 case ui::TextEditCommand::UNSELECT: |
| 1790 case ui::TextEditCommand::INVALID_COMMAND: | 1811 case ui::TextEditCommand::INVALID_COMMAND: |
| 1791 NOTREACHED(); | 1812 NOTREACHED(); |
| 1792 break; | 1813 break; |
| 1793 } | 1814 } |
| 1794 | 1815 return is_text_changed; |
| 1795 cursor_changed |= GetSelectionModel() != selection_model; | |
| 1796 if (cursor_changed && HasSelection()) | |
| 1797 UpdateSelectionClipboard(); | |
| 1798 UpdateAfterChange(text_changed, cursor_changed); | |
| 1799 OnAfterUserAction(); | |
| 1800 } | 1816 } |
| 1801 | 1817 |
| 1802 //////////////////////////////////////////////////////////////////////////////// | 1818 //////////////////////////////////////////////////////////////////////////////// |
| 1803 // Textfield, private: | 1819 // Textfield, private: |
| 1804 | 1820 |
| 1805 //////////////////////////////////////////////////////////////////////////////// | 1821 //////////////////////////////////////////////////////////////////////////////// |
| 1806 // Textfield, SelectionControllerDelegate overrides: | 1822 // Textfield, SelectionControllerDelegate overrides: |
| 1807 | 1823 |
| 1808 gfx::RenderText* Textfield::GetRenderTextForSelectionController() { | 1824 gfx::RenderText* Textfield::GetRenderTextForSelectionController() { |
| 1809 return GetRenderText(); | 1825 return GetRenderText(); |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2086 cursor_blink_timer_.Stop(); | 2102 cursor_blink_timer_.Stop(); |
| 2087 } | 2103 } |
| 2088 | 2104 |
| 2089 void Textfield::OnCursorBlinkTimerFired() { | 2105 void Textfield::OnCursorBlinkTimerFired() { |
| 2090 DCHECK(ShouldBlinkCursor()); | 2106 DCHECK(ShouldBlinkCursor()); |
| 2091 cursor_view_.SetVisible(!cursor_view_.visible()); | 2107 cursor_view_.SetVisible(!cursor_view_.visible()); |
| 2092 UpdateCursorView(); | 2108 UpdateCursorView(); |
| 2093 } | 2109 } |
| 2094 | 2110 |
| 2095 } // namespace views | 2111 } // namespace views |
| OLD | NEW |