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

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

Issue 2743573003: Fix an issue in fullscreen detector when context is destroyed (Closed)
Patch Set: addressed nits 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
« no previous file with comments | « third_party/WebKit/Source/core/html/MediaCustomControlsFullscreenDetector.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 0d5a4ae6714079a8afe8222acc4ab629f142c4c5..39e9ee874369b1bcf003372bed0d6f83a6eba6a0 100644
--- a/third_party/WebKit/Source/core/html/MediaCustomControlsFullscreenDetector.cpp
+++ b/third_party/WebKit/Source/core/html/MediaCustomControlsFullscreenDetector.cpp
@@ -23,7 +23,6 @@ constexpr float kMostlyFillViewportThresholdOfVisibleProportion = 0.75f;
MediaCustomControlsFullscreenDetector::MediaCustomControlsFullscreenDetector(
HTMLVideoElement& video)
: EventListener(CPPEventListenerType),
- ContextLifecycleObserver(nullptr),
m_videoElement(video),
m_checkViewportIntersectionTimer(
TaskRunnerHelper::get(TaskType::Unthrottled, &video.document()),
@@ -44,7 +43,6 @@ bool MediaCustomControlsFullscreenDetector::operator==(
}
void MediaCustomControlsFullscreenDetector::attach() {
- setContext(&videoElement().document());
videoElement().document().addEventListener(
EventTypeNames::webkitfullscreenchange, this, true);
videoElement().document().addEventListener(EventTypeNames::fullscreenchange,
@@ -52,12 +50,14 @@ 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();
+
+ if (videoElement().webMediaPlayer())
+ videoElement().webMediaPlayer()->setIsEffectivelyFullscreen(false);
}
bool MediaCustomControlsFullscreenDetector::computeIsDominantVideoForTests(
@@ -130,11 +130,11 @@ void MediaCustomControlsFullscreenDetector::handleEvent(
BLINK_FROM_HERE);
}
-void MediaCustomControlsFullscreenDetector::contextDestroyed(
- ExecutionContext*) {
- if (videoElement().webMediaPlayer())
- videoElement().webMediaPlayer()->setIsEffectivelyFullscreen(false);
-
+void MediaCustomControlsFullscreenDetector::contextDestroyed() {
+ // This method is called by HTMLVideoElement when it observes context destroy.
+ // The reason is that when HTMLMediaElement observes context destroy, it will
+ // destroy webMediaPlayer() thus the final setIsEffectivelyFullscreen(false)
+ // is not called.
detach();
}
@@ -164,7 +164,6 @@ bool MediaCustomControlsFullscreenDetector::isVideoOrParentFullscreen() {
DEFINE_TRACE(MediaCustomControlsFullscreenDetector) {
EventListener::trace(visitor);
- ContextLifecycleObserver::trace(visitor);
visitor->trace(m_videoElement);
}
« no previous file with comments | « third_party/WebKit/Source/core/html/MediaCustomControlsFullscreenDetector.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698