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

Unified Diff: ui/views/view.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/view.cc
diff --git a/ui/views/view.cc b/ui/views/view.cc
index 2918ee1aa908ae9dc847777214cfe680b8c38149..5ae3bda90e321f7e1e337c8f6edf3ab60f6845aa 100644
--- a/ui/views/view.cc
+++ b/ui/views/view.cc
@@ -110,9 +110,12 @@ class PostEventDispatchHandler : public ui::EventHandler {
if (event->type() == ui::ET_GESTURE_LONG_PRESS &&
(!owner_->drag_controller() ||
owner_->drag_controller()->CanStartDragForView(
- owner_, event->location(), event->location()))) {
- if (owner_->DoDrag(*event, event->location(),
- ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH)) {
+ owner_,
+ gfx::ToFlooredPoint(event->location()),
+ gfx::ToFlooredPoint(event->location())))) {
+ if (owner_->DoDrag(*event,
+ gfx::ToFlooredPoint(event->location()),
+ ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH)) {
event->StopPropagation();
return;
}
@@ -123,7 +126,7 @@ class PostEventDispatchHandler : public ui::EventHandler {
(event->type() == ui::ET_GESTURE_LONG_PRESS ||
event->type() == ui::ET_GESTURE_LONG_TAP ||
event->type() == ui::ET_GESTURE_TWO_FINGER_TAP)) {
- gfx::Point location(event->location());
+ gfx::Point location(gfx::ToFlooredPoint(event->location()));
View::ConvertPointToScreen(owner_, &location);
owner_->ShowContextMenu(location, ui::MENU_SOURCE_TOUCH);
event->StopPropagation();
@@ -2166,8 +2169,9 @@ void View::DestroyLayer() {
bool View::ProcessMousePressed(const ui::MouseEvent& event) {
int drag_operations =
(enabled_ && event.IsOnlyLeftMouseButton() &&
- HitTestPoint(event.location())) ?
- GetDragOperations(event.location()) : 0;
+ HitTestPoint(gfx::ToFlooredPoint(event.location())))
+ ? GetDragOperations(gfx::ToFlooredPoint(event.location()))
+ : 0;
ContextMenuController* context_menu_controller = event.IsRightMouseButton() ?
context_menu_controller_ : 0;
View::DragInfo* drag_info = GetDragInfo();
@@ -2175,7 +2179,8 @@ bool View::ProcessMousePressed(const ui::MouseEvent& event) {
// TODO(sky): for debugging 360238.
int storage_id = 0;
if (event.IsOnlyRightMouseButton() && context_menu_controller &&
- kContextMenuOnMousePress && HitTestPoint(event.location())) {
+ kContextMenuOnMousePress &&
+ HitTestPoint(gfx::ToFlooredPoint(event.location()))) {
ViewStorage* view_storage = ViewStorage::GetInstance();
storage_id = view_storage->CreateStorageID();
view_storage->StoreView(storage_id, this);
@@ -2191,7 +2196,7 @@ bool View::ProcessMousePressed(const ui::MouseEvent& event) {
kContextMenuOnMousePress) {
// Assume that if there is a context menu controller we won't be deleted
// from mouse pressed.
- gfx::Point location(event.location());
+ gfx::Point location(gfx::ToFlooredPoint(event.location()));
if (HitTestPoint(location)) {
if (storage_id != 0)
CHECK_EQ(this, ViewStorage::GetInstance()->RetrieveView(storage_id));
@@ -2203,7 +2208,7 @@ bool View::ProcessMousePressed(const ui::MouseEvent& event) {
// WARNING: we may have been deleted, don't use any View variables.
if (drag_operations != ui::DragDropTypes::DRAG_NONE) {
- drag_info->PossibleDrag(event.location());
+ drag_info->PossibleDrag(gfx::ToFlooredPoint(event.location()));
return true;
}
return !!context_menu_controller || result;
@@ -2215,10 +2220,13 @@ bool View::ProcessMouseDragged(const ui::MouseEvent& event) {
ContextMenuController* context_menu_controller = context_menu_controller_;
const bool possible_drag = GetDragInfo()->possible_drag;
if (possible_drag &&
- ExceededDragThreshold(GetDragInfo()->start_pt - event.location()) &&
+ ExceededDragThreshold(GetDragInfo()->start_pt -
+ gfx::ToFlooredPoint(event.location())) &&
(!drag_controller_ ||
drag_controller_->CanStartDragForView(
- this, GetDragInfo()->start_pt, event.location()))) {
+ this,
+ GetDragInfo()->start_pt,
+ gfx::ToFlooredPoint(event.location())))) {
DoDrag(event, GetDragInfo()->start_pt,
ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE);
} else {
@@ -2235,7 +2243,7 @@ void View::ProcessMouseReleased(const ui::MouseEvent& event) {
event.IsOnlyRightMouseButton()) {
// Assume that if there is a context menu controller we won't be deleted
// from mouse released.
- gfx::Point location(event.location());
+ gfx::Point location(gfx::ToFlooredPoint(event.location()));
OnMouseReleased(event);
if (HitTestPoint(location)) {
ConvertPointToScreen(this, &location);
@@ -2388,7 +2396,7 @@ bool View::DoDrag(const ui::LocatedEvent& event,
// Message the RootView to do the drag and drop. That way if we're removed
// the RootView can detect it and avoid calling us back.
- gfx::Point widget_location(event.location());
+ gfx::Point widget_location(gfx::ToFlooredPoint(event.location()));
ConvertPointToWidget(this, &widget_location);
widget->RunShellDrag(this, data, widget_location, drag_operations, source);
// WARNING: we may have been deleted.

Powered by Google App Engine
This is Rietveld 408576698