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

Side by Side Diff: ui/aura/window_event_dispatcher.cc

Issue 2628393003: Remove ScopedVector from ui/events/. (Closed)
Patch Set: chromeos2 Created 3 years, 11 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_event_dispatcher.h" 5 #include "ui/aura/window_event_dispatcher.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 Window* window, 151 Window* window,
152 const gfx::Point& point) { 152 const gfx::Point& point) {
153 ui::MouseEvent event(ui::ET_MOUSE_EXITED, point, point, ui::EventTimeForNow(), 153 ui::MouseEvent event(ui::ET_MOUSE_EXITED, point, point, ui::EventTimeForNow(),
154 ui::EF_NONE, ui::EF_NONE); 154 ui::EF_NONE, ui::EF_NONE);
155 return DispatchMouseEnterOrExit(window, event, ui::ET_MOUSE_EXITED); 155 return DispatchMouseEnterOrExit(window, event, ui::ET_MOUSE_EXITED);
156 } 156 }
157 157
158 void WindowEventDispatcher::ProcessedTouchEvent(uint32_t unique_event_id, 158 void WindowEventDispatcher::ProcessedTouchEvent(uint32_t unique_event_id,
159 Window* window, 159 Window* window,
160 ui::EventResult result) { 160 ui::EventResult result) {
161 std::unique_ptr<ui::GestureRecognizer::Gestures> gestures( 161 ui::GestureRecognizer::Gestures gestures =
162 ui::GestureRecognizer::Get()->AckTouchEvent(unique_event_id, result, 162 ui::GestureRecognizer::Get()->AckTouchEvent(unique_event_id, result,
163 window)); 163 window);
164 DispatchDetails details = ProcessGestures(window, gestures.get()); 164 DispatchDetails details = ProcessGestures(window, std::move(gestures));
165 if (details.dispatcher_destroyed) 165 if (details.dispatcher_destroyed)
166 return; 166 return;
167 } 167 }
168 168
169 void WindowEventDispatcher::HoldPointerMoves() { 169 void WindowEventDispatcher::HoldPointerMoves() {
170 if (!move_hold_count_) 170 if (!move_hold_count_)
171 held_event_factory_.InvalidateWeakPtrs(); 171 held_event_factory_.InvalidateWeakPtrs();
172 ++move_hold_count_; 172 ++move_hold_count_;
173 TRACE_EVENT_ASYNC_BEGIN0("ui", "WindowEventDispatcher::HoldPointerMoves", 173 TRACE_EVENT_ASYNC_BEGIN0("ui", "WindowEventDispatcher::HoldPointerMoves",
174 this); 174 this);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 ui::MouseEvent translated_event(event, 268 ui::MouseEvent translated_event(event,
269 target, 269 target,
270 mouse_moved_handler_, 270 mouse_moved_handler_,
271 type, 271 type,
272 event.flags() | ui::EF_IS_SYNTHESIZED); 272 event.flags() | ui::EF_IS_SYNTHESIZED);
273 return DispatchEvent(mouse_moved_handler_, &translated_event); 273 return DispatchEvent(mouse_moved_handler_, &translated_event);
274 } 274 }
275 275
276 ui::EventDispatchDetails WindowEventDispatcher::ProcessGestures( 276 ui::EventDispatchDetails WindowEventDispatcher::ProcessGestures(
277 Window* target, 277 Window* target,
278 ui::GestureRecognizer::Gestures* gestures) { 278 ui::GestureRecognizer::Gestures gestures) {
279 DispatchDetails details; 279 DispatchDetails details;
280 if (!gestures || gestures->empty()) 280 if (gestures.empty())
281 return details; 281 return details;
282 282
283 // If a window has been hidden between the touch event and now, the associated 283 // If a window has been hidden between the touch event and now, the associated
284 // gestures may not have a valid target. 284 // gestures may not have a valid target.
285 if (!target) 285 if (!target)
286 return details; 286 return details;
287 287
288 for (size_t i = 0; i < gestures->size(); ++i) { 288 for (const auto& event : gestures) {
289 ui::GestureEvent* event = gestures->get().at(i);
290 event->ConvertLocationToTarget(window(), target); 289 event->ConvertLocationToTarget(window(), target);
291 details = DispatchEvent(target, event); 290 details = DispatchEvent(target, event.get());
292 if (details.dispatcher_destroyed || details.target_destroyed) 291 if (details.dispatcher_destroyed || details.target_destroyed)
293 break; 292 break;
294 } 293 }
295 return details; 294 return details;
296 } 295 }
297 296
298 void WindowEventDispatcher::OnWindowHidden(Window* invisible, 297 void WindowEventDispatcher::OnWindowHidden(Window* invisible,
299 WindowHiddenReason reason) { 298 WindowHiddenReason reason) {
300 // If the window the mouse was pressed in becomes invisible, it should no 299 // If the window the mouse was pressed in becomes invisible, it should no
301 // longer receive mouse events. 300 // longer receive mouse events.
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 #endif 478 #endif
480 479
481 if (event.IsTouchEvent() && !details.target_destroyed) { 480 if (event.IsTouchEvent() && !details.target_destroyed) {
482 // Do not let 'held' touch events contribute to any gestures unless it is 481 // Do not let 'held' touch events contribute to any gestures unless it is
483 // being dispatched. 482 // being dispatched.
484 if (is_dispatched_held_event(event) || !held_move_event_ || 483 if (is_dispatched_held_event(event) || !held_move_event_ ||
485 !held_move_event_->IsTouchEvent()) { 484 !held_move_event_->IsTouchEvent()) {
486 const ui::TouchEvent& touchevent = *event.AsTouchEvent(); 485 const ui::TouchEvent& touchevent = *event.AsTouchEvent();
487 486
488 if (!touchevent.synchronous_handling_disabled()) { 487 if (!touchevent.synchronous_handling_disabled()) {
489 std::unique_ptr<ui::GestureRecognizer::Gestures> gestures; 488 Window* window = static_cast<Window*>(target);
489 ui::GestureRecognizer::Gestures gestures =
490 ui::GestureRecognizer::Get()->AckTouchEvent(
491 touchevent.unique_event_id(), event.result(), window);
490 492
491 Window* window = static_cast<Window*>(target); 493 return ProcessGestures(window, std::move(gestures));
492 gestures.reset(ui::GestureRecognizer::Get()->AckTouchEvent(
493 touchevent.unique_event_id(), event.result(), window));
494
495 return ProcessGestures(window, gestures.get());
496 } 494 }
497 } 495 }
498 } 496 }
499 497
500 return details; 498 return details;
501 } 499 }
502 500
503 //////////////////////////////////////////////////////////////////////////////// 501 ////////////////////////////////////////////////////////////////////////////////
504 // WindowEventDispatcher, ui::GestureEventHelper implementation: 502 // WindowEventDispatcher, ui::GestureEventHelper implementation:
505 503
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 } 859 }
862 860
863 // This flag is set depending on the gestures recognized in the call above, 861 // This flag is set depending on the gestures recognized in the call above,
864 // and needs to propagate with the forwarded event. 862 // and needs to propagate with the forwarded event.
865 event->set_may_cause_scrolling(orig_event.may_cause_scrolling()); 863 event->set_may_cause_scrolling(orig_event.may_cause_scrolling());
866 864
867 return PreDispatchLocatedEvent(target, event); 865 return PreDispatchLocatedEvent(target, event);
868 } 866 }
869 867
870 } // namespace aura 868 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698