diff options
Diffstat (limited to 'chromium/content/renderer/browser_plugin/browser_plugin.cc')
-rw-r--r-- | chromium/content/renderer/browser_plugin/browser_plugin.cc | 103 |
1 files changed, 66 insertions, 37 deletions
diff --git a/chromium/content/renderer/browser_plugin/browser_plugin.cc b/chromium/content/renderer/browser_plugin/browser_plugin.cc index 973f835727b..c5fe59a5237 100644 --- a/chromium/content/renderer/browser_plugin/browser_plugin.cc +++ b/chromium/content/renderer/browser_plugin/browser_plugin.cc @@ -22,6 +22,7 @@ #include "components/viz/common/surfaces/surface_info.h" #include "content/common/browser_plugin/browser_plugin_constants.h" #include "content/common/browser_plugin/browser_plugin_messages.h" +#include "content/common/frame_messages.h" #include "content/common/view_messages.h" #include "content/public/common/content_client.h" #include "content/public/common/content_switches.h" @@ -34,17 +35,17 @@ #include "content/renderer/drop_data_builder.h" #include "content/renderer/render_thread_impl.h" #include "content/renderer/sad_plugin.h" -#include "third_party/WebKit/public/platform/WebCoalescedInputEvent.h" -#include "third_party/WebKit/public/platform/WebGestureEvent.h" -#include "third_party/WebKit/public/platform/WebInputEvent.h" -#include "third_party/WebKit/public/platform/WebMouseWheelEvent.h" -#include "third_party/WebKit/public/platform/WebRect.h" -#include "third_party/WebKit/public/web/WebAXObject.h" -#include "third_party/WebKit/public/web/WebDocument.h" -#include "third_party/WebKit/public/web/WebElement.h" -#include "third_party/WebKit/public/web/WebLocalFrame.h" -#include "third_party/WebKit/public/web/WebPluginContainer.h" -#include "third_party/WebKit/public/web/WebView.h" +#include "third_party/blink/public/platform/web_coalesced_input_event.h" +#include "third_party/blink/public/platform/web_gesture_event.h" +#include "third_party/blink/public/platform/web_input_event.h" +#include "third_party/blink/public/platform/web_mouse_wheel_event.h" +#include "third_party/blink/public/platform/web_rect.h" +#include "third_party/blink/public/web/web_ax_object.h" +#include "third_party/blink/public/web/web_document.h" +#include "third_party/blink/public/web/web_element.h" +#include "third_party/blink/public/web/web_local_frame.h" +#include "third_party/blink/public/web/web_plugin_container.h" +#include "third_party/blink/public/web/web_view.h" #include "ui/base/ui_base_features.h" #include "ui/events/keycodes/keyboard_codes.h" @@ -123,6 +124,8 @@ bool BrowserPlugin::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(BrowserPluginMsg_Attach_ACK, OnAttachACK) IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestGone, OnGuestGone) IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestReady, OnGuestReady) + IPC_MESSAGE_HANDLER(BrowserPluginMsg_EnableAutoResize, OnEnableAutoResize) + IPC_MESSAGE_HANDLER(BrowserPluginMsg_DisableAutoResize, OnDisableAutoResize) IPC_MESSAGE_HANDLER(BrowserPluginMsg_ResizeDueToAutoResize, OnResizeDueToAutoResize) IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetCursor, OnSetCursor) @@ -145,11 +148,12 @@ void BrowserPlugin::OnSetChildFrameSurface( return; if (!enable_surface_synchronization_) { - compositing_helper_->SetPrimarySurfaceId(surface_info.id(), - frame_rect().size()); + compositing_helper_->SetPrimarySurfaceId( + surface_info.id(), screen_space_rect().size(), + cc::DeadlinePolicy::UseDefaultDeadline()); } compositing_helper_->SetFallbackSurfaceId(surface_info.id(), - frame_rect().size()); + screen_space_rect().size()); } void BrowserPlugin::UpdateDOMAttribute(const std::string& attribute_name, @@ -168,7 +172,7 @@ void BrowserPlugin::Attach() { BrowserPluginHostMsg_Attach_Params attach_params; attach_params.focused = ShouldGuestBeFocused(); attach_params.visible = visible_; - attach_params.frame_rect = frame_rect(); + attach_params.frame_rect = screen_space_rect(); attach_params.is_full_page_plugin = false; if (Container()) { blink::WebLocalFrame* frame = Container()->GetDocument().GetFrame(); @@ -221,7 +225,7 @@ void BrowserPlugin::Detach() { } const viz::LocalSurfaceId& BrowserPlugin::GetLocalSurfaceId() const { - return parent_local_surface_id_allocator_.last_known_local_surface_id(); + return parent_local_surface_id_allocator_.GetCurrentLocalSurfaceId(); } #if defined(USE_AURA) @@ -248,10 +252,18 @@ void BrowserPlugin::CreateMusWindowAndEmbed( void BrowserPlugin::WasResized() { bool size_changed = !sent_resize_params_ || - sent_resize_params_->frame_rect.size() != - pending_resize_params_.frame_rect.size() || - sent_resize_params_->sequence_number != - pending_resize_params_.sequence_number; + sent_resize_params_->auto_resize_enabled != + pending_resize_params_.auto_resize_enabled || + sent_resize_params_->min_size_for_auto_resize != + pending_resize_params_.min_size_for_auto_resize || + sent_resize_params_->max_size_for_auto_resize != + pending_resize_params_.max_size_for_auto_resize || + sent_resize_params_->local_frame_size != + pending_resize_params_.local_frame_size || + sent_resize_params_->screen_space_rect.size() != + pending_resize_params_.screen_space_rect.size() || + sent_resize_params_->auto_resize_sequence_number != + pending_resize_params_.auto_resize_sequence_number; bool synchronized_params_changed = !sent_resize_params_ || size_changed || @@ -261,26 +273,28 @@ void BrowserPlugin::WasResized() { parent_local_surface_id_allocator_.GenerateId(); if (enable_surface_synchronization_ && frame_sink_id_.is_valid()) { + // TODO(vmpstr): When capture_sequence_number is available, the deadline + // should be infinite if the sequence number has changed. compositing_helper_->SetPrimarySurfaceId( viz::SurfaceId(frame_sink_id_, GetLocalSurfaceId()), - frame_rect().size()); + screen_space_rect().size(), cc::DeadlinePolicy::UseDefaultDeadline()); } - bool position_changed = - !sent_resize_params_ || sent_resize_params_->frame_rect.origin() != - pending_resize_params_.frame_rect.origin(); + bool position_changed = !sent_resize_params_ || + sent_resize_params_->screen_space_rect.origin() != + pending_resize_params_.screen_space_rect.origin(); bool resize_params_changed = synchronized_params_changed || position_changed; if (resize_params_changed && attached()) { // Let the browser know about the updated view rect. BrowserPluginManager::Get()->Send( - new BrowserPluginHostMsg_UpdateResizeParams( - browser_plugin_instance_id_, frame_rect(), screen_info(), - auto_size_sequence_number(), GetLocalSurfaceId())); + new BrowserPluginHostMsg_UpdateResizeParams(browser_plugin_instance_id_, + GetLocalSurfaceId(), + pending_resize_params_)); } if (delegate_ && size_changed) - delegate_->DidResizeElement(frame_rect().size()); + delegate_->DidResizeElement(screen_space_rect().size()); if (resize_params_changed && attached()) sent_resize_params_ = pending_resize_params_; @@ -314,7 +328,7 @@ void BrowserPlugin::OnAttachACK( void BrowserPlugin::OnGuestGone(int browser_plugin_instance_id) { guest_crashed_ = true; - compositing_helper_->ChildFrameGone(frame_rect().size(), + compositing_helper_->ChildFrameGone(screen_space_rect().size(), screen_info().device_scale_factor); } @@ -328,7 +342,21 @@ void BrowserPlugin::OnGuestReady(int browser_plugin_instance_id, void BrowserPlugin::OnResizeDueToAutoResize(int browser_plugin_instance_id, uint64_t sequence_number) { - pending_resize_params_.sequence_number = sequence_number; + pending_resize_params_.auto_resize_sequence_number = sequence_number; + WasResized(); +} + +void BrowserPlugin::OnEnableAutoResize(int browser_plugin_instance_id, + const gfx::Size& min_size, + const gfx::Size& max_size) { + pending_resize_params_.auto_resize_enabled = true; + pending_resize_params_.min_size_for_auto_resize = min_size; + pending_resize_params_.max_size_for_auto_resize = max_size; + WasResized(); +} + +void BrowserPlugin::OnDisableAutoResize(int browser_plugin_instance_id) { + pending_resize_params_.auto_resize_enabled = false; WasResized(); } @@ -384,8 +412,9 @@ void BrowserPlugin::OnShouldAcceptTouchEvents(int browser_plugin_instance_id, gfx::Rect BrowserPlugin::FrameRectInPixels() const { const float device_scale_factor = GetDeviceScaleFactor(); return gfx::Rect( - gfx::ScaleToFlooredPoint(frame_rect().origin(), device_scale_factor), - gfx::ScaleToCeiledSize(frame_rect().size(), device_scale_factor)); + gfx::ScaleToFlooredPoint(screen_space_rect().origin(), + device_scale_factor), + gfx::ScaleToCeiledSize(screen_space_rect().size(), device_scale_factor)); } float BrowserPlugin::GetDeviceScaleFactor() const { @@ -416,7 +445,7 @@ void BrowserPlugin::ScreenInfoChanged(const ScreenInfo& screen_info) { pending_resize_params_.screen_info = screen_info; if (guest_crashed_) { // Update the sad page to match the current ScreenInfo. - compositing_helper_->ChildFrameGone(frame_rect().size(), + compositing_helper_->ChildFrameGone(screen_space_rect().size(), screen_info.device_scale_factor); return; } @@ -537,7 +566,7 @@ void BrowserPlugin::UpdateGeometry(const WebRect& plugin_rect_in_viewport, // If this local root belongs to an OOPIF, on the browser side we will have to // consider the displacement of the child frame in root window. embedding_render_widget_->ConvertViewportToWindow(&rect_in_css); - gfx::Rect frame_rect = rect_in_css; + gfx::Rect screen_space_rect = rect_in_css; if (!ready_) { if (delegate_) @@ -545,10 +574,10 @@ void BrowserPlugin::UpdateGeometry(const WebRect& plugin_rect_in_viewport, ready_ = true; } - pending_resize_params_.frame_rect = frame_rect; + pending_resize_params_.screen_space_rect = screen_space_rect; if (guest_crashed_) { // Update the sad page to match the current ScreenInfo. - compositing_helper_->ChildFrameGone(frame_rect.size(), + compositing_helper_->ChildFrameGone(screen_space_rect.size(), screen_info().device_scale_factor); return; } @@ -783,7 +812,7 @@ void BrowserPlugin::OnMusEmbeddedFrameSurfaceChanged( return; compositing_helper_->SetFallbackSurfaceId(surface_info.id(), - frame_rect().size()); + screen_space_rect().size()); } void BrowserPlugin::OnMusEmbeddedFrameSinkIdAllocated( |