Fix OSR resize issue when multiple monitors have different scale factors (fixes issue #3240)

This commit is contained in:
Nick Mueller 2022-01-14 16:50:23 +00:00 committed by Marshall Greenblatt
parent 17d51ceed0
commit 029cc67915
2 changed files with 11 additions and 2 deletions

View File

@ -1467,8 +1467,13 @@ void CefRenderWidgetHostViewOSR::OnPaint(const gfx::Rect& damage_rect,
rcList, pixels, pixel_size.width(), pixel_size.height());
// Release the resize hold when we reach the desired size.
if (hold_resize_ && pixel_size == SizeInPixels())
ReleaseResizeHold();
if (hold_resize_) {
DCHECK_GT(cached_scale_factor_, 0);
gfx::Size expected_size =
gfx::ScaleToCeiledSize(GetViewBounds().size(), cached_scale_factor_);
if (pixel_size == expected_size)
ReleaseResizeHold();
}
}
ui::Layer* CefRenderWidgetHostViewOSR::GetRootLayer() const {
@ -1573,6 +1578,7 @@ bool CefRenderWidgetHostViewOSR::ResizeRootLayer() {
// The size has changed. Avoid resizing again until ReleaseResizeHold() is
// called.
hold_resize_ = true;
cached_scale_factor_ = GetDeviceScaleFactor();
return true;
}
} else if (!pending_resize_) {
@ -1586,6 +1592,7 @@ bool CefRenderWidgetHostViewOSR::ResizeRootLayer() {
void CefRenderWidgetHostViewOSR::ReleaseResizeHold() {
DCHECK(hold_resize_);
hold_resize_ = false;
cached_scale_factor_ = -1;
if (pending_resize_) {
pending_resize_ = false;
CEF_POST_TASK(CEF_UIT,

View File

@ -375,6 +375,8 @@ class CefRenderWidgetHostViewOSR
bool hold_resize_ = false;
bool pending_resize_ = false;
float cached_scale_factor_ = 0.0f;
// The associated Model. While |this| is being Destroyed,
// |render_widget_host_| is NULL and the message loop is run one last time
// Message handlers must check for a NULL |render_widget_host_|.