Index: ui/views/win/hwnd_message_handler.cc |
diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc |
index 1544507ef39740982de458fcff8f71dd0b069b6c..2df7dbbc6595a178dca89fbe7e532d30af429b93 100644 |
--- a/ui/views/win/hwnd_message_handler.cc |
+++ b/ui/views/win/hwnd_message_handler.cc |
@@ -12,6 +12,7 @@ |
#include "base/bind.h" |
#include "base/debug/trace_event.h" |
+#include "base/win/scoped_gdi_object.h" |
#include "base/win/win_util.h" |
#include "base/win/windows_version.h" |
#include "ui/base/touch/touch_enabled.h" |
@@ -1128,14 +1129,14 @@ void HWNDMessageHandler::ResetWindowRegion(bool force, bool redraw) { |
// Changing the window region is going to force a paint. Only change the |
// window region if the region really differs. |
- HRGN current_rgn = CreateRectRgn(0, 0, 0, 0); |
+ base::win::ScopedRegion current_rgn(CreateRectRgn(0, 0, 0, 0)); |
int current_rgn_result = GetWindowRgn(hwnd(), current_rgn); |
RECT window_rect; |
GetWindowRect(hwnd(), &window_rect); |
- HRGN new_region; |
+ base::win::ScopedRegion new_region; |
if (custom_window_region_) { |
- new_region = ::CreateRectRgn(0, 0, 0, 0); |
+ new_region.Set(::CreateRectRgn(0, 0, 0, 0)); |
::CombineRgn(new_region, custom_window_region_.Get(), NULL, RGN_COPY); |
} else if (IsMaximized()) { |
HMONITOR monitor = MonitorFromWindow(hwnd(), MONITOR_DEFAULTTONEAREST); |
@@ -1144,23 +1145,22 @@ void HWNDMessageHandler::ResetWindowRegion(bool force, bool redraw) { |
GetMonitorInfo(monitor, &mi); |
RECT work_rect = mi.rcWork; |
OffsetRect(&work_rect, -window_rect.left, -window_rect.top); |
- new_region = CreateRectRgnIndirect(&work_rect); |
+ new_region.Set(CreateRectRgnIndirect(&work_rect)); |
} else { |
gfx::Path window_mask; |
delegate_->GetWindowMask(gfx::Size(window_rect.right - window_rect.left, |
window_rect.bottom - window_rect.top), |
&window_mask); |
- new_region = gfx::CreateHRGNFromSkPath(window_mask); |
+ if (!window_mask.isEmpty()) |
+ new_region.Set(gfx::CreateHRGNFromSkPath(window_mask)); |
} |
- if (current_rgn_result == ERROR || !EqualRgn(current_rgn, new_region)) { |
+ if (current_rgn_result == ERROR || |
+ new_region == NULL || |
+ !EqualRgn(current_rgn, new_region)) { |
Wez
2014/10/28 18:21:57
Ditto here re equality of NULL region.
alex-ac
2014/10/29 14:19:48
Done.
|
// SetWindowRgn takes ownership of the HRGN created by CreateNativeRegion. |
SetWindowRgn(hwnd(), new_region, redraw); |
- } else { |
- DeleteObject(new_region); |
} |
- |
- DeleteObject(current_rgn); |
} |
void HWNDMessageHandler::UpdateDwmNcRenderingPolicy() { |