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

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

Issue 11308322: events: Start changing EventHandler interface to not return a value. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 delete native_event_; 64 delete native_event_;
65 #endif 65 #endif
66 } 66 }
67 67
68 bool Event::HasNativeEvent() const { 68 bool Event::HasNativeEvent() const {
69 base::NativeEvent null_event; 69 base::NativeEvent null_event;
70 std::memset(&null_event, 0, sizeof(null_event)); 70 std::memset(&null_event, 0, sizeof(null_event));
71 return !!std::memcmp(&native_event_, &null_event, sizeof(null_event)); 71 return !!std::memcmp(&native_event_, &null_event, sizeof(null_event));
72 } 72 }
73 73
74 void Event::StopPropagation() {
75 CHECK(phase_ != EP_PREDISPATCH && phase_ != EP_POSTDISPATCH);
76 result_ = static_cast<ui::EventResult>(result_ | ER_CONSUMED);
77 CHECK(stopped_propagation());
78 }
79
80 void Event::PreventDefault() {
81 CHECK(phase_ != EP_PREDISPATCH && phase_ != EP_POSTDISPATCH);
Ben Goodger (Google) 2012/12/03 17:36:54 i would also like the ability to prevent this (and
sadrul 2012/12/03 17:45:20 Indeed. I have that in mind :) [ crbug.com/163617
82 result_ = static_cast<ui::EventResult>(result_ | ER_HANDLED);
83 }
84
74 Event::Event(EventType type, base::TimeDelta time_stamp, int flags) 85 Event::Event(EventType type, base::TimeDelta time_stamp, int flags)
75 : type_(type), 86 : type_(type),
76 time_stamp_(time_stamp), 87 time_stamp_(time_stamp),
77 flags_(flags), 88 flags_(flags),
78 delete_native_event_(false), 89 delete_native_event_(false),
79 target_(NULL), 90 target_(NULL),
80 phase_(EP_PREDISPATCH), 91 phase_(EP_PREDISPATCH),
81 result_(ER_UNHANDLED) { 92 result_(ER_UNHANDLED) {
82 Init(); 93 Init();
83 } 94 }
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 int GestureEvent::GetLowestTouchId() const { 563 int GestureEvent::GetLowestTouchId() const {
553 if (touch_ids_bitfield_ == 0) 564 if (touch_ids_bitfield_ == 0)
554 return -1; 565 return -1;
555 int i = -1; 566 int i = -1;
556 // Find the index of the least significant 1 bit 567 // Find the index of the least significant 1 bit
557 while (!(1 << ++i & touch_ids_bitfield_)); 568 while (!(1 << ++i & touch_ids_bitfield_));
558 return i; 569 return i;
559 } 570 }
560 571
561 } // namespace ui 572 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698