Commit f4df1632 authored by Magnus Melin's avatar Magnus Melin
Browse files

Bug 1869195 - Fix crash in [@ mozilla::PresShell::GetRootScrollFrame]. r=emilio, a=dmeehan

parent 2557ef36
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -2480,17 +2480,26 @@ PresShell::CompleteMove(bool aForward, bool aExtend) {
// end implementations nsISelectionController

nsIFrame* PresShell::GetRootScrollFrame() const {
  if (!mFrameConstructor) {
    return nullptr;
  }
  nsIFrame* rootFrame = mFrameConstructor->GetRootFrame();
  // Ensure root frame is a viewport frame
  if (!rootFrame || !rootFrame->IsViewportFrame()) return nullptr;
  if (!rootFrame || !rootFrame->IsViewportFrame()) {
    return nullptr;
  }
  nsIFrame* theFrame = rootFrame->PrincipalChildList().FirstChild();
  if (!theFrame || !theFrame->IsScrollFrame()) return nullptr;
  if (!theFrame || !theFrame->IsScrollFrame()) {
    return nullptr;
  }
  return theFrame;
}

nsIScrollableFrame* PresShell::GetRootScrollFrameAsScrollable() const {
  nsIFrame* frame = GetRootScrollFrame();
  if (!frame) return nullptr;
  if (!frame) {
    return nullptr;
  }
  nsIScrollableFrame* scrollableFrame = do_QueryFrame(frame);
  NS_ASSERTION(scrollableFrame,
               "All scroll frames must implement nsIScrollableFrame");