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

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

Issue 137893017: Rebuild Views Textfield context menu runner on each showing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Just recreate the menu runner on each showing. Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/i18n/case_conversion.h" 10 #include "base/i18n/case_conversion.h"
11 #include "grit/ui_strings.h" 11 #include "grit/ui_strings.h"
12 #include "ui/base/accessibility/accessible_view_state.h" 12 #include "ui/base/accessibility/accessible_view_state.h"
13 #include "ui/base/dragdrop/drag_drop_types.h" 13 #include "ui/base/dragdrop/drag_drop_types.h"
14 #include "ui/base/dragdrop/drag_utils.h" 14 #include "ui/base/dragdrop/drag_utils.h"
15 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/base/ui_base_switches_util.h" 16 #include "ui/base/ui_base_switches_util.h"
17 #include "ui/events/event.h" 17 #include "ui/events/event.h"
18 #include "ui/events/keycodes/keyboard_codes.h" 18 #include "ui/events/keycodes/keyboard_codes.h"
19 #include "ui/gfx/canvas.h" 19 #include "ui/gfx/canvas.h"
20 #include "ui/gfx/insets.h" 20 #include "ui/gfx/insets.h"
21 #include "ui/native_theme/native_theme.h" 21 #include "ui/native_theme/native_theme.h"
22 #include "ui/views/background.h" 22 #include "ui/views/background.h"
23 #include "ui/views/controls/focusable_border.h" 23 #include "ui/views/controls/focusable_border.h"
24 #include "ui/views/controls/menu/menu_item_view.h" 24 #include "ui/views/controls/menu/menu_item_view.h"
25 #include "ui/views/controls/menu/menu_model_adapter.h"
26 #include "ui/views/controls/menu/menu_runner.h" 25 #include "ui/views/controls/menu/menu_runner.h"
27 #include "ui/views/controls/native/native_view_host.h" 26 #include "ui/views/controls/native/native_view_host.h"
28 #include "ui/views/controls/textfield/textfield_controller.h" 27 #include "ui/views/controls/textfield/textfield_controller.h"
29 #include "ui/views/drag_utils.h" 28 #include "ui/views/drag_utils.h"
30 #include "ui/views/ime/input_method.h" 29 #include "ui/views/ime/input_method.h"
31 #include "ui/views/metrics.h" 30 #include "ui/views/metrics.h"
32 #include "ui/views/painter.h" 31 #include "ui/views/painter.h"
33 #include "ui/views/views_delegate.h" 32 #include "ui/views/views_delegate.h"
34 #include "ui/views/widget/widget.h" 33 #include "ui/views/widget/widget.h"
35 34
(...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); 1489 context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR);
1491 context_menu_contents_->AddItemWithStringId(IDS_APP_CUT, IDS_APP_CUT); 1490 context_menu_contents_->AddItemWithStringId(IDS_APP_CUT, IDS_APP_CUT);
1492 context_menu_contents_->AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY); 1491 context_menu_contents_->AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY);
1493 context_menu_contents_->AddItemWithStringId(IDS_APP_PASTE, IDS_APP_PASTE); 1492 context_menu_contents_->AddItemWithStringId(IDS_APP_PASTE, IDS_APP_PASTE);
1494 context_menu_contents_->AddItemWithStringId(IDS_APP_DELETE, IDS_APP_DELETE); 1493 context_menu_contents_->AddItemWithStringId(IDS_APP_DELETE, IDS_APP_DELETE);
1495 context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); 1494 context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR);
1496 context_menu_contents_->AddItemWithStringId(IDS_APP_SELECT_ALL, 1495 context_menu_contents_->AddItemWithStringId(IDS_APP_SELECT_ALL,
1497 IDS_APP_SELECT_ALL); 1496 IDS_APP_SELECT_ALL);
1498 if (controller_) 1497 if (controller_)
1499 controller_->UpdateContextMenu(context_menu_contents_.get()); 1498 controller_->UpdateContextMenu(context_menu_contents_.get());
1500 context_menu_runner_.reset(new MenuRunner(context_menu_contents_.get()));
1501 } 1499 }
1500 context_menu_runner_.reset(new MenuRunner(context_menu_contents_.get()));
1502 } 1501 }
1503 1502
1504 void Textfield::TrackMouseClicks(const ui::MouseEvent& event) { 1503 void Textfield::TrackMouseClicks(const ui::MouseEvent& event) {
1505 if (event.IsOnlyLeftMouseButton()) { 1504 if (event.IsOnlyLeftMouseButton()) {
1506 base::TimeDelta time_delta = event.time_stamp() - last_click_time_; 1505 base::TimeDelta time_delta = event.time_stamp() - last_click_time_;
1507 if (time_delta.InMilliseconds() <= GetDoubleClickInterval() && 1506 if (time_delta.InMilliseconds() <= GetDoubleClickInterval() &&
1508 !ExceededDragThreshold(event.location() - last_click_location_)) { 1507 !ExceededDragThreshold(event.location() - last_click_location_)) {
1509 // Upon clicking after a triple click, the count should go back to double 1508 // Upon clicking after a triple click, the count should go back to double
1510 // click and alternate between double and triple. This assignment maps 1509 // click and alternate between double and triple. This assignment maps
1511 // 0 to 1, 1 to 2, 2 to 1. 1510 // 0 to 1, 1 to 2, 2 to 1.
(...skipping 26 matching lines...) Expand all
1538 void Textfield::CreateTouchSelectionControllerAndNotifyIt() { 1537 void Textfield::CreateTouchSelectionControllerAndNotifyIt() {
1539 if (!touch_selection_controller_) { 1538 if (!touch_selection_controller_) {
1540 touch_selection_controller_.reset( 1539 touch_selection_controller_.reset(
1541 ui::TouchSelectionController::create(this)); 1540 ui::TouchSelectionController::create(this));
1542 } 1541 }
1543 if (touch_selection_controller_) 1542 if (touch_selection_controller_)
1544 touch_selection_controller_->SelectionChanged(); 1543 touch_selection_controller_->SelectionChanged();
1545 } 1544 }
1546 1545
1547 } // namespace views 1546 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698