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

Unified Diff: views/controls/textfield/native_textfield_views.cc

Issue 8527015: Fix omnibox mouse click highlight/word select/focus issue in aura build. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address the code review comments. Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: views/controls/textfield/native_textfield_views.cc
diff --git a/views/controls/textfield/native_textfield_views.cc b/views/controls/textfield/native_textfield_views.cc
index 07725fffba6e7513e1f4288c3917505fb99ddf15..96fbc3eed5b41ff378cd3962230ffd72fb602196 100644
--- a/views/controls/textfield/native_textfield_views.cc
+++ b/views/controls/textfield/native_textfield_views.cc
@@ -95,44 +95,13 @@ NativeTextfieldViews::~NativeTextfieldViews() {
bool NativeTextfieldViews::OnMousePressed(const MouseEvent& event) {
OnBeforeUserAction();
- textfield_->RequestFocus();
+ TrackMouseClicks(event);
- if (event.IsOnlyLeftMouseButton()) {
- base::TimeDelta time_delta = event.time_stamp() - last_click_time_;
- gfx::Point location_delta = event.location().Subtract(last_click_location_);
- if (time_delta.InMilliseconds() <= GetDoubleClickInterval() &&
- !ExceededDragThreshold(location_delta.x(), location_delta.y())) {
- aggregated_clicks_ = (aggregated_clicks_ + 1) % 3;
- } else {
- aggregated_clicks_ = 0;
- }
- last_click_time_ = event.time_stamp();
- last_click_location_ = event.location();
-
- initiating_drag_ = false;
- bool can_drag = true;
-#if defined(TOUCH_UI)
- can_drag = false;
-#endif
- switch(aggregated_clicks_) {
- case 0:
- if (can_drag && GetRenderText()->IsPointInSelection(event.location()))
- initiating_drag_ = true;
- else
- MoveCursorTo(event.location(), event.IsShiftDown());
- break;
- case 1:
- model_->SelectWord();
- OnCaretBoundsChanged();
- break;
- case 2:
- model_->SelectAll();
- OnCaretBoundsChanged();
- break;
- default:
- NOTREACHED();
- }
- SchedulePaint();
+ // Allow the textfield/omnibox to optionally handle the mouse pressed event.
+ // This should be removed once native textfield implementations are
+ // consolidated to textfield.
+ if (!textfield_->OnMousePressed(event)) {
+ HandleMousePresseEvent(event);
}
OnAfterUserAction();
@@ -1065,6 +1034,52 @@ bool NativeTextfieldViews::Paste() {
return success;
}
+void NativeTextfieldViews::TrackMouseClicks(const MouseEvent& event) {
+ if (event.IsOnlyLeftMouseButton()) {
+ base::TimeDelta time_delta = event.time_stamp() - last_click_time_;
+ gfx::Point location_delta = event.location().Subtract(last_click_location_);
+ if (time_delta.InMilliseconds() <= GetDoubleClickInterval() &&
+ !ExceededDragThreshold(location_delta.x(), location_delta.y())) {
+ aggregated_clicks_ = (aggregated_clicks_ + 1) % 3;
+ } else {
+ aggregated_clicks_ = 0;
+ }
+ last_click_time_ = event.time_stamp();
+ last_click_location_ = event.location();
+ }
+}
+
+void NativeTextfieldViews::HandleMousePresseEvent(const MouseEvent& event) {
+ if (event.IsOnlyLeftMouseButton()) {
+ textfield_->RequestFocus();
+
+ initiating_drag_ = false;
+ bool can_drag = true;
+#if defined(TOUCH_UI)
msw 2011/11/12 02:19:21 Please add a comment here, something like "Tempora
jennyz 2011/11/14 18:28:57 Done.
+ can_drag = false;
+#endif
+ switch(aggregated_clicks_) {
+ case 0:
+ if (can_drag && GetRenderText()->IsPointInSelection(event.location()))
+ initiating_drag_ = true;
+ else
+ MoveCursorTo(event.location(), event.IsShiftDown());
+ break;
msw 2011/11/12 02:19:21 outdent break by two spaces, it's not part of the
jennyz 2011/11/14 18:28:57 Done.
+ case 1:
+ model_->SelectWord();
+ OnCaretBoundsChanged();
+ break;
+ case 2:
+ model_->SelectAll();
+ OnCaretBoundsChanged();
+ break;
+ default:
+ NOTREACHED();
+ }
+ SchedulePaint();
+ }
+}
+
// static
bool NativeTextfieldViews::ShouldInsertChar(char16 ch, int flags) {
// Filter out all control characters, including tab and new line characters,

Powered by Google App Engine
This is Rietveld 408576698