[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.20-204-g221d8e8
bfulgham at webkit.org
bfulgham at webkit.org
Wed Feb 10 22:14:22 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 67e38101017c4afc9b87633bc774c74ee745bb3c
Author: bfulgham at webkit.org <bfulgham at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Feb 4 18:42:59 2010 +0000
Properly handle margin settings in WinCairo.
https://bugs.webkit.org/show_bug.cgi?id=34545
Reviewed by Adam Roben.
* WebFrame.cpp:
(scaleFactor): Require the margin information as an input
parameter, and use them when computing the scaling factor.
(WebFrame::drawHeader): Pass margin size to scaleFactor.
(WebFrame::drawFooter): Pass margin size to scaleFactor.
(WebFrame::spoolPage):
1. Pass margin size to scaleFactor.
2. Recognize that the return value of printerMarginRect is
already in device units, and therefore scale it so that
the Cairo drawing is correct.
3. Remove scaling call for margins in GDI code, as it is
already in scaled units.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54356 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/win/ChangeLog b/WebKit/win/ChangeLog
index 36d3144..9419593 100644
--- a/WebKit/win/ChangeLog
+++ b/WebKit/win/ChangeLog
@@ -1,3 +1,23 @@
+2010-02-04 Brent Fulgham <bfulgham at webkit.org>
+
+ Reviewed by Adam Roben.
+
+ Properly handle margin settings in WinCairo.
+ https://bugs.webkit.org/show_bug.cgi?id=34545
+
+ * WebFrame.cpp:
+ (scaleFactor): Require the margin information as an input
+ parameter, and use them when computing the scaling factor.
+ (WebFrame::drawHeader): Pass margin size to scaleFactor.
+ (WebFrame::drawFooter): Pass margin size to scaleFactor.
+ (WebFrame::spoolPage):
+ 1. Pass margin size to scaleFactor.
+ 2. Recognize that the return value of printerMarginRect is
+ already in device units, and therefore scale it so that
+ the Cairo drawing is correct.
+ 3. Remove scaling call for margins in GDI code, as it is
+ already in scaled units.
+
2010-02-03 Brian Weinstein <bweinstein at apple.com>
Reviewed by Steve Falkenburg.
diff --git a/WebKit/win/WebFrame.cpp b/WebKit/win/WebFrame.cpp
index c0c1601..3662bfe 100644
--- a/WebKit/win/WebFrame.cpp
+++ b/WebKit/win/WebFrame.cpp
@@ -2018,11 +2018,17 @@ void WebFrame::spoolPage(PlatformGraphicsContext* pctx, GraphicsContext* spoolCt
CGContextRestoreGState(pctx);
}
#elif PLATFORM(CAIRO)
-static float scaleFactor(HDC printDC, const IntRect& pageRect)
+static float scaleFactor(HDC printDC, const IntRect& marginRect, const IntRect& pageRect)
{
const IntRect& printRect = printerRect(printDC);
- float scale = static_cast<float>(printRect.width()) / static_cast<float>(pageRect.width());
+ IntRect adjustedRect = IntRect(
+ printRect.x() + marginRect.x(),
+ printRect.y() + marginRect.y(),
+ printRect.width() - marginRect.x() - marginRect.right(),
+ printRect.height() - marginRect.y() - marginRect.bottom());
+
+ float scale = static_cast<float>(adjustedRect.width()) / static_cast<float>(pageRect.width());
if (!scale)
scale = 1.0;
@@ -2038,8 +2044,9 @@ static HDC hdcFromContext(PlatformGraphicsContext* pctx)
void WebFrame::drawHeader(PlatformGraphicsContext* pctx, IWebUIDelegate* ui, const IntRect& pageRect, float headerHeight)
{
HDC hdc = hdcFromContext(pctx);
+ const IntRect& marginRect = printerMarginRect(hdc);
- const float scale = scaleFactor(hdc, pageRect);
+ const float scale = scaleFactor(hdc, marginRect, pageRect);
int x = static_cast<int>(scale * pageRect.x());
int y = 0;
RECT headerRect = {x, y, x + static_cast<int>(scale * pageRect.width()), y + static_cast<int>(scale * headerHeight)};
@@ -2050,8 +2057,9 @@ void WebFrame::drawHeader(PlatformGraphicsContext* pctx, IWebUIDelegate* ui, con
void WebFrame::drawFooter(PlatformGraphicsContext* pctx, IWebUIDelegate* ui, const IntRect& pageRect, UINT page, UINT pageCount, float headerHeight, float footerHeight)
{
HDC hdc = hdcFromContext(pctx);
+ const IntRect& marginRect = printerMarginRect(hdc);
- const float scale = scaleFactor(hdc, pageRect);
+ const float scale = scaleFactor(hdc, marginRect, pageRect);
int x = static_cast<int>(scale * pageRect.x());
int y = static_cast<int>(scale * max(static_cast<int>(headerHeight) + pageRect.height(), m_pageHeight-static_cast<int>(footerHeight)));
RECT footerRect = {x, y, x + static_cast<int>(scale * pageRect.width()), y + static_cast<int>(scale * footerHeight)};
@@ -2064,24 +2072,27 @@ void WebFrame::spoolPage(PlatformGraphicsContext* pctx, GraphicsContext* spoolCt
Frame* coreFrame = core(this);
const IntRect& pageRect = m_pageRects[page];
- IntRect marginRect = printerMarginRect(printDC);
+ const IntRect& marginRect = printerMarginRect(printDC);
cairo_save(pctx);
- float scale = scaleFactor(printDC, pageRect);
+ float scale = scaleFactor(printDC, marginRect, pageRect);
cairo_scale(pctx, scale, scale);
- cairo_translate(pctx, -pageRect.x() + marginRect.x(), -pageRect.y() + marginRect.y() + headerHeight);
+ IntRect cairoMarginRect (marginRect);
+ cairoMarginRect.scale (1 / scale);
+
+ cairo_translate(pctx, -pageRect.x() + cairoMarginRect.x(), -pageRect.y() + cairoMarginRect.y() + headerHeight);
coreFrame->view()->paintContents(spoolCtx, pageRect);
- cairo_translate(pctx, pageRect.x() - marginRect.x(), pageRect.y() - marginRect.y() - headerHeight);
+ cairo_translate(pctx, pageRect.x() - cairoMarginRect.x(), pageRect.y() - cairoMarginRect.y() - headerHeight);
XFORM originalWorld;
::GetWorldTransform(printDC, &originalWorld);
// Position world transform to account for margin
XFORM newWorld = originalWorld;
- newWorld.eDx = scale * marginRect.x();
- newWorld.eDy = scale * marginRect.y();
+ newWorld.eDx = marginRect.x();
+ newWorld.eDy = marginRect.y();
::SetWorldTransform(printDC, &newWorld);
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list