Commit ab165629 authored by kylechar's avatar kylechar Committed by Commit Bot

Remove HwndMessageHandler DCHECKs

The DCHECKs that |exposed_pixels_| is smaller than the client area
doesn't hold when restoring a minimized content_shell window. On restore
the height of the window gets larger but the height of the client area
shrinks a bit. Since the height of the window was almost zero before
being restored exposed_pixels_.height() > cr.bottom and the DCHECK
fails.

I believe this is because content_shell lets Windows draw the title bar,
so it is non-client area, and the title bar wasn't drawn when the window
was minimized.

It doesn't seem problematic that area to be filled is potentially larger
than the client area, since FillRect() is already clipped by ps.rcPaint.
HwndMessageHandler also tells the delegate to repaint everything in
ps.rcPaint immediately the fill. As such, removing the DCHECKs seems
safe. Trying to account for window frame size changes would add more
complexity with no clear benefit.

Bug: 1084625
Change-Id: Ibb7966e5780d4d221d2b4e8fbb82eb5e37aa93b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2267501
Commit-Queue: kylechar <kylechar@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#782534}
parent b1a92631
...@@ -2419,23 +2419,28 @@ void HWNDMessageHandler::OnPaint(HDC dc) { ...@@ -2419,23 +2419,28 @@ void HWNDMessageHandler::OnPaint(HDC dc) {
// flicker opaque black. http://crbug.com/586454 // flicker opaque black. http://crbug.com/586454
FillRect(ps.hdc, &ps.rcPaint, brush); FillRect(ps.hdc, &ps.rcPaint, brush);
} else if (exposed_pixels_.height() > 0 || exposed_pixels_.width() > 0) { } else if (exposed_pixels_ != gfx::Size()) {
// Fill in newly exposed window client area with black to ensure Windows // Fill in newly exposed window client area with black to ensure Windows
// doesn't put something else there (eg. copying existing pixels). This // doesn't put something else there (eg. copying existing pixels). This
// isn't needed if we've just cleared the whole client area outside the // isn't needed if we've just cleared the whole client area outside the
// child window above. // child window above.
RECT cr; RECT cr;
if (GetClientRect(hwnd(), &cr)) { if (GetClientRect(hwnd(), &cr)) {
// GetClientRect() always returns a rect with top/left at 0.
const gfx::Size client_area = gfx::Rect(cr).size();
// It's possible that |exposed_pixels_| height and/or width is larger
// than the client area if the window frame size changed. This isn't an
// issue since FillRect() is clipped by |ps.rcPaint|.
if (exposed_pixels_.height() > 0) { if (exposed_pixels_.height() > 0) {
DCHECK_GE(cr.bottom, exposed_pixels_.height()); RECT rect = {0, client_area.height() - exposed_pixels_.height(),
RECT rect = {cr.left, cr.bottom - exposed_pixels_.height(), cr.right, client_area.width(), client_area.height()};
cr.bottom};
FillRect(ps.hdc, &rect, brush); FillRect(ps.hdc, &rect, brush);
} }
if (exposed_pixels_.width() > 0) { if (exposed_pixels_.width() > 0) {
DCHECK_GE(cr.right, exposed_pixels_.width()); RECT rect = {client_area.width() - exposed_pixels_.width(), 0,
RECT rect = {cr.right - exposed_pixels_.width(), cr.top, cr.right, client_area.width(),
cr.bottom - exposed_pixels_.height()}; client_area.height() - exposed_pixels_.height()};
FillRect(ps.hdc, &rect, brush); FillRect(ps.hdc, &rect, brush);
} }
} }
......
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