Bug 1024082: Remove most of the nsIPresShell::FrameManager calls. r=dholbert

Most of them just want GetRootFrame(), and there's no need to explicitly go
through the frame manager for that, we have a handy alias in the shell.

MozReview-Commit-ID: GriEqkasidY
This commit is contained in:
Emilio Cobos Álvarez 2018-03-06 10:25:21 +01:00
parent 72f6feaa97
commit 043503a6d4
18 changed files with 38 additions and 39 deletions

View File

@ -223,7 +223,7 @@ public:
mContent = nullptr;
nsPoint pt = mPoint -
frame->GetOffsetTo(mPresContext->PresShell()->FrameManager()->GetRootFrame());
frame->GetOffsetTo(mPresContext->PresShell()->GetRootFrame());
RefPtr<nsFrameSelection> frameSelection = mFrameSelection;
frameSelection->HandleDrag(frame, pt);
if (!frame.IsAlive()) {
@ -1794,7 +1794,7 @@ Selection::SelectFrames(nsPresContext* aPresContext, nsRange* aRange,
if (mFrameSelection->GetTableCellSelection()) {
nsINode* node = aRange->GetCommonAncestor();
nsIFrame* frame = node->IsContent() ? node->AsContent()->GetPrimaryFrame()
: aPresContext->FrameManager()->GetRootFrame();
: aPresContext->PresShell()->GetRootFrame();
if (frame) {
frame->InvalidateFrameSubtree();
}
@ -2181,7 +2181,7 @@ Selection::DoAutoScroll(nsIFrame* aFrame, nsPoint aPoint)
nsRootPresContext* rootPC = presContext->GetRootPresContext();
if (!rootPC)
return NS_OK;
nsIFrame* rootmostFrame = rootPC->PresShell()->FrameManager()->GetRootFrame();
nsIFrame* rootmostFrame = rootPC->PresShell()->GetRootFrame();
AutoWeakFrame weakRootFrame(rootmostFrame);
AutoWeakFrame weakFrame(aFrame);
// Get the point relative to the root most frame because the scroll we are
@ -2227,7 +2227,7 @@ Selection::DoAutoScroll(nsIFrame* aFrame, nsPoint aPoint)
// Start the AutoScroll timer if necessary.
if (didScroll && mAutoScrollTimer) {
nsPoint presContextPoint = globalPoint -
shell->FrameManager()->GetRootFrame()->GetOffsetToCrossDoc(rootmostFrame);
shell->GetRootFrame()->GetOffsetToCrossDoc(rootmostFrame);
mAutoScrollTimer->Start(presContext, presContextPoint);
}

View File

@ -488,7 +488,7 @@ nsDOMWindowUtils::SetDisplayPortForElement(float aXPx, float aYPx,
nsLayoutUtils::InvalidateForDisplayPortChange(content, !!currentData,
currentData ? currentData->mRect : nsRect(), displayport);
nsIFrame* rootFrame = presShell->FrameManager()->GetRootFrame();
nsIFrame* rootFrame = presShell->GetRootFrame();
if (rootFrame) {
rootFrame->SchedulePaint();
@ -3497,7 +3497,7 @@ nsDOMWindowUtils::SelectAtPoint(float aX, float aY, uint32_t aSelectBehavior,
}
// The root frame for this content window
nsIFrame* rootFrame = presShell->FrameManager()->GetRootFrame();
nsIFrame* rootFrame = presShell->GetRootFrame();
if (!rootFrame) {
return NS_ERROR_UNEXPECTED;
}

View File

@ -2644,7 +2644,7 @@ EventStateManager::ComputeScrollTarget(nsIFrame* aTargetFrame,
}
nsIFrame* newFrame = nsLayoutUtils::GetCrossDocParentFrame(
aTargetFrame->PresContext()->FrameManager()->GetRootFrame());
aTargetFrame->PresShell()->GetRootFrame());
aOptions =
static_cast<ComputeScrollTargetOptions>(aOptions & ~START_FROM_PARENT);
return newFrame ? ComputeScrollTarget(newFrame, aEvent, aOptions) : nullptr;

View File

@ -2623,7 +2623,7 @@ TabChild::RecvRenderLayers(const bool& aEnabled, const uint64_t& aLayerObserverE
if (nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell()) {
presShell->SetIsActive(true);
if (nsIFrame* root = presShell->FrameConstructor()->GetRootFrame()) {
if (nsIFrame* root = presShell->GetRootFrame()) {
FrameLayerBuilder::InvalidateAllLayersForFrame(
nsLayoutUtils::GetDisplayRootFrame(root));
root->SchedulePaint();
@ -2937,7 +2937,7 @@ TabChild::MakeHidden()
if (nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell()) {
if (nsPresContext* presContext = presShell->GetPresContext()) {
nsRootPresContext* rootPresContext = presContext->GetRootPresContext();
nsIFrame* rootFrame = presShell->FrameConstructor()->GetRootFrame();
nsIFrame* rootFrame = presShell->GetRootFrame();
rootPresContext->ComputePluginGeometryUpdates(rootFrame, nullptr, nullptr);
rootPresContext->ApplyPluginGeometryUpdates();
}

View File

@ -2105,7 +2105,7 @@ TabParent::GetChildProcessOffset()
}
nsPresContext* presContext = targetFrame->PresContext();
nsIFrame* rootFrame = presContext->PresShell()->FrameManager()->GetRootFrame();
nsIFrame* rootFrame = presContext->PresShell()->GetRootFrame();
nsView* rootView = rootFrame ? rootFrame->GetView() : nullptr;
if (!rootView) {
return offset;

View File

@ -10290,7 +10290,7 @@ void ReflowCountMgr::DoIndiTotalsTree()
printf("------------------------------------------------\n");
if (mPresShell) {
nsIFrame * rootFrame = mPresShell->FrameManager()->GetRootFrame();
nsIFrame* rootFrame = mPresShell->GetRootFrame();
RecurseIndiTotals(mPresContext, mIndiFrameCounts, rootFrame, 0);
printf("------------------------------------------------\n");
printf("-- Individual Counts of Frames not in Root Tree\n");

View File

@ -6589,7 +6589,7 @@ nsLayoutUtils::GetClosestLayer(nsIFrame* aFrame)
}
if (layer)
return layer;
return aFrame->PresShell()->FrameManager()->GetRootFrame();
return aFrame->PresShell()->GetRootFrame();
}
SamplingFilter
@ -7494,7 +7494,7 @@ nsLayoutUtils::GetDisplayRootFrame(nsIFrame* aFrame)
nsIFrame* f = aFrame;
for (;;) {
if (!f->HasAnyStateBits(NS_FRAME_IN_POPUP)) {
f = f->PresContext()->FrameManager()->GetRootFrame();
f = f->PresShell()->GetRootFrame();
if (!f) {
return aFrame;
}

View File

@ -730,8 +730,7 @@ nsPresContext::InvalidatePaintedLayers()
{
if (!mShell)
return;
nsIFrame* rootFrame = mShell->FrameManager()->GetRootFrame();
if (rootFrame) {
if (nsIFrame* rootFrame = mShell->GetRootFrame()) {
// FrameLayerBuilder caches invalidation-related values that depend on the
// appunits-per-dev-pixel ratio, so ensure that all PaintedLayer drawing
// is completely flushed.
@ -3193,7 +3192,7 @@ nsRootPresContext::ComputePluginGeometryUpdates(nsIFrame* aFrame,
if (aBuilder) {
MOZ_ASSERT(aList);
nsIFrame* rootFrame = FrameManager()->GetRootFrame();
nsIFrame* rootFrame = mShell->GetRootFrame();
if (rootFrame && aBuilder->ContainsPluginItem()) {
aBuilder->SetForPluginGeometry(true);

View File

@ -172,7 +172,7 @@ nsCanvasFrame::ScrollPositionWillChange(nscoord aX, nscoord aY)
{
if (mDoPaintFocus) {
mDoPaintFocus = false;
PresContext()->FrameManager()->GetRootFrame()->InvalidateFrameSubtree();
PresShell()->GetRootFrame()->InvalidateFrameSubtree();
}
}
@ -181,7 +181,7 @@ nsCanvasFrame::SetHasFocus(bool aHasFocus)
{
if (mDoPaintFocus != aHasFocus) {
mDoPaintFocus = aHasFocus;
PresContext()->FrameManager()->GetRootFrame()->InvalidateFrameSubtree();
PresShell()->GetRootFrame()->InvalidateFrameSubtree();
if (!mAddedScrollPositionListener) {
nsIScrollableFrame* sf =

View File

@ -1004,7 +1004,7 @@ nsIFrame::RemoveDisplayItemDataForDeletion()
}
if (IsFrameModified()) {
nsIFrame* rootFrame = PresContext()->PresShell()->GetRootFrame();
nsIFrame* rootFrame = PresShell()->GetRootFrame();
MOZ_ASSERT(rootFrame);
nsTArray<nsIFrame*>* modifiedFrames =
@ -1020,7 +1020,7 @@ nsIFrame::RemoveDisplayItemDataForDeletion()
}
if (HasOverrideDirtyRegion()) {
nsIFrame* rootFrame = PresContext()->PresShell()->GetRootFrame();
nsIFrame* rootFrame = PresShell()->GetRootFrame();
MOZ_ASSERT(rootFrame);
nsTArray<nsIFrame*>* frames =
@ -1061,7 +1061,7 @@ nsIFrame::MarkNeedsDisplayItemRebuild()
return;
}
nsIFrame* rootFrame = PresContext()->PresShell()->GetRootFrame();
nsIFrame* rootFrame = PresShell()->GetRootFrame();
MOZ_ASSERT(rootFrame);
if (rootFrame->IsFrameModified()) {
@ -6795,7 +6795,7 @@ nsRect nsIFrame::GetScreenRectInAppUnits() const
{
nsPresContext* presContext = PresContext();
nsIFrame* rootFrame =
presContext->PresShell()->FrameManager()->GetRootFrame();
presContext->PresShell()->GetRootFrame();
nsPoint rootScreenPos(0, 0);
nsPoint rootFrameOffsetInParent(0, 0);
nsIFrame* rootFrameParent =
@ -7878,7 +7878,7 @@ nsIFrame::RootFrameList(nsPresContext* aPresContext, FILE* out, const char* aPre
nsIPresShell *shell = aPresContext->GetPresShell();
if (shell) {
nsIFrame* frame = shell->FrameManager()->GetRootFrame();
nsIFrame* frame = shell->GetRootFrame();
if(frame) {
frame->List(out, aPrefix);
}

View File

@ -508,7 +508,7 @@ nsFrameSelection::ConstrainFrameAndPointToAnchorSubtree(nsIFrame* aFrame,
// Find the frame under the mouse cursor with the root frame.
// At this time, don't use the anchor's frame because it may not have
// fixed positioned frames.
nsIFrame* rootFrame = mShell->FrameManager()->GetRootFrame();
nsIFrame* rootFrame = mShell->GetRootFrame();
nsPoint ptInRoot = aPoint + aFrame->GetOffsetTo(rootFrame);
nsIFrame* cursorFrame =
nsLayoutUtils::GetFrameForPoint(rootFrame, ptInRoot);

View File

@ -280,7 +280,7 @@ nsPluginFrame::PrepForDrawing(nsIWidget *aWidget)
if (mWidget) {
// Disallow windowed plugins in popups
nsIFrame* rootFrame = rpc->PresShell()->FrameManager()->GetRootFrame();
nsIFrame* rootFrame = rpc->PresShell()->GetRootFrame();
nsIWidget* parentWidget = rootFrame->GetNearestWidget();
if (!parentWidget || nsLayoutUtils::GetDisplayRootFrame(this) != rootFrame) {
return NS_ERROR_FAILURE;
@ -632,7 +632,7 @@ nsPluginFrame::CallSetWindow(bool aCheckIsHidden)
if (!rootPC)
return NS_ERROR_FAILURE;
int32_t appUnitsPerDevPixel = presContext->AppUnitsPerDevPixel();
nsIFrame* rootFrame = rootPC->PresShell()->FrameManager()->GetRootFrame();
nsIFrame* rootFrame = rootPC->PresShell()->GetRootFrame();
nsRect bounds = GetContentRectRelativeToSelf() + GetOffsetToCrossDoc(rootFrame);
nsIntRect intBounds = bounds.ToNearestPixels(appUnitsPerDevPixel);

View File

@ -3009,7 +3009,7 @@ nsCSSRendering::ComputeImageLayerPositioningArea(nsPresContext* aPresContext,
// If it's a fixed background attachment, then the image is placed
// relative to the viewport, which is the area of the root frame
// in a screen context or the page content frame in a print context.
attachedToFrame = aPresContext->PresShell()->FrameManager()->GetRootFrame();
attachedToFrame = aPresContext->PresShell()->GetRootFrame();
NS_ASSERTION(attachedToFrame, "no root frame");
nsIFrame* pageContentFrame = nullptr;
if (aPresContext->IsPaginated()) {

View File

@ -2429,7 +2429,7 @@ nsPrintJob::ReflowPrintObject(const UniquePtr<nsPrintObject>& aPO)
FILE * fd = fopen(filename, "w");
if (fd) {
nsIFrame *theRootFrame =
aPO->mPresShell->FrameManager()->GetRootFrame();
aPO->mPresShell->GetRootFrame();
fprintf(fd, "Title: %s\n", docStr.get());
fprintf(fd, "URL: %s\n", urlStr.get());
fprintf(fd, "--------------- Frames ----------------\n");
@ -2665,7 +2665,7 @@ nsPrintJob::DoPrint(const UniquePtr<nsPrintObject>& aPO)
printData->mPreparingForPrint = false;
#ifdef EXTENDED_DEBUG_PRINTING
nsIFrame* rootFrame = poPresShell->FrameManager()->GetRootFrame();
nsIFrame* rootFrame = poPresShell->GetRootFrame();
if (aPO->IsPrintable()) {
nsAutoCString docStr;
nsAutoCString urlStr;
@ -3659,7 +3659,7 @@ static void RootFrameList(nsPresContext* aPresContext, FILE* out,
nsIPresShell *shell = aPresContext->GetPresShell();
if (shell) {
nsIFrame* frame = shell->FrameManager()->GetRootFrame();
nsIFrame* frame = shell->GetRootFrame();
if (frame) {
frame->List(out, aPrefix);
}
@ -3815,7 +3815,7 @@ static void DumpPrintObjectsList(const nsTArray<nsPrintObject*>& aDocList)
NS_ASSERTION(po, "nsPrintObject can't be null!");
nsIFrame* rootFrame = nullptr;
if (po->mPresShell) {
rootFrame = po->mPresShell->FrameManager()->GetRootFrame();
rootFrame = po->mPresShell->GetRootFrame();
while (rootFrame != nullptr) {
nsIPageSequenceFrame * sqf = do_QueryFrame(rootFrame);
if (sqf) {
@ -3891,7 +3891,7 @@ static void DumpPrintObjectsTreeLayout(const UniquePtr<nsPrintObject>& aPO,
if (fd) {
nsIFrame* rootFrame = nullptr;
if (aPO->mPresShell) {
rootFrame = aPO->mPresShell->FrameManager()->GetRootFrame();
rootFrame = aPO->mPresShell->GetRootFrame();
}
for (int32_t k=0;k<aLevel;k++) fprintf(fd, " ");
fprintf(fd, "%s %p %p\n", types[aPO->mFrameType], aPO.get(),

View File

@ -1383,7 +1383,7 @@ nsRect
nsMenuPopupFrame::ComputeAnchorRect(nsPresContext* aRootPresContext, nsIFrame* aAnchorFrame)
{
// Get the root frame for a reference
nsIFrame* rootFrame = aRootPresContext->FrameManager()->GetRootFrame();
nsIFrame* rootFrame = aRootPresContext->PresShell()->GetRootFrame();
// The dimensions of the anchor
nsRect anchorRect = aAnchorFrame->GetRectRelativeToSelf();
@ -1413,7 +1413,7 @@ nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame, bool aIsMove, bool aS
}
nsPresContext* presContext = PresContext();
nsIFrame* rootFrame = presContext->PresShell()->FrameManager()->GetRootFrame();
nsIFrame* rootFrame = presContext->PresShell()->GetRootFrame();
NS_ASSERTION(rootFrame->GetView() && GetView() &&
rootFrame->GetView() == GetView()->GetParent(),
"rootFrame's view is not our view's parent???");

View File

@ -219,7 +219,7 @@ nsResizerFrame::HandleEvent(nsPresContext* aPresContext,
}
else if (menuPopupFrame) {
nsRect frameRect = menuPopupFrame->GetScreenRectInAppUnits();
nsIFrame* rootFrame = aPresContext->PresShell()->FrameManager()->GetRootFrame();
nsIFrame* rootFrame = aPresContext->PresShell()->GetRootFrame();
nsRect rootScreenRect = rootFrame->GetScreenRectInAppUnits();
nsPopupLevel popupLevel = menuPopupFrame->PopupLevel();

View File

@ -28,7 +28,7 @@ nsIRootBox::GetRootBox(nsIPresShell* aShell)
if (!aShell) {
return nullptr;
}
nsIFrame* rootFrame = aShell->FrameManager()->GetRootFrame();
nsIFrame* rootFrame = aShell->GetRootFrame();
if (!rootFrame) {
return nullptr;
}

View File

@ -660,7 +660,7 @@ nsXULPopupManager::InitTriggerEvent(nsIDOMEvent* aEvent, nsIContent* aPopup,
if (!rootDocPresContext)
return;
nsIFrame* rootDocumentRootFrame = rootDocPresContext->
PresShell()->FrameManager()->GetRootFrame();
PresShell()->GetRootFrame();
if ((event->mClass == eMouseEventClass ||
event->mClass == eMouseScrollEventClass ||
event->mClass == eWheelEventClass) &&
@ -672,7 +672,7 @@ nsXULPopupManager::InitTriggerEvent(nsIDOMEvent* aEvent, nsIContent* aPopup,
mouseEvent->GetClientY(&clientPt.y);
// XXX this doesn't handle IFRAMEs in transforms
nsPoint thisDocToRootDocOffset = presShell->FrameManager()->
nsPoint thisDocToRootDocOffset = presShell->
GetRootFrame()->GetOffsetToCrossDoc(rootDocumentRootFrame);
// convert to device pixels
mCachedMousePoint.x = presContext->AppUnitsToDevPixels(