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/native_textfield_views.h" | 5 #include "ui/views/controls/textfield/native_textfield_views.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // TODO: Remove once NativeTextfield implementations are consolidated to | 105 // TODO: Remove once NativeTextfield implementations are consolidated to |
106 // Textfield. | 106 // Textfield. |
107 if (!textfield_->OnMousePressed(event)) | 107 if (!textfield_->OnMousePressed(event)) |
108 HandleMousePressEvent(event); | 108 HandleMousePressEvent(event); |
109 OnAfterUserAction(); | 109 OnAfterUserAction(); |
110 return true; | 110 return true; |
111 } | 111 } |
112 | 112 |
113 bool NativeTextfieldViews::ExceededDragThresholdFromLastClickLocation( | 113 bool NativeTextfieldViews::ExceededDragThresholdFromLastClickLocation( |
114 const ui::MouseEvent& event) { | 114 const ui::MouseEvent& event) { |
115 gfx::Point location_delta = event.location().Subtract(last_click_location_); | 115 return ExceededDragThreshold(event.location() - last_click_location_); |
116 return ExceededDragThreshold(location_delta.x(), location_delta.y()); | |
117 } | 116 } |
118 | 117 |
119 bool NativeTextfieldViews::OnMouseDragged(const ui::MouseEvent& event) { | 118 bool NativeTextfieldViews::OnMouseDragged(const ui::MouseEvent& event) { |
120 // Don't adjust the cursor on a potential drag and drop, or if the mouse | 119 // Don't adjust the cursor on a potential drag and drop, or if the mouse |
121 // movement from the last mouse click does not exceed the drag threshold. | 120 // movement from the last mouse click does not exceed the drag threshold. |
122 if (initiating_drag_ || !ExceededDragThresholdFromLastClickLocation(event)) | 121 if (initiating_drag_ || !ExceededDragThresholdFromLastClickLocation(event)) |
123 return true; | 122 return true; |
124 | 123 |
125 OnBeforeUserAction(); | 124 OnBeforeUserAction(); |
126 // TODO: Remove once NativeTextfield implementations are consolidated to | 125 // TODO: Remove once NativeTextfield implementations are consolidated to |
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1233 // Filter out all control characters, including tab and new line characters, | 1232 // Filter out all control characters, including tab and new line characters, |
1234 // and all characters with Alt modifier. But we need to allow characters with | 1233 // and all characters with Alt modifier. But we need to allow characters with |
1235 // AltGr modifier. | 1234 // AltGr modifier. |
1236 // On Windows AltGr is represented by Alt+Ctrl, and on Linux it's a different | 1235 // On Windows AltGr is represented by Alt+Ctrl, and on Linux it's a different |
1237 // flag that we don't care about. | 1236 // flag that we don't care about. |
1238 return ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) && | 1237 return ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) && |
1239 (flags & ~(ui::EF_SHIFT_DOWN | ui::EF_CAPS_LOCK_DOWN)) != ui::EF_ALT_DOWN; | 1238 (flags & ~(ui::EF_SHIFT_DOWN | ui::EF_CAPS_LOCK_DOWN)) != ui::EF_ALT_DOWN; |
1240 } | 1239 } |
1241 | 1240 |
1242 } // namespace views | 1241 } // namespace views |
OLD | NEW |