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

Issue 11308322: events: Start changing EventHandler interface to not return a value. (Closed)

Created:
8 years ago by sadrul
Modified:
8 years ago
CC:
chromium-reviews, tfarina, ben+watch_chromium.org
Visibility:
Public.

Description

events: Start changing EventHandler interface to not return a value. The EventHandler should explicitly stop the propagation of an event (Event::StopPropagation()), or mark it has having been handled (Event::PreventDefault()), by calling a function on the event object, instead of returning a value from the event-handler functions. This patch takes the first step by converting EventHandler::OnEvent. Subsequent patches will conver the event-specific callbacks (OnKeyEvent etc.) BUG=163618 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=170801

Patch Set 1 #

Total comments: 6

Patch Set 2 : self-nit #

Patch Set 3 : . #

Unified diffs Side-by-side diffs Delta from patch set Stats (+125 lines, -101 lines) Patch
M ui/aura/root_window.h View 1 1 chunk +5 lines, -6 lines 0 comments Download
M ui/aura/root_window.cc View 1 2 8 chunks +25 lines, -22 lines 0 comments Download
M ui/base/events/event.h View 1 2 1 chunk +9 lines, -0 lines 0 comments Download
M ui/base/events/event.cc View 1 2 1 chunk +11 lines, -0 lines 0 comments Download
M ui/base/events/event_dispatcher.h View 5 chunks +22 lines, -27 lines 0 comments Download
M ui/base/events/event_dispatcher.cc View 2 chunks +3 lines, -2 lines 0 comments Download
M ui/base/events/event_dispatcher_unittest.cc View 1 2 8 chunks +20 lines, -23 lines 0 comments Download
M ui/base/events/event_handler.h View 1 chunk +1 line, -1 line 0 comments Download
M ui/base/events/event_handler.cc View 1 2 1 chunk +16 lines, -11 lines 0 comments Download
M ui/views/corewm/activation_change_shim.h View 1 2 1 chunk +1 line, -1 line 0 comments Download
M ui/views/corewm/activation_change_shim.cc View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M ui/views/corewm/focus_change_shim.h View 1 2 1 chunk +1 line, -1 line 0 comments Download
M ui/views/corewm/focus_change_shim.cc View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M ui/views/corewm/focus_controller.cc View 1 1 chunk +2 lines, -1 line 0 comments Download
M ui/views/corewm/focus_controller_unittest.cc View 1 2 1 chunk +5 lines, -2 lines 0 comments Download

Messages

Total messages: 7 (0 generated)
sadrul
One concern I have is that the event-handlers may perform some action, and then forget ...
8 years ago (2012-12-03 17:21:46 UTC) #1
Ben Goodger (Google)
I believe "unhandled" is probably right in 99% of cases, so I'm not too concerned.
8 years ago (2012-12-03 17:36:44 UTC) #2
Ben Goodger (Google)
lgtm https://codereview.chromium.org/11308322/diff/1/ui/base/events/event.cc File ui/base/events/event.cc (right): https://codereview.chromium.org/11308322/diff/1/ui/base/events/event.cc#newcode81 ui/base/events/event.cc:81: CHECK(phase_ != EP_PREDISPATCH && phase_ != EP_POSTDISPATCH); i ...
8 years ago (2012-12-03 17:36:53 UTC) #3
sadrul
https://codereview.chromium.org/11308322/diff/1/ui/base/events/event.cc File ui/base/events/event.cc (right): https://codereview.chromium.org/11308322/diff/1/ui/base/events/event.cc#newcode81 ui/base/events/event.cc:81: CHECK(phase_ != EP_PREDISPATCH && phase_ != EP_POSTDISPATCH); On 2012/12/03 ...
8 years ago (2012-12-03 17:45:20 UTC) #4
sadrul
Changed to SetHandled() and handled()
8 years ago (2012-12-03 18:04:48 UTC) #5
Ben Goodger (Google)
slgtm
8 years ago (2012-12-03 18:45:36 UTC) #6
Ben Goodger (Google)
8 years ago (2012-12-04 08:16:28 UTC) #7
I like handled()/SetHandled().

-Ben


On Mon, Dec 3, 2012 at 9:45 AM, <sadrul@chromium.org> wrote:

>
> https://codereview.chromium.**org/11308322/diff/1/ui/base/**
>
events/event.cc<https://codereview.chromium.org/11308322/diff/1/ui/base/events/event.cc>
> File ui/base/events/event.cc (right):
>
> https://codereview.chromium.**org/11308322/diff/1/ui/base/**
>
events/event.cc#newcode81<https://codereview.chromium.org/11308322/diff/1/ui/base/events/event.cc#newcode81>
> ui/base/events/event.cc:81: CHECK(phase_ != EP_PREDISPATCH && phase_ !=
> EP_POSTDISPATCH);
> On 2012/12/03 17:36:54, Ben Goodger (Google) wrote:
>
>> i would also like the ability to prevent this (and probably
>>
> stoppropagation?)
>
>> via a flag on the dispatcher api to event. e.g. focus change events
>>
> should not
>
>> be cancelable.
>>
>
>  can be done in a followon cl.
>>
>
> Indeed. I have that in mind :) [ crbug.com/163617 ]
>
>
>
https://codereview.chromium.**org/11308322/diff/1/ui/base/**events/event.h<ht...
> File ui/base/events/event.h (right):
>
> https://codereview.chromium.**org/11308322/diff/1/ui/base/**
>
events/event.h#newcode166<https://codereview.chromium.org/11308322/diff/1/ui/base/events/event.h#newcode166>
> ui/base/events/event.h:166: // be in the list will not receive the event
> after this is called.
> On 2012/12/03 17:36:54, Ben Goodger (Google) wrote:
>
>> One thing to note. Reading the W3C spec for DOMEvents, stop
>>
> propagation only
>
>> takes effect after the current layer, e.g. for pre-target handlers all
>>
> handlers
>
>> at the current level will be fired and then propagation stopped. Not
>>
> sure we
>
>> care here, at least not yet.
>>
>
> One of the use-cases for StopPropagation is when the target is destroyed
> by an event-handler. In such cases, continuing to dispatch the event to
> other handlers can cause crashes etc.
>
>
> https://codereview.chromium.**org/11308322/diff/1/ui/base/**
>
events/event.h#newcode171<https://codereview.chromium.org/11308322/diff/1/ui/base/events/event.h#newcode171>
> ui/base/events/event.h:171: bool default_prevented() const { return
> result_ != ui::ER_UNHANDLED; }
> On 2012/12/03 17:36:54, Ben Goodger (Google) wrote:
>
>> This reads a little awkwardly. I'm not sure I have any more precise
>>
> suggestions
>
>> though. DOM's "canceled" is simpler but maybe vaguer?
>>
>
> How about 'handled()' or 'processed()' (and
> 'MarkHandled'/'MarkProcessed')**?
>
>
https://codereview.chromium.**org/11308322/<https://codereview.chromium.org/1...
>

Powered by Google App Engine
This is Rietveld 408576698