Browse Source

fix: offset browserview drag regions on macOS (#27986)

Co-authored-by: Shelley Vohr <[email protected]>
trop[bot] 4 years ago
parent
commit
59951f344b
1 changed files with 7 additions and 7 deletions
  1. 7 7
      shell/browser/native_browser_view_mac.mm

+ 7 - 7
shell/browser/native_browser_view_mac.mm

@@ -299,7 +299,6 @@ void NativeBrowserViewMac::UpdateDraggableRegions(
   NSView* web_view = GetWebContents()->GetNativeView().GetNativeNSView();
   NSView* inspectable_view = iwc_view->GetNativeView().GetNativeNSView();
   NSView* window_content_view = inspectable_view.superview;
-  const auto window_content_view_height = NSHeight(window_content_view.bounds);
 
   // Remove all DragRegionViews that were added last time. Note that we need
   // to copy the `subviews` array to avoid mutation during iteration.
@@ -315,14 +314,15 @@ void NativeBrowserViewMac::UpdateDraggableRegions(
       [[DragRegionView alloc] initWithFrame:web_view.bounds]);
   [web_view addSubview:drag_region_view];
 
-  // Then, on top of that, add "exclusion zones"
+  // Then, on top of that, add "exclusion zones".
+  auto const offset = GetBounds().OffsetFromOrigin();
+  const auto window_content_view_height = NSHeight(window_content_view.bounds);
   for (const auto& rect : drag_exclude_rects) {
-    const auto window_content_view_exclude_rect =
-        NSMakeRect(rect.x(), window_content_view_height - rect.bottom(),
-                   rect.width(), rect.height());
+    const auto x = rect.x() + offset.x();
+    const auto y = window_content_view_height - rect.bottom() + offset.y();
+    const auto exclude_rect = NSMakeRect(x, y, rect.width(), rect.height());
     const auto drag_region_view_exclude_rect =
-        [window_content_view convertRect:window_content_view_exclude_rect
-                                  toView:drag_region_view];
+        [window_content_view convertRect:exclude_rect toView:drag_region_view];
 
     base::scoped_nsobject<NSView> exclude_drag_region_view(
         [[ExcludeDragRegionView alloc]