Commit ff20be5f authored by Tomasz Moniuszko's avatar Tomasz Moniuszko Committed by Commit Bot

Fix crash on ResetWindowControls with no non-client view

Crash happens when Widget with no non-client view (for example
TYPE_WINDOW_FRAMELESS) is being shown on Windows 7 with Aero Glass
disabled.

This is a regression introduced by
https://chromium-review.googlesource.com/924315.
ResetWindowControls is called from HWNDMessageHandler::OnSysCommand.
Previously it wasn't called if non-client view was null because
ShouldHandleSystemCommands returned false in such case.

Bug: 189112
Change-Id: Ia12013ab11fd67dd28bcaf5d490c846928569a78
Reviewed-on: https://chromium-review.googlesource.com/960029
Commit-Queue: Tomasz Moniuszko <tmoniuszko@opera.com>
Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543350}
parent d7cbb5e3
...@@ -134,6 +134,31 @@ TEST_F(DesktopNativeWidgetAuraTest, WidgetNotVisibleOnlyWindowTreeHostShown) { ...@@ -134,6 +134,31 @@ TEST_F(DesktopNativeWidgetAuraTest, WidgetNotVisibleOnlyWindowTreeHostShown) {
EXPECT_FALSE(widget.IsVisible()); EXPECT_FALSE(widget.IsVisible());
} }
TEST_F(DesktopNativeWidgetAuraTest, DesktopAuraWindowShowFrameless) {
Widget widget;
Widget::InitParams init_params =
CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
init_params.native_widget = new DesktopNativeWidgetAura(&widget);
widget.Init(init_params);
// Make sure that changing frame type doesn't crash when there's no non-client
// view.
ASSERT_EQ(nullptr, widget.non_client_view());
widget.DebugToggleFrameType();
widget.Show();
#if defined(OS_WIN)
// On Windows also make sure that handling WM_SYSCOMMAND doesn't crash with
// custom frame. Frame type needs to be toggled again if Aero Glass is
// disabled.
if (widget.ShouldUseNativeFrame())
widget.DebugToggleFrameType();
SendMessage(widget.GetNativeWindow()->GetHost()->GetAcceleratedWidget(),
WM_SYSCOMMAND, SC_RESTORE, 0);
#endif // OS_WIN
}
// Verify that the cursor state is shared between two native widgets. // Verify that the cursor state is shared between two native widgets.
TEST_F(DesktopNativeWidgetAuraTest, GlobalCursorState) { TEST_F(DesktopNativeWidgetAuraTest, GlobalCursorState) {
// Create two native widgets, each owning different root windows. // Create two native widgets, each owning different root windows.
......
...@@ -727,6 +727,7 @@ gfx::Size DesktopWindowTreeHostWin::DIPToScreenSize( ...@@ -727,6 +727,7 @@ gfx::Size DesktopWindowTreeHostWin::DIPToScreenSize(
} }
void DesktopWindowTreeHostWin::ResetWindowControls() { void DesktopWindowTreeHostWin::ResetWindowControls() {
if (GetWidget()->non_client_view())
GetWidget()->non_client_view()->ResetWindowControls(); GetWidget()->non_client_view()->ResetWindowControls();
} }
...@@ -845,6 +846,7 @@ void DesktopWindowTreeHostWin::HandleFrameChanged() { ...@@ -845,6 +846,7 @@ void DesktopWindowTreeHostWin::HandleFrameChanged() {
CheckForMonitorChange(); CheckForMonitorChange();
SetWindowTransparency(); SetWindowTransparency();
// Replace the frame and layout the contents. // Replace the frame and layout the contents.
if (GetWidget()->non_client_view())
GetWidget()->non_client_view()->UpdateFrame(); GetWidget()->non_client_view()->UpdateFrame();
} }
......
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