Fix for 3787133, some web pages print with many blank pages. Make sure to use the...
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Dec 2004 01:36:23 +0000 (01:36 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Dec 2004 01:36:23 +0000 (01:36 +0000)
not a damage rect that can be changed when intersected with the clip regions of the web page.

        Reviewed by john

        * khtml/rendering/render_canvas.h:
        (khtml::RenderCanvas::printRect):
        (khtml::RenderCanvas::setPrintRect):
        * khtml/rendering/render_flow.cpp:
        (RenderFlow::paintLines):
        * khtml/rendering/render_list.cpp:
        (RenderListMarker::paint):
        * kwq/KWQKHTMLPart.mm:
        (KWQKHTMLPart::adjustPageHeight):

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

WebCore/ChangeLog-2005-08-23
WebCore/khtml/rendering/render_canvas.h
WebCore/khtml/rendering/render_flow.cpp
WebCore/khtml/rendering/render_list.cpp
WebCore/kwq/KWQKHTMLPart.mm

index c7a6fdb185ea6df385c70b9ad0e7f56cf2c874da..07ac771f4747b49934737883f828f1f93808ecd9 100644 (file)
@@ -1,3 +1,20 @@
+2004-12-06  David Hyatt  <hyatt@apple.com>
+
+       Fix for 3787133, some web pages print with many blank pages.  Make sure to use the real page print rect and
+       not a damage rect that can be changed when intersected with the clip regions of the web page.
+       
+        Reviewed by john
+
+        * khtml/rendering/render_canvas.h:
+        (khtml::RenderCanvas::printRect):
+        (khtml::RenderCanvas::setPrintRect):
+        * khtml/rendering/render_flow.cpp:
+        (RenderFlow::paintLines):
+        * khtml/rendering/render_list.cpp:
+        (RenderListMarker::paint):
+        * kwq/KWQKHTMLPart.mm:
+        (KWQKHTMLPart::adjustPageHeight):
+
 2004-12-06  David Harrison  <harrison@apple.com>
 
         Reviewed by Ken Kocienda and Dave Hyatt (OOPS!).
index f6c2911f7789d025322ca58b76166edd1b54f596..d1c081fb01e00cab261d952c1900456f0539455d 100644 (file)
@@ -99,6 +99,9 @@ public:
 
     virtual void selectionStartEnd(int& spos, int& epos);
 
+    QRect printRect() const { return m_printRect; }
+    void setPrintRect(const QRect& r) { m_printRect = r; }
+
 protected:
 
     KHTMLView *m_view;
@@ -120,6 +123,7 @@ protected:
     int m_truncatedAt;
     
     int m_maximalOutlineSize; // Used to apply a fudge factor to dirty-rect checks on blocks/tables.
+    QRect m_printRect; // Used when printing.
 };
 
 };
index 01b90bade27b892b096dac134b42b3cbcff51436..5852345873781cdb6f12f2984857df190aaf4e7e 100644 (file)
@@ -381,10 +381,10 @@ void RenderFlow::paintLines(PaintInfo& i, int _tx, int _ty)
             // FIXME: This is a feeble effort to avoid splitting a line across two pages.
             // 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.
-            if (_ty + curr->root()->bottomOverflow() > i.r.y() + i.r.height()) {
-                RenderCanvas* canvasObj = canvas();
-                if (_ty + curr->root()->topOverflow() < canvasObj->truncatedAt())
-                    canvasObj->setBestTruncatedAt(_ty + curr->root()->topOverflow(), this);
+            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;
             }
index ba92f3efa9118cf5d93463c7b721912b49106737..d1a3a7956c568c5d2e75fd091080f6580cde6e2b 100644 (file)
@@ -403,22 +403,15 @@ void RenderListMarker::paint(PaintInfo& i, int _tx, int _ty)
     }
 
     bool isPrinting = (p->device()->devType() == QInternal::Printer);
-    if (isPrinting)
-    {
+    if (isPrinting) {
         if (_ty < i.r.y())
-        {
             // This has been printed already we suppose.
             return;
-        }
-        if (_ty + m_height + paddingBottom() + borderBottom() >= i.r.y() + i.r.height())
-        {
-            RenderCanvas *rootObj = canvas();
-            if (_ty < rootObj->truncatedAt())
-#if APPLE_CHANGES
-                rootObj->setBestTruncatedAt(_ty, this);
-#else
-                rootObj->setTruncatedAt(_ty);
-#endif
+        
+        RenderCanvas* c = canvas();
+        if (_ty + m_height + paddingBottom() + borderBottom() >= c->printRect().y() + c->printRect().height()) {
+            if (_ty < c->truncatedAt())
+                c->setBestTruncatedAt(_ty, this);
             // Let's print this on the next page.
             return; 
         }
index 8838c75dca9f12c5784b5cbbfe54dd5352a6d07e..78bc0df3b6746af2517e32a3c4470a7d269e7207 100644 (file)
@@ -1144,6 +1144,7 @@ void KWQKHTMLPart::adjustPageHeight(float *newBottom, float oldTop, float oldBot
         root->setTruncatedAt((int)floor(oldBottom));
         QRect dirtyRect(0, (int)floor(oldTop),
                         root->docWidth(), (int)ceil(oldBottom-oldTop));
+        root->setPrintRect(dirtyRect);
         root->layer()->paint(&painter, dirtyRect);
         *newBottom = root->bestTruncatedAt();
         if (*newBottom == 0) {