Commit 175147e4 authored by Vladimir Levin's avatar Vladimir Levin Committed by Commit Bot

content-visibility: Increase the auto intersection margin to 150%.

This patch increases the viewport intersection margin for
content-visibility: auto to 150% of the viewport.

This prevents excessive 'checkerboarding' from lack of rendered
content on quick flings.

R=chrishtr@chromium.org
TEST=Tested with scrollBy({ top: 10000, behavior: 'smooth' }) on FB.

Change-Id: I70d3ef371d5aeb943dca26d6decae97184db446b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2453029
Commit-Queue: vmpstr <vmpstr@chromium.org>
Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814799}
parent f351ec3e
...@@ -2824,10 +2824,10 @@ TEST_F(DisplayLockContextRenderingTest, ...@@ -2824,10 +2824,10 @@ TEST_F(DisplayLockContextRenderingTest,
AutoReachesStableStateOnContentSmallerThanLockedSize) { AutoReachesStableStateOnContentSmallerThanLockedSize) {
SetHtmlInnerHTML(R"HTML( SetHtmlInnerHTML(R"HTML(
<style> <style>
.spacer { height: 10000px; } .spacer { height: 20000px; }
.auto { .auto {
content-visibility: auto; content-visibility: auto;
contain-intrinsic-size: 1px 10000px; contain-intrinsic-size: 1px 20000px;
} }
.auto > div { .auto > div {
height: 3000px; height: 3000px;
...@@ -2842,7 +2842,7 @@ TEST_F(DisplayLockContextRenderingTest, ...@@ -2842,7 +2842,7 @@ TEST_F(DisplayLockContextRenderingTest,
UpdateAllLifecyclePhasesForTest(); UpdateAllLifecyclePhasesForTest();
GetDocument().scrollingElement()->setScrollTop(19000); GetDocument().scrollingElement()->setScrollTop(29000);
Element* element = GetDocument().getElementById("e1"); Element* element = GetDocument().getElementById("e1");
...@@ -2852,35 +2852,35 @@ TEST_F(DisplayLockContextRenderingTest, ...@@ -2852,35 +2852,35 @@ TEST_F(DisplayLockContextRenderingTest,
// Initially we start with locked in the viewport. // Initially we start with locked in the viewport.
UpdateAllLifecyclePhasesForTest(); UpdateAllLifecyclePhasesForTest();
EXPECT_TRUE(element->GetDisplayLockContext()->IsLocked()); EXPECT_TRUE(element->GetDisplayLockContext()->IsLocked());
EXPECT_EQ(GetDocument().scrollingElement()->scrollTop(), 19000.); EXPECT_EQ(GetDocument().scrollingElement()->scrollTop(), 29000.);
// It gets unlocked because it's in the viewport. // It gets unlocked because it's in the viewport.
UpdateAllLifecyclePhasesForTest(); UpdateAllLifecyclePhasesForTest();
EXPECT_FALSE(element->GetDisplayLockContext()->IsLocked()); EXPECT_FALSE(element->GetDisplayLockContext()->IsLocked());
EXPECT_EQ(GetDocument().scrollingElement()->scrollTop(), 19000.); EXPECT_EQ(GetDocument().scrollingElement()->scrollTop(), 29000.);
// By unlocking it, it shrinks so next time it gets relocked. // By unlocking it, it shrinks so next time it gets relocked.
UpdateAllLifecyclePhasesForTest(); UpdateAllLifecyclePhasesForTest();
EXPECT_TRUE(element->GetDisplayLockContext()->IsLocked()); EXPECT_TRUE(element->GetDisplayLockContext()->IsLocked());
EXPECT_EQ(GetDocument().scrollingElement()->scrollTop(), 19000.); EXPECT_EQ(GetDocument().scrollingElement()->scrollTop(), 29000.);
// It again gets unlocked and shrink. // It again gets unlocked and shrink.
UpdateAllLifecyclePhasesForTest(); UpdateAllLifecyclePhasesForTest();
EXPECT_FALSE(element->GetDisplayLockContext()->IsLocked()); EXPECT_FALSE(element->GetDisplayLockContext()->IsLocked());
EXPECT_EQ(GetDocument().scrollingElement()->scrollTop(), 19000.); EXPECT_EQ(GetDocument().scrollingElement()->scrollTop(), 29000.);
// On the next relock we select the following element as an anchor and thus // On the next relock we select the following element as an anchor and thus
// the scroll top changes to be higher. // the scroll top changes to be higher.
UpdateAllLifecyclePhasesForTest(); UpdateAllLifecyclePhasesForTest();
EXPECT_TRUE(element->GetDisplayLockContext()->IsLocked()); EXPECT_TRUE(element->GetDisplayLockContext()->IsLocked());
EXPECT_GT(GetDocument().scrollingElement()->scrollTop(), 19000.); EXPECT_GT(GetDocument().scrollingElement()->scrollTop(), 29000.);
// Subsequent updates no longer unlock the element because even if its locked // Subsequent updates no longer unlock the element because even if its locked
// state it is far enough off-screen. // state it is far enough off-screen.
for (int i = 0; i < 5; ++i) { for (int i = 0; i < 5; ++i) {
UpdateAllLifecyclePhasesForTest(); UpdateAllLifecyclePhasesForTest();
EXPECT_TRUE(element->GetDisplayLockContext()->IsLocked()); EXPECT_TRUE(element->GetDisplayLockContext()->IsLocked());
EXPECT_GT(GetDocument().scrollingElement()->scrollTop(), 19000.); EXPECT_GT(GetDocument().scrollingElement()->scrollTop(), 29000.);
} }
} }
...@@ -3019,5 +3019,4 @@ TEST_F(DisplayLockContextTest, GraphicsLayerBitsNotCheckedInLockedSubtree) { ...@@ -3019,5 +3019,4 @@ TEST_F(DisplayLockContextTest, GraphicsLayerBitsNotCheckedInLockedSubtree) {
EXPECT_FALSE( EXPECT_FALSE(
target_layer->GetCompositedLayerMapping()->NeedsGraphicsLayerUpdate()); target_layer->GetCompositedLayerMapping()->NeedsGraphicsLayerUpdate());
} }
} // namespace blink } // namespace blink
...@@ -88,10 +88,11 @@ IntersectionObserver& DisplayLockDocumentState::EnsureIntersectionObserver() { ...@@ -88,10 +88,11 @@ IntersectionObserver& DisplayLockDocumentState::EnsureIntersectionObserver() {
// have run. This means for the duration of the idle time that follows, we // have run. This means for the duration of the idle time that follows, we
// should always have clean layout. // should always have clean layout.
// //
// Note that we use 50% margin (on the viewport) so that we get the // Note that we use 150% margin (on the viewport) so that we get the
// observation before the element enters the viewport. // observation before the element enters the viewport.
intersection_observer_ = IntersectionObserver::Create( intersection_observer_ = IntersectionObserver::Create(
{Length::Percent(50.f)}, {std::numeric_limits<float>::min()}, document_, {Length::Percent(150.f)}, {std::numeric_limits<float>::min()},
document_,
WTF::BindRepeating( WTF::BindRepeating(
&DisplayLockDocumentState::ProcessDisplayLockActivationObservation, &DisplayLockDocumentState::ProcessDisplayLockActivationObservation,
WrapWeakPersistent(this)), WrapWeakPersistent(this)),
......
...@@ -9,10 +9,10 @@ ...@@ -9,10 +9,10 @@
<style> <style>
.small_child { .small_child {
height: 500px; height: 1000px;
} }
.large_child { .large_child {
height: 5000px; height: 20000px;
position: relative; position: relative;
} }
#target { #target {
......
...@@ -12,10 +12,10 @@ ...@@ -12,10 +12,10 @@
<style> <style>
.auto { .auto {
content-visibility: auto; content-visibility: auto;
contain-intrinsic-size: 1px 500px; contain-intrinsic-size: 1px 1000px;
} }
.child { .child {
height: 5000px; height: 20000px;
position: relative; position: relative;
} }
#target { #target {
......
...@@ -9,10 +9,10 @@ ...@@ -9,10 +9,10 @@
<style> <style>
.small_child { .small_child {
height: 500px; height: 1000px;
} }
.large_child { .large_child {
height: 5000px; height: 20000px;
position: relative; position: relative;
} }
#target { #target {
......
...@@ -12,10 +12,10 @@ ...@@ -12,10 +12,10 @@
<style> <style>
.auto { .auto {
content-visibility: auto; content-visibility: auto;
contain-intrinsic-size: 1px 500px; contain-intrinsic-size: 1px 1000px;
} }
.child { .child {
height: 5000px; height: 20000px;
position: relative; position: relative;
} }
#target { #target {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment