Bug 1897135 Part 3 - Change two APIs to ensure root frame is a ViewportFrame. r=dholbert
Move `SetRootFrame()` to nsFrameManager.cpp, because in order to compile `mRootFrame = aRootFrame` the compiler requires the full definition of `ViewportFrame` to know that `ViewportFrame` is a subclass of `nsIFrame` Differential Revision: https://phabricator.services.mozilla.com/D210671
This commit is contained in:
@@ -115,6 +115,7 @@
|
|||||||
#include "mozilla/Try.h"
|
#include "mozilla/Try.h"
|
||||||
#include "mozilla/UniquePtr.h"
|
#include "mozilla/UniquePtr.h"
|
||||||
#include "mozilla/Unused.h"
|
#include "mozilla/Unused.h"
|
||||||
|
#include "mozilla/ViewportFrame.h"
|
||||||
#include "mozilla/ViewportUtils.h"
|
#include "mozilla/ViewportUtils.h"
|
||||||
#include "nsAnimationManager.h"
|
#include "nsAnimationManager.h"
|
||||||
#include "nsAutoLayoutPhase.h"
|
#include "nsAutoLayoutPhase.h"
|
||||||
@@ -1766,10 +1767,10 @@ nsresult PresShell::Initialize() {
|
|||||||
// XXXbz it would be nice to move this somewhere else... like frame manager
|
// XXXbz it would be nice to move this somewhere else... like frame manager
|
||||||
// Init(), say. But we need to make sure our views are all set up by the
|
// Init(), say. But we need to make sure our views are all set up by the
|
||||||
// time we do this!
|
// time we do this!
|
||||||
nsIFrame* rootFrame = mFrameConstructor->GetRootFrame();
|
MOZ_ASSERT(!mFrameConstructor->GetRootFrame(),
|
||||||
NS_ASSERTION(!rootFrame, "How did that happen, exactly?");
|
"How did that happen, exactly?");
|
||||||
|
ViewportFrame* rootFrame;
|
||||||
if (!rootFrame) {
|
{
|
||||||
nsAutoScriptBlocker scriptBlocker;
|
nsAutoScriptBlocker scriptBlocker;
|
||||||
rootFrame = mFrameConstructor->ConstructRootFrame();
|
rootFrame = mFrameConstructor->ConstructRootFrame();
|
||||||
mFrameConstructor->SetRootFrame(rootFrame);
|
mFrameConstructor->SetRootFrame(rootFrame);
|
||||||
@@ -2458,8 +2459,7 @@ nsIFrame* PresShell::GetRootScrollFrame() const {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
nsIFrame* rootFrame = mFrameConstructor->GetRootFrame();
|
nsIFrame* rootFrame = mFrameConstructor->GetRootFrame();
|
||||||
// Ensure root frame is a viewport frame
|
if (!rootFrame) {
|
||||||
if (!rootFrame || !rootFrame->IsViewportFrame()) {
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
nsIFrame* theFrame = rootFrame->PrincipalChildList().FirstChild();
|
nsIFrame* theFrame = rootFrame->PrincipalChildList().FirstChild();
|
||||||
|
|||||||
@@ -2635,7 +2635,7 @@ RestyleManager* nsCSSFrameConstructor::RestyleManager() const {
|
|||||||
return mPresShell->GetPresContext()->RestyleManager();
|
return mPresShell->GetPresContext()->RestyleManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIFrame* nsCSSFrameConstructor::ConstructRootFrame() {
|
ViewportFrame* nsCSSFrameConstructor::ConstructRootFrame() {
|
||||||
AUTO_PROFILER_LABEL_HOT("nsCSSFrameConstructor::ConstructRootFrame",
|
AUTO_PROFILER_LABEL_HOT("nsCSSFrameConstructor::ConstructRootFrame",
|
||||||
LAYOUT_FrameConstruction);
|
LAYOUT_FrameConstruction);
|
||||||
AUTO_LAYOUT_PHASE_ENTRY_POINT(mPresShell->GetPresContext(), FrameC);
|
AUTO_LAYOUT_PHASE_ENTRY_POINT(mPresShell->GetPresContext(), FrameC);
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ class ComputedStyle;
|
|||||||
class PresShell;
|
class PresShell;
|
||||||
class PrintedSheetFrame;
|
class PrintedSheetFrame;
|
||||||
class RestyleManager;
|
class RestyleManager;
|
||||||
|
class ViewportFrame;
|
||||||
|
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
|
||||||
@@ -96,7 +97,7 @@ class nsCSSFrameConstructor final : public nsFrameManager {
|
|||||||
|
|
||||||
mozilla::RestyleManager* RestyleManager() const;
|
mozilla::RestyleManager* RestyleManager() const;
|
||||||
|
|
||||||
nsIFrame* ConstructRootFrame();
|
mozilla::ViewportFrame* ConstructRootFrame();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum Operation { CONTENTAPPEND, CONTENTINSERT };
|
enum Operation { CONTENTAPPEND, CONTENTINSERT };
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "mozilla/MemoryReporting.h"
|
#include "mozilla/MemoryReporting.h"
|
||||||
#include "mozilla/PresShell.h"
|
#include "mozilla/PresShell.h"
|
||||||
#include "mozilla/PresState.h"
|
#include "mozilla/PresState.h"
|
||||||
|
#include "mozilla/ViewportFrame.h"
|
||||||
#include "nsAbsoluteContainingBlock.h"
|
#include "nsAbsoluteContainingBlock.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsContainerFrame.h"
|
#include "nsContainerFrame.h"
|
||||||
@@ -37,6 +38,12 @@ nsFrameManager::~nsFrameManager() {
|
|||||||
NS_ASSERTION(!mPresShell, "nsFrameManager::Destroy never called");
|
NS_ASSERTION(!mPresShell, "nsFrameManager::Destroy never called");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void nsFrameManager::SetRootFrame(ViewportFrame* aRootFrame) {
|
||||||
|
MOZ_ASSERT(aRootFrame, "The root frame should be valid!");
|
||||||
|
MOZ_ASSERT(!mRootFrame, "We should set a root frame only once!");
|
||||||
|
mRootFrame = aRootFrame;
|
||||||
|
}
|
||||||
|
|
||||||
void nsFrameManager::Destroy() {
|
void nsFrameManager::Destroy() {
|
||||||
NS_ASSERTION(mPresShell, "Frame manager already shut down.");
|
NS_ASSERTION(mPresShell, "Frame manager already shut down.");
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ class nsWindowSizes;
|
|||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
struct FrameDestroyContext;
|
struct FrameDestroyContext;
|
||||||
class PresShell;
|
class PresShell;
|
||||||
|
class ViewportFrame;
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,21 +36,18 @@ class nsFrameManager {
|
|||||||
using DestroyContext = mozilla::FrameDestroyContext;
|
using DestroyContext = mozilla::FrameDestroyContext;
|
||||||
|
|
||||||
explicit nsFrameManager(mozilla::PresShell* aPresShell)
|
explicit nsFrameManager(mozilla::PresShell* aPresShell)
|
||||||
: mPresShell(aPresShell), mRootFrame(nullptr) {
|
: mPresShell(aPresShell) {
|
||||||
MOZ_ASSERT(mPresShell, "need a pres shell");
|
MOZ_ASSERT(mPresShell, "need a pres shell");
|
||||||
}
|
}
|
||||||
~nsFrameManager();
|
~nsFrameManager();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Gets and sets the root frame (typically the viewport). The lifetime of the
|
* Gets and sets the root frame (i.e. ViewportFrame). The lifetime of the
|
||||||
* root frame is controlled by the frame manager. When the frame manager is
|
* root frame is controlled by the frame manager. When the frame manager is
|
||||||
* destroyed, it destroys the entire frame hierarchy.
|
* destroyed, it destroys the entire frame hierarchy.
|
||||||
*/
|
*/
|
||||||
nsIFrame* GetRootFrame() const { return mRootFrame; }
|
nsIFrame* GetRootFrame() const { return mRootFrame; }
|
||||||
void SetRootFrame(nsIFrame* aRootFrame) {
|
void SetRootFrame(mozilla::ViewportFrame* aRootFrame);
|
||||||
NS_ASSERTION(!mRootFrame, "already have a root frame");
|
|
||||||
mRootFrame = aRootFrame;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* After Destroy is called, it is an error to call any FrameManager methods.
|
* After Destroy is called, it is an error to call any FrameManager methods.
|
||||||
@@ -94,7 +92,11 @@ class nsFrameManager {
|
|||||||
protected:
|
protected:
|
||||||
// weak link, because the pres shell owns us
|
// weak link, because the pres shell owns us
|
||||||
mozilla::PresShell* MOZ_NON_OWNING_REF mPresShell;
|
mozilla::PresShell* MOZ_NON_OWNING_REF mPresShell;
|
||||||
nsIFrame* mRootFrame;
|
|
||||||
|
// Note: We use nsIFrame* instead of ViewportFrame* for mRootFrame to avoid
|
||||||
|
// exposing ViewportFrame to the callers via GetRootFrame(), since they do not
|
||||||
|
// depend on any ViewportFrame-specific APIs or details.
|
||||||
|
nsIFrame* mRootFrame = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* rendering object that is the root of the frame tree, which contains
|
* rendering object that is the root of the frame tree, which contains
|
||||||
* the document's scrollbars and contains fixed-positioned elements
|
* contains fixed-positioned elements
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef mozilla_ViewportFrame_h
|
#ifndef mozilla_ViewportFrame_h
|
||||||
@@ -23,9 +23,10 @@ class nsDisplayWrapList;
|
|||||||
class ServoRestyleState;
|
class ServoRestyleState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ViewportFrame is the parent of a single child - the doc root frame or a
|
* ViewportFrame is the parent of a single child -- the root canvas frame or a
|
||||||
* scroll frame containing the doc root frame. ViewportFrame stores this child
|
* scroll container frame containing the root canvas frame. See
|
||||||
* in its primary child list.
|
* nsCSSFrameConstructor::SetUpDocElementContainingBlock() for the root frame
|
||||||
|
* hierarchy. ViewportFrame stores this child in its primary child list.
|
||||||
*/
|
*/
|
||||||
class ViewportFrame : public nsContainerFrame {
|
class ViewportFrame : public nsContainerFrame {
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user