Diff
Modified: trunk/LayoutTests/ChangeLog (245836 => 245837)
--- trunk/LayoutTests/ChangeLog 2019-05-29 01:05:45 UTC (rev 245836)
+++ trunk/LayoutTests/ChangeLog 2019-05-29 01:07:03 UTC (rev 245837)
@@ -1,3 +1,18 @@
+2019-05-28 Simon Fraser <[email protected]>
+
+ Use scroll-velocity-based tile coverage for overflow:scroll
+ https://bugs.webkit.org/show_bug.cgi?id=198294
+ rdar://problem/48942184
+
+ Reviewed by Tim Horton.
+
+ * tiled-drawing/scrolling/overflow/overflow-scrolled-down-tile-coverage-expected.txt: Added.
+ * tiled-drawing/scrolling/overflow/overflow-scrolled-down-tile-coverage.html: Added.
+ * tiled-drawing/scrolling/overflow/overflow-scrolled-up-tile-coverage-expected.txt: Added.
+ * tiled-drawing/scrolling/overflow/overflow-scrolled-up-tile-coverage.html: Added.
+ * tiled-drawing/scrolling/overflow/overflow-tile-coverage-expected.txt: Added.
+ * tiled-drawing/scrolling/overflow/overflow-tile-coverage.html: Added.
+
2019-05-28 Youenn Fablet <[email protected]>
createAnswer() SDP Rejected by setLocalDescription()
Added: trunk/LayoutTests/tiled-drawing/scrolling/overflow/overflow-scrolled-down-tile-coverage-expected.txt (0 => 245837)
--- trunk/LayoutTests/tiled-drawing/scrolling/overflow/overflow-scrolled-down-tile-coverage-expected.txt (rev 0)
+++ trunk/LayoutTests/tiled-drawing/scrolling/overflow/overflow-scrolled-down-tile-coverage-expected.txt 2019-05-29 01:07:03 UTC (rev 245837)
@@ -0,0 +1,63 @@
+(GraphicsLayer
+ (anchor 0.00 0.00)
+ (bounds 785.00 700.00)
+ (visible rect 0.00, 0.00 785.00 x 600.00)
+ (coverage rect 0.00, 0.00 785.00 x 600.00)
+ (intersects coverage rect 1)
+ (contentsScale 1.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 785.00 700.00)
+ (contentsOpaque 1)
+ (visible rect 0.00, 0.00 785.00 x 600.00)
+ (coverage rect 0.00, 0.00 785.00 x 600.00)
+ (intersects coverage rect 1)
+ (contentsScale 1.00)
+ (tile cache coverage 0, 0 785 x 700)
+ (tile size 785 x 512)
+ (top left tile 0, 0 tiles grid 1 x 2)
+ (in window 1)
+ (children 1
+ (GraphicsLayer
+ (position 58.00 50.00)
+ (bounds 402.00 514.00)
+ (drawsContent 1)
+ (visible rect 0.00, 0.00 402.00 x 514.00)
+ (coverage rect -58.00, -50.00 785.00 x 600.00)
+ (intersects coverage rect 1)
+ (contentsScale 1.00)
+ (children 1
+ (GraphicsLayer
+ (offsetFromRenderer width=1 height=1)
+ (position 1.00 1.00)
+ (bounds 385.00 512.00)
+ (visible rect 0.00, 0.00 385.00 x 512.00)
+ (coverage rect 0.00, 0.00 385.00 x 512.00)
+ (intersects coverage rect 1)
+ (contentsScale 1.00)
+ (children 1
+ (GraphicsLayer
+ (offsetFromRenderer width=1 height=1)
+ (scrollOffset (0,1800))
+ (position 0.00 -1800.00)
+ (anchor 0.00 0.00)
+ (bounds 385.00 3000.00)
+ (drawsContent 1)
+ (visible rect 0.00, 1800.00 385.00 x 512.00)
+ (coverage rect 0.00, 1544.00 897.00 x 1024.00)
+ (intersects coverage rect 1)
+ (contentsScale 1.00)
+ (tile cache coverage 0, 1536 385 x 1464)
+ (tile size 512 x 512)
+ (top left tile 0, 3 tiles grid 1 x 3)
+ (in window 1)
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+)
+
Added: trunk/LayoutTests/tiled-drawing/scrolling/overflow/overflow-scrolled-down-tile-coverage.html (0 => 245837)
--- trunk/LayoutTests/tiled-drawing/scrolling/overflow/overflow-scrolled-down-tile-coverage.html (rev 0)
+++ trunk/LayoutTests/tiled-drawing/scrolling/overflow/overflow-scrolled-down-tile-coverage.html 2019-05-29 01:07:03 UTC (rev 245837)
@@ -0,0 +1,54 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<head>
+ <style>
+ #scroller {
+ margin: 50px;
+ height: 512px;
+ width: 400px;
+ overflow-y: scroll;
+ border: 1px solid black;
+ }
+
+ .contents {
+ height: 3000px;
+ background-image: repeating-linear-gradient(white, silver 400px);
+ }
+
+ </style>
+ <script>
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ }
+
+ function startTest()
+ {
+ requestAnimationFrame(() => {
+ scroller.scrollTop = 2000;
+
+ requestAnimationFrame(() => {
+ scroller.scrollTop = 1800;
+
+ document.getElementById('layers').innerText = internals.layerTreeAsText(document,
+ internals.LAYER_TREE_INCLUDES_VISIBLE_RECTS | internals.LAYER_TREE_INCLUDES_TILE_CACHES);
+
+ if (window.testRunner)
+ testRunner.notifyDone();
+ });
+ });
+ }
+
+ window.addEventListener('load', startTest, false);
+ </script>
+</head>
+<body>
+
+ <div id="scroller">
+ <div class="contents">
+ </div>
+ </div>
+
+<pre id="layers">Layer tree goes here</p>
+</body>
+</html>
Added: trunk/LayoutTests/tiled-drawing/scrolling/overflow/overflow-scrolled-up-tile-coverage-expected.txt (0 => 245837)
--- trunk/LayoutTests/tiled-drawing/scrolling/overflow/overflow-scrolled-up-tile-coverage-expected.txt (rev 0)
+++ trunk/LayoutTests/tiled-drawing/scrolling/overflow/overflow-scrolled-up-tile-coverage-expected.txt 2019-05-29 01:07:03 UTC (rev 245837)
@@ -0,0 +1,63 @@
+(GraphicsLayer
+ (anchor 0.00 0.00)
+ (bounds 785.00 700.00)
+ (visible rect 0.00, 0.00 785.00 x 600.00)
+ (coverage rect 0.00, 0.00 785.00 x 600.00)
+ (intersects coverage rect 1)
+ (contentsScale 1.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 785.00 700.00)
+ (contentsOpaque 1)
+ (visible rect 0.00, 0.00 785.00 x 600.00)
+ (coverage rect 0.00, 0.00 785.00 x 600.00)
+ (intersects coverage rect 1)
+ (contentsScale 1.00)
+ (tile cache coverage 0, 0 785 x 700)
+ (tile size 785 x 512)
+ (top left tile 0, 0 tiles grid 1 x 2)
+ (in window 1)
+ (children 1
+ (GraphicsLayer
+ (position 58.00 50.00)
+ (bounds 402.00 514.00)
+ (drawsContent 1)
+ (visible rect 0.00, 0.00 402.00 x 514.00)
+ (coverage rect -58.00, -50.00 785.00 x 600.00)
+ (intersects coverage rect 1)
+ (contentsScale 1.00)
+ (children 1
+ (GraphicsLayer
+ (offsetFromRenderer width=1 height=1)
+ (position 1.00 1.00)
+ (bounds 385.00 512.00)
+ (visible rect 0.00, 0.00 385.00 x 512.00)
+ (coverage rect 0.00, 0.00 385.00 x 512.00)
+ (intersects coverage rect 1)
+ (contentsScale 1.00)
+ (children 1
+ (GraphicsLayer
+ (offsetFromRenderer width=1 height=1)
+ (scrollOffset (0,200))
+ (position 0.00 -200.00)
+ (anchor 0.00 0.00)
+ (bounds 385.00 3000.00)
+ (drawsContent 1)
+ (visible rect 0.00, 200.00 385.00 x 512.00)
+ (coverage rect 0.00, 0.00 897.00 x 1024.00)
+ (intersects coverage rect 1)
+ (contentsScale 1.00)
+ (tile cache coverage 0, 0 385 x 1024)
+ (tile size 512 x 512)
+ (top left tile 0, 0 tiles grid 1 x 2)
+ (in window 1)
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+)
+
Added: trunk/LayoutTests/tiled-drawing/scrolling/overflow/overflow-scrolled-up-tile-coverage.html (0 => 245837)
--- trunk/LayoutTests/tiled-drawing/scrolling/overflow/overflow-scrolled-up-tile-coverage.html (rev 0)
+++ trunk/LayoutTests/tiled-drawing/scrolling/overflow/overflow-scrolled-up-tile-coverage.html 2019-05-29 01:07:03 UTC (rev 245837)
@@ -0,0 +1,54 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<head>
+ <style>
+ #scroller {
+ margin: 50px;
+ height: 512px;
+ width: 400px;
+ overflow-y: scroll;
+ border: 1px solid black;
+ }
+
+ .contents {
+ height: 3000px;
+ background-image: repeating-linear-gradient(white, silver 400px);
+ }
+
+ </style>
+ <script>
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ }
+
+ function startTest()
+ {
+ requestAnimationFrame(() => {
+ scroller.scrollTop = 20;
+
+ requestAnimationFrame(() => {
+ scroller.scrollTop = 200;
+
+ document.getElementById('layers').innerText = internals.layerTreeAsText(document,
+ internals.LAYER_TREE_INCLUDES_VISIBLE_RECTS | internals.LAYER_TREE_INCLUDES_TILE_CACHES);
+
+ if (window.testRunner)
+ testRunner.notifyDone();
+ });
+ });
+ }
+
+ window.addEventListener('load', startTest, false);
+ </script>
+</head>
+<body>
+
+ <div id="scroller">
+ <div class="contents">
+ </div>
+ </div>
+
+<pre id="layers">Layer tree goes here</p>
+</body>
+</html>
Added: trunk/LayoutTests/tiled-drawing/scrolling/overflow/overflow-tile-coverage-expected.txt (0 => 245837)
--- trunk/LayoutTests/tiled-drawing/scrolling/overflow/overflow-tile-coverage-expected.txt (rev 0)
+++ trunk/LayoutTests/tiled-drawing/scrolling/overflow/overflow-tile-coverage-expected.txt 2019-05-29 01:07:03 UTC (rev 245837)
@@ -0,0 +1,61 @@
+(GraphicsLayer
+ (anchor 0.00 0.00)
+ (bounds 785.00 700.00)
+ (visible rect 0.00, 0.00 785.00 x 600.00)
+ (coverage rect 0.00, 0.00 785.00 x 600.00)
+ (intersects coverage rect 1)
+ (contentsScale 1.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 785.00 700.00)
+ (contentsOpaque 1)
+ (visible rect 0.00, 0.00 785.00 x 600.00)
+ (coverage rect 0.00, 0.00 785.00 x 600.00)
+ (intersects coverage rect 1)
+ (contentsScale 1.00)
+ (tile cache coverage 0, 0 785 x 700)
+ (tile size 785 x 512)
+ (top left tile 0, 0 tiles grid 1 x 2)
+ (in window 1)
+ (children 1
+ (GraphicsLayer
+ (position 58.00 50.00)
+ (bounds 402.00 514.00)
+ (drawsContent 1)
+ (visible rect 0.00, 0.00 402.00 x 514.00)
+ (coverage rect -58.00, -50.00 785.00 x 600.00)
+ (intersects coverage rect 1)
+ (contentsScale 1.00)
+ (children 1
+ (GraphicsLayer
+ (offsetFromRenderer width=1 height=1)
+ (position 1.00 1.00)
+ (bounds 385.00 512.00)
+ (visible rect 0.00, 0.00 385.00 x 512.00)
+ (coverage rect 0.00, 0.00 385.00 x 512.00)
+ (intersects coverage rect 1)
+ (contentsScale 1.00)
+ (children 1
+ (GraphicsLayer
+ (offsetFromRenderer width=1 height=1)
+ (anchor 0.00 0.00)
+ (bounds 385.00 3000.00)
+ (drawsContent 1)
+ (visible rect 0.00, 0.00 385.00 x 512.00)
+ (coverage rect 0.00, 0.00 385.00 x 512.00)
+ (intersects coverage rect 1)
+ (contentsScale 1.00)
+ (tile cache coverage 0, 0 385 x 512)
+ (tile size 512 x 512)
+ (top left tile 0, 0 tiles grid 1 x 1)
+ (in window 1)
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+)
+
Added: trunk/LayoutTests/tiled-drawing/scrolling/overflow/overflow-tile-coverage.html (0 => 245837)
--- trunk/LayoutTests/tiled-drawing/scrolling/overflow/overflow-tile-coverage.html (rev 0)
+++ trunk/LayoutTests/tiled-drawing/scrolling/overflow/overflow-tile-coverage.html 2019-05-29 01:07:03 UTC (rev 245837)
@@ -0,0 +1,38 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<head>
+ <style>
+ .scroller {
+ margin: 50px;
+ height: 512px;
+ width: 400px;
+ overflow-y: scroll;
+ border: 1px solid black;
+ }
+
+ .contents {
+ height: 3000px;
+ background-image: repeating-linear-gradient(white, silver 400px);
+ }
+
+ </style>
+ <script>
+ if (window.testRunner)
+ testRunner.dumpAsText();
+
+ window.addEventListener('load', () => {
+ document.getElementById('layers').innerText = internals.layerTreeAsText(document,
+ internals.LAYER_TREE_INCLUDES_VISIBLE_RECTS | internals.LAYER_TREE_INCLUDES_TILE_CACHES);
+ }, false);
+ </script>
+</head>
+<body>
+
+ <div class="scroller">
+ <div class="contents">
+ </div>
+ </div>
+
+<pre id="layers">Layer tree goes here</p>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (245836 => 245837)
--- trunk/Source/WebCore/ChangeLog 2019-05-29 01:05:45 UTC (rev 245836)
+++ trunk/Source/WebCore/ChangeLog 2019-05-29 01:07:03 UTC (rev 245837)
@@ -1,3 +1,47 @@
+2019-05-28 Simon Fraser <[email protected]>
+
+ Use scroll-velocity-based tile coverage for overflow:scroll
+ https://bugs.webkit.org/show_bug.cgi?id=198294
+ rdar://problem/48942184
+
+ Reviewed by Tim Horton.
+
+ Start using a velocity-based tile coverage computation on layers with Type::ScrolledContents,
+ which is the content layers for overflow:scroll when they get big enough to get tiled.
+
+ Move legacy macOS coverage code into adjustTileCoverageForDesktopPageScrolling() because
+ I don't want to change its behavior in this patch. Use TileController::adjustTileCoverageRectForScrolling()
+ for iOS and macOS overflow scrolling. Since only iOS page scrolling gets velocity data from the UI
+ process, compute velocity in TileController using the visible rect top-left.
+
+ For overflow scroll, we have to plumb horizontal and vertical coverage in from
+ RenderLayerBacking.
+
+ Tests: tiled-drawing/scrolling/overflow/overflow-scrolled-down-tile-coverage.html
+ tiled-drawing/scrolling/overflow/overflow-scrolled-up-tile-coverage.html
+ tiled-drawing/scrolling/overflow/overflow-tile-coverage.html
+
+ * platform/graphics/TiledBacking.h:
+ * platform/graphics/ca/GraphicsLayerCA.cpp:
+ (WebCore::GraphicsLayerCA::adjustCoverageRect const):
+ * platform/graphics/ca/PlatformCALayer.h:
+ * platform/graphics/ca/TileController.cpp:
+ (WebCore::TileController::setVelocity):
+ (WebCore::TileController::adjustTileCoverageRect):
+ (WebCore::TileController::adjustTileCoverageForDesktopPageScrolling const):
+ (WebCore::TileController::adjustTileCoverageWithScrollingVelocity const):
+ (WebCore::TileController::adjustTileCoverageRectForScrolling):
+ (WebCore::expandRectWithinRect): Deleted.
+ (WebCore::TileController::adjustTileCoverageRect const): Deleted.
+ (WebCore::TileController::adjustTileCoverageRectForScrolling const): Deleted.
+ * platform/graphics/ca/TileController.h:
+ * rendering/RenderLayer.h:
+ * rendering/RenderLayerBacking.cpp:
+ (WebCore::computePageTiledBackingCoverage):
+ (WebCore::computeOverflowTiledBackingCoverage):
+ (WebCore::RenderLayerBacking::adjustTiledBackingCoverage):
+ (WebCore::RenderLayerBacking::updateGeometry):
+
2019-05-28 Shawn Roberts <[email protected]>
Unreviewed, rolling out r245475.
Modified: trunk/Source/WebCore/platform/graphics/TiledBacking.h (245836 => 245837)
--- trunk/Source/WebCore/platform/graphics/TiledBacking.h 2019-05-29 01:05:45 UTC (rev 245836)
+++ trunk/Source/WebCore/platform/graphics/TiledBacking.h 2019-05-29 01:07:03 UTC (rev 245837)
@@ -95,8 +95,8 @@
virtual void setTileCoverage(TileCoverage) = 0;
virtual TileCoverage tileCoverage() const = 0;
- virtual FloatRect adjustTileCoverageRect(const FloatRect& coverageRect, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, bool sizeChanged) const = 0;
- virtual FloatRect adjustTileCoverageRectForScrolling(const FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, float contentsScale) const = 0;
+ virtual FloatRect adjustTileCoverageRect(const FloatRect& coverageRect, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, bool sizeChanged) = 0;
+ virtual FloatRect adjustTileCoverageRectForScrolling(const FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, float contentsScale) = 0;
virtual void willStartLiveResize() = 0;
virtual void didEndLiveResize() = 0;
Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (245836 => 245837)
--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp 2019-05-29 01:05:45 UTC (rev 245836)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp 2019-05-29 01:07:03 UTC (rev 245837)
@@ -1447,9 +1447,12 @@
case Type::PageTiledBacking:
coverageRect = tiledBacking()->adjustTileCoverageRectForScrolling(coverageRect, size(), oldVisibleRect, rects.visibleRect, pageScaleFactor() * deviceScaleFactor());
break;
+ case Type::ScrolledContents:
+ if (m_layer->usesTiledBackingLayer())
+ coverageRect = tiledBacking()->adjustTileCoverageRectForScrolling(coverageRect, size(), oldVisibleRect, rects.visibleRect, pageScaleFactor() * deviceScaleFactor());
+ break;
case Type::Normal:
- case Type::ScrolledContents:
- if (m_layer->layerType() == PlatformCALayer::LayerTypeTiledBackingLayer)
+ if (m_layer->usesTiledBackingLayer())
coverageRect = tiledBacking()->adjustTileCoverageRect(coverageRect, oldVisibleRect, rects.visibleRect, size() != m_sizeAtLastCoverageRectUpdate);
break;
default:
Modified: trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h (245836 => 245837)
--- trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h 2019-05-29 01:05:45 UTC (rev 245836)
+++ trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h 2019-05-29 01:07:03 UTC (rev 245837)
@@ -99,6 +99,8 @@
bool usesTiledBackingLayer() const { return layerType() == LayerTypePageTiledBackingLayer || layerType() == LayerTypeTiledBackingLayer; }
+ bool isPageTiledBackingLayer() const { return layerType() == LayerTypePageTiledBackingLayer; }
+
PlatformCALayerClient* owner() const { return m_owner; }
virtual void setOwner(PlatformCALayerClient* owner) { m_owner = owner; }
Modified: trunk/Source/WebCore/platform/graphics/ca/TileController.cpp (245836 => 245837)
--- trunk/Source/WebCore/platform/graphics/ca/TileController.cpp 2019-05-29 01:05:45 UTC (rev 245836)
+++ trunk/Source/WebCore/platform/graphics/ca/TileController.cpp 2019-05-29 01:07:03 UTC (rev 245837)
@@ -240,8 +240,10 @@
void TileController::setVelocity(const VelocityData& velocity)
{
bool changeAffectsTileCoverage = m_velocity.velocityOrScaleIsChanging() || velocity.velocityOrScaleIsChanging();
+
m_velocity = velocity;
-
+ m_haveExternalVelocityData = true;
+
if (changeAffectsTileCoverage)
setNeedsRevalidateTiles();
}
@@ -360,34 +362,8 @@
return boundsWithoutMargin;
}
-#if !PLATFORM(IOS_FAMILY)
-// Return 'rect' padded evenly on all sides to achieve 'newSize', but make the padding uneven to contain within constrainingRect.
-static FloatRect expandRectWithinRect(const FloatRect& rect, const FloatSize& newSize, const FloatRect& constrainingRect)
+FloatRect TileController::adjustTileCoverageRect(const FloatRect& coverageRect, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, bool sizeChanged)
{
- ASSERT(newSize.width() >= rect.width() && newSize.height() >= rect.height());
-
- FloatSize extraSize = newSize - rect.size();
-
- FloatRect expandedRect = rect;
- expandedRect.inflateX(extraSize.width() / 2);
- expandedRect.inflateY(extraSize.height() / 2);
-
- if (expandedRect.x() < constrainingRect.x())
- expandedRect.setX(constrainingRect.x());
- else if (expandedRect.maxX() > constrainingRect.maxX())
- expandedRect.setX(constrainingRect.maxX() - expandedRect.width());
-
- if (expandedRect.y() < constrainingRect.y())
- expandedRect.setY(constrainingRect.y());
- else if (expandedRect.maxY() > constrainingRect.maxY())
- expandedRect.setY(constrainingRect.maxY() - expandedRect.height());
-
- return intersection(expandedRect, constrainingRect);
-}
-#endif
-
-FloatRect TileController::adjustTileCoverageRect(const FloatRect& coverageRect, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, bool sizeChanged) const
-{
// If the old visible rect is empty, we have no information about how the visible area is changing
// (maybe the layer was just created), so don't attempt to expand. Also don't attempt to expand
// if the size changed or the rects don't overlap.
@@ -449,16 +425,63 @@
return unionRect(coverageRect, expandedRect);
}
-FloatRect TileController::adjustTileCoverageRectForScrolling(const FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& visibleRect, float contentsScale) const
+#if !PLATFORM(IOS_FAMILY)
+// Coverage expansion for less memory-constrained devices.
+// Kept separate to preserve historical behavior; should be merged with adjustTileCoverageWithScrollingVelocity eventually.
+FloatRect TileController::adjustTileCoverageForDesktopPageScrolling(const FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& visibleRect) const
{
- // If the page is not in a window (for example if it's in a background tab), we limit the tile coverage rect to the visible rect.
- if (!m_isInWindow)
- return visibleRect;
+ // FIXME: look at how far the document can scroll in each dimension.
+ FloatSize coverageSize = visibleRect.size();
-#if PLATFORM(IOS_FAMILY)
- // FIXME: unify the iOS and Mac code.
- UNUSED_PARAM(previousVisibleRect);
-
+ bool largeVisibleRectChange = !previousVisibleRect.isEmpty() && !visibleRect.intersects(previousVisibleRect);
+
+ // Inflate the coverage rect so that it covers 2x of the visible width and 3x of the visible height.
+ // These values were chosen because it's more common to have tall pages and to scroll vertically,
+ // so we keep more tiles above and below the current area.
+ float widthScale = 1;
+ float heightScale = 1;
+
+ if (m_tileCoverage & CoverageForHorizontalScrolling && !largeVisibleRectChange)
+ widthScale = 2;
+
+ if (m_tileCoverage & CoverageForVerticalScrolling && !largeVisibleRectChange)
+ heightScale = 3;
+
+ coverageSize.scale(widthScale, heightScale);
+
+ FloatRect coverageBounds = boundsForSize(newSize);
+
+ // Return 'rect' padded evenly on all sides to achieve 'newSize', but make the padding uneven to contain within constrainingRect.
+ auto expandRectWithinRect = [](const FloatRect& rect, const FloatSize& newSize, const FloatRect& constrainingRect) {
+ ASSERT(newSize.width() >= rect.width() && newSize.height() >= rect.height());
+
+ FloatSize extraSize = newSize - rect.size();
+
+ FloatRect expandedRect = rect;
+ expandedRect.inflateX(extraSize.width() / 2);
+ expandedRect.inflateY(extraSize.height() / 2);
+
+ if (expandedRect.x() < constrainingRect.x())
+ expandedRect.setX(constrainingRect.x());
+ else if (expandedRect.maxX() > constrainingRect.maxX())
+ expandedRect.setX(constrainingRect.maxX() - expandedRect.width());
+
+ if (expandedRect.y() < constrainingRect.y())
+ expandedRect.setY(constrainingRect.y());
+ else if (expandedRect.maxY() > constrainingRect.maxY())
+ expandedRect.setY(constrainingRect.maxY() - expandedRect.height());
+
+ return intersection(expandedRect, constrainingRect);
+ };
+
+ FloatRect coverage = expandRectWithinRect(visibleRect, coverageSize, coverageBounds);
+ LOG_WITH_STREAM(Tiling, stream << "TileController::adjustTileCoverageForDesktopPageScrolling newSize=" << newSize << " mode " << m_tileCoverage << " expanded to " << coverageSize << " bounds with margin " << coverageBounds << " coverage " << coverage);
+ return unionRect(coverageRect, coverage);
+}
+#endif
+
+FloatRect TileController::adjustTileCoverageWithScrollingVelocity(const FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& visibleRect, float contentsScale) const
+{
if (m_tileCoverage == CoverageForVisibleArea || MemoryPressureHandler::singleton().isUnderMemoryPressure())
return visibleRect;
@@ -508,37 +531,37 @@
if (futureRect.y() < 0)
futureRect.setY(0);
- LOG_WITH_STREAM(Tiling, stream << "TileController " << this << " computeTileCoverageRect - coverage " << coverageRect << " expanded to " << unionRect(coverageRect, futureRect) << " velocity " << m_velocity);
+ LOG_WITH_STREAM(Tiling, stream << "TileController " << this << " adjustTileCoverageForScrolling - coverage " << coverageRect << " expanded to " << unionRect(coverageRect, futureRect) << " velocity " << m_velocity);
return unionRect(coverageRect, futureRect);
-#else
- UNUSED_PARAM(contentsScale);
+}
- // FIXME: look at how far the document can scroll in each dimension.
- FloatSize coverageSize = visibleRect.size();
+FloatRect TileController::adjustTileCoverageRectForScrolling(const FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& visibleRect, float contentsScale)
+{
+ // If the page is not in a window (for example if it's in a background tab), we limit the tile coverage rect to the visible rect.
+ if (!m_isInWindow)
+ return visibleRect;
- bool largeVisibleRectChange = !previousVisibleRect.isEmpty() && !visibleRect.intersects(previousVisibleRect);
+#if !PLATFORM(IOS_FAMILY)
+ if (m_tileCacheLayer->isPageTiledBackingLayer())
+ return adjustTileCoverageForDesktopPageScrolling(coverageRect, newSize, previousVisibleRect, visibleRect);
+#else
+ UNUSED_PARAM(previousVisibleRect);
+#endif
- // Inflate the coverage rect so that it covers 2x of the visible width and 3x of the visible height.
- // These values were chosen because it's more common to have tall pages and to scroll vertically,
- // so we keep more tiles above and below the current area.
- float widthScale = 1;
- float heightScale = 1;
+ auto computeVelocityIfNecessary = [&](FloatPoint scrollOffset) {
+ if (m_haveExternalVelocityData)
+ return;
- if (m_tileCoverage & CoverageForHorizontalScrolling && !largeVisibleRectChange)
- widthScale = 2;
+ if (!m_historicalVelocityData)
+ m_historicalVelocityData = std::make_unique<HistoricalVelocityData>();
- if (m_tileCoverage & CoverageForVerticalScrolling && !largeVisibleRectChange)
- heightScale = 3;
+ m_velocity = m_historicalVelocityData->velocityForNewData(scrollOffset, contentsScale, MonotonicTime::now());
+ };
- coverageSize.scale(widthScale, heightScale);
+ computeVelocityIfNecessary(visibleRect.location());
- FloatRect coverageBounds = boundsForSize(newSize);
-
- FloatRect coverage = expandRectWithinRect(visibleRect, coverageSize, coverageBounds);
- LOG_WITH_STREAM(Tiling, stream << "TileController::computeTileCoverageRect newSize=" << newSize << " mode " << m_tileCoverage << " expanded to " << coverageSize << " bounds with margin " << coverageBounds << " coverage " << coverage);
- return unionRect(coverageRect, coverage);
-#endif
+ return adjustTileCoverageWithScrollingVelocity(coverageRect, newSize, visibleRect, contentsScale);
}
void TileController::scheduleTileRevalidation(Seconds interval)
Modified: trunk/Source/WebCore/platform/graphics/ca/TileController.h (245836 => 245837)
--- trunk/Source/WebCore/platform/graphics/ca/TileController.h 2019-05-29 01:05:45 UTC (rev 245836)
+++ trunk/Source/WebCore/platform/graphics/ca/TileController.h 2019-05-29 01:07:03 UTC (rev 245837)
@@ -122,8 +122,8 @@
int rightMarginWidth() const final;
TileCoverage tileCoverage() const final { return m_tileCoverage; }
- FloatRect adjustTileCoverageRect(const FloatRect& coverageRect, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, bool sizeChanged) const final;
- FloatRect adjustTileCoverageRectForScrolling(const FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, float contentsScale) const final;
+ FloatRect adjustTileCoverageRect(const FloatRect& coverageRect, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, bool sizeChanged) final;
+ FloatRect adjustTileCoverageRectForScrolling(const FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, float contentsScale) final;
bool scrollingPerformanceLoggingEnabled() const final { return m_scrollingPerformanceLoggingEnabled; }
@@ -190,7 +190,13 @@
void notePendingTileSizeChange();
void tileSizeChangeTimerFired();
-
+
+#if !PLATFORM(IOS_FAMILY)
+ FloatRect adjustTileCoverageForDesktopPageScrolling(const FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& visibleRect) const;
+#endif
+
+ FloatRect adjustTileCoverageWithScrollingVelocity(const FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& visibleRect, float contentsScale) const;
+
IntRect boundsForSize(const FloatSize&) const;
PlatformCALayerClient* owningGraphicsLayer() const { return m_tileCacheLayer->owner(); }
@@ -205,6 +211,8 @@
std::unique_ptr<TileGrid> m_tileGrid;
std::unique_ptr<TileGrid> m_zoomedOutTileGrid;
+ std::unique_ptr<HistoricalVelocityData> m_historicalVelocityData; // Used when we track velocity internally.
+
FloatRect m_visibleRect; // Only used for scroll performance logging.
Optional<FloatRect> m_layoutViewportRect; // Only used by the tiled scrolling indicator.
FloatRect m_coverageRect;
@@ -214,7 +222,7 @@
DeferrableOneShotTimer m_tileSizeChangeTimer;
TileCoverage m_tileCoverage { CoverageForVisibleArea };
-
+
VelocityData m_velocity;
int m_marginSize { kDefaultTileSize };
@@ -236,6 +244,7 @@
bool m_hasTilesWithTemporaryScaleFactor { false }; // Used to make low-res tiles when zooming.
bool m_inLiveResize { false };
bool m_tileSizeLocked { false };
+ bool m_haveExternalVelocityData { false };
bool m_isTileSizeUpdateDelayDisabledForTesting { false };
Color m_tileDebugBorderColor;
Modified: trunk/Source/WebCore/rendering/RenderLayer.h (245836 => 245837)
--- trunk/Source/WebCore/rendering/RenderLayer.h 2019-05-29 01:05:45 UTC (rev 245836)
+++ trunk/Source/WebCore/rendering/RenderLayer.h 2019-05-29 01:07:03 UTC (rev 245837)
@@ -450,6 +450,8 @@
void scrollRectToVisible(const LayoutRect& absoluteRect, bool insideFixed, const ScrollRectToVisibleOptions&);
bool scrollsOverflow() const;
+ bool hasScrollableHorizontalOverflow() const;
+ bool hasScrollableVerticalOverflow() const;
bool hasScrollbars() const { return m_hBar || m_vBar; }
void setHasHorizontalScrollbar(bool);
void setHasVerticalScrollbar(bool);
@@ -1066,8 +1068,6 @@
void computeScrollDimensions();
bool hasHorizontalOverflow() const;
bool hasVerticalOverflow() const;
- bool hasScrollableHorizontalOverflow() const;
- bool hasScrollableVerticalOverflow() const;
bool showsOverflowControls() const;
Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (245836 => 245837)
--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2019-05-29 01:05:45 UTC (rev 245836)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2019-05-29 01:07:03 UTC (rev 245837)
@@ -355,15 +355,14 @@
return m_graphicsLayer->tiledBacking();
}
-static TiledBacking::TileCoverage computePageTiledBackingCoverage(RenderLayerBacking* backing)
+static TiledBacking::TileCoverage computePageTiledBackingCoverage(const RenderLayer& layer)
{
- // FIXME: When we use TiledBacking for overflow, this should look at RenderView scrollability.
- auto& frameView = backing->owningLayer().renderer().view().frameView();
-
// If the page is non-visible, don't incur the cost of keeping extra tiles for scrolling.
- if (!backing->owningLayer().page().isVisible())
+ if (!layer.page().isVisible())
return TiledBacking::CoverageForVisibleArea;
+ auto& frameView = layer.renderer().view().frameView();
+
TiledBacking::TileCoverage tileCoverage = TiledBacking::CoverageForVisibleArea;
bool useMinimalTilesDuringLiveResize = frameView.inLiveResize();
if (frameView.speculativeTilingEnabled() && !useMinimalTilesDuringLiveResize) {
@@ -377,13 +376,39 @@
return tileCoverage;
}
+static TiledBacking::TileCoverage computeOverflowTiledBackingCoverage(const RenderLayer& layer)
+{
+ // If the page is non-visible, don't incur the cost of keeping extra tiles for scrolling.
+ if (!layer.page().isVisible())
+ return TiledBacking::CoverageForVisibleArea;
+
+ auto& frameView = layer.renderer().view().frameView();
+
+ TiledBacking::TileCoverage tileCoverage = TiledBacking::CoverageForVisibleArea;
+ bool useMinimalTilesDuringLiveResize = frameView.inLiveResize();
+ if (!useMinimalTilesDuringLiveResize) {
+ if (layer.hasScrollableHorizontalOverflow())
+ tileCoverage |= TiledBacking::CoverageForHorizontalScrolling;
+
+ if (layer.hasScrollableVerticalOverflow())
+ tileCoverage |= TiledBacking::CoverageForVerticalScrolling;
+ }
+ return tileCoverage;
+}
+
void RenderLayerBacking::adjustTiledBackingCoverage()
{
- if (!m_isFrameLayerWithTiledBacking)
- return;
+ if (m_isFrameLayerWithTiledBacking) {
+ auto tileCoverage = computePageTiledBackingCoverage(m_owningLayer);
+ tiledBacking()->setTileCoverage(tileCoverage);
+ }
- TiledBacking::TileCoverage tileCoverage = computePageTiledBackingCoverage(this);
- tiledBacking()->setTileCoverage(tileCoverage);
+ if (m_owningLayer.hasCompositedScrollableOverflow() && m_scrolledContentsLayer) {
+ if (auto* tiledBacking = m_scrolledContentsLayer->tiledBacking()) {
+ auto tileCoverage = computeOverflowTiledBackingCoverage(m_owningLayer);
+ tiledBacking->setTileCoverage(tileCoverage);
+ }
+ }
}
void RenderLayerBacking::setTiledBackingHasMargins(bool hasExtendedBackgroundOnLeftAndRight, bool hasExtendedBackgroundOnTopAndBottom)
@@ -1258,6 +1283,8 @@
m_foregroundLayer->setSize(m_scrolledContentsLayer->size());
m_foregroundLayer->setOffsetFromRenderer(m_scrolledContentsLayer->offsetFromRenderer() - toLayoutSize(m_scrolledContentsLayer->scrollOffset()));
}
+
+ adjustTiledBackingCoverage();
}
// If this layer was created just for clipping or to apply perspective, it doesn't need its own backing store.