Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/bind_helpers.h" | 5 #include "base/bind_helpers.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 9 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
| 10 #include "content/browser/frame_host/render_widget_host_view_guest.h" | 10 #include "content/browser/frame_host/render_widget_host_view_guest.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 #endif | 121 #endif |
| 122 | 122 |
| 123 gfx::Rect RenderWidgetHostViewGuest::GetViewBounds() const { | 123 gfx::Rect RenderWidgetHostViewGuest::GetViewBounds() const { |
| 124 if (!guest_) | 124 if (!guest_) |
| 125 return gfx::Rect(); | 125 return gfx::Rect(); |
| 126 | 126 |
| 127 RenderWidgetHostViewBase* rwhv = GetGuestRenderWidgetHostView(); | 127 RenderWidgetHostViewBase* rwhv = GetGuestRenderWidgetHostView(); |
| 128 gfx::Rect embedder_bounds; | 128 gfx::Rect embedder_bounds; |
| 129 if (rwhv) | 129 if (rwhv) |
| 130 embedder_bounds = rwhv->GetViewBounds(); | 130 embedder_bounds = rwhv->GetViewBounds(); |
| 131 gfx::Rect shifted_rect = guest_->ToGuestRect(embedder_bounds); | 131 gfx::Rect shifted_rect; |
|
lazyboy
2014/09/08 19:00:57
Would be easier to read by constructing the Rect d
Fady Samuel
2014/09/08 19:17:05
Done.
| |
| 132 shifted_rect.set_width(size_.width()); | 132 shifted_rect.set_origin( |
| 133 shifted_rect.set_height(size_.height()); | 133 guest_->GetScreenCoordinates(embedder_bounds.origin())); |
| 134 shifted_rect.set_size(size_); | |
| 134 return shifted_rect; | 135 return shifted_rect; |
| 135 } | 136 } |
| 136 | 137 |
| 137 void RenderWidgetHostViewGuest::RenderProcessGone( | 138 void RenderWidgetHostViewGuest::RenderProcessGone( |
| 138 base::TerminationStatus status, | 139 base::TerminationStatus status, |
| 139 int error_code) { | 140 int error_code) { |
| 140 platform_view_->RenderProcessGone(status, error_code); | 141 platform_view_->RenderProcessGone(status, error_code); |
| 141 // Destroy the guest view instance only, so we don't end up calling | 142 // Destroy the guest view instance only, so we don't end up calling |
| 142 // platform_view_->Destroy(). | 143 // platform_view_->Destroy(). |
| 143 DestroyGuestView(); | 144 DestroyGuestView(); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 290 const gfx::Range& range, | 291 const gfx::Range& range, |
| 291 const std::vector<gfx::Rect>& character_bounds) { | 292 const std::vector<gfx::Rect>& character_bounds) { |
| 292 if (!guest_) | 293 if (!guest_) |
| 293 return; | 294 return; |
| 294 | 295 |
| 295 RenderWidgetHostViewBase* rwhv = GetGuestRenderWidgetHostView(); | 296 RenderWidgetHostViewBase* rwhv = GetGuestRenderWidgetHostView(); |
| 296 if (!rwhv) | 297 if (!rwhv) |
| 297 return; | 298 return; |
| 298 std::vector<gfx::Rect> guest_character_bounds; | 299 std::vector<gfx::Rect> guest_character_bounds; |
| 299 for (size_t i = 0; i < character_bounds.size(); ++i) { | 300 for (size_t i = 0; i < character_bounds.size(); ++i) { |
| 300 gfx::Rect guest_rect = guest_->ToGuestRect(character_bounds[i]); | 301 gfx::Rect guest_rect; |
| 302 guest_rect.set_origin(guest_->GetScreenCoordinates( | |
| 303 character_bounds[i].origin())); | |
| 304 guest_rect.set_size(character_bounds[i].size()); | |
| 301 guest_character_bounds.push_back(guest_rect); | 305 guest_character_bounds.push_back(guest_rect); |
| 302 } | 306 } |
| 303 // Forward the information to embedding RWHV. | 307 // Forward the information to embedding RWHV. |
| 304 rwhv->ImeCompositionRangeChanged(range, guest_character_bounds); | 308 rwhv->ImeCompositionRangeChanged(range, guest_character_bounds); |
| 305 } | 309 } |
| 306 #endif | 310 #endif |
| 307 | 311 |
| 308 void RenderWidgetHostViewGuest::SelectionChanged(const base::string16& text, | 312 void RenderWidgetHostViewGuest::SelectionChanged(const base::string16& text, |
| 309 size_t offset, | 313 size_t offset, |
| 310 const gfx::Range& range) { | 314 const gfx::Range& range) { |
| 311 platform_view_->SelectionChanged(text, offset, range); | 315 platform_view_->SelectionChanged(text, offset, range); |
| 312 } | 316 } |
| 313 | 317 |
| 314 void RenderWidgetHostViewGuest::SelectionBoundsChanged( | 318 void RenderWidgetHostViewGuest::SelectionBoundsChanged( |
| 315 const ViewHostMsg_SelectionBounds_Params& params) { | 319 const ViewHostMsg_SelectionBounds_Params& params) { |
| 316 if (!guest_) | 320 if (!guest_) |
| 317 return; | 321 return; |
| 318 | 322 |
| 319 RenderWidgetHostViewBase* rwhv = GetGuestRenderWidgetHostView(); | 323 RenderWidgetHostViewBase* rwhv = GetGuestRenderWidgetHostView(); |
| 320 if (!rwhv) | 324 if (!rwhv) |
| 321 return; | 325 return; |
| 322 ViewHostMsg_SelectionBounds_Params guest_params(params); | 326 ViewHostMsg_SelectionBounds_Params guest_params(params); |
| 323 guest_params.anchor_rect = guest_->ToGuestRect(params.anchor_rect); | 327 guest_params.anchor_rect.set_origin( |
| 324 guest_params.focus_rect = guest_->ToGuestRect(params.focus_rect); | 328 guest_->GetScreenCoordinates(params.anchor_rect.origin())); |
| 329 guest_params.focus_rect.set_origin( | |
| 330 guest_->GetScreenCoordinates(params.focus_rect.origin())); | |
| 325 rwhv->SelectionBoundsChanged(guest_params); | 331 rwhv->SelectionBoundsChanged(guest_params); |
| 326 } | 332 } |
| 327 | 333 |
| 328 void RenderWidgetHostViewGuest::CopyFromCompositingSurface( | 334 void RenderWidgetHostViewGuest::CopyFromCompositingSurface( |
| 329 const gfx::Rect& src_subrect, | 335 const gfx::Rect& src_subrect, |
| 330 const gfx::Size& dst_size, | 336 const gfx::Size& dst_size, |
| 331 const base::Callback<void(bool, const SkBitmap&)>& callback, | 337 const base::Callback<void(bool, const SkBitmap&)>& callback, |
| 332 const SkColorType color_type) { | 338 const SkColorType color_type) { |
| 333 CHECK(guest_); | 339 CHECK(guest_); |
| 334 guest_->CopyFromCompositingSurface(src_subrect, dst_size, callback); | 340 guest_->CopyFromCompositingSurface(src_subrect, dst_size, callback); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 523 return kN32_SkColorType; | 529 return kN32_SkColorType; |
| 524 } | 530 } |
| 525 | 531 |
| 526 RenderWidgetHostViewBase* | 532 RenderWidgetHostViewBase* |
| 527 RenderWidgetHostViewGuest::GetGuestRenderWidgetHostView() const { | 533 RenderWidgetHostViewGuest::GetGuestRenderWidgetHostView() const { |
| 528 return static_cast<RenderWidgetHostViewBase*>( | 534 return static_cast<RenderWidgetHostViewBase*>( |
| 529 guest_->GetEmbedderRenderWidgetHostView()); | 535 guest_->GetEmbedderRenderWidgetHostView()); |
| 530 } | 536 } |
| 531 | 537 |
| 532 } // namespace content | 538 } // namespace content |
| OLD | NEW |