| 1 | /* |
| 2 | * Copyright (C) 2012 Apple 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 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
| 14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
| 17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 23 | * THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
| 26 | #pragma once |
| 27 | |
| 28 | #include <wtf/MonotonicTime.h> |
| 29 | #include <wtf/Optional.h> |
| 30 | |
| 31 | namespace WebCore { |
| 32 | |
| 33 | enum TileSizeMode { |
| 34 | StandardTileSizeMode, |
| 35 | GiantTileSizeMode |
| 36 | }; |
| 37 | |
| 38 | class FloatPoint; |
| 39 | class FloatRect; |
| 40 | class FloatSize; |
| 41 | class IntRect; |
| 42 | class IntSize; |
| 43 | class PlatformCALayer; |
| 44 | |
| 45 | enum ScrollingModeIndication { |
| 46 | SynchronousScrollingBecauseOfLackOfScrollingCoordinatorIndication, |
| 47 | SynchronousScrollingBecauseOfStyleIndication, |
| 48 | SynchronousScrollingBecauseOfEventHandlersIndication, |
| 49 | AsyncScrollingIndication |
| 50 | }; |
| 51 | |
| 52 | struct VelocityData { |
| 53 | double horizontalVelocity; |
| 54 | double verticalVelocity; |
| 55 | double scaleChangeRate; |
| 56 | MonotonicTime lastUpdateTime; |
| 57 | |
| 58 | VelocityData(double horizontal = 0, double vertical = 0, double scaleChange = 0, MonotonicTime updateTime = MonotonicTime()) |
| 59 | : horizontalVelocity(horizontal) |
| 60 | , verticalVelocity(vertical) |
| 61 | , scaleChangeRate(scaleChange) |
| 62 | , lastUpdateTime(updateTime) |
| 63 | { |
| 64 | } |
| 65 | |
| 66 | bool velocityOrScaleIsChanging() const |
| 67 | { |
| 68 | return horizontalVelocity || verticalVelocity || scaleChangeRate; |
| 69 | } |
| 70 | }; |
| 71 | |
| 72 | class TiledBacking { |
| 73 | public: |
| 74 | virtual ~TiledBacking() = default; |
| 75 | |
| 76 | virtual void setVisibleRect(const FloatRect&) = 0; |
| 77 | virtual FloatRect visibleRect() const = 0; |
| 78 | |
| 79 | // Only used to update the tile coverage map. |
| 80 | virtual void setLayoutViewportRect(Optional<FloatRect>) = 0; |
| 81 | |
| 82 | virtual void setCoverageRect(const FloatRect&) = 0; |
| 83 | virtual FloatRect coverageRect() const = 0; |
| 84 | virtual bool tilesWouldChangeForCoverageRect(const FloatRect&) const = 0; |
| 85 | |
| 86 | virtual void setTiledScrollingIndicatorPosition(const FloatPoint&) = 0; |
| 87 | virtual void setTopContentInset(float) = 0; |
| 88 | |
| 89 | virtual void setVelocity(const VelocityData&) = 0; |
| 90 | |
| 91 | virtual void setTileSizeUpdateDelayDisabledForTesting(bool) = 0; |
| 92 | |
| 93 | enum { |
| 94 | NotScrollable = 0, |
| 95 | HorizontallyScrollable = 1 << 0, |
| 96 | VerticallyScrollable = 1 << 1 |
| 97 | }; |
| 98 | typedef unsigned Scrollability; |
| 99 | virtual void setScrollability(Scrollability) = 0; |
| 100 | |
| 101 | virtual void prepopulateRect(const FloatRect&) = 0; |
| 102 | |
| 103 | virtual void setIsInWindow(bool) = 0; |
| 104 | virtual bool isInWindow() const = 0; |
| 105 | |
| 106 | enum { |
| 107 | CoverageForVisibleArea = 0, |
| 108 | CoverageForVerticalScrolling = 1 << 0, |
| 109 | CoverageForHorizontalScrolling = 1 << 1, |
| 110 | CoverageForScrolling = CoverageForVerticalScrolling | CoverageForHorizontalScrolling |
| 111 | }; |
| 112 | typedef unsigned TileCoverage; |
| 113 | |
| 114 | virtual void setTileCoverage(TileCoverage) = 0; |
| 115 | virtual TileCoverage tileCoverage() const = 0; |
| 116 | |
| 117 | virtual void adjustTileCoverageRect(FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, float contentsScale) const = 0; |
| 118 | |
| 119 | virtual void willStartLiveResize() = 0; |
| 120 | virtual void didEndLiveResize() = 0; |
| 121 | |
| 122 | virtual IntSize tileSize() const = 0; |
| 123 | |
| 124 | virtual void revalidateTiles() = 0; |
| 125 | virtual void forceRepaint() = 0; |
| 126 | |
| 127 | virtual void setScrollingPerformanceLoggingEnabled(bool) = 0; |
| 128 | virtual bool scrollingPerformanceLoggingEnabled() const = 0; |
| 129 | |
| 130 | virtual double retainedTileBackingStoreMemory() const = 0; |
| 131 | |
| 132 | virtual void setHasMargins(bool marginTop, bool marginBottom, bool marginLeft, bool marginRight) = 0; |
| 133 | virtual void setMarginSize(int) = 0; |
| 134 | virtual bool hasMargins() const = 0; |
| 135 | virtual bool hasHorizontalMargins() const = 0; |
| 136 | virtual bool hasVerticalMargins() const = 0; |
| 137 | |
| 138 | virtual int topMarginHeight() const = 0; |
| 139 | virtual int bottomMarginHeight() const = 0; |
| 140 | virtual int leftMarginWidth() const = 0; |
| 141 | virtual int rightMarginWidth() const = 0; |
| 142 | |
| 143 | virtual void setZoomedOutContentsScale(float) = 0; |
| 144 | virtual float zoomedOutContentsScale() const = 0; |
| 145 | |
| 146 | // Includes margins. |
| 147 | virtual IntRect bounds() const = 0; |
| 148 | virtual IntRect boundsWithoutMargin() const = 0; |
| 149 | |
| 150 | // Exposed for testing |
| 151 | virtual IntRect tileCoverageRect() const = 0; |
| 152 | virtual IntRect tileGridExtent() const = 0; |
| 153 | virtual void setScrollingModeIndication(ScrollingModeIndication) = 0; |
| 154 | |
| 155 | #if USE(CA) |
| 156 | virtual PlatformCALayer* tiledScrollingIndicatorLayer() = 0; |
| 157 | #endif |
| 158 | }; |
| 159 | |
| 160 | } // namespace WebCore |
| 161 | |