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

Side by Side Diff: Source/core/frame/TopControls.h

Issue 893683003: Implement top controls show/hide functionality for main thread scrolling (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix minor macro issue Created 5 years, 10 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
(Empty)
1 /*
2 * Copyright (C) 2015 Google Inc. All rights reserved.
3 *
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
26 #ifndef TopControls_h
27 #define TopControls_h
28
29 #include "platform/heap/Handle.h"
30 #include "public/platform/WebTopControlsState.h"
31 #include "wtf/OwnPtr.h"
32 #include "wtf/PassOwnPtr.h"
33
34 namespace blink {
35 class FrameHost;
36 class FloatSize;
37
38 // This class encapsulate data and logic required to show/hide top controls
39 // duplicating cc::TopControlsManager behaviour. Top controls' self-animation
40 // to completion is still handled by compositor and kicks in when scrolling is
41 // complete (i.e, upon ScrollEnd or FlingEnd).
42 class TopControls final : public NoBaseWillBeGarbageCollectedFinalized<TopContro ls> {
43 public:
44 static PassOwnPtrWillBeRawPtr<TopControls> create(const FrameHost& host)
45 {
46 return adoptPtrWillBeNoop(new TopControls(host));
47 }
48
49 // The amount that the viewport was shrunk by to accommodate the top
50 // controls.
51 float layoutHeight();
52 // The amount that top controls are currently shown.
53 float contentOffset();
54
55 float height() const { return m_height; }
56 bool shrinkViewport() const { return m_shrinkViewport; }
57 void setHeight(float height, bool shrinkViewport);
58
59 float shownRatio() const { return m_shownRatio; }
60 void setShownRatio(float);
61
62 void updateConstraints(WebTopControlsState constraints);
63
64 void scrollBegin();
65
66 // Scrolls top controls vertically if possible and returns the remaining scr oll
67 // amount.
68 FloatSize scrollBy(FloatSize scrollDelta);
69
70 private:
71 explicit TopControls(const FrameHost&);
72 void resetBaseline();
73
74 const FrameHost& m_frameHost;
75
76 // The top controls height regardless of whether it is visible or not.
77 float m_height;
78
79 // The top controls shown amount (normalized from 0 to 1) since the last
80 // compositor commit. This value is updated from two sources:
81 // (1) compositor (impl) thread at the beginning of frame if it has
82 // scrolled top controls since last commit.
83 // (2) blink (main) thread updates this value if it scrolls top controls
84 // when responding to gesture scroll events.
85 // This value is reflected in web layer tree and is synced with compositor
86 // during the commit.
87 float m_shownRatio;
88
89 // Content offset when last re-baseline occurred.
90 float m_baselineContentOffset;
91
92 // Accumulated scroll delta since last re-baseline.
93 float m_accumulatedScrollDelta;
94
95 // If this is true, then the embedder shrunk the WebView size by the top
96 // controls height.
97 bool m_shrinkViewport;
98
99 // Constraints on the top controls state
100 WebTopControlsState m_permittedState;
101
102 };
103 } // namespace blink
104
105 #endif // TopControls_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698