🔧 Implement feedback

This commit is contained in:
Felix Rieseberg 2017-08-15 16:13:14 -07:00
parent b4bb00843b
commit 6191e6e787
5 changed files with 10 additions and 16 deletions

View file

@ -15,8 +15,4 @@ NativeBrowserView::NativeBrowserView(
NativeBrowserView::~NativeBrowserView() {}
void NativeBrowserView::UpdateDraggableRegions(
std::vector<gfx::Rect> system_drag_exclude_areas) {
}
} // namespace atom

View file

@ -42,7 +42,7 @@ class NativeBrowserView {
// Called when the window needs to update its draggable region.
virtual void UpdateDraggableRegions(
std::vector<gfx::Rect> system_drag_exclude_areas);
const std::vector<gfx::Rect>& system_drag_exclude_areas) {};
protected:
explicit NativeBrowserView(

View file

@ -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<gfx::Rect> system_drag_exclude_areas) override;
void UpdateDraggableRegions(const std::vector<gfx::Rect>& system_drag_exclude_areas) override;
private:
DISALLOW_COPY_AND_ASSIGN(NativeBrowserViewMac);

View file

@ -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<gfx::Rect> system_drag_exclude_areas) {
const std::vector<gfx::Rect>& 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<gfx::Rect>::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<NSView> controlRegion(

View file

@ -1767,8 +1767,6 @@ void NativeWindowMac::UpdateDraggableRegionViews(
std::vector<gfx::Rect> 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);
}