mirror of
https://github.com/roytam1/basilisk55.git
synced 2026-06-11 02:59:15 +00:00
37 lines
1.0 KiB
JavaScript
37 lines
1.0 KiB
JavaScript
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
"use strict";
|
|
|
|
const { getDisplayedRequests } = require("./requests");
|
|
|
|
function isSidebarToggleButtonDisabled(state) {
|
|
return getDisplayedRequests(state).isEmpty();
|
|
}
|
|
|
|
const EPSILON = 0.001;
|
|
|
|
function getWaterfallScale(state) {
|
|
const { requests, timingMarkers, ui } = state;
|
|
|
|
if (requests.firstStartedMillis == +Infinity) {
|
|
return null;
|
|
}
|
|
|
|
if (ui.waterfallWidth == null) {
|
|
return null;
|
|
}
|
|
|
|
const lastEventMillis = Math.max(requests.lastEndedMillis,
|
|
timingMarkers.firstDocumentDOMContentLoadedTimestamp,
|
|
timingMarkers.firstDocumentLoadTimestamp);
|
|
const longestWidth = lastEventMillis - requests.firstStartedMillis;
|
|
return Math.min(Math.max(ui.waterfallWidth / longestWidth, EPSILON), 1);
|
|
}
|
|
|
|
module.exports = {
|
|
isSidebarToggleButtonDisabled,
|
|
getWaterfallScale,
|
|
};
|