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

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

Issue 1488653002: Fix scroll restoration when exiting fullscreen mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Accidentally made will_cause_resize always false in previous cleanup. Fixed Created 4 years, 10 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 namespace blink { 47 namespace blink {
48 48
49 PassOwnPtrWillBeRawPtr<FullscreenController> FullscreenController::create(WebVie wImpl* webViewImpl) 49 PassOwnPtrWillBeRawPtr<FullscreenController> FullscreenController::create(WebVie wImpl* webViewImpl)
50 { 50 {
51 return adoptPtrWillBeNoop(new FullscreenController(webViewImpl)); 51 return adoptPtrWillBeNoop(new FullscreenController(webViewImpl));
52 } 52 }
53 53
54 FullscreenController::FullscreenController(WebViewImpl* webViewImpl) 54 FullscreenController::FullscreenController(WebViewImpl* webViewImpl)
55 : m_webViewImpl(webViewImpl) 55 : m_webViewImpl(webViewImpl)
56 , m_haveEnteredFullscreen(false)
56 , m_exitFullscreenPageScaleFactor(0) 57 , m_exitFullscreenPageScaleFactor(0)
57 , m_isCancelingFullScreen(false) 58 , m_isCancelingFullScreen(false)
58 { 59 {
59 } 60 }
60 61
61 void FullscreenController::didEnterFullScreen() 62 void FullscreenController::didEnterFullScreen()
62 { 63 {
63 if (!m_provisionalFullScreenElement) 64 if (!m_provisionalFullScreenElement)
64 return; 65 return;
65 66
66 RefPtrWillBeRawPtr<Element> element = m_provisionalFullScreenElement.release (); 67 RefPtrWillBeRawPtr<Element> element = m_provisionalFullScreenElement.release ();
67 Document& document = element->document(); 68 Document& document = element->document();
68 m_fullScreenFrame = document.frame(); 69 m_fullScreenFrame = document.frame();
69 70
70 if (!m_fullScreenFrame) 71 if (!m_fullScreenFrame)
71 return; 72 return;
72 73
73 if (!m_exitFullscreenPageScaleFactor) { 74 if (!m_haveEnteredFullscreen) {
74 m_exitFullscreenPageScaleFactor = m_webViewImpl->pageScaleFactor();
75 m_exitFullscreenScrollOffset = m_webViewImpl->mainFrame()->scrollOffset( );
76 m_exitFullscreenVisualViewportOffset = m_webViewImpl->visualViewportOffs et();
77
78 updatePageScaleConstraints(false); 75 updatePageScaleConstraints(false);
79 m_webViewImpl->setPageScaleFactor(1.0f); 76 m_webViewImpl->setPageScaleFactor(1.0f);
80 m_webViewImpl->mainFrame()->setScrollOffset(WebSize()); 77 m_webViewImpl->mainFrame()->setScrollOffset(WebSize());
81 m_webViewImpl->setVisualViewportOffset(FloatPoint()); 78 m_webViewImpl->setVisualViewportOffset(FloatPoint());
79 m_haveEnteredFullscreen = true;
82 } 80 }
83 81
84 Fullscreen::from(document).didEnterFullScreenForElement(element.get()); 82 Fullscreen::from(document).didEnterFullScreenForElement(element.get());
85 ASSERT(Fullscreen::currentFullScreenElementFrom(document) == element); 83 ASSERT(Fullscreen::currentFullScreenElementFrom(document) == element);
86 84
87 if (isHTMLVideoElement(element)) { 85 if (isHTMLVideoElement(element)) {
88 HTMLVideoElement* videoElement = toHTMLVideoElement(element); 86 HTMLVideoElement* videoElement = toHTMLVideoElement(element);
89 if (videoElement->usesOverlayFullscreenVideo()) { 87 if (videoElement->usesOverlayFullscreenVideo()) {
90 if (videoElement->webMediaPlayer() 88 if (videoElement->webMediaPlayer()
91 // FIXME: There is no embedder-side handling in layout test mode . 89 // FIXME: There is no embedder-side handling in layout test mode .
(...skipping 18 matching lines...) Expand all
110 // When the client exits from full screen we have to call fullyE xitFullscreen to notify 108 // When the client exits from full screen we have to call fullyE xitFullscreen to notify
111 // the document. While doing that, suppress notifications back t o the client. 109 // the document. While doing that, suppress notifications back t o the client.
112 m_isCancelingFullScreen = true; 110 m_isCancelingFullScreen = true;
113 Fullscreen::fullyExitFullscreen(*document); 111 Fullscreen::fullyExitFullscreen(*document);
114 m_isCancelingFullScreen = false; 112 m_isCancelingFullScreen = false;
115 113
116 // If the video used overlay fullscreen mode, the background was made transparent. Restore the transparency. 114 // If the video used overlay fullscreen mode, the background was made transparent. Restore the transparency.
117 if (isHTMLVideoElement(element) && m_webViewImpl->layerTreeView( )) 115 if (isHTMLVideoElement(element) && m_webViewImpl->layerTreeView( ))
118 m_webViewImpl->layerTreeView()->setHasTransparentBackground( m_webViewImpl->isTransparent()); 116 m_webViewImpl->layerTreeView()->setHasTransparentBackground( m_webViewImpl->isTransparent());
119 117
120 if (m_exitFullscreenPageScaleFactor) { 118 if (m_haveEnteredFullscreen) {
121 updatePageScaleConstraints(true); 119 updatePageScaleConstraints(true);
122 m_webViewImpl->setPageScaleFactor(m_exitFullscreenPageScaleF actor); 120 m_webViewImpl->setPageScaleFactor(m_exitFullscreenPageScaleF actor);
123 m_webViewImpl->mainFrame()->setScrollOffset(WebSize(m_exitFu llscreenScrollOffset)); 121 m_webViewImpl->mainFrame()->setScrollOffset(WebSize(m_exitFu llscreenScrollOffset));
124 m_webViewImpl->setVisualViewportOffset(m_exitFullscreenVisua lViewportOffset); 122 m_webViewImpl->setVisualViewportOffset(m_exitFullscreenVisua lViewportOffset);
125 m_exitFullscreenPageScaleFactor = 0; 123 m_haveEnteredFullscreen = false;
126 m_exitFullscreenScrollOffset = IntSize();
127 } 124 }
128 125
129 fullscreen->didExitFullScreenForElement(0); 126 fullscreen->didExitFullScreenForElement(0);
130 } 127 }
131 } 128 }
132 } 129 }
133 130
134 m_fullScreenFrame.clear(); 131 m_fullScreenFrame.clear();
135 } 132 }
136 133
137 void FullscreenController::enterFullScreenForElement(Element* element) 134 void FullscreenController::enterFullScreenForElement(Element* element)
138 { 135 {
139 // We are already transitioning to fullscreen for a different element. 136 // We are already transitioning to fullscreen for a different element.
140 if (m_provisionalFullScreenElement) { 137 if (m_provisionalFullScreenElement) {
141 m_provisionalFullScreenElement = element; 138 m_provisionalFullScreenElement = element;
142 return; 139 return;
143 } 140 }
144 141
145 // We are already in fullscreen mode. 142 // We are already in fullscreen mode.
146 if (m_fullScreenFrame) { 143 if (m_fullScreenFrame) {
147 m_provisionalFullScreenElement = element; 144 m_provisionalFullScreenElement = element;
148 didEnterFullScreen(); 145 didEnterFullScreen();
149 return; 146 return;
150 } 147 }
151 148
149 // We need to store these values here rather than didEnterFullScreen since
150 // by the time the latter is called, a Resize has already occured, clamping
151 // the scroll offset.
152 if (!m_haveEnteredFullscreen) {
153 m_exitFullscreenPageScaleFactor = m_webViewImpl->pageScaleFactor();
154 m_exitFullscreenScrollOffset = m_webViewImpl->mainFrame()->scrollOffset( );
155 m_exitFullscreenVisualViewportOffset = m_webViewImpl->visualViewportOffs et();
156 }
157
152 // We need to transition to fullscreen mode. 158 // We need to transition to fullscreen mode.
153 WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(element->document(). frame()); 159 WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(element->document(). frame());
154 if (frame && frame->client()) { 160 if (frame && frame->client()) {
155 frame->client()->enterFullscreen(); 161 frame->client()->enterFullscreen();
156 m_provisionalFullScreenElement = element; 162 m_provisionalFullScreenElement = element;
157 } 163 }
158 } 164 }
159 165
160 void FullscreenController::exitFullScreenForElement(Element* element) 166 void FullscreenController::exitFullScreenForElement(Element* element)
161 { 167 {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 } 201 }
196 202
197 DEFINE_TRACE(FullscreenController) 203 DEFINE_TRACE(FullscreenController)
198 { 204 {
199 visitor->trace(m_provisionalFullScreenElement); 205 visitor->trace(m_provisionalFullScreenElement);
200 visitor->trace(m_fullScreenFrame); 206 visitor->trace(m_fullScreenFrame);
201 } 207 }
202 208
203 } // namespace blink 209 } // namespace blink
204 210
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/FullscreenController.h ('k') | ui/views/controls/webview/webview.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698