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/renderer_host/render_widget_host_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 OnImeCancelComposition) | 478 OnImeCancelComposition) |
479 IPC_MESSAGE_HANDLER(ViewHostMsg_DidActivateAcceleratedCompositing, | 479 IPC_MESSAGE_HANDLER(ViewHostMsg_DidActivateAcceleratedCompositing, |
480 OnDidActivateAcceleratedCompositing) | 480 OnDidActivateAcceleratedCompositing) |
481 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse) | 481 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse) |
482 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) | 482 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) |
483 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowDisambiguationPopup, | 483 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowDisambiguationPopup, |
484 OnShowDisambiguationPopup) | 484 OnShowDisambiguationPopup) |
485 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnSelectionChanged) | 485 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnSelectionChanged) |
486 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionBoundsChanged, | 486 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionBoundsChanged, |
487 OnSelectionBoundsChanged) | 487 OnSelectionBoundsChanged) |
488 IPC_MESSAGE_HANDLER(ViewHostMsg_Snapshot, OnSnapshot) | |
489 #if defined(OS_WIN) | 488 #if defined(OS_WIN) |
490 IPC_MESSAGE_HANDLER(ViewHostMsg_WindowlessPluginDummyWindowCreated, | 489 IPC_MESSAGE_HANDLER(ViewHostMsg_WindowlessPluginDummyWindowCreated, |
491 OnWindowlessPluginDummyWindowCreated) | 490 OnWindowlessPluginDummyWindowCreated) |
492 IPC_MESSAGE_HANDLER(ViewHostMsg_WindowlessPluginDummyWindowDestroyed, | 491 IPC_MESSAGE_HANDLER(ViewHostMsg_WindowlessPluginDummyWindowDestroyed, |
493 OnWindowlessPluginDummyWindowDestroyed) | 492 OnWindowlessPluginDummyWindowDestroyed) |
494 #endif | 493 #endif |
495 #if defined(OS_MACOSX) | 494 #if defined(OS_MACOSX) |
496 IPC_MESSAGE_HANDLER(ViewHostMsg_CompositorSurfaceBuffersSwapped, | 495 IPC_MESSAGE_HANDLER(ViewHostMsg_CompositorSurfaceBuffersSwapped, |
497 OnCompositorSurfaceBuffersSwapped) | 496 OnCompositorSurfaceBuffersSwapped) |
498 #endif | 497 #endif |
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1181 // factor). | 1180 // factor). |
1182 InvalidateScreenInfo(); | 1181 InvalidateScreenInfo(); |
1183 WasResized(); | 1182 WasResized(); |
1184 } | 1183 } |
1185 | 1184 |
1186 void RenderWidgetHostImpl::InvalidateScreenInfo() { | 1185 void RenderWidgetHostImpl::InvalidateScreenInfo() { |
1187 screen_info_out_of_date_ = true; | 1186 screen_info_out_of_date_ = true; |
1188 screen_info_.reset(); | 1187 screen_info_.reset(); |
1189 } | 1188 } |
1190 | 1189 |
1191 void RenderWidgetHostImpl::GetSnapshotFromRenderer( | |
1192 const gfx::Rect& src_subrect, | |
1193 const base::Callback<void(bool, const SkBitmap&)>& callback) { | |
1194 TRACE_EVENT0("browser", "RenderWidgetHostImpl::GetSnapshotFromRenderer"); | |
1195 if (!view_) { | |
1196 callback.Run(false, SkBitmap()); | |
1197 return; | |
1198 } | |
1199 | |
1200 pending_snapshots_.push(callback); | |
1201 | |
1202 gfx::Rect copy_rect = src_subrect.IsEmpty() ? | |
1203 gfx::Rect(view_->GetViewBounds().size()) : src_subrect; | |
1204 | |
1205 gfx::Rect copy_rect_in_pixel = ConvertViewRectToPixel(view_, copy_rect); | |
1206 Send(new ViewMsg_Snapshot(GetRoutingID(), copy_rect_in_pixel)); | |
1207 } | |
1208 | |
1209 void RenderWidgetHostImpl::OnSelectionChanged(const base::string16& text, | 1190 void RenderWidgetHostImpl::OnSelectionChanged(const base::string16& text, |
1210 size_t offset, | 1191 size_t offset, |
1211 const gfx::Range& range) { | 1192 const gfx::Range& range) { |
1212 if (view_) | 1193 if (view_) |
1213 view_->SelectionChanged(text, offset, range); | 1194 view_->SelectionChanged(text, offset, range); |
1214 } | 1195 } |
1215 | 1196 |
1216 void RenderWidgetHostImpl::OnSelectionBoundsChanged( | 1197 void RenderWidgetHostImpl::OnSelectionBoundsChanged( |
1217 const ViewHostMsg_SelectionBounds_Params& params) { | 1198 const ViewHostMsg_SelectionBounds_Params& params) { |
1218 if (view_) { | 1199 if (view_) { |
1219 view_->SelectionBoundsChanged(params); | 1200 view_->SelectionBoundsChanged(params); |
1220 } | 1201 } |
1221 } | 1202 } |
1222 | 1203 |
1223 void RenderWidgetHostImpl::OnSnapshot(bool success, | |
1224 const SkBitmap& bitmap) { | |
1225 if (pending_snapshots_.size() == 0) { | |
1226 LOG(ERROR) << "RenderWidgetHostImpl::OnSnapshot: " | |
1227 "Received a snapshot that was not requested."; | |
1228 return; | |
1229 } | |
1230 | |
1231 base::Callback<void(bool, const SkBitmap&)> callback = | |
1232 pending_snapshots_.front(); | |
1233 pending_snapshots_.pop(); | |
1234 | |
1235 if (!success) { | |
1236 callback.Run(success, SkBitmap()); | |
1237 return; | |
1238 } | |
1239 | |
1240 callback.Run(success, bitmap); | |
1241 } | |
1242 | |
1243 void RenderWidgetHostImpl::UpdateVSyncParameters(base::TimeTicks timebase, | 1204 void RenderWidgetHostImpl::UpdateVSyncParameters(base::TimeTicks timebase, |
1244 base::TimeDelta interval) { | 1205 base::TimeDelta interval) { |
1245 Send(new ViewMsg_UpdateVSyncParameters(GetRoutingID(), timebase, interval)); | 1206 Send(new ViewMsg_UpdateVSyncParameters(GetRoutingID(), timebase, interval)); |
1246 } | 1207 } |
1247 | 1208 |
1248 void RenderWidgetHostImpl::RendererExited(base::TerminationStatus status, | 1209 void RenderWidgetHostImpl::RendererExited(base::TerminationStatus status, |
1249 int exit_code) { | 1210 int exit_code) { |
1250 // Clearing this flag causes us to re-create the renderer when recovering | 1211 // Clearing this flag causes us to re-create the renderer when recovering |
1251 // from a crashed renderer. | 1212 // from a crashed renderer. |
1252 renderer_initialized_ = false; | 1213 renderer_initialized_ = false; |
(...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2393 } | 2354 } |
2394 } | 2355 } |
2395 | 2356 |
2396 SkBitmap::Config RenderWidgetHostImpl::PreferredReadbackFormat() { | 2357 SkBitmap::Config RenderWidgetHostImpl::PreferredReadbackFormat() { |
2397 if (view_) | 2358 if (view_) |
2398 return view_->PreferredReadbackFormat(); | 2359 return view_->PreferredReadbackFormat(); |
2399 return SkBitmap::kARGB_8888_Config; | 2360 return SkBitmap::kARGB_8888_Config; |
2400 } | 2361 } |
2401 | 2362 |
2402 } // namespace content | 2363 } // namespace content |
OLD | NEW |