OLD | NEW |
1 /* | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 * Copyright (C) 2015 Google Inc. All rights reserved. | 2 // Use of this source code is governed by a BSD-style license that can be |
3 * | 3 // found in the LICENSE file. |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions | |
6 * are met: | |
7 * | |
8 * 1. Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * 2. Redistributions in binary form must reproduce the above copyright | |
11 * notice, this list of conditions and the following disclaimer in the | |
12 * documentation and/or other materials provided with the distribution. | |
13 * | |
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | |
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | |
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
24 */ | |
25 | 4 |
26 #ifndef TopControls_h | 5 #ifndef TopControls_h |
27 #define TopControls_h | 6 #define TopControls_h |
28 | 7 |
29 #include "platform/heap/Handle.h" | 8 #include "platform/heap/Handle.h" |
30 #include "public/platform/WebTopControlsState.h" | 9 #include "public/platform/WebTopControlsState.h" |
31 #include "wtf/OwnPtr.h" | 10 #include "wtf/OwnPtr.h" |
32 #include "wtf/PassOwnPtr.h" | 11 #include "wtf/PassOwnPtr.h" |
33 | 12 |
34 namespace blink { | 13 namespace blink { |
35 class FrameHost; | 14 class FrameHost; |
36 class FloatSize; | 15 class FloatSize; |
37 | 16 |
38 // This class encapsulate data and logic required to show/hide top controls | 17 // This class encapsulate data and logic required to show/hide top controls |
39 // duplicating cc::TopControlsManager behaviour. Top controls' self-animation | 18 // duplicating cc::TopControlsManager behaviour. Top controls' self-animation |
40 // to completion is still handled by compositor and kicks in when scrolling is | 19 // to completion is still handled by compositor and kicks in when scrolling is |
41 // complete (i.e, upon ScrollEnd or FlingEnd). | 20 // complete (i.e, upon ScrollEnd or FlingEnd). |
42 class TopControls final : public NoBaseWillBeGarbageCollectedFinalized<TopContro
ls> { | 21 class TopControls final : public NoBaseWillBeGarbageCollectedFinalized<TopContro
ls> { |
43 public: | 22 public: |
44 static PassOwnPtrWillBeRawPtr<TopControls> create(const FrameHost& host) | 23 static PassOwnPtrWillBeRawPtr<TopControls> create(const FrameHost& host) |
45 { | 24 { |
46 return adoptPtrWillBeNoop(new TopControls(host)); | 25 return adoptPtrWillBeNoop(new TopControls(host)); |
47 } | 26 } |
48 | 27 |
| 28 ~TopControls(); |
| 29 void trace(Visitor*); |
| 30 |
49 // The amount that the viewport was shrunk by to accommodate the top | 31 // The amount that the viewport was shrunk by to accommodate the top |
50 // controls. | 32 // controls. |
51 float layoutHeight(); | 33 float layoutHeight(); |
52 // The amount that top controls are currently shown. | 34 // The amount that top controls are currently shown. |
53 float contentOffset(); | 35 float contentOffset(); |
54 | 36 |
55 float height() const { return m_height; } | 37 float height() const { return m_height; } |
56 bool shrinkViewport() const { return m_shrinkViewport; } | 38 bool shrinkViewport() const { return m_shrinkViewport; } |
57 void setHeight(float height, bool shrinkViewport); | 39 void setHeight(float height, bool shrinkViewport); |
58 | 40 |
59 float shownRatio() const { return m_shownRatio; } | 41 float shownRatio() const { return m_shownRatio; } |
60 void setShownRatio(float); | 42 void setShownRatio(float); |
61 | 43 |
62 void updateConstraints(WebTopControlsState constraints); | 44 void updateConstraints(WebTopControlsState constraints); |
63 | 45 |
64 void scrollBegin(); | 46 void scrollBegin(); |
65 | 47 |
66 // Scrolls top controls vertically if possible and returns the remaining scr
oll | 48 // Scrolls top controls vertically if possible and returns the remaining scr
oll |
67 // amount. | 49 // amount. |
68 FloatSize scrollBy(FloatSize scrollDelta); | 50 FloatSize scrollBy(FloatSize scrollDelta); |
69 | 51 |
70 private: | 52 private: |
71 explicit TopControls(const FrameHost&); | 53 explicit TopControls(const FrameHost&); |
72 void resetBaseline(); | 54 void resetBaseline(); |
73 | 55 |
74 const FrameHost& m_frameHost; | 56 RawPtrWillBeMember<const FrameHost> m_frameHost; |
75 | 57 |
76 // The top controls height regardless of whether it is visible or not. | 58 // The top controls height regardless of whether it is visible or not. |
77 float m_height; | 59 float m_height; |
78 | 60 |
79 // The top controls shown amount (normalized from 0 to 1) since the last | 61 // The top controls shown amount (normalized from 0 to 1) since the last |
80 // compositor commit. This value is updated from two sources: | 62 // compositor commit. This value is updated from two sources: |
81 // (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 |
82 // scrolled top controls since last commit. | 64 // scrolled top controls since last commit. |
83 // (2) blink (main) thread updates this value if it scrolls top controls | 65 // (2) blink (main) thread updates this value if it scrolls top controls |
84 // when responding to gesture scroll events. | 66 // when responding to gesture scroll events. |
(...skipping 11 matching lines...) Expand all Loading... |
96 // controls height. | 78 // controls height. |
97 bool m_shrinkViewport; | 79 bool m_shrinkViewport; |
98 | 80 |
99 // Constraints on the top controls state | 81 // Constraints on the top controls state |
100 WebTopControlsState m_permittedState; | 82 WebTopControlsState m_permittedState; |
101 | 83 |
102 }; | 84 }; |
103 } // namespace blink | 85 } // namespace blink |
104 | 86 |
105 #endif // TopControls_h | 87 #endif // TopControls_h |
OLD | NEW |