/* 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/. */
/** * Return true if we should display a status message when we are in the given * state. Return false otherwise. * * @param {snapshotState|diffingState|dominatorTreeState} state * @param {models.view} view * @param {snapshotModel} snapshot * * @returns {Boolean}
*/ function shouldDisplayStatus(state, view, snapshot) { switch (state) { case states.IMPORTING: case states.SAVING: case states.SAVED: case states.READING: case censusState.SAVING: case treeMapState.SAVING: case diffingState.SELECTING: case diffingState.TAKING_DIFF: case dominatorTreeState.COMPUTING: case dominatorTreeState.COMPUTED: case dominatorTreeState.FETCHING: case individualsState.COMPUTING_DOMINATOR_TREE: case individualsState.FETCHING: returntrue;
} return view.state === viewState.DOMINATOR_TREE && !snapshot.dominatorTree;
}
/** * Get the status text to display for the given state. * * @param {snapshotState|diffingState|dominatorTreeState} state * @param {diffingModel} diffing * * @returns {String}
*/ function getStateStatusText(state, diffing) { if (state === diffingState.SELECTING) { return L10N.getStr(
diffing.firstSnapshotId === null
? "diffing.prompt.selectBaseline"
: "diffing.prompt.selectComparison"
);
}
return getStatusTextFull(state);
}
/** * Given that we should display a status message, return true if we should also * display a throbber along with the status message. Return false otherwise. * * @param {diffingModel} diffing * * @returns {Boolean}
*/ function shouldDisplayThrobber(diffing) { return !diffing || diffing.state !== diffingState.SELECTING;
}
/** * Get the current state's error, or return null if there is none. * * @param {snapshotModel} snapshot * @param {diffingModel} diffing * @param {individualsModel} individuals * * @returns {Error|null}
*/ function getError(snapshot, diffing, individuals) { if (diffing) { if (diffing.state === diffingState.ERROR) { return diffing.error;
} if (diffing.census === censusState.ERROR) { return diffing.census.error;
}
}
if (snapshot) { if (snapshot.state === states.ERROR) { return snapshot.error;
}
if (snapshot.census === censusState.ERROR) { return snapshot.census.error;
}
if (snapshot.treeMap === treeMapState.ERROR) { return snapshot.treeMap.error;
}
if (individuals && individuals.state === individualsState.ERROR) { return individuals.error;
}
returnnull;
}
/** * Main view for the memory tool. * * The Heap component contains several panels for different states; an initial * state of only a button to take a snapshot, loading states, the census view * tree, the dominator tree, etc.
*/ class Heap extends Component { static get propTypes() { return {
onSnapshotClick: PropTypes.func.isRequired,
onLoadMoreSiblings: PropTypes.func.isRequired,
onCensusExpand: PropTypes.func.isRequired,
onCensusCollapse: PropTypes.func.isRequired,
onDominatorTreeExpand: PropTypes.func.isRequired,
onDominatorTreeCollapse: PropTypes.func.isRequired,
onCensusFocus: PropTypes.func.isRequired,
onDominatorTreeFocus: PropTypes.func.isRequired,
onShortestPathsResize: PropTypes.func.isRequired,
snapshot: snapshotModel,
onViewSourceInDebugger: PropTypes.func.isRequired,
onPopView: PropTypes.func.isRequired,
individuals: models.individuals,
onViewIndividuals: PropTypes.func.isRequired,
onFocusIndividual: PropTypes.func.isRequired,
diffing: diffingModel,
view: models.view.isRequired,
sizes: PropTypes.object.isRequired,
};
}
_renderCensus(
state,
census,
diffing,
onViewSourceInDebugger,
onViewIndividuals
) { assert(
census.report, "Should not render census that does not have a report"
);
_renderIndividuals(
state,
individuals,
dominatorTree,
onViewSourceInDebugger
) { assert(
individuals.state === individualsState.FETCHED, "Should have fetched individuals"
); assert(dominatorTree?.root, "Should have a dominator tree and its root");
if (view.state === viewState.TREE_MAP) { returnthis._renderTreeMap(state, snapshot.treeMap);
}
if (view.state === viewState.INDIVIDUALS) { assert(
individuals.state === individualsState.FETCHED, "Should have fetched the individuals -- " + "other states are rendered as statuses"
); returnthis._renderIndividuals(
state,
individuals,
individuals.dominatorTree,
onViewSourceInDebugger
);
}
assert(
view.state === viewState.DOMINATOR_TREE, "If we aren't in progress, looking at a census, or diffing, then we " + "must be looking at a dominator tree"
); assert(!diffing, "Should not have diffing"); assert(snapshot.dominatorTree, "Should have a dominator tree");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.