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

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

Issue 2316983002: Change capitalization FullScreen->Fullscreen where possible in Blink (Closed)
Patch Set: update test expectations Created 4 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
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 FullscreenController* FullscreenController::create(WebViewImpl* webViewImpl) 50 FullscreenController* FullscreenController::create(WebViewImpl* webViewImpl)
51 { 51 {
52 return new FullscreenController(webViewImpl); 52 return new FullscreenController(webViewImpl);
53 } 53 }
54 54
55 FullscreenController::FullscreenController(WebViewImpl* webViewImpl) 55 FullscreenController::FullscreenController(WebViewImpl* webViewImpl)
56 : m_webViewImpl(webViewImpl) 56 : m_webViewImpl(webViewImpl)
57 , m_haveEnteredFullscreen(false) 57 , m_haveEnteredFullscreen(false)
58 , m_exitFullscreenPageScaleFactor(0) 58 , m_exitFullscreenPageScaleFactor(0)
59 , m_needsScrollAndScaleRestore(false) 59 , m_needsScrollAndScaleRestore(false)
60 , m_isCancelingFullScreen(false) 60 , m_isCancelingFullscreen(false)
61 { 61 {
62 } 62 }
63 63
64 void FullscreenController::didEnterFullscreen() 64 void FullscreenController::didEnterFullscreen()
65 { 65 {
66 if (!m_provisionalFullScreenElement) 66 if (!m_provisionalFullscreenElement)
67 return; 67 return;
68 68
69 Element* element = m_provisionalFullScreenElement.release(); 69 Element* element = m_provisionalFullscreenElement.release();
70 Document& document = element->document(); 70 Document& document = element->document();
71 m_fullScreenFrame = document.frame(); 71 m_fullscreenFrame = document.frame();
72 72
73 if (!m_fullScreenFrame) 73 if (!m_fullscreenFrame)
74 return; 74 return;
75 75
76 if (!m_haveEnteredFullscreen) { 76 if (!m_haveEnteredFullscreen) {
77 updatePageScaleConstraints(false); 77 updatePageScaleConstraints(false);
78 m_webViewImpl->setPageScaleFactor(1.0f); 78 m_webViewImpl->setPageScaleFactor(1.0f);
79 if (m_webViewImpl->mainFrame()->isWebLocalFrame()) 79 if (m_webViewImpl->mainFrame()->isWebLocalFrame())
80 m_webViewImpl->mainFrame()->setScrollOffset(WebSize()); 80 m_webViewImpl->mainFrame()->setScrollOffset(WebSize());
81 m_webViewImpl->setVisualViewportOffset(FloatPoint()); 81 m_webViewImpl->setVisualViewportOffset(FloatPoint());
82 m_haveEnteredFullscreen = true; 82 m_haveEnteredFullscreen = true;
83 } 83 }
84 84
85 Fullscreen::from(document).didEnterFullscreenForElement(element); 85 Fullscreen::from(document).didEnterFullscreenForElement(element);
86 DCHECK_EQ(Fullscreen::currentFullScreenElementFrom(document), element); 86 DCHECK_EQ(Fullscreen::currentFullScreenElementFrom(document), element);
87 87
88 if (isHTMLVideoElement(element)) { 88 if (isHTMLVideoElement(element)) {
89 HTMLVideoElement* videoElement = toHTMLVideoElement(element); 89 HTMLVideoElement* videoElement = toHTMLVideoElement(element);
90 if (videoElement->usesOverlayFullscreenVideo() && m_webViewImpl->layerTr eeView()) 90 if (videoElement->usesOverlayFullscreenVideo() && m_webViewImpl->layerTr eeView())
91 m_webViewImpl->layerTreeView()->setHasTransparentBackground(true); 91 m_webViewImpl->layerTreeView()->setHasTransparentBackground(true);
92 } 92 }
93 } 93 }
94 94
95 void FullscreenController::didExitFullscreen() 95 void FullscreenController::didExitFullscreen()
96 { 96 {
97 if (!m_fullScreenFrame) 97 if (!m_fullscreenFrame)
98 return; 98 return;
99 99
100 if (m_haveEnteredFullscreen) 100 if (m_haveEnteredFullscreen)
101 updatePageScaleConstraints(true); 101 updatePageScaleConstraints(true);
102 102
103 if (Document* document = m_fullScreenFrame->document()) { 103 if (Document* document = m_fullscreenFrame->document()) {
104 if (Fullscreen* fullscreen = Fullscreen::fromIfExists(*document)) { 104 if (Fullscreen* fullscreen = Fullscreen::fromIfExists(*document)) {
105 Element* element = fullscreen->currentFullScreenElement(); 105 Element* element = fullscreen->currentFullScreenElement();
106 if (element) { 106 if (element) {
107 // When the client exits from full screen we have to call fullyE xitFullscreen to notify 107 // When the client exits from full screen we have to call fullyE xitFullscreen to notify
108 // the document. While doing that, suppress notifications back t o the client. 108 // the document. While doing that, suppress notifications back t o the client.
109 m_isCancelingFullScreen = true; 109 m_isCancelingFullscreen = true;
110 Fullscreen::fullyExitFullscreen(*document); 110 Fullscreen::fullyExitFullscreen(*document);
111 m_isCancelingFullScreen = false; 111 m_isCancelingFullscreen = false;
112 112
113 // If the video used overlay fullscreen mode, the background was made transparent. Restore the transparency. 113 // If the video used overlay fullscreen mode, the background was made transparent. Restore the transparency.
114 if (isHTMLVideoElement(element) && m_webViewImpl->layerTreeView( )) 114 if (isHTMLVideoElement(element) && m_webViewImpl->layerTreeView( ))
115 m_webViewImpl->layerTreeView()->setHasTransparentBackground( m_webViewImpl->isTransparent()); 115 m_webViewImpl->layerTreeView()->setHasTransparentBackground( m_webViewImpl->isTransparent());
116 116
117 // We need to wait until style and layout are updated in order 117 // We need to wait until style and layout are updated in order
118 // to propertly restore scroll offsets since content may not be 118 // to propertly restore scroll offsets since content may not be
119 // overflowing in the same way until they do. 119 // overflowing in the same way until they do.
120 if (m_haveEnteredFullscreen) 120 if (m_haveEnteredFullscreen)
121 m_needsScrollAndScaleRestore = true; 121 m_needsScrollAndScaleRestore = true;
122 122
123 fullscreen->didExitFullscreen(); 123 fullscreen->didExitFullscreen();
124 } 124 }
125 } 125 }
126 } 126 }
127 127
128 m_haveEnteredFullscreen = false; 128 m_haveEnteredFullscreen = false;
129 m_fullScreenFrame.clear(); 129 m_fullscreenFrame.clear();
130 } 130 }
131 131
132 void FullscreenController::enterFullScreenForElement(Element* element) 132 void FullscreenController::enterFullscreenForElement(Element* element)
133 { 133 {
134 // We are already transitioning to fullscreen for a different element. 134 // We are already transitioning to fullscreen for a different element.
135 if (m_provisionalFullScreenElement) { 135 if (m_provisionalFullscreenElement) {
136 m_provisionalFullScreenElement = element; 136 m_provisionalFullscreenElement = element;
137 return; 137 return;
138 } 138 }
139 139
140 // We are already in fullscreen mode. 140 // We are already in fullscreen mode.
141 if (m_fullScreenFrame) { 141 if (m_fullscreenFrame) {
142 m_provisionalFullScreenElement = element; 142 m_provisionalFullscreenElement = element;
143 didEnterFullscreen(); 143 didEnterFullscreen();
144 return; 144 return;
145 } 145 }
146 146
147 // We need to store these values here rather than didEnterFullscreen since 147 // We need to store these values here rather than didEnterFullscreen since
148 // by the time the latter is called, a Resize has already occured, clamping 148 // by the time the latter is called, a Resize has already occured, clamping
149 // the scroll offset. Don't save values if we're still waiting to restore 149 // the scroll offset. Don't save values if we're still waiting to restore
150 // a previous set. This can happen if we exit and quickly reenter fullscreen 150 // a previous set. This can happen if we exit and quickly reenter fullscreen
151 // without performing a layout. 151 // without performing a layout.
152 if (!m_haveEnteredFullscreen && !m_needsScrollAndScaleRestore) { 152 if (!m_haveEnteredFullscreen && !m_needsScrollAndScaleRestore) {
153 m_exitFullscreenPageScaleFactor = m_webViewImpl->pageScaleFactor(); 153 m_exitFullscreenPageScaleFactor = m_webViewImpl->pageScaleFactor();
154 m_exitFullscreenScrollOffset = m_webViewImpl->mainFrame()->isWebLocalFra me() ? m_webViewImpl->mainFrame()->scrollOffset() : WebSize(); 154 m_exitFullscreenScrollOffset = m_webViewImpl->mainFrame()->isWebLocalFra me() ? m_webViewImpl->mainFrame()->scrollOffset() : WebSize();
155 m_exitFullscreenVisualViewportOffset = m_webViewImpl->visualViewportOffs et(); 155 m_exitFullscreenVisualViewportOffset = m_webViewImpl->visualViewportOffs et();
156 } 156 }
157 157
158 // We need to transition to fullscreen mode. 158 // We need to transition to fullscreen mode.
159 WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(element->document(). frame()); 159 WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(element->document(). frame());
160 if (frame && frame->client()) { 160 if (frame && frame->client()) {
161 if (!Fullscreen::from(element->document()).forCrossProcessDescendant()) 161 if (!Fullscreen::from(element->document()).forCrossProcessDescendant())
162 frame->client()->enterFullscreen(); 162 frame->client()->enterFullscreen();
163 m_provisionalFullScreenElement = element; 163 m_provisionalFullscreenElement = element;
164 } 164 }
165 } 165 }
166 166
167 void FullscreenController::exitFullScreenForElement(Element* element) 167 void FullscreenController::exitFullscreenForElement(Element* element)
168 { 168 {
169 DCHECK(element); 169 DCHECK(element);
170 170
171 // The client is exiting full screen, so don't send a notification. 171 // The client is exiting full screen, so don't send a notification.
172 if (m_isCancelingFullScreen) 172 if (m_isCancelingFullscreen)
173 return; 173 return;
174 174
175 WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(element->document(). frame()); 175 WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(element->document(). frame());
176 if (frame && frame->client()) 176 if (frame && frame->client())
177 frame->client()->exitFullscreen(); 177 frame->client()->exitFullscreen();
178 } 178 }
179 179
180 void FullscreenController::updateSize() 180 void FullscreenController::updateSize()
181 { 181 {
182 if (!isFullscreen()) 182 if (!isFullscreen())
183 return; 183 return;
184 184
185 updatePageScaleConstraints(false); 185 updatePageScaleConstraints(false);
186 186
187 LayoutFullScreen* layoutObject = Fullscreen::from(*m_fullScreenFrame->docume nt()).fullScreenLayoutObject(); 187 LayoutFullScreen* layoutObject = Fullscreen::from(*m_fullscreenFrame->docume nt()).fullScreenLayoutObject();
188 if (layoutObject) 188 if (layoutObject)
189 layoutObject->updateStyle(); 189 layoutObject->updateStyle();
190 } 190 }
191 191
192 void FullscreenController::didUpdateLayout() 192 void FullscreenController::didUpdateLayout()
193 { 193 {
194 if (!m_needsScrollAndScaleRestore) 194 if (!m_needsScrollAndScaleRestore)
195 return; 195 return;
196 196
197 // If we re-entered fullscreen before we could restore the scroll and scale 197 // If we re-entered fullscreen before we could restore the scroll and scale
(...skipping 25 matching lines...) Expand all
223 // Just fire the event again to ensure the final constraints pick up the lat est contents size. 223 // Just fire the event again to ensure the final constraints pick up the lat est contents size.
224 m_webViewImpl->didChangeContentsSize(); 224 m_webViewImpl->didChangeContentsSize();
225 if (m_webViewImpl->mainFrameImpl() && m_webViewImpl->mainFrameImpl()->frameV iew()) 225 if (m_webViewImpl->mainFrameImpl() && m_webViewImpl->mainFrameImpl()->frameV iew())
226 m_webViewImpl->mainFrameImpl()->frameView()->setNeedsLayout(); 226 m_webViewImpl->mainFrameImpl()->frameView()->setNeedsLayout();
227 227
228 m_webViewImpl->updateMainFrameLayoutSize(); 228 m_webViewImpl->updateMainFrameLayoutSize();
229 } 229 }
230 230
231 DEFINE_TRACE(FullscreenController) 231 DEFINE_TRACE(FullscreenController)
232 { 232 {
233 visitor->trace(m_provisionalFullScreenElement); 233 visitor->trace(m_provisionalFullscreenElement);
234 visitor->trace(m_fullScreenFrame); 234 visitor->trace(m_fullscreenFrame);
235 } 235 }
236 236
237 } // namespace blink 237 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/FullscreenController.h ('k') | third_party/WebKit/Source/web/WebFrameWidgetImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698