diff options
author | sadrul <sadrul@chromium.org> | 2015-12-07 17:55:40 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-08 01:56:52 +0000 |
commit | 33c52dde3a9c355c6b21fc7725e200cda19c29a5 (patch) | |
tree | 31c63c2798d4566d1f4959e138a924ec34c3a2dd /components/html_viewer | |
parent | 4a48e3d6ac23770e16305d239dcd64344091b167 (diff) | |
download | chromium_src-33c52dde3a9c355c6b21fc7725e200cda19c29a5.zip chromium_src-33c52dde3a9c355c6b21fc7725e200cda19c29a5.tar.gz chromium_src-33c52dde3a9c355c6b21fc7725e200cda19c29a5.tar.bz2 |
mus: Allow a mus app to manually/explicitly ack an event.
Instead of dispatching an input event to all mus::WindowObservers of a
mus::Window, have an explicit mus::InputEventHandler, which is responsible
for processing events for a Window. The InputEventHandler receives the
target, the event, and the ack callback. If it wants to explicitly ack the
event (possibly asynchronously, e.g. chrome renderer, when it receives the
event in the compositor thread, but wants to process the event in the main
thread before ack'ing), it can take the ack callback, and return true to
notify the client-lib.
BUG=none
Committed: https://crrev.com/07a19a2bc8560ce5e99cd27a9830089683153046
Cr-Commit-Position: refs/heads/master@{#363617}
Review URL: https://codereview.chromium.org/1492963003
Cr-Commit-Position: refs/heads/master@{#363700}
Diffstat (limited to 'components/html_viewer')
-rw-r--r-- | components/html_viewer/html_frame.cc | 21 | ||||
-rw-r--r-- | components/html_viewer/html_frame.h | 11 |
2 files changed, 21 insertions, 11 deletions
diff --git a/components/html_viewer/html_frame.cc b/components/html_viewer/html_frame.cc index 1ddb997..50a183d 100644 --- a/components/html_viewer/html_frame.cc +++ b/components/html_viewer/html_frame.cc @@ -584,11 +584,15 @@ web_view::mojom::Frame* HTMLFrame::GetServerFrame() { } void HTMLFrame::SetWindow(mus::Window* window) { - if (window_) + if (window_) { + window_->set_input_event_handler(nullptr); window_->RemoveObserver(this); + } window_ = window; - if (window_) + if (window_) { window_->AddObserver(this); + window_->set_input_event_handler(this); + } } void HTMLFrame::CreateRootWebWidget() { @@ -757,8 +761,14 @@ void HTMLFrame::OnWindowDestroyed(mus::Window* window) { Close(); } +void HTMLFrame::OnWindowFocusChanged(mus::Window* gained_focus, + mus::Window* lost_focus) { + UpdateFocus(); +} + void HTMLFrame::OnWindowInputEvent(mus::Window* window, - const mus::mojom::EventPtr& event) { + mus::mojom::EventPtr event, + scoped_ptr<base::Closure>* ack_callback) { if (event->pointer_data && event->pointer_data->location) { // Blink expects coordintes to be in DIPs. event->pointer_data->location->x /= global_state()->device_pixel_ratio(); @@ -794,11 +804,6 @@ void HTMLFrame::OnWindowInputEvent(mus::Window* window, web_widget->handleInputEvent(*web_event); } -void HTMLFrame::OnWindowFocusChanged(mus::Window* gained_focus, - mus::Window* lost_focus) { - UpdateFocus(); -} - void HTMLFrame::OnConnect( web_view::mojom::FramePtr frame, uint32_t change_id, diff --git a/components/html_viewer/html_frame.h b/components/html_viewer/html_frame.h index 9f108ac..1439c6a2 100644 --- a/components/html_viewer/html_frame.h +++ b/components/html_viewer/html_frame.h @@ -13,6 +13,7 @@ #include "cc/layers/surface_layer.h" #include "components/html_viewer/html_frame_tree_manager.h" #include "components/html_viewer/replicated_frame_state.h" +#include "components/mus/public/cpp/input_event_handler.h" #include "components/mus/public/cpp/window_observer.h" #include "components/web_view/public/interfaces/frame.mojom.h" #include "mojo/public/cpp/bindings/binding.h" @@ -70,7 +71,8 @@ class WebLayerTreeViewImpl; class HTMLFrame : public blink::WebFrameClient, public blink::WebRemoteFrameClient, public web_view::mojom::FrameClient, - public mus::WindowObserver { + public mus::WindowObserver, + public mus::InputEventHandler { public: struct CreateParams { CreateParams( @@ -270,11 +272,14 @@ class HTMLFrame : public blink::WebFrameClient, const gfx::Rect& old_bounds, const gfx::Rect& new_bounds) override; void OnWindowDestroyed(mus::Window* window) override; - void OnWindowInputEvent(mus::Window* window, - const mus::mojom::EventPtr& event) override; void OnWindowFocusChanged(mus::Window* gained_focus, mus::Window* lost_focus) override; + // mus::InputEventHandler: + void OnWindowInputEvent(mus::Window* window, + mus::mojom::EventPtr event, + scoped_ptr<base::Closure>* ack_callback) override; + // web_view::mojom::FrameClient: void OnConnect(web_view::mojom::FramePtr server, uint32_t change_id, |