OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef TopControls_h | 5 #ifndef BrowserControls_h |
6 #define TopControls_h | 6 #define BrowserControls_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "platform/heap/Handle.h" | 9 #include "platform/heap/Handle.h" |
10 #include "public/platform/WebTopControlsState.h" | 10 #include "public/platform/WebBrowserControlsState.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 class FrameHost; | 13 class FrameHost; |
14 class FloatSize; | 14 class FloatSize; |
15 | 15 |
16 // This class encapsulate data and logic required to show/hide top controls | 16 // This class encapsulate data and logic required to show/hide browser controls |
17 // duplicating cc::TopControlsManager behaviour. Top controls' self-animation | 17 // duplicating cc::BrowserControlsManager behaviour. Browser controls' |
18 // to completion is still handled by compositor and kicks in when scrolling is | 18 // self-animation to completion is still handled by compositor and kicks in |
19 // complete (i.e, upon ScrollEnd or FlingEnd). | 19 // when scrolling is complete (i.e, upon ScrollEnd or FlingEnd). |
20 class CORE_EXPORT TopControls final : public GarbageCollected<TopControls> { | 20 class CORE_EXPORT BrowserControls final |
| 21 : public GarbageCollected<BrowserControls> { |
21 public: | 22 public: |
22 static TopControls* create(const FrameHost& host) { | 23 static BrowserControls* create(const FrameHost& host) { |
23 return new TopControls(host); | 24 return new BrowserControls(host); |
24 } | 25 } |
25 | 26 |
26 DECLARE_TRACE(); | 27 DECLARE_TRACE(); |
27 | 28 |
28 // The amount that the viewport was shrunk by to accommodate the top | 29 // The amount that the viewport was shrunk by to accommodate the top |
29 // controls. | 30 // controls. |
30 float layoutHeight(); | 31 float layoutHeight(); |
31 // The amount that top controls are currently shown. | 32 // The amount that browser controls are currently shown. |
32 float contentOffset(); | 33 float contentOffset(); |
33 | 34 |
34 float height() const { return m_height; } | 35 float height() const { return m_height; } |
35 bool shrinkViewport() const { return m_shrinkViewport; } | 36 bool shrinkViewport() const { return m_shrinkViewport; } |
36 void setHeight(float height, bool shrinkViewport); | 37 void setHeight(float height, bool shrinkViewport); |
37 | 38 |
38 float shownRatio() const { return m_shownRatio; } | 39 float shownRatio() const { return m_shownRatio; } |
39 void setShownRatio(float); | 40 void setShownRatio(float); |
40 | 41 |
41 void updateConstraintsAndState(WebTopControlsState constraints, | 42 void updateConstraintsAndState(WebBrowserControlsState constraints, |
42 WebTopControlsState current, | 43 WebBrowserControlsState current, |
43 bool animate); | 44 bool animate); |
44 | 45 |
45 void scrollBegin(); | 46 void scrollBegin(); |
46 | 47 |
47 // Scrolls top controls vertically if possible and returns the remaining | 48 // Scrolls browser controls vertically if possible and returns the remaining |
48 // scroll amount. | 49 // scroll amount. |
49 FloatSize scrollBy(FloatSize scrollDelta); | 50 FloatSize scrollBy(FloatSize scrollDelta); |
50 | 51 |
51 private: | 52 private: |
52 explicit TopControls(const FrameHost&); | 53 explicit BrowserControls(const FrameHost&); |
53 void resetBaseline(); | 54 void resetBaseline(); |
54 | 55 |
55 Member<const FrameHost> m_frameHost; | 56 Member<const FrameHost> m_frameHost; |
56 | 57 |
57 // The top controls height regardless of whether it is visible or not. | 58 // The browser controls height regardless of whether it is visible or not. |
58 float m_height; | 59 float m_height; |
59 | 60 |
60 // The top controls shown amount (normalized from 0 to 1) since the last | 61 // The browser controls shown amount (normalized from 0 to 1) since the last |
61 // compositor commit. This value is updated from two sources: | 62 // compositor commit. This value is updated from two sources: |
62 // (1) compositor (impl) thread at the beginning of frame if it has | 63 // (1) compositor (impl) thread at the beginning of frame if it has |
63 // scrolled top controls since last commit. | 64 // scrolled browser controls since last commit. |
64 // (2) blink (main) thread updates this value if it scrolls top controls | 65 // (2) blink (main) thread updates this value if it scrolls browser controls |
65 // when responding to gesture scroll events. | 66 // when responding to gesture scroll events. |
66 // This value is reflected in web layer tree and is synced with compositor | 67 // This value is reflected in web layer tree and is synced with compositor |
67 // during the commit. | 68 // during the commit. |
68 float m_shownRatio; | 69 float m_shownRatio; |
69 | 70 |
70 // Content offset when last re-baseline occurred. | 71 // Content offset when last re-baseline occurred. |
71 float m_baselineContentOffset; | 72 float m_baselineContentOffset; |
72 | 73 |
73 // Accumulated scroll delta since last re-baseline. | 74 // Accumulated scroll delta since last re-baseline. |
74 float m_accumulatedScrollDelta; | 75 float m_accumulatedScrollDelta; |
75 | 76 |
76 // If this is true, then the embedder shrunk the WebView size by the top | 77 // If this is true, then the embedder shrunk the WebView size by the top |
77 // controls height. | 78 // controls height. |
78 bool m_shrinkViewport; | 79 bool m_shrinkViewport; |
79 | 80 |
80 // Constraints on the top controls state | 81 // Constraints on the browser controls state |
81 WebTopControlsState m_permittedState; | 82 WebBrowserControlsState m_permittedState; |
82 }; | 83 }; |
83 } // namespace blink | 84 } // namespace blink |
84 | 85 |
85 #endif // TopControls_h | 86 #endif // BrowserControls_h |
OLD | NEW |