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

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

Issue 139983009: ui::LocatedEvent location() returns gfx::PointF (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Undo accidental change. Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/textfield/textfield.cc
diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc
index 9b20f0c1606fa98e688dcd556c340c91e88c6eb8..6696668d26bb18adb46851c8058a4b09dad88683 100644
--- a/ui/views/controls/textfield/textfield.cc
+++ b/ui/views/controls/textfield/textfield.cc
@@ -492,7 +492,8 @@ const char* Textfield::GetClassName() const {
}
gfx::NativeCursor Textfield::GetCursor(const ui::MouseEvent& event) {
- bool in_selection = GetRenderText()->IsPointInSelection(event.location());
+ bool in_selection = GetRenderText()->IsPointInSelection(
+ gfx::ToFlooredPoint(event.location()));
bool drag_event = event.type() == ui::ET_MOUSE_DRAGGED;
bool text_cursor = !initiating_drag_ && (drag_event || !in_selection);
return text_cursor ? GetNativeIBeamCursor() : gfx::kNullCursor;
@@ -512,13 +513,15 @@ bool Textfield::OnMousePressed(const ui::MouseEvent& event) {
initiating_drag_ = false;
switch (aggregated_clicks_) {
case 0:
- if (GetRenderText()->IsPointInSelection(event.location()))
+ if (GetRenderText()->IsPointInSelection(
+ gfx::ToFlooredPoint(event.location())))
initiating_drag_ = true;
else
- MoveCursorTo(event.location(), event.IsShiftDown());
+ MoveCursorTo(gfx::ToFlooredPoint(event.location()),
+ event.IsShiftDown());
break;
case 1:
- model_->MoveCursorTo(event.location(), false);
+ model_->MoveCursorTo(gfx::ToFlooredPoint(event.location()), false);
model_->SelectWord();
UpdateAfterChange(false, true);
double_click_word_ = GetRenderText()->selection();
@@ -534,7 +537,8 @@ bool Textfield::OnMousePressed(const ui::MouseEvent& event) {
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
if (event.IsOnlyMiddleMouseButton()) {
- if (GetRenderText()->IsPointInSelection(event.location())) {
+ if (GetRenderText()->IsPointInSelection(
+ gfx::ToFlooredPoint(event.location()))) {
OnBeforeUserAction();
ClearSelection();
ui::ScopedClipboardWriter(
@@ -556,12 +560,13 @@ bool Textfield::OnMouseDragged(const ui::MouseEvent& event) {
// Don't adjust the cursor on a potential drag and drop, or if the mouse
// movement from the last mouse click does not exceed the drag threshold.
if (initiating_drag_ || !event.IsOnlyLeftMouseButton() ||
- !ExceededDragThreshold(event.location() - last_click_location_)) {
+ !ExceededDragThreshold(gfx::ToFlooredPoint(event.location()) -
+ last_click_location_)) {
return true;
}
OnBeforeUserAction();
- model_->MoveCursorTo(event.location(), true);
+ model_->MoveCursorTo(gfx::ToFlooredPoint(event.location()), true);
if (aggregated_clicks_ == 1) {
model_->SelectWord();
// Expand the selection so the initially selected word remains selected.
@@ -584,7 +589,7 @@ void Textfield::OnMouseReleased(const ui::MouseEvent& event) {
OnBeforeUserAction();
// Cancel suspected drag initiations, the user was clicking in the selection.
if (initiating_drag_)
- MoveCursorTo(event.location(), false);
+ MoveCursorTo(gfx::ToFlooredPoint(event.location()), false);
initiating_drag_ = false;
UpdateSelectionClipboard();
OnAfterUserAction();
@@ -636,14 +641,15 @@ void Textfield::OnGestureEvent(ui::GestureEvent* event) {
// We don't deselect if the point is in the selection
// because TAP_DOWN may turn into a LONG_PRESS.
- if (!GetRenderText()->IsPointInSelection(event->location()))
- MoveCursorTo(event->location(), false);
+ if (!GetRenderText()->IsPointInSelection(
+ gfx::ToFlooredPoint(event->location())))
+ MoveCursorTo(gfx::ToFlooredPoint(event->location()), false);
OnAfterUserAction();
event->SetHandled();
break;
case ui::ET_GESTURE_SCROLL_UPDATE:
OnBeforeUserAction();
- MoveCursorTo(event->location(), true);
+ MoveCursorTo(gfx::ToFlooredPoint(event->location()), true);
OnAfterUserAction();
event->SetHandled();
break;
@@ -674,7 +680,8 @@ void Textfield::OnGestureEvent(ui::GestureEvent* event) {
// If long press happens in selected text and touch drag drop is enabled,
// we will turn off touch selection (if one exists) and let views do drag
// drop.
- if (!GetRenderText()->IsPointInSelection(event->location())) {
+ if (!GetRenderText()->IsPointInSelection(
+ gfx::ToFlooredPoint(event->location()))) {
OnBeforeUserAction();
model_->SelectWord();
touch_selection_controller_.reset(
@@ -755,7 +762,8 @@ int Textfield::OnDragUpdated(const ui::DropTargetEvent& event) {
DCHECK(CanDrop(event.data()));
gfx::RenderText* render_text = GetRenderText();
const gfx::Range& selection = render_text->selection();
- drop_cursor_position_ = render_text->FindCursorPosition(event.location());
+ drop_cursor_position_ =
+ render_text->FindCursorPosition(gfx::ToFlooredPoint(event.location()));
bool in_selection = !selection.is_empty() &&
selection.Contains(gfx::Range(drop_cursor_position_.caret_pos()));
drop_cursor_visible_ = !in_selection;
@@ -788,13 +796,14 @@ int Textfield::OnPerformDrop(const ui::DropTargetEvent& event) {
}
gfx::RenderText* render_text = GetRenderText();
- DCHECK(!initiating_drag_ ||
- !render_text->IsPointInSelection(event.location()));
+ DCHECK(
+ !initiating_drag_ ||
+ !render_text->IsPointInSelection(gfx::ToFlooredPoint(event.location())));
OnBeforeUserAction();
skip_input_method_cancel_composition_ = true;
gfx::SelectionModel drop_destination_model =
- render_text->FindCursorPosition(event.location());
+ render_text->FindCursorPosition(gfx::ToFlooredPoint(event.location()));
base::string16 new_text;
event.data().GetString(&new_text);
@@ -1610,7 +1619,8 @@ void Textfield::TrackMouseClicks(const ui::MouseEvent& event) {
if (event.IsOnlyLeftMouseButton()) {
base::TimeDelta time_delta = event.time_stamp() - last_click_time_;
if (time_delta.InMilliseconds() <= GetDoubleClickInterval() &&
- !ExceededDragThreshold(event.location() - last_click_location_)) {
+ !ExceededDragThreshold(gfx::ToFlooredPoint(event.location()) -
+ last_click_location_)) {
// Upon clicking after a triple click, the count should go back to double
// click and alternate between double and triple. This assignment maps
// 0 to 1, 1 to 2, 2 to 1.
@@ -1619,7 +1629,7 @@ void Textfield::TrackMouseClicks(const ui::MouseEvent& event) {
aggregated_clicks_ = 0;
}
last_click_time_ = event.time_stamp();
- last_click_location_ = event.location();
+ last_click_location_ = gfx::ToFlooredPoint(event.location());
}
}
@@ -1669,8 +1679,8 @@ void Textfield::PasteSelectionClipboard(const ui::MouseEvent& event) {
OnBeforeUserAction();
gfx::Range range = GetSelectionModel().selection();
gfx::LogicalCursorDirection affinity = GetSelectionModel().caret_affinity();
- const gfx::SelectionModel mouse =
- GetRenderText()->FindCursorPosition(event.location());
+ const gfx::SelectionModel mouse = GetRenderText()->FindCursorPosition(
+ gfx::ToFlooredPoint(event.location()));
model_->MoveCursorTo(mouse);
model_->InsertText(selection_clipboard_text);
// Update the new selection range as needed.

Powered by Google App Engine
This is Rietveld 408576698