[WinCairo] Correct scaling for print preview
Created attachment 56425 [details] Patch
Cairo does not properly deal with Windows HDC's that have been scaled using MM_ANISOTROPIC mapping mode, and a WindowExt and ViewportExt setting. (see http://bugs.freedesktop.org/show_bug.cgi?id=28161) Instead, reset the HDC's WorldTransform to unity, scale the cairo context to the desired scaling, and perform the drawing operation.
Comment on attachment 56425 [details] Patch Brent asked me to do an informal review of this patch. I just have a couple nits. Someone who knows a little bit more about Windows print preview and printing should probably review this officially. > + * WebFrame.cpp: > + (WebFrame::drawHeader): Use pre-positioned context to simplify > + tthis method. 'tthis' -> 'this' :) > +static void setCairoToHDC(cairo_t* cr, HDC targetDC) I think maybe this should have a more descriptive name as it touches not only the Cairo context but the current world transform. Since this patch is a work-around for a Cairo bug, maybe there should be a longish comment at the call-site with a high-level overview of the problem (and perhaps a link to the Cairo bug report, if it exists?). This all looks pretty reasonable to me.
Comment on attachment 56425 [details] Patch WebKit/win/ChangeLog:8 + Cairo does not properly deal with Windows HDC's that have been There's no apostrophe in "HDCs". WebKit/win/ChangeLog:13 + Instead, reset the HDC's WorldTransform to unity, scale the Here, too. I think maybe you mean "identity" instead of "unity". WebKit/win/WebFrame.cpp:2166 + int y = max(static_cast<int>(headerHeight) + pageRect.height(), m_pageHeight -static_cast<int>(footerHeight)); Weird spacing around the - operator here. WebKit/win/WebFrame.cpp:2172 + static XFORM buildXformFromCairo(HDC targetDC, cairo_t* cr) I think WebKit naming conventions say this should be buildXFORMFromCairo. Is there a better name we can use than "cr"? WebKit/win/WebFrame.cpp:2247 + static void setCairoToHDC(cairo_t* cr, HDC targetDC) Again, a better name than "cr" would be nice. I agree that this function could use a better name. WebKit/win/WebFrame.cpp:2252 + XFORM revertedCTM(passedCTM); Using constructor syntax here is a little surprising.
Landed in http://trac.webkit.org/changeset/59855.