| 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 gfx::Vector2d location_delta = |
| 116 event.location().DistanceFrom(last_click_location_); |
| 116 return ExceededDragThreshold(location_delta.x(), location_delta.y()); | 117 return ExceededDragThreshold(location_delta.x(), location_delta.y()); |
| 117 } | 118 } |
| 118 | 119 |
| 119 bool NativeTextfieldViews::OnMouseDragged(const ui::MouseEvent& event) { | 120 bool NativeTextfieldViews::OnMouseDragged(const ui::MouseEvent& event) { |
| 120 // Don't adjust the cursor on a potential drag and drop, or if the mouse | 121 // 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. | 122 // movement from the last mouse click does not exceed the drag threshold. |
| 122 if (initiating_drag_ || !ExceededDragThresholdFromLastClickLocation(event)) | 123 if (initiating_drag_ || !ExceededDragThresholdFromLastClickLocation(event)) |
| 123 return true; | 124 return true; |
| 124 | 125 |
| 125 OnBeforeUserAction(); | 126 OnBeforeUserAction(); |
| (...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1231 // Filter out all control characters, including tab and new line characters, | 1232 // Filter out all control characters, including tab and new line characters, |
| 1232 // 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 |
| 1233 // AltGr modifier. | 1234 // AltGr modifier. |
| 1234 // 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 |
| 1235 // flag that we don't care about. | 1236 // flag that we don't care about. |
| 1236 return ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) && | 1237 return ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) && |
| 1237 (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; |
| 1238 } | 1239 } |
| 1239 | 1240 |
| 1240 } // namespace views | 1241 } // namespace views |
| OLD | NEW |