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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_event_handler.cc

Issue 2775553002: Adds the ability for WebContentsDelegate to decide if event should be updated (Closed)
Patch Set: Fix compile Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "content/browser/renderer_host/render_widget_host_view_event_handler.h" 5 #include "content/browser/renderer_host/render_widget_host_view_event_handler.h"
6 6
7 #include "base/metrics/user_metrics_action.h" 7 #include "base/metrics/user_metrics_action.h"
8 #include "content/browser/renderer_host/input/touch_selection_controller_client_ aura.h" 8 #include "content/browser/renderer_host/input/touch_selection_controller_client_ aura.h"
9 #include "content/browser/renderer_host/overscroll_controller.h" 9 #include "content/browser/renderer_host/overscroll_controller.h"
10 #include "content/browser/renderer_host/render_view_host_delegate.h" 10 #include "content/browser/renderer_host/render_view_host_delegate.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 241
242 void RenderWidgetHostViewEventHandler::OnKeyEvent(ui::KeyEvent* event) { 242 void RenderWidgetHostViewEventHandler::OnKeyEvent(ui::KeyEvent* event) {
243 TRACE_EVENT0("input", "RenderWidgetHostViewBase::OnKeyEvent"); 243 TRACE_EVENT0("input", "RenderWidgetHostViewBase::OnKeyEvent");
244 244
245 if (NeedsInputGrab(popup_child_host_view_)) { 245 if (NeedsInputGrab(popup_child_host_view_)) {
246 popup_child_event_handler_->OnKeyEvent(event); 246 popup_child_event_handler_->OnKeyEvent(event);
247 if (event->handled()) 247 if (event->handled())
248 return; 248 return;
249 } 249 }
250 250
251 bool mark_event_as_handled = true;
251 // We need to handle the Escape key for Pepper Flash. 252 // We need to handle the Escape key for Pepper Flash.
252 if (host_view_->is_fullscreen() && event->key_code() == ui::VKEY_ESCAPE) { 253 if (host_view_->is_fullscreen() && event->key_code() == ui::VKEY_ESCAPE) {
253 // Focus the window we were created from. 254 // Focus the window we were created from.
254 if (host_tracker_.get() && !host_tracker_->windows().empty()) { 255 if (host_tracker_.get() && !host_tracker_->windows().empty()) {
255 aura::Window* host = *(host_tracker_->windows().begin()); 256 aura::Window* host = *(host_tracker_->windows().begin());
256 aura::client::FocusClient* client = aura::client::GetFocusClient(host); 257 aura::client::FocusClient* client = aura::client::GetFocusClient(host);
257 if (client) { 258 if (client) {
258 // Calling host->Focus() may delete |this|. We create a local observer 259 // Calling host->Focus() may delete |this|. We create a local observer
259 // for that. In that case we exit without further access to any members. 260 // for that. In that case we exit without further access to any members.
260 auto local_tracker = std::move(host_tracker_); 261 auto local_tracker = std::move(host_tracker_);
(...skipping 15 matching lines...) Expand all
276 // Accept return key character events between press and release events. 277 // Accept return key character events between press and release events.
277 accept_return_character_ = event->type() == ui::ET_KEY_PRESSED; 278 accept_return_character_ = event->type() == ui::ET_KEY_PRESSED;
278 } 279 }
279 280
280 // Call SetKeyboardFocus() for not only ET_KEY_PRESSED but also 281 // Call SetKeyboardFocus() for not only ET_KEY_PRESSED but also
281 // ET_KEY_RELEASED. If a user closed the hotdog menu with ESC key press, 282 // ET_KEY_RELEASED. If a user closed the hotdog menu with ESC key press,
282 // we need to notify focus to Blink on ET_KEY_RELEASED for ESC key. 283 // we need to notify focus to Blink on ET_KEY_RELEASED for ESC key.
283 SetKeyboardFocus(); 284 SetKeyboardFocus();
284 // We don't have to communicate with an input method here. 285 // We don't have to communicate with an input method here.
285 NativeWebKeyboardEvent webkit_event(*event); 286 NativeWebKeyboardEvent webkit_event(*event);
286 delegate_->ForwardKeyboardEvent(webkit_event); 287 delegate_->ForwardKeyboardEvent(webkit_event, &mark_event_as_handled);
287 } 288 }
288 event->SetHandled(); 289 if (mark_event_as_handled)
290 event->SetHandled();
289 } 291 }
290 292
291 void RenderWidgetHostViewEventHandler::OnMouseEvent(ui::MouseEvent* event) { 293 void RenderWidgetHostViewEventHandler::OnMouseEvent(ui::MouseEvent* event) {
292 TRACE_EVENT0("input", "RenderWidgetHostViewBase::OnMouseEvent"); 294 TRACE_EVENT0("input", "RenderWidgetHostViewBase::OnMouseEvent");
293 ForwardMouseEventToParent(event); 295 ForwardMouseEventToParent(event);
294 // TODO(mgiuca): Return if event->handled() returns true. This currently 296 // TODO(mgiuca): Return if event->handled() returns true. This currently
295 // breaks drop-down lists which means something is incorrectly setting 297 // breaks drop-down lists which means something is incorrectly setting
296 // event->handled to true (http://crbug.com/577983). 298 // event->handled to true (http://crbug.com/577983).
297 299
298 if (mouse_locked_) { 300 if (mouse_locked_) {
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 host_->ForwardWheelEventWithLatencyInfo(event, latency); 869 host_->ForwardWheelEventWithLatencyInfo(event, latency);
868 } 870 }
869 871
870 void RenderWidgetHostViewEventHandler::ProcessTouchEvent( 872 void RenderWidgetHostViewEventHandler::ProcessTouchEvent(
871 const blink::WebTouchEvent& event, 873 const blink::WebTouchEvent& event,
872 const ui::LatencyInfo& latency) { 874 const ui::LatencyInfo& latency) {
873 host_->ForwardTouchEventWithLatencyInfo(event, latency); 875 host_->ForwardTouchEventWithLatencyInfo(event, latency);
874 } 876 }
875 877
876 } // namespace content 878 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698