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; | 580 const blink::WebInputEvent* modified_event = &event; |
Fady Samuel
2014/09/10 01:10:54
We can probably get rid of this local variable too
jdduke (slow)
2014/09/10 15:31:23
Good catch, for whatever reason I thought keyboard
| |
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) && | 581 if (blink::WebInputEvent::isKeyboardEventType(event.type) && |
627 !edit_commands_.empty()) { | 582 !edit_commands_.empty()) { |
628 browser_plugin_manager()->Send( | 583 browser_plugin_manager()->Send( |
629 new BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent( | 584 new BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent( |
630 render_view_routing_id_, | 585 render_view_routing_id_, |
631 browser_plugin_instance_id_, | 586 browser_plugin_instance_id_, |
632 edit_commands_)); | 587 edit_commands_)); |
633 edit_commands_.clear(); | 588 edit_commands_.clear(); |
634 } | 589 } |
635 | 590 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
771 const blink::WebMouseEvent& event) { | 726 const blink::WebMouseEvent& event) { |
772 browser_plugin_manager()->Send( | 727 browser_plugin_manager()->Send( |
773 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, | 728 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, |
774 browser_plugin_instance_id_, | 729 browser_plugin_instance_id_, |
775 plugin_rect_, | 730 plugin_rect_, |
776 &event)); | 731 &event)); |
777 return true; | 732 return true; |
778 } | 733 } |
779 | 734 |
780 } // namespace content | 735 } // namespace content |
OLD | NEW |