Skip to content

Commit

Permalink
Record google-font experiment (#35390)
Browse files Browse the repository at this point in the history
See b/194504282 for details.
  • Loading branch information
jridgewell authored Jul 24, 2021
1 parent 78c8985 commit e20fe9a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/service/performance-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {VisibilityState} from '#core/constants/visibility-state';
import {Signals} from '#core/data-structures/signals';
import {whenDocumentComplete, whenDocumentReady} from '#core/document-ready';
import {layoutRectLtwh} from '#core/dom/layout/rect';
import {computedStyle} from '#core/dom/style';
import {throttle} from '#core/types/function';
import {dict, map} from '#core/types/object';

Expand Down Expand Up @@ -203,6 +204,11 @@ export class Performance {
whenDocumentComplete(win.document).then(() => this.onload_());
this.registerPerformanceObserver_();
this.registerFirstInputDelayPolyfillListener_();

/**
* @private {boolean}
*/
this.googleFontExpRecorded_ = false;
}

/**
Expand Down Expand Up @@ -466,6 +472,20 @@ export class Performance {
*/
tickCumulativeMetrics_() {
if (this.supportsLayoutShift_) {
if (!this.googleFontExpRecorded_) {
this.googleFontExpRecorded_ = true;
const {win} = this;
const googleFontExp = parseInt(
computedStyle(win, win.document.body).getPropertyValue(
'--google-font-exp'
),
10
);
if (googleFontExp >= 0) {
this.addEnabledExperiment(`google-font-exp=${googleFontExp}`);
}
}

this.tickLayoutShiftScore_();
}
if (this.supportsLargestContentfulPaint_) {
Expand Down

0 comments on commit e20fe9a

Please sign in to comment.