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

Unified Diff: third_party/WebKit/Source/core/html/MediaCustomControlsFullscreenDetector.cpp

Issue 2729613007: Fixing a crash in MediaCustomControlsFullscreenDetector when the page is destroyed (Closed)
Patch Set: rebased 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/html/MediaCustomControlsFullscreenDetector.cpp
diff --git a/third_party/WebKit/Source/core/html/MediaCustomControlsFullscreenDetector.cpp b/third_party/WebKit/Source/core/html/MediaCustomControlsFullscreenDetector.cpp
index 841fb64472b7914e86007c01ba0ff24f2ab8e0e8..0d5a4ae6714079a8afe8222acc4ab629f142c4c5 100644
--- a/third_party/WebKit/Source/core/html/MediaCustomControlsFullscreenDetector.cpp
+++ b/third_party/WebKit/Source/core/html/MediaCustomControlsFullscreenDetector.cpp
@@ -23,6 +23,7 @@ constexpr float kMostlyFillViewportThresholdOfVisibleProportion = 0.75f;
MediaCustomControlsFullscreenDetector::MediaCustomControlsFullscreenDetector(
HTMLVideoElement& video)
: EventListener(CPPEventListenerType),
+ ContextLifecycleObserver(nullptr),
m_videoElement(video),
m_checkViewportIntersectionTimer(
TaskRunnerHelper::get(TaskType::Unthrottled, &video.document()),
@@ -43,6 +44,7 @@ bool MediaCustomControlsFullscreenDetector::operator==(
}
void MediaCustomControlsFullscreenDetector::attach() {
+ setContext(&videoElement().document());
videoElement().document().addEventListener(
EventTypeNames::webkitfullscreenchange, this, true);
videoElement().document().addEventListener(EventTypeNames::fullscreenchange,
@@ -50,10 +52,12 @@ void MediaCustomControlsFullscreenDetector::attach() {
}
void MediaCustomControlsFullscreenDetector::detach() {
+ setContext(nullptr);
videoElement().document().removeEventListener(
EventTypeNames::webkitfullscreenchange, this, true);
videoElement().document().removeEventListener(
EventTypeNames::fullscreenchange, this, true);
+ m_checkViewportIntersectionTimer.stop();
}
bool MediaCustomControlsFullscreenDetector::computeIsDominantVideoForTests(
@@ -126,6 +130,14 @@ void MediaCustomControlsFullscreenDetector::handleEvent(
BLINK_FROM_HERE);
}
+void MediaCustomControlsFullscreenDetector::contextDestroyed(
+ ExecutionContext*) {
+ if (videoElement().webMediaPlayer())
+ videoElement().webMediaPlayer()->setIsEffectivelyFullscreen(false);
+
+ detach();
+}
+
void MediaCustomControlsFullscreenDetector::
onCheckViewportIntersectionTimerFired(TimerBase*) {
DCHECK(isVideoOrParentFullscreen());
@@ -152,6 +164,7 @@ bool MediaCustomControlsFullscreenDetector::isVideoOrParentFullscreen() {
DEFINE_TRACE(MediaCustomControlsFullscreenDetector) {
EventListener::trace(visitor);
+ ContextLifecycleObserver::trace(visitor);
visitor->trace(m_videoElement);
}

Powered by Google App Engine
This is Rietveld 408576698