Clean up DynamicScrollCullRectExpansion
It was enabled by default in 129.0.6668.0. Bug: 40942582 Change-Id: I254df4a80db725af4ff321a95666cf9a654bfc21 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5954184 Reviewed-by: Ian Vollick <vollick@chromium.org> Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org> Cr-Commit-Position: refs/heads/main@{#1372780}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
7e9b2e2cb6
commit
0f51361064
android_webview/java/src/org/chromium/android_webview/common
testing/variations
third_party/blink/renderer
core
platform
@ -515,7 +515,6 @@ public final class ProductionSupportedFlagList {
|
||||
BlinkFeatures.THREADED_BODY_LOADER,
|
||||
"If enabled, reads and decodes navigation body data off the main thread."),
|
||||
Flag.baseFeature(BlinkFeatures.HIT_TEST_OPAQUENESS),
|
||||
Flag.baseFeature(BlinkFeatures.DYNAMIC_SCROLL_CULL_RECT_EXPANSION),
|
||||
Flag.baseFeature(BlinkFeatures.EXPAND_COMPOSITED_CULL_RECT),
|
||||
Flag.baseFeature(BlinkFeatures.RASTER_INDUCING_SCROLL),
|
||||
Flag.baseFeature(BlinkFeatures.SCROLLBAR_COLOR),
|
||||
|
@ -8914,28 +8914,6 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"DynamicScrollCullRectExpansion": [
|
||||
{
|
||||
"platforms": [
|
||||
"android",
|
||||
"android_webview",
|
||||
"chromeos",
|
||||
"chromeos_lacros",
|
||||
"fuchsia",
|
||||
"linux",
|
||||
"mac",
|
||||
"windows"
|
||||
],
|
||||
"experiments": [
|
||||
{
|
||||
"name": "Enabled",
|
||||
"enable_features": [
|
||||
"DynamicScrollCullRectExpansion"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"EagerPrefetchBlockUntilHeadDifferentTimeoutsRetrospective": [
|
||||
{
|
||||
"platforms": [
|
||||
|
@ -11,14 +11,8 @@
|
||||
|
||||
namespace blink {
|
||||
|
||||
class CullRectUpdaterTest
|
||||
: public PaintControllerPaintTestBase,
|
||||
public testing::WithParamInterface<bool>,
|
||||
private ScopedDynamicScrollCullRectExpansionForTest {
|
||||
class CullRectUpdaterTest : public PaintControllerPaintTestBase {
|
||||
protected:
|
||||
CullRectUpdaterTest()
|
||||
: ScopedDynamicScrollCullRectExpansionForTest(GetParam()) {}
|
||||
|
||||
CullRect GetCullRect(const char* id) {
|
||||
return GetLayoutObjectByElementId(id)->FirstFragment().GetCullRect();
|
||||
}
|
||||
@ -38,9 +32,7 @@ class CullRectUpdaterTest
|
||||
}
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(All, CullRectUpdaterTest, testing::Bool());
|
||||
|
||||
TEST_P(CullRectUpdaterTest, SimpleCullRect) {
|
||||
TEST_F(CullRectUpdaterTest, SimpleCullRect) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<div id='target'
|
||||
style='width: 200px; height: 200px; position: relative'>
|
||||
@ -50,7 +42,7 @@ TEST_P(CullRectUpdaterTest, SimpleCullRect) {
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 800, 600), GetCullRect("target").Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, TallLayerCullRect) {
|
||||
TEST_F(CullRectUpdaterTest, TallLayerCullRect) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<div id='target'
|
||||
style='width: 200px; height: 10000px; position: relative'>
|
||||
@ -62,7 +54,7 @@ TEST_P(CullRectUpdaterTest, TallLayerCullRect) {
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 800, 4600), GetCullRect("target").Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, WideLayerCullRect) {
|
||||
TEST_F(CullRectUpdaterTest, WideLayerCullRect) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<div id='target'
|
||||
style='width: 10000px; height: 200px; position: relative'>
|
||||
@ -73,7 +65,7 @@ TEST_P(CullRectUpdaterTest, WideLayerCullRect) {
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 4800, 600), GetCullRect("target").Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, VerticalRLWritingModeDocument) {
|
||||
TEST_F(CullRectUpdaterTest, VerticalRLWritingModeDocument) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<style>
|
||||
html { writing-mode: vertical-rl; }
|
||||
@ -92,7 +84,7 @@ TEST_P(CullRectUpdaterTest, VerticalRLWritingModeDocument) {
|
||||
EXPECT_EQ(gfx::Rect(200, 0, 8800, 600), GetCullRect("target").Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, VerticalRLWritingModeScrollDiv) {
|
||||
TEST_F(CullRectUpdaterTest, VerticalRLWritingModeScrollDiv) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<style>
|
||||
html { writing-mode: vertical-rl; }
|
||||
@ -111,7 +103,7 @@ TEST_P(CullRectUpdaterTest, VerticalRLWritingModeScrollDiv) {
|
||||
GetContentsCullRect("scroller").Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, ScaledCullRect) {
|
||||
TEST_F(CullRectUpdaterTest, ScaledCullRect) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<style>body { margin: 0 }</style>
|
||||
<div id='target'
|
||||
@ -124,7 +116,7 @@ TEST_P(CullRectUpdaterTest, ScaledCullRect) {
|
||||
EXPECT_EQ(gfx::Rect(-2000, -2000, 4400, 4800), GetCullRect("target").Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, ScaledCullRectUnderCompositedScroller) {
|
||||
TEST_F(CullRectUpdaterTest, ScaledCullRectUnderCompositedScroller) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<div style='width: 200px; height: 300px; overflow: scroll; background: blue;
|
||||
transform: scaleX(2) scaleY(0.75); transform-origin: 0 0'>
|
||||
@ -134,13 +126,10 @@ TEST_P(CullRectUpdaterTest, ScaledCullRectUnderCompositedScroller) {
|
||||
)HTML");
|
||||
|
||||
// The expansion is calculated based on 4000 / max(scaleX, scaleY).
|
||||
EXPECT_EQ(RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()
|
||||
? gfx::Rect(0, 0, 1224, 1324)
|
||||
: gfx::Rect(0, 0, 2200, 2300),
|
||||
GetCullRect("target").Rect());
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 1224, 1324), GetCullRect("target").Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, ScaledAndRotatedCullRect) {
|
||||
TEST_F(CullRectUpdaterTest, ScaledAndRotatedCullRect) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<div id='target'
|
||||
style='width: 200px; height: 300px; will-change: transform;
|
||||
@ -154,7 +143,7 @@ TEST_P(CullRectUpdaterTest, ScaledAndRotatedCullRect) {
|
||||
GetCullRect("target").Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, ScaledAndRotatedCullRectUnderCompositedScroller) {
|
||||
TEST_F(CullRectUpdaterTest, ScaledAndRotatedCullRectUnderCompositedScroller) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<div style='width: 200px; height: 300px; overflow: scroll; background: blue;
|
||||
transform: scaleX(3) scaleY(0.5) rotateZ(45deg)'>
|
||||
@ -166,19 +155,15 @@ TEST_P(CullRectUpdaterTest, ScaledAndRotatedCullRectUnderCompositedScroller) {
|
||||
|
||||
// The expansion 6599 is 4000 * max_dimension(1x1 rect projected from screen
|
||||
// to local).
|
||||
EXPECT_EQ(RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()
|
||||
? gfx::Rect(-6599, -6599, 16697, 16797)
|
||||
: gfx::Rect(0, 0, 6799, 6899),
|
||||
EXPECT_EQ(gfx::Rect(-6599, -6599, 16697, 16797),
|
||||
GetCullRect("target").Rect());
|
||||
EXPECT_EQ(RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()
|
||||
? gfx::Rect(-6599, -6599, 16697, 16797)
|
||||
: gfx::Rect(0, 0, 6799, 6899),
|
||||
EXPECT_EQ(gfx::Rect(-6599, -6599, 16697, 16797),
|
||||
GetContentsCullRect("target").Rect());
|
||||
}
|
||||
|
||||
// This is a testcase for https://crbug.com/1227907 where repeated cull rect
|
||||
// updates are expensive on the motionmark microbenchmark.
|
||||
TEST_P(CullRectUpdaterTest, OptimizeNonCompositedTransformUpdate) {
|
||||
TEST_F(CullRectUpdaterTest, OptimizeNonCompositedTransformUpdate) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<style>
|
||||
#target {
|
||||
@ -203,7 +188,7 @@ TEST_P(CullRectUpdaterTest, OptimizeNonCompositedTransformUpdate) {
|
||||
EXPECT_TRUE(GetCullRect("target").IsInfinite());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, 3DRotated90DegreesCullRect) {
|
||||
TEST_F(CullRectUpdaterTest, 3DRotated90DegreesCullRect) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<div id='target'
|
||||
style='width: 200px; height: 300px; will-change: transform;
|
||||
@ -214,7 +199,7 @@ TEST_P(CullRectUpdaterTest, 3DRotated90DegreesCullRect) {
|
||||
EXPECT_TRUE(GetCullRect("target").Rect().Contains(gfx::Rect(0, 0, 200, 300)));
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, 3DRotatedNear90DegreesCullRect) {
|
||||
TEST_F(CullRectUpdaterTest, 3DRotatedNear90DegreesCullRect) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<div id='target'
|
||||
style='width: 200px; height: 300px; will-change: transform;
|
||||
@ -225,7 +210,7 @@ TEST_P(CullRectUpdaterTest, 3DRotatedNear90DegreesCullRect) {
|
||||
EXPECT_TRUE(GetCullRect("target").Rect().Contains(gfx::Rect(0, 0, 200, 300)));
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, PerspectiveCullRect) {
|
||||
TEST_F(CullRectUpdaterTest, PerspectiveCullRect) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<div id=target style='transform: perspective(1000px) rotateX(-100deg);'>
|
||||
<div style='width: 2000px; height: 3000px></div>
|
||||
@ -236,7 +221,7 @@ TEST_P(CullRectUpdaterTest, PerspectiveCullRect) {
|
||||
GetCullRect("target").Rect().Contains(gfx::Rect(0, 0, 2000, 3000)));
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, 3D60DegRotatedTallCullRect) {
|
||||
TEST_F(CullRectUpdaterTest, 3D60DegRotatedTallCullRect) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<style>body { margin: 0 }</style>
|
||||
<div id='target'
|
||||
@ -249,7 +234,7 @@ TEST_P(CullRectUpdaterTest, 3D60DegRotatedTallCullRect) {
|
||||
EXPECT_EQ(gfx::Rect(-4100, 0, 9600, 4600), GetCullRect("target").Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, FixedPositionInNonScrollableViewCullRect) {
|
||||
TEST_F(CullRectUpdaterTest, FixedPositionInNonScrollableViewCullRect) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<div id='target' style='width: 1000px; height: 2000px;
|
||||
position: fixed; top: 100px; left: 200px;'>
|
||||
@ -259,7 +244,7 @@ TEST_P(CullRectUpdaterTest, FixedPositionInNonScrollableViewCullRect) {
|
||||
EXPECT_EQ(gfx::Rect(-200, -100, 800, 600), GetCullRect("target").Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, FixedPositionInScrollableViewCullRect) {
|
||||
TEST_F(CullRectUpdaterTest, FixedPositionInScrollableViewCullRect) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<div id='target' style='width: 1000px; height: 2000px;
|
||||
position: fixed; top: 100px; left: 200px;'>
|
||||
@ -270,7 +255,7 @@ TEST_P(CullRectUpdaterTest, FixedPositionInScrollableViewCullRect) {
|
||||
EXPECT_EQ(gfx::Rect(-200, -100, 800, 600), GetCullRect("target").Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, LayerOffscreenNearCullRect) {
|
||||
TEST_F(CullRectUpdaterTest, LayerOffscreenNearCullRect) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<div id='target'
|
||||
style='width: 200px; height: 300px; will-change: transform;
|
||||
@ -282,7 +267,7 @@ TEST_P(CullRectUpdaterTest, LayerOffscreenNearCullRect) {
|
||||
EXPECT_TRUE(cull_rect.Contains(gfx::Rect(0, 0, 200, 300)));
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, LayerOffscreenFarCullRect) {
|
||||
TEST_F(CullRectUpdaterTest, LayerOffscreenFarCullRect) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<div id='target'
|
||||
style='width: 200px; height: 300px; will-change: transform;
|
||||
@ -295,7 +280,7 @@ TEST_P(CullRectUpdaterTest, LayerOffscreenFarCullRect) {
|
||||
GetCullRect("target").Rect().Intersects(gfx::Rect(0, 0, 200, 300)));
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, ScrollingLayerCullRect) {
|
||||
TEST_F(CullRectUpdaterTest, ScrollingLayerCullRect) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<style>
|
||||
div::-webkit-scrollbar { width: 5px; }
|
||||
@ -317,7 +302,7 @@ TEST_P(CullRectUpdaterTest, ScrollingLayerCullRect) {
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 195, 4193), GetCullRect("target").Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, NonCompositedScrollingLayerCullRect) {
|
||||
TEST_F(CullRectUpdaterTest, NonCompositedScrollingLayerCullRect) {
|
||||
SetPreferCompositingToLCDText(false);
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<style>
|
||||
@ -334,7 +319,7 @@ TEST_P(CullRectUpdaterTest, NonCompositedScrollingLayerCullRect) {
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 195, 4193), GetCullRect("target").Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, ClippedBigLayer) {
|
||||
TEST_F(CullRectUpdaterTest, ClippedBigLayer) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<div style='width: 1px; height: 1px; overflow: hidden'>
|
||||
<div id='target'
|
||||
@ -346,7 +331,7 @@ TEST_P(CullRectUpdaterTest, ClippedBigLayer) {
|
||||
EXPECT_EQ(gfx::Rect(8, 8, 1, 1), GetCullRect("target").Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, TallScrolledLayerCullRect) {
|
||||
TEST_F(CullRectUpdaterTest, TallScrolledLayerCullRect) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<div id='target' style='width: 200px; height: 12000px; position: relative'>
|
||||
</div>
|
||||
@ -374,7 +359,7 @@ TEST_P(CullRectUpdaterTest, TallScrolledLayerCullRect) {
|
||||
EXPECT_EQ(gfx::Rect(0, 600, 800, 8600), GetCullRect("target").Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, WholeDocumentCullRect) {
|
||||
TEST_F(CullRectUpdaterTest, WholeDocumentCullRect) {
|
||||
SetPreferCompositingToLCDText(true);
|
||||
GetDocument().GetSettings()->SetMainFrameClipsContent(false);
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
@ -406,7 +391,7 @@ TEST_P(CullRectUpdaterTest, WholeDocumentCullRect) {
|
||||
EXPECT_EQ(7u, ContentDisplayItems().size());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, FixedPositionUnderClipPath) {
|
||||
TEST_F(CullRectUpdaterTest, FixedPositionUnderClipPath) {
|
||||
GetDocument().View()->Resize(800, 600);
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<div style="height: 100vh"></div>
|
||||
@ -427,7 +412,7 @@ TEST_P(CullRectUpdaterTest, FixedPositionUnderClipPath) {
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 800, 1000), GetCullRect("fixed").Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, FixedPositionUnderClipPathWillChangeTransform) {
|
||||
TEST_F(CullRectUpdaterTest, FixedPositionUnderClipPathWillChangeTransform) {
|
||||
GetDocument().View()->Resize(800, 600);
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<div style="height: 100vh"></div>
|
||||
@ -448,7 +433,7 @@ TEST_P(CullRectUpdaterTest, FixedPositionUnderClipPathWillChangeTransform) {
|
||||
EXPECT_EQ(gfx::Rect(-4000, -4000, 8800, 10000), GetCullRect("fixed").Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, AbsolutePositionUnderNonContainingStackingContext) {
|
||||
TEST_F(CullRectUpdaterTest, AbsolutePositionUnderNonContainingStackingContext) {
|
||||
SetPreferCompositingToLCDText(false);
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<div id="scroller" style="width: 200px; height: 200px; overflow: auto;
|
||||
@ -468,7 +453,7 @@ TEST_P(CullRectUpdaterTest, AbsolutePositionUnderNonContainingStackingContext) {
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 500, 500), GetCullRect("absolute").Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, StackedChildOfNonStackingContextScroller) {
|
||||
TEST_F(CullRectUpdaterTest, StackedChildOfNonStackingContextScroller) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<div id="scroller" style="width: 200px; height: 200px; overflow: auto;
|
||||
background: white">
|
||||
@ -511,7 +496,7 @@ TEST_P(CullRectUpdaterTest, StackedChildOfNonStackingContextScroller) {
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 200, 4200), GetCullRect("child").Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, ContentsCullRectCoveringWholeContentsRect) {
|
||||
TEST_F(CullRectUpdaterTest, ContentsCullRectCoveringWholeContentsRect) {
|
||||
SetPreferCompositingToLCDText(true);
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<div id="scroller" style="width: 400px; height: 400px; overflow: scroll">
|
||||
@ -553,7 +538,7 @@ TEST_P(CullRectUpdaterTest, ContentsCullRectCoveringWholeContentsRect) {
|
||||
EXPECT_EQ(gfx::Rect(-4000, -7000, 8400, 7020), GetCullRect("child").Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, SVGForeignObject) {
|
||||
TEST_F(CullRectUpdaterTest, SVGForeignObject) {
|
||||
SetPreferCompositingToLCDText(false);
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<div id="scroller" style="width: 100px; height: 100px; overflow: scroll">
|
||||
@ -589,7 +574,7 @@ TEST_P(CullRectUpdaterTest, SVGForeignObject) {
|
||||
EXPECT_FALSE(svg->DescendantNeedsCullRectUpdate());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, LayerUnderSVGHiddenContainer) {
|
||||
TEST_F(CullRectUpdaterTest, LayerUnderSVGHiddenContainer) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<div id="div" style="display: contents">
|
||||
<svg id="svg1"></svg>
|
||||
@ -609,7 +594,7 @@ TEST_P(CullRectUpdaterTest, LayerUnderSVGHiddenContainer) {
|
||||
EXPECT_FALSE(GetLayoutObjectByElementId("svg1"));
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, PerspectiveDescendants) {
|
||||
TEST_F(CullRectUpdaterTest, PerspectiveDescendants) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<div style="perspective: 1000px">
|
||||
<div style="height: 300px; transform-style: preserve-3d; contain: strict">
|
||||
@ -621,7 +606,7 @@ TEST_P(CullRectUpdaterTest, PerspectiveDescendants) {
|
||||
}
|
||||
|
||||
// Test case for crbug.com/1382842.
|
||||
TEST_P(CullRectUpdaterTest, UpdateOnCompositedScrollingStatusChange) {
|
||||
TEST_F(CullRectUpdaterTest, UpdateOnCompositedScrollingStatusChange) {
|
||||
SetPreferCompositingToLCDText(false);
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<style>body {position: absolute}</style>
|
||||
@ -643,7 +628,7 @@ TEST_P(CullRectUpdaterTest, UpdateOnCompositedScrollingStatusChange) {
|
||||
EXPECT_EQ(gfx::Rect(100, 1000), GetContentsCullRect("scroller").Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, StickyPositionInCompositedScroller) {
|
||||
TEST_F(CullRectUpdaterTest, StickyPositionInCompositedScroller) {
|
||||
SetPreferCompositingToLCDText(true);
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<div id="scroller" style="width: 300px; height: 300px; overflow: scroll">
|
||||
@ -699,7 +684,7 @@ TEST_P(CullRectUpdaterTest, StickyPositionInCompositedScroller) {
|
||||
EXPECT_EQ(gfx::Rect(), GetCullRect("sticky2").Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, StickyPositionInNonCompositedScroller) {
|
||||
TEST_F(CullRectUpdaterTest, StickyPositionInNonCompositedScroller) {
|
||||
SetPreferCompositingToLCDText(false);
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<div id="scroller" style="width: 300px; height: 300px; overflow: scroll">
|
||||
@ -754,7 +739,7 @@ TEST_P(CullRectUpdaterTest, StickyPositionInNonCompositedScroller) {
|
||||
EXPECT_EQ(gfx::Rect(), GetCullRect("sticky2").Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, NestedOverriddenCullRectScopes) {
|
||||
TEST_F(CullRectUpdaterTest, NestedOverriddenCullRectScopes) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<div id="div1" style="contain: paint; height: 100px"></div>
|
||||
<div id="div2" style="contain: paint; height: 100px"></div>
|
||||
@ -817,7 +802,7 @@ TEST_P(CullRectUpdaterTest, NestedOverriddenCullRectScopes) {
|
||||
EXPECT_EQ(cull_rect2, GetCullRect(layer2));
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, OverriddenCullRectWithoutExpansion) {
|
||||
TEST_F(CullRectUpdaterTest, OverriddenCullRectWithoutExpansion) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<style>body { margin: 0 }</style>
|
||||
<div id="clip" style="width: 300px; height: 300px; overflow: hidden">
|
||||
@ -833,10 +818,7 @@ TEST_P(CullRectUpdaterTest, OverriddenCullRectWithoutExpansion) {
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 800, 600), GetCullRect(clip).Rect());
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 300, 300), GetContentsCullRect(clip).Rect());
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 300, 300), GetCullRect(scroller).Rect());
|
||||
EXPECT_EQ(RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()
|
||||
? gfx::Rect(0, 0, 1300, 1300)
|
||||
: gfx::Rect(0, 0, 2000, 2000),
|
||||
GetContentsCullRect(scroller).Rect());
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 1300, 1300), GetContentsCullRect(scroller).Rect());
|
||||
|
||||
{
|
||||
const bool disable_expansion = true;
|
||||
@ -853,13 +835,10 @@ TEST_P(CullRectUpdaterTest, OverriddenCullRectWithoutExpansion) {
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 800, 600), GetCullRect(clip).Rect());
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 300, 300), GetContentsCullRect(clip).Rect());
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 300, 300), GetCullRect(scroller).Rect());
|
||||
EXPECT_EQ(RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()
|
||||
? gfx::Rect(0, 0, 1300, 1300)
|
||||
: gfx::Rect(0, 0, 2000, 2000),
|
||||
GetContentsCullRect(scroller).Rect());
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 1300, 1300), GetContentsCullRect(scroller).Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, LimitedDynamicCullRectExpansionY) {
|
||||
TEST_F(CullRectUpdaterTest, LimitedDynamicCullRectExpansionY) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<style>body { margin: 0 }</style>
|
||||
<div id="clip" style="width: 300px; height: 300px; overflow: hidden">
|
||||
@ -875,13 +854,10 @@ TEST_P(CullRectUpdaterTest, LimitedDynamicCullRectExpansionY) {
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 800, 600), GetCullRect(clip).Rect());
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 300, 300), GetContentsCullRect(clip).Rect());
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 300, 300), GetCullRect(scroller).Rect());
|
||||
EXPECT_EQ(RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()
|
||||
? gfx::Rect(0, 0, 300, 1300)
|
||||
: gfx::Rect(0, 0, 1000, 2000),
|
||||
GetContentsCullRect(scroller).Rect());
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 300, 1300), GetContentsCullRect(scroller).Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, LimitedDynamicCullRectExpansionX) {
|
||||
TEST_F(CullRectUpdaterTest, LimitedDynamicCullRectExpansionX) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<style>body { margin: 0 }</style>
|
||||
<div id="clip" style="width: 300px; height: 300px; overflow: hidden">
|
||||
@ -902,13 +878,10 @@ TEST_P(CullRectUpdaterTest, LimitedDynamicCullRectExpansionX) {
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 800, 600), GetCullRect(clip).Rect());
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 300, 300), GetContentsCullRect(clip).Rect());
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 300, 300), GetCullRect(scroller).Rect());
|
||||
EXPECT_EQ(RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()
|
||||
? gfx::Rect(0, 0, 1300, 300)
|
||||
: gfx::Rect(0, 0, 2000, 1000),
|
||||
GetContentsCullRect(scroller).Rect());
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 1300, 300), GetContentsCullRect(scroller).Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdaterTest, ViewScrollNeedsCullRectUpdate) {
|
||||
TEST_F(CullRectUpdaterTest, ViewScrollNeedsCullRectUpdate) {
|
||||
SetBodyInnerHTML("<div style='height: 5000px'>");
|
||||
|
||||
auto& layer = *GetLayoutView().Layer();
|
||||
@ -945,7 +918,7 @@ TEST_P(CullRectUpdaterTest, ViewScrollNeedsCullRectUpdate) {
|
||||
// The test doesn't apply on Android or iOS where the LayoutObject of <select>
|
||||
// doesn't scroll.
|
||||
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
|
||||
TEST_P(CullRectUpdaterTest, SelectDoesntExpandCullRect) {
|
||||
TEST_F(CullRectUpdaterTest, SelectDoesntExpandCullRect) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<select id="select" style="height: 50px; font-size: 20px" size="3">
|
||||
<option>a</option>
|
||||
@ -963,7 +936,7 @@ TEST_P(CullRectUpdaterTest, SelectDoesntExpandCullRect) {
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST_P(CullRectUpdaterTest, InputDoesntExpandCullRect) {
|
||||
TEST_F(CullRectUpdaterTest, InputDoesntExpandCullRect) {
|
||||
SetBodyInnerHTML(R"HTML(
|
||||
<input id="input" style="font-size: 20px; width: 100px; height: 20px"
|
||||
value="ABCDEFGHIJKLMNOPQRSTUVWXYZ">
|
||||
@ -1062,11 +1035,7 @@ class CullRectUpdateOnPaintPropertyChangeTest : public CullRectUpdaterTest {
|
||||
)HTML";
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(All,
|
||||
CullRectUpdateOnPaintPropertyChangeTest,
|
||||
testing::Bool());
|
||||
|
||||
TEST_P(CullRectUpdateOnPaintPropertyChangeTest, Opacity) {
|
||||
TEST_F(CullRectUpdateOnPaintPropertyChangeTest, Opacity) {
|
||||
TestTargetChange("opacity: 0.2", "opacity: 0.8", false, false, false);
|
||||
TestTargetChange("opacity: 0.5", "", true, false, true);
|
||||
TestTargetChange("", "opacity: 0.5", true, false, true);
|
||||
@ -1076,7 +1045,7 @@ TEST_P(CullRectUpdateOnPaintPropertyChangeTest, Opacity) {
|
||||
false, false, false);
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdateOnPaintPropertyChangeTest, NonPixelMovingFilter) {
|
||||
TEST_F(CullRectUpdateOnPaintPropertyChangeTest, NonPixelMovingFilter) {
|
||||
TestTargetChange("filter: invert(5%)", "filter: invert(8%)", false, false,
|
||||
false);
|
||||
TestTargetChange("filter: invert(5%)", "", true, false, true);
|
||||
@ -1088,7 +1057,7 @@ TEST_P(CullRectUpdateOnPaintPropertyChangeTest, NonPixelMovingFilter) {
|
||||
false);
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdateOnPaintPropertyChangeTest, PixelMovingFilter) {
|
||||
TEST_F(CullRectUpdateOnPaintPropertyChangeTest, PixelMovingFilter) {
|
||||
TestTargetChange("filter: blur(5px)", "filter: blur(8px)", false, false,
|
||||
false);
|
||||
TestTargetChange("filter: blur(5px)", "", true, true, true);
|
||||
@ -1099,7 +1068,7 @@ TEST_P(CullRectUpdateOnPaintPropertyChangeTest, PixelMovingFilter) {
|
||||
"will-change: filter; filter: blur(5px)", true, false, true);
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdateOnPaintPropertyChangeTest, Transform) {
|
||||
TEST_F(CullRectUpdateOnPaintPropertyChangeTest, Transform) {
|
||||
// We use infinite cull rect for small layers with non-composited transforms,
|
||||
// so don't need to update cull rect on non-composited transform change.
|
||||
TestTargetChange("transform: translateX(10px)", "transform: translateX(20px)",
|
||||
@ -1117,7 +1086,7 @@ TEST_P(CullRectUpdateOnPaintPropertyChangeTest, Transform) {
|
||||
true, false);
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdateOnPaintPropertyChangeTest, AnimatingTransform) {
|
||||
TEST_F(CullRectUpdateOnPaintPropertyChangeTest, AnimatingTransform) {
|
||||
html_ = html_ + R"HTML(
|
||||
<style>
|
||||
@keyframes test {
|
||||
@ -1133,13 +1102,13 @@ TEST_P(CullRectUpdateOnPaintPropertyChangeTest, AnimatingTransform) {
|
||||
TestTargetChange("", "transform: translateX(10px)", false, false, false);
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdateOnPaintPropertyChangeTest, ScrollContentsSizeChange) {
|
||||
TEST_F(CullRectUpdateOnPaintPropertyChangeTest, ScrollContentsSizeChange) {
|
||||
TestChildChange("", "width: 3000px", true, true, true);
|
||||
TestChildChange("", "height: 3000px", true, true, true);
|
||||
TestChildChange("", "width: 50px; height: 50px", true, true, true);
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdateOnPaintPropertyChangeTest, SmallContentsScroll) {
|
||||
TEST_F(CullRectUpdateOnPaintPropertyChangeTest, SmallContentsScroll) {
|
||||
// TODO(wangxianzhu): Optimize for scrollers with small contents.
|
||||
bool needs_cull_rect_update = false;
|
||||
TestTargetScroll(ScrollOffset(), ScrollOffset(100, 200), false,
|
||||
@ -1150,7 +1119,7 @@ TEST_P(CullRectUpdateOnPaintPropertyChangeTest, SmallContentsScroll) {
|
||||
needs_cull_rect_update, false);
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdateOnPaintPropertyChangeTest,
|
||||
TEST_F(CullRectUpdateOnPaintPropertyChangeTest,
|
||||
LargeContentsScrollSmallDeltaOrNotExposingNewContents1) {
|
||||
html_ = html_ + "<style>#child { width: auto; height: 10000px; }</style>";
|
||||
// Scroll offset changes that are small or won't expose new contents don't
|
||||
@ -1166,7 +1135,7 @@ TEST_P(CullRectUpdateOnPaintPropertyChangeTest,
|
||||
needs_cull_rect_update, false);
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdateOnPaintPropertyChangeTest,
|
||||
TEST_F(CullRectUpdateOnPaintPropertyChangeTest,
|
||||
LargeContentsScrollSmallDeltaOrNotExposingNewContents2) {
|
||||
html_ = html_ + "<style>#child { width: 10000px; height: 10000px; }</style>";
|
||||
// Scroll offset changes that are small or won't expose new contents don't
|
||||
@ -1182,7 +1151,7 @@ TEST_P(CullRectUpdateOnPaintPropertyChangeTest,
|
||||
needs_cull_rect_update, false);
|
||||
}
|
||||
|
||||
TEST_P(CullRectUpdateOnPaintPropertyChangeTest,
|
||||
TEST_F(CullRectUpdateOnPaintPropertyChangeTest,
|
||||
LargeContentsScrollExposingNewContents) {
|
||||
html_ = html_ + "<style>#child { width: 10000px; height: 10000px; }</style>";
|
||||
// Big scroll offset changes that will expose new contents to paint need cull
|
||||
|
@ -146,57 +146,50 @@ std::pair<bool, bool> CullRect::ApplyScrollTranslation(
|
||||
|
||||
gfx::Rect contents_rect = scroll->ContentsRect();
|
||||
// Expand the cull rect for scrolling contents for composited scrolling.
|
||||
std::pair<bool, bool> expanded{true, true};
|
||||
int outset = LocalPixelDistanceToExpand(root_transform, scroll_translation,
|
||||
expansion_ratio);
|
||||
if (RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()) {
|
||||
int scroll_range_x = contents_rect.width() - container_rect.width();
|
||||
int scroll_range_y = contents_rect.height() - container_rect.height();
|
||||
int outset_x = outset;
|
||||
int outset_y = outset;
|
||||
if (scroll_range_x <= 0) {
|
||||
outset_x = 0;
|
||||
}
|
||||
if (scroll_range_y <= 0) {
|
||||
outset_y = 0;
|
||||
}
|
||||
if (outset_x > 0 && outset_y > 0) {
|
||||
// If scroller is scrollable in both axes, expand by half to prevent the
|
||||
// area of the cull rect from being too big (thus probably too slow to
|
||||
// paint and composite).
|
||||
outset_x /= 2;
|
||||
outset_y /= 2;
|
||||
// Give the extra outset beyond scroll range in one axis to the other.
|
||||
if (outset_x > scroll_range_x) {
|
||||
outset_y += outset_x - scroll_range_x;
|
||||
}
|
||||
if (outset_y > scroll_range_y) {
|
||||
outset_x += outset_y - scroll_range_y;
|
||||
}
|
||||
}
|
||||
// The operations above may have caused the outsets to exceed the scroll
|
||||
// range. Trim them back here. Note that we clamp the outset in a single
|
||||
// direction to the entire scroll range. Eg, if we have a `scroll_range_x`
|
||||
// of 100, we will clamp offset_x to 100, but this will result in both the
|
||||
// left and right outset of 100 which means that we will expand the cull
|
||||
// rect by 200 in the x dimension. If `rect_` is touching the edge of the
|
||||
// contents rect, this will be required on one side (since you can paint a
|
||||
// full 100 units into the scroller), but there can be some extra. Commonly,
|
||||
// the extra outset will be removed by the intersection with contents_rect
|
||||
// below, but it can happen that the original rect is sized and positioned
|
||||
// such that the expanded rect won't be adequately clipped by this
|
||||
// intersection. This can happen if we are clipped by an ancestor.
|
||||
int min_expansion = MinimumLocalPixelDistanceToExpand(expansion_ratio);
|
||||
outset_x = std::min(std::max(outset_x, min_expansion), scroll_range_x);
|
||||
outset_y = std::min(std::max(outset_y, min_expansion), scroll_range_y);
|
||||
expanded.first = outset_x > 0;
|
||||
expanded.second = outset_y > 0;
|
||||
rect_.Outset(gfx::Outsets::VH(outset_y, outset_x));
|
||||
} else {
|
||||
rect_.Outset(outset);
|
||||
int outset_x = LocalPixelDistanceToExpand(root_transform, scroll_translation,
|
||||
expansion_ratio);
|
||||
int outset_y = outset_x;
|
||||
int scroll_range_x = contents_rect.width() - container_rect.width();
|
||||
int scroll_range_y = contents_rect.height() - container_rect.height();
|
||||
if (scroll_range_x <= 0) {
|
||||
outset_x = 0;
|
||||
}
|
||||
if (scroll_range_y <= 0) {
|
||||
outset_y = 0;
|
||||
}
|
||||
if (outset_x > 0 && outset_y > 0) {
|
||||
// If scroller is scrollable in both axes, expand by half to prevent the
|
||||
// area of the cull rect from being too big (thus probably too slow to
|
||||
// paint and composite).
|
||||
outset_x /= 2;
|
||||
outset_y /= 2;
|
||||
// Give the extra outset beyond scroll range in one axis to the other.
|
||||
if (outset_x > scroll_range_x) {
|
||||
outset_y += outset_x - scroll_range_x;
|
||||
}
|
||||
if (outset_y > scroll_range_y) {
|
||||
outset_x += outset_y - scroll_range_y;
|
||||
}
|
||||
}
|
||||
// The operations above may have caused the outsets to exceed the scroll
|
||||
// range. Trim them back here. Note that we clamp the outset in a single
|
||||
// direction to the entire scroll range. Eg, if we have a `scroll_range_x`
|
||||
// of 100, we will clamp offset_x to 100, but this will result in both the
|
||||
// left and right outset of 100 which means that we will expand the cull
|
||||
// rect by 200 in the x dimension. If `rect_` is touching the edge of the
|
||||
// contents rect, this will be required on one side (since you can paint a
|
||||
// full 100 units into the scroller), but there can be some extra. Commonly,
|
||||
// the extra outset will be removed by the intersection with contents_rect
|
||||
// below, but it can happen that the original rect is sized and positioned
|
||||
// such that the expanded rect won't be adequately clipped by this
|
||||
// intersection. This can happen if we are clipped by an ancestor.
|
||||
int min_expansion = MinimumLocalPixelDistanceToExpand(expansion_ratio);
|
||||
outset_x = std::min(std::max(outset_x, min_expansion), scroll_range_x);
|
||||
outset_y = std::min(std::max(outset_y, min_expansion), scroll_range_y);
|
||||
rect_.Outset(gfx::Outsets::VH(outset_y, outset_x));
|
||||
|
||||
rect_.Intersect(contents_rect);
|
||||
return expanded;
|
||||
return {outset_x > 0, outset_y > 0};
|
||||
}
|
||||
|
||||
bool CullRect::ApplyPaintPropertiesWithoutExpansion(
|
||||
|
@ -12,12 +12,8 @@
|
||||
|
||||
namespace blink {
|
||||
|
||||
class CullRectTest : public testing::Test,
|
||||
public testing::WithParamInterface<bool>,
|
||||
private ScopedDynamicScrollCullRectExpansionForTest {
|
||||
class CullRectTest : public testing::Test {
|
||||
protected:
|
||||
CullRectTest() : ScopedDynamicScrollCullRectExpansionForTest(GetParam()) {}
|
||||
|
||||
bool ApplyPaintProperties(
|
||||
CullRect& cull_rect,
|
||||
const PropertyTreeState& root,
|
||||
@ -45,9 +41,7 @@ class CullRectTest : public testing::Test,
|
||||
float expansion_ratio_ = 1.f;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(All, CullRectTest, testing::Bool());
|
||||
|
||||
TEST_P(CullRectTest, IntersectsRect) {
|
||||
TEST_F(CullRectTest, IntersectsRect) {
|
||||
CullRect cull_rect(gfx::Rect(0, 0, 50, 50));
|
||||
|
||||
EXPECT_TRUE(cull_rect.Intersects(gfx::Rect(0, 0, 1, 1)));
|
||||
@ -59,7 +53,7 @@ TEST_P(CullRectTest, IntersectsRect) {
|
||||
EXPECT_FALSE(CullRect(gfx::Rect()).Intersects(gfx::Rect()));
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, IntersectsTransformed) {
|
||||
TEST_F(CullRectTest, IntersectsTransformed) {
|
||||
CullRect cull_rect(gfx::Rect(0, 0, 50, 50));
|
||||
AffineTransform transform;
|
||||
transform.Translate(-2, -2);
|
||||
@ -74,13 +68,13 @@ TEST_P(CullRectTest, IntersectsTransformed) {
|
||||
transform, gfx::RectF(1, 1, 1, 0)));
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, Infinite) {
|
||||
TEST_F(CullRectTest, Infinite) {
|
||||
EXPECT_TRUE(CullRect::Infinite().IsInfinite());
|
||||
EXPECT_TRUE(CullRect(InfiniteIntRect()).IsInfinite());
|
||||
EXPECT_FALSE(CullRect(gfx::Rect(0, 0, 100, 100)).IsInfinite());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, Move) {
|
||||
TEST_F(CullRectTest, Move) {
|
||||
CullRect cull_rect(gfx::Rect(0, 0, 50, 50));
|
||||
cull_rect.Move(gfx::Vector2d());
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 50, 50), cull_rect.Rect());
|
||||
@ -88,7 +82,7 @@ TEST_P(CullRectTest, Move) {
|
||||
EXPECT_EQ(gfx::Rect(10, 20, 50, 50), cull_rect.Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, MoveInfinite) {
|
||||
TEST_F(CullRectTest, MoveInfinite) {
|
||||
CullRect cull_rect = CullRect::Infinite();
|
||||
cull_rect.Move(gfx::Vector2d());
|
||||
EXPECT_TRUE(cull_rect.IsInfinite());
|
||||
@ -96,7 +90,7 @@ TEST_P(CullRectTest, MoveInfinite) {
|
||||
EXPECT_TRUE(cull_rect.IsInfinite());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, ApplyTransform) {
|
||||
TEST_F(CullRectTest, ApplyTransform) {
|
||||
CullRect cull_rect(gfx::Rect(1, 1, 50, 50));
|
||||
auto* transform = CreateTransform(t0(), MakeTranslationMatrix(1, 1));
|
||||
cull_rect.ApplyTransform(*transform);
|
||||
@ -104,14 +98,14 @@ TEST_P(CullRectTest, ApplyTransform) {
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 50, 50), cull_rect.Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, ApplyTransformInfinite) {
|
||||
TEST_F(CullRectTest, ApplyTransformInfinite) {
|
||||
CullRect cull_rect = CullRect::Infinite();
|
||||
auto* transform = CreateTransform(t0(), MakeTranslationMatrix(1, 1));
|
||||
cull_rect.ApplyTransform(*transform);
|
||||
EXPECT_TRUE(cull_rect.IsInfinite());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, ApplyScrollTranslationPartialScrollingContents1) {
|
||||
TEST_F(CullRectTest, ApplyScrollTranslationPartialScrollingContents1) {
|
||||
auto state = CreateCompositedScrollTranslationState(
|
||||
PropertyTreeState::Root(), 0, -5000, gfx::Rect(20, 10, 40, 50),
|
||||
gfx::Size(40, 8000));
|
||||
@ -123,44 +117,26 @@ TEST_P(CullRectTest, ApplyScrollTranslationPartialScrollingContents1) {
|
||||
// Inverse transformed: (20, 5010, 30, 50)
|
||||
// Expanded: (0, 1010, 30/40, 8050)
|
||||
// Then clipped by the contents rect.
|
||||
if (RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()) {
|
||||
EXPECT_EQ(std::make_pair(false, true),
|
||||
ApplyScrollTranslation(cull_rect, scroll_translation));
|
||||
EXPECT_EQ(gfx::Rect(20, 1010, 30, 7000), cull_rect.Rect());
|
||||
} else {
|
||||
EXPECT_EQ(std::make_pair(true, true),
|
||||
ApplyScrollTranslation(cull_rect, scroll_translation));
|
||||
EXPECT_EQ(gfx::Rect(20, 1010, 40, 7000), cull_rect.Rect());
|
||||
}
|
||||
EXPECT_EQ(std::make_pair(false, true),
|
||||
ApplyScrollTranslation(cull_rect, scroll_translation));
|
||||
EXPECT_EQ(gfx::Rect(20, 1010, 30, 7000), cull_rect.Rect());
|
||||
|
||||
cull_rect = CullRect::Infinite();
|
||||
// This result differs from the above result in width (30 vs 40)
|
||||
// because it's not clipped by the infinite input cull rect.
|
||||
if (RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()) {
|
||||
EXPECT_EQ(std::make_pair(false, true),
|
||||
ApplyScrollTranslation(cull_rect, scroll_translation));
|
||||
EXPECT_EQ(gfx::Rect(20, 1010, 40, 7000), cull_rect.Rect());
|
||||
} else {
|
||||
EXPECT_EQ(std::make_pair(true, true),
|
||||
ApplyScrollTranslation(cull_rect, scroll_translation));
|
||||
EXPECT_EQ(gfx::Rect(20, 1010, 40, 7000), cull_rect.Rect());
|
||||
}
|
||||
EXPECT_EQ(std::make_pair(false, true),
|
||||
ApplyScrollTranslation(cull_rect, scroll_translation));
|
||||
EXPECT_EQ(gfx::Rect(20, 1010, 40, 7000), cull_rect.Rect());
|
||||
|
||||
// This cull rect is fully contained by the container rect.
|
||||
cull_rect = CullRect(gfx::Rect(30, 10, 20, 30));
|
||||
if (RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()) {
|
||||
EXPECT_EQ(std::make_pair(false, true),
|
||||
ApplyScrollTranslation(cull_rect, scroll_translation));
|
||||
// No expansion in the non-scrollable direction.
|
||||
EXPECT_EQ(gfx::Rect(30, 1010, 20, 7000), cull_rect.Rect());
|
||||
} else {
|
||||
EXPECT_EQ(std::make_pair(true, true),
|
||||
ApplyScrollTranslation(cull_rect, scroll_translation));
|
||||
EXPECT_EQ(gfx::Rect(20, 1010, 40, 7000), cull_rect.Rect());
|
||||
}
|
||||
EXPECT_EQ(std::make_pair(false, true),
|
||||
ApplyScrollTranslation(cull_rect, scroll_translation));
|
||||
// No expansion in the non-scrollable direction.
|
||||
EXPECT_EQ(gfx::Rect(30, 1010, 20, 7000), cull_rect.Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, ApplyScrollTranslationPartialScrollingContents2) {
|
||||
TEST_F(CullRectTest, ApplyScrollTranslationPartialScrollingContents2) {
|
||||
auto state = CreateCompositedScrollTranslationState(
|
||||
PropertyTreeState::Root(), -3000, -5000, gfx::Rect(20, 10, 40, 50),
|
||||
gfx::Size(8000, 8000));
|
||||
@ -171,20 +147,14 @@ TEST_P(CullRectTest, ApplyScrollTranslationPartialScrollingContents2) {
|
||||
// cull rect along both axes.
|
||||
EXPECT_EQ(std::make_pair(true, true),
|
||||
ApplyScrollTranslation(cull_rect, scroll_translation));
|
||||
EXPECT_EQ(RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()
|
||||
? gfx::Rect(1020, 3010, 4030, 4050)
|
||||
: gfx::Rect(20, 1010, 7030, 7000),
|
||||
cull_rect.Rect());
|
||||
EXPECT_EQ(gfx::Rect(1020, 3010, 4030, 4050), cull_rect.Rect());
|
||||
cull_rect = CullRect::Infinite();
|
||||
EXPECT_EQ(std::make_pair(true, true),
|
||||
ApplyScrollTranslation(cull_rect, scroll_translation));
|
||||
EXPECT_EQ(RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()
|
||||
? gfx::Rect(1020, 3010, 4040, 4050)
|
||||
: gfx::Rect(20, 1010, 7040, 7000),
|
||||
cull_rect.Rect());
|
||||
EXPECT_EQ(gfx::Rect(1020, 3010, 4040, 4050), cull_rect.Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest,
|
||||
TEST_F(CullRectTest,
|
||||
ApplyScrollTranslationPartialScrollingContentsExpansionRatio) {
|
||||
expansion_ratio_ = 3;
|
||||
auto state = CreateCompositedScrollTranslationState(
|
||||
@ -197,20 +167,14 @@ TEST_P(CullRectTest,
|
||||
// cull rect along both axes.
|
||||
EXPECT_EQ(std::make_pair(true, true),
|
||||
ApplyScrollTranslation(cull_rect, scroll_translation));
|
||||
EXPECT_EQ(RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()
|
||||
? gfx::Rect(3020, 9010, 12030, 12050)
|
||||
: gfx::Rect(20, 3010, 21030, 21000),
|
||||
cull_rect.Rect());
|
||||
EXPECT_EQ(gfx::Rect(3020, 9010, 12030, 12050), cull_rect.Rect());
|
||||
cull_rect = CullRect::Infinite();
|
||||
EXPECT_EQ(std::make_pair(true, true),
|
||||
ApplyScrollTranslation(cull_rect, scroll_translation));
|
||||
EXPECT_EQ(RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()
|
||||
? gfx::Rect(3020, 9010, 12040, 12050)
|
||||
: gfx::Rect(20, 3010, 21040, 21000),
|
||||
cull_rect.Rect());
|
||||
EXPECT_EQ(gfx::Rect(3020, 9010, 12040, 12050), cull_rect.Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest,
|
||||
TEST_F(CullRectTest,
|
||||
ApplyNonCompositedScrollTranslationPartialScrollingContents1) {
|
||||
auto state = CreateScrollTranslationState(PropertyTreeState::Root(), 0, -5000,
|
||||
gfx::Rect(20, 10, 40, 50),
|
||||
@ -219,27 +183,17 @@ TEST_P(CullRectTest,
|
||||
|
||||
CullRect cull_rect(gfx::Rect(0, 0, 50, 100));
|
||||
// Same as ApplyScrollTranslationPartialScrollingContents1.
|
||||
if (RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()) {
|
||||
EXPECT_EQ(std::make_pair(false, true),
|
||||
ApplyScrollTranslation(cull_rect, scroll_translation));
|
||||
EXPECT_EQ(gfx::Rect(20, 1010, 30, 7000), cull_rect.Rect());
|
||||
} else {
|
||||
EXPECT_EQ(std::make_pair(true, true),
|
||||
ApplyScrollTranslation(cull_rect, scroll_translation));
|
||||
EXPECT_EQ(gfx::Rect(20, 1010, 40, 7000), cull_rect.Rect());
|
||||
}
|
||||
EXPECT_EQ(std::make_pair(false, true),
|
||||
ApplyScrollTranslation(cull_rect, scroll_translation));
|
||||
EXPECT_EQ(gfx::Rect(20, 1010, 30, 7000), cull_rect.Rect());
|
||||
|
||||
cull_rect = CullRect::Infinite();
|
||||
if (RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()) {
|
||||
EXPECT_EQ(std::make_pair(false, true),
|
||||
ApplyScrollTranslation(cull_rect, scroll_translation));
|
||||
} else {
|
||||
EXPECT_EQ(std::make_pair(true, true),
|
||||
ApplyScrollTranslation(cull_rect, scroll_translation));
|
||||
}
|
||||
EXPECT_EQ(std::make_pair(false, true),
|
||||
ApplyScrollTranslation(cull_rect, scroll_translation));
|
||||
EXPECT_EQ(gfx::Rect(20, 1010, 40, 7000), cull_rect.Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest,
|
||||
TEST_F(CullRectTest,
|
||||
ApplyNonCompositedScrollTranslationPartialScrollingContents2) {
|
||||
auto state = CreateScrollTranslationState(PropertyTreeState::Root(), -3000,
|
||||
-5000, gfx::Rect(20, 10, 40, 50),
|
||||
@ -250,20 +204,14 @@ TEST_P(CullRectTest,
|
||||
// Same as ApplyScrollTranslationPartialScrollingContents2.
|
||||
EXPECT_EQ(std::make_pair(true, true),
|
||||
ApplyScrollTranslation(cull_rect, scroll_translation));
|
||||
EXPECT_EQ(RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()
|
||||
? gfx::Rect(1020, 3010, 4030, 4050)
|
||||
: gfx::Rect(20, 1010, 7030, 7000),
|
||||
cull_rect.Rect());
|
||||
EXPECT_EQ(gfx::Rect(1020, 3010, 4030, 4050), cull_rect.Rect());
|
||||
cull_rect = CullRect::Infinite();
|
||||
EXPECT_EQ(std::make_pair(true, true),
|
||||
ApplyScrollTranslation(cull_rect, scroll_translation));
|
||||
EXPECT_EQ(RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()
|
||||
? gfx::Rect(1020, 3010, 4040, 4050)
|
||||
: gfx::Rect(20, 1010, 7040, 7000),
|
||||
cull_rect.Rect());
|
||||
EXPECT_EQ(gfx::Rect(1020, 3010, 4040, 4050), cull_rect.Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest,
|
||||
TEST_F(CullRectTest,
|
||||
ApplyScrollTranslationPartialScrollingContentsWithoutExpansion) {
|
||||
expansion_ratio_ = 0;
|
||||
auto state = CreateCompositedScrollTranslationState(
|
||||
@ -287,7 +235,7 @@ TEST_P(CullRectTest,
|
||||
EXPECT_EQ(gfx::Rect(3020, 5010, 40, 50), cull_rect.Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, ApplyScrollTranslationNoIntersectionWithContainerRect) {
|
||||
TEST_F(CullRectTest, ApplyScrollTranslationNoIntersectionWithContainerRect) {
|
||||
auto state = CreateCompositedScrollTranslationState(
|
||||
PropertyTreeState::Root(), -10, -15, gfx::Rect(200, 100, 40, 50),
|
||||
gfx::Size(2000, 2000));
|
||||
@ -299,7 +247,7 @@ TEST_P(CullRectTest, ApplyScrollTranslationNoIntersectionWithContainerRect) {
|
||||
EXPECT_TRUE(cull_rect.Rect().IsEmpty());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest,
|
||||
TEST_F(CullRectTest,
|
||||
ApplyNonCompositedScrollTranslationNoIntersectionWithContainerRect) {
|
||||
auto state = CreateCompositedScrollTranslationState(
|
||||
PropertyTreeState::Root(), -10, -15, gfx::Rect(200, 100, 40, 50),
|
||||
@ -312,7 +260,7 @@ TEST_P(CullRectTest,
|
||||
EXPECT_TRUE(cull_rect.Rect().IsEmpty());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, ApplyScrollTranslationWholeScrollingContents) {
|
||||
TEST_F(CullRectTest, ApplyScrollTranslationWholeScrollingContents) {
|
||||
auto state = CreateCompositedScrollTranslationState(
|
||||
PropertyTreeState::Root(), -10, -15, gfx::Rect(20, 10, 40, 50),
|
||||
gfx::Size(2000, 2000));
|
||||
@ -334,7 +282,7 @@ TEST_P(CullRectTest, ApplyScrollTranslationWholeScrollingContents) {
|
||||
EXPECT_EQ(gfx::Rect(20, 10, 2000, 2000), cull_rect.Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest,
|
||||
TEST_F(CullRectTest,
|
||||
ApplyNonCompositedScrollTranslationWholeScrollingContents) {
|
||||
auto state = CreateScrollTranslationState(PropertyTreeState::Root(), -10, -15,
|
||||
gfx::Rect(20, 10, 40, 50),
|
||||
@ -352,7 +300,7 @@ TEST_P(CullRectTest,
|
||||
EXPECT_EQ(gfx::Rect(20, 10, 2000, 2000), cull_rect.Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest,
|
||||
TEST_F(CullRectTest,
|
||||
ApplyScrollTranslationWholeScrollingContentsWithoutExpansion) {
|
||||
expansion_ratio_ = 0;
|
||||
auto state = CreateCompositedScrollTranslationState(
|
||||
@ -376,14 +324,14 @@ TEST_P(CullRectTest,
|
||||
EXPECT_EQ(gfx::Rect(30, 25, 40, 50), cull_rect.Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, ChangedEnoughEmpty) {
|
||||
TEST_F(CullRectTest, ChangedEnoughEmpty) {
|
||||
EXPECT_FALSE(ChangedEnough(gfx::Rect(), gfx::Rect()));
|
||||
EXPECT_FALSE(ChangedEnough(gfx::Rect(1, 1, 0, 0), gfx::Rect(2, 2, 0, 0)));
|
||||
EXPECT_TRUE(ChangedEnough(gfx::Rect(), gfx::Rect(0, 0, 1, 1)));
|
||||
EXPECT_FALSE(ChangedEnough(gfx::Rect(0, 0, 1, 1), gfx::Rect()));
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, ChangedNotEnough) {
|
||||
TEST_F(CullRectTest, ChangedNotEnough) {
|
||||
gfx::Rect old_rect(100, 100, 100, 100);
|
||||
EXPECT_FALSE(ChangedEnough(old_rect, old_rect));
|
||||
EXPECT_FALSE(ChangedEnough(old_rect, gfx::Rect(100, 100, 90, 90)));
|
||||
@ -391,7 +339,7 @@ TEST_P(CullRectTest, ChangedNotEnough) {
|
||||
EXPECT_FALSE(ChangedEnough(old_rect, gfx::Rect(1, 1, 200, 200)));
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, ChangedEnoughOnMovement) {
|
||||
TEST_F(CullRectTest, ChangedEnoughOnMovement) {
|
||||
gfx::Rect old_rect(100, 100, 100, 100);
|
||||
gfx::Rect new_rect(old_rect);
|
||||
new_rect.Offset(500, 0);
|
||||
@ -404,7 +352,7 @@ TEST_P(CullRectTest, ChangedEnoughOnMovement) {
|
||||
EXPECT_TRUE(ChangedEnough(old_rect, new_rect));
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, ChangedEnoughNewRectTouchingEdge) {
|
||||
TEST_F(CullRectTest, ChangedEnoughNewRectTouchingEdge) {
|
||||
gfx::Rect bounds(0, 0, 500, 500);
|
||||
gfx::Rect old_rect(100, 100, 100, 100);
|
||||
// Top edge.
|
||||
@ -437,7 +385,7 @@ TEST_P(CullRectTest, ChangedEnoughNewRectTouchingEdge) {
|
||||
EXPECT_TRUE(ChangedEnough(old_rect, gfx::Rect(0, 200, 400, 100), bounds));
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, ChangedEnoughOldRectTouchingEdge) {
|
||||
TEST_F(CullRectTest, ChangedEnoughOldRectTouchingEdge) {
|
||||
gfx::Rect bounds(0, 0, 500, 500);
|
||||
gfx::Rect new_rect(100, 100, 300, 300);
|
||||
// Top edge.
|
||||
@ -462,7 +410,7 @@ TEST_P(CullRectTest, ChangedEnoughOldRectTouchingEdge) {
|
||||
EXPECT_FALSE(ChangedEnough(gfx::Rect(300, 400, 100, 100), new_rect, bounds));
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, ChangedEnoughNotExpanded) {
|
||||
TEST_F(CullRectTest, ChangedEnoughNotExpanded) {
|
||||
gfx::Rect old_rect(100, 100, 300, 300);
|
||||
// X is not expanded and unchanged, y isn't changed enough.
|
||||
EXPECT_FALSE(ChangedEnough(old_rect, gfx::Rect(100, 0, 300, 300),
|
||||
@ -483,7 +431,7 @@ TEST_P(CullRectTest, ChangedEnoughNotExpanded) {
|
||||
std::nullopt, {true, false}));
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, ApplyPaintPropertiesWithoutClipScroll) {
|
||||
TEST_F(CullRectTest, ApplyPaintPropertiesWithoutClipScroll) {
|
||||
auto* t1 = CreateTransform(t0(), MakeTranslationMatrix(1, 2));
|
||||
auto* t2 = CreateTransform(*t1, MakeTranslationMatrix(10, 20));
|
||||
PropertyTreeState root = PropertyTreeState::Root();
|
||||
@ -510,7 +458,7 @@ TEST_P(CullRectTest, ApplyPaintPropertiesWithoutClipScroll) {
|
||||
EXPECT_TRUE(infinite.IsInfinite());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, SingleScrollWholeCompsitedScrollingContents) {
|
||||
TEST_F(CullRectTest, SingleScrollWholeCompsitedScrollingContents) {
|
||||
auto* t1 = CreateTransform(t0(), MakeTranslationMatrix(1, 2));
|
||||
PropertyTreeState state1(*t1, c0(), e0());
|
||||
auto scroll_translation_state = CreateCompositedScrollTranslationState(
|
||||
@ -536,7 +484,7 @@ TEST_P(CullRectTest, SingleScrollWholeCompsitedScrollingContents) {
|
||||
EXPECT_EQ(gfx::Rect(20, 10, 2000, 2000), cull_rect3.Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, ApplyTransformsWithOrigin) {
|
||||
TEST_F(CullRectTest, ApplyTransformsWithOrigin) {
|
||||
auto* t1 = CreateTransform(t0(), MakeTranslationMatrix(1, 2));
|
||||
auto* t2 =
|
||||
CreateTransform(*t1, MakeScaleMatrix(0.5), gfx::Point3F(50, 100, 0));
|
||||
@ -548,7 +496,7 @@ TEST_P(CullRectTest, ApplyTransformsWithOrigin) {
|
||||
EXPECT_EQ(gfx::Rect(-50, -100, 100, 400), cull_rect1.Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, SingleScrollPartialScrollingContents) {
|
||||
TEST_F(CullRectTest, SingleScrollPartialScrollingContents) {
|
||||
auto* t1 = Create2DTranslation(t0(), 1, 2);
|
||||
PropertyTreeState state1(*t1, c0(), e0());
|
||||
|
||||
@ -559,15 +507,9 @@ TEST_P(CullRectTest, SingleScrollPartialScrollingContents) {
|
||||
CullRect cull_rect1(gfx::Rect(0, 0, 50, 100));
|
||||
EXPECT_TRUE(ApplyPaintProperties(cull_rect1, state1, state1,
|
||||
scroll_translation_state));
|
||||
EXPECT_EQ(RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()
|
||||
? gfx::Rect(1020, 3010, 4030, 4050)
|
||||
: gfx::Rect(20, 1010, 7030, 7000),
|
||||
cull_rect1.Rect());
|
||||
EXPECT_EQ(gfx::Rect(1020, 3010, 4030, 4050), cull_rect1.Rect());
|
||||
|
||||
CullRect old_cull_rect(
|
||||
RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()
|
||||
? gfx::Rect(1000, 3100, 4000, 4000)
|
||||
: gfx::Rect(20, 1100, 7050, 6910));
|
||||
CullRect old_cull_rect(gfx::Rect(1000, 3100, 4000, 4000));
|
||||
CullRect cull_rect2(gfx::Rect(0, 0, 50, 100));
|
||||
// Use old_cull_rect if the new cull rect didn't change enough.
|
||||
EXPECT_TRUE(ApplyPaintProperties(cull_rect2, state1, state1,
|
||||
@ -586,13 +528,10 @@ TEST_P(CullRectTest, SingleScrollPartialScrollingContents) {
|
||||
scroll_translation_state));
|
||||
// This result differs from the first result in width (4030 vs 4040)
|
||||
// because it's not clipped by the infinite input cull rect.
|
||||
EXPECT_EQ(RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()
|
||||
? gfx::Rect(1020, 3010, 4040, 4050)
|
||||
: gfx::Rect(20, 1010, 7040, 7000),
|
||||
cull_rect4.Rect());
|
||||
EXPECT_EQ(gfx::Rect(1020, 3010, 4040, 4050), cull_rect4.Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, TransformUnderScrollTranslation) {
|
||||
TEST_F(CullRectTest, TransformUnderScrollTranslation) {
|
||||
auto* t1 = Create2DTranslation(t0(), 1, 2);
|
||||
PropertyTreeState state1(*t1, c0(), e0());
|
||||
auto scroll_translation_state = CreateCompositedScrollTranslationState(
|
||||
@ -606,15 +545,9 @@ TEST_P(CullRectTest, TransformUnderScrollTranslation) {
|
||||
// except that the offset is adjusted with |t2|.
|
||||
CullRect cull_rect1(gfx::Rect(0, 0, 50, 100));
|
||||
EXPECT_TRUE(ApplyPaintProperties(cull_rect1, state1, state1, state2));
|
||||
EXPECT_EQ(RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()
|
||||
? gfx::Rect(-980, 10, 4030, 4050)
|
||||
: gfx::Rect(-1980, -1990, 7030, 7000),
|
||||
cull_rect1.Rect());
|
||||
EXPECT_EQ(gfx::Rect(-980, 10, 4030, 4050), cull_rect1.Rect());
|
||||
|
||||
CullRect old_cull_rect(
|
||||
RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()
|
||||
? gfx::Rect(-980, 10, 4000, 4000)
|
||||
: gfx::Rect(-1980, -1990, 7030, 7000));
|
||||
CullRect old_cull_rect(gfx::Rect(-980, 10, 4000, 4000));
|
||||
CullRect cull_rect2(gfx::Rect(0, 0, 50, 100));
|
||||
// Use old_cull_rect if the new cull rect didn't change enough.
|
||||
EXPECT_TRUE(
|
||||
@ -632,13 +565,10 @@ TEST_P(CullRectTest, TransformUnderScrollTranslation) {
|
||||
EXPECT_TRUE(ApplyPaintProperties(cull_rect4, state1, state1, state2));
|
||||
// This result differs from the first result in height (7050 vs 7060)
|
||||
// because it's not clipped by the infinite input cull rect.
|
||||
EXPECT_EQ(RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()
|
||||
? gfx::Rect(-980, 10, 4040, 4050)
|
||||
: gfx::Rect(-1980, -1990, 7040, 7000),
|
||||
cull_rect4.Rect());
|
||||
EXPECT_EQ(gfx::Rect(-980, 10, 4040, 4050), cull_rect4.Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, TransformEscapingScroll) {
|
||||
TEST_F(CullRectTest, TransformEscapingScroll) {
|
||||
PropertyTreeState root = PropertyTreeState::Root();
|
||||
auto* t1 = CreateTransform(t0(), MakeTranslationMatrix(1, 2));
|
||||
auto* c1 = CreateClip(c0(), t0(), FloatRoundedRect(111, 222, 333, 444));
|
||||
@ -670,7 +600,7 @@ TEST_P(CullRectTest, TransformEscapingScroll) {
|
||||
EXPECT_EQ(cull_rect1, cull_rect3);
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, SmallScrollContentsAfterBigScrollContents) {
|
||||
TEST_F(CullRectTest, SmallScrollContentsAfterBigScrollContents) {
|
||||
auto* t1 = CreateTransform(t0(), MakeTranslationMatrix(1, 2));
|
||||
PropertyTreeState state1(*t1, c0(), e0());
|
||||
|
||||
@ -698,7 +628,7 @@ TEST_P(CullRectTest, SmallScrollContentsAfterBigScrollContents) {
|
||||
EXPECT_EQ(cull_rect1, cull_rect2);
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, BigScrollContentsAfterSmallScrollContents) {
|
||||
TEST_F(CullRectTest, BigScrollContentsAfterSmallScrollContents) {
|
||||
auto* t1 = CreateTransform(t0(), MakeTranslationMatrix(1, 2));
|
||||
PropertyTreeState state1(*t1, c0(), e0());
|
||||
|
||||
@ -720,15 +650,9 @@ TEST_P(CullRectTest, BigScrollContentsAfterSmallScrollContents) {
|
||||
// After t2: (-3980, -3975, 8070, 8180)
|
||||
// Clipped by the container rect of the second scroll: (20, 10, 50, 100)
|
||||
// After the second scroll offset: (3020, 5010, 50, 100)
|
||||
// DynamicScrollCullRectExpansion:
|
||||
// Expanded: (1020, 3010, 4050, 4100)
|
||||
// Otherwise:
|
||||
// Expanded: (-980, 1010, 8050, 8100)
|
||||
// Then clipped by the contents rect.
|
||||
EXPECT_EQ(RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()
|
||||
? gfx::Rect(1020, 3010, 4050, 4100)
|
||||
: gfx::Rect(20, 1010, 7050, 8100),
|
||||
cull_rect1.Rect());
|
||||
// Expanded: (1020, 3010, 4050, 4100)
|
||||
// Then clipped by the contents rect.
|
||||
EXPECT_EQ(gfx::Rect(1020, 3010, 4050, 4100), cull_rect1.Rect());
|
||||
|
||||
CullRect old_cull_rect = cull_rect1;
|
||||
old_cull_rect.Move(gfx::Vector2d(0, 100));
|
||||
@ -746,7 +670,7 @@ TEST_P(CullRectTest, BigScrollContentsAfterSmallScrollContents) {
|
||||
EXPECT_EQ(cull_rect1, cull_rect3);
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, NonCompositedTransformUnderClip) {
|
||||
TEST_F(CullRectTest, NonCompositedTransformUnderClip) {
|
||||
PropertyTreeState root = PropertyTreeState::Root();
|
||||
auto* c1 = CreateClip(c0(), t0(), FloatRoundedRect(100, 200, 300, 400));
|
||||
auto* t1 = CreateTransform(t0(), MakeTranslationMatrix(10, 20));
|
||||
@ -773,7 +697,7 @@ TEST_P(CullRectTest, NonCompositedTransformUnderClip) {
|
||||
EXPECT_EQ(gfx::Rect(), cull_rect4.Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, CompositedTranslationUnderClip) {
|
||||
TEST_F(CullRectTest, CompositedTranslationUnderClip) {
|
||||
PropertyTreeState root = PropertyTreeState::Root();
|
||||
auto* c1 = CreateClip(c0(), t0(), FloatRoundedRect(100, 200, 300, 400));
|
||||
auto transform = MakeTranslationMatrix(10, 20);
|
||||
@ -812,7 +736,7 @@ TEST_P(CullRectTest, CompositedTranslationUnderClip) {
|
||||
EXPECT_EQ(gfx::Rect(), cull_rect5.Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, CompositedTransformUnderClipWithoutExpansion) {
|
||||
TEST_F(CullRectTest, CompositedTransformUnderClipWithoutExpansion) {
|
||||
expansion_ratio_ = 0;
|
||||
PropertyTreeState root = PropertyTreeState::Root();
|
||||
auto* c1 = CreateClip(c0(), t0(), FloatRoundedRect(100, 200, 300, 400));
|
||||
@ -842,7 +766,7 @@ TEST_P(CullRectTest, CompositedTransformUnderClipWithoutExpansion) {
|
||||
EXPECT_EQ(gfx::Rect(), cull_rect4.Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, ClipAndCompositedScrollAndClip) {
|
||||
TEST_F(CullRectTest, ClipAndCompositedScrollAndClip) {
|
||||
auto root = PropertyTreeState::Root();
|
||||
auto* c1 = CreateClip(c0(), t0(), FloatRoundedRect(0, 10000, 100, 100));
|
||||
auto* t1 = Create2DTranslation(t0(), 0, 10000);
|
||||
@ -903,7 +827,7 @@ TEST_P(CullRectTest, ClipAndCompositedScrollAndClip) {
|
||||
|
||||
// Test for multiple clips (e.g., overflow clip and inner border radius)
|
||||
// associated with the same scroll translation.
|
||||
TEST_P(CullRectTest, MultipleClips) {
|
||||
TEST_F(CullRectTest, MultipleClips) {
|
||||
auto* t1 = Create2DTranslation(t0(), 0, 0);
|
||||
auto scroll_state = CreateCompositedScrollTranslationState(
|
||||
PropertyTreeState(*t1, c0(), e0()), 0, 0, gfx::Rect(0, 0, 100, 100),
|
||||
@ -922,7 +846,7 @@ TEST_P(CullRectTest, MultipleClips) {
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 100, 2000), cull_rect.Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, ClipWithNonIntegralOffsetAndZeroSize) {
|
||||
TEST_F(CullRectTest, ClipWithNonIntegralOffsetAndZeroSize) {
|
||||
auto* clip = CreateClip(c0(), t0(), FloatRoundedRect(0.4, 0.6, 0, 0));
|
||||
PropertyTreeState source = PropertyTreeState::Root();
|
||||
PropertyTreeState destination(t0(), *clip, e0());
|
||||
@ -931,7 +855,7 @@ TEST_P(CullRectTest, ClipWithNonIntegralOffsetAndZeroSize) {
|
||||
EXPECT_TRUE(cull_rect.Rect().IsEmpty());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, ScrollableAlongOneAxisWithClippedInput) {
|
||||
TEST_F(CullRectTest, ScrollableAlongOneAxisWithClippedInput) {
|
||||
auto root = PropertyTreeState::Root();
|
||||
// Scrollable along y only.
|
||||
auto scroll_state = CreateCompositedScrollTranslationState(
|
||||
@ -941,11 +865,7 @@ TEST_P(CullRectTest, ScrollableAlongOneAxisWithClippedInput) {
|
||||
CullRect cull_rect(gfx::Rect(10, 10, 150, 250));
|
||||
// Apply scroll translation. Should expand in the scrollable direction.
|
||||
EXPECT_TRUE(ApplyPaintProperties(cull_rect, root, root, scroll_state));
|
||||
if (RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()) {
|
||||
EXPECT_EQ(gfx::Rect(10, 0, 150, 4260), cull_rect.Rect());
|
||||
} else {
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 300, 4260), cull_rect.Rect());
|
||||
}
|
||||
EXPECT_EQ(gfx::Rect(10, 0, 150, 4260), cull_rect.Rect());
|
||||
|
||||
CullRect old_cull_rect = cull_rect;
|
||||
// The input rect becomes wider but still smaller than the container rect.
|
||||
@ -953,14 +873,10 @@ TEST_P(CullRectTest, ScrollableAlongOneAxisWithClippedInput) {
|
||||
cull_rect = CullRect(gfx::Rect(10, 10, 200, 250));
|
||||
EXPECT_TRUE(
|
||||
ApplyPaintProperties(cull_rect, root, root, scroll_state, old_cull_rect));
|
||||
if (RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()) {
|
||||
EXPECT_EQ(gfx::Rect(10, 0, 200, 4260), cull_rect.Rect());
|
||||
} else {
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 300, 4260), cull_rect.Rect());
|
||||
}
|
||||
EXPECT_EQ(gfx::Rect(10, 0, 200, 4260), cull_rect.Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, IntersectsVerticalRange) {
|
||||
TEST_F(CullRectTest, IntersectsVerticalRange) {
|
||||
CullRect cull_rect(gfx::Rect(0, 0, 50, 100));
|
||||
|
||||
EXPECT_TRUE(cull_rect.IntersectsVerticalRange(LayoutUnit(), LayoutUnit(1)));
|
||||
@ -968,7 +884,7 @@ TEST_P(CullRectTest, IntersectsVerticalRange) {
|
||||
cull_rect.IntersectsVerticalRange(LayoutUnit(100), LayoutUnit(101)));
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, IntersectsHorizontalRange) {
|
||||
TEST_F(CullRectTest, IntersectsHorizontalRange) {
|
||||
CullRect cull_rect(gfx::Rect(0, 0, 50, 100));
|
||||
|
||||
EXPECT_TRUE(cull_rect.IntersectsHorizontalRange(LayoutUnit(), LayoutUnit(1)));
|
||||
@ -976,7 +892,7 @@ TEST_P(CullRectTest, IntersectsHorizontalRange) {
|
||||
cull_rect.IntersectsHorizontalRange(LayoutUnit(50), LayoutUnit(51)));
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, TransferExpansionOutsetY) {
|
||||
TEST_F(CullRectTest, TransferExpansionOutsetY) {
|
||||
auto state = CreateCompositedScrollTranslationState(
|
||||
PropertyTreeState::Root(), -10, -15, gfx::Rect(20, 10, 40, 50),
|
||||
gfx::Size(200, 12000));
|
||||
@ -986,42 +902,28 @@ TEST_P(CullRectTest, TransferExpansionOutsetY) {
|
||||
EXPECT_EQ(std::make_pair(true, true),
|
||||
ApplyScrollTranslation(cull_rect, scroll_translation));
|
||||
|
||||
if (RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()) {
|
||||
// Clipped: (20, 10, 30, 50)
|
||||
// Inverse transformed: (30, 25, 30, 50)
|
||||
// Outsets in the dynamic case are initially 4000, but in this case, the
|
||||
// scrollable is scrollable in both dimensions, so we initially drop this to
|
||||
// 2000 in all directions to prevent the rect from being too large. However,
|
||||
// in this case, our scroll extent in the x direction is small (160). This
|
||||
// reduces the total extent in the x dimension to 160 and the remaining
|
||||
// outset (1840) is added to the y outset (giving a total outset of 3840).
|
||||
// So the expanded width will be 30 + 2 * 160 = 350 and the total height
|
||||
// will be 50 + 2 * 3840 = 7730.
|
||||
// Expanded: (-130, -3815, 350, 7730)
|
||||
// Now the contents rect is (20, 10, 200, 12000),
|
||||
// Clipped with contents rect: (20, 10, 200, 3905)
|
||||
EXPECT_EQ(gfx::Rect(20, 10, 200, 3905), cull_rect.Rect());
|
||||
} else {
|
||||
// Clipped: (20, 10, 30, 50)
|
||||
// Inverse transformed: (30, 25, 30, 50)
|
||||
// Uniform outset of 4000.
|
||||
// Expanded: (-3970, -3975, 8030, 8050)
|
||||
// Contents rect is (20, 10, 200, 12000)
|
||||
// Clipped with contents rect: (20, 10, 200, 4065)
|
||||
EXPECT_EQ(gfx::Rect(20, 10, 200, 4065), cull_rect.Rect());
|
||||
}
|
||||
// Clipped: (20, 10, 30, 50)
|
||||
// Inverse transformed: (30, 25, 30, 50)
|
||||
// Outsets in the dynamic case are initially 4000, but in this case, the
|
||||
// scrollable is scrollable in both dimensions, so we initially drop this to
|
||||
// 2000 in all directions to prevent the rect from being too large. However,
|
||||
// in this case, our scroll extent in the x direction is small (160). This
|
||||
// reduces the total extent in the x dimension to 160 and the remaining
|
||||
// outset (1840) is added to the y outset (giving a total outset of 3840).
|
||||
// So the expanded width will be 30 + 2 * 160 = 350 and the total height
|
||||
// will be 50 + 2 * 3840 = 7730.
|
||||
// Expanded: (-130, -3815, 350, 7730)
|
||||
// Now the contents rect is (20, 10, 200, 12000),
|
||||
// Clipped with contents rect: (20, 10, 200, 3905)
|
||||
EXPECT_EQ(gfx::Rect(20, 10, 200, 3905), cull_rect.Rect());
|
||||
|
||||
cull_rect = CullRect::Infinite();
|
||||
EXPECT_EQ(std::make_pair(true, true),
|
||||
ApplyScrollTranslation(cull_rect, scroll_translation));
|
||||
if (RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()) {
|
||||
EXPECT_EQ(gfx::Rect(20, 10, 200, 3905), cull_rect.Rect());
|
||||
} else {
|
||||
EXPECT_EQ(gfx::Rect(20, 10, 200, 4065), cull_rect.Rect());
|
||||
}
|
||||
EXPECT_EQ(gfx::Rect(20, 10, 200, 3905), cull_rect.Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, TransferExpansionOutsetX) {
|
||||
TEST_F(CullRectTest, TransferExpansionOutsetX) {
|
||||
auto state = CreateCompositedScrollTranslationState(
|
||||
PropertyTreeState::Root(), -10, -15, gfx::Rect(20, 10, 40, 50),
|
||||
gfx::Size(12000, 200));
|
||||
@ -1031,37 +933,24 @@ TEST_P(CullRectTest, TransferExpansionOutsetX) {
|
||||
EXPECT_EQ(std::make_pair(true, true),
|
||||
ApplyScrollTranslation(cull_rect, scroll_translation));
|
||||
|
||||
if (RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()) {
|
||||
// Clipped: (20, 10, 30, 50)
|
||||
// Inverse transformed: (30, 25, 30, 50)
|
||||
// We have a scroll range of 150 in y. We're starting with 2000 in the case
|
||||
// of being scrollable in two dimensions, so this leaves 1850 to be
|
||||
// transferred to the x outset leading to an outset of 3850.
|
||||
// Expanded: (-3820, -125, 7730, 350)
|
||||
// Clip to contents rect (20, 10, 12000, 2000)
|
||||
EXPECT_EQ(gfx::Rect(20, 10, 3890, 200), cull_rect.Rect());
|
||||
} else {
|
||||
// Clipped: (20, 10, 30, 50)
|
||||
// Inverse transformed: (30, 25, 30, 50)
|
||||
// Uniform outset of 4000.
|
||||
// Expanded: (-3970, -3975, 8030, 8050)
|
||||
// Clip to contents rect (20, 10, 12000, 2000)
|
||||
EXPECT_EQ(gfx::Rect(20, 10, 4040, 200), cull_rect.Rect());
|
||||
}
|
||||
// Clipped: (20, 10, 30, 50)
|
||||
// Inverse transformed: (30, 25, 30, 50)
|
||||
// We have a scroll range of 150 in y. We're starting with 2000 in the case
|
||||
// of being scrollable in two dimensions, so this leaves 1850 to be
|
||||
// transferred to the x outset leading to an outset of 3850.
|
||||
// Expanded: (-3820, -125, 7730, 350)
|
||||
// Clip to contents rect (20, 10, 12000, 2000)
|
||||
EXPECT_EQ(gfx::Rect(20, 10, 3890, 200), cull_rect.Rect());
|
||||
|
||||
cull_rect = CullRect::Infinite();
|
||||
EXPECT_EQ(std::make_pair(true, true),
|
||||
ApplyScrollTranslation(cull_rect, scroll_translation));
|
||||
// In the following cases, the infinite rect is clipped to (20, 10, 40, 50).
|
||||
// The increase in width is reflected in the values below.
|
||||
if (RuntimeEnabledFeatures::DynamicScrollCullRectExpansionEnabled()) {
|
||||
EXPECT_EQ(gfx::Rect(20, 10, 3900, 200), cull_rect.Rect());
|
||||
} else {
|
||||
EXPECT_EQ(gfx::Rect(20, 10, 4050, 200), cull_rect.Rect());
|
||||
}
|
||||
EXPECT_EQ(gfx::Rect(20, 10, 3900, 200), cull_rect.Rect());
|
||||
}
|
||||
|
||||
TEST_P(CullRectTest, TransferExpansionOutsetBlocked) {
|
||||
TEST_F(CullRectTest, TransferExpansionOutsetBlocked) {
|
||||
auto state = CreateCompositedScrollTranslationState(
|
||||
PropertyTreeState::Root(), -10, -15, gfx::Rect(20, 10, 40, 50),
|
||||
gfx::Size(200, 200));
|
||||
|
@ -1650,10 +1650,6 @@
|
||||
name: "DynamicSafeAreaInsetsOnScroll",
|
||||
depends_on: ["DynamicSafeAreaInsets"]
|
||||
},
|
||||
{
|
||||
name: "DynamicScrollCullRectExpansion",
|
||||
status: "stable",
|
||||
},
|
||||
{
|
||||
name: "ElementCapture",
|
||||
origin_trial_feature_name: "ElementCapture",
|
||||
|
Reference in New Issue
Block a user