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

Unified Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 1778753003: Fire visibilitychange event on unload (behind the flag) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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/dom/Document.cpp
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp
index a1cf59db7c956423f8e84681d2729ddb1ab74deb..fd33170772845c0d473d4491f85b908113027059 100644
--- a/third_party/WebKit/Source/core/dom/Document.cpp
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -1366,6 +1366,11 @@ PageVisibilityState Document::pageVisibilityState() const
// http://dvcs.w3.org/hg/webperf/raw-file/tip/specs/PageVisibility/Overview.html#dom-document-hidden
if (!m_frame || !m_frame->page())
return PageVisibilityStateHidden;
+ // While visibilitychange is being dispatched during unloading it is
+ // expected that the visibility is hidden regardless of the page's
+ // visibility.
+ if (m_loadEventProgress == UnloadVisibilityChangeInProgress)
+ return PageVisibilityStateHidden;
dcheng 2016/03/10 22:46:33 I think we should update pageDismissalEventBeingDi
kinuko 2016/03/11 04:13:05 Oh yeah we should. Done.
return m_frame->page()->visibilityState();
}
@@ -2779,6 +2784,17 @@ void Document::dispatchUnloadEvents()
if (!m_frame)
return;
+ PageVisibilityState visibilityState = pageVisibilityState();
+ m_loadEventProgress = UnloadVisibilityChangeInProgress;
+ if (visibilityState != PageVisibilityStateHidden && RuntimeEnabledFeatures::visibilityChangeOnUnloadEnabled()) {
+ // Dispatch visibilitychange event, but don't bother doing
+ // other notifications as we're about to be unloaded.
+ dispatchEvent(Event::createBubble(EventTypeNames::visibilitychange));
+ dispatchEvent(Event::createBubble(EventTypeNames::webkitvisibilitychange));
+ }
+ if (!m_frame)
+ return;
+
// The DocumentLoader (and thus its DocumentLoadTiming) might get destroyed
// while dispatching the event, so protect it to prevent writing the end
// time into freed memory.
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.h ('k') | third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698