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

Side by Side Diff: ui/views/widget/root_view.cc

Issue 10912063: events: Get rid of GestureStatus in favour of EventResult. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 3 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
« no previous file with comments | « ui/views/widget/root_view.h ('k') | ui/views/widget/widget.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 448
449 return status; 449 return status;
450 } 450 }
451 451
452 // Reset touch_pressed_handler_ to indicate that no processing is occurring. 452 // Reset touch_pressed_handler_ to indicate that no processing is occurring.
453 touch_pressed_handler_ = NULL; 453 touch_pressed_handler_ = NULL;
454 454
455 return status; 455 return status;
456 } 456 }
457 457
458 ui::GestureStatus RootView::OnGestureEvent(const ui::GestureEvent& event) { 458 ui::EventResult RootView::OnGestureEvent(const ui::GestureEvent& event) {
459 ui::GestureStatus status = ui::GESTURE_STATUS_UNKNOWN; 459 ui::EventResult status = ui::ER_UNHANDLED;
460 460
461 if (gesture_handler_) { 461 if (gesture_handler_) {
462 // |gesture_handler_| (or |scroll_gesture_handler_|) can be deleted during 462 // |gesture_handler_| (or |scroll_gesture_handler_|) can be deleted during
463 // processing. 463 // processing.
464 View* handler = scroll_gesture_handler_ && 464 View* handler = scroll_gesture_handler_ &&
465 (event.IsScrollGestureEvent() || event.IsFlingScrollEvent()) ? 465 (event.IsScrollGestureEvent() || event.IsFlingScrollEvent()) ?
466 scroll_gesture_handler_ : gesture_handler_; 466 scroll_gesture_handler_ : gesture_handler_;
467 ui::GestureEvent handler_event(event, static_cast<View*>(this), handler); 467 ui::GestureEvent handler_event(event, static_cast<View*>(this), handler);
468 468
469 ui::GestureStatus status = handler->ProcessGestureEvent(handler_event); 469 ui::EventResult status = handler->ProcessGestureEvent(handler_event);
470 470
471 if (event.type() == ui::ET_GESTURE_END && 471 if (event.type() == ui::ET_GESTURE_END &&
472 event.details().touch_points() <= 1) 472 event.details().touch_points() <= 1)
473 gesture_handler_ = NULL; 473 gesture_handler_ = NULL;
474 474
475 if (scroll_gesture_handler_ && (event.type() == ui::ET_GESTURE_SCROLL_END || 475 if (scroll_gesture_handler_ && (event.type() == ui::ET_GESTURE_SCROLL_END ||
476 event.type() == ui::ET_SCROLL_FLING_START)) 476 event.type() == ui::ET_SCROLL_FLING_START))
477 scroll_gesture_handler_ = NULL; 477 scroll_gesture_handler_ = NULL;
478 478
479 if (status == ui::GESTURE_STATUS_CONSUMED) 479 if (status == ui::ER_CONSUMED)
480 return status; 480 return status;
481 481
482 DCHECK_EQ(ui::GESTURE_STATUS_UNKNOWN, status); 482 DCHECK_EQ(ui::ER_UNHANDLED, status);
483 483
484 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN && 484 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN &&
485 !scroll_gesture_handler_) { 485 !scroll_gesture_handler_) {
486 // Some view started processing gesture events, however it does not 486 // Some view started processing gesture events, however it does not
487 // process scroll-gesture events. In such case, we allow the event to 487 // process scroll-gesture events. In such case, we allow the event to
488 // bubble up, and install a different scroll-gesture handler different 488 // bubble up, and install a different scroll-gesture handler different
489 // from the default gesture handler. 489 // from the default gesture handler.
490 for (scroll_gesture_handler_ = gesture_handler_->parent(); 490 for (scroll_gesture_handler_ = gesture_handler_->parent();
491 scroll_gesture_handler_ && scroll_gesture_handler_ != this; 491 scroll_gesture_handler_ && scroll_gesture_handler_ != this;
492 scroll_gesture_handler_ = scroll_gesture_handler_->parent()) { 492 scroll_gesture_handler_ = scroll_gesture_handler_->parent()) {
493 ui::GestureEvent gesture_event(event, static_cast<View*>(this), 493 ui::GestureEvent gesture_event(event, static_cast<View*>(this),
494 scroll_gesture_handler_); 494 scroll_gesture_handler_);
495 status = scroll_gesture_handler_->ProcessGestureEvent(gesture_event); 495 status = scroll_gesture_handler_->ProcessGestureEvent(gesture_event);
496 if (status == ui::GESTURE_STATUS_CONSUMED) 496 if (status == ui::ER_CONSUMED)
497 return status; 497 return status;
498 } 498 }
499 scroll_gesture_handler_ = NULL; 499 scroll_gesture_handler_ = NULL;
500 } 500 }
501 501
502 return ui::GESTURE_STATUS_UNKNOWN; 502 return ui::ER_UNHANDLED;
503 } 503 }
504 504
505 // Walk up the tree until we find a view that wants the gesture event. 505 // Walk up the tree until we find a view that wants the gesture event.
506 for (gesture_handler_ = GetEventHandlerForPoint(event.location()); 506 for (gesture_handler_ = GetEventHandlerForPoint(event.location());
507 gesture_handler_ && (gesture_handler_ != this); 507 gesture_handler_ && (gesture_handler_ != this);
508 gesture_handler_ = gesture_handler_->parent()) { 508 gesture_handler_ = gesture_handler_->parent()) {
509 if (!gesture_handler_->enabled()) { 509 if (!gesture_handler_->enabled()) {
510 // Disabled views eat events but are treated as not handled. 510 // Disabled views eat events but are treated as not handled.
511 return ui::GESTURE_STATUS_UNKNOWN; 511 return ui::ER_UNHANDLED;
512 } 512 }
513 513
514 // See if this view wants to handle the Gesture. 514 // See if this view wants to handle the Gesture.
515 ui::GestureEvent gesture_event(event, static_cast<View*>(this), 515 ui::GestureEvent gesture_event(event, static_cast<View*>(this),
516 gesture_handler_); 516 gesture_handler_);
517 status = gesture_handler_->ProcessGestureEvent(gesture_event); 517 status = gesture_handler_->ProcessGestureEvent(gesture_event);
518 518
519 // The view could have removed itself from the tree when handling 519 // The view could have removed itself from the tree when handling
520 // OnGestureEvent(). So handle as per OnMousePressed. NB: we 520 // OnGestureEvent(). So handle as per OnMousePressed. NB: we
521 // assume that the RootView itself cannot be so removed. 521 // assume that the RootView itself cannot be so removed.
522 if (!gesture_handler_) 522 if (!gesture_handler_)
523 return ui::GESTURE_STATUS_UNKNOWN; 523 return ui::ER_UNHANDLED;
524 524
525 if (status == ui::GESTURE_STATUS_CONSUMED) { 525 if (status == ui::ER_CONSUMED) {
526 if (gesture_event.type() == ui::ET_GESTURE_SCROLL_BEGIN) 526 if (gesture_event.type() == ui::ET_GESTURE_SCROLL_BEGIN)
527 scroll_gesture_handler_ = gesture_handler_; 527 scroll_gesture_handler_ = gesture_handler_;
528 return status; 528 return status;
529 } 529 }
530 530
531 // The gesture event wasn't processed. Go up the view hierarchy and 531 // The gesture event wasn't processed. Go up the view hierarchy and
532 // dispatch the gesture event. 532 // dispatch the gesture event.
533 DCHECK_EQ(ui::GESTURE_STATUS_UNKNOWN, status); 533 DCHECK_EQ(ui::ER_UNHANDLED, status);
534 } 534 }
535 535
536 gesture_handler_ = NULL; 536 gesture_handler_ = NULL;
537 537
538 return status; 538 return status;
539 } 539 }
540 540
541 void RootView::SetMouseHandler(View* new_mh) { 541 void RootView::SetMouseHandler(View* new_mh) {
542 // If we're clearing the mouse handler, clear explicit_mouse_handler_ as well. 542 // If we're clearing the mouse handler, clear explicit_mouse_handler_ as well.
543 explicit_mouse_handler_ = (new_mh != NULL); 543 explicit_mouse_handler_ = (new_mh != NULL);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 } 607 }
608 608
609 void RootView::SetMouseLocationAndFlags(const ui::MouseEvent& event) { 609 void RootView::SetMouseLocationAndFlags(const ui::MouseEvent& event) {
610 last_mouse_event_flags_ = event.flags(); 610 last_mouse_event_flags_ = event.flags();
611 last_mouse_event_x_ = event.x(); 611 last_mouse_event_x_ = event.x();
612 last_mouse_event_y_ = event.y(); 612 last_mouse_event_y_ = event.y();
613 } 613 }
614 614
615 } // namespace internal 615 } // namespace internal
616 } // namespace views 616 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/root_view.h ('k') | ui/views/widget/widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698