Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 scroll top controls. | |
| 39 // Top controls' self-animation is still handled by compositor and kicks in when | |
| 40 // scroll is complete (i.e, ScrollEnd, or FlingEnd). | |
|
Rick Byers
2015/02/19 16:38:38
nit: Add a comment saying that this duplicates CC'
majidvp
2015/02/19 19:18:01
Done.
| |
| 41 class TopControls final : public NoBaseWillBeGarbageCollectedFinalized<TopContro ls> { | |
| 42 public: | |
| 43 static PassOwnPtrWillBeRawPtr<TopControls> create(const FrameHost& host) | |
| 44 { | |
| 45 return adoptPtrWillBeNoop(new TopControls(host)); | |
| 46 } | |
| 47 | |
| 48 // The amount that the viewport was shrunk by to accommodate the top | |
| 49 // controls. | |
| 50 float layoutHeight(); | |
| 51 // The amount that top controls are currently shown. | |
| 52 float contentOffset(); | |
| 53 | |
| 54 float height() const { return m_height; } | |
| 55 bool shrinkViewport() const { return m_shrinkViewport; } | |
| 56 void setHeight(float height, bool shrinkViewport); | |
| 57 | |
| 58 float shownRatio() const { return m_shownRatio; } | |
| 59 void setShownRatio(float); | |
| 60 | |
| 61 void updateConstraints(WebTopControlsState constraints); | |
| 62 | |
| 63 void scrollBegin(); | |
| 64 | |
| 65 // Scrolls top controls vertically if possible and returns the remaining scr oll | |
| 66 // amount. | |
| 67 FloatSize scrollBy(FloatSize scrollDelta); | |
|
Rick Byers
2015/02/19 16:38:38
conceptually this is a scroll customization (custo
majidvp
2015/02/19 19:18:01
I agree we should be able to model this as yet ano
| |
| 68 | |
| 69 private: | |
| 70 explicit TopControls(const FrameHost&); | |
| 71 void resetBaseline(); | |
| 72 | |
| 73 const FrameHost& m_frameHost; | |
| 74 | |
| 75 // The top controls height regardless of whether it is visible or not. | |
| 76 // |layoutHeight()| give your the amount that viewport is shrunk to | |
|
Rick Byers
2015/02/19 16:38:38
nit: "give your" -> "gives you"? Although I guess
majidvp
2015/02/19 19:18:01
Removed as it is indeed redundant.
| |
| 77 // accommodate top controls . | |
| 78 float m_height; | |
| 79 | |
| 80 // The top controls shown amount (normalized from 0 to 1) since the last | |
| 81 // compositor commit. This value is updated from two sources: | |
| 82 // (1) compositor (impl) thread at the beginning of frame if it has | |
| 83 // scrolled top controls since last commit. | |
| 84 // (2) blink (main) thread updates this value if it scrolls top controls | |
| 85 // when responding to gesture scroll events. | |
| 86 // This value is reflected in web layer tree and is synced with compositor | |
| 87 // during the commit. | |
| 88 float m_shownRatio; | |
| 89 | |
| 90 // Content offset when last re-baseline occurred. | |
| 91 float m_baselineContentOffset; | |
| 92 | |
| 93 // Accumulated scroll delta since last re-baseline. | |
| 94 float m_accumulatedScrollDelta; | |
| 95 | |
| 96 // If this is true, then the embedder shrunk the WebView size by the top | |
| 97 // controls height. | |
| 98 bool m_shrinkViewport; | |
| 99 | |
| 100 // Constraints on the top controls state | |
| 101 WebTopControlsState m_permittedState; | |
| 102 | |
| 103 }; | |
| 104 } // namespace blink | |
| 105 | |
| 106 #endif // TopControls_h | |
| OLD | NEW |