Skip to content

Commit

Permalink
fix: don't unnecessarily copy draggable regions (#21723)
Browse files Browse the repository at this point in the history
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.

Co-authored-by: CezaryKulakowski <50166166+CezaryKulakowski@users.noreply.github.com>
  • Loading branch information
2 people authored and zcbenz committed Jan 13, 2020
1 parent 3bd3d94 commit 7b1117e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions shell/browser/api/atom_api_browser_window_mac.mm
Expand Up @@ -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_ != &regions) {
draggable_regions_.clear();
for (const auto& r : regions)
draggable_regions_.push_back(r.Clone());
}
std::vector<gfx::Rect> drag_exclude_rects;
if (regions.empty()) {
drag_exclude_rects.push_back(gfx::Rect(0, 0, webViewWidth, webViewHeight));
Expand Down

0 comments on commit 7b1117e

Please sign in to comment.