Bug 30621 - Printing using other media types then "print"
Summary: Printing using other media types then "print"
Status: RESOLVED DUPLICATE of bug 25866
Alias: None
Product: WebKit
Classification: Unclassified
Component: Printing (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-21 01:54 PDT by Jakob Truelsen
Modified: 2010-06-12 15:39 PDT (History)
3 users (show)

See Also:


Attachments
Media Type 1.0 (6.10 KB, patch)
2009-10-21 01:58 PDT, Jakob Truelsen
zecke: review-
Details | Formatted Diff | Diff
Media Type 1.1 (6.53 KB, patch)
2009-10-21 07:46 PDT, Jakob Truelsen
ap: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jakob Truelsen 2009-10-21 01:54:01 PDT
Some times, especialy when printing to pdf, it makes sense to use another media type then print when printing, often "screen".
Comment 1 Jakob Truelsen 2009-10-21 01:58:37 PDT
Created attachment 41556 [details]
Media Type 1.0

Patch implementing printing media type setting
Comment 2 Holger Freyther 2009-10-21 06:23:27 PDT
Comment on attachment 41556 [details]
Media Type 1.0


>  void Frame::setPrinting(bool printing, float minPageWidth, float maxPageWidth, bool adjustViewSize)
>  {
> +    String mediaType;
> +    if (m_page->settings())


Use:

     String mediaType = settings() ? settings()->printingMediaType() : "print";

reasoning:
     - m_page can be NULL... m_page->settings() not..
     - provide a default for printingMediaType as well..



> +*/
> +QString QWebSettings::printingMediaType() const
> +{
> +    return d->printingMediaType;
> +}

Which can be QString() which is not what your API doc said... have a default... and let it be "print"

but in general this is a nice patch!
Comment 3 Jakob Truelsen 2009-10-21 07:07:53 PDT
if I give d->printingMediaType a default value in the constructor, it will not inherit a value set in globalSettings unless explicitly set to the empty string.  While this is consistent with other current behaviour (https://bugs.webkit.org/show_bug.cgi?id=30622) it is clearly not what one wants.  The way QWebSettings currently work's putting default values into variables is broken.  

The only solution I can think of to the problem would be to do
settings->setPrintingMediaType(type.isEmpty() ? "print" : type);

however then printingMediaType would still return the empty (null) string .
Comment 4 Jakob Truelsen 2009-10-21 07:46:28 PDT
Created attachment 41567 [details]
Media Type 1.1

Fix mentioned issues.  Mention in documentation that QString() means that a default value is used.
Comment 5 Eric Seidel (no email) 2009-10-21 10:30:42 PDT
I'm not sure this really shoudl be a setting.  I would envision this being a one-off.  If you were to expose some sort of UI to the user to print and they could chose to override the "print" stylesheet and print what's on screen.

Then again, I'm not sure this is very useful to begin with.
Comment 6 Alexey Proskuryakov 2009-10-22 00:04:43 PDT
Comment on attachment 41567 [details]
Media Type 1.1

I agree with Eric - making this a setting seems wrong.
Comment 7 Jakob Truelsen 2009-10-22 00:34:42 PDT
Whether this is a feature needed by other projects then my own (wkhtmltopdf), I cannot judge.  I would however really like this feature in webkit. I tried submitting a patch where the media type is an optional settings for one of the print methods (compute page rects I think).  However the review was denied saying that this was the wrong way to do it.  So I made it a setting, which is apparently also the wrong way to get this feature.  If neither of these approaches are good, is there an approach I can take, that will give me some kind of way to set the printing media type to screen?
Comment 8 Alexey Proskuryakov 2009-10-22 19:44:51 PDT
The best place to discuss this would be webkit-dev mailing list.
Comment 9 Alexey Proskuryakov 2010-06-12 15:39:14 PDT

*** This bug has been marked as a duplicate of bug 25866 ***