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

Side by Side Diff: ui/base/events/event.cc

Issue 11881042: highlight intermediate tabs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make check for Gesture vs Scroll event for flings explicit Created 7 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 | Annotate | Revision Log
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/base/events/event.h" 5 #include "ui/base/events/event.h"
6 6
7 #if defined(USE_X11) 7 #if defined(USE_X11)
8 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
9 #endif 9 #endif
10 10
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 LocatedEvent::LocatedEvent(const base::NativeEvent& native_event) 229 LocatedEvent::LocatedEvent(const base::NativeEvent& native_event)
230 : Event(native_event, 230 : Event(native_event,
231 EventTypeFromNative(native_event), 231 EventTypeFromNative(native_event),
232 EventFlagsFromNative(native_event)), 232 EventFlagsFromNative(native_event)),
233 location_(EventLocationFromNative(native_event)), 233 location_(EventLocationFromNative(native_event)),
234 root_location_(location_), 234 root_location_(location_),
235 valid_system_location_(true), 235 valid_system_location_(true),
236 system_location_(ui::EventSystemLocationFromNative(native_event)) { 236 system_location_(ui::EventSystemLocationFromNative(native_event)) {
237 } 237 }
238 238
239 LocatedEvent::LocatedEvent(const LocatedEvent& model)
240 : Event(model),
241 location_(model.location_),
242 root_location_(model.root_location_),
243 valid_system_location_(model.valid_system_location_),
244 system_location_(model.system_location_) {
245 }
246
239 LocatedEvent::LocatedEvent(EventType type, 247 LocatedEvent::LocatedEvent(EventType type,
240 const gfx::Point& location, 248 const gfx::Point& location,
241 const gfx::Point& root_location, 249 const gfx::Point& root_location,
242 base::TimeDelta time_stamp, 250 base::TimeDelta time_stamp,
243 int flags) 251 int flags)
244 : Event(type, time_stamp, flags), 252 : Event(type, time_stamp, flags),
245 location_(location), 253 location_(location),
246 root_location_(root_location), 254 root_location_(root_location),
247 valid_system_location_(false), 255 valid_system_location_(false),
248 system_location_(0, 0) { 256 system_location_(0, 0) {
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 bool is_cancel; 631 bool is_cancel;
624 GetFlingData(native_event, &x_offset_, &y_offset_, &is_cancel); 632 GetFlingData(native_event, &x_offset_, &y_offset_, &is_cancel);
625 } else { 633 } else {
626 NOTREACHED() << "Unexpected event type " << type() 634 NOTREACHED() << "Unexpected event type " << type()
627 << " when constructing a ScrollEvent."; 635 << " when constructing a ScrollEvent.";
628 } 636 }
629 } 637 }
630 638
631 ScrollEvent::ScrollEvent(EventType type, 639 ScrollEvent::ScrollEvent(EventType type,
632 const gfx::Point& location, 640 const gfx::Point& location,
641 base::TimeDelta time_stamp,
633 int flags, 642 int flags,
634 float x_offset, 643 float x_offset,
635 float y_offset) 644 float y_offset,
645 int finger_count)
636 : MouseEvent(type, location, location, flags), 646 : MouseEvent(type, location, location, flags),
637 x_offset_(x_offset), 647 x_offset_(x_offset),
638 y_offset_(y_offset) { 648 y_offset_(y_offset),
649 finger_count_(finger_count) {
650 set_time_stamp(time_stamp);
639 CHECK(IsScrollEvent()); 651 CHECK(IsScrollEvent());
640 } 652 }
641 653
642 void ScrollEvent::Scale(const float factor) { 654 void ScrollEvent::Scale(const float factor) {
643 x_offset_ *= factor; 655 x_offset_ *= factor;
644 y_offset_ *= factor; 656 y_offset_ *= factor;
645 } 657 }
646 658
647 //////////////////////////////////////////////////////////////////////////////// 659 ////////////////////////////////////////////////////////////////////////////////
648 // GestureEvent 660 // GestureEvent
649 661
650 GestureEvent::GestureEvent(EventType type, 662 GestureEvent::GestureEvent(EventType type,
651 int x, 663 int x,
652 int y, 664 int y,
653 int flags, 665 int flags,
654 base::TimeDelta time_stamp, 666 base::TimeDelta time_stamp,
655 const GestureEventDetails& details, 667 const GestureEventDetails& details,
656 unsigned int touch_ids_bitfield) 668 unsigned int touch_ids_bitfield)
657 : LocatedEvent(type, gfx::Point(x, y), gfx::Point(x, y), time_stamp, flags), 669 : LocatedEvent(type,
670 gfx::Point(x, y),
671 gfx::Point(x, y),
672 time_stamp,
673 flags),
658 details_(details), 674 details_(details),
659 touch_ids_bitfield_(touch_ids_bitfield) { 675 touch_ids_bitfield_(touch_ids_bitfield) {
660 } 676 }
661 677
662 GestureEvent::~GestureEvent() { 678 GestureEvent::~GestureEvent() {
663 } 679 }
664 680
665 int GestureEvent::GetLowestTouchId() const { 681 int GestureEvent::GetLowestTouchId() const {
666 if (touch_ids_bitfield_ == 0) 682 if (touch_ids_bitfield_ == 0)
667 return -1; 683 return -1;
668 int i = -1; 684 int i = -1;
669 // Find the index of the least significant 1 bit 685 // Find the index of the least significant 1 bit
670 while (!(1 << ++i & touch_ids_bitfield_)); 686 while (!(1 << ++i & touch_ids_bitfield_));
671 return i; 687 return i;
672 } 688 }
673 689
674 } // namespace ui 690 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698