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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 return adoptPtr(new FullscreenController(webViewImpl)); | 49 return adoptPtr(new FullscreenController(webViewImpl)); |
50 } | 50 } |
51 | 51 |
52 FullscreenController::FullscreenController(WebViewImpl* webViewImpl) | 52 FullscreenController::FullscreenController(WebViewImpl* webViewImpl) |
53 : m_webViewImpl(webViewImpl) | 53 : m_webViewImpl(webViewImpl) |
54 , m_exitFullscreenPageScaleFactor(0) | 54 , m_exitFullscreenPageScaleFactor(0) |
55 , m_isCancelingFullScreen(false) | 55 , m_isCancelingFullScreen(false) |
56 { | 56 { |
57 } | 57 } |
58 | 58 |
59 void FullscreenController::willEnterFullScreen() | 59 void FullscreenController::didEnterFullScreen() |
60 { | 60 { |
61 if (!m_provisionalFullScreenElement) | 61 if (!m_provisionalFullScreenElement) |
62 return; | 62 return; |
63 | 63 |
64 // Ensure that this element's document is still attached. | 64 RefPtrWillBeRawPtr<Element> element = m_provisionalFullScreenElement.release
(); |
65 Document& doc = m_provisionalFullScreenElement->document(); | 65 Document& document = element->document(); |
66 if (doc.frame()) { | 66 m_fullScreenFrame = document.frame(); |
67 Fullscreen::from(doc).willEnterFullScreenForElement(m_provisionalFullScr
eenElement.get()); | |
68 m_fullScreenFrame = doc.frame(); | |
69 } | |
70 m_provisionalFullScreenElement.clear(); | |
71 } | |
72 | 67 |
73 void FullscreenController::didEnterFullScreen() | |
74 { | |
75 if (!m_fullScreenFrame) | 68 if (!m_fullScreenFrame) |
76 return; | 69 return; |
77 | 70 |
78 if (Document* doc = m_fullScreenFrame->document()) { | 71 if (!m_exitFullscreenPageScaleFactor) { |
79 if (Fullscreen::isFullScreen(*doc)) { | 72 m_exitFullscreenPageScaleFactor = m_webViewImpl->pageScaleFactor(); |
80 if (!m_exitFullscreenPageScaleFactor) { | 73 m_exitFullscreenScrollOffset = m_webViewImpl->mainFrame()->scrollOffset(
); |
81 m_exitFullscreenPageScaleFactor = m_webViewImpl->pageScaleFactor
(); | 74 m_exitFullscreenPinchViewportOffset = m_webViewImpl->pinchViewportOffset
(); |
82 m_exitFullscreenScrollOffset = m_webViewImpl->mainFrame()->scrol
lOffset(); | 75 m_webViewImpl->setPageScaleFactor(1.0f); |
83 m_exitFullscreenPinchViewportOffset = m_webViewImpl->pinchViewpo
rtOffset(); | 76 m_webViewImpl->setMainFrameScrollOffset(IntPoint()); |
84 m_webViewImpl->setPageScaleFactor(1.0f); | 77 m_webViewImpl->setPinchViewportOffset(FloatPoint()); |
85 m_webViewImpl->setMainFrameScrollOffset(IntPoint()); | 78 } |
86 m_webViewImpl->setPinchViewportOffset(FloatPoint()); | 79 |
| 80 Fullscreen::from(document).didEnterFullScreenForElement(element.get()); |
| 81 ASSERT(Fullscreen::currentFullScreenElementFrom(document) == element); |
| 82 |
| 83 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled()) { |
| 84 if (isHTMLMediaElement(element)) { |
| 85 HTMLMediaElement* mediaElement = toHTMLMediaElement(element); |
| 86 if (mediaElement->webMediaPlayer() && mediaElement->webMediaPlayer()
->canEnterFullscreen() |
| 87 // FIXME: There is no embedder-side handling in layout test mode
. |
| 88 && !LayoutTestSupport::isRunningLayoutTest()) { |
| 89 mediaElement->webMediaPlayer()->enterFullscreen(); |
87 } | 90 } |
88 | 91 if (m_webViewImpl->layerTreeView()) |
89 Fullscreen::from(*doc).didEnterFullScreenForElement(0); | 92 m_webViewImpl->layerTreeView()->setHasTransparentBackground(true
); |
90 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled()) { | |
91 Element* element = Fullscreen::currentFullScreenElementFrom(*doc
); | |
92 ASSERT(element); | |
93 if (isHTMLMediaElement(*element)) { | |
94 HTMLMediaElement* mediaElement = toHTMLMediaElement(element)
; | |
95 if (mediaElement->webMediaPlayer() && mediaElement->webMedia
Player()->canEnterFullscreen() | |
96 // FIXME: There is no embedder-side handling in layout t
est mode. | |
97 && !LayoutTestSupport::isRunningLayoutTest()) { | |
98 mediaElement->webMediaPlayer()->enterFullscreen(); | |
99 } | |
100 if (m_webViewImpl->layerTreeView()) | |
101 m_webViewImpl->layerTreeView()->setHasTransparentBackgro
und(true); | |
102 } | |
103 } | |
104 } | 93 } |
105 } | 94 } |
106 } | 95 } |
107 | |
108 void FullscreenController::willExitFullScreen() | |
109 { | |
110 if (!m_fullScreenFrame) | |
111 return; | |
112 | |
113 if (Document* doc = m_fullScreenFrame->document()) { | |
114 Fullscreen* fullscreen = Fullscreen::fromIfExists(*doc); | |
115 if (!fullscreen) | |
116 return; | |
117 if (fullscreen->isFullScreen(*doc)) { | |
118 // When the client exits from full screen we have to call fullyExitF
ullscreen to notify | |
119 // the document. While doing that, suppress notifications back to th
e client. | |
120 m_isCancelingFullScreen = true; | |
121 Fullscreen::fullyExitFullscreen(*doc); | |
122 m_isCancelingFullScreen = false; | |
123 fullscreen->willExitFullScreenForElement(0); | |
124 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && m_web
ViewImpl->layerTreeView()) | |
125 m_webViewImpl->layerTreeView()->setHasTransparentBackground(m_we
bViewImpl->isTransparent()); | |
126 } | |
127 } | |
128 } | |
129 | 96 |
130 void FullscreenController::didExitFullScreen() | 97 void FullscreenController::didExitFullScreen() |
131 { | 98 { |
132 if (!m_fullScreenFrame) | 99 if (!m_fullScreenFrame) |
133 return; | 100 return; |
134 | 101 |
135 if (Document* doc = m_fullScreenFrame->document()) { | 102 if (Document* document = m_fullScreenFrame->document()) { |
136 if (Fullscreen* fullscreen = Fullscreen::fromIfExists(*doc)) { | 103 if (Fullscreen* fullscreen = Fullscreen::fromIfExists(*document)) { |
137 if (fullscreen->webkitCurrentFullScreenElement()) { | 104 if (fullscreen->webkitCurrentFullScreenElement()) { |
| 105 // When the client exits from full screen we have to call fullyE
xitFullscreen to notify |
| 106 // the document. While doing that, suppress notifications back t
o the client. |
| 107 m_isCancelingFullScreen = true; |
| 108 Fullscreen::fullyExitFullscreen(*document); |
| 109 m_isCancelingFullScreen = false; |
| 110 |
| 111 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && m
_webViewImpl->layerTreeView()) |
| 112 m_webViewImpl->layerTreeView()->setHasTransparentBackground(
m_webViewImpl->isTransparent()); |
| 113 |
138 if (m_exitFullscreenPageScaleFactor) { | 114 if (m_exitFullscreenPageScaleFactor) { |
139 m_webViewImpl->setPageScaleFactor(m_exitFullscreenPageScaleF
actor); | 115 m_webViewImpl->setPageScaleFactor(m_exitFullscreenPageScaleF
actor); |
140 m_webViewImpl->setMainFrameScrollOffset(IntPoint(m_exitFulls
creenScrollOffset)); | 116 m_webViewImpl->setMainFrameScrollOffset(IntPoint(m_exitFulls
creenScrollOffset)); |
141 m_webViewImpl->setPinchViewportOffset(m_exitFullscreenPinchV
iewportOffset); | 117 m_webViewImpl->setPinchViewportOffset(m_exitFullscreenPinchV
iewportOffset); |
142 m_exitFullscreenPageScaleFactor = 0; | 118 m_exitFullscreenPageScaleFactor = 0; |
143 m_exitFullscreenScrollOffset = IntSize(); | 119 m_exitFullscreenScrollOffset = IntSize(); |
144 } | 120 } |
145 | 121 |
146 fullscreen->didExitFullScreenForElement(0); | 122 fullscreen->didExitFullScreenForElement(0); |
147 } | 123 } |
148 } | 124 } |
149 } | 125 } |
150 | 126 |
151 m_fullScreenFrame.clear(); | 127 m_fullScreenFrame.clear(); |
152 } | 128 } |
153 | 129 |
154 void FullscreenController::enterFullScreenForElement(Element* element) | 130 void FullscreenController::enterFullScreenForElement(Element* element) |
155 { | 131 { |
156 // We are already transitioning to fullscreen for a different element. | 132 // We are already transitioning to fullscreen for a different element. |
157 if (m_provisionalFullScreenElement) { | 133 if (m_provisionalFullScreenElement) { |
158 m_provisionalFullScreenElement = element; | 134 m_provisionalFullScreenElement = element; |
159 return; | 135 return; |
160 } | 136 } |
161 | 137 |
162 // We are already in fullscreen mode. | 138 // We are already in fullscreen mode. |
163 if (m_fullScreenFrame) { | 139 if (m_fullScreenFrame) { |
164 m_provisionalFullScreenElement = element; | 140 m_provisionalFullScreenElement = element; |
165 willEnterFullScreen(); | |
166 didEnterFullScreen(); | 141 didEnterFullScreen(); |
167 return; | 142 return; |
168 } | 143 } |
169 | 144 |
170 // We need to transition to fullscreen mode. | 145 // We need to transition to fullscreen mode. |
171 if (WebViewClient* client = m_webViewImpl->client()) { | 146 if (WebViewClient* client = m_webViewImpl->client()) { |
172 if (client->enterFullScreen()) | 147 if (client->enterFullScreen()) |
173 m_provisionalFullScreenElement = element; | 148 m_provisionalFullScreenElement = element; |
174 } | 149 } |
175 } | 150 } |
176 | 151 |
177 void FullscreenController::exitFullScreenForElement(Element* element) | 152 void FullscreenController::exitFullScreenForElement(Element* element) |
178 { | 153 { |
179 // The client is exiting full screen, so don't send a notification. | 154 // The client is exiting full screen, so don't send a notification. |
180 if (m_isCancelingFullScreen) | 155 if (m_isCancelingFullScreen) |
181 return; | 156 return; |
182 if (WebViewClient* client = m_webViewImpl->client()) | 157 if (WebViewClient* client = m_webViewImpl->client()) |
183 client->exitFullScreen(); | 158 client->exitFullScreen(); |
184 } | 159 } |
185 | 160 |
186 } // namespace blink | 161 } // namespace blink |
187 | 162 |
OLD | NEW |