Chromium Code Reviews| Index: Source/core/frame/TopControls.h |
| diff --git a/Source/core/frame/TopControls.h b/Source/core/frame/TopControls.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..96ce56db7fe3ce439d173bbd027efd9302acd191 |
| --- /dev/null |
| +++ b/Source/core/frame/TopControls.h |
| @@ -0,0 +1,106 @@ |
| +/* |
| + * Copyright (C) 2015 Google Inc. All rights reserved. |
| + * |
| + * Redistribution and use in source and binary forms, with or without |
| + * modification, are permitted provided that the following conditions |
| + * are met: |
| + * |
| + * 1. Redistributions of source code must retain the above copyright |
| + * notice, this list of conditions and the following disclaimer. |
| + * 2. Redistributions in binary form must reproduce the above copyright |
| + * notice, this list of conditions and the following disclaimer in the |
| + * documentation and/or other materials provided with the distribution. |
| + * |
| + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
| + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| + */ |
| + |
| +#ifndef TopControls_h |
| +#define TopControls_h |
| + |
| +#include "platform/heap/Handle.h" |
| +#include "public/platform/WebTopControlsState.h" |
| +#include "wtf/OwnPtr.h" |
| +#include "wtf/PassOwnPtr.h" |
| + |
| +namespace blink { |
| +class FrameHost; |
| +class FloatSize; |
| + |
| +// This class encapsulate data and logic required to scroll top controls. |
| +// Top controls' self-animation is still handled by compositor and kicks in when |
| +// 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.
|
| +class TopControls final : public NoBaseWillBeGarbageCollectedFinalized<TopControls> { |
| +public: |
| + static PassOwnPtrWillBeRawPtr<TopControls> create(const FrameHost& host) |
| + { |
| + return adoptPtrWillBeNoop(new TopControls(host)); |
| + } |
| + |
| + // The amount that the viewport was shrunk by to accommodate the top |
| + // controls. |
| + float layoutHeight(); |
| + // The amount that top controls are currently shown. |
| + float contentOffset(); |
| + |
| + float height() const { return m_height; } |
| + bool shrinkViewport() const { return m_shrinkViewport; } |
| + void setHeight(float height, bool shrinkViewport); |
| + |
| + float shownRatio() const { return m_shownRatio; } |
| + void setShownRatio(float); |
| + |
| + void updateConstraints(WebTopControlsState constraints); |
| + |
| + void scrollBegin(); |
| + |
| + // Scrolls top controls vertically if possible and returns the remaining scroll |
| + // amount. |
| + 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
|
| + |
| +private: |
| + explicit TopControls(const FrameHost&); |
| + void resetBaseline(); |
| + |
| + const FrameHost& m_frameHost; |
| + |
| + // The top controls height regardless of whether it is visible or not. |
| + // |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.
|
| + // accommodate top controls . |
| + float m_height; |
| + |
| + // The top controls shown amount (normalized from 0 to 1) since the last |
| + // compositor commit. This value is updated from two sources: |
| + // (1) compositor (impl) thread at the beginning of frame if it has |
| + // scrolled top controls since last commit. |
| + // (2) blink (main) thread updates this value if it scrolls top controls |
| + // when responding to gesture scroll events. |
| + // This value is reflected in web layer tree and is synced with compositor |
| + // during the commit. |
| + float m_shownRatio; |
| + |
| + // Content offset when last re-baseline occurred. |
| + float m_baselineContentOffset; |
| + |
| + // Accumulated scroll delta since last re-baseline. |
| + float m_accumulatedScrollDelta; |
| + |
| + // If this is true, then the embedder shrunk the WebView size by the top |
| + // controls height. |
| + bool m_shrinkViewport; |
| + |
| + // Constraints on the top controls state |
| + WebTopControlsState m_permittedState; |
| + |
| +}; |
| +} // namespace blink |
| + |
| +#endif // TopControls_h |