Closed Bug 389358 Opened 17 years ago Closed 17 years ago

print headers do not display in print preview window

Categories

(Core :: Print Preview, defect, P3)

x86
All
defect

Tracking

()

RESOLVED FIXED

People

(Reporter: jtd, Assigned: dholbert)

References

()

Details

(Keywords: regression)

Attachments

(2 files, 1 obsolete file)

Steps:

1. Open URL
2. File > Print Preview (with default Page Setup settings, Portrait, Shrink to Fit)

Result: print footer shows but not the print header

If the page is printed, the header prints but with a large top offset.
Flags: blocking1.9?
Flags: blocking1.9? → blocking1.9+
not sure what would have caused this...
Keywords: regression
Priority: -- → P3
I see this on linux as well.

OS --> all, assigning to me.
Assignee: nobody → dholbert
OS: Windows XP → All
Testing Linux Trunk builds, this actually regressed way back in early 2006...

Regression window is between:

Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9a1) Gecko/20060329 Firefox/1.6a1
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9a1) Gecko/20060330 Firefox/1.6a1

Looks like a regression from Bug 331415: "Some printing code cleanup"
Blocks: 331415
Ok, it looks like the print-preview header values (page title and page URL) were originally getting set in this function:

  nsSimplePageSequenceFrame::StartPrint(nsPresContext*   aPresContext,
                                        nsIPrintSettings* aPrintSettings,
                                        PRUnichar*        aDocTitle,
                                        PRUnichar*        aDocURL)
which was called via this callstack:

 #0  nsSimplePageSequenceFrame::StartPrint at nsSimplePageSequence.cpp:584
 #1  nsPrintEngine::DoPrint at nsPrintEngine.cpp:3295
 #2  nsPrintEngine::ShowDocListInternal at nsPrintEngine.cpp:4228
 #3  nsPrintEngine::ShowDocList at nsPrintEngine.cpp:4253
 #4  DocumentViewerImpl::InstallNewPresentation at nsDocumentViewer.cpp:4188
 #5  nsPrintEngine::FinishPrintPreview at nsPrintEngine.cpp:4337

However, the patch for bug 331415 (attachment 216680 [details] [diff] [review]) removed the ShowDocList and ShowDocListInternal functions, so after that patch, we only get down to level #4 in this callstack, and we never call nsSimplePageSequenceFrame::StartPrint.
Attached patch WIP #1 (obsolete) — Splinter Review
This restores the call to
   nsSimplePageSequenceFrame::StartPrint
which sets the fields
   mPageData->mDocTitle
   mPageData->mDocURL
on the nsSimplePageSequenceFrame object.

(Up to now, these fields weren't getting set during Print Preview, and this is why the header wasn't appearing)

I put the call inside of 
     nsPrintEngine::ReflowDocList
after we've reflowed the 

Concerns: 
 1) I'm not sure if this is the best place to put the call to StartPrint.
 2) I'm not sure we need all of the functionality in nsSimplePageSequenceFrame::StartPrint.  (I'm only calling that method because it's the only existing method which lets me set mPageData->mDocTitle and  mPageData->mDocURL)  Maybe I should just add a new method on nsSimplePageSequenceFrame & nsIPageSequenceFrame that just sets the doc title & URL, and does nothing else?
(In reply to comment #6)
> I put the call inside of 
>      nsPrintEngine::ReflowDocList
> after we've reflowed the 

I meant to say "after we've reflowed the print object."
Comment on attachment 299853 [details] [diff] [review]
WIP #1

roc -- could you let me know if the WIP makes sense & if you've got any ideas on the two concerns listed in Comment 6?
Attachment #299853 - Flags: review?(roc)
I think since we were calling StartPrint before, we can depend on stuff like selection printing and page ranges not being enabled, so we can assume that code doesn't actually do anything.

Putting it there means we call it twice when really printing, don't we? I think the best place would be at the end of SetupToPrintContent, where we call PrintDocContent if we're really printing.
Attached patch patch v2Splinter Review
> I think since we were calling StartPrint before, we can depend on stuff like
> selection printing and page ranges not being enabled, so we can assume that
> code doesn't actually do anything.

Ok, cool.

> I think
> the best place would be at the end of SetupToPrintContent, where we call
> PrintDocContent if we're really printing.

This patch puts it slightly earlier in that function, just after the call to BeginDocument if we were actually printing.  I put it there to take advantage of the fact that we've already got docTitleStr and docURLStr there, and we haven't freed them yet.

This patch only frees docTitleStr and docURLStr in the NON-print-preview case, because StartPrint() passes the strings by pointer, and so we need to keep those strings around for PrintPreview to use them.   They'll be freed later, in the nsSharedPageData's destructor:

  96 nsSharedPageData::~nsSharedPageData()
  97 {
 ...
 102   if (mDocTitle) nsMemory::Free(mDocTitle);
 103   if (mDocURL) nsMemory::Free(mDocURL);
 104 }
Attachment #299888 - Flags: review?(roc)
Attachment #299853 - Attachment is obsolete: true
Attachment #299853 - Flags: review?(roc)
Comment on attachment 299888 [details] [diff] [review]
patch v2

+    // Print Preview -- pass docTitleStr and docURLStr down to seqFrame here.

"pass ownership of"
Attachment #299888 - Flags: superreview+
Attachment #299888 - Flags: review?(roc)
Attachment #299888 - Flags: review+
Attached patch patch as landedSplinter Review
Improved comment -- here's patch as landed.
Attachment #299947 - Attachment is patch: true
Checking in nsPrintEngine.cpp;
/cvsroot/mozilla/layout/printing/nsPrintEngine.cpp,v  <--  nsPrintEngine.cpp
new revision: 1.162; previous revision: 1.161
done


--> Fixed.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
In tonight's build:

Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.9b4pre) Gecko/2008020702 SeaMonkey/2.0a1pre

the headers and footers are showing in the Print Preview window.  

However (please advise if this should be reported as a new bug), in Portrait mode, the headers were cut off at the top of the page and the footers did not print at all.  I suspect this has to do with the removal of margin settings under both Page Setup and Print/Preferences.  

This margin setting capability really needs to be restored.
I was able to get the footers to print, but only after editing about:config to use the same settings as SM 1.1.8.  

However some text is mixing in with the footers, which requires that scaling to be tested until it prints to the satisfaction of the user.  The item to ignore scaling and shrink to fit automatically, doesn't work, the scaling only seems to work with this box unchecked.


Depends on: 423345
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: