Permalink
Browse files

Merge pull request #2492 from didierkorthoudt/cpview-updateTA-recursi…

…ve-bug

Fixed: CPView setFrameSize was calling _updateTrackingAreas too often + empty overlappingTA test
  • Loading branch information...
2 parents bea03de + e0fab80 commit 969d1dff2a36ce073758605253cc29a8c2d86d09 @mrcarlberg mrcarlberg committed on GitHub Oct 13, 2016
Showing with 18 additions and 15 deletions.
  1. +15 −15 AppKit/CPView.j
  2. +3 −0 AppKit/CPWindow/CPWindow.j
View
@@ -1030,7 +1030,7 @@ var CPViewHighDPIDrawingEnabled = YES;
[[self superview] viewFrameChanged:[[CPNotification alloc] initWithName:CPViewFrameDidChangeNotification object:self userInfo:nil]];
if (!_inhibitUpdateTrackingAreas)
- [self _updateTrackingAreas];
+ [self _updateTrackingAreasWithRecursion:YES];
}
/*!
@@ -1103,7 +1103,7 @@ var CPViewHighDPIDrawingEnabled = YES;
#endif
if (!_inhibitUpdateTrackingAreas && !_inhibitFrameAndBoundsChangedNotifications)
- [self _updateTrackingAreas];
+ [self _updateTrackingAreasWithRecursion:YES];
}
/*!
@@ -1257,7 +1257,7 @@ var CPViewHighDPIDrawingEnabled = YES;
[[self superview] viewFrameChanged:[[CPNotification alloc] initWithName:CPViewFrameDidChangeNotification object:self userInfo:nil]];
if (!_inhibitUpdateTrackingAreas && !_inhibitFrameAndBoundsChangedNotifications)
- [self _updateTrackingAreas];
+ [self _updateTrackingAreasWithRecursion:!_autoresizesSubviews];
}
/*!
@@ -1306,7 +1306,7 @@ var CPViewHighDPIDrawingEnabled = YES;
[[self superview] viewBoundsChanged:[[CPNotification alloc] initWithName:CPViewBoundsDidChangeNotification object:self userInfo:nil]];
if (!_inhibitUpdateTrackingAreas)
- [self _updateTrackingAreas];
+ [self _updateTrackingAreasWithRecursion:YES];
}
/*!
@@ -1374,7 +1374,7 @@ var CPViewHighDPIDrawingEnabled = YES;
[[self superview] viewBoundsChanged:[[CPNotification alloc] initWithName:CPViewBoundsDidChangeNotification object:self userInfo:nil]];
if (!_inhibitUpdateTrackingAreas && !_inhibitFrameAndBoundsChangedNotifications)
- [self _updateTrackingAreas];
+ [self _updateTrackingAreasWithRecursion:YES];
}
/*!
@@ -1418,7 +1418,7 @@ var CPViewHighDPIDrawingEnabled = YES;
[[self superview] viewBoundsChanged:[[CPNotification alloc] initWithName:CPViewBoundsDidChangeNotification object:self userInfo:nil]];
if (!_inhibitUpdateTrackingAreas && !_inhibitFrameAndBoundsChangedNotifications)
- [self _updateTrackingAreas];
+ [self _updateTrackingAreasWithRecursion:YES];
}
@@ -3590,21 +3590,21 @@ setBoundsOrigin:
[_trackingAreas removeObjectIdenticalTo:trackingArea];
}
-- (void)_updateTrackingAreas
+- (void)_updateTrackingAreasWithRecursion:(BOOL)shouldCallRecursively
{
_inhibitUpdateTrackingAreas = YES;
- [self _recursivelyUpdateTrackingAreas];
+ [self _updateTrackingAreasForOwners:[self _calcTrackingAreaOwners]];
- _inhibitUpdateTrackingAreas = NO;
-}
+ if (shouldCallRecursively)
+ {
+ // Now, call _updateTrackingAreasWithRecursion on subviews
-- (void)_recursivelyUpdateTrackingAreas
-{
- [self _updateTrackingAreasForOwners:[self _calcTrackingAreaOwners]];
+ for (var i = 0; i < _subviews.length; i++)
+ [_subviews[i] _updateTrackingAreasWithRecursion:YES];
+ }
- for (var i = 0; i < _subviews.length; i++)
- [_subviews[i] _recursivelyUpdateTrackingAreas];
+ _inhibitUpdateTrackingAreas = NO;
}
- (CPArray)_calcTrackingAreaOwners
@@ -4098,6 +4098,9 @@ var interpolate = function(fromValue, toValue, progress)
[overlappingTrackingAreas addObject:aTrackingArea];
}
+ if (overlappingTrackingAreas.length === 0)
+ return;
+
var frontmostTrackingArea = overlappingTrackingAreas[0],
frontmostView = [frontmostTrackingArea view];

0 comments on commit 969d1df

Please sign in to comment.