Bug 1229202 (part 1) - Remove some unused arguments in nsPrintEngine's functions. r=mattwoodrow.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 02 Dec 2015 15:32:16 -0800
changeset 275364 b8f81e66d022c8a18e5d47ade0b56374652623e9
parent 275363 8ee27d317a6889be6e886f676835bda9d9c3e2e7
child 275365 5f78854c2c7233b9dc6692f2b652e9ae36c61b07
push id29752
push usercbook@mozilla.com
push dateThu, 03 Dec 2015 11:03:31 +0000
treeherdermozilla-central@85cf2e720a84 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1229202
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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.)
layout/printing/nsPrintEngine.cpp
layout/printing/nsPrintEngine.h
--- a/layout/printing/nsPrintEngine.cpp
+++ b/layout/printing/nsPrintEngine.cpp
@@ -2426,35 +2426,26 @@ nsPrintEngine::DoPrint(nsPrintObject * a
       if (nsIPrintSettings::kRangeSelection == printRangeType) {
         CloneSelection(aPO->mDocument->GetOriginalDocument(), aPO->mDocument);
 
         poPresContext->SetIsRenderingOnlySelection(true);
         // temporarily creating rendering context
         // 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;
         nsIFrame* endFrame;
         int32_t   startPageNum;
         int32_t   endPageNum;
         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)) {
           mPrt->mPrintSettings->SetStartPageRange(startPageNum);
           mPrt->mPrintSettings->SetEndPageRange(endPageNum);
           nsIntMargin marginTwips(0,0,0,0);
           nsIntMargin unwrtMarginTwips(0,0,0,0);
           mPrt->mPrintSettings->GetMarginInTwips(marginTwips);
@@ -2732,115 +2723,102 @@ nsPrintEngine::PrintPage(nsPrintObject* 
   mPageSeqFrame->DoPageEnd();
 
   return donePrinting;
 }
 
 /** ---------------------------------------------------
  *  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,
                                            nsRect&         aStartRect,
                                            nsIFrame *&     aEndFrame,
                                            nsRect&         aEndRect)
 {
-  NS_ASSERTION(aPresContext, "Pointer is null!");
   NS_ASSERTION(aParentFrame, "Pointer is null!");
 
   aRect += aParentFrame->GetPosition();
   for (; !aChildFrames.AtEnd(); aChildFrames.Next()) {
     nsIFrame* child = aChildFrames.get();
     if (child->IsSelected() && child->IsVisibleForPainting()) {
       nsRect r = child->GetRect();
       if (aStartFrame == nullptr) {
         aStartFrame = child;
         aStartRect.SetRect(aRect.x + r.x, aRect.y + r.y, r.width, r.height);
       } else {
         aEndFrame = child;
         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();
   return NS_OK;
 }
 
 //-------------------------------------------------------
 // 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;
 }
 
 /** ---------------------------------------------------
  *  This method finds the starting and ending page numbers
  *  of the selection and also returns rect for each where
  *  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,
                                         nsIFrame**            aEndFrame,
                                         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!");
 
   nsIFrame * seqFrame = do_QueryFrame(aPageSeqFrame);
   if (!seqFrame) {
     return NS_ERROR_FAILURE;
   }
 
   nsIFrame * startFrame = nullptr;
   nsIFrame * endFrame   = nullptr;
 
   // start out with the sequence frame and search the entire frame tree
   // 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);
   printf("End Frame:   %p\n", endFrame);
 #endif
 
   // initial the page numbers here
   // in case we don't find and frames
--- a/layout/printing/nsPrintEngine.h
+++ b/layout/printing/nsPrintEngine.h
@@ -219,40 +219,32 @@ protected:
                          nsIWebProgressListener* aWebProgressListener,
                          nsIDOMDocument* aDoc);
 
   void FirePrintCompletionEvent();
   static nsresult GetSeqFrameAndCountPagesInternal(nsPrintObject*  aPO,
                                                    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,
                                               nsRect&         aStartRect,
                                               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,
                                            nsIFrame**            aEndFrame,
                                            int32_t&              aEndPageNum,
                                            nsRect&               aEndRect);
 
   static void MapContentForPO(nsPrintObject* aPO, nsIContent* aContent);