fune/devtools/client/netmonitor/selectors/ui.js
Jarda Snajdr bcce5eb099 Bug 1309866 - Migrate RequestsMenuView to a React component with Redux store r=Honza
MozReview-Commit-ID: IMu1sJLxQYy

--HG--
extra : rebase_source : aa5a6f1a67ad0d4d83bcb0308d3dd6fe0de0ee0f
2016-10-11 15:13:28 +02:00

32 lines
1,011 B
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;
}
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,
};