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

Side by Side Diff: content/renderer/browser_plugin/browser_plugin.cc

Issue 1254883006: Bubble scroll events from WebView guest to embedder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Complete test. Created 5 years, 4 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/renderer/browser_plugin/browser_plugin.h" 5 #include "content/renderer/browser_plugin/browser_plugin.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 488
489 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_SetVisibility( 489 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_SetVisibility(
490 browser_plugin_instance_id_, 490 browser_plugin_instance_id_,
491 visible)); 491 visible));
492 } 492 }
493 493
494 bool BrowserPlugin::acceptsInputEvents() { 494 bool BrowserPlugin::acceptsInputEvents() {
495 return true; 495 return true;
496 } 496 }
497 497
498 namespace {
499
500 bool IsScrollEvent(blink::WebInputEvent::Type event_type) {
501 return event_type == blink::WebInputEvent::GestureScrollBegin ||
502 event_type == blink::WebInputEvent::GestureScrollUpdate ||
503 event_type == blink::WebInputEvent::GestureScrollEnd ||
504 event_type == blink::WebInputEvent::MouseWheel;
505 }
506
507 } // namespace
508
498 bool BrowserPlugin::handleInputEvent(const blink::WebInputEvent& event, 509 bool BrowserPlugin::handleInputEvent(const blink::WebInputEvent& event,
499 blink::WebCursorInfo& cursor_info) { 510 blink::WebCursorInfo& cursor_info) {
500 if (guest_crashed_ || !attached()) 511 if (guest_crashed_ || !attached())
501 return false; 512 return false;
502 513
503 if (event.type == blink::WebInputEvent::ContextMenu) 514 if (event.type == blink::WebInputEvent::ContextMenu)
504 return true; 515 return true;
505 516
506 if (blink::WebInputEvent::isKeyboardEventType(event.type) && 517 if (blink::WebInputEvent::isKeyboardEventType(event.type) &&
507 !edit_commands_.empty()) { 518 !edit_commands_.empty()) {
508 BrowserPluginManager::Get()->Send( 519 BrowserPluginManager::Get()->Send(
509 new BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent( 520 new BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent(
510 browser_plugin_instance_id_, 521 browser_plugin_instance_id_,
511 edit_commands_)); 522 edit_commands_));
512 edit_commands_.clear(); 523 edit_commands_.clear();
513 } 524 }
514 525
515 BrowserPluginManager::Get()->Send( 526 BrowserPluginManager::Get()->Send(
516 new BrowserPluginHostMsg_HandleInputEvent(browser_plugin_instance_id_, 527 new BrowserPluginHostMsg_HandleInputEvent(browser_plugin_instance_id_,
517 view_rect_, 528 view_rect_,
518 &event)); 529 &event));
519 GetWebKitCursorInfo(cursor_, &cursor_info); 530 GetWebKitCursorInfo(cursor_, &cursor_info);
520 return true; 531
532 // For scroll events we must block and wait for the response from the guest,
533 // otherwise we do not know if the guest was able to handle the scroll event.
534 // We need to give other elements in the embedder renderer a chance to handle
535 // the scroll if the guest did not.
536 if (IsScrollEvent(event.type))
537 return BrowserPluginManager::Get()->GetScrollHandledStatus();
538 else
539 return true;
521 } 540 }
522 541
523 bool BrowserPlugin::handleDragStatusUpdate(blink::WebDragStatus drag_status, 542 bool BrowserPlugin::handleDragStatusUpdate(blink::WebDragStatus drag_status,
524 const blink::WebDragData& drag_data, 543 const blink::WebDragData& drag_data,
525 blink::WebDragOperationsMask mask, 544 blink::WebDragOperationsMask mask,
526 const blink::WebPoint& position, 545 const blink::WebPoint& position,
527 const blink::WebPoint& screen) { 546 const blink::WebPoint& screen) {
528 if (guest_crashed_ || !attached()) 547 if (guest_crashed_ || !attached())
529 return false; 548 return false;
530 BrowserPluginManager::Get()->Send( 549 BrowserPluginManager::Get()->Send(
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 bool BrowserPlugin::HandleMouseLockedInputEvent( 661 bool BrowserPlugin::HandleMouseLockedInputEvent(
643 const blink::WebMouseEvent& event) { 662 const blink::WebMouseEvent& event) {
644 BrowserPluginManager::Get()->Send( 663 BrowserPluginManager::Get()->Send(
645 new BrowserPluginHostMsg_HandleInputEvent(browser_plugin_instance_id_, 664 new BrowserPluginHostMsg_HandleInputEvent(browser_plugin_instance_id_,
646 view_rect_, 665 view_rect_,
647 &event)); 666 &event));
648 return true; 667 return true;
649 } 668 }
650 669
651 } // namespace content 670 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/browser_plugin/browser_plugin.h ('k') | content/renderer/browser_plugin/browser_plugin_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698