[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

darin darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 06:30:59 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 24484453a9dfbf9d9151018ea9ad2c2a8d135712
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Aug 13 16:45:30 2002 +0000

    	Some QRegion fixes inspired by Dave's clipping work.
    
            * kwq/qt/qregion.h: Add setClip, remove getNSBezierPath.
            * kwq/KWQRegion.mm:
            (NSMakePoint): Added. Helper function; could go in a header some day.
            (NSMakeRect): Added. Helper function; could go in a header some day.
            (MakeQRect): Added. Helper function; could go in a header some day.
            (QRegion::QRegion): Make a paths array instead of a single path. Also, change things
    	so we actually copy the paths. The old code might translate a path that was shared
    	by two QRegion objects.
            (QRegion::intersect): Merge the paths arrays of the two passed-in paths.
            (QRegion::contains): Return true only if all paths in the array contain the point.
            (QRegion::isNull): Return true if any of the paths in the array are empty.
            (QRegion::translate): Translate all the paths in the array.
            (QRegion::boundingRect): Return the intersection of the bounding rects of all the
    	paths in the array.
            (QRegion::setClip): Call setClip on the first path, and addClip on the others.
    
            * kwq/KWQPainter.mm: (QPainter::setClipRegion): Use QRegion::setClip().
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1807 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index 5084080..fabd08a 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,25 @@
+2002-08-13  Darin Adler  <darin at apple.com>
+
+	Some QRegion fixes inspired by Dave's clipping work.
+
+        * kwq/qt/qregion.h: Add setClip, remove getNSBezierPath.
+        * kwq/KWQRegion.mm:
+        (NSMakePoint): Added. Helper function; could go in a header some day.
+        (NSMakeRect): Added. Helper function; could go in a header some day.
+        (MakeQRect): Added. Helper function; could go in a header some day.
+        (QRegion::QRegion): Make a paths array instead of a single path. Also, change things
+	so we actually copy the paths. The old code might translate a path that was shared
+	by two QRegion objects.
+        (QRegion::intersect): Merge the paths arrays of the two passed-in paths.
+        (QRegion::contains): Return true only if all paths in the array contain the point.
+        (QRegion::isNull): Return true if any of the paths in the array are empty.
+        (QRegion::translate): Translate all the paths in the array.
+        (QRegion::boundingRect): Return the intersection of the bounding rects of all the
+	paths in the array.
+        (QRegion::setClip): Call setClip on the first path, and addClip on the others.
+
+        * kwq/KWQPainter.mm: (QPainter::setClipRegion): Use QRegion::setClip().
+
 2002-08-12  David Hyatt  <hyatt at apple.com>
 
 	Reverting a change that I unintentionally checked in last
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 5084080..fabd08a 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,25 @@
+2002-08-13  Darin Adler  <darin at apple.com>
+
+	Some QRegion fixes inspired by Dave's clipping work.
+
+        * kwq/qt/qregion.h: Add setClip, remove getNSBezierPath.
+        * kwq/KWQRegion.mm:
+        (NSMakePoint): Added. Helper function; could go in a header some day.
+        (NSMakeRect): Added. Helper function; could go in a header some day.
+        (MakeQRect): Added. Helper function; could go in a header some day.
+        (QRegion::QRegion): Make a paths array instead of a single path. Also, change things
+	so we actually copy the paths. The old code might translate a path that was shared
+	by two QRegion objects.
+        (QRegion::intersect): Merge the paths arrays of the two passed-in paths.
+        (QRegion::contains): Return true only if all paths in the array contain the point.
+        (QRegion::isNull): Return true if any of the paths in the array are empty.
+        (QRegion::translate): Translate all the paths in the array.
+        (QRegion::boundingRect): Return the intersection of the bounding rects of all the
+	paths in the array.
+        (QRegion::setClip): Call setClip on the first path, and addClip on the others.
+
+        * kwq/KWQPainter.mm: (QPainter::setClipRegion): Use QRegion::setClip().
+
 2002-08-12  David Hyatt  <hyatt at apple.com>
 
 	Reverting a change that I unintentionally checked in last
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 5084080..fabd08a 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,25 @@
+2002-08-13  Darin Adler  <darin at apple.com>
+
+	Some QRegion fixes inspired by Dave's clipping work.
+
+        * kwq/qt/qregion.h: Add setClip, remove getNSBezierPath.
+        * kwq/KWQRegion.mm:
+        (NSMakePoint): Added. Helper function; could go in a header some day.
+        (NSMakeRect): Added. Helper function; could go in a header some day.
+        (MakeQRect): Added. Helper function; could go in a header some day.
+        (QRegion::QRegion): Make a paths array instead of a single path. Also, change things
+	so we actually copy the paths. The old code might translate a path that was shared
+	by two QRegion objects.
+        (QRegion::intersect): Merge the paths arrays of the two passed-in paths.
+        (QRegion::contains): Return true only if all paths in the array contain the point.
+        (QRegion::isNull): Return true if any of the paths in the array are empty.
+        (QRegion::translate): Translate all the paths in the array.
+        (QRegion::boundingRect): Return the intersection of the bounding rects of all the
+	paths in the array.
+        (QRegion::setClip): Call setClip on the first path, and addClip on the others.
+
+        * kwq/KWQPainter.mm: (QPainter::setClipRegion): Use QRegion::setClip().
+
 2002-08-12  David Hyatt  <hyatt at apple.com>
 
 	Reverting a change that I unintentionally checked in last
diff --git a/WebCore/kwq/KWQPainter.mm b/WebCore/kwq/KWQPainter.mm
index 0e162ab..2184b82 100644
--- a/WebCore/kwq/KWQPainter.mm
+++ b/WebCore/kwq/KWQPainter.mm
@@ -402,7 +402,7 @@ void QPainter::fillRect(int x, int y, int w, int h, const QBrush &brush)
 void QPainter::setClipRegion(const QRegion &region)
 {
     data->state.clip = region;
-    [(region.getNSBezierPath()) setClip];
+    region.setClip();
 }
 
 const QRegion &QPainter::clipRegion() const
diff --git a/WebCore/kwq/KWQRegion.h b/WebCore/kwq/KWQRegion.h
index 089bdb5..ffea3b4 100644
--- a/WebCore/kwq/KWQRegion.h
+++ b/WebCore/kwq/KWQRegion.h
@@ -31,9 +31,9 @@
 #include <qrect.h>
 
 #ifdef __OBJC__
- at class NSBezierPath;
+ at class NSArray;
 #else
-class NSBezierPath;
+class NSArray;
 #endif
 
 class QRegion {
@@ -44,21 +44,24 @@ public:
     QRegion(const QRect &);
     QRegion(int, int, int, int, RegionType=Rectangle);
     QRegion(const QPointArray &);
-    QRegion(const QRegion &);
     ~QRegion();
 
-    QRegion intersect(const QRegion &) const;
-    bool contains(const QPoint &) const;
+    QRegion(const QRegion &);
+    QRegion &operator=(const QRegion &);
+
     bool isNull() const;
-    void translate(int deltaX, int deltaY);
+    bool contains(const QPoint &) const;
     QRect boundingRect() const;
 
-    QRegion &operator=(const QRegion &);
+    void translate(int deltaX, int deltaY);
+    QRegion intersect(const QRegion &) const;
 
-    NSBezierPath* getNSBezierPath() const { return path; }
+    void setClip() const;
 
 private:
-    NSBezierPath *path;    
+    QRegion(NSArray *);
+    
+    NSArray *paths;    
 };
 
 #endif
diff --git a/WebCore/kwq/KWQRegion.mm b/WebCore/kwq/KWQRegion.mm
index 433bbf5..e206c7c 100644
--- a/WebCore/kwq/KWQRegion.mm
+++ b/WebCore/kwq/KWQRegion.mm
@@ -27,93 +27,160 @@
 
 #import <kwqdebug.h>
 
+// FIXME: Find some header to put these inline functions in, because they are widely useful.
+
+inline NSPoint NSMakePoint(const QPoint &qp)
+{
+    NSPoint p;
+    p.x = qp.x();
+    p.y = qp.y();
+    return p;
+}
+
+inline NSRect NSMakeRect(const QRect &qr)
+{
+    NSRect r;
+    r.origin.x = qr.x();
+    r.origin.y = qr.y();
+    r.size.width = qr.width();
+    r.size.height = qr.height();
+    return r;
+}
+
+inline QRect MakeQRect(const NSRect &r)
+{
+    return QRect((int)r.origin.x, (int)r.origin.y, (int)r.size.width, (int)r.size.height);
+}
+
 QRegion::QRegion()
-    : path(nil)
+    : paths([[NSArray alloc] init])
 {
 }
 
 QRegion::QRegion(const QRect &rect)
-    : path([[NSBezierPath bezierPathWithRect:NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height())] retain])
+    : paths([[NSArray arrayWithObject:[NSBezierPath bezierPathWithRect:NSMakeRect(rect)]] retain])
 {
 }
 
 QRegion::QRegion(int x, int y, int w, int h, RegionType t)
 {
-    NSRect rect;
-    
-    rect = NSMakeRect(x,y,w,h);
-
     if (t == Rectangle) {
-        path = [[NSBezierPath bezierPathWithRect:rect] retain];
-    }
-    else { // Ellipse
-        path = [[NSBezierPath bezierPathWithOvalInRect:rect] retain];
+        paths = [[NSArray arrayWithObject:[NSBezierPath bezierPathWithRect:NSMakeRect(x, y, w, h)]] retain];
+    } else { // Ellipse
+        paths = [[NSArray arrayWithObject:[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(x, y, w, h)]] retain];
     }
 }
 
 QRegion::QRegion(const QPointArray &arr)
-    : path([[NSBezierPath alloc] init])
 {
-    [path moveToPoint:NSMakePoint(arr[0].x(), arr[0].y())];
+    NSBezierPath *path = [[NSBezierPath alloc] init];
+    [path moveToPoint:NSMakePoint(arr[0])];
     for (uint i = 1; i < arr.count(); ++i) {
-        [path lineToPoint:NSMakePoint(arr[i].x(), arr[i].y())];
+        [path lineToPoint:NSMakePoint(arr[i])];
     }
+    paths = [[NSArray arrayWithObject:path] retain];
+    [path release];
 }
 
-QRegion::QRegion(const QRegion &other)
-    : path([other.path copy])
+QRegion::QRegion(NSArray *array)
+    : paths([[NSArray alloc] initWithArray:array copyItems:true])
 {
 }
 
 QRegion::~QRegion()
 {
-    [path release];
+    [paths release];
 }
 
-QRegion QRegion::intersect(const QRegion &region) const
+QRegion::QRegion(const QRegion &other)
+    : paths([[NSArray alloc] initWithArray:other.paths copyItems:true])
 {
-    _logNotYetImplemented();
-    return region;
 }
 
-bool QRegion::contains(const QPoint &point) const
+QRegion &QRegion::operator=(const QRegion &other)
 {
-    return path && [path containsPoint:NSMakePoint(point.x(), point.y())];
+    if (this == &other)
+        return *this;
+    [paths release];
+    paths = [[NSArray alloc] initWithArray:other.paths copyItems:true];
+    return *this;
 }
 
-bool QRegion::isNull() const
+QRegion QRegion::intersect(const QRegion &other) const
 {
-    return path == nil || [path isEmpty];
+    return [paths arrayByAddingObjectsFromArray:other.paths];
 }
 
-QRegion &QRegion::operator=(const QRegion &other)
+bool QRegion::contains(const QPoint &point) const
 {
-    NSBezierPath *newPath;
-    
-    newPath = [other.path copy];
-    [path release];
-    path = newPath;
-    return *this;
+    if ([paths count] == 0) {
+        return false;
+    }
+    NSEnumerator *e = [paths objectEnumerator];
+    NSBezierPath *path;
+    while ((path = [e nextObject])) {
+        if (![path containsPoint:NSMakePoint(point.x(), point.y())]) {
+            return false;
+        }
+    }
+    return true;
 }
 
-void QRegion::translate(int deltaX, int deltaY)
+bool QRegion::isNull() const
 {
-    if (!path) {
-        return;
+    // FIXME: Note that intersection can lead to an empty QRegion that
+    // still won't return true for isNull. But this doesn't matter since
+    // intersection is hardly used in KHTML, and never with isNull.
+    if ([paths count] == 0) {
+        return true;
     }
-    
+    NSEnumerator *e = [paths objectEnumerator];
+    NSBezierPath *path;
+    while ((path = [e nextObject])) {
+        if ([path isEmpty]) {
+            return true;
+        }
+    }
+    return false;
+}
+
+void QRegion::translate(int deltaX, int deltaY)
+{
     NSAffineTransform *translation = [[NSAffineTransform alloc] init];
     [translation translateXBy:deltaX yBy:deltaY];
-    [path transformUsingAffineTransform:translation];
+    [paths makeObjectsPerformSelector:@selector(transformUsingAffineTransform:) withObject:translation];    
     [translation release];
 }
 
 QRect QRegion::boundingRect() const
 {
-    if (!path) {
+    // Note that this returns the intersection of the bounds of all the paths.
+    // That's not quite the same as the bounds of the intersection of all the
+    // paths, but that doesn't matter because intersection is hardly used at all.
+    
+    NSEnumerator *e = [paths objectEnumerator];
+    NSBezierPath *path = [e nextObject];
+    if (path == nil) {
 	return QRect();
     }
+    NSRect bounds = [path bounds];
+    while ((path = [e nextObject])) {
+        bounds = NSIntersectionRect(bounds, [path bounds]);
+    }
+    return MakeQRect(bounds);
+}
 
+void QRegion::setClip() const
+{
+    NSEnumerator *e = [paths objectEnumerator];
+    NSBezierPath *path = [e nextObject];
+    if (path == nil) {
+        [[NSBezierPath bezierPath] setClip];
+        return;
+    }
+    [path setClip];
     NSRect bounds = [path bounds];
-    return QRect((int)bounds.origin.x, (int)bounds.origin.y, (int)bounds.size.width, (int)bounds.size.height);
+    while ((path = [e nextObject])) {
+        [path addClip];
+    }
 }
diff --git a/WebCore/kwq/qt/qregion.h b/WebCore/kwq/qt/qregion.h
index 089bdb5..ffea3b4 100644
--- a/WebCore/kwq/qt/qregion.h
+++ b/WebCore/kwq/qt/qregion.h
@@ -31,9 +31,9 @@
 #include <qrect.h>
 
 #ifdef __OBJC__
- at class NSBezierPath;
+ at class NSArray;
 #else
-class NSBezierPath;
+class NSArray;
 #endif
 
 class QRegion {
@@ -44,21 +44,24 @@ public:
     QRegion(const QRect &);
     QRegion(int, int, int, int, RegionType=Rectangle);
     QRegion(const QPointArray &);
-    QRegion(const QRegion &);
     ~QRegion();
 
-    QRegion intersect(const QRegion &) const;
-    bool contains(const QPoint &) const;
+    QRegion(const QRegion &);
+    QRegion &operator=(const QRegion &);
+
     bool isNull() const;
-    void translate(int deltaX, int deltaY);
+    bool contains(const QPoint &) const;
     QRect boundingRect() const;
 
-    QRegion &operator=(const QRegion &);
+    void translate(int deltaX, int deltaY);
+    QRegion intersect(const QRegion &) const;
 
-    NSBezierPath* getNSBezierPath() const { return path; }
+    void setClip() const;
 
 private:
-    NSBezierPath *path;    
+    QRegion(NSArray *);
+    
+    NSArray *paths;    
 };
 
 #endif

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list