Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef UI_EVENTS_EVENT_REWRITER_H_ | |
| 6 #define UI_EVENTS_EVENT_REWRITER_H_ | |
| 7 | |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "ui/events/events_export.h" | |
| 10 | |
| 11 namespace ui { | |
| 12 | |
| 13 class Event; | |
| 14 | |
| 15 // Return status of EventRewriter operations; see that class below. | |
| 16 enum EventRewriteStatus { | |
| 17 // Nothing was done; no rewritten event returned. Pass the original | |
| 18 // event to later rewriters, or send it to the EventProcessor if this | |
| 19 // was the final rewriter. | |
| 20 EVENT_REWRITE_CONTINUE, | |
| 21 | |
| 22 // The event has been rewritten. Send the rewritten event to the | |
| 23 // EventProcessor instead of the original event (without sending | |
| 24 // either to any later rewriters). | |
| 25 EVENT_REWRITE_REWRITTEN, | |
| 26 | |
| 27 // The event should be discarded, neither passing it to any later | |
| 28 // rewriters nor sending it to the EventProcessor. | |
| 29 EVENT_REWRITE_DISCARD, | |
| 30 | |
| 31 // The event has been rewritten. As for EVENT_REWRITE_REWRITTEN, | |
| 32 // send the rewritten event to the EventProcessor instead of the | |
| 33 // original event (without sending either to any later rewriters). | |
| 34 // In addition the rewriter has one or more additional new events | |
| 35 // to be retrieved using |NextDispatchEvent()| and sent to the | |
| 36 // EventProcessor. | |
| 37 EVENT_REWRITE_DISPATCH_ANOTHER, | |
| 38 }; | |
| 39 | |
| 40 // EventRewriter provides a mechanism for Events to be rewritten | |
| 41 // before being dispatched from EventSource to EventProcessor. | |
| 42 class EVENTS_EXPORT EventRewriter { | |
| 43 public: | |
| 44 virtual ~EventRewriter() {} | |
| 45 | |
| 46 // Potentially rewrites (replaces) an event, or requests it be discarded. | |
| 47 // or discards an event. The arguments must not alias. If the rewriter | |
| 48 // wants to rewrite an event, and dispatch another event once the rewritten | |
| 49 // event is dispatched, it should return EVENT_REWRITE_DISPATCH_ANOTHER, | |
| 50 // and return the next event to dispatch from |NextDispatchEvent()|. | |
| 51 virtual EventRewriteStatus RewriteEvent( | |
| 52 const Event& event, scoped_ptr<Event>& rewritten_event) = 0; | |
|
sadrul
2014/03/26 17:26:27
chromium doesn't allow non-const refs. So use a po
| |
| 53 | |
| 54 // Supplies an additional event to be dispatched. The arguments must not | |
| 55 // alias. It is only valid to call this after the immediately previous | |
|
sadrul
2014/03/26 17:26:27
ditto
| |
| 56 // call to |RewriteEvent()| or |NextDispatchEvent()| has returned | |
| 57 // EVENT_REWRITE_DISPATCH_ANOTHER. Should only return either | |
| 58 // EVENT_REWRITE_REWRITTEN or EVENT_REWRITE_DISPATCH_ANOTHER; otherwise | |
| 59 // the previous call should not have returned EVENT_REWRITE_DISPATCH_ANOTHER. | |
| 60 virtual EventRewriteStatus NextDispatchEvent( | |
| 61 const Event& last_event, scoped_ptr<Event>& new_event) = 0; | |
| 62 }; | |
| 63 | |
| 64 } // namespace ui | |
| 65 | |
| 66 #endif // UI_EVENTS_EVENT_REWRITER_H_ | |
| OLD | NEW |