+2004-12-06 Darin Adler <darin@apple.com>
+
+ Reviewed by Maciej.
+
+ - fixed <rdar://problem/3906327> Select All of a large document is slow (>15 secs on my machine for attached specimen)
+
+ * kwq/KWQScrollView.mm: (QScrollView::updateContents): Intersect with visibleRect before calling through
+ to NSView to dirty; NSView could also be more efficient in this case (I filed 3906343).
+
2004-12-06 John Sullivan <sullivan@apple.com>
Darin found what appears to be the real leak that we were falsely blaming
void QScrollView::updateContents(const QRect &rect, bool now)
{
KWQ_BLOCK_EXCEPTIONS;
- NSView * view = getView();
+
+ NSView *view = getView();
if ([view _KWQ_isScrollView])
view = getDocumentView();
- if (now)
- [view displayRect: rect];
- else
- [view setNeedsDisplayInRect:rect];
+ // Checking for rect visibility is an important optimization for the case of
+ // Select All of a large document. AppKit does not do this check, and so ends
+ // up building a large complicated NSRegion if we don't perform the check.
+ NSRect dirtyRect = NSIntersectionRect(rect, [view visibleRect]);
+ if (!NSIsEmptyRect(dirtyRect)) {
+ if (now)
+ [view displayRect:dirtyRect];
+ else
+ [view setNeedsDisplayInRect:dirtyRect];
+ }
+
KWQ_UNBLOCK_EXCEPTIONS;
}