[Webkit-unassigned] [Bug 26584] [Qt] Printing extra information

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Sep 3 01:19:42 PDT 2009


https://bugs.webkit.org/show_bug.cgi?id=26584


Ariya Hidayat <ariya.hidayat at trolltech.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ariya.hidayat at trolltech.com




--- Comment #16 from Ariya Hidayat <ariya.hidayat at trolltech.com>  2009-09-03 01:19:42 PDT ---
I am also not so confident that the new API functions that you propose here is
the right way to implement it. I am not even sure that it will work (you do not
include any unit test at all).
Note that I fully agree that there should be a mechanism for the developer to
control and fine-tune the printing process.

Anyway, here is my feedback.

> +quint32 QWebFrame::countPages(QPrinter* printer) const {

Looking at other Qt API functions, the closes I get is pageCount(), e.g.
QTextDocument. Granted, it does not take a QPrinter as an argument, hence more
like a property rather than an action. I am not sure about the name
"countPages", it seems to me that the web frame is counting the pages, but then
what? Maybe something like "computePageCount" sounds better? Feel free to
suggest other names as well.

> +void QWebFrame::print(QPrinter* printer, QPainter* painter) const

Here is my biggest concern, I am not sure that passing another QPainter is the
right thing to do. Read further more for more comments.

> +    \fn void QWebFrame::printingNewPage(QPrinter *printer, int fromPage, int toPage, int Page) const

This does not make a good API. A signal is usually in the form of past tense,
because it indicates that something has happened. Otherwise use the form
aboutToDoSomething.
Also, have you checked whether this works at all? I mean, from the moment the
signal is emitted until you do something in your object slot, another new page
might have been printed.


Finally, here is an idea if I were to implement this (I don't know if this is
technically manageable or not). Instead of using "pull" strategy, what about a
"push" one. Look at the code:

int pageCount = frame->computePageCount(myPrinter)
// setup the print dialog if necessary, which might need the page count
frame->beginPrint(myPrinter);
for (int i = 1; i < pageCount; ++i)
  frame->spoolPage(i);
frame->endPrint();

The drawbacks: we put some kind of state information into the QWebFrame, hence
you can't really interleave the printing e.g. to two printers (but seriously,
who does that).
Also if you need to grab the QPainter that operates on the printer, it's
possible via myPrinter->paintEngine()->painter() but then it's const (might
need some casting). If this is ugly, we might need some other hook like
"printingPainter()".

r- until we solve this issues.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list