feat: replace scroll-touch* with generic input-event (#35531)

This commit is contained in:
Jeremy Rose 2022-09-27 14:47:46 -05:00 committed by GitHub
parent dfb8a2d804
commit f82a863f65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 253 additions and 138 deletions

View file

@ -106,10 +106,6 @@ BrowserWindow::BrowserWindow(gin::Arguments* args,
// Associate with BrowserWindow.
web_contents->SetOwnerWindow(window());
auto* host = web_contents->web_contents()->GetRenderViewHost();
if (host)
host->GetWidget()->AddInputEventObserver(this);
InitWithArgs(args);
// Install the content view after BaseWindow's JS code is initialized.
@ -128,9 +124,6 @@ BrowserWindow::~BrowserWindow() {
if (api_web_contents_) {
// Cleanup the observers if user destroyed this instance directly instead of
// gracefully closing content::WebContents.
auto* host = web_contents()->GetRenderViewHost();
if (host)
host->GetWidget()->RemoveInputEventObserver(this);
api_web_contents_->RemoveObserver(this);
// Destroy the WebContents.
OnCloseContents();
@ -138,26 +131,6 @@ BrowserWindow::~BrowserWindow() {
}
}
void BrowserWindow::OnInputEvent(const blink::WebInputEvent& event) {
switch (event.GetType()) {
case blink::WebInputEvent::Type::kGestureScrollBegin:
case blink::WebInputEvent::Type::kGestureScrollUpdate:
case blink::WebInputEvent::Type::kGestureScrollEnd:
Emit("scroll-touch-edge");
break;
default:
break;
}
}
void BrowserWindow::RenderViewHostChanged(content::RenderViewHost* old_host,
content::RenderViewHost* new_host) {
if (old_host)
old_host->GetWidget()->RemoveInputEventObserver(this);
if (new_host)
new_host->GetWidget()->AddInputEventObserver(this);
}
void BrowserWindow::BeforeUnloadDialogCancelled() {
WindowList::WindowCloseCancelled(window());
// Cancel unresponsive event when window close is cancelled.