Bug 389359: In print-preview jump-to-page, scale page-position so we arrive at correct spot. r+sr=roc, a=blocking1.9+
authordholbert@cs.stanford.edu
Tue, 29 Jan 2008 12:14:51 -0800
changeset 10937 ba951d7b40fcfc2ae45a52c086b1bdf9a8f2ef55
parent 10936 73cb11b9f9e6e8a62eed591e04604bfcd21ce1ef
child 10938 b324a844c7a0104db21d9dd102c6faf71565b857
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersblocking1.9
bugs389359
milestone1.9b3pre
Bug 389359: In print-preview jump-to-page, scale page-position so we arrive at correct spot. r+sr=roc, a=blocking1.9+
layout/base/nsDocumentViewer.cpp
layout/printing/nsPrintEngine.h
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -3654,18 +3654,25 @@ DocumentViewerImpl::PrintPreviewNavigate
   if (fndPageFrame && scrollableView) {
     nscoord deadSpaceGapTwips = 0;
     nsIPageSequenceFrame * sqf;
     if (NS_SUCCEEDED(CallQueryInterface(seqFrame, &sqf))) {
       sqf->GetDeadSpaceValue(&deadSpaceGapTwips);
     }
     nscoord deadSpaceGap = mPresContext->TwipsToAppUnits(deadSpaceGapTwips);
 
-    // scroll so that top of page (plus the gray area) is at the top of the scroll area
-    scrollableView->ScrollTo(0, fndPageFrame->GetPosition().y-deadSpaceGap, PR_TRUE);
+    // XXXdholbert: deadSpaceGap should be subtracted from
+    // fndPageFrame->GetPosition().y, before the scaling.  However,
+    // deadSpaceGap isn't matching up to the actual visible dead space in Print
+    // Preview right now -- see bug 414075.  Hence, ignoring deadSpaceGap for
+    // now -- instead, we'll navigate to exactly the top of the given page.
+    nscoord newYPosn = 
+      nscoord(mPrintEngine->GetPrintPreviewScale() * 
+              float(fndPageFrame->GetPosition().y));
+    scrollableView->ScrollTo(0, newYPosn, PR_TRUE);
   }
   return NS_OK;
 
 }
 
 /* readonly attribute nsIPrintSettings globalPrintSettings; */
 NS_IMETHODIMP
 DocumentViewerImpl::GetGlobalPrintSettings(nsIPrintSettings * *aGlobalPrintSettings)
--- a/layout/printing/nsPrintEngine.h
+++ b/layout/printing/nsPrintEngine.h
@@ -194,16 +194,19 @@ public:
 
   PRBool   CheckBeforeDestroy();
   nsresult Cancelled();
 
   nsIWidget* GetPrintPreviewWindow() {return mPrtPreview->mPrintObject->mWindow;}
 
   nsIViewManager* GetPrintPreviewViewManager() {return mPrtPreview->mPrintObject->mViewManager;}
 
+  float GetPrintPreviewScale() { return mPrtPreview->mPrintObject->
+                                        mPresContext->GetPrintPreviewScale(); }
+  
   static nsIPresShell* GetPresShellFor(nsIDocShell* aDocShell);
 
   // These calls also update the DocViewer
   void SetIsPrinting(PRBool aIsPrinting);
   PRBool GetIsPrinting()
   {
     return mIsDoingPrinting;
   }