Commit d1d9b0a7 authored by Steve Kobes's avatar Steve Kobes Committed by Commit Bot

Update layout instability terminology in core/timing.

This renames Performance::layout_jank_buffer_ and associated objects, as
well as WindowPerformance::AddLayoutJankFraction.

Also remove some references to "jank" in LayoutShiftTracker unit tests.

Bug: 963474
Change-Id: I71877731150008928bf56319bf9631d6326ad0f8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1720997Reviewed-by: default avatarTimothy Dresser <tdresser@chromium.org>
Commit-Queue: Steve Kobes <skobes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681920}
parent 816e4bc6
......@@ -364,8 +364,8 @@ void LayoutShiftTracker::ReportShift(double score_delta,
WindowPerformance* performance =
DOMWindowPerformance::performance(*frame.DomWindow());
if (performance) {
performance->AddLayoutJankFraction(score_delta, had_recent_input,
most_recent_input_timestamp_);
performance->AddLayoutShiftValue(score_delta, had_recent_input,
most_recent_input_timestamp_);
}
}
......
......@@ -158,7 +158,7 @@ TEST_F(LayoutShiftTrackerTest, IgnoreAfterInput) {
TEST_F(LayoutShiftTrackerTest, CompositedElementMovement) {
SetBodyInnerHTML(R"HTML(
<style>
#jank {
#shift {
position: relative;
width: 500px;
height: 200px;
......@@ -176,7 +176,7 @@ TEST_F(LayoutShiftTrackerTest, CompositedElementMovement) {
</style>
<div id='container' class='tr'>
<div id='space'></div>
<div id='jank' class='tr'></div>
<div id='shift' class='tr'></div>
</div>
)HTML");
......@@ -184,14 +184,14 @@ TEST_F(LayoutShiftTrackerTest, CompositedElementMovement) {
html_names::kStyleAttr, AtomicString("height: 100px"));
UpdateAllLifecyclePhases();
// #jank is 400x200 after viewport intersection with correct application of
// composited #container offset, and 100px lower after janking, so jank score
// is (400 * 300) * (100 / 800) / (viewport size 800 * 600)
// #shift is 400x200 after viewport intersection with correct application of
// composited #container offset, and 100px lower after shifting, so shift
// score is (400 * 300) * (100 / 800) / (viewport size 800 * 600)
EXPECT_FLOAT_EQ(0.25 * (100.0 / 800.0), GetLayoutShiftTracker().Score());
}
TEST_F(LayoutShiftTrackerTest, CompositedJankBeforeFirstPaint) {
// Tests that we don't crash if a new layer janks during a second compositing
TEST_F(LayoutShiftTrackerTest, CompositedShiftBeforeFirstPaint) {
// Tests that we don't crash if a new layer shifts during a second compositing
// update before prepaint sets up property tree state. See crbug.com/881735
// (which invokes UpdateLifecycleToCompositingCleanPlusScrolling through
// accessibilityController.accessibleElementById).
......@@ -261,7 +261,7 @@ TEST_F(LayoutShiftTrackerTest, IgnoreSVG) {
EXPECT_FLOAT_EQ(0, GetLayoutShiftTracker().Score());
}
TEST_F(LayoutShiftTrackerTest, JankWhileScrolled) {
TEST_F(LayoutShiftTrackerTest, ShiftWhileScrolled) {
SetBodyInnerHTML(R"HTML(
<style>
body { height: 1000px; margin: 0; }
......@@ -367,7 +367,7 @@ TEST_F(LayoutShiftTrackerTest, ShiftInToViewport) {
AtomicString("top: 400px"));
UpdateAllLifecyclePhases();
// The element moves from outside the viewport to within the viewport, which
// should generate jank.
// should generate a shift.
// (width 600) * (height 0 + move 200) * (200 / 800) / (800 * 600 viewport)
EXPECT_FLOAT_EQ(0.25 * (200.0 / 800.0), GetLayoutShiftTracker().Score());
}
......@@ -386,14 +386,14 @@ TEST_F(LayoutShiftTrackerTest, ClipWithoutPaintLayer) {
)HTML");
// Increase j's top margin by 100px. Since j is clipped by the scroller, this
// should not generate jank. However, due to the issue in crbug/971639, this
// case was erroneously reported as janking, before that bug was fixed. This
// test ensures we do not regress this behavior.
// should not generate a shift. However, due to the issue in crbug.com/971639,
// this case was erroneously reported as shifting, before that bug was fixed.
// This test ensures we do not regress this behavior.
GetDocument().getElementById("j")->setAttribute(
html_names::kStyleAttr, AtomicString("margin-top: 100px"));
UpdateAllLifecyclePhases();
// Make sure no jank score is reported, since the element that moved is fully
// Make sure no shift score is reported, since the element that moved is fully
// clipped by the scroller.
EXPECT_FLOAT_EQ(0.0, GetLayoutShiftTracker().Score());
}
......
......@@ -97,7 +97,7 @@ using PerformanceObserverVector = HeapVector<Member<PerformanceObserver>>;
constexpr size_t kDefaultResourceTimingBufferSize = 250;
constexpr size_t kDefaultEventTimingBufferSize = 150;
constexpr size_t kDefaultElementTimingBufferSize = 150;
constexpr size_t kDefaultLayoutJankBufferSize = 150;
constexpr size_t kDefaultLayoutShiftBufferSize = 150;
constexpr size_t kDefaultLargestContenfulPaintSize = 150;
Performance::Performance(
......@@ -249,8 +249,8 @@ PerformanceEntryVector Performance::getEntriesByTypeInternal(
case PerformanceEntry::kTaskAttribution:
break;
case PerformanceEntry::kLayoutShift:
for (const auto& layout_jank : layout_jank_buffer_)
entries.push_back(layout_jank);
for (const auto& layout_shift : layout_shift_buffer_)
entries.push_back(layout_shift);
break;
case PerformanceEntry::kLargestContentfulPaint:
UseCounter::Count(GetExecutionContext(),
......@@ -549,9 +549,9 @@ void Performance::AddEventTimingBuffer(PerformanceEventTiming& entry) {
}
}
void Performance::AddLayoutJankBuffer(LayoutShift& entry) {
if (layout_jank_buffer_.size() < kDefaultLayoutJankBufferSize)
layout_jank_buffer_.push_back(&entry);
void Performance::AddLayoutShiftBuffer(LayoutShift& entry) {
if (layout_shift_buffer_.size() < kDefaultLayoutShiftBufferSize)
layout_shift_buffer_.push_back(&entry);
}
void Performance::AddLargestContentfulPaint(LargestContentfulPaint* entry) {
......@@ -914,7 +914,7 @@ void Performance::Trace(blink::Visitor* visitor) {
visitor->Trace(resource_timing_secondary_buffer_);
visitor->Trace(element_timing_buffer_);
visitor->Trace(event_timing_buffer_);
visitor->Trace(layout_jank_buffer_);
visitor->Trace(layout_shift_buffer_);
visitor->Trace(largest_contentful_paint_buffer_);
visitor->Trace(navigation_timing_);
visitor->Trace(user_timing_);
......
......@@ -179,7 +179,7 @@ class CORE_EXPORT Performance : public EventTargetWithInlineData {
bool IsEventTimingBufferFull() const;
void AddEventTimingBuffer(PerformanceEventTiming&);
void AddLayoutJankBuffer(LayoutShift&);
void AddLayoutShiftBuffer(LayoutShift&);
void AddLargestContentfulPaint(LargestContentfulPaint*);
......@@ -350,7 +350,7 @@ class CORE_EXPORT Performance : public EventTargetWithInlineData {
unsigned event_timing_buffer_max_size_;
PerformanceEntryVector element_timing_buffer_;
unsigned element_timing_buffer_max_size_;
PerformanceEntryVector layout_jank_buffer_;
PerformanceEntryVector layout_shift_buffer_;
PerformanceEntryVector largest_contentful_paint_buffer_;
Member<PerformanceEntry> navigation_timing_;
Member<UserTiming> user_timing_;
......
......@@ -72,9 +72,9 @@ TEST_F(PerformanceObserverTest, ObserveWithBufferedFlag) {
options->setBuffered(true);
EXPECT_EQ(0, NumPerformanceEntries());
// add a layoutjank to performance so getEntries() returns it
// add a layout-shift to performance so getEntries() returns it
auto* entry = MakeGarbageCollected<LayoutShift>(0.0, 1234, true, 5678);
base_->AddLayoutJankBuffer(*entry);
base_->AddLayoutShiftBuffer(*entry);
// call observe with the buffered flag
observer_->observe(options, exception_state);
......
......@@ -425,18 +425,18 @@ void WindowPerformance::DispatchFirstInputTiming(
first_input_timing_ = entry;
}
void WindowPerformance::AddLayoutJankFraction(double jank_fraction,
bool input_detected,
base::TimeTicks input_timestamp) {
void WindowPerformance::AddLayoutShiftValue(double value,
bool input_detected,
base::TimeTicks input_timestamp) {
DCHECK(RuntimeEnabledFeatures::LayoutInstabilityAPIEnabled(
GetExecutionContext()));
auto* entry = MakeGarbageCollected<LayoutShift>(
now(), jank_fraction, input_detected,
now(), value, input_detected,
input_detected ? MonotonicTimeToDOMHighResTimeStamp(input_timestamp)
: 0.0);
if (HasObserverFor(PerformanceEntry::kLayoutShift))
NotifyObserversOfEntry(*entry);
AddLayoutJankBuffer(*entry);
AddLayoutShiftBuffer(*entry);
}
void WindowPerformance::OnLargestContentfulPaintUpdated(
......
......@@ -84,9 +84,9 @@ class CORE_EXPORT WindowPerformance final : public Performance,
const AtomicString& id,
Element*);
void AddLayoutJankFraction(double jank_fraction,
bool input_detected,
base::TimeTicks input_timestamp);
void AddLayoutShiftValue(double value,
bool input_detected,
base::TimeTicks input_timestamp);
void OnLargestContentfulPaintUpdated(base::TimeTicks paint_time,
uint64_t paint_size,
......
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