Commit 6e3582ad authored by mlamouri's avatar mlamouri Committed by Commit bot

Send resize event when the screen info changes.

This is a regression from https://codereview.chromium.org/953233002

BUG=475939

Review URL: https://codereview.chromium.org/1078123002

Cr-Commit-Position: refs/heads/master@{#325494}
parent d8ea0a12
...@@ -325,6 +325,7 @@ bool RenderViewHostImpl::CreateRenderView( ...@@ -325,6 +325,7 @@ bool RenderViewHostImpl::CreateRenderView(
params.enable_auto_resize = auto_resize_enabled(); params.enable_auto_resize = auto_resize_enabled();
params.min_size = min_size_for_auto_resize(); params.min_size = min_size_for_auto_resize();
params.max_size = max_size_for_auto_resize(); params.max_size = max_size_for_auto_resize();
UpdateScreenInfo();
GetResizeParams(&params.initial_size); GetResizeParams(&params.initial_size);
if (!is_active_) { if (!is_active_) {
params.replicated_frame_state = params.replicated_frame_state =
......
...@@ -170,7 +170,7 @@ RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, ...@@ -170,7 +170,7 @@ RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate,
is_hidden_(hidden), is_hidden_(hidden),
repaint_ack_pending_(false), repaint_ack_pending_(false),
resize_ack_pending_(false), resize_ack_pending_(false),
screen_info_out_of_date_(false), screen_info_out_of_date_(true),
auto_resize_enabled_(false), auto_resize_enabled_(false),
waiting_for_screen_rects_ack_(false), waiting_for_screen_rects_ack_(false),
needs_repainting_on_restore_(false), needs_repainting_on_restore_(false),
...@@ -577,13 +577,11 @@ void RenderWidgetHostImpl::WasShown(const ui::LatencyInfo& latency_info) { ...@@ -577,13 +577,11 @@ void RenderWidgetHostImpl::WasShown(const ui::LatencyInfo& latency_info) {
} }
bool RenderWidgetHostImpl::GetResizeParams( bool RenderWidgetHostImpl::GetResizeParams(
ViewMsg_Resize_Params* resize_params) { ViewMsg_Resize_Params* resize_params) const {
DCHECK(!screen_info_out_of_date_);
*resize_params = ViewMsg_Resize_Params(); *resize_params = ViewMsg_Resize_Params();
if (!screen_info_) {
screen_info_.reset(new blink::WebScreenInfo);
GetWebScreenInfo(screen_info_.get());
}
resize_params->screen_info = *screen_info_; resize_params->screen_info = *screen_info_;
resize_params->resizer_rect = GetRootWindowResizerRect(); resize_params->resizer_rect = GetRootWindowResizerRect();
...@@ -604,7 +602,7 @@ bool RenderWidgetHostImpl::GetResizeParams( ...@@ -604,7 +602,7 @@ bool RenderWidgetHostImpl::GetResizeParams(
(old_resize_params_->physical_backing_size.IsEmpty() && (old_resize_params_->physical_backing_size.IsEmpty() &&
!resize_params->physical_backing_size.IsEmpty()); !resize_params->physical_backing_size.IsEmpty());
bool dirty = bool dirty =
size_changed || screen_info_out_of_date_ || size_changed ||
old_resize_params_->physical_backing_size != old_resize_params_->physical_backing_size !=
resize_params->physical_backing_size || resize_params->physical_backing_size ||
old_resize_params_->is_fullscreen_granted != old_resize_params_->is_fullscreen_granted !=
...@@ -626,6 +624,17 @@ bool RenderWidgetHostImpl::GetResizeParams( ...@@ -626,6 +624,17 @@ bool RenderWidgetHostImpl::GetResizeParams(
return dirty; return dirty;
} }
bool RenderWidgetHostImpl::UpdateScreenInfo() {
if (!screen_info_out_of_date_)
return false;
screen_info_.reset(new blink::WebScreenInfo);
GetWebScreenInfo(screen_info_.get());
screen_info_out_of_date_ = false;
return true;
}
void RenderWidgetHostImpl::SetInitialRenderSizeParams( void RenderWidgetHostImpl::SetInitialRenderSizeParams(
const ViewMsg_Resize_Params& resize_params) { const ViewMsg_Resize_Params& resize_params) {
resize_ack_pending_ = resize_params.needs_resize_ack; resize_ack_pending_ = resize_params.needs_resize_ack;
...@@ -642,8 +651,9 @@ void RenderWidgetHostImpl::WasResized() { ...@@ -642,8 +651,9 @@ void RenderWidgetHostImpl::WasResized() {
return; return;
} }
bool screen_info_was_updated = UpdateScreenInfo();
scoped_ptr<ViewMsg_Resize_Params> params(new ViewMsg_Resize_Params); scoped_ptr<ViewMsg_Resize_Params> params(new ViewMsg_Resize_Params);
if (!GetResizeParams(params.get())) if (!GetResizeParams(params.get()) && !screen_info_was_updated)
return; return;
bool width_changed = bool width_changed =
...@@ -1137,8 +1147,9 @@ void RenderWidgetHostImpl::GetWebScreenInfo(blink::WebScreenInfo* result) { ...@@ -1137,8 +1147,9 @@ void RenderWidgetHostImpl::GetWebScreenInfo(blink::WebScreenInfo* result) {
view_->GetScreenInfo(result); view_->GetScreenInfo(result);
else else
RenderWidgetHostViewBase::GetDefaultScreenInfo(result); RenderWidgetHostViewBase::GetDefaultScreenInfo(result);
// TODO(sievers): find a way to make this done another way so the method
// can be const.
latency_tracker_.set_device_scale_factor(result->deviceScaleFactor); latency_tracker_.set_device_scale_factor(result->deviceScaleFactor);
screen_info_out_of_date_ = false;
} }
const NativeWebKeyboardEvent* const NativeWebKeyboardEvent*
......
...@@ -554,7 +554,7 @@ class CONTENT_EXPORT RenderWidgetHostImpl ...@@ -554,7 +554,7 @@ class CONTENT_EXPORT RenderWidgetHostImpl
// Fills in the |resize_params| struct. // Fills in the |resize_params| struct.
// Returns |false| if the update is redundant, |true| otherwise. // Returns |false| if the update is redundant, |true| otherwise.
bool GetResizeParams(ViewMsg_Resize_Params* resize_params); bool GetResizeParams(ViewMsg_Resize_Params* resize_params) const;
// Sets the |resize_params| that were sent to the renderer bundled with the // Sets the |resize_params| that were sent to the renderer bundled with the
// request to create a new RenderWidget. // request to create a new RenderWidget.
...@@ -568,6 +568,10 @@ class CONTENT_EXPORT RenderWidgetHostImpl ...@@ -568,6 +568,10 @@ class CONTENT_EXPORT RenderWidgetHostImpl
return --in_flight_event_count_; return --in_flight_event_count_;
} }
// Update screen_info_ if needed.
// Returns whether screen_info_ was updated.
bool UpdateScreenInfo();
// The View associated with the RenderViewHost. The lifetime of this object // The View associated with the RenderViewHost. The lifetime of this object
// is associated with the lifetime of the Render process. If the Renderer // is associated with the lifetime of the Render process. If the Renderer
// crashes, its View is destroyed and this pointer becomes NULL, even though // crashes, its View is destroyed and this pointer becomes NULL, even though
......
...@@ -141,6 +141,7 @@ class MockRenderWidgetHost : public RenderWidgetHostImpl { ...@@ -141,6 +141,7 @@ class MockRenderWidgetHost : public RenderWidgetHostImpl {
using RenderWidgetHostImpl::OnUpdateRect; using RenderWidgetHostImpl::OnUpdateRect;
using RenderWidgetHostImpl::RendererExited; using RenderWidgetHostImpl::RendererExited;
using RenderWidgetHostImpl::SetInitialRenderSizeParams; using RenderWidgetHostImpl::SetInitialRenderSizeParams;
using RenderWidgetHostImpl::UpdateScreenInfo;
using RenderWidgetHostImpl::old_resize_params_; using RenderWidgetHostImpl::old_resize_params_;
using RenderWidgetHostImpl::is_hidden_; using RenderWidgetHostImpl::is_hidden_;
using RenderWidgetHostImpl::resize_ack_pending_; using RenderWidgetHostImpl::resize_ack_pending_;
...@@ -446,6 +447,7 @@ class RenderWidgetHostTest : public testing::Test { ...@@ -446,6 +447,7 @@ class RenderWidgetHostTest : public testing::Test {
void SetInitialRenderSizeParams() { void SetInitialRenderSizeParams() {
ViewMsg_Resize_Params render_size_params; ViewMsg_Resize_Params render_size_params;
host_->UpdateScreenInfo();
host_->GetResizeParams(&render_size_params); host_->GetResizeParams(&render_size_params);
host_->SetInitialRenderSizeParams(render_size_params); host_->SetInitialRenderSizeParams(render_size_params);
} }
...@@ -604,8 +606,8 @@ class RenderWidgetHostWithSourceTest ...@@ -604,8 +606,8 @@ class RenderWidgetHostWithSourceTest
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
TEST_F(RenderWidgetHostTest, Resize) { TEST_F(RenderWidgetHostTest, Resize) {
// The initial bounds is the empty rect, and the screen info hasn't been sent // The initial bounds is the empty rect, so setting it to the same thing
// yet, so setting it to the same thing shouldn't send the resize message. // shouldn't send the resize message.
view_->set_bounds(gfx::Rect()); view_->set_bounds(gfx::Rect());
host_->WasResized(); host_->WasResized();
EXPECT_FALSE(host_->resize_ack_pending_); EXPECT_FALSE(host_->resize_ack_pending_);
...@@ -719,6 +721,14 @@ TEST_F(RenderWidgetHostTest, Resize) { ...@@ -719,6 +721,14 @@ TEST_F(RenderWidgetHostTest, Resize) {
EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
} }
// Test that a resize event is sent if InvalidateScreenInfo() was called.
TEST_F(RenderWidgetHostTest, ResizeScreenInfo) {
host_->InvalidateScreenInfo();
host_->WasResized();
EXPECT_FALSE(host_->resize_ack_pending_);
EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
}
// Test for crbug.com/25097. If a renderer crashes between a resize and the // Test for crbug.com/25097. If a renderer crashes between a resize and the
// corresponding update message, we must be sure to clear the resize ack logic. // corresponding update message, we must be sure to clear the resize ack logic.
TEST_F(RenderWidgetHostTest, ResizeThenCrash) { TEST_F(RenderWidgetHostTest, ResizeThenCrash) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment