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

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: Created 5 years 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 namespace blink { 48 namespace blink {
49 49
50 PassOwnPtrWillBeRawPtr<FullscreenController> FullscreenController::create(WebVie wImpl* webViewImpl) 50 PassOwnPtrWillBeRawPtr<FullscreenController> FullscreenController::create(WebVie wImpl* webViewImpl)
51 { 51 {
52 return adoptPtrWillBeNoop(new FullscreenController(webViewImpl)); 52 return adoptPtrWillBeNoop(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_exitFullscreenPageScaleFactor(0) 58 , m_exitFullscreenPageScaleFactor(0)
58 , m_isCancelingFullScreen(false) 59 , m_isCancelingFullScreen(false)
59 { 60 {
60 } 61 }
61 62
62 void FullscreenController::didEnterFullScreen() 63 void FullscreenController::didEnterFullScreen()
63 { 64 {
64 if (!m_provisionalFullScreenElement) 65 if (!m_provisionalFullScreenElement)
65 return; 66 return;
66 67
67 RefPtrWillBeRawPtr<Element> element = m_provisionalFullScreenElement.release (); 68 RefPtrWillBeRawPtr<Element> element = m_provisionalFullScreenElement.release ();
68 Document& document = element->document(); 69 Document& document = element->document();
69 m_fullScreenFrame = document.frame(); 70 m_fullScreenFrame = document.frame();
70 71
71 if (!m_fullScreenFrame) 72 if (!m_fullScreenFrame)
72 return; 73 return;
73 74
74 if (!m_exitFullscreenPageScaleFactor) { 75 if (!m_haveEnteredFullscreen) {
75 m_exitFullscreenPageScaleFactor = m_webViewImpl->pageScaleFactor();
76 m_exitFullscreenScrollOffset = m_webViewImpl->mainFrame()->scrollOffset( );
77 m_exitFullscreenVisualViewportOffset = m_webViewImpl->visualViewportOffs et();
78
79 updatePageScaleConstraints(false); 76 updatePageScaleConstraints(false);
80 m_webViewImpl->setPageScaleFactor(1.0f); 77 m_webViewImpl->setPageScaleFactor(1.0f);
81 m_webViewImpl->mainFrame()->setScrollOffset(WebSize()); 78 m_webViewImpl->mainFrame()->setScrollOffset(WebSize());
82 m_webViewImpl->setVisualViewportOffset(FloatPoint()); 79 m_webViewImpl->setVisualViewportOffset(FloatPoint());
80 m_haveEnteredFullscreen = true;
83 } 81 }
84 82
85 Fullscreen::from(document).didEnterFullScreenForElement(element.get()); 83 Fullscreen::from(document).didEnterFullScreenForElement(element.get());
86 ASSERT(Fullscreen::currentFullScreenElementFrom(document) == element); 84 ASSERT(Fullscreen::currentFullScreenElementFrom(document) == element);
87 85
88 if (isHTMLVideoElement(element)) { 86 if (isHTMLVideoElement(element)) {
89 HTMLVideoElement* videoElement = toHTMLVideoElement(element); 87 HTMLVideoElement* videoElement = toHTMLVideoElement(element);
90 if (videoElement->usesOverlayFullscreenVideo()) { 88 if (videoElement->usesOverlayFullscreenVideo()) {
91 if (videoElement->webMediaPlayer() 89 if (videoElement->webMediaPlayer()
92 // FIXME: There is no embedder-side handling in layout test mode . 90 // FIXME: There is no embedder-side handling in layout test mode .
(...skipping 18 matching lines...) Expand all
111 // When the client exits from full screen we have to call fullyE xitFullscreen to notify 109 // When the client exits from full screen we have to call fullyE xitFullscreen to notify
112 // the document. While doing that, suppress notifications back t o the client. 110 // the document. While doing that, suppress notifications back t o the client.
113 m_isCancelingFullScreen = true; 111 m_isCancelingFullScreen = true;
114 Fullscreen::fullyExitFullscreen(*document); 112 Fullscreen::fullyExitFullscreen(*document);
115 m_isCancelingFullScreen = false; 113 m_isCancelingFullScreen = false;
116 114
117 // If the video used overlay fullscreen mode, the background was made transparent. Restore the transparency. 115 // If the video used overlay fullscreen mode, the background was made transparent. Restore the transparency.
118 if (isHTMLVideoElement(element) && m_webViewImpl->layerTreeView( )) 116 if (isHTMLVideoElement(element) && m_webViewImpl->layerTreeView( ))
119 m_webViewImpl->layerTreeView()->setHasTransparentBackground( m_webViewImpl->isTransparent()); 117 m_webViewImpl->layerTreeView()->setHasTransparentBackground( m_webViewImpl->isTransparent());
120 118
121 if (m_exitFullscreenPageScaleFactor) { 119 if (m_haveEnteredFullscreen) {
122 updatePageScaleConstraints(true); 120 updatePageScaleConstraints(true);
123 m_webViewImpl->setPageScaleFactor(m_exitFullscreenPageScaleF actor); 121 m_webViewImpl->setPageScaleFactor(m_exitFullscreenPageScaleF actor);
124 m_webViewImpl->mainFrame()->setScrollOffset(WebSize(m_exitFu llscreenScrollOffset)); 122 m_webViewImpl->mainFrame()->setScrollOffset(WebSize(m_exitFu llscreenScrollOffset));
125 m_webViewImpl->setVisualViewportOffset(m_exitFullscreenVisua lViewportOffset); 123 m_webViewImpl->setVisualViewportOffset(m_exitFullscreenVisua lViewportOffset);
126 m_exitFullscreenPageScaleFactor = 0; 124 m_haveEnteredFullscreen = false;
127 m_exitFullscreenScrollOffset = IntSize();
128 } 125 }
129 126
130 fullscreen->didExitFullScreenForElement(0); 127 fullscreen->didExitFullScreenForElement(0);
131 } 128 }
132 } 129 }
133 } 130 }
134 131
135 m_fullScreenFrame.clear(); 132 m_fullScreenFrame.clear();
136 } 133 }
137 134
138 void FullscreenController::enterFullScreenForElement(Element* element) 135 void FullscreenController::enterFullScreenForElement(Element* element)
139 { 136 {
140 // We are already transitioning to fullscreen for a different element. 137 // We are already transitioning to fullscreen for a different element.
141 if (m_provisionalFullScreenElement) { 138 if (m_provisionalFullScreenElement) {
142 m_provisionalFullScreenElement = element; 139 m_provisionalFullScreenElement = element;
143 return; 140 return;
144 } 141 }
145 142
146 // We are already in fullscreen mode. 143 // We are already in fullscreen mode.
147 if (m_fullScreenFrame) { 144 if (m_fullScreenFrame) {
148 m_provisionalFullScreenElement = element; 145 m_provisionalFullScreenElement = element;
149 didEnterFullScreen(); 146 didEnterFullScreen();
150 return; 147 return;
151 } 148 }
152 149
150 // We need to store these values here rather than didEnterFullScreen since b y the time the latter
scheib 2015/12/01 00:30:18 Comments might as well wrap to 80 chars. (optional
bokan 2015/12/01 20:46:10 Done.
151 // is called, a Resize has already occured, clamping 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
153 // We need to transition to fullscreen mode. 158 // We need to transition to fullscreen mode.
154 WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(element->document(). frame()); 159 WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(element->document(). frame());
155 if (frame && frame->client()) { 160 if (frame && frame->client()) {
156 frame->client()->enterFullscreen(); 161 frame->client()->enterFullscreen();
157 m_provisionalFullScreenElement = element; 162 m_provisionalFullScreenElement = element;
158 } 163 }
159 } 164 }
160 165
161 void FullscreenController::exitFullScreenForElement(Element* element) 166 void FullscreenController::exitFullScreenForElement(Element* element)
162 { 167 {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 } 201 }
197 202
198 DEFINE_TRACE(FullscreenController) 203 DEFINE_TRACE(FullscreenController)
199 { 204 {
200 visitor->trace(m_provisionalFullScreenElement); 205 visitor->trace(m_provisionalFullScreenElement);
201 visitor->trace(m_fullScreenFrame); 206 visitor->trace(m_fullScreenFrame);
202 } 207 }
203 208
204 } // namespace blink 209 } // namespace blink
205 210
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698