<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[19965] trunk/WebKit</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/19965">19965</a></dd>
<dt>Author</dt> <dd>sullivan</dd>
<dt>Date</dt> <dd>2007-03-05 10:37:17 -0800 (Mon, 05 Mar 2007)</dd>
</dl>
<h3>Log Message</h3>
<pre> Reviewed by Darin and Kevin D
- fixed <rdar://problem/5038087> Header and footer on printed page are too large after certain steps
* WebView/WebView.mm:
(-[WebView _adjustPrintingMarginsForHeaderAndFooter]):
This method was modifying the margins in the NSPrintInfo object without any sort of check whether
this had already been done. In some cases this can be called multiple times with the same
NSPrintInfo, so now we stash information in the NSPrintInfo's dictionary such that we always
start with a fresh copy of the original margins.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebKitChangeLog">trunk/WebKit/ChangeLog</a></li>
<li><a href="#trunkWebKitWebViewWebViewmm">trunk/WebKit/WebView/WebView.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebKit/ChangeLog (19964 => 19965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKit/ChangeLog        2007-03-05 18:25:34 UTC (rev 19964)
+++ trunk/WebKit/ChangeLog        2007-03-05 18:37:17 UTC (rev 19965)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2007-03-05 John Sullivan <sullivan@apple.com>
+
+ Reviewed by Darin and Kevin D
+
+ - fixed <rdar://problem/5038087> Header and footer on printed page are too large after certain steps
+
+ * WebView/WebView.mm:
+ (-[WebView _adjustPrintingMarginsForHeaderAndFooter]):
+ This method was modifying the margins in the NSPrintInfo object without any sort of check whether
+ this had already been done. In some cases this can be called multiple times with the same
+ NSPrintInfo, so now we stash information in the NSPrintInfo's dictionary such that we always
+ start with a fresh copy of the original margins.
+
</ins><span class="cx"> 2007-03-02 Kevin McCullough <kmccullough@apple.com>
</span><span class="cx">
</span><span class="cx"> Reviewed by Geoff.
</span></span></pre></div>
<a id="trunkWebKitWebViewWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/WebKit/WebView/WebView.mm (19964 => 19965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKit/WebView/WebView.mm        2007-03-05 18:25:34 UTC (rev 19964)
+++ trunk/WebKit/WebView/WebView.mm        2007-03-05 18:37:17 UTC (rev 19965)
</span><span class="lines">@@ -233,6 +233,9 @@
</span><span class="cx"> macro(yank) \
</span><span class="cx"> macro(yankAndSelect) \
</span><span class="cx">
</span><ins>+#define WebKitOriginalTopPrintingMarginKey @"WebKitOriginalTopMargin"
+#define WebKitOriginalBottomPrintingMarginKey @"WebKitOriginalBottomMargin"
+
</ins><span class="cx"> static BOOL applicationIsTerminating;
</span><span class="cx"> static int pluginDatabaseClientCount = 0;
</span><span class="cx">
</span><span class="lines">@@ -2896,9 +2899,31 @@
</span><span class="cx"> {
</span><span class="cx"> NSPrintOperation *op = [NSPrintOperation currentOperation];
</span><span class="cx"> NSPrintInfo *info = [op printInfo];
</span><ins>+ NSMutableDictionary *infoDictionary = [info dictionary];
+
+ // We need to modify the top and bottom margins in the NSPrintInfo to account for the space needed by the
+ // header and footer. Because this method can be called more than once on the same NSPrintInfo (see 5038087),
+ // we stash away the unmodified top and bottom margins the first time this method is called, and we read from
+ // those stashed-away values on subsequent calls.
+ float originalTopMargin;
+ float originalBottomMargin;
+ NSNumber *originalTopMarginNumber = [infoDictionary objectForKey:WebKitOriginalTopPrintingMarginKey];
+ if (!originalTopMarginNumber) {
+ ASSERT(![infoDictionary objectForKey:WebKitOriginalBottomPrintingMarginKey]);
+ originalTopMargin = [info topMargin];
+ originalBottomMargin = [info bottomMargin];
+ [infoDictionary setObject:[NSNumber numberWithFloat:originalTopMargin] forKey:WebKitOriginalTopPrintingMarginKey];
+ [infoDictionary setObject:[NSNumber numberWithFloat:originalBottomMargin] forKey:WebKitOriginalBottomPrintingMarginKey];
+ } else {
+ ASSERT([originalTopMarginNumber isKindOfClass:[NSNumber class]]);
+ ASSERT([[infoDictionary objectForKey:WebKitOriginalBottomPrintingMarginKey] isKindOfClass:[NSNumber class]]);
+ originalTopMargin = [originalTopMarginNumber floatValue];
+ originalBottomMargin = [[infoDictionary objectForKey:WebKitOriginalBottomPrintingMarginKey] floatValue];
+ }
+
</ins><span class="cx"> float scale = [op _web_pageSetupScaleFactor];
</span><del>- [info setTopMargin:[info topMargin] + [self _headerHeight]*scale];
- [info setBottomMargin:[info bottomMargin] + [self _footerHeight]*scale];
</del><ins>+ [info setTopMargin:originalTopMargin + [self _headerHeight] * scale];
+ [info setBottomMargin:originalBottomMargin + [self _footerHeight] * scale];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)_drawHeaderAndFooter
</span></span></pre>
</div>
</div>
</body>
</html>