Bug 1499828 Part 1 - Add API for getting the current recording position, r=mccr8.

--HG--
extra : rebase_source : c04a4504f9e46e4a727c724834f97c1d7dce2417
This commit is contained in:
Brian Hackett 2018-10-17 13:30:52 -06:00
Родитель 0ec9f5972e
Коммит 93fe98e776
3 изменённых файлов: 33 добавлений и 0 удалений

Просмотреть файл

@ -432,6 +432,21 @@ Middleman_HadRepaintFailure(JSContext* aCx, unsigned aArgc, Value* aVp)
return true;
}
static bool
Middleman_RecordingPosition(JSContext* aCx, unsigned aArgc, Value* aVp)
{
CallArgs args = CallArgsFromVp(aArgc, aVp);
Maybe<double> recordingPosition = parent::GetRecordingPosition();
if (recordingPosition.isSome()) {
args.rval().setNumber(recordingPosition.ref());
} else {
args.rval().setUndefined();
}
return true;
}
///////////////////////////////////////////////////////////////////////////////
// Devtools Sandbox
///////////////////////////////////////////////////////////////////////////////
@ -912,6 +927,7 @@ static const JSFunctionSpec gMiddlemanMethods[] = {
JS_FN("maybeSwitchToReplayingChild", Middleman_MaybeSwitchToReplayingChild, 0, 0),
JS_FN("hadRepaint", Middleman_HadRepaint, 2, 0),
JS_FN("hadRepaintFailure", Middleman_HadRepaintFailure, 0, 0),
JS_FN("recordingPosition", Middleman_RecordingPosition, 0, 0),
JS_FS_END
};

Просмотреть файл

@ -857,6 +857,19 @@ MaybeSwitchToReplayingChild()
}
}
Maybe<double>
GetRecordingPosition()
{
if (gActiveChild->IsRecording()) {
return Nothing();
}
// Get the fraction of the recording that the active child has reached so far.
double fraction = (gActiveChild->MostRecentCheckpoint() - CheckpointId::First)
/ (double) (gCheckpointTimes.length() - CheckpointId::First);
return Some(fraction);
}
///////////////////////////////////////////////////////////////////////////////
// Initialization
///////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -76,6 +76,10 @@ void SetBreakpoint(size_t aId, const js::BreakpointPosition& aPosition);
// children cannot process such requests).
void MaybeSwitchToReplayingChild();
// If the active child is replaying, get its fractional (range [0,1]) position
// in the recording. If the active child is recording, return Nothing.
Maybe<double> GetRecordingPosition();
///////////////////////////////////////////////////////////////////////////////
// Graphics
///////////////////////////////////////////////////////////////////////////////