https://bugs.webkit.org/show_bug.cgi?id=181651
Patch by Antoine Quint <graouts@apple.com> on 2018-01-16
Reviewed by Dean Jackson.
Cleaning up Dean's previous patch as suggested by Darin's post-commit review comments. The
downcast function can match const automatically and it's a better style to put the * inside
the downcast call rather than outside.
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::createTimingFunctionValue):
* platform/animation/TimingFunction.cpp:
(WebCore::operator<<):
(WebCore::TimingFunction::transformTime const):
* platform/animation/TimingFunction.h:
* platform/graphics/ca/cocoa/PlatformCAAnimationCocoa.mm:
(WebCore::toCAMediaTimingFunction):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226976
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2018-01-16 Antoine Quint <graouts@apple.com>
+
+ Use traits for animation timing functions
+ https://bugs.webkit.org/show_bug.cgi?id=181651
+
+ Reviewed by Dean Jackson.
+
+ Cleaning up Dean's previous patch as suggested by Darin's post-commit review comments. The
+ downcast function can match const automatically and it's a better style to put the * inside
+ the downcast call rather than outside.
+
+ * css/CSSComputedStyleDeclaration.cpp:
+ (WebCore::createTimingFunctionValue):
+ * platform/animation/TimingFunction.cpp:
+ (WebCore::operator<<):
+ (WebCore::TimingFunction::transformTime const):
+ * platform/animation/TimingFunction.h:
+ * platform/graphics/ca/cocoa/PlatformCAAnimationCocoa.mm:
+ (WebCore::toCAMediaTimingFunction):
+
2018-01-16 Philippe Normand <pnormand@igalia.com>
[GStreamer] Live streaming cleanups
{
switch (timingFunction.type()) {
case TimingFunction::CubicBezierFunction: {
- auto& function = downcast<const CubicBezierTimingFunction>(timingFunction);
+ auto& function = downcast<CubicBezierTimingFunction>(timingFunction);
if (function.timingFunctionPreset() != CubicBezierTimingFunction::Custom) {
CSSValueID valueId = CSSValueInvalid;
switch (function.timingFunctionPreset()) {
return CSSCubicBezierTimingFunctionValue::create(function.x1(), function.y1(), function.x2(), function.y2());
}
case TimingFunction::StepsFunction: {
- auto& function = downcast<const StepsTimingFunction>(timingFunction);
+ auto& function = downcast<StepsTimingFunction>(timingFunction);
return CSSStepsTimingFunctionValue::create(function.numberOfSteps(), function.stepAtStart());
}
case TimingFunction::FramesFunction: {
- auto& function = downcast<const FramesTimingFunction>(timingFunction);
+ auto& function = downcast<FramesTimingFunction>(timingFunction);
return CSSFramesTimingFunctionValue::create(function.numberOfFrames());
}
case TimingFunction::SpringFunction: {
- auto& function = downcast<const SpringTimingFunction>(timingFunction);
+ auto& function = downcast<SpringTimingFunction>(timingFunction);
return CSSSpringTimingFunctionValue::create(function.mass(), function.stiffness(), function.damping(), function.initialVelocity());
}
default:
ts << "linear";
break;
case TimingFunction::CubicBezierFunction: {
- auto& function = static_cast<const CubicBezierTimingFunction&>(timingFunction);
+ auto& function = downcast<CubicBezierTimingFunction>(timingFunction);
ts << "cubic-bezier(" << function.x1() << ", " << function.y1() << ", " << function.x2() << ", " << function.y2() << ")";
break;
}
case TimingFunction::StepsFunction: {
- auto& function = static_cast<const StepsTimingFunction&>(timingFunction);
+ auto& function = downcast<StepsTimingFunction>(timingFunction);
ts << "steps(" << function.numberOfSteps() << ", " << (function.stepAtStart() ? "start" : "end") << ")";
break;
}
case TimingFunction::FramesFunction: {
- auto& function = static_cast<const FramesTimingFunction&>(timingFunction);
+ auto& function = downcast<FramesTimingFunction>(timingFunction);
ts << "frames(" << function.numberOfFrames() << ")";
break;
}
case TimingFunction::SpringFunction: {
- auto& function = static_cast<const SpringTimingFunction&>(timingFunction);
+ auto& function = downcast<SpringTimingFunction>(timingFunction);
ts << "spring(" << function.mass() << " " << function.stiffness() << " " << function.damping() << " " << function.initialVelocity() << ")";
break;
}
{
switch (m_type) {
case TimingFunction::CubicBezierFunction: {
- auto& function = *downcast<const CubicBezierTimingFunction>(this);
+ auto& function = downcast<CubicBezierTimingFunction>(*this);
// The epsilon value we pass to UnitBezier::solve given that the animation is going to run over |dur| seconds. The longer the
// animation, the more precision we need in the timing function result to avoid ugly discontinuities.
auto epsilon = 1.0 / (200.0 * duration);
return UnitBezier(function.x1(), function.y1(), function.x2(), function.y2()).solve(inputTime, epsilon);
}
case TimingFunction::StepsFunction: {
- auto& function = *downcast<const StepsTimingFunction>(this);
+ auto& function = downcast<StepsTimingFunction>(*this);
auto numberOfSteps = function.numberOfSteps();
if (function.stepAtStart())
return std::min(1.0, (std::floor(numberOfSteps * inputTime) + 1) / numberOfSteps);
}
case TimingFunction::FramesFunction: {
// https://drafts.csswg.org/css-timing/#frames-timing-functions
- auto& function = *downcast<const FramesTimingFunction>(this);
+ auto& function = downcast<FramesTimingFunction>(*this);
auto numberOfFrames = function.numberOfFrames();
ASSERT(numberOfFrames > 1);
auto outputTime = std::floor(inputTime * numberOfFrames) / (numberOfFrames - 1);
return outputTime;
}
case TimingFunction::SpringFunction: {
- auto& function = *downcast<const SpringTimingFunction>(this);
+ auto& function = downcast<SpringTimingFunction>(*this);
return SpringSolver(function.mass(), function.stiffness(), function.damping(), function.initialVelocity()).solve(inputTime * duration);
}
case TimingFunction::LinearFunction:
{
if (!is<CubicBezierTimingFunction>(other))
return false;
- auto& otherCubic = downcast<const CubicBezierTimingFunction>(other);
+ auto& otherCubic = downcast<CubicBezierTimingFunction>(other);
if (m_timingFunctionPreset != otherCubic.m_timingFunctionPreset)
return false;
if (m_timingFunctionPreset != Custom)
{
if (!is<StepsTimingFunction>(other))
return false;
- auto& otherSteps = downcast<const StepsTimingFunction>(other);
+ auto& otherSteps = downcast<StepsTimingFunction>(other);
return m_steps == otherSteps.m_steps && m_stepAtStart == otherSteps.m_stepAtStart;
}
{
if (is<FramesTimingFunction>(other))
return false;
- auto& otherFrames = downcast<const FramesTimingFunction>(other);
+ auto& otherFrames = downcast<FramesTimingFunction>(other);
return m_frames == otherFrames.m_frames;
}
{
if (!is<SpringTimingFunction>(other))
return false;
- auto& otherSpring = downcast<const SpringTimingFunction>(other);
+ auto& otherSpring = downcast<SpringTimingFunction>(other);
return m_mass == otherSpring.m_mass && m_stiffness == otherSpring.m_stiffness && m_damping == otherSpring.m_damping && m_initialVelocity == otherSpring.m_initialVelocity;
}
ASSERT(timingFunction);
if (is<CubicBezierTimingFunction>(timingFunction)) {
RefPtr<CubicBezierTimingFunction> reversed;
- const CubicBezierTimingFunction* ctf = downcast<const CubicBezierTimingFunction>(timingFunction);
+ auto* function = downcast<CubicBezierTimingFunction>(timingFunction);
if (reverse) {
- reversed = ctf->createReversed();
- ctf = reversed.get();
+ reversed = function->createReversed();
+ function = reversed.get();
}
- float x1 = static_cast<float>(ctf->x1());
- float y1 = static_cast<float>(ctf->y1());
- float x2 = static_cast<float>(ctf->x2());
- float y2 = static_cast<float>(ctf->y2());
+ float x1 = static_cast<float>(function->x1());
+ float y1 = static_cast<float>(function->y1());
+ float x2 = static_cast<float>(function->x2());
+ float y2 = static_cast<float>(function->y2());
return [CAMediaTimingFunction functionWithControlPoints: x1 : y1 : x2 : y2];
}