Title: [102460] trunk/Source/WebCore
- Revision
- 102460
- Author
- [email protected]
- Date
- 2011-12-09 11:34:56 -0800 (Fri, 09 Dec 2011)
Log Message
WebScrollbarPartAnimation should only know about the scrollbar it's animating
https://bugs.webkit.org/show_bug.cgi?id=74192
Reviewed by Sam Weinig.
* platform/mac/ScrollAnimatorMac.mm:
(-[WebScrollbarPartAnimation initWithScrollbar:featureToAnimate:animateFrom:animateTo:duration:]):
Change the designated initializer to just take the scrollbar. Also, make the animation non-blocking here
so we don't have to do it in all the call sites.
(-[WebScrollbarPartAnimation startAnimation]):
Update the scrollbar painter.
(-[WebScrollbarPartAnimation setCurrentProgress:]):
Just invalidate the scrollbar we're animating.
(-[WebScrollbarPainterDelegate setUpAlphaAnimation:scrollerPainter:part:WebCore::animateAlphaTo:duration:]):
(-[WebScrollbarPainterDelegate scrollerImp:animateUIStateTransitionWithDuration:]):
Update call sites to use the new designated initializer.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (102459 => 102460)
--- trunk/Source/WebCore/ChangeLog 2011-12-09 18:59:21 UTC (rev 102459)
+++ trunk/Source/WebCore/ChangeLog 2011-12-09 19:34:56 UTC (rev 102460)
@@ -1,3 +1,25 @@
+2011-12-09 Anders Carlsson <[email protected]>
+
+ WebScrollbarPartAnimation should only know about the scrollbar it's animating
+ https://bugs.webkit.org/show_bug.cgi?id=74192
+
+ Reviewed by Sam Weinig.
+
+ * platform/mac/ScrollAnimatorMac.mm:
+ (-[WebScrollbarPartAnimation initWithScrollbar:featureToAnimate:animateFrom:animateTo:duration:]):
+ Change the designated initializer to just take the scrollbar. Also, make the animation non-blocking here
+ so we don't have to do it in all the call sites.
+
+ (-[WebScrollbarPartAnimation startAnimation]):
+ Update the scrollbar painter.
+
+ (-[WebScrollbarPartAnimation setCurrentProgress:]):
+ Just invalidate the scrollbar we're animating.
+
+ (-[WebScrollbarPainterDelegate setUpAlphaAnimation:scrollerPainter:part:WebCore::animateAlphaTo:duration:]):
+ (-[WebScrollbarPainterDelegate scrollerImp:animateUIStateTransitionWithDuration:]):
+ Update call sites to use the new designated initializer.
+
2011-12-08 Jocelyn Turcotte <[email protected]>
Inspector: Don't translate the context when rendering the highlights on a tiled layer.
Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm (102459 => 102460)
--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm 2011-12-09 18:59:21 UTC (rev 102459)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm 2011-12-09 19:34:56 UTC (rev 102460)
@@ -274,35 +274,40 @@
@interface WebScrollbarPartAnimation : NSAnimation
{
- RetainPtr<ScrollbarPainter> _scrollerPainter;
+ Scrollbar* _scrollbar;
+ RetainPtr<ScrollbarPainter> _scrollbarPainter;
FeatureToAnimate _featureToAnimate;
- ScrollAnimatorMac* _animator;
CGFloat _startValue;
CGFloat _endValue;
}
-- (id)initWithScrollbarPainter:(ScrollbarPainter)scrollerPainter animate:(FeatureToAnimate)featureToAnimate scrollAnimator:(ScrollAnimatorMac*)scrollAnimator animateFrom:(CGFloat)startValue animateTo:(CGFloat)endValue duration:(NSTimeInterval)duration;
+- (id)initWithScrollbar:(Scrollbar*)scrollbar featureToAnimate:(FeatureToAnimate)featureToAnimate animateFrom:(CGFloat)startValue animateTo:(CGFloat)endValue duration:(NSTimeInterval)duration;
@end
@implementation WebScrollbarPartAnimation
-- (id)initWithScrollbarPainter:(ScrollbarPainter)scrollerPainter animate:(FeatureToAnimate)featureToAnimate scrollAnimator:(ScrollAnimatorMac*)scrollAnimator animateFrom:(CGFloat)startValue animateTo:(CGFloat)endValue duration:(NSTimeInterval)duration
+- (id)initWithScrollbar:(Scrollbar*)scrollbar featureToAnimate:(FeatureToAnimate)featureToAnimate animateFrom:(CGFloat)startValue animateTo:(CGFloat)endValue duration:(NSTimeInterval)duration
{
self = [super initWithDuration:duration animationCurve:NSAnimationEaseInOut];
if (!self)
return nil;
-
- _scrollerPainter = scrollerPainter;
+
+ _scrollbar = scrollbar;
_featureToAnimate = featureToAnimate;
- _animator = scrollAnimator;
_startValue = startValue;
_endValue = endValue;
-
- return self;
+
+ [self setAnimationBlockingMode:NSAnimationNonblocking];
+
+ return self;
}
-- (void)setScrollbarPainter:(ScrollbarPainter)scrollerPainter
+- (void)startAnimation
{
- _scrollerPainter = scrollerPainter;
+ ASSERT(_scrollbar);
+
+ _scrollbarPainter = scrollbarPainterForScrollbar(_scrollbar);
+
+ [super startAnimation];
}
- (void)setStartValue:(CGFloat)startValue
@@ -319,8 +324,7 @@
{
[super setCurrentProgress:progress];
- if (!_animator)
- return;
+ ASSERT(_scrollbar);
CGFloat currentValue;
if (_startValue > _endValue)
@@ -330,21 +334,17 @@
switch (_featureToAnimate) {
case ThumbAlpha:
- [_scrollerPainter.get() setKnobAlpha:currentValue];
+ [_scrollbarPainter.get() setKnobAlpha:currentValue];
break;
case TrackAlpha:
- [_scrollerPainter.get() setTrackAlpha:currentValue];
+ [_scrollbarPainter.get() setTrackAlpha:currentValue];
break;
case UIStateTransition:
- [_scrollerPainter.get() setUiStateTransitionProgress:currentValue];
+ [_scrollbarPainter.get() setUiStateTransitionProgress:currentValue];
break;
}
- // Invalidate the scrollbars so that they paint the animation
- if (Scrollbar* verticalScrollbar = _animator->scrollableArea()->verticalScrollbar())
- verticalScrollbar->invalidate();
- if (Scrollbar* horizontalScrollbar = _animator->scrollableArea()->horizontalScrollbar())
- horizontalScrollbar->invalidate();
+ _scrollbar->invalidate();
}
- (void)scrollAnimatorDestroyed
@@ -352,7 +352,7 @@
BEGIN_BLOCK_OBJC_EXCEPTIONS;
[self stopAnimation];
END_BLOCK_OBJC_EXCEPTIONS;
- _animator = 0;
+ _scrollbar = 0;
}
@end
@@ -477,13 +477,11 @@
[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:duration];
- scrollbarPartAnimation.adoptNS([[WebScrollbarPartAnimation alloc] initWithScrollbarPainter:scrollerPainter
- animate:part == ThumbPart ? ThumbAlpha : TrackAlpha
- scrollAnimator:[self scrollAnimator]
- animateFrom:part == ThumbPart ? [scrollerPainter knobAlpha] : [scrollerPainter trackAlpha]
- animateTo:newAlpha
- duration:duration]);
- [scrollbarPartAnimation.get() setAnimationBlockingMode:NSAnimationNonblocking];
+ scrollbarPartAnimation.adoptNS([[WebScrollbarPartAnimation alloc] initWithScrollbar:_scrollbar
+ featureToAnimate:part == ThumbPart ? ThumbAlpha : TrackAlpha
+ animateFrom:part == ThumbPart ? [scrollerPainter knobAlpha] : [scrollerPainter trackAlpha]
+ animateTo:newAlpha
+ duration:duration]);
[scrollbarPartAnimation.get() startAnimation];
[NSAnimationContext endGrouping];
}
@@ -528,17 +526,14 @@
[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:duration];
- if (!scrollbarPartAnimation) {
- scrollbarPartAnimation.adoptNS([[WebScrollbarPartAnimation alloc] initWithScrollbarPainter:scrollerPainter
- animate:UIStateTransition
- scrollAnimator:[self scrollAnimator]
- animateFrom:[scrollerPainter uiStateTransitionProgress]
- animateTo:1.0
- duration:duration]);
- [scrollbarPartAnimation.get() setAnimationBlockingMode:NSAnimationNonblocking];
- } else {
+ if (!scrollbarPartAnimation)
+ scrollbarPartAnimation.adoptNS([[WebScrollbarPartAnimation alloc] initWithScrollbar:_scrollbar
+ featureToAnimate:UIStateTransition
+ animateFrom:[scrollerPainter uiStateTransitionProgress]
+ animateTo:1.0
+ duration:duration]);
+ else {
// If we don't need to initialize the animation, just reset the values in case they have changed.
- [scrollbarPartAnimation.get() setScrollbarPainter:scrollerPainter];
[scrollbarPartAnimation.get() setStartValue:[scrollerPainter uiStateTransitionProgress]];
[scrollbarPartAnimation.get() setEndValue:1.0];
[scrollbarPartAnimation.get() setDuration:duration];
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes