Make BrowserView DragRegionViews children of the WebContents view
Previously they were children of the `InspectableWebContentsView` view,
which caused this assertion to fail:
f993888424/brightray/browser/mac/bry_inspectable_web_contents_view.mm (L162)
This commit is contained in:
parent
3b8ddd0997
commit
42934a1006
3 changed files with 10 additions and 3 deletions
|
@ -22,4 +22,8 @@ NativeBrowserView::GetInspectableWebContentsView() {
|
||||||
return inspectable_web_contents_->GetView();
|
return inspectable_web_contents_->GetView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
content::WebContents* NativeBrowserView::GetWebContents() {
|
||||||
|
return inspectable_web_contents_->GetWebContents();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include "atom/common/draggable_region.h"
|
#include "atom/common/draggable_region.h"
|
||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
|
#include "content/public/browser/web_contents.h"
|
||||||
#include "third_party/skia/include/core/SkColor.h"
|
#include "third_party/skia/include/core/SkColor.h"
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
@ -39,6 +40,7 @@ class NativeBrowserView {
|
||||||
}
|
}
|
||||||
|
|
||||||
brightray::InspectableWebContentsView* GetInspectableWebContentsView();
|
brightray::InspectableWebContentsView* GetInspectableWebContentsView();
|
||||||
|
content::WebContents* GetWebContents();
|
||||||
|
|
||||||
virtual void SetAutoResizeFlags(uint8_t flags) = 0;
|
virtual void SetAutoResizeFlags(uint8_t flags) = 0;
|
||||||
virtual void SetBounds(const gfx::Rect& bounds) = 0;
|
virtual void SetBounds(const gfx::Rect& bounds) = 0;
|
||||||
|
|
|
@ -195,13 +195,14 @@ void NativeBrowserViewMac::SetBackgroundColor(SkColor color) {
|
||||||
|
|
||||||
void NativeBrowserViewMac::UpdateDraggableRegions(
|
void NativeBrowserViewMac::UpdateDraggableRegions(
|
||||||
const std::vector<gfx::Rect>& drag_exclude_rects) {
|
const std::vector<gfx::Rect>& drag_exclude_rects) {
|
||||||
|
NSView* web_view = GetWebContents()->GetNativeView();
|
||||||
NSView* inspectable_view = GetInspectableWebContentsView()->GetNativeView();
|
NSView* inspectable_view = GetInspectableWebContentsView()->GetNativeView();
|
||||||
NSView* window_content_view = inspectable_view.superview;
|
NSView* window_content_view = inspectable_view.superview;
|
||||||
const auto window_content_view_height = NSHeight(window_content_view.bounds);
|
const auto window_content_view_height = NSHeight(window_content_view.bounds);
|
||||||
|
|
||||||
// Remove all DragRegionViews that were added last time. Note that we need
|
// Remove all DragRegionViews that were added last time. Note that we need
|
||||||
// to copy the `subviews` array to avoid mutation during iteration.
|
// to copy the `subviews` array to avoid mutation during iteration.
|
||||||
base::scoped_nsobject<NSArray> subviews([[inspectable_view subviews] copy]);
|
base::scoped_nsobject<NSArray> subviews([[web_view subviews] copy]);
|
||||||
for (NSView* subview in subviews.get()) {
|
for (NSView* subview in subviews.get()) {
|
||||||
if ([subview isKindOfClass:[DragRegionView class]]) {
|
if ([subview isKindOfClass:[DragRegionView class]]) {
|
||||||
[subview removeFromSuperview];
|
[subview removeFromSuperview];
|
||||||
|
@ -210,8 +211,8 @@ void NativeBrowserViewMac::UpdateDraggableRegions(
|
||||||
|
|
||||||
// Create one giant NSView that is draggable.
|
// Create one giant NSView that is draggable.
|
||||||
base::scoped_nsobject<NSView> drag_region_view(
|
base::scoped_nsobject<NSView> drag_region_view(
|
||||||
[[DragRegionView alloc] initWithFrame:inspectable_view.bounds]);
|
[[DragRegionView alloc] initWithFrame:web_view.bounds]);
|
||||||
[inspectable_view addSubview:drag_region_view];
|
[web_view addSubview:drag_region_view];
|
||||||
|
|
||||||
// Then, on top of that, add "exclusion zones"
|
// Then, on top of that, add "exclusion zones"
|
||||||
for (const auto& rect : drag_exclude_rects) {
|
for (const auto& rect : drag_exclude_rects) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue