[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
trey
trey at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:34:02 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 22ed602c1a2aa6572294b6528f8efd0984ea195b
Author: trey <trey at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Apr 4 00:12:30 2003 +0000
WebCore:
3067928 - printing should not break lines in half
3217607 - when printing we should not draw the selection
We leverage the existing knowledge that a couple render object classes had
for adjusting pagination. Wrote 3217705 saying we should add similar
smarts to a few more places.
Reviewed by Darin.
* ForwardingHeaders/qprinter.h: Added.
* khtml/rendering/render_list.cpp:
(RenderListMarker::paintObject): Call our special setBestTruncatedAt instead
of khtml's setTruncatedAt.
* khtml/rendering/render_root.cpp:
(RenderRoot::setBestTruncatedAt): Accumulate the best pagination boundary.
* khtml/rendering/render_root.h:
* khtml/rendering/render_text.cpp:
(RenderText::paintObject): Call our special setBestTruncatedAt instead
of khtml's setTruncatedAt.
* kwq/KWQKHTMLPart.h:
* kwq/KWQKHTMLPart.mm:
(KWQKHTMLPart::paint): Don't draw the debugging red background when printing.
(KWQKHTMLPart::adjustPageHeight): The meat of the change. Make another
painting pass (with actual painting disabled) to get the pagination boundary
set as a side effect. Return result up to AppKit.
* kwq/KWQPaintDevice.h: devType() made virtual
* kwq/KWQPainter.h:
* kwq/KWQPainter.mm:
(QPainter::QPainter): New constructor for making a printing painter.
(QPainter::device): Return either the Screen or Printer device.
* kwq/KWQPixmap.h: Destructor needed to become virtual.
* kwq/KWQPrinter.h: Implement devType().
* kwq/WebCoreBridge.h:
* kwq/WebCoreBridge.mm:
(-[WebCoreBridge drawRect:]): Setup printer device in our painter if we're
not drawing to the screen.
(-[WebCoreBridge adjustFrames:]): Ditto.
(-[WebCoreBridge adjustPageHeightNew:top:bottom:limit:]): Forward to part.
WebKit:
3067928 - printing should not break lines in half
This is just glue to call the right piece in WebCore.
Reviewed by Darin.
(-[WebHTMLView adjustPageHeightNew:top:bottom:limit:]):
Defer to WebCore to set pagination boundary.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4016 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index cc65c77..d9b68c5 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,44 @@
+2003-04-03 Trey Matteson <trey at apple.com>
+
+ 3067928 - printing should not break lines in half
+ 3217607 - when printing we should not draw the selection
+
+ We leverage the existing knowledge that a couple render object classes had
+ for adjusting pagination. Wrote 3217705 saying we should add similar
+ smarts to a few more places.
+
+ Reviewed by Darin.
+
+ * ForwardingHeaders/qprinter.h: Added.
+ * khtml/rendering/render_list.cpp:
+ (RenderListMarker::paintObject): Call our special setBestTruncatedAt instead
+ of khtml's setTruncatedAt.
+ * khtml/rendering/render_root.cpp:
+ (RenderRoot::setBestTruncatedAt): Accumulate the best pagination boundary.
+ * khtml/rendering/render_root.h:
+ * khtml/rendering/render_text.cpp:
+ (RenderText::paintObject): Call our special setBestTruncatedAt instead
+ of khtml's setTruncatedAt.
+ * kwq/KWQKHTMLPart.h:
+ * kwq/KWQKHTMLPart.mm:
+ (KWQKHTMLPart::paint): Don't draw the debugging red background when printing.
+ (KWQKHTMLPart::adjustPageHeight): The meat of the change. Make another
+ painting pass (with actual painting disabled) to get the pagination boundary
+ set as a side effect. Return result up to AppKit.
+ * kwq/KWQPaintDevice.h: devType() made virtual
+ * kwq/KWQPainter.h:
+ * kwq/KWQPainter.mm:
+ (QPainter::QPainter): New constructor for making a printing painter.
+ (QPainter::device): Return either the Screen or Printer device.
+ * kwq/KWQPixmap.h: Destructor needed to become virtual.
+ * kwq/KWQPrinter.h: Implement devType().
+ * kwq/WebCoreBridge.h:
+ * kwq/WebCoreBridge.mm:
+ (-[WebCoreBridge drawRect:]): Setup printer device in our painter if we're
+ not drawing to the screen.
+ (-[WebCoreBridge adjustFrames:]): Ditto.
+ (-[WebCoreBridge adjustPageHeightNew:top:bottom:limit:]): Forward to part.
+
2003-04-03 Darin Adler <darin at apple.com>
Reviewed by John.
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index cc65c77..d9b68c5 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,44 @@
+2003-04-03 Trey Matteson <trey at apple.com>
+
+ 3067928 - printing should not break lines in half
+ 3217607 - when printing we should not draw the selection
+
+ We leverage the existing knowledge that a couple render object classes had
+ for adjusting pagination. Wrote 3217705 saying we should add similar
+ smarts to a few more places.
+
+ Reviewed by Darin.
+
+ * ForwardingHeaders/qprinter.h: Added.
+ * khtml/rendering/render_list.cpp:
+ (RenderListMarker::paintObject): Call our special setBestTruncatedAt instead
+ of khtml's setTruncatedAt.
+ * khtml/rendering/render_root.cpp:
+ (RenderRoot::setBestTruncatedAt): Accumulate the best pagination boundary.
+ * khtml/rendering/render_root.h:
+ * khtml/rendering/render_text.cpp:
+ (RenderText::paintObject): Call our special setBestTruncatedAt instead
+ of khtml's setTruncatedAt.
+ * kwq/KWQKHTMLPart.h:
+ * kwq/KWQKHTMLPart.mm:
+ (KWQKHTMLPart::paint): Don't draw the debugging red background when printing.
+ (KWQKHTMLPart::adjustPageHeight): The meat of the change. Make another
+ painting pass (with actual painting disabled) to get the pagination boundary
+ set as a side effect. Return result up to AppKit.
+ * kwq/KWQPaintDevice.h: devType() made virtual
+ * kwq/KWQPainter.h:
+ * kwq/KWQPainter.mm:
+ (QPainter::QPainter): New constructor for making a printing painter.
+ (QPainter::device): Return either the Screen or Printer device.
+ * kwq/KWQPixmap.h: Destructor needed to become virtual.
+ * kwq/KWQPrinter.h: Implement devType().
+ * kwq/WebCoreBridge.h:
+ * kwq/WebCoreBridge.mm:
+ (-[WebCoreBridge drawRect:]): Setup printer device in our painter if we're
+ not drawing to the screen.
+ (-[WebCoreBridge adjustFrames:]): Ditto.
+ (-[WebCoreBridge adjustPageHeightNew:top:bottom:limit:]): Forward to part.
+
2003-04-03 Darin Adler <darin at apple.com>
Reviewed by John.
diff --git a/WebCore/ForwardingHeaders/qprinter.h b/WebCore/ForwardingHeaders/qprinter.h
new file mode 100644
index 0000000..fb301b6
--- /dev/null
+++ b/WebCore/ForwardingHeaders/qprinter.h
@@ -0,0 +1 @@
+#include "KWQPrinter.h"
diff --git a/WebCore/khtml/rendering/render_list.cpp b/WebCore/khtml/rendering/render_list.cpp
index 283a4de..8a9552c 100644
--- a/WebCore/khtml/rendering/render_list.cpp
+++ b/WebCore/khtml/rendering/render_list.cpp
@@ -395,7 +395,11 @@ void RenderListMarker::paintObject(QPainter *p, int, int _y,
{
RenderRoot *rootObj = root();
if (_ty < rootObj->truncatedAt())
+#if APPLE_CHANGES
+ rootObj->setBestTruncatedAt(_ty, this);
+#else
rootObj->setTruncatedAt(_ty);
+#endif
// Let's print this on the next page.
return;
}
diff --git a/WebCore/khtml/rendering/render_root.cpp b/WebCore/khtml/rendering/render_root.cpp
index e7a2b2c..165233a 100644
--- a/WebCore/khtml/rendering/render_root.cpp
+++ b/WebCore/khtml/rendering/render_root.cpp
@@ -629,3 +629,17 @@ int RenderRoot::docWidth() const
}
return w;
}
+
+#if APPLE_CHANGES
+// The idea here is to take into account what object is moving the pagination point, and
+// thus choose the best place to chop it.
+void RenderRoot::setBestTruncatedAt(int y, RenderObject *forRenderer)
+{
+ // prefer the widest object who tries to move the pagination point
+ int width = forRenderer->width();
+ if (width > m_truncatorWidth) {
+ m_truncatorWidth = width;
+ m_bestTruncatedAt = y;
+ }
+}
+#endif
diff --git a/WebCore/khtml/rendering/render_root.h b/WebCore/khtml/rendering/render_root.h
index 0d0ff01..fa9c0c0 100644
--- a/WebCore/khtml/rendering/render_root.h
+++ b/WebCore/khtml/rendering/render_root.h
@@ -68,7 +68,17 @@ public:
bool printingMode() const { return m_printingMode; }
void setPrintImages(bool enable) { m_printImages = enable; }
bool printImages() const { return m_printImages; }
+#if APPLE_CHANGES
+ void setTruncatedAt(int y) { m_truncatedAt = y; m_bestTruncatedAt = m_truncatorWidth = 0; }
+ void setBestTruncatedAt(int y, RenderObject *forRenderer);
+ int bestTruncatedAt() const { return m_bestTruncatedAt; }
+private:
+ int m_bestTruncatedAt;
+ int m_truncatorWidth;
+public:
+#else
void setTruncatedAt(int y) { m_truncatedAt = y; }
+#endif
int truncatedAt() const { return m_truncatedAt; }
virtual void setWidth( int width ) { m_rootWidth = m_width = width; }
diff --git a/WebCore/khtml/rendering/render_text.cpp b/WebCore/khtml/rendering/render_text.cpp
index e14be94..752a5de 100644
--- a/WebCore/khtml/rendering/render_text.cpp
+++ b/WebCore/khtml/rendering/render_text.cpp
@@ -653,7 +653,11 @@ void RenderText::paintObject(QPainter *p, int /*x*/, int y, int /*w*/, int h,
{
RenderRoot *rootObj = root();
if (ty+s->m_y < rootObj->truncatedAt())
- rootObj->setTruncatedAt(ty+s->m_y);
+#if APPLE_CHANGES
+ rootObj->setBestTruncatedAt(ty+s->m_y, this);
+#else
+ rootObj->setTruncatedAt(ty+s->m_y);
+#endif
// Let's stop here.
break;
}
diff --git a/WebCore/kwq/KWQKHTMLPart.h b/WebCore/kwq/KWQKHTMLPart.h
index 5cfd895..e62552c 100644
--- a/WebCore/kwq/KWQKHTMLPart.h
+++ b/WebCore/kwq/KWQKHTMLPart.h
@@ -145,6 +145,8 @@ public:
void paint(QPainter *, const QRect &);
void paintSelectionOnly(QPainter *p, const QRect &rect);
+ void adjustPageHeight(float *newBottom, float oldTop, float oldBottom, float bottomLimit);
+
void createEmptyDocument();
static WebCoreBridge *bridgeForWidget(const QWidget *);
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index fb3612a..45f86a3 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -45,6 +45,7 @@
#import "KWQPageState.h"
#import "KWQDOMNode.h"
#import "KWQWindowWidget.h"
+#import <KWQPrinter.h>
#import "xml/dom2_eventsimpl.h"
@@ -604,7 +605,10 @@ void KWQKHTMLPart::redirectionTimerStartedOrStopped()
void KWQKHTMLPart::paint(QPainter *p, const QRect &rect)
{
#ifndef NDEBUG
- p->fillRect(rect.x(), rect.y(), rect.width(), rect.height(), QColor(0xFF, 0, 0));
+ bool isPrinting = (p->device()->devType() == QInternal::Printer);
+ if (!isPrinting) {
+ p->fillRect(rect.x(), rect.y(), rect.width(), rect.height(), QColor(0xFF, 0, 0));
+ }
#endif
if (renderer()) {
@@ -623,6 +627,26 @@ void KWQKHTMLPart::paintSelectionOnly(QPainter *p, const QRect &rect)
}
}
+void KWQKHTMLPart::adjustPageHeight(float *newBottom, float oldTop, float oldBottom, float bottomLimit)
+{
+ RenderRoot *root = static_cast<khtml::RenderRoot *>(xmlDocImpl()->renderer());
+ if (root) {
+ // Use a printer device, with painting disabled for the pagination phase
+ QPainter painter(true);
+ painter.setPaintingDisabled(true);
+
+ root->setTruncatedAt((int)floor(oldBottom));
+ root->layer()->paint(&painter, 0, (int)floor(oldTop),
+ root->docWidth(), (int)ceil(oldBottom-oldTop), false);
+ *newBottom = root->bestTruncatedAt();
+ if (*newBottom == 0) {
+ *newBottom = oldBottom;
+ }
+ } else {
+ *newBottom = oldBottom;
+ }
+}
+
RenderObject *KWQKHTMLPart::renderer()
{
DocumentImpl *doc = xmlDocImpl();
diff --git a/WebCore/kwq/KWQPaintDevice.h b/WebCore/kwq/KWQPaintDevice.h
index a8849cd..5fbe98f 100644
--- a/WebCore/kwq/KWQPaintDevice.h
+++ b/WebCore/kwq/KWQPaintDevice.h
@@ -34,7 +34,7 @@ struct QInternal {
class QPaintDevice {
public:
- static QInternal::DeviceType devType() { return QInternal::NotPrinter; }
+ virtual QInternal::DeviceType devType() { return QInternal::NotPrinter; }
};
#endif
diff --git a/WebCore/kwq/KWQPainter.h b/WebCore/kwq/KWQPainter.h
index 87cf32e..6ab7d2a 100644
--- a/WebCore/kwq/KWQPainter.h
+++ b/WebCore/kwq/KWQPainter.h
@@ -47,9 +47,10 @@ public:
typedef enum { RTL, LTR } TextDirection;
QPainter();
+ QPainter(bool forPrinting);
~QPainter();
-
- QPaintDevice *device() const { return 0; }
+
+ QPaintDevice *device() const;
const QFont &font() const;
void setFont(const QFont &);
@@ -112,6 +113,7 @@ private:
void _updateRenderer(NSString **families);
QPainterPrivate *data;
+ bool _isForPrinting;
};
#endif
diff --git a/WebCore/kwq/KWQPainter.mm b/WebCore/kwq/KWQPainter.mm
index fef8f4a..afcb381 100644
--- a/WebCore/kwq/KWQPainter.mm
+++ b/WebCore/kwq/KWQPainter.mm
@@ -29,6 +29,8 @@
#import "KWQPixmap.h"
#import "KWQPtrStack.h"
#import "KWQPointArray.h"
+#import "KWQPaintDevice.h"
+#import "KWQPrinter.h"
#import "KWQAssertions.h"
#import "KWQTextRendererFactory.h"
@@ -56,15 +58,31 @@ struct QPainterPrivate {
QFont textRendererFont;
};
-QPainter::QPainter() : data(new QPainterPrivate)
+QPainter::QPainter() : data(new QPainterPrivate), _isForPrinting(false)
{
}
+QPainter::QPainter(bool forPrinting) : data(new QPainterPrivate)
+{
+ _isForPrinting = forPrinting;
+}
+
QPainter::~QPainter()
{
delete data;
}
-
+
+QPaintDevice *QPainter::device() const
+{
+ if (_isForPrinting) {
+ static QPrinter thePrinter;
+ return &thePrinter;
+ } else {
+ static QPaintDevice theScreen;
+ return &theScreen;
+ }
+}
+
const QFont &QPainter::font() const
{
return data->state.font;
diff --git a/WebCore/kwq/KWQPixmap.h b/WebCore/kwq/KWQPixmap.h
index 84cfbed..82baa13 100644
--- a/WebCore/kwq/KWQPixmap.h
+++ b/WebCore/kwq/KWQPixmap.h
@@ -52,7 +52,7 @@ public:
QPixmap(const QByteArray&);
QPixmap(int, int);
QPixmap(const QPixmap &);
- ~QPixmap();
+ virtual ~QPixmap();
bool isNull() const;
diff --git a/WebCore/kwq/KWQPrinter.h b/WebCore/kwq/KWQPrinter.h
index bd91186..38bdbe0 100644
--- a/WebCore/kwq/KWQPrinter.h
+++ b/WebCore/kwq/KWQPrinter.h
@@ -26,12 +26,16 @@
#ifndef KWQPRINTER_H_
#define KWQPRINTER_H_
-class QPrinter {
+#include "KWQPaintDevice.h"
+
+class QPrinter : public QPaintDevice {
public:
typedef enum {
PrinterResolution,
ScreenResolution
} PrinterMode;
+
+ virtual QInternal::DeviceType devType() { return QInternal::Printer; }
};
#endif /* KWQPRINTER_H_ */
diff --git a/WebCore/kwq/WebCoreBridge.h b/WebCore/kwq/WebCoreBridge.h
index ba1c4bd..0a334e1 100644
--- a/WebCore/kwq/WebCoreBridge.h
+++ b/WebCore/kwq/WebCoreBridge.h
@@ -146,6 +146,7 @@ enum FrameBorderStyle {
- (BOOL)needsLayout;
- (void)adjustFrames:(NSRect)rect;
- (void)drawRect:(NSRect)rect;
+- (void)adjustPageHeightNew:(float *)newBottom top:(float)oldTop bottom:(float)oldBottom limit:(float)bottomLimit;
- (void)mouseDown:(NSEvent *)event;
- (void)mouseUp:(NSEvent *)event;
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index 7e73a8d..f99c191 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -54,6 +54,7 @@ using khtml::RenderWidget;
#import "KWQPageState.h"
#import "KWQRenderTreeDebug.h"
#import "KWQView.h"
+#import "KWQPrinter.h"
#import "WebCoreDOMPrivate.h"
#import "WebCoreImageRenderer.h"
@@ -335,8 +336,8 @@ static bool initializedObjectCacheSize = FALSE;
- (void)drawRect:(NSRect)rect
{
- QPainter p;
- [self drawRect:rect withPainter:&p];
+ QPainter painter(![[NSGraphicsContext currentContext] isDrawingToScreen]);
+ [self drawRect:rect withPainter:&painter];
}
- (void)adjustFrames:(NSRect)rect
@@ -346,9 +347,15 @@ static bool initializedObjectCacheSize = FALSE;
// layout and do a draw with rendering disabled to
// correctly adjust the frames.
[self forceLayout];
- QPainter p;
- p.setPaintingDisabled(YES);
- [self drawRect:rect withPainter:&p];
+ QPainter painter(![[NSGraphicsContext currentContext] isDrawingToScreen]);
+ painter.setPaintingDisabled(YES);
+ [self drawRect:rect withPainter:&painter];
+}
+
+// Vertical pagination hook from AppKit
+- (void)adjustPageHeightNew:(float *)newBottom top:(float)oldTop bottom:(float)oldBottom limit:(float)bottomLimit
+{
+ _part->adjustPageHeight(newBottom, oldTop, oldBottom, bottomLimit);
}
- (NSObject *)copyDOMNode:(NodeImpl *)node copier:(id <WebCoreDOMTreeCopier>)copier
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 9079240..89e01cb 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,14 @@
+2003-04-03 Trey Matteson <trey at apple.com>
+
+ 3067928 - printing should not break lines in half
+
+ This is just glue to call the right piece in WebCore.
+
+ Reviewed by Darin.
+
+ (-[WebHTMLView adjustPageHeightNew:top:bottom:limit:]):
+ Defer to WebCore to set pagination boundary.
+
2003-04-03 Richard Williamson <rjw at apple.com>
As requested by Nancy, drop "Is" and "Are" from setters,
diff --git a/WebKit/WebView.subproj/WebHTMLView.m b/WebKit/WebView.subproj/WebHTMLView.m
index 9d704ba..ca1214d 100644
--- a/WebKit/WebView.subproj/WebHTMLView.m
+++ b/WebKit/WebView.subproj/WebHTMLView.m
@@ -790,6 +790,11 @@
}
}
+- (void)adjustPageHeightNew:(float *)newBottom top:(float)oldTop bottom:(float)oldBottom limit:(float)bottomLimit
+{
+ [[self _bridge] adjustPageHeightNew:newBottom top:oldTop bottom:oldBottom limit:bottomLimit];
+}
+
- (void)beginDocument
{
// Must do this explicit display here, because otherwise the view might redisplay while the print
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list