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

Unified Diff: third_party/WebKit/Source/web/FullscreenController.cpp

Issue 2530883002: Refactor overlay fullscreen video handling into a single callback (Closed)
Patch Set: rebase Created 4 years, 1 month 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/web/FullscreenController.h ('k') | third_party/WebKit/Source/web/WebViewImpl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/FullscreenController.cpp
diff --git a/third_party/WebKit/Source/web/FullscreenController.cpp b/third_party/WebKit/Source/web/FullscreenController.cpp
index a3e15c9c45f353105a29b71be725fb183eba58b8..09e664a31adbfe5bcc0c31aec95d99c9fb382704 100644
--- a/third_party/WebKit/Source/web/FullscreenController.cpp
+++ b/third_party/WebKit/Source/web/FullscreenController.cpp
@@ -35,7 +35,6 @@
#include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/PageScaleConstraintsSet.h"
-#include "core/html/HTMLMediaElement.h"
#include "core/html/HTMLVideoElement.h"
#include "core/layout/LayoutFullScreen.h"
#include "platform/RuntimeEnabledFeatures.h"
@@ -80,13 +79,6 @@ void FullscreenController::didEnterFullscreen() {
Fullscreen::from(document).didEnterFullscreenForElement(element);
DCHECK_EQ(Fullscreen::currentFullScreenElementFrom(document), element);
-
- if (isHTMLVideoElement(element)) {
- HTMLVideoElement* videoElement = toHTMLVideoElement(element);
- if (videoElement->usesOverlayFullscreenVideo() &&
- m_webViewImpl->layerTreeView())
- m_webViewImpl->layerTreeView()->setHasTransparentBackground(true);
- }
}
void FullscreenController::didExitFullscreen() {
@@ -107,12 +99,6 @@ void FullscreenController::didExitFullscreen() {
Fullscreen::fullyExitFullscreen(*document);
m_isCancelingFullscreen = false;
- // If the video used overlay fullscreen mode, the background was made
- // transparent. Restore the transparency.
- if (isHTMLVideoElement(element) && m_webViewImpl->layerTreeView())
- m_webViewImpl->layerTreeView()->setHasTransparentBackground(
- m_webViewImpl->isTransparent());
-
// We need to wait until style and layout are updated in order
// to propertly restore scroll offsets since content may not be
// overflowing in the same way until they do.
@@ -179,6 +165,42 @@ void FullscreenController::exitFullscreen(LocalFrame* frame) {
webFrame->client()->exitFullscreen();
}
+void FullscreenController::fullscreenElementChanged(Element* fromElement,
+ Element* toElement) {
+ DCHECK_NE(fromElement, toElement);
+
+ if (toElement) {
+ DCHECK(Fullscreen::isCurrentFullScreenElement(*toElement));
+
+ if (isHTMLVideoElement(*toElement)) {
+ HTMLVideoElement& videoElement = toHTMLVideoElement(*toElement);
+ videoElement.didEnterFullscreen();
+
+ // If the video uses overlay fullscreen mode, make the background
+ // transparent.
+ if (videoElement.usesOverlayFullscreenVideo() &&
+ m_webViewImpl->layerTreeView()) {
+ m_webViewImpl->layerTreeView()->setHasTransparentBackground(true);
+ }
+ }
+ }
+
+ if (fromElement) {
+ DCHECK(!Fullscreen::isCurrentFullScreenElement(*fromElement));
+
+ if (isHTMLVideoElement(*fromElement)) {
+ // If the video used overlay fullscreen mode, restore the transparency.
+ if (m_webViewImpl->layerTreeView()) {
+ m_webViewImpl->layerTreeView()->setHasTransparentBackground(
+ m_webViewImpl->isTransparent());
+ }
+
+ HTMLVideoElement& videoElement = toHTMLVideoElement(*fromElement);
+ videoElement.didExitFullscreen();
+ }
+ }
+}
+
void FullscreenController::updateSize() {
if (!isFullscreen())
return;
« no previous file with comments | « third_party/WebKit/Source/web/FullscreenController.h ('k') | third_party/WebKit/Source/web/WebViewImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698