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/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 gfx::Rect applied_widget_rect() const { return applied_widget_rect_; } | 174 gfx::Rect applied_widget_rect() const { return applied_widget_rect_; } |
175 gfx::Rect original_screen_rect() const { return original_view_screen_rect_; } | 175 gfx::Rect original_screen_rect() const { return original_view_screen_rect_; } |
176 const WebScreenInfo& original_screen_info() { return original_screen_info_; } | 176 const WebScreenInfo& original_screen_info() { return original_screen_info_; } |
177 | 177 |
178 void ChangeEmulationParams( | 178 void ChangeEmulationParams( |
179 const WebDeviceEmulationParams& params); | 179 const WebDeviceEmulationParams& params); |
180 | 180 |
181 // The following methods alter handlers' behavior for messages related to | 181 // The following methods alter handlers' behavior for messages related to |
182 // widget size and position. | 182 // widget size and position. |
183 void OnResizeMessage(const ViewMsg_Resize_Params& params); | 183 void OnResizeMessage(const ViewMsg_Resize_Params& params); |
| 184 void ResizeSynchronously(const gfx::Rect& rect); |
184 void OnUpdateScreenRectsMessage(const gfx::Rect& view_screen_rect, | 185 void OnUpdateScreenRectsMessage(const gfx::Rect& view_screen_rect, |
185 const gfx::Rect& window_screen_rect); | 186 const gfx::Rect& window_screen_rect); |
186 void OnShowContextMenu(ContextMenuParams* params); | 187 void OnShowContextMenu(ContextMenuParams* params); |
187 | 188 |
188 private: | 189 private: |
189 void Reapply(); | 190 void Reapply(); |
190 void Apply(float overdraw_bottom_height, | 191 void Apply(float overdraw_bottom_height, |
191 gfx::Rect resizer_rect, | 192 gfx::Rect resizer_rect, |
192 bool is_fullscreen); | 193 bool is_fullscreen); |
193 | 194 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 Apply(params.overdraw_bottom_height, params.resizer_rect, | 329 Apply(params.overdraw_bottom_height, params.resizer_rect, |
329 params.is_fullscreen); | 330 params.is_fullscreen); |
330 | 331 |
331 if (need_ack) { | 332 if (need_ack) { |
332 widget_->set_next_paint_is_resize_ack(); | 333 widget_->set_next_paint_is_resize_ack(); |
333 if (widget_->compositor_) | 334 if (widget_->compositor_) |
334 widget_->compositor_->SetNeedsRedrawRect(gfx::Rect(widget_->size_)); | 335 widget_->compositor_->SetNeedsRedrawRect(gfx::Rect(widget_->size_)); |
335 } | 336 } |
336 } | 337 } |
337 | 338 |
| 339 void RenderWidget::ScreenMetricsEmulator::ResizeSynchronously( |
| 340 const gfx::Rect& rect) { |
| 341 original_size_ = rect.size(); |
| 342 original_view_screen_rect_ = rect; |
| 343 original_window_screen_rect_ = rect; |
| 344 Reapply(); |
| 345 } |
| 346 |
338 void RenderWidget::ScreenMetricsEmulator::OnUpdateScreenRectsMessage( | 347 void RenderWidget::ScreenMetricsEmulator::OnUpdateScreenRectsMessage( |
339 const gfx::Rect& view_screen_rect, | 348 const gfx::Rect& view_screen_rect, |
340 const gfx::Rect& window_screen_rect) { | 349 const gfx::Rect& window_screen_rect) { |
341 original_view_screen_rect_ = view_screen_rect; | 350 original_view_screen_rect_ = view_screen_rect; |
342 original_window_screen_rect_ = window_screen_rect; | 351 original_window_screen_rect_ = window_screen_rect; |
343 if (params_.screenPosition == WebDeviceEmulationParams::Desktop) | 352 if (params_.screenPosition == WebDeviceEmulationParams::Desktop) |
344 Reapply(); | 353 Reapply(); |
345 } | 354 } |
346 | 355 |
347 void RenderWidget::ScreenMetricsEmulator::OnShowContextMenu( | 356 void RenderWidget::ScreenMetricsEmulator::OnShowContextMenu( |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 | 696 |
688 if (fullscreen_change) | 697 if (fullscreen_change) |
689 DidToggleFullscreen(); | 698 DidToggleFullscreen(); |
690 | 699 |
691 // If a resize ack is requested and it isn't set-up, then no more resizes will | 700 // If a resize ack is requested and it isn't set-up, then no more resizes will |
692 // come in and in general things will go wrong. | 701 // come in and in general things will go wrong. |
693 DCHECK(resize_ack != SEND_RESIZE_ACK || next_paint_is_resize_ack()); | 702 DCHECK(resize_ack != SEND_RESIZE_ACK || next_paint_is_resize_ack()); |
694 } | 703 } |
695 | 704 |
696 void RenderWidget::ResizeSynchronously(const gfx::Rect& new_position) { | 705 void RenderWidget::ResizeSynchronously(const gfx::Rect& new_position) { |
697 Resize(new_position.size(), new_position.size(), overdraw_bottom_height_, | 706 if (screen_metrics_emulator_) { |
698 visible_viewport_size_, gfx::Rect(), is_fullscreen_, NO_RESIZE_ACK); | 707 screen_metrics_emulator_->ResizeSynchronously(new_position); |
699 view_screen_rect_ = new_position; | 708 } else { |
700 window_screen_rect_ = new_position; | 709 Resize(new_position.size(), new_position.size(), overdraw_bottom_height_, |
| 710 visible_viewport_size_, gfx::Rect(), is_fullscreen_, NO_RESIZE_ACK); |
| 711 view_screen_rect_ = new_position; |
| 712 window_screen_rect_ = new_position; |
| 713 } |
701 if (!did_show_) | 714 if (!did_show_) |
702 initial_pos_ = new_position; | 715 initial_pos_ = new_position; |
703 } | 716 } |
704 | 717 |
705 void RenderWidget::OnClose() { | 718 void RenderWidget::OnClose() { |
706 if (closing_) | 719 if (closing_) |
707 return; | 720 return; |
708 closing_ = true; | 721 closing_ = true; |
709 | 722 |
710 // Browser correspondence is no longer needed at this point. | 723 // Browser correspondence is no longer needed at this point. |
(...skipping 1428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2139 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2152 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
2140 video_hole_frames_.AddObserver(frame); | 2153 video_hole_frames_.AddObserver(frame); |
2141 } | 2154 } |
2142 | 2155 |
2143 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2156 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
2144 video_hole_frames_.RemoveObserver(frame); | 2157 video_hole_frames_.RemoveObserver(frame); |
2145 } | 2158 } |
2146 #endif // defined(VIDEO_HOLE) | 2159 #endif // defined(VIDEO_HOLE) |
2147 | 2160 |
2148 } // namespace content | 2161 } // namespace content |
OLD | NEW |