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 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "ui/accessibility/ax_view_state.h" | 10 #include "ui/accessibility/ax_view_state.h" |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 } | 609 } |
610 OnAfterUserAction(); | 610 OnAfterUserAction(); |
611 } | 611 } |
612 | 612 |
613 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 613 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
614 if (event.IsOnlyMiddleMouseButton()) { | 614 if (event.IsOnlyMiddleMouseButton()) { |
615 if (GetRenderText()->IsPointInSelection(event.location())) { | 615 if (GetRenderText()->IsPointInSelection(event.location())) { |
616 OnBeforeUserAction(); | 616 OnBeforeUserAction(); |
617 ClearSelection(); | 617 ClearSelection(); |
618 ui::ScopedClipboardWriter( | 618 ui::ScopedClipboardWriter( |
619 ui::Clipboard::GetForCurrentThread(), | |
620 ui::CLIPBOARD_TYPE_SELECTION).WriteText(base::string16()); | 619 ui::CLIPBOARD_TYPE_SELECTION).WriteText(base::string16()); |
621 OnAfterUserAction(); | 620 OnAfterUserAction(); |
622 } else if (!read_only()) { | 621 } else if (!read_only()) { |
623 PasteSelectionClipboard(event); | 622 PasteSelectionClipboard(event); |
624 } | 623 } |
625 } | 624 } |
626 #endif | 625 #endif |
627 } | 626 } |
628 | 627 |
629 return true; | 628 return true; |
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1784 ui::TouchSelectionController::create(this)); | 1783 ui::TouchSelectionController::create(this)); |
1785 } | 1784 } |
1786 if (touch_selection_controller_) | 1785 if (touch_selection_controller_) |
1787 touch_selection_controller_->SelectionChanged(); | 1786 touch_selection_controller_->SelectionChanged(); |
1788 } | 1787 } |
1789 | 1788 |
1790 void Textfield::UpdateSelectionClipboard() const { | 1789 void Textfield::UpdateSelectionClipboard() const { |
1791 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 1790 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
1792 if (performing_user_action_ && HasSelection()) { | 1791 if (performing_user_action_ && HasSelection()) { |
1793 ui::ScopedClipboardWriter( | 1792 ui::ScopedClipboardWriter( |
1794 ui::Clipboard::GetForCurrentThread(), | |
1795 ui::CLIPBOARD_TYPE_SELECTION).WriteText(GetSelectedText()); | 1793 ui::CLIPBOARD_TYPE_SELECTION).WriteText(GetSelectedText()); |
1796 if (controller_) | 1794 if (controller_) |
1797 controller_->OnAfterCutOrCopy(ui::CLIPBOARD_TYPE_SELECTION); | 1795 controller_->OnAfterCutOrCopy(ui::CLIPBOARD_TYPE_SELECTION); |
1798 } | 1796 } |
1799 #endif | 1797 #endif |
1800 } | 1798 } |
1801 | 1799 |
1802 void Textfield::PasteSelectionClipboard(const ui::MouseEvent& event) { | 1800 void Textfield::PasteSelectionClipboard(const ui::MouseEvent& event) { |
1803 DCHECK(event.IsOnlyMiddleMouseButton()); | 1801 DCHECK(event.IsOnlyMiddleMouseButton()); |
1804 DCHECK(!read_only()); | 1802 DCHECK(!read_only()); |
(...skipping 11 matching lines...) Expand all Loading... |
1816 const size_t length = selection_clipboard_text.length(); | 1814 const size_t length = selection_clipboard_text.length(); |
1817 range = gfx::Range(range.start() + length, range.end() + length); | 1815 range = gfx::Range(range.start() + length, range.end() + length); |
1818 } | 1816 } |
1819 model_->MoveCursorTo(gfx::SelectionModel(range, affinity)); | 1817 model_->MoveCursorTo(gfx::SelectionModel(range, affinity)); |
1820 UpdateAfterChange(true, true); | 1818 UpdateAfterChange(true, true); |
1821 OnAfterUserAction(); | 1819 OnAfterUserAction(); |
1822 } | 1820 } |
1823 } | 1821 } |
1824 | 1822 |
1825 } // namespace views | 1823 } // namespace views |
OLD | NEW |