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

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

Issue 22454003: Support subtitles for native fullscreen video (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebased Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RenderObject.h ('k') | Source/web/WebMediaPlayerClientImpl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "FullscreenController.h" 32 #include "FullscreenController.h"
33 33
34 #include "RuntimeEnabledFeatures.h"
34 #include "WebFrame.h" 35 #include "WebFrame.h"
35 #include "WebViewClient.h" 36 #include "WebViewClient.h"
36 #include "WebViewImpl.h" 37 #include "WebViewImpl.h"
37 #include "core/dom/Document.h" 38 #include "core/dom/Document.h"
38 #include "core/dom/FullscreenElementStack.h" 39 #include "core/dom/FullscreenElementStack.h"
39 #include "core/html/HTMLMediaElement.h" 40 #include "core/html/HTMLMediaElement.h"
40 #include "core/page/Frame.h" 41 #include "core/page/Frame.h"
42 #include "core/platform/LayoutTestSupport.h"
41 43
42 using namespace WebCore; 44 using namespace WebCore;
43 45
44 namespace WebKit { 46 namespace WebKit {
45 47
46 PassOwnPtr<FullscreenController> FullscreenController::create(WebViewImpl* webVi ewImpl) 48 PassOwnPtr<FullscreenController> FullscreenController::create(WebViewImpl* webVi ewImpl)
47 { 49 {
48 return adoptPtr(new FullscreenController(webViewImpl)); 50 return adoptPtr(new FullscreenController(webViewImpl));
49 } 51 }
50 52
(...skipping 25 matching lines...) Expand all
76 78
77 if (Document* doc = m_fullScreenFrame->document()) { 79 if (Document* doc = m_fullScreenFrame->document()) {
78 if (FullscreenElementStack::isFullScreen(doc)) { 80 if (FullscreenElementStack::isFullScreen(doc)) {
79 if (!m_exitFullscreenPageScaleFactor) { 81 if (!m_exitFullscreenPageScaleFactor) {
80 m_exitFullscreenPageScaleFactor = m_webViewImpl->pageScaleFactor (); 82 m_exitFullscreenPageScaleFactor = m_webViewImpl->pageScaleFactor ();
81 m_exitFullscreenScrollOffset = m_webViewImpl->mainFrame()->scrol lOffset(); 83 m_exitFullscreenScrollOffset = m_webViewImpl->mainFrame()->scrol lOffset();
82 m_webViewImpl->setPageScaleFactorPreservingScrollOffset(1.0f); 84 m_webViewImpl->setPageScaleFactorPreservingScrollOffset(1.0f);
83 } 85 }
84 86
85 FullscreenElementStack::from(doc)->webkitDidEnterFullScreenForElemen t(0); 87 FullscreenElementStack::from(doc)->webkitDidEnterFullScreenForElemen t(0);
88 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled()) {
89 Element* element = FullscreenElementStack::currentFullScreenElem entFrom(doc);
90 ASSERT(element);
91 if (element->isMediaElement() && m_webViewImpl->layerTreeView())
92 m_webViewImpl->layerTreeView()->setHasTransparentBackground( true);
93 }
86 } 94 }
87 } 95 }
88 } 96 }
89 97
90 void FullscreenController::willExitFullScreen() 98 void FullscreenController::willExitFullScreen()
91 { 99 {
92 if (!m_fullScreenFrame) 100 if (!m_fullScreenFrame)
93 return; 101 return;
94 102
95 if (Document* doc = m_fullScreenFrame->document()) { 103 if (Document* doc = m_fullScreenFrame->document()) {
96 FullscreenElementStack* fullscreen = FullscreenElementStack::fromIfExist s(doc); 104 FullscreenElementStack* fullscreen = FullscreenElementStack::fromIfExist s(doc);
97 if (!fullscreen) 105 if (!fullscreen)
98 return; 106 return;
99 if (fullscreen->isFullScreen(doc)) { 107 if (fullscreen->isFullScreen(doc)) {
100 // When the client exits from full screen we have to call webkitCanc elFullScreen to 108 // When the client exits from full screen we have to call webkitCanc elFullScreen to
101 // notify the document. While doing that, suppress notifications bac k to the client. 109 // notify the document. While doing that, suppress notifications bac k to the client.
102 m_isCancelingFullScreen = true; 110 m_isCancelingFullScreen = true;
103 fullscreen->webkitCancelFullScreen(); 111 fullscreen->webkitCancelFullScreen();
104 m_isCancelingFullScreen = false; 112 m_isCancelingFullScreen = false;
105 fullscreen->webkitWillExitFullScreenForElement(0); 113 fullscreen->webkitWillExitFullScreenForElement(0);
114 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && m_web ViewImpl->layerTreeView())
115 m_webViewImpl->layerTreeView()->setHasTransparentBackground(m_we bViewImpl->isTransparent());
106 } 116 }
107 } 117 }
108 } 118 }
109 119
110 void FullscreenController::didExitFullScreen() 120 void FullscreenController::didExitFullScreen()
111 { 121 {
112 if (!m_fullScreenFrame) 122 if (!m_fullScreenFrame)
113 return; 123 return;
114 124
115 if (Document* doc = m_fullScreenFrame->document()) { 125 if (Document* doc = m_fullScreenFrame->document()) {
(...skipping 23 matching lines...) Expand all
139 } 149 }
140 150
141 // We are already in fullscreen mode. 151 // We are already in fullscreen mode.
142 if (m_fullScreenFrame) { 152 if (m_fullScreenFrame) {
143 m_provisionalFullScreenElement = element; 153 m_provisionalFullScreenElement = element;
144 willEnterFullScreen(); 154 willEnterFullScreen();
145 didEnterFullScreen(); 155 didEnterFullScreen();
146 return; 156 return;
147 } 157 }
148 158
149 #if USE(NATIVE_FULLSCREEN_VIDEO) 159 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled()
150 if (element && element->isMediaElement()) { 160 && element && element->isMediaElement()
161 // FIXME: There is no embedder-side handling in layout test mode.
162 && !isRunningLayoutTest()) {
151 HTMLMediaElement* mediaElement = toHTMLMediaElement(element); 163 HTMLMediaElement* mediaElement = toHTMLMediaElement(element);
152 if (mediaElement->player() && mediaElement->player()->canEnterFullscreen ()) { 164 if (mediaElement->player() && mediaElement->player()->canShowFullscreenO verlay()) {
153 mediaElement->player()->enterFullscreen(); 165 mediaElement->player()->showFullscreenOverlay();
154 m_provisionalFullScreenElement = element; 166 m_provisionalFullScreenElement = element;
167 return;
155 } 168 }
156 return;
157 } 169 }
158 #endif
159 170
160 // We need to transition to fullscreen mode. 171 // We need to transition to fullscreen mode.
161 if (WebViewClient* client = m_webViewImpl->client()) { 172 if (WebViewClient* client = m_webViewImpl->client()) {
162 if (client->enterFullScreen()) 173 if (client->enterFullScreen())
163 m_provisionalFullScreenElement = element; 174 m_provisionalFullScreenElement = element;
164 } 175 }
165 } 176 }
166 177
167 void FullscreenController::exitFullScreenForElement(WebCore::Element* element) 178 void FullscreenController::exitFullScreenForElement(WebCore::Element* element)
168 { 179 {
169 // The client is exiting full screen, so don't send a notification. 180 // The client is exiting full screen, so don't send a notification.
170 if (m_isCancelingFullScreen) 181 if (m_isCancelingFullScreen)
171 return; 182 return;
172 #if USE(NATIVE_FULLSCREEN_VIDEO) 183 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled()
173 if (element && element->isMediaElement()) { 184 && element && element->isMediaElement()
185 // FIXME: There is no embedder-side handling in layout test mode.
186 && !isRunningLayoutTest()) {
174 HTMLMediaElement* mediaElement = toHTMLMediaElement(element); 187 HTMLMediaElement* mediaElement = toHTMLMediaElement(element);
175 if (mediaElement->player()) 188 if (mediaElement->player())
176 mediaElement->player()->exitFullscreen(); 189 mediaElement->player()->hideFullscreenOverlay();
177 return; 190 return;
178 } 191 }
179 #endif
180 if (WebViewClient* client = m_webViewImpl->client()) 192 if (WebViewClient* client = m_webViewImpl->client())
181 client->exitFullScreen(); 193 client->exitFullScreen();
182 } 194 }
183 195
184 } 196 }
185 197
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderObject.h ('k') | Source/web/WebMediaPlayerClientImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698