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

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

Issue 358553004: Added text filtering to Overview Mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Thanks chrome team for helping me fix the previous patch Created 6 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 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "grit/ui_strings.h" 10 #include "grit/ui_strings.h"
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 594
595 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 595 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
596 if (event.IsOnlyMiddleMouseButton()) { 596 if (event.IsOnlyMiddleMouseButton()) {
597 if (GetRenderText()->IsPointInSelection(event.location())) { 597 if (GetRenderText()->IsPointInSelection(event.location())) {
598 OnBeforeUserAction(); 598 OnBeforeUserAction();
599 ClearSelection(); 599 ClearSelection();
600 ui::ScopedClipboardWriter( 600 ui::ScopedClipboardWriter(
601 ui::Clipboard::GetForCurrentThread(), 601 ui::Clipboard::GetForCurrentThread(),
602 ui::CLIPBOARD_TYPE_SELECTION).WriteText(base::string16()); 602 ui::CLIPBOARD_TYPE_SELECTION).WriteText(base::string16());
603 OnAfterUserAction(); 603 OnAfterUserAction();
604 } else if(!read_only()) { 604 } else if (!read_only()) {
605 PasteSelectionClipboard(event); 605 PasteSelectionClipboard(event);
606 } 606 }
607 } 607 }
608 #endif 608 #endif
609 } 609 }
610 610
611 return true; 611 return true;
612 } 612 }
613 613
614 bool Textfield::OnMouseDragged(const ui::MouseEvent& event) { 614 bool Textfield::OnMouseDragged(const ui::MouseEvent& event) {
(...skipping 25 matching lines...) Expand all
640 drag_selection_timer_.Stop(); 640 drag_selection_timer_.Stop();
641 // Cancel suspected drag initiations, the user was clicking in the selection. 641 // Cancel suspected drag initiations, the user was clicking in the selection.
642 if (initiating_drag_) 642 if (initiating_drag_)
643 MoveCursorTo(event.location(), false); 643 MoveCursorTo(event.location(), false);
644 initiating_drag_ = false; 644 initiating_drag_ = false;
645 UpdateSelectionClipboard(); 645 UpdateSelectionClipboard();
646 OnAfterUserAction(); 646 OnAfterUserAction();
647 } 647 }
648 648
649 bool Textfield::OnKeyPressed(const ui::KeyEvent& event) { 649 bool Textfield::OnKeyPressed(const ui::KeyEvent& event) {
650 // Since HandleKeyEvent() might destroy |this|, get a weak pointer and verify
651 // it isn't null before proceeding.
652 base::WeakPtr<Textfield> textfield(weak_ptr_factory_.GetWeakPtr());
650 bool handled = controller_ && controller_->HandleKeyEvent(this, event); 653 bool handled = controller_ && controller_->HandleKeyEvent(this, event);
651 654
655 if (!textfield)
656 return handled;
657
652 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 658 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
653 ui::TextEditKeyBindingsDelegateAuraLinux* delegate = 659 ui::TextEditKeyBindingsDelegateAuraLinux* delegate =
654 ui::GetTextEditKeyBindingsDelegate(); 660 ui::GetTextEditKeyBindingsDelegate();
655 std::vector<ui::TextEditCommandAuraLinux> commands; 661 std::vector<ui::TextEditCommandAuraLinux> commands;
656 if (!handled && delegate && delegate->MatchEvent(event, &commands)) { 662 if (!handled && delegate && delegate->MatchEvent(event, &commands)) {
657 const bool rtl = GetTextDirection() == base::i18n::RIGHT_TO_LEFT; 663 const bool rtl = GetTextDirection() == base::i18n::RIGHT_TO_LEFT;
658 for (size_t i = 0; i < commands.size(); ++i) { 664 for (size_t i = 0; i < commands.size(); ++i) {
659 const int command = GetViewsCommand(commands[i], rtl); 665 const int command = GetViewsCommand(commands[i], rtl);
660 if (IsCommandIdEnabled(command)) { 666 if (IsCommandIdEnabled(command)) {
661 ExecuteCommand(command); 667 ExecuteCommand(command);
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
1581 // Draw placeholder text if needed. 1587 // Draw placeholder text if needed.
1582 gfx::RenderText* render_text = GetRenderText(); 1588 gfx::RenderText* render_text = GetRenderText();
1583 if (text().empty() && !GetPlaceholderText().empty()) { 1589 if (text().empty() && !GetPlaceholderText().empty()) {
1584 canvas->DrawStringRect(GetPlaceholderText(), GetFontList(), 1590 canvas->DrawStringRect(GetPlaceholderText(), GetFontList(),
1585 placeholder_text_color(), render_text->display_rect()); 1591 placeholder_text_color(), render_text->display_rect());
1586 } 1592 }
1587 1593
1588 // Draw the text, cursor, and selection. 1594 // Draw the text, cursor, and selection.
1589 render_text->set_cursor_visible(cursor_visible_ && !drop_cursor_visible_ && 1595 render_text->set_cursor_visible(cursor_visible_ && !drop_cursor_visible_ &&
1590 !HasSelection()); 1596 !HasSelection());
1597 render_text->set_shadows(shadows_);
1598
flackr 2014/06/27 20:00:07 nit: no need for an extra newline here.
1591 render_text->Draw(canvas); 1599 render_text->Draw(canvas);
1592 1600
1593 // Draw the detached drop cursor that marks where the text will be dropped. 1601 // Draw the detached drop cursor that marks where the text will be dropped.
1594 if (drop_cursor_visible_) 1602 if (drop_cursor_visible_)
1595 render_text->DrawCursor(canvas, drop_cursor_position_); 1603 render_text->DrawCursor(canvas, drop_cursor_position_);
1596 1604
1597 canvas->Restore(); 1605 canvas->Restore();
1598 } 1606 }
1599 1607
1600 void Textfield::MoveCursorTo(const gfx::Point& point, bool select) { 1608 void Textfield::MoveCursorTo(const gfx::Point& point, bool select) {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1761 const size_t length = selection_clipboard_text.length(); 1769 const size_t length = selection_clipboard_text.length();
1762 range = gfx::Range(range.start() + length, range.end() + length); 1770 range = gfx::Range(range.start() + length, range.end() + length);
1763 } 1771 }
1764 model_->MoveCursorTo(gfx::SelectionModel(range, affinity)); 1772 model_->MoveCursorTo(gfx::SelectionModel(range, affinity));
1765 UpdateAfterChange(true, true); 1773 UpdateAfterChange(true, true);
1766 OnAfterUserAction(); 1774 OnAfterUserAction();
1767 } 1775 }
1768 } 1776 }
1769 1777
1770 } // namespace views 1778 } // namespace views
OLDNEW
« ui/views/controls/textfield/textfield.h ('K') | « ui/views/controls/textfield/textfield.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698