8000 chore: Move draggable regions implementation from NativeBrowserView into InspectableWebContentsView by daniel-koc · Pull Request #35007 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chore 8000 : Move draggable regions implementation from NativeBrowserView into InspectableWebContentsView #35007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions filenames.gni
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ filenames = {
"shell/browser/ui/inspectable_web_contents.cc",
"shell/browser/ui/inspectable_web_contents.h",
"shell/browser/ui/inspectable_web_contents_delegate.h",
"shell/browser/ui/inspectable_web_contents_view.cc",
"shell/browser/ui/inspectable_web_contents_view.h",
"shell/browser/ui/inspectable_web_contents_view_delegate.cc",
"shell/browser/ui/inspectable_web_contents_view_delegate.h",
Expand Down
14 changes: 13 additions & 1 deletion shell/browser/api/electron_api_browser_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,16 @@ void BrowserView::SetOwnerWindow(BaseWindow* window) {
if (web_contents())
web_contents()->SetOwnerWindow(window ? window->window() : nullptr);

if (owner_window_.get()) {
owner_window_->window()->remove_inspectable_view(
view_->GetInspectableWebContentsView());
}

owner_window_ = window ? window->GetWeakPtr() : nullptr;

if (owner_window_.get() && view_->GetInspectableWebContentsView())
owner_window_->window()->add_inspectable_view(
view_->GetInspectableWebContentsView());
}

BrowserView::~BrowserView() {
Expand All @@ -123,7 +132,10 @@ void BrowserView::WebContentsDestroyed() {

void BrowserView::OnDraggableRegionsUpdated(
const std::vector<mojom::DraggableRegionPtr>& regions) {
view_->UpdateDraggableRegions(regions);
InspectableWebContentsView* iwc_view = view_->GetInspectableWebContentsView();
if (!iwc_view)
return;
iwc_view->UpdateDraggableRegions(regions);
}

// static
Expand Down
4 changes: 2 additions & 2 deletions shell/browser/api/electron_api_browser_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ void BrowserWindow::OnCloseButtonClicked(bool* prevent_default) {
api_web_contents_->NotifyUserActivation();

// Trigger beforeunload events for associated BrowserViews.
for (NativeBrowserView* view : window_->browser_views()) {
auto* vwc = view->web_contents();
for (InspectableWebContentsView* view : window_->inspectable_views()) {
auto* vwc = view->inspectable_web_contents()->GetWebContents();
auto* api_web_contents = api::WebContents::From(vwc);

// Required to make beforeunload handler work.
Expand Down
13 changes: 0 additions & 13 deletions shell/browser/native_browser_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "shell/common/api/api.mojom.h"
#include "third_party/skia/include/core/SkColor.h"

namespace gfx {
Expand Down Expand Up @@ -43,31 +42,19 @@ class NativeBrowserView : public content::WebContentsObserver {
return inspectable_web_contents_;
}

const std::vector<mojom::DraggableRegionPtr>& GetDraggableRegions() const {
return draggable_regions_;
}

InspectableWebContentsView* GetInspectableWebContentsView();

virtual void SetAutoResizeFlags(uint8_t flags) = 0;
virtual void SetBounds(const gfx::Rect& bounds) = 0;
virtual gfx::Rect GetBounds() = 0;
virtual void SetBackgroundColor(SkColor color) = 0;

virtual void UpdateDraggableRegions(
const std::vector<gfx::Rect>& drag_exclude_rects) {}

// Called when the window needs to update its draggable region.
virtual void UpdateDraggableRegions(
const std::vector<mojom::DraggableRegionPtr>& regions) {}

protected:
explicit NativeBrowserView(InspectableWebContents* inspectable_web_contents);
// content::WebContentsObserver:
void WebContentsDestroyed() override;

InspectableWebContents* inspectable_web_contents_;
std::vector<mojom::DraggableRegionPtr> draggable_regions_;
};

} // namespace electron
Expand Down
6 changes: 0 additions & 6 deletions shell/browser/native_browser_view_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ class NativeBrowserViewMac : public NativeBrowserView {
void SetBounds(const gfx::Rect& bounds) override;
gfx::Rect GetBounds() override;
void SetBackgroundColor(SkColor color) override;

void UpdateDraggableRegions(
const std::vector<mojom::DraggableRegionPtr>& regions) override;

void UpdateDraggableRegions(
const std::vector<gfx::Rect>& drag_exclude_rects) override;
};

} // namespace electron
Expand Down
Loading
0