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 <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 delegate_(delegate), | 140 delegate_(delegate), |
141 process_(process), | 141 process_(process), |
142 routing_id_(routing_id), | 142 routing_id_(routing_id), |
143 surface_id_(0), | 143 surface_id_(0), |
144 is_loading_(false), | 144 is_loading_(false), |
145 is_hidden_(false), | 145 is_hidden_(false), |
146 is_fullscreen_(false), | 146 is_fullscreen_(false), |
147 is_accelerated_compositing_active_(false), | 147 is_accelerated_compositing_active_(false), |
148 repaint_ack_pending_(false), | 148 repaint_ack_pending_(false), |
149 resize_ack_pending_(false), | 149 resize_ack_pending_(false), |
150 renderer_screen_info_out_of_date_(false), | |
150 overdraw_bottom_height_(0.f), | 151 overdraw_bottom_height_(0.f), |
151 should_auto_resize_(false), | 152 should_auto_resize_(false), |
152 waiting_for_screen_rects_ack_(false), | 153 waiting_for_screen_rects_ack_(false), |
153 mouse_move_pending_(false), | 154 mouse_move_pending_(false), |
154 mouse_wheel_pending_(false), | 155 mouse_wheel_pending_(false), |
155 accessibility_mode_(AccessibilityModeOff), | 156 accessibility_mode_(AccessibilityModeOff), |
156 select_range_pending_(false), | 157 select_range_pending_(false), |
157 move_caret_pending_(false), | 158 move_caret_pending_(false), |
158 needs_repainting_on_restore_(false), | 159 needs_repainting_on_restore_(false), |
159 is_unresponsive_(false), | 160 is_unresponsive_(false), |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
519 | 520 |
520 gfx::Size old_physical_backing_size = physical_backing_size_; | 521 gfx::Size old_physical_backing_size = physical_backing_size_; |
521 physical_backing_size_ = view_->GetPhysicalBackingSize(); | 522 physical_backing_size_ = view_->GetPhysicalBackingSize(); |
522 bool was_fullscreen = is_fullscreen_; | 523 bool was_fullscreen = is_fullscreen_; |
523 is_fullscreen_ = IsFullscreen(); | 524 is_fullscreen_ = IsFullscreen(); |
524 float old_overdraw_bottom_height = overdraw_bottom_height_; | 525 float old_overdraw_bottom_height = overdraw_bottom_height_; |
525 overdraw_bottom_height_ = view_->GetOverdrawBottomHeight(); | 526 overdraw_bottom_height_ = view_->GetOverdrawBottomHeight(); |
526 | 527 |
527 bool size_changed = new_size != current_size_; | 528 bool size_changed = new_size != current_size_; |
528 bool side_payload_changed = | 529 bool side_payload_changed = |
530 renderer_screen_info_out_of_date_ || | |
529 old_physical_backing_size != physical_backing_size_ || | 531 old_physical_backing_size != physical_backing_size_ || |
530 was_fullscreen != is_fullscreen_ || | 532 was_fullscreen != is_fullscreen_ || |
531 old_overdraw_bottom_height != overdraw_bottom_height_; | 533 old_overdraw_bottom_height != overdraw_bottom_height_; |
532 | 534 |
533 if (!size_changed && !side_payload_changed) | 535 if (!size_changed && !side_payload_changed) |
534 return; | 536 return; |
535 | 537 |
536 if (in_flight_size_ != gfx::Size() && new_size == in_flight_size_ && | 538 if (in_flight_size_ != gfx::Size() && new_size == in_flight_size_ && |
537 !side_payload_changed) | 539 !side_payload_changed) |
538 return; | 540 return; |
539 | 541 |
540 // We don't expect to receive an ACK when the requested size or the physical | 542 // We don't expect to receive an ACK when the requested size or the physical |
541 // backing size is empty, or when the main viewport size didn't change. | 543 // backing size is empty, or when the main viewport size didn't change. |
542 if (!new_size.IsEmpty() && !physical_backing_size_.IsEmpty() && size_changed) | 544 if (!new_size.IsEmpty() && !physical_backing_size_.IsEmpty() && size_changed) |
543 resize_ack_pending_ = true; | 545 resize_ack_pending_ = true; |
544 | 546 |
545 if (!Send(new ViewMsg_Resize(routing_id_, new_size, physical_backing_size_, | 547 ViewMsg_Resize_Params params; |
546 overdraw_bottom_height_, | 548 GetWebScreenInfo(¶ms.screen_info); |
piman
2013/05/25 00:37:25
This could be a bit expensive, like round-tripping
ccameron
2013/05/25 01:53:37
Yes, I was on the fence about this. I didn't initi
| |
547 GetRootWindowResizerRect(), is_fullscreen_))) { | 549 params.new_size = new_size; |
550 params.physical_backing_size = physical_backing_size_; | |
551 params.overdraw_bottom_height = overdraw_bottom_height_; | |
552 params.resizer_rect = GetRootWindowResizerRect(); | |
553 params.is_fullscreen = is_fullscreen_; | |
554 if (!Send(new ViewMsg_Resize(routing_id_, params))) { | |
548 resize_ack_pending_ = false; | 555 resize_ack_pending_ = false; |
549 } else { | 556 } else { |
550 in_flight_size_ = new_size; | 557 in_flight_size_ = new_size; |
558 renderer_screen_info_out_of_date_ = false; | |
551 } | 559 } |
552 } | 560 } |
553 | 561 |
554 void RenderWidgetHostImpl::ResizeRectChanged(const gfx::Rect& new_rect) { | 562 void RenderWidgetHostImpl::ResizeRectChanged(const gfx::Rect& new_rect) { |
555 Send(new ViewMsg_ChangeResizeRect(routing_id_, new_rect)); | 563 Send(new ViewMsg_ChangeResizeRect(routing_id_, new_rect)); |
556 } | 564 } |
557 | 565 |
558 void RenderWidgetHostImpl::GotFocus() { | 566 void RenderWidgetHostImpl::GotFocus() { |
559 Focus(); | 567 Focus(); |
560 } | 568 } |
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1326 } | 1334 } |
1327 | 1335 |
1328 const NativeWebKeyboardEvent* | 1336 const NativeWebKeyboardEvent* |
1329 RenderWidgetHostImpl::GetLastKeyboardEvent() const { | 1337 RenderWidgetHostImpl::GetLastKeyboardEvent() const { |
1330 if (key_queue_.empty()) | 1338 if (key_queue_.empty()) |
1331 return NULL; | 1339 return NULL; |
1332 return &key_queue_.front(); | 1340 return &key_queue_.front(); |
1333 } | 1341 } |
1334 | 1342 |
1335 void RenderWidgetHostImpl::NotifyScreenInfoChanged() { | 1343 void RenderWidgetHostImpl::NotifyScreenInfoChanged() { |
1336 WebKit::WebScreenInfo screen_info; | 1344 // The resize message (which may not happen immediately) will carry with it |
1337 GetWebScreenInfo(&screen_info); | 1345 // the screen info as well as the new size (if the screen has changed scale |
1338 Send(new ViewMsg_ScreenInfoChanged(GetRoutingID(), screen_info)); | 1346 // factor). |
1347 renderer_screen_info_out_of_date_ = true; | |
1348 WasResized(); | |
1339 } | 1349 } |
1340 | 1350 |
1341 void RenderWidgetHostImpl::GetSnapshotFromRenderer( | 1351 void RenderWidgetHostImpl::GetSnapshotFromRenderer( |
1342 const gfx::Rect& src_subrect, | 1352 const gfx::Rect& src_subrect, |
1343 const base::Callback<void(bool, const SkBitmap&)>& callback) { | 1353 const base::Callback<void(bool, const SkBitmap&)>& callback) { |
1344 TRACE_EVENT0("browser", "RenderWidgetHostImpl::GetSnapshotFromRenderer"); | 1354 TRACE_EVENT0("browser", "RenderWidgetHostImpl::GetSnapshotFromRenderer"); |
1345 pending_snapshots_.push(callback); | 1355 pending_snapshots_.push(callback); |
1346 | 1356 |
1347 gfx::Rect copy_rect = src_subrect.IsEmpty() ? | 1357 gfx::Rect copy_rect = src_subrect.IsEmpty() ? |
1348 gfx::Rect(view_->GetViewBounds().size()) : src_subrect; | 1358 gfx::Rect(view_->GetViewBounds().size()) : src_subrect; |
(...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2476 } | 2486 } |
2477 | 2487 |
2478 void RenderWidgetHostImpl::DetachDelegate() { | 2488 void RenderWidgetHostImpl::DetachDelegate() { |
2479 delegate_ = NULL; | 2489 delegate_ = NULL; |
2480 } | 2490 } |
2481 | 2491 |
2482 void RenderWidgetHostImpl::FrameSwapped(const cc::LatencyInfo& latency_info) { | 2492 void RenderWidgetHostImpl::FrameSwapped(const cc::LatencyInfo& latency_info) { |
2483 } | 2493 } |
2484 | 2494 |
2485 } // namespace content | 2495 } // namespace content |
OLD | NEW |