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

Side by Side Diff: third_party/WebKit/Source/web/FullscreenController.cpp

Issue 2235473002: Notify WebMediaPlayer when HTML video enters full screen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 22 matching lines...) Expand all
33 #include "core/dom/Document.h" 33 #include "core/dom/Document.h"
34 #include "core/dom/Fullscreen.h" 34 #include "core/dom/Fullscreen.h"
35 #include "core/frame/FrameView.h" 35 #include "core/frame/FrameView.h"
36 #include "core/frame/LocalFrame.h" 36 #include "core/frame/LocalFrame.h"
37 #include "core/frame/PageScaleConstraintsSet.h" 37 #include "core/frame/PageScaleConstraintsSet.h"
38 #include "core/html/HTMLMediaElement.h" 38 #include "core/html/HTMLMediaElement.h"
39 #include "core/html/HTMLVideoElement.h" 39 #include "core/html/HTMLVideoElement.h"
40 #include "platform/RuntimeEnabledFeatures.h" 40 #include "platform/RuntimeEnabledFeatures.h"
41 #include "public/platform/WebLayerTreeView.h" 41 #include "public/platform/WebLayerTreeView.h"
42 #include "public/web/WebFrameClient.h" 42 #include "public/web/WebFrameClient.h"
43 #include "third_party/WebKit/Source/core/dom/TagCollection.h"
43 #include "web/WebLocalFrameImpl.h" 44 #include "web/WebLocalFrameImpl.h"
44 #include "web/WebSettingsImpl.h" 45 #include "web/WebSettingsImpl.h"
45 #include "web/WebViewImpl.h" 46 #include "web/WebViewImpl.h"
46 47
47 namespace blink { 48 namespace blink {
48 49
49 FullscreenController* FullscreenController::create(WebViewImpl* webViewImpl) 50 FullscreenController* FullscreenController::create(WebViewImpl* webViewImpl)
50 { 51 {
51 return new FullscreenController(webViewImpl); 52 return new FullscreenController(webViewImpl);
52 } 53 }
53 54
54 FullscreenController::FullscreenController(WebViewImpl* webViewImpl) 55 FullscreenController::FullscreenController(WebViewImpl* webViewImpl)
55 : m_webViewImpl(webViewImpl) 56 : m_webViewImpl(webViewImpl)
56 , m_haveEnteredFullscreen(false) 57 , m_haveEnteredFullscreen(false)
57 , m_exitFullscreenPageScaleFactor(0) 58 , m_exitFullscreenPageScaleFactor(0)
58 , m_needsScrollAndScaleRestore(false) 59 , m_needsScrollAndScaleRestore(false)
59 , m_isCancelingFullScreen(false) 60 , m_isCancelingFullScreen(false)
60 { 61 {
61 } 62 }
62 63
64 // Notify the current media element or all its child media elements when
65 // the |element| enters/exits full screen.
66 void FullscreenController::updateMediaInFullscreen(Element* element, bool isFull screen)
67 {
68 if (!element)
69 return;
70 if (isHTMLMediaElement(element)) {
71 toHTMLMediaElement(element)->updateMediaInFullscreen(isFullscreen);
72 } else {
73 TagCollection* collection = element->getElementsByTagName("video");
fs 2016/08/10 17:30:13 Drive-by: You should be able to do: for (HTMLVide
xjz 2016/08/10 21:33:29 Thanks for the review! I'll address it in the next
74 for (unsigned i = 0; i < collection->length(); ++i) {
75 Element* childElement = collection->item(i);
76 if (!isHTMLMediaElement(childElement))
77 continue;
78 toHTMLMediaElement(childElement)->updateMediaInFullscreen(isFullscre en);
79 }
80 }
81 }
82
63 void FullscreenController::didEnterFullscreen() 83 void FullscreenController::didEnterFullscreen()
64 { 84 {
65 if (!m_provisionalFullScreenElement) 85 if (!m_provisionalFullScreenElement)
66 return; 86 return;
67 87
68 Element* element = m_provisionalFullScreenElement.release(); 88 Element* element = m_provisionalFullScreenElement.release();
69 Document& document = element->document(); 89 Document& document = element->document();
70 m_fullScreenFrame = document.frame(); 90 m_fullScreenFrame = document.frame();
71 91
72 if (!m_fullScreenFrame) 92 if (!m_fullScreenFrame)
73 return; 93 return;
74 94
75 if (!m_haveEnteredFullscreen) { 95 if (!m_haveEnteredFullscreen) {
76 updatePageScaleConstraints(false); 96 updatePageScaleConstraints(false);
77 m_webViewImpl->setPageScaleFactor(1.0f); 97 m_webViewImpl->setPageScaleFactor(1.0f);
78 if (m_webViewImpl->mainFrame()->isWebLocalFrame()) 98 if (m_webViewImpl->mainFrame()->isWebLocalFrame())
79 m_webViewImpl->mainFrame()->setScrollOffset(WebSize()); 99 m_webViewImpl->mainFrame()->setScrollOffset(WebSize());
80 m_webViewImpl->setVisualViewportOffset(FloatPoint()); 100 m_webViewImpl->setVisualViewportOffset(FloatPoint());
81 m_haveEnteredFullscreen = true; 101 m_haveEnteredFullscreen = true;
82 } 102 }
83 103
84 Fullscreen::from(document).didEnterFullscreenForElement(element); 104 Fullscreen::from(document).didEnterFullscreenForElement(element);
85 DCHECK_EQ(Fullscreen::currentFullScreenElementFrom(document), element); 105 DCHECK_EQ(Fullscreen::currentFullScreenElementFrom(document), element);
86 106
107 updateMediaInFullscreen(element, true);
87 if (isHTMLVideoElement(element)) { 108 if (isHTMLVideoElement(element)) {
88 HTMLVideoElement* videoElement = toHTMLVideoElement(element); 109 HTMLVideoElement* videoElement = toHTMLVideoElement(element);
89 if (videoElement->usesOverlayFullscreenVideo() && m_webViewImpl->layerTr eeView()) 110 if (videoElement->usesOverlayFullscreenVideo() && m_webViewImpl->layerTr eeView())
90 m_webViewImpl->layerTreeView()->setHasTransparentBackground(true); 111 m_webViewImpl->layerTreeView()->setHasTransparentBackground(true);
91 } 112 }
92 } 113 }
93 114
94 void FullscreenController::didExitFullscreen() 115 void FullscreenController::didExitFullscreen()
95 { 116 {
96 if (!m_fullScreenFrame) 117 if (!m_fullScreenFrame)
(...skipping 15 matching lines...) Expand all
112 // If the video used overlay fullscreen mode, the background was made transparent. Restore the transparency. 133 // If the video used overlay fullscreen mode, the background was made transparent. Restore the transparency.
113 if (isHTMLVideoElement(element) && m_webViewImpl->layerTreeView( )) 134 if (isHTMLVideoElement(element) && m_webViewImpl->layerTreeView( ))
114 m_webViewImpl->layerTreeView()->setHasTransparentBackground( m_webViewImpl->isTransparent()); 135 m_webViewImpl->layerTreeView()->setHasTransparentBackground( m_webViewImpl->isTransparent());
115 136
116 // We need to wait until style and layout are updated in order 137 // We need to wait until style and layout are updated in order
117 // to propertly restore scroll offsets since content may not be 138 // to propertly restore scroll offsets since content may not be
118 // overflowing in the same way until they do. 139 // overflowing in the same way until they do.
119 if (m_haveEnteredFullscreen) 140 if (m_haveEnteredFullscreen)
120 m_needsScrollAndScaleRestore = true; 141 m_needsScrollAndScaleRestore = true;
121 142
143 updateMediaInFullscreen(element, false);
122 fullscreen->didExitFullscreen(); 144 fullscreen->didExitFullscreen();
123 } 145 }
124 } 146 }
125 } 147 }
126 148
127 m_haveEnteredFullscreen = false; 149 m_haveEnteredFullscreen = false;
128 m_fullScreenFrame.clear(); 150 m_fullScreenFrame.clear();
129 } 151 }
130 152
131 void FullscreenController::enterFullScreenForElement(Element* element) 153 void FullscreenController::enterFullScreenForElement(Element* element)
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 m_webViewImpl->updateMainFrameLayoutSize(); 263 m_webViewImpl->updateMainFrameLayoutSize();
242 } 264 }
243 265
244 DEFINE_TRACE(FullscreenController) 266 DEFINE_TRACE(FullscreenController)
245 { 267 {
246 visitor->trace(m_provisionalFullScreenElement); 268 visitor->trace(m_provisionalFullScreenElement);
247 visitor->trace(m_fullScreenFrame); 269 visitor->trace(m_fullScreenFrame);
248 } 270 }
249 271
250 } // namespace blink 272 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698