Commit 6ba1fb38 authored by Chris Blume's avatar Chris Blume Committed by Commit Bot

Refactor surface property sync

The exact* same code shows up in RWHVA::
OnDeviceScaleFactorChanged()
WasResized()
InternalSetBounds()

This patch refactors that code out to its own function.

*There is one tiny difference, notifying the host of the resize or not.

Bug: 814916
Change-Id: I9336d476a904930cd6a700ee0700d7685000c00c
Reviewed-on: https://chromium-review.googlesource.com/932830
Commit-Queue: Chris Blume <cblume@chromium.org>
Reviewed-by: default avatarFady Samuel <fsamuel@chromium.org>
Reviewed-by: default avatarSaman Sami <samans@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539199}
parent f5b83555
...@@ -1583,18 +1583,7 @@ void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged( ...@@ -1583,18 +1583,7 @@ void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged(
if (!window_->GetRootWindow()) if (!window_->GetRootWindow())
return; return;
if (delegated_frame_host_) { SyncSurfaceProperties(cc::DeadlinePolicy::UseDefaultDeadline());
delegated_frame_host_->WasResized(window_->GetLocalSurfaceId(),
window_->bounds().size(),
cc::DeadlinePolicy::UseDefaultDeadline());
}
// Note that |host_| will retrieve resize parameters from
// |delegated_frame_host_|, so it must have WasResized called after.
host_->WasResized();
if (host_->auto_resize_enabled()) {
host_->DidAllocateLocalSurfaceIdForAutoResize(
host_->last_auto_resize_request_number());
}
device_scale_factor_ = new_device_scale_factor; device_scale_factor_ = new_device_scale_factor;
const display::Display display = const display::Display display =
...@@ -2046,15 +2035,7 @@ void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { ...@@ -2046,15 +2035,7 @@ void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() {
void RenderWidgetHostViewAura::WasResized( void RenderWidgetHostViewAura::WasResized(
const cc::DeadlinePolicy& deadline_policy) { const cc::DeadlinePolicy& deadline_policy) {
window_->AllocateLocalSurfaceId(); window_->AllocateLocalSurfaceId();
if (delegated_frame_host_) { SyncSurfaceProperties(deadline_policy);
delegated_frame_host_->WasResized(window_->GetLocalSurfaceId(),
window_->bounds().size(),
deadline_policy);
}
if (host_->auto_resize_enabled()) {
host_->DidAllocateLocalSurfaceIdForAutoResize(
host_->last_auto_resize_request_number());
}
} }
ui::InputMethod* RenderWidgetHostViewAura::GetInputMethod() const { ui::InputMethod* RenderWidgetHostViewAura::GetInputMethod() const {
...@@ -2191,10 +2172,23 @@ void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { ...@@ -2191,10 +2172,23 @@ void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) {
// a Window::SetBoundsInternal call. // a Window::SetBoundsInternal call.
if (!in_bounds_changed_) if (!in_bounds_changed_)
window_->SetBounds(rect); window_->SetBounds(rect);
SyncSurfaceProperties(cc::DeadlinePolicy::UseDefaultDeadline());
#if defined(OS_WIN)
UpdateLegacyWin();
if (mouse_locked_)
UpdateMouseLockRegion();
#endif
}
void RenderWidgetHostViewAura::SyncSurfaceProperties(
const cc::DeadlinePolicy& deadline_policy) {
if (delegated_frame_host_) { if (delegated_frame_host_) {
delegated_frame_host_->WasResized(window_->GetLocalSurfaceId(), delegated_frame_host_->WasResized(window_->GetLocalSurfaceId(),
window_->bounds().size(), window_->bounds().size(),
cc::DeadlinePolicy::UseDefaultDeadline()); deadline_policy);
} }
// Note that |host_| will retrieve resize parameters from // Note that |host_| will retrieve resize parameters from
// |delegated_frame_host_|, so it must have WasResized called after. // |delegated_frame_host_|, so it must have WasResized called after.
...@@ -2203,12 +2197,6 @@ void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { ...@@ -2203,12 +2197,6 @@ void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) {
host_->DidAllocateLocalSurfaceIdForAutoResize( host_->DidAllocateLocalSurfaceIdForAutoResize(
host_->last_auto_resize_request_number()); host_->last_auto_resize_request_number());
} }
#if defined(OS_WIN)
UpdateLegacyWin();
if (mouse_locked_)
UpdateMouseLockRegion();
#endif
} }
#if defined(OS_WIN) #if defined(OS_WIN)
......
...@@ -440,6 +440,9 @@ class CONTENT_EXPORT RenderWidgetHostViewAura ...@@ -440,6 +440,9 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
// space is required by the aura::Window. // space is required by the aura::Window.
void InternalSetBounds(const gfx::Rect& rect); void InternalSetBounds(const gfx::Rect& rect);
// Handles propagation of surface properties when they are changed.
void SyncSurfaceProperties(const cc::DeadlinePolicy& deadline_policy);
#if defined(OS_WIN) #if defined(OS_WIN)
// Creates and/or updates the legacy dummy window which corresponds to // Creates and/or updates the legacy dummy window which corresponds to
// the bounds of the webcontents. It is needed for accessibility and // the bounds of the webcontents. It is needed for accessibility and
......
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