OLD | NEW |
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/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 } | 570 } |
571 | 571 |
572 bool BrowserPlugin::handleInputEvent(const blink::WebInputEvent& event, | 572 bool BrowserPlugin::handleInputEvent(const blink::WebInputEvent& event, |
573 blink::WebCursorInfo& cursor_info) { | 573 blink::WebCursorInfo& cursor_info) { |
574 if (guest_crashed_ || !ready()) | 574 if (guest_crashed_ || !ready()) |
575 return false; | 575 return false; |
576 | 576 |
577 if (event.type == blink::WebInputEvent::ContextMenu) | 577 if (event.type == blink::WebInputEvent::ContextMenu) |
578 return true; | 578 return true; |
579 | 579 |
580 const blink::WebInputEvent* modified_event = &event; | |
581 scoped_ptr<blink::WebTouchEvent> touch_event; | |
582 // TODO(jdduke): Remove this branch when Blink starts forwarding | |
583 // WebTouchEvents with a fully populated |touches| field. | |
584 if (blink::WebInputEvent::isTouchEventType(event.type) && | |
585 static_cast<const blink::WebTouchEvent*>(&event)->changedTouchesLength) { | |
586 const blink::WebTouchEvent* orig_touch_event = | |
587 static_cast<const blink::WebTouchEvent*>(&event); | |
588 | |
589 touch_event.reset(new blink::WebTouchEvent()); | |
590 memcpy(touch_event.get(), orig_touch_event, sizeof(blink::WebTouchEvent)); | |
591 | |
592 // TODO(bokan): Blink passes back a WebGestureEvent with a touches, | |
593 // changedTouches, and targetTouches lists; however, it doesn't set | |
594 // the state field on the touches which is what the RenderWidget uses | |
595 // to create a WebCore::TouchEvent. crbug.com/358132 tracks removing | |
596 // these multiple lists from WebTouchEvent since they lead to misuse | |
597 // like this and are functionally unused. In the mean time we'll setup | |
598 // the state field here manually to fix multi-touch BrowserPlugins. | |
599 for (size_t i = 0; i < touch_event->touchesLength; ++i) { | |
600 blink::WebTouchPoint& touch = touch_event->touches[i]; | |
601 touch.state = blink::WebTouchPoint::StateStationary; | |
602 for (size_t j = 0; j < touch_event->changedTouchesLength; ++j) { | |
603 blink::WebTouchPoint& changed_touch = touch_event->changedTouches[j]; | |
604 if (touch.id == changed_touch.id) { | |
605 touch.state = changed_touch.state; | |
606 break; | |
607 } | |
608 } | |
609 } | |
610 | |
611 // For End and Cancel, Blink gives BrowserPlugin a list of touches that | |
612 // are down, but the browser process expects a list of all touches. We | |
613 // modify these events here to match these expectations. | |
614 if (event.type == blink::WebInputEvent::TouchEnd || | |
615 event.type == blink::WebInputEvent::TouchCancel) { | |
616 if (touch_event->changedTouchesLength > 0) { | |
617 memcpy(&touch_event->touches[touch_event->touchesLength], | |
618 &touch_event->changedTouches, | |
619 touch_event->changedTouchesLength * sizeof(blink::WebTouchPoint)); | |
620 touch_event->touchesLength += touch_event->changedTouchesLength; | |
621 } | |
622 } | |
623 modified_event = touch_event.get(); | |
624 } | |
625 | |
626 if (blink::WebInputEvent::isKeyboardEventType(event.type) && | 580 if (blink::WebInputEvent::isKeyboardEventType(event.type) && |
627 !edit_commands_.empty()) { | 581 !edit_commands_.empty()) { |
628 browser_plugin_manager()->Send( | 582 browser_plugin_manager()->Send( |
629 new BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent( | 583 new BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent( |
630 render_view_routing_id_, | 584 render_view_routing_id_, |
631 browser_plugin_instance_id_, | 585 browser_plugin_instance_id_, |
632 edit_commands_)); | 586 edit_commands_)); |
633 edit_commands_.clear(); | 587 edit_commands_.clear(); |
634 } | 588 } |
635 | 589 |
636 browser_plugin_manager()->Send( | 590 browser_plugin_manager()->Send( |
637 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, | 591 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, |
638 browser_plugin_instance_id_, | 592 browser_plugin_instance_id_, |
639 plugin_rect_, | 593 plugin_rect_, |
640 modified_event)); | 594 &event)); |
641 GetWebKitCursorInfo(cursor_, &cursor_info); | 595 GetWebKitCursorInfo(cursor_, &cursor_info); |
642 return true; | 596 return true; |
643 } | 597 } |
644 | 598 |
645 bool BrowserPlugin::handleDragStatusUpdate(blink::WebDragStatus drag_status, | 599 bool BrowserPlugin::handleDragStatusUpdate(blink::WebDragStatus drag_status, |
646 const blink::WebDragData& drag_data, | 600 const blink::WebDragData& drag_data, |
647 blink::WebDragOperationsMask mask, | 601 blink::WebDragOperationsMask mask, |
648 const blink::WebPoint& position, | 602 const blink::WebPoint& position, |
649 const blink::WebPoint& screen) { | 603 const blink::WebPoint& screen) { |
650 if (guest_crashed_ || !ready()) | 604 if (guest_crashed_ || !ready()) |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 const blink::WebMouseEvent& event) { | 725 const blink::WebMouseEvent& event) { |
772 browser_plugin_manager()->Send( | 726 browser_plugin_manager()->Send( |
773 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, | 727 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, |
774 browser_plugin_instance_id_, | 728 browser_plugin_instance_id_, |
775 plugin_rect_, | 729 plugin_rect_, |
776 &event)); | 730 &event)); |
777 return true; | 731 return true; |
778 } | 732 } |
779 | 733 |
780 } // namespace content | 734 } // namespace content |
OLD | NEW |