🔧 Handle offset BrowserView
This commit is contained in:
parent
47d652b5a2
commit
d913b53fea
1 changed files with 15 additions and 2 deletions
|
@ -144,8 +144,21 @@ void NativeBrowserViewMac::SetBackgroundColor(SkColor color) {
|
||||||
void NativeBrowserViewMac::UpdateDraggableRegions(
|
void NativeBrowserViewMac::UpdateDraggableRegions(
|
||||||
std::vector<gfx::Rect> system_drag_exclude_areas) {
|
std::vector<gfx::Rect> system_drag_exclude_areas) {
|
||||||
NSView* webView = GetInspectableWebContentsView()->GetNativeView();
|
NSView* webView = GetInspectableWebContentsView()->GetNativeView();
|
||||||
|
|
||||||
|
NSInteger superViewHeight = NSHeight([webView.superview bounds]);
|
||||||
NSInteger webViewHeight = NSHeight([webView bounds]);
|
NSInteger webViewHeight = NSHeight([webView bounds]);
|
||||||
NSInteger webViewWidth = NSWidth([webView bounds]);
|
NSInteger webViewWidth = NSWidth([webView bounds]);
|
||||||
|
NSInteger webViewX = NSMinX([webView frame]);
|
||||||
|
NSInteger webViewY = 0;
|
||||||
|
|
||||||
|
// Apple's NSViews have their coordinate system originate at the bottom left,
|
||||||
|
// meaning that we need to be a bit smarter when it comes to calculating our
|
||||||
|
// current top offset
|
||||||
|
if (webViewHeight > superViewHeight) {
|
||||||
|
webViewY = std::abs(webViewHeight - superViewHeight - (std::abs(NSMinY([webView frame]))));
|
||||||
|
} else {
|
||||||
|
webViewY = superViewHeight - NSMaxY([webView frame]);
|
||||||
|
}
|
||||||
|
|
||||||
// Remove all DraggableRegionViews that are added last time.
|
// Remove all DraggableRegionViews that are added last time.
|
||||||
// Note that [webView subviews] returns the view's mutable internal array and
|
// Note that [webView subviews] returns the view's mutable internal array and
|
||||||
|
@ -171,8 +184,8 @@ void NativeBrowserViewMac::UpdateDraggableRegions(
|
||||||
++iter) {
|
++iter) {
|
||||||
base::scoped_nsobject<NSView> controlRegion(
|
base::scoped_nsobject<NSView> controlRegion(
|
||||||
[[ExcludeDragRegionView alloc] initWithFrame:NSZeroRect]);
|
[[ExcludeDragRegionView alloc] initWithFrame:NSZeroRect]);
|
||||||
[controlRegion setFrame:NSMakeRect(iter->x(),
|
[controlRegion setFrame:NSMakeRect(iter->x() - webViewX,
|
||||||
webViewHeight - iter->bottom(),
|
webViewHeight - iter->bottom() + webViewY,
|
||||||
iter->width(),
|
iter->width(),
|
||||||
iter->height())];
|
iter->height())];
|
||||||
[dragRegion addSubview:controlRegion];
|
[dragRegion addSubview:controlRegion];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue