index = index - 1;
// Not all records will be UiEvents. But we want access to fields like
// duration and the type maps. These will return appropriate 0 and null
// values for non-UiEvent EventRecords.
UiEvent record = eventList.get(index).cast();
final List<HintRecord> hints = new ArrayList<HintRecord>();
final JsIntegerDoubleMap aggregateTypeDurations = JsIntegerDoubleMap.create();
// We want to add a wedge in the pie chart for the time the browser's UI
// thread was available.
collector.setTotalAvailableTime(rightBound - leftBound);
// We are starting at the right edge of the window, which may chop an event.
if (UiEvent.isUiEvent(record)) {
record = splitEventTreeOnBoundary(record, rightBound, true);
// Guard against having the record split an event outside the window.
if (record == null) {
return new ReportData(null, null);
}
}
// We will walk backward to find the left window boundary. Because we can
// have ResourceUpdate records that have nonsensical time stamps, we place
// the terminating condition within the loop.
while (index >= 0) {
double endTime = record.getTime() + record.getDuration();
// Our real terminating condition is if the record passes the left edge.
if (endTime < leftBound) {
break;
}
// Chop records that fall within the window, but start to the left of
// the leftBound.
if (UiEvent.isUiEvent(record) && record.getTime() < leftBound
&& endTime >= leftBound) {
record = splitEventTreeOnBoundary(record, leftBound, false);
assert (record != null) : "Splitting a node should yield a valid non-null clone here!";
}