[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
sullivan
sullivan at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:14:41 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit aa29846e562c659e013bd0ae5d7d0b68d89f21bc
Author: sullivan <sullivan at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Nov 21 18:16:07 2003 +0000
WebCore:
- WebCore part of fix for <rdar://problem/3333744>: Safari prints page with
very, very long line very, very small
Reviewed by Ken.
* kwq/KWQKHTMLPart.h:
* kwq/KWQKHTMLPart.mm:
(KWQKHTMLPart::forceLayoutWithPageWidthRange):
Changed method name from forceLayoutForPageWidth; now takes min and max
page width values. Use max page width value to limit how wide page will
get when there's a very long line.
* kwq/WebCoreBridge.h:
* kwq/WebCoreBridge.mm:
(-[WebCoreBridge forceLayoutWithMinimumPageWidth:maximumPageWidth:adjustingViewSize:]):
changed pageWidth parameter into min and max parameters; pass them along to KWQKHTMLPart.
WebKit:
- WebKit part of fix for <rdar://problem/3333744>: Safari prints page with
very, very long line very, very small
Reviewed by Ken.
* WebView.subproj/WebHTMLView.m:
renamed PrintingExtraWidthFactor to PrintingMinimumShrinkFactor, added
PrintingMaximumShrinkFactor of 2.0, which matches IE
(-[WebHTMLView layoutToMinimumPageWidth:maximumPageWidth:adjustingViewSize:]):
now takes a min and max page width; passes them along to bridge
(-[WebHTMLView _setPrinting:minimumPageWidth:maximumPageWidth:adjustViewSize:]):
now takes a min and max page width; passes them along to layoutTo...
(-[WebHTMLView _scaleFactorForPrintOperation:]):
now takes PrintingMaximumScaleFactor into account
(-[WebHTMLView knowsPageRange:]):
now takes PrintingMaximumScaleFactor into account
(-[WebHTMLView layout]):
pass 0 for maximumPageWidth when passing 0 for minimumPageWidth
(-[WebHTMLView adjustPageHeightNew:top:bottom:limit:]):
ditto
(-[WebHTMLView _web_setPrintingModeRecursive]):
ditto
(-[WebHTMLView _web_clearPrintingModeRecursive]):
ditto
(-[WebHTMLView endDocument]):
ditto
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@5621 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 0272f65..8cadbdf 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,22 @@
+2003-11-21 John Sullivan <sullivan at apple.com>
+
+ - WebCore part of fix for <rdar://problem/3333744>: Safari prints page with
+ very, very long line very, very small
+
+ Reviewed by Ken.
+
+ * kwq/KWQKHTMLPart.h:
+ * kwq/KWQKHTMLPart.mm:
+ (KWQKHTMLPart::forceLayoutWithPageWidthRange):
+ Changed method name from forceLayoutForPageWidth; now takes min and max
+ page width values. Use max page width value to limit how wide page will
+ get when there's a very long line.
+
+ * kwq/WebCoreBridge.h:
+ * kwq/WebCoreBridge.mm:
+ (-[WebCoreBridge forceLayoutWithMinimumPageWidth:maximumPageWidth:adjustingViewSize:]):
+ changed pageWidth parameter into min and max parameters; pass them along to KWQKHTMLPart.
+
2003-11-21 Darin Adler <darin at apple.com>
Reviewed by Ken.
diff --git a/WebCore/kwq/KWQKHTMLPart.h b/WebCore/kwq/KWQKHTMLPart.h
index 2c940ca..5364cd0 100644
--- a/WebCore/kwq/KWQKHTMLPart.h
+++ b/WebCore/kwq/KWQKHTMLPart.h
@@ -169,7 +169,7 @@ public:
using KHTMLPart::xmlDocImpl;
khtml::RenderObject *renderer();
void forceLayout();
- void forceLayoutForPageWidth(float pageWidth);
+ void forceLayoutWithPageWidthRange(float minPageWidth, float maxPageWidth);
void sendResizeEvent();
void paint(QPainter *, const QRect &);
void paintSelectionOnly(QPainter *p, const QRect &rect);
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index 0429d89..ef3267e 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -1392,24 +1392,26 @@ void KWQKHTMLPart::forceLayout()
}
}
-void KWQKHTMLPart::forceLayoutForPageWidth(float pageWidth)
+void KWQKHTMLPart::forceLayoutWithPageWidthRange(float minPageWidth, float maxPageWidth)
{
// Dumping externalRepresentation(_part->renderer()).ascii() is a good trick to see
// the state of things before and after the layout
RenderCanvas *root = static_cast<RenderCanvas *>(xmlDocImpl()->renderer());
if (root) {
// This magic is basically copied from khtmlview::print
- int pageW = (int)ceil(pageWidth);
+ int pageW = (int)ceil(minPageWidth);
root->setWidth(pageW);
root->setNeedsLayoutAndMinMaxRecalc();
forceLayout();
- // See if we spilled outside our page width. If we did, then we'll do one more layout in an
- // attempt to fit. FIXME: We are assuming a shrink-to-fit printing implementation. A cropping
+ // If we don't fit in the minimum page width, we'll lay out again. If we don't fit in the
+ // maximum page width, we will lay out to the maximum page width and clip extra content.
+ // FIXME: We are assuming a shrink-to-fit printing implementation. A cropping
// implementation should not do this!
int rightmostPos = root->rightmostPosition();
- if (rightmostPos > pageWidth) {
- root->setWidth(rightmostPos);
+ if (rightmostPos > minPageWidth) {
+ pageW = kMin(rightmostPos, (int)ceil(maxPageWidth));
+ root->setWidth(pageW);
root->setNeedsLayoutAndMinMaxRecalc();
forceLayout();
}
diff --git a/WebCore/kwq/WebCoreBridge.h b/WebCore/kwq/WebCoreBridge.h
index 725a961..40ad7f4 100644
--- a/WebCore/kwq/WebCoreBridge.h
+++ b/WebCore/kwq/WebCoreBridge.h
@@ -146,7 +146,7 @@ typedef enum {
- (void)reapplyStylesForDeviceType:(WebCoreDeviceType)deviceType;
- (void)forceLayoutAdjustingViewSize:(BOOL)adjustSizeFlag;
-- (void)forceLayoutForPageWidth:(float)pageWidth adjustingViewSize:(BOOL)adjustSizeFlag;
+- (void)forceLayoutWithMinimumPageWidth:(float)minPageWidth maximumPageWidth:(float)maxPageWidth adjustingViewSize:(BOOL)adjustSizeFlag;
- (void)sendResizeEvent;
- (BOOL)needsLayout;
- (void)drawRect:(NSRect)rect;
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index 397a009..f7678ee 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -407,10 +407,10 @@ static BOOL nowPrinting(WebCoreBridge *self)
[self _setupRootForPrinting:NO];
}
-- (void)forceLayoutForPageWidth:(float)pageWidth adjustingViewSize:(BOOL)flag
+- (void)forceLayoutWithMinimumPageWidth:(float)minPageWidth maximumPageWidth:(float)maxPageWidth adjustingViewSize:(BOOL)flag
{
[self _setupRootForPrinting:YES];
- _part->forceLayoutForPageWidth(pageWidth);
+ _part->forceLayoutWithPageWidthRange(minPageWidth, maxPageWidth);
if (flag) {
[self adjustViewSize];
}
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 59c167a..22e5e00 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,33 @@
+2003-11-21 John Sullivan <sullivan at apple.com>
+
+ - WebKit part of fix for <rdar://problem/3333744>: Safari prints page with
+ very, very long line very, very small
+
+ Reviewed by Ken.
+
+ * WebView.subproj/WebHTMLView.m:
+ renamed PrintingExtraWidthFactor to PrintingMinimumShrinkFactor, added
+ PrintingMaximumShrinkFactor of 2.0, which matches IE
+ (-[WebHTMLView layoutToMinimumPageWidth:maximumPageWidth:adjustingViewSize:]):
+ now takes a min and max page width; passes them along to bridge
+ (-[WebHTMLView _setPrinting:minimumPageWidth:maximumPageWidth:adjustViewSize:]):
+ now takes a min and max page width; passes them along to layoutTo...
+ (-[WebHTMLView _scaleFactorForPrintOperation:]):
+ now takes PrintingMaximumScaleFactor into account
+ (-[WebHTMLView knowsPageRange:]):
+ now takes PrintingMaximumScaleFactor into account
+
+ (-[WebHTMLView layout]):
+ pass 0 for maximumPageWidth when passing 0 for minimumPageWidth
+ (-[WebHTMLView adjustPageHeightNew:top:bottom:limit:]):
+ ditto
+ (-[WebHTMLView _web_setPrintingModeRecursive]):
+ ditto
+ (-[WebHTMLView _web_clearPrintingModeRecursive]):
+ ditto
+ (-[WebHTMLView endDocument]):
+ ditto
+
2003-11-20 John Sullivan <sullivan at apple.com>
- WebKit part of <rdar://problem/3183124>: Support page-break-before/after with a value of "always"
diff --git a/WebKit/WebView.subproj/WebHTMLView.m b/WebKit/WebView.subproj/WebHTMLView.m
index ba30928..3455993 100644
--- a/WebKit/WebView.subproj/WebHTMLView.m
+++ b/WebKit/WebView.subproj/WebHTMLView.m
@@ -54,9 +54,14 @@
// thin pages will be scaled down a little, matching the way they
// print in IE and Camino. This lets them use fewer sheets than they
// would otherwise, which is presumably why other browsers do this.
-// Wide pages will be scaled down as necessary to fit their content,
-// so this factor only affects thin pages.
-#define PrintingExtraWidthFactor 1.25
+// Wide pages will be scaled down more than this.
+#define PrintingMinimumShrinkFactor 1.25
+
+// This number determines how small we are willing to reduce the page content
+// in order to accommodate the widest line. If the page would have to be
+// reduced smaller to make the widest line fit, we just clip instead (this
+// behavior matches MacIE and Mozilla, at least)
+#define PrintingMaximumShrinkFactor 2.0
#define AUTOSCROLL_INTERVAL 0.1
@@ -74,7 +79,7 @@
static BOOL forceRealHitTest = NO;
@interface WebHTMLView (WebHTMLViewPrivate)
-- (void)_setPrinting:(BOOL)printing pageWidth:(float)pageWidth adjustViewSize:(BOOL)adjustViewSize;
+- (void)_setPrinting:(BOOL)printing minimumPageWidth:(float)minPageWidth maximumPageWidth:(float)maxPageWidth adjustViewSize:(BOOL)adjustViewSize;
- (void)_updateTextSizeMultiplier;
- (float)_calculatePrintHeight;
@end
@@ -718,13 +723,13 @@ static WebHTMLView *lastHitView = nil;
- (void)_web_setPrintingModeRecursive
{
- [self _setPrinting:YES pageWidth:0 adjustViewSize:NO];
+ [self _setPrinting:YES minimumPageWidth:0.0 maximumPageWidth:0.0 adjustViewSize:NO];
[super _web_setPrintingModeRecursive];
}
- (void)_web_clearPrintingModeRecursive
{
- [self _setPrinting:NO pageWidth:0 adjustViewSize:NO];
+ [self _setPrinting:NO minimumPageWidth:0.0 maximumPageWidth:0.0 adjustViewSize:NO];
[super _web_clearPrintingModeRecursive];
}
@@ -1166,8 +1171,8 @@ static WebHTMLView *lastHitView = nil;
}
// Do a layout, but set up a new fixed width for the purposes of doing printing layout.
-// pageWidth==0 implies a non-printing layout
-- (void)layoutToPageWidth:(float)pageWidth adjustingViewSize:(BOOL)adjustViewSize
+// minPageWidth==0 implies a non-printing layout
+- (void)layoutToMinimumPageWidth:(float)minPageWidth maximumPageWidth:(float)maxPageWidth adjustingViewSize:(BOOL)adjustViewSize
{
[self reapplyStyles];
@@ -1185,8 +1190,8 @@ static WebHTMLView *lastHitView = nil;
LOG(View, "%@ doing layout", self);
- if (pageWidth > 0.0) {
- [[self _bridge] forceLayoutForPageWidth:pageWidth adjustingViewSize:adjustViewSize];
+ if (minPageWidth > 0.0) {
+ [[self _bridge] forceLayoutWithMinimumPageWidth:minPageWidth maximumPageWidth:maxPageWidth adjustingViewSize:adjustViewSize];
} else {
[[self _bridge] forceLayoutAdjustingViewSize:adjustViewSize];
}
@@ -1213,7 +1218,7 @@ static WebHTMLView *lastHitView = nil;
- (void)layout
{
- [self layoutToPageWidth:0.0 adjustingViewSize:NO];
+ [self layoutToMinimumPageWidth:0.0 maximumPageWidth:0.0 adjustingViewSize:NO];
}
- (NSMenu *)menuForEvent:(NSEvent *)event
@@ -1634,7 +1639,7 @@ static WebHTMLView *lastHitView = nil;
// Does setNeedsDisplay:NO as a side effect. Useful for begin/endDocument.
// pageWidth != 0 implies we will relayout to a new width
-- (void)_setPrinting:(BOOL)printing pageWidth:(float)pageWidth adjustViewSize:(BOOL)adjustViewSize
+- (void)_setPrinting:(BOOL)printing minimumPageWidth:(float)minPageWidth maximumPageWidth:(float)maxPageWidth adjustViewSize:(BOOL)adjustViewSize
{
WebFrame *frame = [self _frame];
NSArray *subframes = [frame childFrames];
@@ -1644,7 +1649,7 @@ static WebHTMLView *lastHitView = nil;
WebFrame *subframe = [subframes objectAtIndex:i];
WebFrameView *frameView = [subframe frameView];
if ([[subframe dataSource] _isDocumentHTML]) {
- [(WebHTMLView *)[frameView documentView] _setPrinting:printing pageWidth:0 adjustViewSize:adjustViewSize];
+ [(WebHTMLView *)[frameView documentView] _setPrinting:printing minimumPageWidth:0.0 maximumPageWidth:0.0 adjustViewSize:adjustViewSize];
}
}
@@ -1654,7 +1659,7 @@ static WebHTMLView *lastHitView = nil;
_private->printing = printing;
[self setNeedsToApplyStyles:YES];
[self setNeedsLayout:YES];
- [self layoutToPageWidth:pageWidth adjustingViewSize:adjustViewSize];
+ [self layoutToMinimumPageWidth:minPageWidth maximumPageWidth:maxPageWidth adjustingViewSize:adjustViewSize];
[self setNeedsDisplay:NO];
}
}
@@ -1667,13 +1672,13 @@ static WebHTMLView *lastHitView = nil;
// If the WebHTMLView itself is what we're printing, then we will never have to do this.
BOOL wasInPrintingMode = _private->printing;
if (!wasInPrintingMode) {
- [self _setPrinting:YES pageWidth:0 adjustViewSize:NO];
+ [self _setPrinting:YES minimumPageWidth:0.0 maximumPageWidth:0.0 adjustViewSize:NO];
}
[[self _bridge] adjustPageHeightNew:newBottom top:oldTop bottom:oldBottom limit:bottomLimit];
if (!wasInPrintingMode) {
- [self _setPrinting:NO pageWidth:0 adjustViewSize:NO];
+ [self _setPrinting:NO minimumPageWidth:0.0 maximumPageWidth:0.0 adjustViewSize:NO];
}
}
@@ -1685,7 +1690,12 @@ static WebHTMLView *lastHitView = nil;
- (float)_scaleFactorForPrintOperation:(NSPrintOperation *)printOperation
{
- return [self _availablePaperWidthForPrintOperation:printOperation]/NSWidth([self bounds]);
+ float viewWidth = NSWidth([self bounds]);
+ if (viewWidth < 1) {
+ ERROR("%@ has no width when printing", self);
+ return 1.0;
+ }
+ return MAX(1/PrintingMaximumShrinkFactor, [self _availablePaperWidthForPrintOperation:printOperation]/viewWidth);
}
// FIXME 3491344: This is a secret AppKit-internal method that we need to override in order
@@ -1705,11 +1715,14 @@ static WebHTMLView *lastHitView = nil;
// If we are a frameset just print with the layout we have onscreen, otherwise relayout
// according to the paper size
- float layoutWidth = 0.0;
+ float minLayoutWidth = 0.0;
+ float maxLayoutWidth = 0.0;
if (![[self _bridge] isFrameSet]) {
- layoutWidth = [self _availablePaperWidthForPrintOperation:[NSPrintOperation currentOperation]]*PrintingExtraWidthFactor;
+ float paperWidth = [self _availablePaperWidthForPrintOperation:[NSPrintOperation currentOperation]];
+ minLayoutWidth = paperWidth*PrintingMinimumShrinkFactor;
+ maxLayoutWidth = paperWidth*PrintingMaximumShrinkFactor;
}
- [self _setPrinting:YES pageWidth:layoutWidth adjustViewSize:YES]; // will relayout
+ [self _setPrinting:YES minimumPageWidth:minLayoutWidth maximumPageWidth:maxLayoutWidth adjustViewSize:YES]; // will relayout
// There is a theoretical chance that someone could do some drawing between here and endDocument,
// if something caused setNeedsDisplay after this point. If so, it's not a big tragedy, because
@@ -1742,7 +1755,7 @@ static WebHTMLView *lastHitView = nil;
{
[super endDocument];
// Note sadly at this point [NSGraphicsContext currentContextDrawingToScreen] is still NO
- [self _setPrinting:NO pageWidth:0.0 adjustViewSize:YES];
+ [self _setPrinting:NO minimumPageWidth:0.0 maximumPageWidth:0.0 adjustViewSize:YES];
[[self window] setAutodisplay:YES];
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list