Bug 1735484 - avoid crashing in nsRefreshDriver::RemoveImageRequest when mPresContext is null, r=emilio.

Differential Revision: https://phabricator.services.mozilla.com/D129506
This commit is contained in:
Florian Quèze 2021-10-26 15:52:19 +00:00
parent 43016d43a8
commit b50386c085

View File

@ -1130,6 +1130,9 @@ RefreshDriverTimer* nsRefreshDriver::ChooseTimer() {
}
static nsDocShell* GetDocShell(nsPresContext* aPresContext) {
if (!aPresContext) {
return nullptr;
}
return static_cast<nsDocShell*>(aPresContext->GetDocShell());
}
@ -1236,12 +1239,10 @@ void nsRefreshDriver::AddRefreshObserver(nsARefreshObserver* aObserver,
FlushType aFlushType,
const char* aObserverDescription) {
ObserverArray& array = ArrayFor(aFlushType);
array.AppendElement(ObserverData{
aObserver, aObserverDescription, TimeStamp::Now(),
mPresContext
? MarkerInnerWindowIdFromDocShell(mPresContext->GetDocShell())
: MarkerInnerWindowId::NoId(),
profiler_capture_backtrace(), aFlushType});
array.AppendElement(
ObserverData{aObserver, aObserverDescription, TimeStamp::Now(),
MarkerInnerWindowIdFromDocShell(GetDocShell(mPresContext)),
profiler_capture_backtrace(), aFlushType});
EnsureTimerStarted();
}