From a9a02a9a9508dc51d07dac7352545f03012c6824 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Mon, 30 Nov 2020 16:56:54 -0800 Subject: [PATCH] Tidy up bounds snapping --- shell/browser/native_browser_view_views.cc | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/shell/browser/native_browser_view_views.cc b/shell/browser/native_browser_view_views.cc index 22cc5e154d3a2..6869093de3ca0 100644 --- a/shell/browser/native_browser_view_views.cc +++ b/shell/browser/native_browser_view_views.cc @@ -36,15 +36,11 @@ void NativeBrowserViewViews::UpdateDraggableRegions( // y-value of each of the passed regions or it will be incorrectly // assumed that the regions begin in the top left corner as they // would for the main client window. - std::vector snapped_regions; - auto bounds = GetBounds(); - for (const auto& r : regions) { - auto region = mojom::DraggableRegion::New(); - region->bounds = - gfx::Rect(r->bounds.x() + bounds.x(), r->bounds.y() + bounds.y(), - r->bounds.width(), r->bounds.height()); - region->draggable = true; - snapped_regions.push_back(std::move(region)); + auto const offset = GetBounds().OffsetFromOrigin(); + auto snapped_regions = mojo::Clone(regions); + for (auto& snapped_region : snapped_regions) { + snapped_region->bounds.Offset(offset); + snapped_region->draggable = true; } draggable_region_ = DraggableRegionsToSkRegion(snapped_regions);