From d1d8c9badd1afc9b4b0ed437fc2dfce43ff8e2f6 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 5 Jan 2021 12:14:15 +0900 Subject: [PATCH] fix: default offset when no drag regions (#27185) Co-authored-by: Shelley Vohr --- shell/browser/native_browser_view_mac.mm | 9 ++++++--- shell/browser/ui/drag_util.cc | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/shell/browser/native_browser_view_mac.mm b/shell/browser/native_browser_view_mac.mm index 406ff66bb3087..98a6f3985f720 100644 --- a/shell/browser/native_browser_view_mac.mm +++ b/shell/browser/native_browser_view_mac.mm @@ -296,11 +296,14 @@ - (void)drawRect:(NSRect)aRect { draggable_regions_ = mojo::Clone(regions); std::vector drag_exclude_rects; - if (regions.empty()) { - drag_exclude_rects.emplace_back(0, 0, webViewWidth, webViewHeight); + if (draggable_regions_.empty()) { + const auto bounds = GetBounds(); + drag_exclude_rects.emplace_back(bounds.x(), bounds.y(), webViewWidth, + webViewHeight); } else { drag_exclude_rects = CalculateNonDraggableRegions( - DraggableRegionsToSkRegion(regions), webViewWidth, webViewHeight); + DraggableRegionsToSkRegion(draggable_regions_), webViewWidth, + webViewHeight); } UpdateDraggableRegions(drag_exclude_rects); diff --git a/shell/browser/ui/drag_util.cc b/shell/browser/ui/drag_util.cc index 861f182210aa5..f90dba9193225 100644 --- a/shell/browser/ui/drag_util.cc +++ b/shell/browser/ui/drag_util.cc @@ -32,8 +32,8 @@ std::unique_ptr DraggableRegionsToSkRegion( auto sk_region = std::make_unique(); for (const auto& region : regions) { sk_region->op( - {region->bounds.x(), region->bounds.y(), region->bounds.right(), - region->bounds.bottom()}, + SkIRect::MakeLTRB(region->bounds.x(), region->bounds.y(), + region->bounds.right(), region->bounds.bottom()), region->draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); } return sk_region;