OLD | NEW |
---|---|
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 19 matching lines...) Expand all Loading... | |
30 | 30 |
31 #include "web/FullscreenController.h" | 31 #include "web/FullscreenController.h" |
32 | 32 |
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/LayoutTestSupport.h" | |
40 #include "platform/RuntimeEnabledFeatures.h" | 41 #include "platform/RuntimeEnabledFeatures.h" |
41 #include "public/platform/WebLayerTreeView.h" | 42 #include "public/platform/WebLayerTreeView.h" |
42 #include "public/web/WebFrameClient.h" | 43 #include "public/web/WebFrameClient.h" |
44 #include "third_party/WebKit/Source/core/dom/TagCollection.h" | |
43 #include "web/WebLocalFrameImpl.h" | 45 #include "web/WebLocalFrameImpl.h" |
44 #include "web/WebSettingsImpl.h" | 46 #include "web/WebSettingsImpl.h" |
45 #include "web/WebViewImpl.h" | 47 #include "web/WebViewImpl.h" |
46 | 48 |
47 namespace blink { | 49 namespace blink { |
48 | 50 |
49 FullscreenController* FullscreenController::create(WebViewImpl* webViewImpl) | 51 FullscreenController* FullscreenController::create(WebViewImpl* webViewImpl) |
50 { | 52 { |
51 return new FullscreenController(webViewImpl); | 53 return new FullscreenController(webViewImpl); |
52 } | 54 } |
(...skipping 24 matching lines...) Expand all Loading... | |
77 m_webViewImpl->setPageScaleFactor(1.0f); | 79 m_webViewImpl->setPageScaleFactor(1.0f); |
78 if (m_webViewImpl->mainFrame()->isWebLocalFrame()) | 80 if (m_webViewImpl->mainFrame()->isWebLocalFrame()) |
79 m_webViewImpl->mainFrame()->setScrollOffset(WebSize()); | 81 m_webViewImpl->mainFrame()->setScrollOffset(WebSize()); |
80 m_webViewImpl->setVisualViewportOffset(FloatPoint()); | 82 m_webViewImpl->setVisualViewportOffset(FloatPoint()); |
81 m_haveEnteredFullscreen = true; | 83 m_haveEnteredFullscreen = true; |
82 } | 84 } |
83 | 85 |
84 Fullscreen::from(document).didEnterFullscreenForElement(element); | 86 Fullscreen::from(document).didEnterFullscreenForElement(element); |
85 DCHECK_EQ(Fullscreen::currentFullScreenElementFrom(document), element); | 87 DCHECK_EQ(Fullscreen::currentFullScreenElementFrom(document), element); |
86 | 88 |
89 // Notify WebMediaPlayer when video enters full screen, and the full screen | |
90 // element is not a HTMLMediaElement. | |
91 if (!isHTMLMediaElement(element)) { | |
liberato (no reviews please)
2016/08/03 21:54:17
could early-out on isRunningLayoutTest here, rathe
xjz
2016/08/04 02:28:15
Done with the helper.
Yes, it could have multiple
| |
92 TagCollection* collection = element->getElementsByTagName("video"); | |
93 for (unsigned i = 0; i < collection->length(); ++i) { | |
94 Element* collectElement = collection->item(i); | |
95 if (isHTMLMediaElement(collectElement)) { | |
liberato (no reviews please)
2016/08/03 21:54:17
if (!is)... continue; will save {} nesting.
xjz
2016/08/04 02:28:15
Done.
| |
96 HTMLMediaElement* videoElement = toHTMLMediaElement(collectEleme nt); | |
97 if (videoElement->webMediaPlayer() | |
98 && !LayoutTestSupport::isRunningLayoutTest()) | |
99 videoElement->webMediaPlayer()->enteredFullscreen(); | |
liberato (no reviews please)
2016/08/03 21:54:17
entered/exitedFullscreen shouldn't be called for a
xjz
2016/08/04 02:28:16
I agree. Now add WebMediaPlayer::updateMediaInFull
| |
100 } | |
101 } | |
102 } | |
103 | |
87 if (isHTMLVideoElement(element)) { | 104 if (isHTMLVideoElement(element)) { |
88 HTMLVideoElement* videoElement = toHTMLVideoElement(element); | 105 HTMLVideoElement* videoElement = toHTMLVideoElement(element); |
89 if (videoElement->usesOverlayFullscreenVideo() && m_webViewImpl->layerTr eeView()) | 106 if (videoElement->usesOverlayFullscreenVideo() && m_webViewImpl->layerTr eeView()) |
90 m_webViewImpl->layerTreeView()->setHasTransparentBackground(true); | 107 m_webViewImpl->layerTreeView()->setHasTransparentBackground(true); |
91 } | 108 } |
92 } | 109 } |
93 | 110 |
94 void FullscreenController::didExitFullscreen() | 111 void FullscreenController::didExitFullscreen() |
95 { | 112 { |
96 if (!m_fullScreenFrame) | 113 if (!m_fullScreenFrame) |
(...skipping 15 matching lines...) Expand all Loading... | |
112 // If the video used overlay fullscreen mode, the background was made transparent. Restore the transparency. | 129 // If the video used overlay fullscreen mode, the background was made transparent. Restore the transparency. |
113 if (isHTMLVideoElement(element) && m_webViewImpl->layerTreeView( )) | 130 if (isHTMLVideoElement(element) && m_webViewImpl->layerTreeView( )) |
114 m_webViewImpl->layerTreeView()->setHasTransparentBackground( m_webViewImpl->isTransparent()); | 131 m_webViewImpl->layerTreeView()->setHasTransparentBackground( m_webViewImpl->isTransparent()); |
115 | 132 |
116 // We need to wait until style and layout are updated in order | 133 // We need to wait until style and layout are updated in order |
117 // to propertly restore scroll offsets since content may not be | 134 // to propertly restore scroll offsets since content may not be |
118 // overflowing in the same way until they do. | 135 // overflowing in the same way until they do. |
119 if (m_haveEnteredFullscreen) | 136 if (m_haveEnteredFullscreen) |
120 m_needsScrollAndScaleRestore = true; | 137 m_needsScrollAndScaleRestore = true; |
121 | 138 |
139 // Notify WebMediaPlayer when video exits full screen, and the | |
140 // full screen element is not a HTMLMediaElement. | |
141 if (!isHTMLMediaElement(element)) { | |
142 TagCollection* collection = element->getElementsByTagName("v ideo"); | |
143 for (unsigned i = 0; i < collection->length(); ++i) { | |
144 Element* collectElement = collection->item(i); | |
145 if (isHTMLMediaElement(collectElement)) { | |
146 HTMLMediaElement* videoElement = toHTMLMediaElement( collectElement); | |
147 if (videoElement->webMediaPlayer()) | |
148 videoElement->webMediaPlayer()->exitedFullscreen (); | |
149 } | |
150 } | |
151 } | |
152 | |
122 fullscreen->didExitFullscreen(); | 153 fullscreen->didExitFullscreen(); |
123 } | 154 } |
124 } | 155 } |
125 } | 156 } |
126 | 157 |
127 m_haveEnteredFullscreen = false; | 158 m_haveEnteredFullscreen = false; |
128 m_fullScreenFrame.clear(); | 159 m_fullScreenFrame.clear(); |
129 } | 160 } |
130 | 161 |
131 void FullscreenController::enterFullScreenForElement(Element* element) | 162 void FullscreenController::enterFullScreenForElement(Element* element) |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
241 m_webViewImpl->updateMainFrameLayoutSize(); | 272 m_webViewImpl->updateMainFrameLayoutSize(); |
242 } | 273 } |
243 | 274 |
244 DEFINE_TRACE(FullscreenController) | 275 DEFINE_TRACE(FullscreenController) |
245 { | 276 { |
246 visitor->trace(m_provisionalFullScreenElement); | 277 visitor->trace(m_provisionalFullScreenElement); |
247 visitor->trace(m_fullScreenFrame); | 278 visitor->trace(m_fullScreenFrame); |
248 } | 279 } |
249 | 280 |
250 } // namespace blink | 281 } // namespace blink |
OLD | NEW |