* Records the normalized CLS score, following the latest CWV standard. * See https://web.dev/evolving-cls/
()
| 625 | * See https://web.dev/evolving-cls/ |
| 626 | */ |
| 627 | flushLayoutShiftScore_() { |
| 628 | const entries = this.layoutShiftEntries_; |
| 629 | const old = this.metrics_.get(TickLabel_Enum.CUMULATIVE_LAYOUT_SHIFT); |
| 630 | let union = 0; |
| 631 | let sum = 0; |
| 632 | for (const entry of entries) { |
| 633 | if (entry.sources) { |
| 634 | for (const source of entry.sources) { |
| 635 | union |= getElementType(source.node); |
| 636 | } |
| 637 | } |
| 638 | sum += entry.value; |
| 639 | } |
| 640 | entries.length = 0; |
| 641 | this.recordGoogleFontExp_(); |
| 642 | if (old == null || sum > old) { |
| 643 | // We'll record the largest windowed CLS. |
| 644 | this.metrics_.reset(TickLabel_Enum.CUMULATIVE_LAYOUT_SHIFT); |
| 645 | this.metrics_.reset(TickLabel_Enum.CUMULATIVE_LAYOUT_SHIFT_TYPE_UNION); |
| 646 | this.tickDelta(TickLabel_Enum.CUMULATIVE_LAYOUT_SHIFT, sum); |
| 647 | this.tickDelta(TickLabel_Enum.CUMULATIVE_LAYOUT_SHIFT_TYPE_UNION, union); |
| 648 | this.flush(); |
| 649 | } |
| 650 | } |
| 651 | |
| 652 | /** |
| 653 | * Record the interaction to next paint score. |
no test coverage detected