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

Side by Side Diff: third_party/WebKit/Source/core/frame/TopControls.cpp

Issue 2105523002: Don't set shownRatio in main thread top controls on animated state change. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Improved test a bit Created 4 years, 5 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/frame/TopControls.h" 5 #include "core/frame/TopControls.h"
6 6
7 #include "core/frame/FrameHost.h" 7 #include "core/frame/FrameHost.h"
8 #include "core/frame/VisualViewport.h" 8 #include "core/frame/VisualViewport.h"
9 #include "core/page/ChromeClient.h" 9 #include "core/page/ChromeClient.h"
10 #include "platform/geometry/FloatSize.h" 10 #include "platform/geometry/FloatSize.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 shownRatio = std::min(shownRatio, 1.f); 88 shownRatio = std::min(shownRatio, 1.f);
89 shownRatio = std::max(shownRatio, 0.f); 89 shownRatio = std::max(shownRatio, 0.f);
90 90
91 if (m_shownRatio == shownRatio) 91 if (m_shownRatio == shownRatio)
92 return; 92 return;
93 93
94 m_shownRatio = shownRatio; 94 m_shownRatio = shownRatio;
95 m_frameHost->chromeClient().didUpdateTopControls(); 95 m_frameHost->chromeClient().didUpdateTopControls();
96 } 96 }
97 97
98 void TopControls::updateConstraints(WebTopControlsState constraints) 98 void TopControls::updateConstraintsAndState(
99 WebTopControlsState constraints,
100 WebTopControlsState current,
101 bool animate)
99 { 102 {
100 m_permittedState = constraints; 103 m_permittedState = constraints;
101 104
102 if (m_permittedState == WebTopControlsShown) 105 DCHECK(!(constraints == WebTopControlsShown && current == WebTopControlsHidd en));
106 DCHECK(!(constraints == WebTopControlsHidden && current == WebTopControlsSho wn));
107
108 // If the change should be animated, let the impl thread drive the change.
109 // Otherwise, immediately set the shown ratio so we don't have to wait for
110 // a commit from the impl thread.
111 if (animate)
112 return;
113
114 if (constraints == WebTopControlsBoth && current == WebTopControlsBoth)
115 return;
116
117 if (constraints == WebTopControlsHidden || current == WebTopControlsHidden)
118 setShownRatio(0.f);
119 else
103 setShownRatio(1.f); 120 setShownRatio(1.f);
104 else if (m_permittedState == WebTopControlsHidden)
105 setShownRatio(0.f);
106 } 121 }
107 122
108 void TopControls::setHeight(float height, bool shrinkViewport) 123 void TopControls::setHeight(float height, bool shrinkViewport)
109 { 124 {
110 if (m_height == height && m_shrinkViewport == shrinkViewport) 125 if (m_height == height && m_shrinkViewport == shrinkViewport)
111 return; 126 return;
112 127
113 m_height = height; 128 m_height = height;
114 m_shrinkViewport = shrinkViewport; 129 m_shrinkViewport = shrinkViewport;
115 m_frameHost->chromeClient().didUpdateTopControls(); 130 m_frameHost->chromeClient().didUpdateTopControls();
116 } 131 }
117 132
118 } // namespace blink 133 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/TopControls.h ('k') | third_party/WebKit/Source/web/WebViewImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698