Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/browser/browser_plugin/browser_plugin_guest.h" | 5 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 356 auto* render_widget_host = RenderWidgetHostImpl::From( | 356 auto* render_widget_host = RenderWidgetHostImpl::From( |
| 357 GetWebContents()->GetRenderViewHost()->GetWidget()); | 357 GetWebContents()->GetRenderViewHost()->GetWidget()); |
| 358 render_widget_host->NotifyScreenInfoChanged(); | 358 render_widget_host->NotifyScreenInfoChanged(); |
| 359 | 359 |
| 360 // TODO(chrishtr): this code is wrong. The navigate_on_drag_drop field will | 360 // TODO(chrishtr): this code is wrong. The navigate_on_drag_drop field will |
| 361 // be reset again the next time preferences are updated. | 361 // be reset again the next time preferences are updated. |
| 362 WebPreferences prefs = | 362 WebPreferences prefs = |
| 363 GetWebContents()->GetRenderViewHost()->GetWebkitPreferences(); | 363 GetWebContents()->GetRenderViewHost()->GetWebkitPreferences(); |
| 364 prefs.navigate_on_drag_drop = false; | 364 prefs.navigate_on_drag_drop = false; |
| 365 GetWebContents()->GetRenderViewHost()->UpdateWebkitPreferences(prefs); | 365 GetWebContents()->GetRenderViewHost()->UpdateWebkitPreferences(prefs); |
| 366 | |
| 367 if (auto* owner_rwhv = GetOwnerRenderWidgetHostView()) { | |
| 368 guest_window_rect_.set_origin(owner_rwhv->TransformPointToRootCoordSpace( | |
| 369 guest_window_rect_.origin())); | |
| 370 } | |
| 366 } | 371 } |
| 367 | 372 |
| 368 BrowserPluginGuest::~BrowserPluginGuest() { | 373 BrowserPluginGuest::~BrowserPluginGuest() { |
| 369 } | 374 } |
| 370 | 375 |
| 371 // static | 376 // static |
| 372 BrowserPluginGuest* BrowserPluginGuest::Create( | 377 BrowserPluginGuest* BrowserPluginGuest::Create( |
| 373 WebContentsImpl* web_contents, | 378 WebContentsImpl* web_contents, |
| 374 BrowserPluginGuestDelegate* delegate) { | 379 BrowserPluginGuestDelegate* delegate) { |
| 375 return new BrowserPluginGuest( | 380 return new BrowserPluginGuest( |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 459 | 464 |
| 460 void BrowserPluginGuest::ResendEventToEmbedder( | 465 void BrowserPluginGuest::ResendEventToEmbedder( |
| 461 const blink::WebInputEvent& event) { | 466 const blink::WebInputEvent& event) { |
| 462 if (!attached() || !owner_web_contents_) | 467 if (!attached() || !owner_web_contents_) |
| 463 return; | 468 return; |
| 464 | 469 |
| 465 DCHECK(browser_plugin_instance_id_); | 470 DCHECK(browser_plugin_instance_id_); |
| 466 RenderWidgetHostViewBase* view = | 471 RenderWidgetHostViewBase* view = |
| 467 static_cast<RenderWidgetHostViewBase*>(GetOwnerRenderWidgetHostView()); | 472 static_cast<RenderWidgetHostViewBase*>(GetOwnerRenderWidgetHostView()); |
| 468 | 473 |
| 469 gfx::Vector2d offset_from_embedder = guest_window_rect_.OffsetFromOrigin(); | 474 gfx::Vector2d offset_from_embedder = guest_window_rect_.OffsetFromOrigin(); |
|
lfg
2016/12/05 19:44:18
If we are transforming guest_window_rect to the ro
EhsanK
2016/12/06 00:08:54
Correct.
| |
| 470 if (event.type == blink::WebInputEvent::GestureScrollUpdate) { | 475 if (event.type == blink::WebInputEvent::GestureScrollUpdate) { |
| 471 blink::WebGestureEvent resent_gesture_event; | 476 blink::WebGestureEvent resent_gesture_event; |
| 472 memcpy(&resent_gesture_event, &event, sizeof(blink::WebGestureEvent)); | 477 memcpy(&resent_gesture_event, &event, sizeof(blink::WebGestureEvent)); |
| 473 resent_gesture_event.x += offset_from_embedder.x(); | 478 resent_gesture_event.x += offset_from_embedder.x(); |
| 474 resent_gesture_event.y += offset_from_embedder.y(); | 479 resent_gesture_event.y += offset_from_embedder.y(); |
| 475 // Mark the resend source with the browser plugin's instance id, so the | 480 // Mark the resend source with the browser plugin's instance id, so the |
| 476 // correct browser_plugin will know to ignore the event. | 481 // correct browser_plugin will know to ignore the event. |
| 477 resent_gesture_event.resendingPluginId = browser_plugin_instance_id_; | 482 resent_gesture_event.resendingPluginId = browser_plugin_instance_id_; |
| 478 ui::LatencyInfo latency_info = | 483 ui::LatencyInfo latency_info = |
| 479 ui::WebInputEventTraits::CreateLatencyInfoForWebGestureEvent( | 484 ui::WebInputEventTraits::CreateLatencyInfoForWebGestureEvent( |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 995 if (mouse_locked_) | 1000 if (mouse_locked_) |
| 996 Send(new ViewMsg_MouseLockLost(routing_id())); | 1001 Send(new ViewMsg_MouseLockLost(routing_id())); |
| 997 mouse_locked_ = false; | 1002 mouse_locked_ = false; |
| 998 } | 1003 } |
| 999 | 1004 |
| 1000 void BrowserPluginGuest::OnUpdateGeometry(int browser_plugin_instance_id, | 1005 void BrowserPluginGuest::OnUpdateGeometry(int browser_plugin_instance_id, |
| 1001 const gfx::Rect& view_rect) { | 1006 const gfx::Rect& view_rect) { |
| 1002 // The plugin has moved within the embedder without resizing or the | 1007 // The plugin has moved within the embedder without resizing or the |
| 1003 // embedder/container's view rect changing. | 1008 // embedder/container's view rect changing. |
| 1004 guest_window_rect_ = view_rect; | 1009 guest_window_rect_ = view_rect; |
| 1010 if (auto* rwhv = GetOwnerRenderWidgetHostView()) { | |
| 1011 guest_window_rect_.set_origin( | |
| 1012 rwhv->TransformPointToRootCoordSpace(guest_window_rect_.origin())); | |
| 1013 } | |
| 1014 | |
| 1005 GetWebContents()->SendScreenRects(); | 1015 GetWebContents()->SendScreenRects(); |
| 1006 } | 1016 } |
| 1007 | 1017 |
| 1008 void BrowserPluginGuest::OnHasTouchEventHandlers(bool accept) { | 1018 void BrowserPluginGuest::OnHasTouchEventHandlers(bool accept) { |
| 1009 SendMessageToEmbedder( | 1019 SendMessageToEmbedder( |
| 1010 base::MakeUnique<BrowserPluginMsg_ShouldAcceptTouchEvents>( | 1020 base::MakeUnique<BrowserPluginMsg_ShouldAcceptTouchEvents>( |
| 1011 browser_plugin_instance_id(), accept)); | 1021 browser_plugin_instance_id(), accept)); |
| 1012 } | 1022 } |
| 1013 | 1023 |
| 1014 #if defined(OS_MACOSX) | 1024 #if defined(OS_MACOSX) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1063 range, character_bounds); | 1073 range, character_bounds); |
| 1064 } | 1074 } |
| 1065 #endif | 1075 #endif |
| 1066 | 1076 |
| 1067 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { | 1077 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { |
| 1068 if (delegate_) | 1078 if (delegate_) |
| 1069 delegate_->SetContextMenuPosition(position); | 1079 delegate_->SetContextMenuPosition(position); |
| 1070 } | 1080 } |
| 1071 | 1081 |
| 1072 } // namespace content | 1082 } // namespace content |
| OLD | NEW |