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/widget/root_view.h" | 5 #include "ui/views/widget/root_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 layer()->SchedulePaint(rect); | 191 layer()->SchedulePaint(rect); |
192 } else { | 192 } else { |
193 gfx::Rect xrect = ConvertRectToParent(rect); | 193 gfx::Rect xrect = ConvertRectToParent(rect); |
194 gfx::Rect invalid_rect = GetLocalBounds().Intersect(xrect); | 194 gfx::Rect invalid_rect = GetLocalBounds().Intersect(xrect); |
195 if (!invalid_rect.IsEmpty()) | 195 if (!invalid_rect.IsEmpty()) |
196 widget_->SchedulePaintInRect(invalid_rect); | 196 widget_->SchedulePaintInRect(invalid_rect); |
197 } | 197 } |
198 } | 198 } |
199 | 199 |
200 bool RootView::OnMousePressed(const MouseEvent& event) { | 200 bool RootView::OnMousePressed(const MouseEvent& event) { |
201 MouseEvent e(event, this); | 201 UpdateCursor(event); |
202 UpdateCursor(e); | 202 SetMouseLocationAndFlags(event); |
203 SetMouseLocationAndFlags(e); | |
204 | 203 |
205 // If mouse_pressed_handler_ is non null, we are currently processing | 204 // If mouse_pressed_handler_ is non null, we are currently processing |
206 // a pressed -> drag -> released session. In that case we send the | 205 // a pressed -> drag -> released session. In that case we send the |
207 // event to mouse_pressed_handler_ | 206 // event to mouse_pressed_handler_ |
208 if (mouse_pressed_handler_) { | 207 if (mouse_pressed_handler_) { |
209 MouseEvent mouse_pressed_event(e, this, mouse_pressed_handler_); | 208 MouseEvent mouse_pressed_event(event, this, mouse_pressed_handler_); |
210 drag_info_.Reset(); | 209 drag_info_.Reset(); |
211 mouse_pressed_handler_->ProcessMousePressed(mouse_pressed_event, | 210 mouse_pressed_handler_->ProcessMousePressed(mouse_pressed_event, |
212 &drag_info_); | 211 &drag_info_); |
213 return true; | 212 return true; |
214 } | 213 } |
215 DCHECK(!explicit_mouse_handler_); | 214 DCHECK(!explicit_mouse_handler_); |
216 | 215 |
217 bool hit_disabled_view = false; | 216 bool hit_disabled_view = false; |
218 // Walk up the tree until we find a view that wants the mouse event. | 217 // Walk up the tree until we find a view that wants the mouse event. |
219 for (mouse_pressed_handler_ = GetEventHandlerForPoint(e.location()); | 218 for (mouse_pressed_handler_ = GetEventHandlerForPoint(event.location()); |
220 mouse_pressed_handler_ && (mouse_pressed_handler_ != this); | 219 mouse_pressed_handler_ && (mouse_pressed_handler_ != this); |
221 mouse_pressed_handler_ = mouse_pressed_handler_->parent()) { | 220 mouse_pressed_handler_ = mouse_pressed_handler_->parent()) { |
222 DVLOG(1) << "OnMousePressed testing " | 221 DVLOG(1) << "OnMousePressed testing " |
223 << mouse_pressed_handler_->GetClassName(); | 222 << mouse_pressed_handler_->GetClassName(); |
224 if (!mouse_pressed_handler_->enabled()) { | 223 if (!mouse_pressed_handler_->enabled()) { |
225 // Disabled views should eat events instead of propagating them upwards. | 224 // Disabled views should eat events instead of propagating them upwards. |
226 hit_disabled_view = true; | 225 hit_disabled_view = true; |
227 break; | 226 break; |
228 } | 227 } |
229 | 228 |
230 // See if this view wants to handle the mouse press. | 229 // See if this view wants to handle the mouse press. |
231 MouseEvent mouse_pressed_event(e, this, mouse_pressed_handler_); | 230 MouseEvent mouse_pressed_event(event, this, mouse_pressed_handler_); |
232 | 231 |
233 // Remove the double-click flag if the handler is different than the | 232 // Remove the double-click flag if the handler is different than the |
234 // one which got the first click part of the double-click. | 233 // one which got the first click part of the double-click. |
235 if (mouse_pressed_handler_ != last_click_handler_) | 234 if (mouse_pressed_handler_ != last_click_handler_) |
236 mouse_pressed_event.set_flags(e.flags() & ~ui::EF_IS_DOUBLE_CLICK); | 235 mouse_pressed_event.set_flags(event.flags() & ~ui::EF_IS_DOUBLE_CLICK); |
237 | 236 |
238 drag_info_.Reset(); | 237 drag_info_.Reset(); |
239 bool handled = mouse_pressed_handler_->ProcessMousePressed( | 238 bool handled = mouse_pressed_handler_->ProcessMousePressed( |
240 mouse_pressed_event, &drag_info_); | 239 mouse_pressed_event, &drag_info_); |
241 | 240 |
242 // The view could have removed itself from the tree when handling | 241 // The view could have removed itself from the tree when handling |
243 // OnMousePressed(). In this case, the removal notification will have | 242 // OnMousePressed(). In this case, the removal notification will have |
244 // reset mouse_pressed_handler_ to NULL out from under us. Detect this | 243 // reset mouse_pressed_handler_ to NULL out from under us. Detect this |
245 // case and stop. (See comments in view.h.) | 244 // case and stop. (See comments in view.h.) |
246 // | 245 // |
(...skipping 13 matching lines...) Expand all Loading... |
260 } | 259 } |
261 } | 260 } |
262 | 261 |
263 // Reset mouse_pressed_handler_ to indicate that no processing is occurring. | 262 // Reset mouse_pressed_handler_ to indicate that no processing is occurring. |
264 mouse_pressed_handler_ = NULL; | 263 mouse_pressed_handler_ = NULL; |
265 | 264 |
266 // In the event that a double-click is not handled after traversing the | 265 // In the event that a double-click is not handled after traversing the |
267 // entire hierarchy (even as a single-click when sent to a different view), | 266 // entire hierarchy (even as a single-click when sent to a different view), |
268 // it must be marked as handled to avoid anything happening from default | 267 // it must be marked as handled to avoid anything happening from default |
269 // processing if it the first click-part was handled by us. | 268 // processing if it the first click-part was handled by us. |
270 if (last_click_handler_ && (e.flags() & ui::EF_IS_DOUBLE_CLICK)) | 269 if (last_click_handler_ && (event.flags() & ui::EF_IS_DOUBLE_CLICK)) |
271 hit_disabled_view = true; | 270 hit_disabled_view = true; |
272 | 271 |
273 last_click_handler_ = NULL; | 272 last_click_handler_ = NULL; |
274 return hit_disabled_view; | 273 return hit_disabled_view; |
275 } | 274 } |
276 | 275 |
277 bool RootView::OnMouseDragged(const MouseEvent& event) { | 276 bool RootView::OnMouseDragged(const MouseEvent& event) { |
278 if (mouse_pressed_handler_) { | 277 if (mouse_pressed_handler_) { |
279 MouseEvent e(event, this); | 278 SetMouseLocationAndFlags(event); |
280 SetMouseLocationAndFlags(e); | |
281 | 279 |
282 MouseEvent mouse_event(e, this, mouse_pressed_handler_); | 280 MouseEvent mouse_event(event, this, mouse_pressed_handler_); |
283 return mouse_pressed_handler_->ProcessMouseDragged(mouse_event, | 281 return mouse_pressed_handler_->ProcessMouseDragged(mouse_event, |
284 &drag_info_); | 282 &drag_info_); |
285 } | 283 } |
286 return false; | 284 return false; |
287 } | 285 } |
288 | 286 |
289 void RootView::OnMouseReleased(const MouseEvent& event) { | 287 void RootView::OnMouseReleased(const MouseEvent& event) { |
290 MouseEvent e(event, this); | 288 UpdateCursor(event); |
291 UpdateCursor(e); | |
292 | 289 |
293 if (mouse_pressed_handler_) { | 290 if (mouse_pressed_handler_) { |
294 MouseEvent mouse_released(e, this, mouse_pressed_handler_); | 291 MouseEvent mouse_released(event, this, mouse_pressed_handler_); |
295 // We allow the view to delete us from ProcessMouseReleased. As such, | 292 // We allow the view to delete us from ProcessMouseReleased. As such, |
296 // configure state such that we're done first, then call View. | 293 // configure state such that we're done first, then call View. |
297 View* mouse_pressed_handler = mouse_pressed_handler_; | 294 View* mouse_pressed_handler = mouse_pressed_handler_; |
298 SetMouseHandler(NULL); | 295 SetMouseHandler(NULL); |
299 mouse_pressed_handler->ProcessMouseReleased(mouse_released); | 296 mouse_pressed_handler->ProcessMouseReleased(mouse_released); |
300 // WARNING: we may have been deleted. | 297 // WARNING: we may have been deleted. |
301 } | 298 } |
302 } | 299 } |
303 | 300 |
304 void RootView::OnMouseCaptureLost() { | 301 void RootView::OnMouseCaptureLost() { |
(...skipping 13 matching lines...) Expand all Loading... |
318 SetMouseHandler(NULL); | 315 SetMouseHandler(NULL); |
319 if (mouse_pressed_handler) | 316 if (mouse_pressed_handler) |
320 mouse_pressed_handler->OnMouseCaptureLost(); | 317 mouse_pressed_handler->OnMouseCaptureLost(); |
321 else | 318 else |
322 gesture_handler->OnMouseCaptureLost(); | 319 gesture_handler->OnMouseCaptureLost(); |
323 // WARNING: we may have been deleted. | 320 // WARNING: we may have been deleted. |
324 } | 321 } |
325 } | 322 } |
326 | 323 |
327 void RootView::OnMouseMoved(const MouseEvent& event) { | 324 void RootView::OnMouseMoved(const MouseEvent& event) { |
328 MouseEvent e(event, this); | 325 View* v = GetEventHandlerForPoint(event.location()); |
329 View* v = GetEventHandlerForPoint(e.location()); | |
330 // Find the first enabled view, or the existing move handler, whichever comes | 326 // Find the first enabled view, or the existing move handler, whichever comes |
331 // first. The check for the existing handler is because if a view becomes | 327 // first. The check for the existing handler is because if a view becomes |
332 // disabled while handling moves, it's wrong to suddenly send ET_MOUSE_EXITED | 328 // disabled while handling moves, it's wrong to suddenly send ET_MOUSE_EXITED |
333 // and ET_MOUSE_ENTERED events, because the mouse hasn't actually exited yet. | 329 // and ET_MOUSE_ENTERED events, because the mouse hasn't actually exited yet. |
334 while (v && !v->enabled() && (v != mouse_move_handler_)) | 330 while (v && !v->enabled() && (v != mouse_move_handler_)) |
335 v = v->parent(); | 331 v = v->parent(); |
336 if (v && v != this) { | 332 if (v && v != this) { |
337 if (v != mouse_move_handler_) { | 333 if (v != mouse_move_handler_) { |
338 if (mouse_move_handler_ != NULL && | 334 if (mouse_move_handler_ != NULL && |
339 (!mouse_move_handler_->notify_enter_exit_on_child() || | 335 (!mouse_move_handler_->notify_enter_exit_on_child() || |
340 !mouse_move_handler_->Contains(v))) { | 336 !mouse_move_handler_->Contains(v))) { |
341 mouse_move_handler_->OnMouseExited(e); | 337 mouse_move_handler_->OnMouseExited(event); |
342 NotifyEnterExitOfDescendant(e, EVENT_EXIT, mouse_move_handler_, v); | 338 NotifyEnterExitOfDescendant(event, EVENT_EXIT, mouse_move_handler_, v); |
343 } | 339 } |
344 View* old_handler = mouse_move_handler_; | 340 View* old_handler = mouse_move_handler_; |
345 mouse_move_handler_ = v; | 341 mouse_move_handler_ = v; |
346 MouseEvent entered_event(e, this, mouse_move_handler_); | 342 MouseEvent entered_event(event, this, mouse_move_handler_); |
347 if (!mouse_move_handler_->notify_enter_exit_on_child() || | 343 if (!mouse_move_handler_->notify_enter_exit_on_child() || |
348 !mouse_move_handler_->Contains(old_handler)) { | 344 !mouse_move_handler_->Contains(old_handler)) { |
349 mouse_move_handler_->OnMouseEntered(entered_event); | 345 mouse_move_handler_->OnMouseEntered(entered_event); |
350 NotifyEnterExitOfDescendant(entered_event, EVENT_ENTER, v, | 346 NotifyEnterExitOfDescendant(entered_event, EVENT_ENTER, v, |
351 old_handler); | 347 old_handler); |
352 } | 348 } |
353 } | 349 } |
354 MouseEvent moved_event(e, this, mouse_move_handler_); | 350 MouseEvent moved_event(event, this, mouse_move_handler_); |
355 mouse_move_handler_->OnMouseMoved(moved_event); | 351 mouse_move_handler_->OnMouseMoved(moved_event); |
356 if (!(moved_event.flags() & ui::EF_IS_NON_CLIENT)) | 352 if (!(moved_event.flags() & ui::EF_IS_NON_CLIENT)) |
357 widget_->SetCursor(mouse_move_handler_->GetCursor(moved_event)); | 353 widget_->SetCursor(mouse_move_handler_->GetCursor(moved_event)); |
358 } else if (mouse_move_handler_ != NULL) { | 354 } else if (mouse_move_handler_ != NULL) { |
359 mouse_move_handler_->OnMouseExited(e); | 355 mouse_move_handler_->OnMouseExited(event); |
360 NotifyEnterExitOfDescendant(e, EVENT_EXIT, mouse_move_handler_, v); | 356 NotifyEnterExitOfDescendant(event, EVENT_EXIT, mouse_move_handler_, v); |
361 // On Aura the non-client area extends slightly outside the root view for | 357 // On Aura the non-client area extends slightly outside the root view for |
362 // some windows. Let the non-client cursor handling code set the cursor | 358 // some windows. Let the non-client cursor handling code set the cursor |
363 // as we do above. | 359 // as we do above. |
364 if (!(e.flags() & ui::EF_IS_NON_CLIENT)) | 360 if (!(event.flags() & ui::EF_IS_NON_CLIENT)) |
365 widget_->SetCursor(gfx::kNullCursor); | 361 widget_->SetCursor(gfx::kNullCursor); |
366 } | 362 } |
367 } | 363 } |
368 | 364 |
369 void RootView::OnMouseExited(const MouseEvent& event) { | 365 void RootView::OnMouseExited(const MouseEvent& event) { |
370 if (mouse_move_handler_ != NULL) { | 366 if (mouse_move_handler_ != NULL) { |
371 mouse_move_handler_->OnMouseExited(event); | 367 mouse_move_handler_->OnMouseExited(event); |
372 NotifyEnterExitOfDescendant(event, EVENT_EXIT, mouse_move_handler_, NULL); | 368 NotifyEnterExitOfDescendant(event, EVENT_EXIT, mouse_move_handler_, NULL); |
373 mouse_move_handler_ = NULL; | 369 mouse_move_handler_ = NULL; |
374 } | 370 } |
375 } | 371 } |
376 | 372 |
377 bool RootView::OnMouseWheel(const MouseWheelEvent& event) { | 373 bool RootView::OnMouseWheel(const MouseWheelEvent& event) { |
378 MouseWheelEvent e(event, this); | |
379 bool consumed = false; | 374 bool consumed = false; |
380 for (View* v = GetFocusManager()->GetFocusedView(); | 375 for (View* v = GetFocusManager()->GetFocusedView(); |
381 v && v != this && !consumed; v = v->parent()) | 376 v && v != this && !consumed; v = v->parent()) |
382 consumed = v->OnMouseWheel(e); | 377 consumed = v->OnMouseWheel(event); |
383 return consumed; | 378 return consumed; |
384 } | 379 } |
385 | 380 |
386 bool RootView::OnScrollEvent(const ScrollEvent& event) { | 381 bool RootView::OnScrollEvent(const ScrollEvent& event) { |
387 ScrollEvent e(event, this); | |
388 bool consumed = false; | 382 bool consumed = false; |
389 for (View* v = GetEventHandlerForPoint(e.location()); | 383 for (View* v = GetEventHandlerForPoint(event.location()); |
390 v && v != this && !consumed; v = v->parent()) | 384 v && v != this && !consumed; v = v->parent()) |
391 consumed = v->OnScrollEvent(e); | 385 consumed = v->OnScrollEvent(event); |
392 return consumed; | 386 return consumed; |
393 } | 387 } |
394 | 388 |
395 ui::TouchStatus RootView::OnTouchEvent(const TouchEvent& event) { | 389 ui::TouchStatus RootView::OnTouchEvent(const TouchEvent& event) { |
396 // TODO: this looks all wrong. On a TOUCH_PRESSED we should figure out the | 390 // TODO: this looks all wrong. On a TOUCH_PRESSED we should figure out the |
397 // view and target that view with all touches with the same id until the | 391 // view and target that view with all touches with the same id until the |
398 // release (or keep it if captured). | 392 // release (or keep it if captured). |
399 | 393 |
400 TouchEvent e(event, this); | |
401 | |
402 // If touch_pressed_handler_ is non null, we are currently processing | 394 // If touch_pressed_handler_ is non null, we are currently processing |
403 // a touch down on the screen situation. In that case we send the | 395 // a touch down on the screen situation. In that case we send the |
404 // event to touch_pressed_handler_ | 396 // event to touch_pressed_handler_ |
405 ui::TouchStatus status = ui::TOUCH_STATUS_UNKNOWN; | 397 ui::TouchStatus status = ui::TOUCH_STATUS_UNKNOWN; |
406 | 398 |
407 if (touch_pressed_handler_) { | 399 if (touch_pressed_handler_) { |
408 TouchEvent touch_event(e, this, touch_pressed_handler_); | 400 TouchEvent touch_event(event, this, touch_pressed_handler_); |
409 status = touch_pressed_handler_->ProcessTouchEvent(touch_event); | 401 status = touch_pressed_handler_->ProcessTouchEvent(touch_event); |
410 if (status == ui::TOUCH_STATUS_END) | 402 if (status == ui::TOUCH_STATUS_END) |
411 touch_pressed_handler_ = NULL; | 403 touch_pressed_handler_ = NULL; |
412 return status; | 404 return status; |
413 } | 405 } |
414 | 406 |
415 // Walk up the tree until we find a view that wants the touch event. | 407 // Walk up the tree until we find a view that wants the touch event. |
416 for (touch_pressed_handler_ = GetEventHandlerForPoint(e.location()); | 408 for (touch_pressed_handler_ = GetEventHandlerForPoint(event.location()); |
417 touch_pressed_handler_ && (touch_pressed_handler_ != this); | 409 touch_pressed_handler_ && (touch_pressed_handler_ != this); |
418 touch_pressed_handler_ = touch_pressed_handler_->parent()) { | 410 touch_pressed_handler_ = touch_pressed_handler_->parent()) { |
419 if (!touch_pressed_handler_->enabled()) { | 411 if (!touch_pressed_handler_->enabled()) { |
420 // Disabled views eat events but are treated as not handled. | 412 // Disabled views eat events but are treated as not handled. |
421 status = ui::TOUCH_STATUS_UNKNOWN; | 413 status = ui::TOUCH_STATUS_UNKNOWN; |
422 break; | 414 break; |
423 } | 415 } |
424 | 416 |
425 // See if this view wants to handle the touch | 417 // See if this view wants to handle the touch |
426 TouchEvent touch_event(e, this, touch_pressed_handler_); | 418 TouchEvent touch_event(event, this, touch_pressed_handler_); |
427 status = touch_pressed_handler_->ProcessTouchEvent(touch_event); | 419 status = touch_pressed_handler_->ProcessTouchEvent(touch_event); |
428 | 420 |
429 // The view could have removed itself from the tree when handling | 421 // The view could have removed itself from the tree when handling |
430 // OnTouchEvent(). So handle as per OnMousePressed. NB: we | 422 // OnTouchEvent(). So handle as per OnMousePressed. NB: we |
431 // assume that the RootView itself cannot be so removed. | 423 // assume that the RootView itself cannot be so removed. |
432 if (!touch_pressed_handler_) | 424 if (!touch_pressed_handler_) |
433 break; | 425 break; |
434 | 426 |
435 // The touch event wasn't processed. Go up the view hierarchy and dispatch | 427 // The touch event wasn't processed. Go up the view hierarchy and dispatch |
436 // the touch event. | 428 // the touch event. |
437 if (status == ui::TOUCH_STATUS_UNKNOWN) | 429 if (status == ui::TOUCH_STATUS_UNKNOWN) |
438 continue; | 430 continue; |
439 | 431 |
440 // If the touch didn't initiate a touch-sequence, then reset the touch event | 432 // If the touch didn't initiate a touch-sequence, then reset the touch event |
441 // handler. Otherwise, leave it set so that subsequent touch events are | 433 // handler. Otherwise, leave it set so that subsequent touch events are |
442 // dispatched to the same handler. | 434 // dispatched to the same handler. |
443 if (status != ui::TOUCH_STATUS_START) | 435 if (status != ui::TOUCH_STATUS_START) |
444 touch_pressed_handler_ = NULL; | 436 touch_pressed_handler_ = NULL; |
445 | 437 |
446 return status; | 438 return status; |
447 } | 439 } |
448 | 440 |
449 // Reset touch_pressed_handler_ to indicate that no processing is occurring. | 441 // Reset touch_pressed_handler_ to indicate that no processing is occurring. |
450 touch_pressed_handler_ = NULL; | 442 touch_pressed_handler_ = NULL; |
451 | 443 |
452 return status; | 444 return status; |
453 } | 445 } |
454 | 446 |
455 ui::GestureStatus RootView::OnGestureEvent(const GestureEvent& event) { | 447 ui::GestureStatus RootView::OnGestureEvent(const GestureEvent& event) { |
456 GestureEvent e(event, this); | |
457 ui::GestureStatus status = ui::GESTURE_STATUS_UNKNOWN; | 448 ui::GestureStatus status = ui::GESTURE_STATUS_UNKNOWN; |
458 | 449 |
459 if (gesture_handler_) { | 450 if (gesture_handler_) { |
460 // |gesture_handler_| (or |scroll_gesture_handler_|) can be deleted during | 451 // |gesture_handler_| (or |scroll_gesture_handler_|) can be deleted during |
461 // processing. | 452 // processing. |
462 View* handler = scroll_gesture_handler_ && | 453 View* handler = scroll_gesture_handler_ && |
463 (event.IsScrollGestureEvent() || event.IsFlingScrollEvent()) ? | 454 (event.IsScrollGestureEvent() || event.IsFlingScrollEvent()) ? |
464 scroll_gesture_handler_ : gesture_handler_; | 455 scroll_gesture_handler_ : gesture_handler_; |
465 GestureEvent handler_event(event, this, handler); | 456 GestureEvent handler_event(event, this, handler); |
466 | 457 |
(...skipping 14 matching lines...) Expand all Loading... |
481 | 472 |
482 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN && | 473 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN && |
483 !scroll_gesture_handler_) { | 474 !scroll_gesture_handler_) { |
484 // Some view started processing gesture events, however it does not | 475 // Some view started processing gesture events, however it does not |
485 // process scroll-gesture events. In such case, we allow the event to | 476 // process scroll-gesture events. In such case, we allow the event to |
486 // bubble up, and install a different scroll-gesture handler different | 477 // bubble up, and install a different scroll-gesture handler different |
487 // from the default gesture handler. | 478 // from the default gesture handler. |
488 for (scroll_gesture_handler_ = gesture_handler_->parent(); | 479 for (scroll_gesture_handler_ = gesture_handler_->parent(); |
489 scroll_gesture_handler_ && scroll_gesture_handler_ != this; | 480 scroll_gesture_handler_ && scroll_gesture_handler_ != this; |
490 scroll_gesture_handler_ = scroll_gesture_handler_->parent()) { | 481 scroll_gesture_handler_ = scroll_gesture_handler_->parent()) { |
491 GestureEvent gesture_event(e, this, scroll_gesture_handler_); | 482 GestureEvent gesture_event(event, this, scroll_gesture_handler_); |
492 status = scroll_gesture_handler_->ProcessGestureEvent(gesture_event); | 483 status = scroll_gesture_handler_->ProcessGestureEvent(gesture_event); |
493 if (status == ui::GESTURE_STATUS_CONSUMED) | 484 if (status == ui::GESTURE_STATUS_CONSUMED) |
494 return status; | 485 return status; |
495 } | 486 } |
496 scroll_gesture_handler_ = NULL; | 487 scroll_gesture_handler_ = NULL; |
497 } | 488 } |
498 | 489 |
499 return ui::GESTURE_STATUS_UNKNOWN; | 490 return ui::GESTURE_STATUS_UNKNOWN; |
500 } | 491 } |
501 | 492 |
502 // Walk up the tree until we find a view that wants the gesture event. | 493 // Walk up the tree until we find a view that wants the gesture event. |
503 for (gesture_handler_ = GetEventHandlerForPoint(e.location()); | 494 for (gesture_handler_ = GetEventHandlerForPoint(event.location()); |
504 gesture_handler_ && (gesture_handler_ != this); | 495 gesture_handler_ && (gesture_handler_ != this); |
505 gesture_handler_ = gesture_handler_->parent()) { | 496 gesture_handler_ = gesture_handler_->parent()) { |
506 if (!gesture_handler_->enabled()) { | 497 if (!gesture_handler_->enabled()) { |
507 // Disabled views eat events but are treated as not handled. | 498 // Disabled views eat events but are treated as not handled. |
508 return ui::GESTURE_STATUS_UNKNOWN; | 499 return ui::GESTURE_STATUS_UNKNOWN; |
509 } | 500 } |
510 | 501 |
511 // See if this view wants to handle the Gesture. | 502 // See if this view wants to handle the Gesture. |
512 GestureEvent gesture_event(e, this, gesture_handler_); | 503 GestureEvent gesture_event(event, this, gesture_handler_); |
513 status = gesture_handler_->ProcessGestureEvent(gesture_event); | 504 status = gesture_handler_->ProcessGestureEvent(gesture_event); |
514 | 505 |
515 // The view could have removed itself from the tree when handling | 506 // The view could have removed itself from the tree when handling |
516 // OnGestureEvent(). So handle as per OnMousePressed. NB: we | 507 // OnGestureEvent(). So handle as per OnMousePressed. NB: we |
517 // assume that the RootView itself cannot be so removed. | 508 // assume that the RootView itself cannot be so removed. |
518 if (!gesture_handler_) | 509 if (!gesture_handler_) |
519 return ui::GESTURE_STATUS_UNKNOWN; | 510 return ui::GESTURE_STATUS_UNKNOWN; |
520 | 511 |
521 if (status == ui::GESTURE_STATUS_CONSUMED) { | 512 if (status == ui::GESTURE_STATUS_CONSUMED) { |
522 if (gesture_event.type() == ui::ET_GESTURE_SCROLL_BEGIN) | 513 if (gesture_event.type() == ui::ET_GESTURE_SCROLL_BEGIN) |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 } | 593 } |
603 | 594 |
604 void RootView::SetMouseLocationAndFlags(const MouseEvent& event) { | 595 void RootView::SetMouseLocationAndFlags(const MouseEvent& event) { |
605 last_mouse_event_flags_ = event.flags(); | 596 last_mouse_event_flags_ = event.flags(); |
606 last_mouse_event_x_ = event.x(); | 597 last_mouse_event_x_ = event.x(); |
607 last_mouse_event_y_ = event.y(); | 598 last_mouse_event_y_ = event.y(); |
608 } | 599 } |
609 | 600 |
610 } // namespace internal | 601 } // namespace internal |
611 } // namespace views | 602 } // namespace views |
OLD | NEW |