| 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 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 |
| OLD | NEW |