From 17baae55e03f5ab3cad3fe40e6743cfa25131fca Mon Sep 17 00:00:00 2001 From: Cezary Kulakowski Date: Wed, 8 Jan 2020 10:21:04 -0500 Subject: [PATCH] fix: don't unnecessarily copy draggable regions In some calls to `BrowserWindow::UpdateDraggableRegions` the parameter `regions` points to object's variable `draggable_regions_` which we later try to update with data received in the parameter. In these cases coping is unnecessary. Additionally after this code is executed `draggable_regions_` would be empty and as a result whole window would be undraggable. --- shell/browser/api/atom_api_browser_window_mac.mm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/shell/browser/api/atom_api_browser_window_mac.mm b/shell/browser/api/atom_api_browser_window_mac.mm index 08dd00ed62f4e..8d0108d2f263c 100644 --- a/shell/browser/api/atom_api_browser_window_mac.mm +++ b/shell/browser/api/atom_api_browser_window_mac.mm @@ -101,9 +101,11 @@ - (NSView*)hitTest:(NSPoint)aPoint { // Draggable regions is implemented by having the whole web view draggable // (mouseDownCanMoveWindow) and overlaying regions that are not draggable. - draggable_regions_.clear(); - for (const auto& r : regions) - draggable_regions_.push_back(r.Clone()); + if (&draggable_regions_ != ®ions) { + draggable_regions_.clear(); + for (const auto& r : regions) + draggable_regions_.push_back(r.Clone()); + } std::vector drag_exclude_rects; if (regions.empty()) { drag_exclude_rects.push_back(gfx::Rect(0, 0, webViewWidth, webViewHeight));