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

Side by Side Diff: ui/aura/window_targeter.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, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/aura/window_targeter.h" 5 #include "ui/aura/window_targeter.h"
6 6
7 #include "ui/aura/client/capture_client.h" 7 #include "ui/aura/client/capture_client.h"
8 #include "ui/aura/client/event_client.h" 8 #include "ui/aura/client/event_client.h"
9 #include "ui/aura/client/focus_client.h" 9 #include "ui/aura/client/focus_client.h"
10 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
(...skipping 11 matching lines...) Expand all
22 const ui::LocatedEvent& event) const { 22 const ui::LocatedEvent& event) const {
23 if (!window->IsVisible()) 23 if (!window->IsVisible())
24 return false; 24 return false;
25 if (window->ignore_events()) 25 if (window->ignore_events())
26 return false; 26 return false;
27 client::EventClient* client = client::GetEventClient(window->GetRootWindow()); 27 client::EventClient* client = client::GetEventClient(window->GetRootWindow());
28 if (client && !client->CanProcessEventsWithinSubtree(window)) 28 if (client && !client->CanProcessEventsWithinSubtree(window))
29 return false; 29 return false;
30 30
31 Window* parent = window->parent(); 31 Window* parent = window->parent();
32 if (parent && parent->delegate_ && !parent->delegate_-> 32 if (parent && parent->delegate_ &&
33 ShouldDescendIntoChildForEventHandling(window, event.location())) { 33 !parent->delegate_->ShouldDescendIntoChildForEventHandling(
34 window, gfx::ToFlooredPoint(event.location()))) {
34 return false; 35 return false;
35 } 36 }
36 return true; 37 return true;
37 } 38 }
38 39
39 bool WindowTargeter::EventLocationInsideBounds( 40 bool WindowTargeter::EventLocationInsideBounds(
40 aura::Window* window, const ui::LocatedEvent& event) const { 41 aura::Window* window, const ui::LocatedEvent& event) const {
41 gfx::Point point = event.location(); 42 gfx::Point point = gfx::ToFlooredPoint(event.location());
42 if (window->parent()) 43 if (window->parent())
43 aura::Window::ConvertPointToTarget(window->parent(), window, &point); 44 aura::Window::ConvertPointToTarget(window->parent(), window, &point);
44 return gfx::Rect(window->bounds().size()).Contains(point); 45 return gfx::Rect(window->bounds().size()).Contains(point);
45 } 46 }
46 47
47 ui::EventTarget* WindowTargeter::FindTargetForEvent(ui::EventTarget* root, 48 ui::EventTarget* WindowTargeter::FindTargetForEvent(ui::EventTarget* root,
48 ui::Event* event) { 49 ui::Event* event) {
49 Window* window = static_cast<Window*>(root); 50 Window* window = static_cast<Window*>(root);
50 Window* target = event->IsKeyEvent() ? 51 Window* target = event->IsKeyEvent() ?
51 FindTargetForKeyEvent(window, *static_cast<ui::KeyEvent*>(event)) : 52 FindTargetForKeyEvent(window, *static_cast<ui::KeyEvent*>(event)) :
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 if (capture_window) 126 if (capture_window)
126 return capture_window; 127 return capture_window;
127 128
128 if (event.IsTouchEvent()) { 129 if (event.IsTouchEvent()) {
129 // Query the gesture-recognizer to find targets for touch events. 130 // Query the gesture-recognizer to find targets for touch events.
130 const ui::TouchEvent& touch = static_cast<const ui::TouchEvent&>(event); 131 const ui::TouchEvent& touch = static_cast<const ui::TouchEvent&>(event);
131 ui::GestureConsumer* consumer = 132 ui::GestureConsumer* consumer =
132 ui::GestureRecognizer::Get()->GetTouchLockedTarget(touch); 133 ui::GestureRecognizer::Get()->GetTouchLockedTarget(touch);
133 if (consumer) 134 if (consumer)
134 return static_cast<Window*>(consumer); 135 return static_cast<Window*>(consumer);
135 consumer = 136 consumer = ui::GestureRecognizer::Get()->GetTargetForLocation(
136 ui::GestureRecognizer::Get()->GetTargetForLocation( 137 gfx::ToFlooredPoint(event.location()), touch.source_device_id());
137 event.location(), touch.source_device_id());
138 if (consumer) 138 if (consumer)
139 return static_cast<Window*>(consumer); 139 return static_cast<Window*>(consumer);
140 140
141 // If the initial touch is outside the root window, target the root. 141 // If the initial touch is outside the root window, target the root.
142 if (!root_window->bounds().Contains(event.location())) 142 if (!root_window->bounds().Contains(gfx::ToFlooredPoint(event.location())))
143 return root_window; 143 return root_window;
144 } 144 }
145 145
146 return NULL; 146 return NULL;
147 } 147 }
148 148
149 } // namespace aura 149 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698