From 6191e6e787825b0f0a057c77692d4da79e5c4b37 Mon Sep 17 00:00:00 2001 From: Felix Rieseberg Date: Tue, 15 Aug 2017 16:13:14 -0700 Subject: [PATCH] :wrench: Implement feedback --- atom/browser/native_browser_view.cc | 4 ---- atom/browser/native_browser_view.h | 2 +- atom/browser/native_browser_view_mac.h | 2 +- atom/browser/native_browser_view_mac.mm | 16 ++++++++-------- atom/browser/native_window_mac.mm | 2 -- 5 files changed, 10 insertions(+), 16 deletions(-) diff --git a/atom/browser/native_browser_view.cc b/atom/browser/native_browser_view.cc index ec49609751fa..949e5e9ec96d 100644 --- a/atom/browser/native_browser_view.cc +++ b/atom/browser/native_browser_view.cc @@ -15,8 +15,4 @@ NativeBrowserView::NativeBrowserView( NativeBrowserView::~NativeBrowserView() {} -void NativeBrowserView::UpdateDraggableRegions( - std::vector system_drag_exclude_areas) { -} - } // namespace atom diff --git a/atom/browser/native_browser_view.h b/atom/browser/native_browser_view.h index 69bd933151bf..d45c6326d3e6 100644 --- a/atom/browser/native_browser_view.h +++ b/atom/browser/native_browser_view.h @@ -42,7 +42,7 @@ class NativeBrowserView { // Called when the window needs to update its draggable region. virtual void UpdateDraggableRegions( - std::vector system_drag_exclude_areas); + const std::vector& system_drag_exclude_areas) {}; protected: explicit NativeBrowserView( diff --git a/atom/browser/native_browser_view_mac.h b/atom/browser/native_browser_view_mac.h index 600a3df8da2f..5d2e463eb482 100644 --- a/atom/browser/native_browser_view_mac.h +++ b/atom/browser/native_browser_view_mac.h @@ -22,7 +22,7 @@ class NativeBrowserViewMac : public NativeBrowserView { void SetAutoResizeFlags(uint8_t flags) override; void SetBounds(const gfx::Rect& bounds) override; void SetBackgroundColor(SkColor color) override; - void UpdateDraggableRegions(std::vector system_drag_exclude_areas) override; + void UpdateDraggableRegions(const std::vector& system_drag_exclude_areas) override; private: DISALLOW_COPY_AND_ASSIGN(NativeBrowserViewMac); diff --git a/atom/browser/native_browser_view_mac.mm b/atom/browser/native_browser_view_mac.mm index 31e501f6ed64..7837ad934ee8 100644 --- a/atom/browser/native_browser_view_mac.mm +++ b/atom/browser/native_browser_view_mac.mm @@ -8,8 +8,6 @@ #include "skia/ext/skia_utils_mac.h" #include "ui/gfx/geometry/rect.h" -using base::scoped_nsobject; - // Match view::Views behavior where the view sticks to the top-left origin. const NSAutoresizingMaskOptions kDefaultAutoResizingMask = NSViewMaxXMargin | NSViewMinYMargin; @@ -54,18 +52,17 @@ const NSAutoresizingMaskOptions kDefaultAutoResizingMask = return; } - NSPoint currentLocation; + NSPoint currentLocation = [NSEvent mouseLocation]; NSPoint newOrigin; NSRect screenFrame = [[NSScreen mainScreen] frame]; NSRect windowFrame = [self.window frame]; - currentLocation = [NSEvent mouseLocation]; newOrigin.x = currentLocation.x - self.initialLocation.x; newOrigin.y = currentLocation.y - self.initialLocation.y; // Don't let window get dragged up under the menu bar - if( (newOrigin.y + windowFrame.size.height) > (screenFrame.origin.y + screenFrame.size.height) ){ + if ((newOrigin.y + windowFrame.size.height) > (screenFrame.origin.y + screenFrame.size.height)) { newOrigin.y = screenFrame.origin.y + (screenFrame.size.height - windowFrame.size.height); } @@ -75,11 +72,13 @@ const NSAutoresizingMaskOptions kDefaultAutoResizingMask = // Debugging tips: // Uncomment the following four lines to color DragRegionView bright red +// #ifdef DEBUG_DRAG_REGIONS // - (void)drawRect:(NSRect)aRect // { // [[NSColor redColor] set]; // NSRectFill([self bounds]); // } +// #endif @end @@ -94,11 +93,13 @@ const NSAutoresizingMaskOptions kDefaultAutoResizingMask = // Debugging tips: // Uncomment the following four lines to color ExcludeDragRegionView bright red +// #ifdef DEBUG_DRAG_REGIONS // - (void)drawRect:(NSRect)aRect // { // [[NSColor greenColor] set]; // NSRectFill([self bounds]); // } +// #endif @end @@ -142,7 +143,7 @@ void NativeBrowserViewMac::SetBackgroundColor(SkColor color) { } void NativeBrowserViewMac::UpdateDraggableRegions( - std::vector system_drag_exclude_areas) { + const std::vector& system_drag_exclude_areas) { NSView* webView = GetInspectableWebContentsView()->GetNativeView(); NSInteger superViewHeight = NSHeight([webView.superview bounds]); @@ -178,8 +179,7 @@ void NativeBrowserViewMac::UpdateDraggableRegions( webViewHeight)]; // Then, on top of that, add "exclusion zones" - for (std::vector::const_iterator iter = - system_drag_exclude_areas.begin(); + for (auto iter = system_drag_exclude_areas.begin(); iter != system_drag_exclude_areas.end(); ++iter) { base::scoped_nsobject controlRegion( diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index fcaf04aa7616..a0af83de3574 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -1767,8 +1767,6 @@ void NativeWindowMac::UpdateDraggableRegionViews( std::vector system_drag_exclude_areas = CalculateNonDraggableRegions(regions, webViewWidth, webViewHeight); - // Call down to a BrowserView, if it exists, and inform it about the - // draggable areas if (browser_view_) { browser_view_->UpdateDraggableRegions(system_drag_exclude_areas); }