Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 // If the change should be animated, let the impl thread drive the change. |
| 103 setShownRatio(1.f); | 106 // Otherwise, immediately set the shown ratio so we don't have to wait for |
| 104 else if (m_permittedState == WebTopControlsHidden) | 107 // a commit from the impl thread. |
| 105 setShownRatio(0.f); | 108 if (!animate) { |
| 109 switch (current) { | |
|
majidvp
2016/06/29 13:56:09
Sorry to go back and forth and not noticing this e
bokan
2016/06/29 16:23:00
Good catch, I hadn't noticed this doesn't fix the
| |
| 110 case WebTopControlsShown: | |
| 111 setShownRatio(1.f); | |
| 112 break; | |
| 113 case WebTopControlsHidden: | |
| 114 setShownRatio(0.f); | |
| 115 break; | |
| 116 case WebTopControlsBoth: | |
| 117 default: | |
| 118 break; | |
| 119 } | |
| 120 } | |
| 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 |
| OLD | NEW |