Reviewed by Chris.
authorsullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Feb 2005 01:44:11 +0000 (01:44 +0000)
committersullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Feb 2005 01:44:11 +0000 (01:44 +0000)
        - WebCore part of fix for <rdar://problem/3980651> REGRESSION (125-180): Huge number of pages printed from certain page,
        iFrame involved

        This also fixes the problems with printing from GMail, yay!

        * khtml/rendering/render_flow.cpp:
        (RenderFlow::paintLines):
        If the current line is taller than the entire page height (e.g. tall iFrame), don't try
        to avoid splitting it across pages.

        * kwq/WebCoreBridge.mm:
        (-[WebCoreBridge computePageRectsWithPrintWidthScaleFactor:printHeight:]):
        Handle error cases in a more obvious manner; this will cause future problems like this
        to print a blank page and complain to the console on debug builds, rather than print a
        zillionty mostly-blank pages.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@8509 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog-2005-08-23
WebCore/khtml/rendering/render_flow.cpp
WebCore/kwq/WebCoreBridge.mm

index 5e839fc..4c2fea3 100644 (file)
@@ -1,3 +1,23 @@
+2005-02-02  John Sullivan  <sullivan@apple.com>
+
+        Reviewed by Chris.
+
+        - WebCore part of fix for <rdar://problem/3980651> REGRESSION (125-180): Huge number of pages printed from certain page, 
+        iFrame involved
+        
+        This also fixes the problems with printing from GMail, yay!
+
+        * khtml/rendering/render_flow.cpp:
+        (RenderFlow::paintLines):
+        If the current line is taller than the entire page height (e.g. tall iFrame), don't try
+        to avoid splitting it across pages.
+        
+        * kwq/WebCoreBridge.mm:
+        (-[WebCoreBridge computePageRectsWithPrintWidthScaleFactor:printHeight:]):
+        Handle error cases in a more obvious manner; this will cause future problems like this
+        to print a blank page and complain to the console on debug builds, rather than print a 
+        zillionty mostly-blank pages.
+
 2005-02-02  Chris Blumenberg  <cblu@apple.com>
 
        Fixed: <rdar://problem/3960304> can't load a particular applet (at www.escape.de) unless it's the first applet to be loaded
index 9355476..a6dce59 100644 (file)
@@ -376,11 +376,15 @@ void RenderFlow::paintLines(PaintInfo& i, int _tx, int _ty)
             // It is utterly inadequate, and this should not be done at paint time at all.
             // The whole way objects break across pages needs to be redone.
             RenderCanvas* c = canvas();
-            if (_ty + curr->root()->bottomOverflow() > c->printRect().y() + c->printRect().height()) {
-                if (_ty + curr->root()->topOverflow() < c->truncatedAt())
-                    c->setBestTruncatedAt(_ty + curr->root()->topOverflow(), this);
-                // Let's stop here.
-                break;
+            // Try to avoid splitting a line vertically, but only if it's less than the height
+            // of the entire page.
+            if (curr->root()->bottomOverflow() - curr->root()->topOverflow() <= c->printRect().height()) {
+                if (_ty + curr->root()->bottomOverflow() > c->printRect().y() + c->printRect().height()) {
+                    if (_ty + curr->root()->topOverflow() < c->truncatedAt())
+                        c->setBestTruncatedAt(_ty + curr->root()->topOverflow(), this);
+                    // Let's stop here.
+                    break;
+                }
             }
         }
 
index 6788412..81a5de8 100644 (file)
@@ -710,8 +710,15 @@ static BOOL nowPrinting(WebCoreBridge *self)
 {
     [self _setupRootForPrinting:YES];
     NSMutableArray* pages = [NSMutableArray arrayWithCapacity:5];
-    if (printWidthScaleFactor == 0 || printHeight == 0)
+    if (printWidthScaleFactor <= 0) {
+        ERROR("printWidthScaleFactor has bad value %.2f", printWidthScaleFactor);
         return pages;
+    }
+    
+    if (printHeight <= 0) {
+        ERROR("printHeight has bad value %.2f", printHeight);
+        return pages;
+    }
        
     if (!_part || !_part->xmlDocImpl() || !_part->view()) return pages;
     RenderCanvas* root = static_cast<khtml::RenderCanvas *>(_part->xmlDocImpl()->renderer());