Bug 1297664 - Null check docShell before use. r=mstange
MozReview-Commit-ID: 1jA5K8is11X
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -1004,33 +1004,39 @@ nsDisplayListBuilder::EnterPresShell(nsI
RefPtr<nsCaret> caret = state->mPresShell->GetCaret();
state->mCaretFrame = caret->GetPaintGeometry(&state->mCaretRect);
if (state->mCaretFrame) {
mFramesMarkedForDisplay.AppendElement(state->mCaretFrame);
MarkFrameForDisplay(state->mCaretFrame, nullptr);
}
nsPresContext* pc = aReferenceFrame->PresContext();
- pc->GetDocShell()->GetWindowDraggingAllowed(&mWindowDraggingAllowed);
+ nsCOMPtr<nsIDocShell> docShell = pc->GetDocShell();
+ if (docShell) {
+ docShell->GetWindowDraggingAllowed(&mWindowDraggingAllowed);
+ }
mIsInChromePresContext = pc->IsChrome();
}
void
nsDisplayListBuilder::LeavePresShell(nsIFrame* aReferenceFrame)
{
NS_ASSERTION(CurrentPresShellState()->mPresShell ==
aReferenceFrame->PresContext()->PresShell(),
"Presshell mismatch");
ResetMarkedFramesForDisplayList();
mPresShellStates.SetLength(mPresShellStates.Length() - 1);
if (!mPresShellStates.IsEmpty()) {
nsPresContext* pc = CurrentPresContext();
- pc->GetDocShell()->GetWindowDraggingAllowed(&mWindowDraggingAllowed);
+ nsCOMPtr<nsIDocShell> docShell = pc->GetDocShell();
+ if (docShell) {
+ docShell->GetWindowDraggingAllowed(&mWindowDraggingAllowed);
+ }
mIsInChromePresContext = pc->IsChrome();
}
}
void
nsDisplayListBuilder::ResetMarkedFramesForDisplayList()
{
// Unmark and pop off the frames marked for display in this pres shell.