From b3dfce7b5aff6a4ed3bb3f39cb1009423dc1b84d Mon Sep 17 00:00:00 2001 From: Martin Carlberg Date: Tue, 31 Mar 2015 17:30:57 +0200 Subject: [PATCH] Fixed: Compared the rects minimum x value with it self instead of the visible minimum x value. Also fixed the test case to catch this. --- AppKit/CPView.j | 2 +- Tests/AppKit/CPScrollViewTest.j | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/AppKit/CPView.j b/AppKit/CPView.j index 4b526d274..324128a0c 100644 --- a/AppKit/CPView.j +++ b/AppKit/CPView.j @@ -2730,7 +2730,7 @@ setBoundsOrigin: doesItFitForWidth = documentViewVisibleRect.size.width >= rectInDocumentView.size.width; // One of the following has to be true since our current visible rect didn't contain aRect. - if (rectInDocumentViewMinX < rectInDocumentViewMinX && doesItFitForWidth) + if (rectInDocumentViewMinX < documentViewVisibleRectMinX && doesItFitForWidth) // Scroll to left edge of aRect as it is to the left of the visible rect and it fit inside scrollPoint.x = rectInDocumentViewMinX; else if (CGRectGetMaxX(rectInDocumentView) > CGRectGetMaxX(documentViewVisibleRect) && doesItFitForWidth) diff --git a/Tests/AppKit/CPScrollViewTest.j b/Tests/AppKit/CPScrollViewTest.j index 40a92749e..320ecb263 100644 --- a/Tests/AppKit/CPScrollViewTest.j +++ b/Tests/AppKit/CPScrollViewTest.j @@ -229,7 +229,7 @@ [scrollView setDocumentView:documentView]; - [textField1 setFrameOrigin:CGPointMake(0, 0)]; + [textField1 setFrameOrigin:CGPointMake(10, 10)]; [textField2 setFrameOrigin:CGPointMake(500, 500)]; [documentView addSubview:textField1]; @@ -260,7 +260,7 @@ visibleRect = [documentView visibleRect]; // We should now be back at top left corner - [self assertPoint:CGPointMake(0, 0) equals:visibleRect.origin message:@"VisibleRect origin not at top left corner again"]; + [self assertPoint:CGPointMake(10, 10) equals:visibleRect.origin message:@"VisibleRect origin not at top left corner again"]; // Try to scroll again and it should not scroll hasScrolled = [textField1 scrollRectToVisible:[textField1 bounds]];