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
31namespace WebCore {
32
33enum TileSizeMode {
34 StandardTileSizeMode,
35 GiantTileSizeMode
36};
37
38class FloatPoint;
39class FloatRect;
40class FloatSize;
41class IntRect;
42class IntSize;
43class PlatformCALayer;
44struct VelocityData;
45
46enum ScrollingModeIndication {
47 SynchronousScrollingBecauseOfLackOfScrollingCoordinatorIndication,
48 SynchronousScrollingBecauseOfStyleIndication,
49 SynchronousScrollingBecauseOfEventHandlersIndication,
50 AsyncScrollingIndication
51};
52
53class TiledBacking {
54public:
55 virtual ~TiledBacking() = default;
56
57 virtual void setVisibleRect(const FloatRect&) = 0;
58 virtual FloatRect visibleRect() const = 0;
59
60 // Only used to update the tile coverage map.
61 virtual void setLayoutViewportRect(Optional<FloatRect>) = 0;
62
63 virtual void setCoverageRect(const FloatRect&) = 0;
64 virtual FloatRect coverageRect() const = 0;
65 virtual bool tilesWouldChangeForCoverageRect(const FloatRect&) const = 0;
66
67 virtual void setTiledScrollingIndicatorPosition(const FloatPoint&) = 0;
68 virtual void setTopContentInset(float) = 0;
69
70 virtual void setVelocity(const VelocityData&) = 0;
71
72 virtual void setTileSizeUpdateDelayDisabledForTesting(bool) = 0;
73
74 enum {
75 NotScrollable = 0,
76 HorizontallyScrollable = 1 << 0,
77 VerticallyScrollable = 1 << 1
78 };
79 typedef unsigned Scrollability;
80 virtual void setScrollability(Scrollability) = 0;
81
82 virtual void prepopulateRect(const FloatRect&) = 0;
83
84 virtual void setIsInWindow(bool) = 0;
85 virtual bool isInWindow() const = 0;
86
87 enum {
88 CoverageForVisibleArea = 0,
89 CoverageForVerticalScrolling = 1 << 0,
90 CoverageForHorizontalScrolling = 1 << 1,
91 CoverageForScrolling = CoverageForVerticalScrolling | CoverageForHorizontalScrolling
92 };
93 typedef unsigned TileCoverage;
94
95 virtual void setTileCoverage(TileCoverage) = 0;
96 virtual TileCoverage tileCoverage() const = 0;
97
98 virtual FloatRect adjustTileCoverageRect(const FloatRect& coverageRect, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, bool sizeChanged) = 0;
99 virtual FloatRect adjustTileCoverageRectForScrolling(const FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, float contentsScale) = 0;
100
101 virtual void willStartLiveResize() = 0;
102 virtual void didEndLiveResize() = 0;
103
104 virtual IntSize tileSize() const = 0;
105
106 virtual void revalidateTiles() = 0;
107 virtual void forceRepaint() = 0;
108
109 virtual void setScrollingPerformanceLoggingEnabled(bool) = 0;
110 virtual bool scrollingPerformanceLoggingEnabled() const = 0;
111
112 virtual double retainedTileBackingStoreMemory() const = 0;
113
114 virtual void setHasMargins(bool marginTop, bool marginBottom, bool marginLeft, bool marginRight) = 0;
115 virtual void setMarginSize(int) = 0;
116 virtual bool hasMargins() const = 0;
117 virtual bool hasHorizontalMargins() const = 0;
118 virtual bool hasVerticalMargins() const = 0;
119
120 virtual int topMarginHeight() const = 0;
121 virtual int bottomMarginHeight() const = 0;
122 virtual int leftMarginWidth() const = 0;
123 virtual int rightMarginWidth() const = 0;
124
125 virtual void setZoomedOutContentsScale(float) = 0;
126 virtual float zoomedOutContentsScale() const = 0;
127
128 // Includes margins.
129 virtual IntRect bounds() const = 0;
130 virtual IntRect boundsWithoutMargin() const = 0;
131
132 // Exposed for testing
133 virtual IntRect tileCoverageRect() const = 0;
134 virtual IntRect tileGridExtent() const = 0;
135 virtual void setScrollingModeIndication(ScrollingModeIndication) = 0;
136
137#if USE(CA)
138 virtual PlatformCALayer* tiledScrollingIndicatorLayer() = 0;
139#endif
140};
141
142} // namespace WebCore
143