Bug 1229202 (part 1) - Remove some unused arguments in nsPrintEngine's functions. r=mattwoodrow.

The first four arguments of GetPageRangeForSelection() are not used usefully,
nor are the first two arguments of FindSelectionBounds() and
FindSelectionBoundsWithList(). (Mutual recursion between the latter two
obscured this fact.)
This commit is contained in:
Nicholas Nethercote 2015-12-02 15:32:16 -08:00
parent 55dd415fae
commit 6c23754a06
2 changed files with 14 additions and 44 deletions

View File

@ -2431,12 +2431,6 @@ nsPrintEngine::DoPrint(nsPrintObject * aPO)
// which is needed to find the selection frames
// mPrintDC must have positive width and height for this call
// CreateRenderingContext can fail for large dimensions
RefPtr<gfxContext> gCtx = mPrt->mPrintDC->CreateRenderingContext();
NS_ENSURE_TRUE(gCtx, NS_ERROR_OUT_OF_MEMORY);
nsRenderingContext rc(gCtx);
// find the starting and ending page numbers
// via the selection
nsIFrame* startFrame;
@ -2446,10 +2440,7 @@ nsPrintEngine::DoPrint(nsPrintObject * aPO)
nsRect startRect;
nsRect endRect;
RefPtr<Selection> selectionPS =
poPresShell->GetCurrentSelection(nsISelectionController::SELECTION_NORMAL);
rv = GetPageRangeForSelection(poPresShell, poPresContext, rc, selectionPS, pageSequence,
rv = GetPageRangeForSelection(pageSequence,
&startFrame, startPageNum, startRect,
&endFrame, endPageNum, endRect);
if (NS_SUCCEEDED(rv)) {
@ -2737,10 +2728,8 @@ nsPrintEngine::PrintPage(nsPrintObject* aPO,
/** ---------------------------------------------------
* Find by checking frames type
*/
nsresult
nsPrintEngine::FindSelectionBoundsWithList(nsPresContext* aPresContext,
nsRenderingContext& aRC,
nsFrameList::Enumerator& aChildFrames,
nsresult
nsPrintEngine::FindSelectionBoundsWithList(nsFrameList::Enumerator& aChildFrames,
nsIFrame * aParentFrame,
nsRect& aRect,
nsIFrame *& aStartFrame,
@ -2748,7 +2737,6 @@ nsPrintEngine::FindSelectionBoundsWithList(nsPresContext* aPresContext,
nsIFrame *& aEndFrame,
nsRect& aEndRect)
{
NS_ASSERTION(aPresContext, "Pointer is null!");
NS_ASSERTION(aParentFrame, "Pointer is null!");
aRect += aParentFrame->GetPosition();
@ -2764,7 +2752,7 @@ nsPrintEngine::FindSelectionBoundsWithList(nsPresContext* aPresContext,
aEndRect.SetRect(aRect.x + r.x, aRect.y + r.y, r.width, r.height);
}
}
FindSelectionBounds(aPresContext, aRC, child, aRect, aStartFrame, aStartRect, aEndFrame, aEndRect);
FindSelectionBounds(child, aRect, aStartFrame, aStartRect, aEndFrame, aEndRect);
child = child->GetNextSibling();
}
aRect -= aParentFrame->GetPosition();
@ -2773,24 +2761,22 @@ nsPrintEngine::FindSelectionBoundsWithList(nsPresContext* aPresContext,
//-------------------------------------------------------
// Find the Frame that is XMost
nsresult
nsPrintEngine::FindSelectionBounds(nsPresContext* aPresContext,
nsRenderingContext& aRC,
nsIFrame * aParentFrame,
nsresult
nsPrintEngine::FindSelectionBounds(nsIFrame * aParentFrame,
nsRect& aRect,
nsIFrame *& aStartFrame,
nsRect& aStartRect,
nsIFrame *& aEndFrame,
nsRect& aEndRect)
{
NS_ASSERTION(aPresContext, "Pointer is null!");
NS_ASSERTION(aParentFrame, "Pointer is null!");
// loop through named child lists
nsIFrame::ChildListIterator lists(aParentFrame);
for (; !lists.IsDone(); lists.Next()) {
nsFrameList::Enumerator childFrames(lists.CurrentList());
nsresult rv = FindSelectionBoundsWithList(aPresContext, aRC, childFrames, aParentFrame, aRect, aStartFrame, aStartRect, aEndFrame, aEndRect);
nsresult rv = FindSelectionBoundsWithList(childFrames, aParentFrame, aRect,
aStartFrame, aStartRect, aEndFrame, aEndRect);
NS_ENSURE_SUCCESS(rv, rv);
}
return NS_OK;
@ -2802,12 +2788,8 @@ nsPrintEngine::FindSelectionBounds(nsPresContext* aPresContext,
* the x,y of the rect is relative to the very top of the
* frame tree (absolutely positioned)
*/
nsresult
nsPrintEngine::GetPageRangeForSelection(nsIPresShell * aPresShell,
nsPresContext* aPresContext,
nsRenderingContext& aRC,
nsISelection* aSelection,
nsIPageSequenceFrame* aPageSeqFrame,
nsresult
nsPrintEngine::GetPageRangeForSelection(nsIPageSequenceFrame* aPageSeqFrame,
nsIFrame** aStartFrame,
int32_t& aStartPageNum,
nsRect& aStartRect,
@ -2815,9 +2797,6 @@ nsPrintEngine::GetPageRangeForSelection(nsIPresShell * aPresShell,
int32_t& aEndPageNum,
nsRect& aEndRect)
{
NS_ASSERTION(aPresShell, "Pointer is null!");
NS_ASSERTION(aPresContext, "Pointer is null!");
NS_ASSERTION(aSelection, "Pointer is null!");
NS_ASSERTION(aPageSeqFrame, "Pointer is null!");
NS_ASSERTION(aStartFrame, "Pointer is null!");
NS_ASSERTION(aEndFrame, "Pointer is null!");
@ -2834,8 +2813,7 @@ nsPrintEngine::GetPageRangeForSelection(nsIPresShell * aPresShell,
// capturing the starting and ending child frames of the selection
// and their rects
nsRect r = seqFrame->GetRect();
FindSelectionBounds(aPresContext, aRC, seqFrame, r,
startFrame, aStartRect, endFrame, aEndRect);
FindSelectionBounds(seqFrame, r, startFrame, aStartRect, endFrame, aEndRect);
#ifdef DEBUG_rodsX
printf("Start Frame: %p\n", startFrame);

View File

@ -224,9 +224,7 @@ protected:
nsIFrame*& aSeqFrame,
int32_t& aCount);
static nsresult FindSelectionBoundsWithList(nsPresContext* aPresContext,
nsRenderingContext& aRC,
nsFrameList::Enumerator& aChildFrames,
static nsresult FindSelectionBoundsWithList(nsFrameList::Enumerator& aChildFrames,
nsIFrame * aParentFrame,
nsRect& aRect,
nsIFrame *& aStartFrame,
@ -234,20 +232,14 @@ protected:
nsIFrame *& aEndFrame,
nsRect& aEndRect);
static nsresult FindSelectionBounds(nsPresContext* aPresContext,
nsRenderingContext& aRC,
nsIFrame * aParentFrame,
static nsresult FindSelectionBounds(nsIFrame * aParentFrame,
nsRect& aRect,
nsIFrame *& aStartFrame,
nsRect& aStartRect,
nsIFrame *& aEndFrame,
nsRect& aEndRect);
static nsresult GetPageRangeForSelection(nsIPresShell * aPresShell,
nsPresContext* aPresContext,
nsRenderingContext& aRC,
nsISelection* aSelection,
nsIPageSequenceFrame* aPageSeqFrame,
static nsresult GetPageRangeForSelection(nsIPageSequenceFrame* aPageSeqFrame,
nsIFrame** aStartFrame,
int32_t& aStartPageNum,
nsRect& aStartRect,