Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Unified Diff: third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp

Issue 2783723002: Keep track in the browser of which frames have onunload and onbeforeunload handlers. (Closed)
Patch Set: fix content_browsertests with plznavigate and also remove now unnecessary unloadcontroller change Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp
diff --git a/third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp b/third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp
index 222a4e02ce27fb3d427ec684553fc1c35090b7b8..b4fd3fe539ce39913ff720a61d538780bdbdfdfb 100644
--- a/third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp
+++ b/third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp
@@ -254,14 +254,6 @@ static void removeAllBeforeUnloadEventListeners(LocalDOMWindow* domWindow) {
}
}
-static bool allowsBeforeUnloadListeners(LocalDOMWindow* window) {
- DCHECK(window);
- LocalFrame* frame = window->frame();
- if (!frame)
- return false;
- return frame->isMainFrame();
-}
-
unsigned LocalDOMWindow::pendingUnloadEventListeners() const {
return windowsWithUnloadEventListeners().count(
const_cast<LocalDOMWindow*>(this));
@@ -1433,16 +1425,9 @@ void LocalDOMWindow::addedEventListener(
addUnloadEventListener(this);
} else if (eventType == EventTypeNames::beforeunload) {
UseCounter::count(document(), UseCounter::DocumentBeforeUnloadRegistered);
- if (allowsBeforeUnloadListeners(this)) {
- // This is confusingly named. It doesn't actually add the listener. It
- // just increments a count so that we know we have listeners registered
- // for the purposes of determining if we can fast terminate the renderer
- // process.
dcheng 2017/03/29 23:03:46 Nit: please keep this comment.
jam 2017/03/30 14:53:23 Done.
- addBeforeUnloadEventListener(this);
- } else {
- // Subframes return false from allowsBeforeUnloadListeners.
+ addBeforeUnloadEventListener(this);
+ if (frame() && !frame()->isMainFrame())
UseCounter::count(document(), UseCounter::SubFrameBeforeUnloadRegistered);
- }
}
}
@@ -1460,8 +1445,7 @@ void LocalDOMWindow::removedEventListener(
if (eventType == EventTypeNames::unload) {
removeUnloadEventListener(this);
- } else if (eventType == EventTypeNames::beforeunload &&
- allowsBeforeUnloadListeners(this)) {
+ } else if (eventType == EventTypeNames::beforeunload) {
removeBeforeUnloadEventListener(this);
dcheng 2017/03/29 23:03:46 This would ideally be commented too.
jam 2017/03/30 14:53:23 all 4 would need comment, to be consistent, or per
}
}

Powered by Google App Engine
This is Rietveld 408576698