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/renderer/render_widget.h" | 5 #include "content/renderer/render_widget.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/debug/trace_event_synthetic_delay.h" | 10 #include "base/debug/trace_event_synthetic_delay.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 #include "content/renderer/renderer_webkitplatformsupport_impl.h" | 47 #include "content/renderer/renderer_webkitplatformsupport_impl.h" |
48 #include "content/renderer/resizing_mode_selector.h" | 48 #include "content/renderer/resizing_mode_selector.h" |
49 #include "ipc/ipc_sync_message.h" | 49 #include "ipc/ipc_sync_message.h" |
50 #include "skia/ext/platform_canvas.h" | 50 #include "skia/ext/platform_canvas.h" |
51 #include "third_party/WebKit/public/platform/WebCursorInfo.h" | 51 #include "third_party/WebKit/public/platform/WebCursorInfo.h" |
52 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 52 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
53 #include "third_party/WebKit/public/platform/WebRect.h" | 53 #include "third_party/WebKit/public/platform/WebRect.h" |
54 #include "third_party/WebKit/public/platform/WebScreenInfo.h" | 54 #include "third_party/WebKit/public/platform/WebScreenInfo.h" |
55 #include "third_party/WebKit/public/platform/WebSize.h" | 55 #include "third_party/WebKit/public/platform/WebSize.h" |
56 #include "third_party/WebKit/public/platform/WebString.h" | 56 #include "third_party/WebKit/public/platform/WebString.h" |
| 57 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" |
57 #include "third_party/WebKit/public/web/WebPagePopup.h" | 58 #include "third_party/WebKit/public/web/WebPagePopup.h" |
58 #include "third_party/WebKit/public/web/WebPopupMenu.h" | 59 #include "third_party/WebKit/public/web/WebPopupMenu.h" |
59 #include "third_party/WebKit/public/web/WebPopupMenuInfo.h" | 60 #include "third_party/WebKit/public/web/WebPopupMenuInfo.h" |
60 #include "third_party/WebKit/public/web/WebRange.h" | 61 #include "third_party/WebKit/public/web/WebRange.h" |
61 #include "third_party/skia/include/core/SkShader.h" | 62 #include "third_party/skia/include/core/SkShader.h" |
62 #include "ui/base/ui_base_switches.h" | 63 #include "ui/base/ui_base_switches.h" |
63 #include "ui/gfx/frame_time.h" | 64 #include "ui/gfx/frame_time.h" |
64 #include "ui/gfx/point_conversions.h" | 65 #include "ui/gfx/point_conversions.h" |
65 #include "ui/gfx/rect_conversions.h" | 66 #include "ui/gfx/rect_conversions.h" |
66 #include "ui/gfx/size_conversions.h" | 67 #include "ui/gfx/size_conversions.h" |
(...skipping 10 matching lines...) Expand all Loading... |
77 #if defined(OS_POSIX) | 78 #if defined(OS_POSIX) |
78 #include "ipc/ipc_channel_posix.h" | 79 #include "ipc/ipc_channel_posix.h" |
79 #include "third_party/skia/include/core/SkMallocPixelRef.h" | 80 #include "third_party/skia/include/core/SkMallocPixelRef.h" |
80 #include "third_party/skia/include/core/SkPixelRef.h" | 81 #include "third_party/skia/include/core/SkPixelRef.h" |
81 #endif // defined(OS_POSIX) | 82 #endif // defined(OS_POSIX) |
82 | 83 |
83 #include "third_party/WebKit/public/web/WebWidget.h" | 84 #include "third_party/WebKit/public/web/WebWidget.h" |
84 | 85 |
85 using blink::WebCompositionUnderline; | 86 using blink::WebCompositionUnderline; |
86 using blink::WebCursorInfo; | 87 using blink::WebCursorInfo; |
| 88 using blink::WebDeviceEmulationParams; |
87 using blink::WebGestureEvent; | 89 using blink::WebGestureEvent; |
88 using blink::WebInputEvent; | 90 using blink::WebInputEvent; |
89 using blink::WebKeyboardEvent; | 91 using blink::WebKeyboardEvent; |
90 using blink::WebMouseEvent; | 92 using blink::WebMouseEvent; |
91 using blink::WebMouseWheelEvent; | 93 using blink::WebMouseWheelEvent; |
92 using blink::WebNavigationPolicy; | 94 using blink::WebNavigationPolicy; |
93 using blink::WebPagePopup; | 95 using blink::WebPagePopup; |
94 using blink::WebPopupMenu; | 96 using blink::WebPopupMenu; |
95 using blink::WebPopupMenuInfo; | 97 using blink::WebPopupMenuInfo; |
96 using blink::WebPopupType; | 98 using blink::WebPopupType; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 } // namespace | 156 } // namespace |
155 | 157 |
156 namespace content { | 158 namespace content { |
157 | 159 |
158 // RenderWidget::ScreenMetricsEmulator ---------------------------------------- | 160 // RenderWidget::ScreenMetricsEmulator ---------------------------------------- |
159 | 161 |
160 class RenderWidget::ScreenMetricsEmulator { | 162 class RenderWidget::ScreenMetricsEmulator { |
161 public: | 163 public: |
162 ScreenMetricsEmulator( | 164 ScreenMetricsEmulator( |
163 RenderWidget* widget, | 165 RenderWidget* widget, |
164 const gfx::Rect& device_rect, | 166 const WebDeviceEmulationParams& params); |
165 const gfx::Rect& widget_rect, | |
166 float device_scale_factor, | |
167 bool fit_to_view); | |
168 virtual ~ScreenMetricsEmulator(); | 167 virtual ~ScreenMetricsEmulator(); |
169 | 168 |
| 169 // Scale and offset used to convert between host coordinates |
| 170 // and webwidget coordinates. |
170 float scale() { return scale_; } | 171 float scale() { return scale_; } |
171 gfx::Point offset() { return offset_; } | 172 gfx::Point offset() { return offset_; } |
172 gfx::Rect widget_rect() const { return widget_rect_; } | 173 gfx::Rect applied_widget_rect() const { return applied_widget_rect_; } |
173 gfx::Rect original_screen_rect() const { return original_view_screen_rect_; } | 174 gfx::Rect original_screen_rect() const { return original_view_screen_rect_; } |
174 const WebScreenInfo& original_screen_info() { return original_screen_info_; } | 175 const WebScreenInfo& original_screen_info() { return original_screen_info_; } |
175 | 176 |
176 void ChangeEmulationParams( | 177 void ChangeEmulationParams( |
177 const gfx::Rect& device_rect, | 178 const WebDeviceEmulationParams& params); |
178 const gfx::Rect& widget_rect, | |
179 float device_scale_factor, | |
180 bool fit_to_view); | |
181 | 179 |
182 // The following methods alter handlers' behavior for messages related to | 180 // The following methods alter handlers' behavior for messages related to |
183 // widget size and position. | 181 // widget size and position. |
184 void OnResizeMessage(const ViewMsg_Resize_Params& params); | 182 void OnResizeMessage(const ViewMsg_Resize_Params& params); |
185 void OnUpdateScreenRectsMessage(const gfx::Rect& view_screen_rect, | 183 void OnUpdateScreenRectsMessage(const gfx::Rect& view_screen_rect, |
186 const gfx::Rect& window_screen_rect); | 184 const gfx::Rect& window_screen_rect); |
187 void OnShowContextMenu(ContextMenuParams* params); | 185 void OnShowContextMenu(ContextMenuParams* params); |
188 | 186 |
189 private: | 187 private: |
190 void CalculateScaleAndOffset(); | 188 void Reapply(); |
191 void Apply(float overdraw_bottom_height, | 189 void Apply(float overdraw_bottom_height, |
192 gfx::Rect resizer_rect, bool is_fullscreen); | 190 gfx::Rect resizer_rect, bool is_fullscreen); |
193 | 191 |
194 RenderWidget* widget_; | 192 RenderWidget* widget_; |
195 | 193 |
196 // Parameters as passed by RenderWidget::EnableScreenMetricsEmulation. | 194 // Parameters as passed by RenderWidget::EnableScreenMetricsEmulation. |
197 gfx::Rect device_rect_; | 195 WebDeviceEmulationParams params_; |
198 gfx::Rect widget_rect_; | |
199 float device_scale_factor_; | |
200 bool fit_to_view_; | |
201 | 196 |
202 // The computed scale and offset used to fit widget into browser window. | 197 // The computed scale and offset used to fit widget into browser window. |
203 float scale_; | 198 float scale_; |
204 gfx::Point offset_; | 199 gfx::Point offset_; |
205 | 200 |
| 201 // Widget rect as passed to webwidget. |
| 202 gfx::Rect applied_widget_rect_; |
| 203 |
206 // Original values to restore back after emulation ends. | 204 // Original values to restore back after emulation ends. |
207 gfx::Size original_size_; | 205 gfx::Size original_size_; |
208 gfx::Size original_physical_backing_size_; | 206 gfx::Size original_physical_backing_size_; |
209 blink::WebScreenInfo original_screen_info_; | 207 blink::WebScreenInfo original_screen_info_; |
210 gfx::Rect original_view_screen_rect_; | 208 gfx::Rect original_view_screen_rect_; |
211 gfx::Rect original_window_screen_rect_; | 209 gfx::Rect original_window_screen_rect_; |
212 }; | 210 }; |
213 | 211 |
214 RenderWidget::ScreenMetricsEmulator::ScreenMetricsEmulator( | 212 RenderWidget::ScreenMetricsEmulator::ScreenMetricsEmulator( |
215 RenderWidget* widget, | 213 RenderWidget* widget, |
216 const gfx::Rect& device_rect, | 214 const WebDeviceEmulationParams& params) |
217 const gfx::Rect& widget_rect, | |
218 float device_scale_factor, | |
219 bool fit_to_view) | |
220 : widget_(widget), | 215 : widget_(widget), |
221 device_rect_(device_rect), | 216 params_(params), |
222 widget_rect_(widget_rect), | |
223 device_scale_factor_(device_scale_factor), | |
224 fit_to_view_(fit_to_view), | |
225 scale_(1.f) { | 217 scale_(1.f) { |
226 original_size_ = widget_->size_; | 218 original_size_ = widget_->size_; |
227 original_physical_backing_size_ = widget_->physical_backing_size_; | 219 original_physical_backing_size_ = widget_->physical_backing_size_; |
228 original_screen_info_ = widget_->screen_info_; | 220 original_screen_info_ = widget_->screen_info_; |
229 original_view_screen_rect_ = widget_->view_screen_rect_; | 221 original_view_screen_rect_ = widget_->view_screen_rect_; |
230 original_window_screen_rect_ = widget_->window_screen_rect_; | 222 original_window_screen_rect_ = widget_->window_screen_rect_; |
231 Apply(widget_->overdraw_bottom_height_, | 223 Apply(widget_->overdraw_bottom_height_, |
232 widget_->resizer_rect_, widget_->is_fullscreen_); | 224 widget_->resizer_rect_, widget_->is_fullscreen_); |
233 } | 225 } |
234 | 226 |
235 RenderWidget::ScreenMetricsEmulator::~ScreenMetricsEmulator() { | 227 RenderWidget::ScreenMetricsEmulator::~ScreenMetricsEmulator() { |
236 widget_->screen_info_ = original_screen_info_; | 228 widget_->screen_info_ = original_screen_info_; |
237 | 229 |
238 widget_->SetDeviceScaleFactor(original_screen_info_.deviceScaleFactor); | 230 widget_->SetDeviceScaleFactor(original_screen_info_.deviceScaleFactor); |
239 widget_->SetScreenMetricsEmulationParameters(0.f, gfx::Point(), 1.f); | 231 widget_->SetScreenMetricsEmulationParameters(0.f, gfx::Point(), 1.f); |
240 widget_->view_screen_rect_ = original_view_screen_rect_; | 232 widget_->view_screen_rect_ = original_view_screen_rect_; |
241 widget_->window_screen_rect_ = original_window_screen_rect_; | 233 widget_->window_screen_rect_ = original_window_screen_rect_; |
242 widget_->Resize(original_size_, original_physical_backing_size_, | 234 widget_->Resize(original_size_, original_physical_backing_size_, |
243 widget_->overdraw_bottom_height_, widget_->resizer_rect_, | 235 widget_->overdraw_bottom_height_, widget_->resizer_rect_, |
244 widget_->is_fullscreen_, NO_RESIZE_ACK); | 236 widget_->is_fullscreen_, NO_RESIZE_ACK); |
245 } | 237 } |
246 | 238 |
247 void RenderWidget::ScreenMetricsEmulator::ChangeEmulationParams( | 239 void RenderWidget::ScreenMetricsEmulator::ChangeEmulationParams( |
248 const gfx::Rect& device_rect, | 240 const WebDeviceEmulationParams& params) { |
249 const gfx::Rect& widget_rect, | 241 params_ = params; |
250 float device_scale_factor, | 242 Reapply(); |
251 bool fit_to_view) { | 243 } |
252 device_rect_ = device_rect; | 244 |
253 widget_rect_ = widget_rect; | 245 void RenderWidget::ScreenMetricsEmulator::Reapply() { |
254 device_scale_factor_ = device_scale_factor; | |
255 fit_to_view_ = fit_to_view; | |
256 Apply(widget_->overdraw_bottom_height_, | 246 Apply(widget_->overdraw_bottom_height_, |
257 widget_->resizer_rect_, widget_->is_fullscreen_); | 247 widget_->resizer_rect_, widget_->is_fullscreen_); |
258 } | 248 } |
259 | 249 |
260 void RenderWidget::ScreenMetricsEmulator::CalculateScaleAndOffset() { | 250 void RenderWidget::ScreenMetricsEmulator::Apply( |
261 if (fit_to_view_) { | 251 float overdraw_bottom_height, gfx::Rect resizer_rect, bool is_fullscreen) { |
| 252 applied_widget_rect_.set_size(params_.viewSize.isEmpty() ? |
| 253 original_size_ : gfx::Size(params_.viewSize)); |
| 254 |
| 255 if (params_.fitToView) { |
262 DCHECK(!original_size_.IsEmpty()); | 256 DCHECK(!original_size_.IsEmpty()); |
263 | 257 |
264 int width_with_gutter = | 258 int width_with_gutter = |
265 std::max(original_size_.width() - 2 * device_rect_.x(), 1); | 259 std::max(original_size_.width() - 2 * params_.viewInsets.width, 1); |
266 int height_with_gutter = | 260 int height_with_gutter = |
267 std::max(original_size_.height() - 2 * device_rect_.y(), 1); | 261 std::max(original_size_.height() - 2 * params_.viewInsets.height, 1); |
268 float width_ratio = | 262 float width_ratio = |
269 static_cast<float>(widget_rect_.width()) / width_with_gutter; | 263 static_cast<float>(applied_widget_rect_.width()) / width_with_gutter; |
270 float height_ratio = | 264 float height_ratio = |
271 static_cast<float>(widget_rect_.height()) / height_with_gutter; | 265 static_cast<float>(applied_widget_rect_.height()) / height_with_gutter; |
272 float ratio = std::max(1.0f, std::max(width_ratio, height_ratio)); | 266 float ratio = std::max(1.0f, std::max(width_ratio, height_ratio)); |
273 scale_ = 1.f / ratio; | 267 scale_ = 1.f / ratio; |
274 | 268 |
275 // Center emulated view inside available view space. | 269 // Center emulated view inside available view space. |
276 offset_.set_x((original_size_.width() - scale_ * widget_rect_.width()) / 2); | 270 offset_.set_x( |
| 271 (original_size_.width() - scale_ * applied_widget_rect_.width()) / 2); |
277 offset_.set_y( | 272 offset_.set_y( |
278 (original_size_.height() - scale_ * widget_rect_.height()) / 2); | 273 (original_size_.height() - scale_ * applied_widget_rect_.height()) / 2); |
279 } else { | 274 } else { |
280 scale_ = 1.f; | 275 scale_ = 1.f; |
281 offset_.SetPoint(0, 0); | 276 offset_.SetPoint(0, 0); |
282 } | 277 } |
283 } | |
284 | 278 |
285 void RenderWidget::ScreenMetricsEmulator::Apply( | 279 if (params_.screenPosition == WebDeviceEmulationParams::Desktop) { |
286 float overdraw_bottom_height, gfx::Rect resizer_rect, bool is_fullscreen) { | 280 applied_widget_rect_.set_origin(original_view_screen_rect_.origin()); |
287 gfx::Rect applied_widget_rect = widget_rect_; | |
288 if (widget_rect_.size().IsEmpty()) { | |
289 scale_ = 1.f; | |
290 offset_.SetPoint(0, 0); | |
291 applied_widget_rect = | |
292 gfx::Rect(original_view_screen_rect_.origin(), original_size_); | |
293 } else { | |
294 CalculateScaleAndOffset(); | |
295 } | |
296 | |
297 if (device_rect_.size().IsEmpty()) { | |
298 widget_->screen_info_.rect = original_screen_info_.rect; | 281 widget_->screen_info_.rect = original_screen_info_.rect; |
299 widget_->screen_info_.availableRect = original_screen_info_.availableRect; | 282 widget_->screen_info_.availableRect = original_screen_info_.availableRect; |
300 widget_->window_screen_rect_ = original_window_screen_rect_; | 283 widget_->window_screen_rect_ = original_window_screen_rect_; |
301 } else { | 284 } else { |
302 widget_->screen_info_.rect = gfx::Rect(device_rect_.size()); | 285 applied_widget_rect_.set_origin(gfx::Point(0, 0)); |
303 widget_->screen_info_.availableRect = gfx::Rect(device_rect_.size()); | 286 widget_->screen_info_.rect = applied_widget_rect_; |
304 widget_->window_screen_rect_ = widget_->screen_info_.availableRect; | 287 widget_->screen_info_.availableRect = applied_widget_rect_; |
| 288 widget_->window_screen_rect_ = applied_widget_rect_; |
305 } | 289 } |
306 | 290 |
307 float applied_device_scale_factor = device_scale_factor_ ? | 291 float applied_device_scale_factor = params_.deviceScaleFactor ? |
308 device_scale_factor_ : original_screen_info_.deviceScaleFactor; | 292 params_.deviceScaleFactor : original_screen_info_.deviceScaleFactor; |
309 widget_->screen_info_.deviceScaleFactor = applied_device_scale_factor; | 293 widget_->screen_info_.deviceScaleFactor = applied_device_scale_factor; |
310 | 294 |
311 // Pass three emulation parameters to the blink side: | 295 // Pass three emulation parameters to the blink side: |
312 // - we keep the real device scale factor in compositor to produce sharp image | 296 // - we keep the real device scale factor in compositor to produce sharp image |
313 // even when emulating different scale factor; | 297 // even when emulating different scale factor; |
314 // - in order to fit into view, WebView applies offset and scale to the | 298 // - in order to fit into view, WebView applies offset and scale to the |
315 // root layer. | 299 // root layer. |
316 widget_->SetScreenMetricsEmulationParameters( | 300 widget_->SetScreenMetricsEmulationParameters( |
317 original_screen_info_.deviceScaleFactor, offset_, scale_); | 301 original_screen_info_.deviceScaleFactor, offset_, scale_); |
318 | 302 |
319 widget_->SetDeviceScaleFactor(applied_device_scale_factor); | 303 widget_->SetDeviceScaleFactor(applied_device_scale_factor); |
320 widget_->view_screen_rect_ = applied_widget_rect; | 304 widget_->view_screen_rect_ = applied_widget_rect_; |
321 | 305 |
322 gfx::Size physical_backing_size = gfx::ToCeiledSize(gfx::ScaleSize( | 306 gfx::Size physical_backing_size = gfx::ToCeiledSize(gfx::ScaleSize( |
323 original_size_, original_screen_info_.deviceScaleFactor)); | 307 original_size_, original_screen_info_.deviceScaleFactor)); |
324 widget_->Resize(applied_widget_rect.size(), physical_backing_size, | 308 widget_->Resize(applied_widget_rect_.size(), physical_backing_size, |
325 overdraw_bottom_height, resizer_rect, is_fullscreen, NO_RESIZE_ACK); | 309 overdraw_bottom_height, resizer_rect, is_fullscreen, NO_RESIZE_ACK); |
326 } | 310 } |
327 | 311 |
328 void RenderWidget::ScreenMetricsEmulator::OnResizeMessage( | 312 void RenderWidget::ScreenMetricsEmulator::OnResizeMessage( |
329 const ViewMsg_Resize_Params& params) { | 313 const ViewMsg_Resize_Params& params) { |
330 bool need_ack = params.new_size != original_size_ && | 314 bool need_ack = params.new_size != original_size_ && |
331 !params.new_size.IsEmpty() && !params.physical_backing_size.IsEmpty(); | 315 !params.new_size.IsEmpty() && !params.physical_backing_size.IsEmpty(); |
332 original_size_ = params.new_size; | 316 original_size_ = params.new_size; |
333 original_physical_backing_size_ = params.physical_backing_size; | 317 original_physical_backing_size_ = params.physical_backing_size; |
334 original_screen_info_ = params.screen_info; | 318 original_screen_info_ = params.screen_info; |
335 Apply(params.overdraw_bottom_height, params.resizer_rect, | 319 Apply(params.overdraw_bottom_height, params.resizer_rect, |
336 params.is_fullscreen); | 320 params.is_fullscreen); |
337 | 321 |
338 if (need_ack) { | 322 if (need_ack) { |
339 widget_->set_next_paint_is_resize_ack(); | 323 widget_->set_next_paint_is_resize_ack(); |
340 if (widget_->compositor_) | 324 if (widget_->compositor_) |
341 widget_->compositor_->SetNeedsRedrawRect(gfx::Rect(widget_->size_)); | 325 widget_->compositor_->SetNeedsRedrawRect(gfx::Rect(widget_->size_)); |
342 } | 326 } |
343 } | 327 } |
344 | 328 |
345 void RenderWidget::ScreenMetricsEmulator::OnUpdateScreenRectsMessage( | 329 void RenderWidget::ScreenMetricsEmulator::OnUpdateScreenRectsMessage( |
346 const gfx::Rect& view_screen_rect, | 330 const gfx::Rect& view_screen_rect, |
347 const gfx::Rect& window_screen_rect) { | 331 const gfx::Rect& window_screen_rect) { |
348 original_view_screen_rect_ = view_screen_rect; | 332 original_view_screen_rect_ = view_screen_rect; |
349 original_window_screen_rect_ = window_screen_rect; | 333 original_window_screen_rect_ = window_screen_rect; |
350 if (device_rect_.size().IsEmpty()) | 334 if (params_.screenPosition == WebDeviceEmulationParams::Desktop) |
351 widget_->window_screen_rect_ = window_screen_rect; | 335 Reapply(); |
352 if (widget_rect_.size().IsEmpty()) | |
353 widget_->view_screen_rect_ = view_screen_rect; | |
354 } | 336 } |
355 | 337 |
356 void RenderWidget::ScreenMetricsEmulator::OnShowContextMenu( | 338 void RenderWidget::ScreenMetricsEmulator::OnShowContextMenu( |
357 ContextMenuParams* params) { | 339 ContextMenuParams* params) { |
358 params->x *= scale_; | 340 params->x *= scale_; |
359 params->x += offset_.x(); | 341 params->x += offset_.x(); |
360 params->y *= scale_; | 342 params->y *= scale_; |
361 params->y += offset_.y(); | 343 params->y += offset_.y(); |
362 } | 344 } |
363 | 345 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 | 523 |
542 bool RenderWidget::UsingSynchronousRendererCompositor() const { | 524 bool RenderWidget::UsingSynchronousRendererCompositor() const { |
543 #if defined(OS_ANDROID) | 525 #if defined(OS_ANDROID) |
544 return SynchronousCompositorFactory::GetInstance() != NULL; | 526 return SynchronousCompositorFactory::GetInstance() != NULL; |
545 #else | 527 #else |
546 return false; | 528 return false; |
547 #endif | 529 #endif |
548 } | 530 } |
549 | 531 |
550 void RenderWidget::EnableScreenMetricsEmulation( | 532 void RenderWidget::EnableScreenMetricsEmulation( |
551 const gfx::Rect& device_rect, | 533 const WebDeviceEmulationParams& params) { |
552 const gfx::Rect& widget_rect, | 534 if (!screen_metrics_emulator_) |
553 float device_scale_factor, | 535 screen_metrics_emulator_.reset(new ScreenMetricsEmulator(this, params)); |
554 bool fit_to_view) { | 536 else |
555 if (!screen_metrics_emulator_) { | 537 screen_metrics_emulator_->ChangeEmulationParams(params); |
556 screen_metrics_emulator_.reset(new ScreenMetricsEmulator(this, | |
557 device_rect, widget_rect, device_scale_factor, fit_to_view)); | |
558 } else { | |
559 screen_metrics_emulator_->ChangeEmulationParams(device_rect, | |
560 widget_rect, device_scale_factor, fit_to_view); | |
561 } | |
562 } | 538 } |
563 | 539 |
564 void RenderWidget::DisableScreenMetricsEmulation() { | 540 void RenderWidget::DisableScreenMetricsEmulation() { |
565 screen_metrics_emulator_.reset(); | 541 screen_metrics_emulator_.reset(); |
566 } | 542 } |
567 | 543 |
568 void RenderWidget::SetPopupOriginAdjustmentsForEmulation( | 544 void RenderWidget::SetPopupOriginAdjustmentsForEmulation( |
569 ScreenMetricsEmulator* emulator) { | 545 ScreenMetricsEmulator* emulator) { |
570 popup_origin_scale_for_emulation_ = emulator->scale(); | 546 popup_origin_scale_for_emulation_ = emulator->scale(); |
571 popup_view_origin_for_emulation_ = emulator->widget_rect().origin(); | 547 popup_view_origin_for_emulation_ = emulator->applied_widget_rect().origin(); |
572 popup_screen_origin_for_emulation_ = gfx::Point( | 548 popup_screen_origin_for_emulation_ = gfx::Point( |
573 emulator->original_screen_rect().origin().x() + emulator->offset().x(), | 549 emulator->original_screen_rect().origin().x() + emulator->offset().x(), |
574 emulator->original_screen_rect().origin().y() + emulator->offset().y()); | 550 emulator->original_screen_rect().origin().y() + emulator->offset().y()); |
575 screen_info_ = emulator->original_screen_info(); | 551 screen_info_ = emulator->original_screen_info(); |
576 device_scale_factor_ = screen_info_.deviceScaleFactor; | 552 device_scale_factor_ = screen_info_.deviceScaleFactor; |
577 } | 553 } |
578 | 554 |
579 void RenderWidget::SetScreenMetricsEmulationParameters( | 555 void RenderWidget::SetScreenMetricsEmulationParameters( |
580 float device_scale_factor, | 556 float device_scale_factor, |
581 const gfx::Point& root_layer_offset, | 557 const gfx::Point& root_layer_offset, |
(...skipping 2314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2896 | 2872 |
2897 void RenderWidget::RegisterSwappedOutChildFrame(RenderFrameImpl* frame) { | 2873 void RenderWidget::RegisterSwappedOutChildFrame(RenderFrameImpl* frame) { |
2898 swapped_out_frames_.AddObserver(frame); | 2874 swapped_out_frames_.AddObserver(frame); |
2899 } | 2875 } |
2900 | 2876 |
2901 void RenderWidget::UnregisterSwappedOutChildFrame(RenderFrameImpl* frame) { | 2877 void RenderWidget::UnregisterSwappedOutChildFrame(RenderFrameImpl* frame) { |
2902 swapped_out_frames_.RemoveObserver(frame); | 2878 swapped_out_frames_.RemoveObserver(frame); |
2903 } | 2879 } |
2904 | 2880 |
2905 } // namespace content | 2881 } // namespace content |
OLD | NEW |