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

Side by Side Diff: Source/web/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 hiding at the page bottom 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 "public/web/WebTopControlsState.h"
30
31 namespace blink {
32 class PlatformGestureEvent;
33 class WebViewImpl;
34
35 // This class encapsulate data and logic required to scroll top controls.
36 // Top controls' self-animation is still handled by compositor and kicks in when
37 // scroll is complete (i.e, ScrollEnd, or FlingEnd).
38 class TopControls {
39 public:
40 explicit TopControls(WebViewImpl*);
41
42 // The amount that the viewport was shrunk by to accommodate the top
43 // controls.
44 float layoutHeight();
45 // The amount that top controls are currently shown.
46 float contentOffset();
47
48 void setHeight(float);
49 void setShrinkViewport(bool);
50
51 float shownRatio() {return m_shownRatio;};
aelias_OOO_until_Jul13 2015/02/13 02:03:17 Should be const, have spaces around the braces, an
majidvp 2015/02/18 21:03:57 Done.
52 void setShownRatio(float);
53 void updateShownRatio(float delta);
aelias_OOO_until_Jul13 2015/02/13 02:03:17 I think this alternate way of setting it is more c
majidvp 2015/02/18 21:03:56 Done.
54
55 void updateState(
aelias_OOO_until_Jul13 2015/02/13 02:03:17 Let's just make this updateConstraints() since the
majidvp 2015/02/18 21:03:57 Done.
56 WebTopControlsState constraints,
57 WebTopControlsState current,
58 bool animate);
59
60 // Handles gesture event and returns true if event was consumed.
61 // |remainingDeltaY| will be the amount of vertical scroll that was not cons umed.
62 bool handleGestureEvent(const PlatformGestureEvent&, float* remainingDeltaY) ;
63
64 private:
65 void scrollBegin();
66 // Scrolls top controls vertically if possible and returns the remaining scr oll
67 // amount.
68 float scrollBy(float scrollDelta);
69 void resetBaseline();
70
71 WebViewImpl* m_webView;
72
73 // The top controls height regardless of whether it is visible or not.
74 // |layoutHeight()| give your the amount that viewport is shrunk to
75 // accommodate top controls .
76 float m_height;
77
78 // The top controls shown amount (normalized from 0 to 1) since the last
79 // compositor commit. This value is updated from two sources:
80 // (1) compositor (impl) thread at the beginning of frame if it has
81 // scrolled top controls since last commit.
82 // (2) blink (main) thread updates this value if it scrolls top controls
83 // when responding to gesture scroll events.
84 // This value is reflected in web layer tree and is synced with compositor
85 // during the commit.
86 float m_shownRatio;
87
88 // Content offset when last re-baseline occurred.
89 float m_baselineContentOffset;
90
91 // Accumulated scroll delta since last re-baseline.
92 float m_accumulatedScrollDelta;
93
94 // If this is true, then the embedder shrunk the WebView size by the top
95 // controls height.
96 bool m_shrinkViewport;
97
98 // Constraints on the top controls state
99 WebTopControlsState m_permittedState;
100
101 // It true, then a pinch is in progress which causes top controls to ignore
102 // any scroll updates.
103 bool m_pinchGestureActive;
104 };
105 } // namespace blink
106
107 #endif // TopControls_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698