| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/events/platform/platform_event_source.h" | 5 #include "ui/events/platform/platform_event_source.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "ui/events/platform/platform_event_dispatcher.h" | 10 #include "ui/events/platform/platform_event_dispatcher.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 CHECK(observer); | 56 CHECK(observer); |
| 57 observers_.AddObserver(observer); | 57 observers_.AddObserver(observer); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void PlatformEventSource::RemovePlatformEventObserver( | 60 void PlatformEventSource::RemovePlatformEventObserver( |
| 61 PlatformEventObserver* observer) { | 61 PlatformEventObserver* observer) { |
| 62 observers_.RemoveObserver(observer); | 62 observers_.RemoveObserver(observer); |
| 63 } | 63 } |
| 64 | 64 |
| 65 uint32_t PlatformEventSource::DispatchEvent(PlatformEvent platform_event) { | 65 uint32_t PlatformEventSource::DispatchEvent(PlatformEvent platform_event) { |
| 66 uint32_t action = POST_DISPATCH_PERFORM_DEFAULT; | 66 uint32_t action = kPostDispatchPerformDefault; |
| 67 | 67 |
| 68 FOR_EACH_OBSERVER(PlatformEventObserver, observers_, | 68 FOR_EACH_OBSERVER(PlatformEventObserver, observers_, |
| 69 WillProcessEvent(platform_event)); | 69 WillProcessEvent(platform_event)); |
| 70 // Give the overridden dispatcher a chance to dispatch the event first. | 70 // Give the overridden dispatcher a chance to dispatch the event first. |
| 71 if (overridden_dispatcher_) | 71 if (overridden_dispatcher_) |
| 72 action = overridden_dispatcher_->DispatchEvent(platform_event); | 72 action = overridden_dispatcher_->DispatchEvent(platform_event); |
| 73 | 73 |
| 74 if ((action & POST_DISPATCH_PERFORM_DEFAULT) && | 74 if ((action & kPostDispatchPerformDefault) && |
| 75 dispatchers_.might_have_observers()) { | 75 dispatchers_.might_have_observers()) { |
| 76 ObserverList<PlatformEventDispatcher>::Iterator iter(dispatchers_); | 76 ObserverList<PlatformEventDispatcher>::Iterator iter(dispatchers_); |
| 77 while (PlatformEventDispatcher* dispatcher = iter.GetNext()) { | 77 while (PlatformEventDispatcher* dispatcher = iter.GetNext()) { |
| 78 if (dispatcher->CanDispatchEvent(platform_event)) | 78 if (dispatcher->CanDispatchEvent(platform_event)) |
| 79 action = dispatcher->DispatchEvent(platform_event); | 79 action = dispatcher->DispatchEvent(platform_event); |
| 80 if (action & POST_DISPATCH_STOP_PROPAGATION) | 80 if (action & kPostDispatchStopPropagation) |
| 81 break; | 81 break; |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 FOR_EACH_OBSERVER(PlatformEventObserver, observers_, | 84 FOR_EACH_OBSERVER(PlatformEventObserver, observers_, |
| 85 DidProcessEvent(platform_event)); | 85 DidProcessEvent(platform_event)); |
| 86 | 86 |
| 87 // If an overridden dispatcher has been destroyed, then the platform | 87 // If an overridden dispatcher has been destroyed, then the platform |
| 88 // event-source should halt dispatching the current stream of events, and wait | 88 // event-source should halt dispatching the current stream of events, and wait |
| 89 // until the next message-loop iteration for dispatching events. This lets any | 89 // until the next message-loop iteration for dispatching events. This lets any |
| 90 // nested message-loop to unwind correctly and any new dispatchers to receive | 90 // nested message-loop to unwind correctly and any new dispatchers to receive |
| (...skipping 11 matching lines...) Expand all Loading... |
| 102 | 102 |
| 103 void PlatformEventSource::OnDispatcherListChanged() { | 103 void PlatformEventSource::OnDispatcherListChanged() { |
| 104 } | 104 } |
| 105 | 105 |
| 106 void PlatformEventSource::OnOverriddenDispatcherRestored() { | 106 void PlatformEventSource::OnOverriddenDispatcherRestored() { |
| 107 CHECK(overridden_dispatcher_); | 107 CHECK(overridden_dispatcher_); |
| 108 overridden_dispatcher_restored_ = true; | 108 overridden_dispatcher_restored_ = true; |
| 109 } | 109 } |
| 110 | 110 |
| 111 } // namespace ui | 111 } // namespace ui |
| OLD | NEW |