Chromium Code Reviews| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 bool hidden) | 160 bool hidden) |
| 161 : view_(NULL), | 161 : view_(NULL), |
| 162 renderer_initialized_(false), | 162 renderer_initialized_(false), |
| 163 hung_renderer_delay_ms_(kHungRendererDelayMs), | 163 hung_renderer_delay_ms_(kHungRendererDelayMs), |
| 164 delegate_(delegate), | 164 delegate_(delegate), |
| 165 process_(process), | 165 process_(process), |
| 166 routing_id_(routing_id), | 166 routing_id_(routing_id), |
| 167 surface_id_(0), | 167 surface_id_(0), |
| 168 is_loading_(false), | 168 is_loading_(false), |
| 169 is_hidden_(hidden), | 169 is_hidden_(hidden), |
| 170 is_fullscreen_(false), | |
| 171 repaint_ack_pending_(false), | 170 repaint_ack_pending_(false), |
| 172 resize_ack_pending_(false), | 171 resize_ack_pending_(false), |
| 173 screen_info_out_of_date_(false), | 172 screen_info_out_of_date_(false), |
| 174 top_controls_layout_height_(0.f), | |
| 175 should_auto_resize_(false), | 173 should_auto_resize_(false), |
| 176 waiting_for_screen_rects_ack_(false), | 174 waiting_for_screen_rects_ack_(false), |
| 177 needs_repainting_on_restore_(false), | 175 needs_repainting_on_restore_(false), |
| 178 is_unresponsive_(false), | 176 is_unresponsive_(false), |
| 179 in_flight_event_count_(0), | 177 in_flight_event_count_(0), |
| 180 in_get_backing_store_(false), | 178 in_get_backing_store_(false), |
| 181 ignore_input_events_(false), | 179 ignore_input_events_(false), |
| 182 input_method_active_(false), | 180 input_method_active_(false), |
| 183 text_direction_updated_(false), | 181 text_direction_updated_(false), |
| 184 text_direction_(blink::WebTextDirectionLeftToRight), | 182 text_direction_(blink::WebTextDirectionLeftToRight), |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 557 // By invoking WasResized the renderer is updated as necessary. WasResized | 555 // By invoking WasResized the renderer is updated as necessary. WasResized |
| 558 // does nothing if the sizes are already in sync. | 556 // does nothing if the sizes are already in sync. |
| 559 // | 557 // |
| 560 // TODO: ideally ViewMsg_WasShown would take a size. This way, the renderer | 558 // TODO: ideally ViewMsg_WasShown would take a size. This way, the renderer |
| 561 // could handle both the restore and resize at once. This isn't that big a | 559 // could handle both the restore and resize at once. This isn't that big a |
| 562 // deal as RenderWidget::WasShown delays updating, so that the resize from | 560 // deal as RenderWidget::WasShown delays updating, so that the resize from |
| 563 // WasResized is usually processed before the renderer is painted. | 561 // WasResized is usually processed before the renderer is painted. |
| 564 WasResized(); | 562 WasResized(); |
| 565 } | 563 } |
| 566 | 564 |
| 565 void RenderWidgetHostImpl::GetResizeParams( | |
| 566 ViewMsg_Resize_Params* resize_params) { | |
| 567 if (!screen_info_) { | |
| 568 screen_info_.reset(new blink::WebScreenInfo); | |
| 569 GetWebScreenInfo(screen_info_.get()); | |
| 570 } | |
| 571 resize_params->screen_info = *screen_info_; | |
| 572 resize_params->new_size = | |
| 573 (view_) ? view_->GetRequestedRendererSize() : gfx::Size(); | |
|
piman
2014/10/29 18:42:57
nit: no need for () around view_.
It might be mor
mkosiba (inactive)
2014/10/31 14:35:06
All are great suggestions! I think I'll go with th
| |
| 574 resize_params->resizer_rect = GetRootWindowResizerRect(); | |
| 575 resize_params->physical_backing_size = | |
| 576 (view_) ? view_->GetPhysicalBackingSize() : gfx::Size(); | |
| 577 resize_params->top_controls_layout_height = | |
| 578 (view_) ? view_->GetTopControlsLayoutHeight() : 0.f; | |
| 579 resize_params->visible_viewport_size = | |
| 580 (view_) ? view_->GetVisibleViewportSize() : gfx::Size(); | |
| 581 resize_params->is_fullscreen = IsFullscreen(); | |
| 582 } | |
| 583 | |
| 584 void RenderWidgetHostImpl::GetNewViewResizeParams( | |
| 585 ViewMsg_Resize_Params* resize_params) { | |
| 586 GetResizeParams(resize_params); | |
| 587 | |
| 588 // We don't expect to receive an ACK when the requested size or the physical | |
| 589 // backing size is empty, or when the main viewport size didn't change. | |
| 590 if (!resize_params->new_size.IsEmpty() && | |
| 591 !resize_params->physical_backing_size.IsEmpty()) { | |
| 592 resize_ack_pending_ = g_check_for_pending_resize_ack; | |
|
piman
2014/10/29 18:42:57
MMh, I certainly would not expect GetNewViewResize
mkosiba (inactive)
2014/10/31 14:35:06
that does indeed sound better. I guess I was tryin
| |
| 593 } | |
| 594 | |
| 595 DCHECK(!old_resize_params_); | |
| 596 old_resize_params_ = | |
| 597 make_scoped_ptr(new ViewMsg_Resize_Params(*resize_params)); | |
| 598 } | |
| 599 | |
| 567 void RenderWidgetHostImpl::WasResized() { | 600 void RenderWidgetHostImpl::WasResized() { |
| 568 // Skip if the |delegate_| has already been detached because | 601 // Skip if the |delegate_| has already been detached because |
| 569 // it's web contents is being deleted. | 602 // it's web contents is being deleted. |
| 570 if (resize_ack_pending_ || !process_->HasConnection() || !view_ || | 603 if (resize_ack_pending_ || !process_->HasConnection() || !view_ || |
| 571 !renderer_initialized_ || should_auto_resize_ || !delegate_) { | 604 !renderer_initialized_ || should_auto_resize_ || !delegate_) { |
| 572 return; | 605 return; |
| 573 } | 606 } |
| 574 | 607 |
| 575 gfx::Size new_size(view_->GetRequestedRendererSize()); | 608 bool size_changed = false; |
| 609 bool side_payload_changed = screen_info_out_of_date_; | |
| 610 scoped_ptr<ViewMsg_Resize_Params> params(new ViewMsg_Resize_Params); | |
| 576 | 611 |
| 577 gfx::Size old_physical_backing_size = physical_backing_size_; | 612 GetResizeParams(params.get()); |
| 578 physical_backing_size_ = view_->GetPhysicalBackingSize(); | 613 if (old_resize_params_) { |
| 579 bool was_fullscreen = is_fullscreen_; | 614 size_changed = old_resize_params_->new_size != params->new_size; |
| 580 is_fullscreen_ = IsFullscreen(); | 615 side_payload_changed = |
| 581 float old_top_controls_layout_height = | 616 side_payload_changed || |
| 582 top_controls_layout_height_; | 617 old_resize_params_->physical_backing_size != |
| 583 top_controls_layout_height_ = | 618 params->physical_backing_size || |
| 584 view_->GetTopControlsLayoutHeight(); | 619 old_resize_params_->is_fullscreen != params->is_fullscreen || |
| 585 gfx::Size old_visible_viewport_size = visible_viewport_size_; | 620 old_resize_params_->top_controls_layout_height != |
| 586 visible_viewport_size_ = view_->GetVisibleViewportSize(); | 621 params->top_controls_layout_height || |
| 587 | 622 old_resize_params_->visible_viewport_size != |
| 588 bool size_changed = new_size != last_requested_size_; | 623 params->visible_viewport_size; |
| 589 bool side_payload_changed = | 624 } |
| 590 screen_info_out_of_date_ || | |
| 591 old_physical_backing_size != physical_backing_size_ || | |
| 592 was_fullscreen != is_fullscreen_ || | |
| 593 old_top_controls_layout_height != | |
| 594 top_controls_layout_height_ || | |
| 595 old_visible_viewport_size != visible_viewport_size_; | |
| 596 | 625 |
| 597 if (!size_changed && !side_payload_changed) | 626 if (!size_changed && !side_payload_changed) |
| 598 return; | 627 return; |
| 599 | 628 |
| 600 if (!screen_info_) { | 629 // We don't expect to receive an ACK when the requested size or the physical |
| 601 screen_info_.reset(new blink::WebScreenInfo); | 630 // backing size is empty, or when the main viewport size didn't change. |
| 602 GetWebScreenInfo(screen_info_.get()); | 631 if (!params->new_size.IsEmpty() && !params->physical_backing_size.IsEmpty() && |
| 632 size_changed) { | |
| 633 resize_ack_pending_ = g_check_for_pending_resize_ack; | |
| 603 } | 634 } |
| 604 | 635 |
| 605 // We don't expect to receive an ACK when the requested size or the physical | 636 if (!Send(new ViewMsg_Resize(routing_id_, *params))) { |
| 606 // backing size is empty, or when the main viewport size didn't change. | |
| 607 if (!new_size.IsEmpty() && !physical_backing_size_.IsEmpty() && size_changed) | |
| 608 resize_ack_pending_ = g_check_for_pending_resize_ack; | |
| 609 | |
| 610 ViewMsg_Resize_Params params; | |
| 611 params.screen_info = *screen_info_; | |
| 612 params.new_size = new_size; | |
| 613 params.physical_backing_size = physical_backing_size_; | |
| 614 params.top_controls_layout_height = top_controls_layout_height_; | |
| 615 params.visible_viewport_size = visible_viewport_size_; | |
| 616 params.resizer_rect = GetRootWindowResizerRect(); | |
| 617 params.is_fullscreen = is_fullscreen_; | |
| 618 if (!Send(new ViewMsg_Resize(routing_id_, params))) { | |
| 619 resize_ack_pending_ = false; | 637 resize_ack_pending_ = false; |
| 620 } else { | 638 } else { |
| 621 last_requested_size_ = new_size; | 639 old_resize_params_.swap(params); |
| 622 } | 640 } |
| 623 } | 641 } |
| 624 | 642 |
| 625 void RenderWidgetHostImpl::ResizeRectChanged(const gfx::Rect& new_rect) { | 643 void RenderWidgetHostImpl::ResizeRectChanged(const gfx::Rect& new_rect) { |
| 626 Send(new ViewMsg_ChangeResizeRect(routing_id_, new_rect)); | 644 Send(new ViewMsg_ChangeResizeRect(routing_id_, new_rect)); |
| 627 } | 645 } |
| 628 | 646 |
| 629 void RenderWidgetHostImpl::GotFocus() { | 647 void RenderWidgetHostImpl::GotFocus() { |
| 630 Focus(); | 648 Focus(); |
| 631 if (delegate_) | 649 if (delegate_) |
| (...skipping 1767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2399 } | 2417 } |
| 2400 #endif | 2418 #endif |
| 2401 | 2419 |
| 2402 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { | 2420 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { |
| 2403 if (view_) | 2421 if (view_) |
| 2404 return view_->PreferredReadbackFormat(); | 2422 return view_->PreferredReadbackFormat(); |
| 2405 return kN32_SkColorType; | 2423 return kN32_SkColorType; |
| 2406 } | 2424 } |
| 2407 | 2425 |
| 2408 } // namespace content | 2426 } // namespace content |
| OLD | NEW |