Commit 940e498e authored by fsamuel's avatar fsamuel Committed by Commit bot

BrowserPlugin: Remove BrowserPluginGuest::ToGuestRect

BrowserPluginGuest::GetScreenCoordinates and BrowserPluginGuest::ToGuestRect
served very similar purposes, and having both around would probably just
increase the likelihood of bugs cropping up. This CL removes ToGuestRect.

BUG=none

Review URL: https://codereview.chromium.org/554773002

Cr-Commit-Position: refs/heads/master@{#293867}
parent b077ed86
...@@ -289,18 +289,6 @@ BrowserPluginGuest::GetBrowserPluginGuestManager() const { ...@@ -289,18 +289,6 @@ BrowserPluginGuest::GetBrowserPluginGuestManager() const {
return GetWebContents()->GetBrowserContext()->GetGuestManager(); return GetWebContents()->GetBrowserContext()->GetGuestManager();
} }
// screen.
gfx::Rect BrowserPluginGuest::ToGuestRect(const gfx::Rect& bounds) {
gfx::Rect guest_rect(bounds);
guest_rect.Offset(guest_window_rect_.OffsetFromOrigin());
if (embedder_web_contents()->GetBrowserPluginGuest()) {
BrowserPluginGuest* embedder_guest =
embedder_web_contents()->GetBrowserPluginGuest();
guest_rect.Offset(embedder_guest->guest_window_rect_.OffsetFromOrigin());
}
return guest_rect;
}
void BrowserPluginGuest::EmbedderVisibilityChanged(bool visible) { void BrowserPluginGuest::EmbedderVisibilityChanged(bool visible) {
embedder_visible_ = visible; embedder_visible_ = visible;
UpdateVisibility(); UpdateVisibility();
...@@ -647,17 +635,6 @@ void BrowserPluginGuest::OnHandleInputEvent( ...@@ -647,17 +635,6 @@ void BrowserPluginGuest::OnHandleInputEvent(
int browser_plugin_instance_id, int browser_plugin_instance_id,
const gfx::Rect& guest_window_rect, const gfx::Rect& guest_window_rect,
const blink::WebInputEvent* event) { const blink::WebInputEvent* event) {
guest_window_rect_ = guest_window_rect;
// If the embedder's RWHV is destroyed then that means that the embedder's
// window has been closed but the embedder's WebContents has not yet been
// destroyed. Computing screen coordinates of a BrowserPlugin only makes sense
// if there is a visible embedder.
if (embedder_web_contents_->GetRenderWidgetHostView()) {
guest_screen_rect_ = guest_window_rect;
guest_screen_rect_.Offset(
embedder_web_contents_->GetRenderWidgetHostView()->
GetViewBounds().OffsetFromOrigin());
}
RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>(
GetWebContents()->GetRenderViewHost()); GetWebContents()->GetRenderViewHost());
......
...@@ -183,7 +183,6 @@ class CONTENT_EXPORT BrowserPluginGuest : public WebContentsObserver { ...@@ -183,7 +183,6 @@ class CONTENT_EXPORT BrowserPluginGuest : public WebContentsObserver {
// Returns whether BrowserPluginGuest is interested in receiving the given // Returns whether BrowserPluginGuest is interested in receiving the given
// |message|. // |message|.
static bool ShouldForwardToBrowserPluginGuest(const IPC::Message& message); static bool ShouldForwardToBrowserPluginGuest(const IPC::Message& message);
gfx::Rect ToGuestRect(const gfx::Rect& rect);
void DragSourceEndedAt(int client_x, int client_y, int screen_x, void DragSourceEndedAt(int client_x, int client_y, int screen_x,
int screen_y, blink::WebDragOperation operation); int screen_y, blink::WebDragOperation operation);
...@@ -337,7 +336,6 @@ class CONTENT_EXPORT BrowserPluginGuest : public WebContentsObserver { ...@@ -337,7 +336,6 @@ class CONTENT_EXPORT BrowserPluginGuest : public WebContentsObserver {
int browser_plugin_instance_id_; int browser_plugin_instance_id_;
float guest_device_scale_factor_; float guest_device_scale_factor_;
gfx::Rect guest_window_rect_; gfx::Rect guest_window_rect_;
gfx::Rect guest_screen_rect_;
bool focused_; bool focused_;
bool mouse_locked_; bool mouse_locked_;
bool pending_lock_request_; bool pending_lock_request_;
......
...@@ -128,10 +128,8 @@ gfx::Rect RenderWidgetHostViewGuest::GetViewBounds() const { ...@@ -128,10 +128,8 @@ gfx::Rect RenderWidgetHostViewGuest::GetViewBounds() const {
gfx::Rect embedder_bounds; gfx::Rect embedder_bounds;
if (rwhv) if (rwhv)
embedder_bounds = rwhv->GetViewBounds(); embedder_bounds = rwhv->GetViewBounds();
gfx::Rect shifted_rect = guest_->ToGuestRect(embedder_bounds); return gfx::Rect(
shifted_rect.set_width(size_.width()); guest_->GetScreenCoordinates(embedder_bounds.origin()), size_);
shifted_rect.set_height(size_.height());
return shifted_rect;
} }
void RenderWidgetHostViewGuest::RenderProcessGone( void RenderWidgetHostViewGuest::RenderProcessGone(
...@@ -297,8 +295,9 @@ void RenderWidgetHostViewGuest::ImeCompositionRangeChanged( ...@@ -297,8 +295,9 @@ void RenderWidgetHostViewGuest::ImeCompositionRangeChanged(
return; return;
std::vector<gfx::Rect> guest_character_bounds; std::vector<gfx::Rect> guest_character_bounds;
for (size_t i = 0; i < character_bounds.size(); ++i) { for (size_t i = 0; i < character_bounds.size(); ++i) {
gfx::Rect guest_rect = guest_->ToGuestRect(character_bounds[i]); guest_character_bounds.push_back(gfx::Rect(
guest_character_bounds.push_back(guest_rect); guest_->GetScreenCoordinates(character_bounds[i].origin()),
character_bounds[i].size()));
} }
// Forward the information to embedding RWHV. // Forward the information to embedding RWHV.
rwhv->ImeCompositionRangeChanged(range, guest_character_bounds); rwhv->ImeCompositionRangeChanged(range, guest_character_bounds);
...@@ -320,8 +319,10 @@ void RenderWidgetHostViewGuest::SelectionBoundsChanged( ...@@ -320,8 +319,10 @@ void RenderWidgetHostViewGuest::SelectionBoundsChanged(
if (!rwhv) if (!rwhv)
return; return;
ViewHostMsg_SelectionBounds_Params guest_params(params); ViewHostMsg_SelectionBounds_Params guest_params(params);
guest_params.anchor_rect = guest_->ToGuestRect(params.anchor_rect); guest_params.anchor_rect.set_origin(
guest_params.focus_rect = guest_->ToGuestRect(params.focus_rect); guest_->GetScreenCoordinates(params.anchor_rect.origin()));
guest_params.focus_rect.set_origin(
guest_->GetScreenCoordinates(params.focus_rect.origin()));
rwhv->SelectionBoundsChanged(guest_params); rwhv->SelectionBoundsChanged(guest_params);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment