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

Unified Diff: mojo/services/native_viewport/native_viewport_impl.cc

Issue 685013002: Refactors event dispatching of NativeViewport into its own interface (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: cleanup Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: mojo/services/native_viewport/native_viewport_impl.cc
diff --git a/mojo/services/native_viewport/native_viewport_impl.cc b/mojo/services/native_viewport/native_viewport_impl.cc
index 810d33976f7380165d51d12d3d59a8197963a972..d6c39d57f695cf052ab4a9aa6d09b0541b0c62eb 100644
--- a/mojo/services/native_viewport/native_viewport_impl.cc
+++ b/mojo/services/native_viewport/native_viewport_impl.cc
@@ -93,6 +93,11 @@ void NativeViewportImpl::SubmittedFrame(SurfaceIdPtr child_surface_id) {
viewport_surface_->SetChildId(child_surface_id_);
}
+void NativeViewportImpl::SetEventDispatcher(
+ NativeViewportEventDispatcherPtr dispatcher) {
+ event_dispatcher_ = dispatcher.Pass();
+}
+
void NativeViewportImpl::OnBoundsChanged(const gfx::Rect& bounds) {
if (size_ == bounds.size())
return;
@@ -118,6 +123,9 @@ void NativeViewportImpl::OnAcceleratedWidgetAvailable(
}
bool NativeViewportImpl::OnEvent(ui::Event* ui_event) {
+ if (!event_dispatcher_.get())
+ return false;
+
// Must not return early before updating capture.
switch (ui_event->type()) {
case ui::ET_MOUSE_PRESSED:
@@ -135,7 +143,7 @@ bool NativeViewportImpl::OnEvent(ui::Event* ui_event) {
if (waiting_for_event_ack_ && IsRateLimitedEventType(ui_event))
return false;
- client()->OnEvent(
+ event_dispatcher_->OnEvent(
Event::From(*ui_event),
base::Bind(&NativeViewportImpl::AckEvent, weak_factory_.GetWeakPtr()));
waiting_for_event_ack_ = true;

Powered by Google App Engine
This is Rietveld 408576698