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