Title: [229419] trunk/Source/WebCore
- Revision
- 229419
- Author
- [email protected]
- Date
- 2018-03-08 11:12:45 -0800 (Thu, 08 Mar 2018)
Log Message
NSAnimation is not working in the WebContent process when WindowServer access is blocked.
https://bugs.webkit.org/show_bug.cgi?id=183291
Reviewed by Dean Jackson.
The animation can be implemented by using an NSTimer instead. Use the existing Bezier timing
function to create a smooth animation.
No new tests. This code is used to fade scrollbars in and out by animating the alpha value.
This scrollbar setting is not the default in macOS, which makes it non trivial to create
layout tests for this.
* platform/mac/ScrollAnimatorMac.mm:
(-[WebScrollbarPartAnimation initWithScrollbar:featureToAnimate:animateFrom:animateTo:duration:]):
(-[WebScrollbarPartAnimation startAnimation]):
(-[WebScrollbarPartAnimation setCurrentProgress:setCurrentProgress:]):
(-[WebScrollbarPartAnimation invalidate]):
(-[WebScrollbarPartAnimation setDuration:]):
(-[WebScrollbarPartAnimation stopAnimation]):
(-[WebScrollbarPartAnimation setCurrentProgress:]): Deleted.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (229418 => 229419)
--- trunk/Source/WebCore/ChangeLog 2018-03-08 19:06:22 UTC (rev 229418)
+++ trunk/Source/WebCore/ChangeLog 2018-03-08 19:12:45 UTC (rev 229419)
@@ -1,3 +1,26 @@
+2018-03-08 Per Arne Vollan <[email protected]>
+
+ NSAnimation is not working in the WebContent process when WindowServer access is blocked.
+ https://bugs.webkit.org/show_bug.cgi?id=183291
+
+ Reviewed by Dean Jackson.
+
+ The animation can be implemented by using an NSTimer instead. Use the existing Bezier timing
+ function to create a smooth animation.
+
+ No new tests. This code is used to fade scrollbars in and out by animating the alpha value.
+ This scrollbar setting is not the default in macOS, which makes it non trivial to create
+ layout tests for this.
+
+ * platform/mac/ScrollAnimatorMac.mm:
+ (-[WebScrollbarPartAnimation initWithScrollbar:featureToAnimate:animateFrom:animateTo:duration:]):
+ (-[WebScrollbarPartAnimation startAnimation]):
+ (-[WebScrollbarPartAnimation setCurrentProgress:setCurrentProgress:]):
+ (-[WebScrollbarPartAnimation invalidate]):
+ (-[WebScrollbarPartAnimation setDuration:]):
+ (-[WebScrollbarPartAnimation stopAnimation]):
+ (-[WebScrollbarPartAnimation setCurrentProgress:]): Deleted.
+
2018-03-08 Said Abou-Hallawa <[email protected]>
Templatize SVGAnimatedType
Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm (229418 => 229419)
--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm 2018-03-08 19:06:22 UTC (rev 229418)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm 2018-03-08 19:12:45 UTC (rev 229419)
@@ -69,6 +69,8 @@
using WebCore::macScrollbarTheme;
using WebCore::IntRect;
using WebCore::ThumbPart;
+using WebCore::CubicBezierTimingFunction;
+
@interface NSObject (ScrollAnimationHelperDetails)
- (id)initWithDelegate:(id)delegate;
- (void)_stopRun;
@@ -284,7 +286,11 @@
ExpansionTransition
};
+#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101400
@interface WebScrollbarPartAnimation : NSAnimation
+#else
+@interface WebScrollbarPartAnimation : NSObject
+#endif
{
Scrollbar* _scrollbar;
RetainPtr<NSScrollerImp> _scrollerImp;
@@ -291,8 +297,19 @@
FeatureToAnimate _featureToAnimate;
CGFloat _startValue;
CGFloat _endValue;
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
+ NSTimeInterval _duration;
+ RetainPtr<NSTimer> _timer;
+ RetainPtr<NSDate> _startDate;
+ RefPtr<CubicBezierTimingFunction> _timingFunction;
+#endif
}
- (id)initWithScrollbar:(Scrollbar*)scrollbar featureToAnimate:(FeatureToAnimate)featureToAnimate animateFrom:(CGFloat)startValue animateTo:(CGFloat)endValue duration:(NSTimeInterval)duration;
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
+- (void)setCurrentProgress:(NSTimer *)timer;
+- (void)setDuration:(NSTimeInterval)duration;
+- (void)stopAnimation;
+#endif
@end
@implementation WebScrollbarPartAnimation
@@ -299,9 +316,16 @@
- (id)initWithScrollbar:(Scrollbar*)scrollbar featureToAnimate:(FeatureToAnimate)featureToAnimate animateFrom:(CGFloat)startValue animateTo:(CGFloat)endValue duration:(NSTimeInterval)duration
{
+#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101400
self = [super initWithDuration:duration animationCurve:NSAnimationEaseInOut];
if (!self)
return nil;
+#else
+ const NSTimeInterval timeInterval = 0.01;
+ _timer = adoptNS([[NSTimer alloc] initWithFireDate:[NSDate dateWithTimeIntervalSinceNow:0] interval:timeInterval target:self selector:@selector(setCurrentProgress:) userInfo:nil repeats:YES]);
+ _duration = duration;
+ _timingFunction = CubicBezierTimingFunction::create(CubicBezierTimingFunction::EaseInOut);
+#endif
_scrollbar = scrollbar;
_featureToAnimate = featureToAnimate;
@@ -308,7 +332,9 @@
_startValue = startValue;
_endValue = endValue;
+#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101400
[self setAnimationBlockingMode:NSAnimationNonblocking];
+#endif
return self;
}
@@ -319,7 +345,12 @@
_scrollerImp = scrollerImpForScrollbar(*_scrollbar);
+#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101400
[super startAnimation];
+#else
+ [[NSRunLoop mainRunLoop] addTimer:_timer.get() forMode:NSDefaultRunLoopMode];
+ _startDate = adoptNS([[NSDate alloc] initWithTimeIntervalSinceNow:0]);
+#endif
}
- (void)setStartValue:(CGFloat)startValue
@@ -332,10 +363,28 @@
_endValue = endValue;
}
+#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101400
- (void)setCurrentProgress:(NSAnimationProgress)progress
+#else
+- (void)setCurrentProgress:(NSTimer *)timer
+#endif
{
+#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101400
[super setCurrentProgress:progress];
-
+#else
+ CGFloat progress = 0;
+ NSDate *now = [NSDate dateWithTimeIntervalSinceNow:0];
+ NSTimeInterval elapsed = [now timeIntervalSinceDate:_startDate.get()];
+ if (elapsed > _duration) {
+ progress = 1;
+ [timer invalidate];
+ } else {
+ NSTimeInterval t = 1;
+ if (_duration)
+ t = elapsed / _duration;
+ progress = _timingFunction->transformTime(t, _duration);
+ }
+#endif
ASSERT(_scrollbar);
CGFloat currentValue;
@@ -371,6 +420,18 @@
_scrollbar = 0;
}
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
+- (void)setDuration:(NSTimeInterval)duration
+{
+ _duration = duration;
+}
+
+- (void)stopAnimation
+{
+ [_timer invalidate];
+}
+#endif
+
@end
@interface WebScrollerImpDelegate : NSObject<NSAnimationDelegate, NSScrollerImpDelegate>
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes