refactor: move draggable regions to WebContents (#36230)

This commit is contained in:
Jeremy Rose 2022-11-07 10:15:57 -08:00 committed by GitHub
parent 2008c9a5d0
commit 184ac2b382
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 96 additions and 202 deletions

View file

@ -14,6 +14,8 @@
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/node_includes.h"
#include "third_party/skia/include/core/SkRegion.h"
#include "ui/base/hit_test.h"
#if BUILDFLAG(IS_MAC)
#include "shell/browser/ui/cocoa/delayed_native_view_host.h"
@ -50,6 +52,15 @@ gin::Handle<WebContents> WebContentsView::GetWebContents(v8::Isolate* isolate) {
return gin::CreateHandle(isolate, api_web_contents_);
}
int WebContentsView::NonClientHitTest(const gfx::Point& point) {
gfx::Point local_point(point);
views::View::ConvertPointFromWidget(view(), &local_point);
SkRegion* region = api_web_contents_->draggable_region();
if (region && region->contains(local_point.x(), local_point.y()))
return HTCAPTION;
return HTNOWHERE;
}
void WebContentsView::WebContentsDestroyed() {
api_web_contents_ = nullptr;
web_contents_.Reset();