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

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

Issue 557863002: Remove references to WebTouchEvent.targetTouches (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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/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 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
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;
581 scoped_ptr<blink::WebTouchEvent> touch_event; 581 scoped_ptr<blink::WebTouchEvent> touch_event;
582 if (blink::WebInputEvent::isTouchEventType(event.type)) { 582 if (blink::WebInputEvent::isTouchEventType(event.type)) {
583 const blink::WebTouchEvent* orig_touch_event = 583 const blink::WebTouchEvent* orig_touch_event =
584 static_cast<const blink::WebTouchEvent*>(&event); 584 static_cast<const blink::WebTouchEvent*>(&event);
585 // TODO(jdduke): Remove this branch when Blink starts forwarding
586 // WebTouchEvents with a fully populated |touches| field.
587 if (orig_touch_event->changedTouchesLength) {
588 touch_event.reset(new blink::WebTouchEvent());
589 memcpy(touch_event.get(), orig_touch_event, sizeof(blink::WebTouchEvent));
585 590
586 touch_event.reset(new blink::WebTouchEvent()); 591 if (touch_event->changedTouchesLength)
bokan 2014/09/09 20:17:38 Nit: I should have done this when i was here...can
jdduke (slow) 2014/09/09 20:52:24 Done.
587 memcpy(touch_event.get(), orig_touch_event, sizeof(blink::WebTouchEvent)); 592 // TODO(bokan): Blink passes back a WebGestureEvent with touches and
593 // changedTouches lists; however, it doesn't set the state field on the
594 // touches which is what the RenderWidget uses to create a
595 // WebCore::TouchEvent. crbug.com/358132 tracks removing these multiple
596 // from WebTouchEvent since they lead to misuse like this and are
597 // functionally unused. In the mean time we'll setup the state field
598 // 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 =
604 touch_event->changedTouches[j];
605 if (touch.id == changed_touch.id) {
606 touch.state = changed_touch.state;
607 break;
608 }
609 }
610 }
588 611
589 // TODO(bokan): Blink passes back a WebGestureEvent with a touches, 612 // For End and Cancel, Blink gives BrowserPlugin a list of touches that
590 // changedTouches, and targetTouches lists; however, it doesn't set 613 // are down, but the browser process expects a list of all touches. We
591 // the state field on the touches which is what the RenderWidget uses 614 // modify these events here to match these expectations.
592 // to create a WebCore::TouchEvent. crbug.com/358132 tracks removing 615 if (event.type == blink::WebInputEvent::TouchEnd ||
593 // these multiple lists from WebTouchEvent since they lead to misuse 616 event.type == blink::WebInputEvent::TouchCancel) {
594 // like this and are functionally unused. In the mean time we'll setup 617 if (touch_event->changedTouchesLength > 0) {
595 // the state field here manually to fix multi-touch BrowserPlugins. 618 memcpy(
596 for (size_t i = 0; i < touch_event->touchesLength; ++i) { 619 &touch_event->touches[touch_event->touchesLength],
597 blink::WebTouchPoint& touch = touch_event->touches[i]; 620 &touch_event->changedTouches,
598 touch.state = blink::WebTouchPoint::StateStationary; 621 touch_event->changedTouchesLength * sizeof(blink::WebTouchPoint));
599 for (size_t j = 0; j < touch_event->changedTouchesLength; ++j) { 622 touch_event->touchesLength += touch_event->changedTouchesLength;
600 blink::WebTouchPoint& changed_touch = touch_event->changedTouches[j];
601 if (touch.id == changed_touch.id) {
602 touch.state = changed_touch.state;
603 break;
604 } 623 }
605 } 624 }
625 modified_event = touch_event.get();
606 } 626 }
607
608 // For End and Cancel, Blink gives BrowserPlugin a list of touches that
609 // are down, but the browser process expects a list of all touches. We
610 // modify these events here to match these expectations.
611 if (event.type == blink::WebInputEvent::TouchEnd ||
612 event.type == blink::WebInputEvent::TouchCancel) {
613 if (touch_event->changedTouchesLength > 0) {
614 memcpy(&touch_event->touches[touch_event->touchesLength],
615 &touch_event->changedTouches,
616 touch_event->changedTouchesLength * sizeof(blink::WebTouchPoint));
617 touch_event->touchesLength += touch_event->changedTouchesLength;
618 }
619 }
620 modified_event = touch_event.get();
621 } 627 }
622 628
623 if (blink::WebInputEvent::isKeyboardEventType(event.type) && 629 if (blink::WebInputEvent::isKeyboardEventType(event.type) &&
624 !edit_commands_.empty()) { 630 !edit_commands_.empty()) {
625 browser_plugin_manager()->Send( 631 browser_plugin_manager()->Send(
626 new BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent( 632 new BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent(
627 render_view_routing_id_, 633 render_view_routing_id_,
628 browser_plugin_instance_id_, 634 browser_plugin_instance_id_,
629 edit_commands_)); 635 edit_commands_));
630 edit_commands_.clear(); 636 edit_commands_.clear();
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 const blink::WebMouseEvent& event) { 774 const blink::WebMouseEvent& event) {
769 browser_plugin_manager()->Send( 775 browser_plugin_manager()->Send(
770 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, 776 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_,
771 browser_plugin_instance_id_, 777 browser_plugin_instance_id_,
772 plugin_rect_, 778 plugin_rect_,
773 &event)); 779 &event));
774 return true; 780 return true;
775 } 781 }
776 782
777 } // namespace content 783 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/pepper/event_conversion.cc » ('j') | content/renderer/pepper/event_conversion.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698