Diff
Modified: trunk/LayoutTests/ChangeLog (201758 => 201759)
--- trunk/LayoutTests/ChangeLog 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/LayoutTests/ChangeLog 2016-06-07 18:15:31 UTC (rev 201759)
@@ -1,3 +1,20 @@
+2016-06-05 Sam Weinig <s...@webkit.org>
+
+ Add experimental support for spring based CSS animations
+ https://bugs.webkit.org/show_bug.cgi?id=158403
+
+ Reviewed by Dean Jackson.
+
+ * animations/script-tests/spring-computed-style.js: Added.
+ * animations/script-tests/spring-parsing.js: Added.
+ * animations/spring-computed-style-expected.txt: Added.
+ * animations/spring-computed-style.html: Added.
+ * animations/spring-function-expected.txt: Added.
+ * animations/spring-function.html: Added.
+ * animations/spring-parsing-expected.txt: Added.
+ * animations/spring-parsing.html: Added.
+ Add tests for the spring timing function.
+
2016-06-07 Chris Dumez <cdu...@apple.com>
Implement EventListenerOptions argument to addEventListener
Added: trunk/LayoutTests/animations/script-tests/spring-computed-style.js (0 => 201759)
--- trunk/LayoutTests/animations/script-tests/spring-computed-style.js (rev 0)
+++ trunk/LayoutTests/animations/script-tests/spring-computed-style.js 2016-06-07 18:15:31 UTC (rev 201759)
@@ -0,0 +1,50 @@
+description("Test the computed style of the spring() function on the transition-timing-function property.");
+
+if (window.internals)
+ internals.settings.setSpringTimingFunctionEnabled(true);
+
+// These have to be global for the test helpers to see them.
+var stylesheet, springStyle;
+var styleElement = document.createElement("style");
+document.head.appendChild(styleElement);
+stylesheet = styleElement.sheet;
+
+function testComputedSpring(description, spring, expectedValue)
+{
+ debug("");
+ debug(description + " : " + spring);
+
+ stylesheet.insertRule("body { transition-timing-function: " + spring + "; }", 0);
+
+ springStyle = window.getComputedStyle(document.body).getPropertyCSSValue("transition-timing-function");
+ shouldBe("springStyle.cssText", "'" + expectedValue + "'");
+
+ stylesheet.deleteRule(0);
+}
+
+debug("")
+debug("Valid spring tests");
+debug("")
+
+testComputedSpring("Basic", "spring(1 100 10 0)", "spring(1 100 10 0)");
+testComputedSpring("Negative Velocity", "spring(1 100 10 -10)", "spring(1 100 10 -10)");
+testComputedSpring("Positive Velocity", "spring(1 100 10 10)", "spring(1 100 10 10)");
+testComputedSpring("Zero Damping", "spring(1 100 0 10)", "spring(1 100 0 10)");
+testComputedSpring("Minimum Values", "spring(1 1 0 -999999)", "spring(1 1 0 -999999)");
+testComputedSpring("Floating Point Values", "spring(1.5 2.3 3.7 -1.8)", "spring(1.5 2.3 3.7 -1.8)");
+
+debug("")
+debug("Invalid spring tests");
+debug("")
+
+testComputedSpring("No parameters", "spring()", "ease");
+testComputedSpring("Not enough parameters", "spring(1 100 10)", "ease");
+testComputedSpring("Too many parameters", "spring(1 100 10 0 0)", "ease");
+testComputedSpring("Non-numeric parameters", "spring(a b c d)", "ease");
+testComputedSpring("Illegal Mass (< 0)", "spring(-1 100 10 0)", "ease");
+testComputedSpring("Illegal Mass (== 0)", "spring(0 100 10 0)", "ease");
+testComputedSpring("Illegal Stiffness (< 0)", "spring(1 -1 10 0)", "ease");
+testComputedSpring("Illegal Stiffness (== 0)", "spring(1 0 10 0)", "ease");
+testComputedSpring("Illegal Damping (< 0)", "spring(1 100 -1 0)", "ease");
+
+successfullyParsed = true;
Added: trunk/LayoutTests/animations/script-tests/spring-parsing.js (0 => 201759)
--- trunk/LayoutTests/animations/script-tests/spring-parsing.js (rev 0)
+++ trunk/LayoutTests/animations/script-tests/spring-parsing.js 2016-06-07 18:15:31 UTC (rev 201759)
@@ -0,0 +1,63 @@
+description("Test the parsing of the spring() function on the transition-timing-function property.");
+
+if (window.internals)
+ internals.settings.setSpringTimingFunctionEnabled(true);
+
+// These have to be global for the test helpers to see them.
+var stylesheet, cssRule, declaration, propertyValue, subRule;
+var styleElement = document.createElement("style");
+document.head.appendChild(styleElement);
+stylesheet = styleElement.sheet;
+
+function testSpring(description, spring, expectedValue)
+{
+ debug("");
+ debug(description + " : " + spring);
+
+ stylesheet.insertRule("body { transition-timing-function: " + spring + "; }", 0);
+ cssRule = stylesheet.cssRules.item(0);
+
+ shouldBe("cssRule.type", "1");
+
+ declaration = cssRule.style;
+ if (!expectedValue) {
+ shouldBe("declaration.length", "0");
+ shouldBeEqualToString("declaration.getPropertyValue('transition-timing-function')", "");
+ return;
+ }
+
+ shouldBe("declaration.length", "1");
+ shouldBe("declaration.getPropertyValue('transition-timing-function')", "'" + expectedValue + "'");
+
+ propertyValue = declaration.getPropertyCSSValue("transition-timing-function");
+ shouldBe("propertyValue.cssText", "'" + expectedValue + "'");
+
+ stylesheet.deleteRule(0);
+}
+
+debug("")
+debug("Valid spring tests");
+debug("")
+
+testSpring("Basic", "spring(1 100 10 0)", "spring(1 100 10 0)");
+testSpring("Negative Velocity", "spring(1 100 10 -10)", "spring(1 100 10 -10)");
+testSpring("Positive Velocity", "spring(1 100 10 10)", "spring(1 100 10 10)");
+testSpring("Zero Damping", "spring(1 100 0 10)", "spring(1 100 0 10)");
+testSpring("Minimum Values", "spring(1 1 0 -999999)", "spring(1 1 0 -999999)");
+testSpring("Floating Point Values", "spring(1.5 2.3 3.7 -1.8)", "spring(1.5 2.3 3.7 -1.8)");
+
+debug("")
+debug("Invalid spring tests");
+debug("")
+
+testSpring("No parameters", "spring()", null);
+testSpring("Not enough parameters", "spring(1 100 10)", null);
+testSpring("Too many parameters", "spring(1 100 10 0 0)", null);
+testSpring("Non-numeric parameters", "spring(a b c d)", null);
+testSpring("Illegal Mass (< 0)", "spring(-1 100 10 0)", null);
+testSpring("Illegal Mass (== 0)", "spring(0 100 10 0)", null);
+testSpring("Illegal Stiffness (< 0)", "spring(1 -1 10 0)", null);
+testSpring("Illegal Stiffness (== 0)", "spring(1 0 10 0)", null);
+testSpring("Illegal Damping (< 0)", "spring(1 100 -1 0)", null);
+
+successfullyParsed = true;
Added: trunk/LayoutTests/animations/spring-computed-style-expected.txt (0 => 201759)
--- trunk/LayoutTests/animations/spring-computed-style-expected.txt (rev 0)
+++ trunk/LayoutTests/animations/spring-computed-style-expected.txt 2016-06-07 18:15:31 UTC (rev 201759)
@@ -0,0 +1,60 @@
+Test the computed style of the spring() function on the transition-timing-function property.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+Valid spring tests
+
+
+Basic : spring(1 100 10 0)
+PASS springStyle.cssText is 'spring(1 100 10 0)'
+
+Negative Velocity : spring(1 100 10 -10)
+PASS springStyle.cssText is 'spring(1 100 10 -10)'
+
+Positive Velocity : spring(1 100 10 10)
+PASS springStyle.cssText is 'spring(1 100 10 10)'
+
+Zero Damping : spring(1 100 0 10)
+PASS springStyle.cssText is 'spring(1 100 0 10)'
+
+Minimum Values : spring(1 1 0 -999999)
+PASS springStyle.cssText is 'spring(1 1 0 -999999)'
+
+Floating Point Values : spring(1.5 2.3 3.7 -1.8)
+PASS springStyle.cssText is 'spring(1.5 2.3 3.7 -1.8)'
+
+Invalid spring tests
+
+
+No parameters : spring()
+PASS springStyle.cssText is 'ease'
+
+Not enough parameters : spring(1 100 10)
+PASS springStyle.cssText is 'ease'
+
+Too many parameters : spring(1 100 10 0 0)
+PASS springStyle.cssText is 'ease'
+
+Non-numeric parameters : spring(a b c d)
+PASS springStyle.cssText is 'ease'
+
+Illegal Mass (< 0) : spring(-1 100 10 0)
+PASS springStyle.cssText is 'ease'
+
+Illegal Mass (== 0) : spring(0 100 10 0)
+PASS springStyle.cssText is 'ease'
+
+Illegal Stiffness (< 0) : spring(1 -1 10 0)
+PASS springStyle.cssText is 'ease'
+
+Illegal Stiffness (== 0) : spring(1 0 10 0)
+PASS springStyle.cssText is 'ease'
+
+Illegal Damping (< 0) : spring(1 100 -1 0)
+PASS springStyle.cssText is 'ease'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/animations/spring-computed-style.html (0 => 201759)
--- trunk/LayoutTests/animations/spring-computed-style.html (rev 0)
+++ trunk/LayoutTests/animations/spring-computed-style.html 2016-06-07 18:15:31 UTC (rev 201759)
@@ -0,0 +1,6 @@
+<!DOCTYPE HTML>
+<script src=""
+<p id="description"></p>
+<div id="console"></div>
+<script src=""
+<script src=""
Added: trunk/LayoutTests/animations/spring-function-expected.txt (0 => 201759)
--- trunk/LayoutTests/animations/spring-function-expected.txt (rev 0)
+++ trunk/LayoutTests/animations/spring-function-expected.txt 2016-06-07 18:15:31 UTC (rev 201759)
@@ -0,0 +1,5 @@
+This test performs an animation of the left property. It animates over 1 second. It takes 3 snapshots and expects each result to be within a specified range.
+PASS - "left" property for "box1" element at 0.25s saw something close to: 512
+PASS - "left" property for "box1" element at 0.5s saw something close to: 537
+PASS - "left" property for "box1" element at 0.75s saw something close to: 487
+
Added: trunk/LayoutTests/animations/spring-function.html (0 => 201759)
--- trunk/LayoutTests/animations/spring-function.html (rev 0)
+++ trunk/LayoutTests/animations/spring-function.html 2016-06-07 18:15:31 UTC (rev 201759)
@@ -0,0 +1,44 @@
+<script>
+ if (window.internals)
+ internals.settings.setSpringTimingFunctionEnabled(true);
+</script>
+<style type="text/css" media="screen">
+ .box {
+ position: relative;
+ left: 100px;
+ top: 0px;
+ height: 5px;
+ width: 5px;
+ background-color: blue;
+ animation-duration: 1s;
+ animation-name: anim;
+ }
+ @keyframes anim {
+ from { left: 0px; }
+ to { left: 500px; }
+ }
+ #box1 {
+ animation-timing-function: spring(1 100 10 0);
+ }
+
+</style>
+<script src="" type="text/_javascript_" charset="utf-8"></script>
+<script type="text/_javascript_" charset="utf-8">
+
+ const expectedValues = [
+ // [animation-name, time, element-id, property, expected-value, tolerance]
+ ["anim", 0.25, "box1", "left", 512, 5],
+ ["anim", 0.50, "box1", "left", 537, 5],
+ ["anim", 0.75, "box1", "left", 487, 5],
+ ];
+
+ runAnimationTest(expectedValues);
+
+</script>
+<body>
+This test performs an animation of the left property. It animates over 1 second.
+It takes 3 snapshots and expects each result to be within a specified range.
+<div class="box" id="box1"></div>
+<div id="result">
+</div>
+</body>
Added: trunk/LayoutTests/animations/spring-parsing-expected.txt (0 => 201759)
--- trunk/LayoutTests/animations/spring-parsing-expected.txt (rev 0)
+++ trunk/LayoutTests/animations/spring-parsing-expected.txt 2016-06-07 18:15:31 UTC (rev 201759)
@@ -0,0 +1,96 @@
+Test the parsing of the spring() function on the transition-timing-function property.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+Valid spring tests
+
+
+Basic : spring(1 100 10 0)
+PASS cssRule.type is 1
+PASS declaration.length is 1
+PASS declaration.getPropertyValue('transition-timing-function') is 'spring(1 100 10 0)'
+PASS propertyValue.cssText is 'spring(1 100 10 0)'
+
+Negative Velocity : spring(1 100 10 -10)
+PASS cssRule.type is 1
+PASS declaration.length is 1
+PASS declaration.getPropertyValue('transition-timing-function') is 'spring(1 100 10 -10)'
+PASS propertyValue.cssText is 'spring(1 100 10 -10)'
+
+Positive Velocity : spring(1 100 10 10)
+PASS cssRule.type is 1
+PASS declaration.length is 1
+PASS declaration.getPropertyValue('transition-timing-function') is 'spring(1 100 10 10)'
+PASS propertyValue.cssText is 'spring(1 100 10 10)'
+
+Zero Damping : spring(1 100 0 10)
+PASS cssRule.type is 1
+PASS declaration.length is 1
+PASS declaration.getPropertyValue('transition-timing-function') is 'spring(1 100 0 10)'
+PASS propertyValue.cssText is 'spring(1 100 0 10)'
+
+Minimum Values : spring(1 1 0 -999999)
+PASS cssRule.type is 1
+PASS declaration.length is 1
+PASS declaration.getPropertyValue('transition-timing-function') is 'spring(1 1 0 -999999)'
+PASS propertyValue.cssText is 'spring(1 1 0 -999999)'
+
+Floating Point Values : spring(1.5 2.3 3.7 -1.8)
+PASS cssRule.type is 1
+PASS declaration.length is 1
+PASS declaration.getPropertyValue('transition-timing-function') is 'spring(1.5 2.3 3.7 -1.8)'
+PASS propertyValue.cssText is 'spring(1.5 2.3 3.7 -1.8)'
+
+Invalid spring tests
+
+
+No parameters : spring()
+PASS cssRule.type is 1
+PASS declaration.length is 0
+PASS declaration.getPropertyValue('transition-timing-function') is ""
+
+Not enough parameters : spring(1 100 10)
+PASS cssRule.type is 1
+PASS declaration.length is 0
+PASS declaration.getPropertyValue('transition-timing-function') is ""
+
+Too many parameters : spring(1 100 10 0 0)
+PASS cssRule.type is 1
+PASS declaration.length is 0
+PASS declaration.getPropertyValue('transition-timing-function') is ""
+
+Non-numeric parameters : spring(a b c d)
+PASS cssRule.type is 1
+PASS declaration.length is 0
+PASS declaration.getPropertyValue('transition-timing-function') is ""
+
+Illegal Mass (< 0) : spring(-1 100 10 0)
+PASS cssRule.type is 1
+PASS declaration.length is 0
+PASS declaration.getPropertyValue('transition-timing-function') is ""
+
+Illegal Mass (== 0) : spring(0 100 10 0)
+PASS cssRule.type is 1
+PASS declaration.length is 0
+PASS declaration.getPropertyValue('transition-timing-function') is ""
+
+Illegal Stiffness (< 0) : spring(1 -1 10 0)
+PASS cssRule.type is 1
+PASS declaration.length is 0
+PASS declaration.getPropertyValue('transition-timing-function') is ""
+
+Illegal Stiffness (== 0) : spring(1 0 10 0)
+PASS cssRule.type is 1
+PASS declaration.length is 0
+PASS declaration.getPropertyValue('transition-timing-function') is ""
+
+Illegal Damping (< 0) : spring(1 100 -1 0)
+PASS cssRule.type is 1
+PASS declaration.length is 0
+PASS declaration.getPropertyValue('transition-timing-function') is ""
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/animations/spring-parsing.html (0 => 201759)
--- trunk/LayoutTests/animations/spring-parsing.html (rev 0)
+++ trunk/LayoutTests/animations/spring-parsing.html 2016-06-07 18:15:31 UTC (rev 201759)
@@ -0,0 +1,6 @@
+<!DOCTYPE HTML>
+<script src=""
+<p id="description"></p>
+<div id="console"></div>
+<script src=""
+<script src=""
Modified: trunk/Source/WebCore/ChangeLog (201758 => 201759)
--- trunk/Source/WebCore/ChangeLog 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/Source/WebCore/ChangeLog 2016-06-07 18:15:31 UTC (rev 201759)
@@ -1,3 +1,241 @@
+2016-06-06 Sam Weinig <s...@webkit.org>
+
+ Add experimental support for spring based CSS animations
+ https://bugs.webkit.org/show_bug.cgi?id=158403
+
+ Reviewed by Dean Jackson.
+
+ Adds experimental support for a new CSS animation timing function that uses
+ spring to model the time function. To use it you replace your normal timing
+ function, be it cubic-bezier or steps, with a new function called spring().
+ For instance, for a transition you would write:
+
+ transition-timing-function: spring(1 100 10 0);
+
+ The parameters are, in order:
+ - Mass
+ - Stiffness
+ - Damping
+ - Initial Velocity
+
+ Tests: animations/spring-computed-style.html
+ animations/spring-function.html
+ animations/spring-parsing.html
+
+ * WebCore.xcodeproj/project.pbxproj:
+ Add new file.
+
+ * css/CSSComputedStyleDeclaration.cpp:
+ (WebCore::createTimingFunctionValue):
+ Modernize and add support for the spring function.
+
+ * css/CSSParser.cpp:
+ (WebCore::CSSParserContext::CSSParserContext):
+ (WebCore::operator==):
+ (WebCore::CSSParser::CSSParser):
+ (WebCore::CSSParser::parseTransformOriginShorthand):
+ (WebCore::CSSParser::isSpringTimingFunctionEnabled):
+ (WebCore::CSSParser::parseCubicBezierTimingFunctionValue):
+ (WebCore::CSSParser::parseSpringTimingFunctionValue):
+ (WebCore::CSSParser::parseAnimationTimingFunction):
+ * css/CSSParser.h:
+ * css/CSSParserMode.h:
+ Add parsing support for the spring() function.
+
+ * css/CSSTimingFunctionValue.cpp:
+ (WebCore::CSSCubicBezierTimingFunctionValue::customCSSText):
+ (WebCore::CSSCubicBezierTimingFunctionValue::equals):
+ (WebCore::CSSStepsTimingFunctionValue::customCSSText):
+ (WebCore::CSSStepsTimingFunctionValue::equals):
+ (WebCore::CSSSpringTimingFunctionValue::customCSSText):
+ (WebCore::CSSSpringTimingFunctionValue::equals):
+ * css/CSSTimingFunctionValue.h:
+ (WebCore::CSSSpringTimingFunctionValue::create):
+ (WebCore::CSSSpringTimingFunctionValue::mass):
+ (WebCore::CSSSpringTimingFunctionValue::stiffness):
+ (WebCore::CSSSpringTimingFunctionValue::damping):
+ (WebCore::CSSSpringTimingFunctionValue::initialVelocity):
+ (WebCore::CSSSpringTimingFunctionValue::CSSSpringTimingFunctionValue):
+ Modernize and add support for the spring function.
+
+ * css/CSSToStyleMap.cpp:
+ (WebCore::CSSToStyleMap::mapAnimationTimingFunction):
+ Pipe the spring function into the animation.
+
+ * css/CSSValue.cpp:
+ (WebCore::CSSValue::equals):
+ (WebCore::CSSValue::cssText):
+ (WebCore::CSSValue::destroy):
+ * css/CSSValue.h:
+ (WebCore::CSSValue::isSpringTimingFunctionValue):
+ Add support for the spring function.
+
+ * page/Settings.in:
+ Add a setting to control if the spring function is enabled.
+
+ * page/animation/AnimationBase.cpp:
+ (WebCore::solveSpringFunction):
+ (WebCore::AnimationBase::progress):
+ Add support for solving the spring function. Since the spring requires time to be absolute,
+ get the real time by multiplying the ratio t, to the total duration.
+
+ * platform/animation/TimingFunction.cpp:
+ (WebCore::operator<<):
+ * platform/animation/TimingFunction.h:
+ (WebCore::TimingFunction::~TimingFunction):
+ (WebCore::TimingFunction::isSpringTimingFunction):
+ Add support for the spring timing function.
+
+ * platform/graphics/SpringSolver.h: Added.
+ (WebCore::SpringSolver::SpringSolver):
+ (WebCore::SpringSolver::solve):
+ Add a Spring solver that matches the one in CoreAnimation.
+
+ * platform/graphics/ca/GraphicsLayerCA.cpp:
+ (WebCore::GraphicsLayerCA::createAnimationFromKeyframes):
+ (WebCore::GraphicsLayerCA::appendToUncommittedAnimations):
+ (WebCore::GraphicsLayerCA::createBasicAnimation):
+ (WebCore::GraphicsLayerCA::createSpringAnimation):
+ (WebCore::GraphicsLayerCA::setupAnimation):
+ * platform/graphics/ca/GraphicsLayerCA.h:
+ Map animations with spring timing functions to CASpringAnimations.
+
+ * platform/graphics/ca/PlatformCAAnimation.cpp:
+ (WebCore::operator<<):
+ (WebCore::PlatformCAAnimation::isBasicAnimation):
+ * platform/graphics/ca/PlatformCAAnimation.h:
+ (WebCore::PlatformCAAnimation::setActualStartTimeIfNeeded):
+ (WebCore::PlatformCAAnimation::PlatformCAAnimation):
+ * platform/graphics/ca/cocoa/PlatformCAAnimationCocoa.mm:
+ (WebCore::toCAMediaTimingFunction):
+ (PlatformCAAnimationCocoa::PlatformCAAnimationCocoa):
+ (PlatformCAAnimationCocoa::setTimingFunction):
+ (PlatformCAAnimationCocoa::copyTimingFunctionFrom):
+ (PlatformCAAnimationCocoa::setFromValue):
+ (PlatformCAAnimationCocoa::copyFromValueFrom):
+ (PlatformCAAnimationCocoa::setToValue):
+ (PlatformCAAnimationCocoa::copyToValueFrom):
+ Add a new type of PlatformCAAnimation, Spring, which is a sub-type of Basic.
+
+2016-06-05 Sam Weinig <s...@webkit.org>
+
+ Add experimental support for spring based CSS animations
+ https://bugs.webkit.org/show_bug.cgi?id=158403
+
+ Reviewed by Dean Jackson.
+
+ Adds experimental support for a new CSS animation timing function that uses
+ spring to model the time function. To use it you replace your normal timing
+ function, be it cubic-bezier or steps, with a new function called spring().
+ For instance, for a transition you would write:
+
+ transition-timing-function: spring(1 100 10 0);
+
+ The parameters are, in order:
+ - Mass
+ - Stiffness
+ - Damping
+ - Initial Velocity
+
+ Tests: animations/spring-computed-style.html
+ animations/spring-function.html
+ animations/spring-parsing.html
+
+ * WebCore.xcodeproj/project.pbxproj:
+ Add new file.
+
+ * css/CSSComputedStyleDeclaration.cpp:
+ (WebCore::createTimingFunctionValue):
+ Modernize and add support for the spring function.
+
+ * css/CSSParser.cpp:
+ (WebCore::CSSParserContext::CSSParserContext):
+ (WebCore::operator==):
+ (WebCore::CSSParser::CSSParser):
+ (WebCore::CSSParser::parseTransformOriginShorthand):
+ (WebCore::CSSParser::isSpringTimingFunctionEnabled):
+ (WebCore::CSSParser::parseCubicBezierTimingFunctionValue):
+ (WebCore::CSSParser::parseSpringTimingFunctionValue):
+ (WebCore::CSSParser::parseAnimationTimingFunction):
+ * css/CSSParser.h:
+ * css/CSSParserMode.h:
+ Add parsing support for the spring() function.
+
+ * css/CSSTimingFunctionValue.cpp:
+ (WebCore::CSSCubicBezierTimingFunctionValue::customCSSText):
+ (WebCore::CSSCubicBezierTimingFunctionValue::equals):
+ (WebCore::CSSStepsTimingFunctionValue::customCSSText):
+ (WebCore::CSSStepsTimingFunctionValue::equals):
+ (WebCore::CSSSpringTimingFunctionValue::customCSSText):
+ (WebCore::CSSSpringTimingFunctionValue::equals):
+ * css/CSSTimingFunctionValue.h:
+ (WebCore::CSSSpringTimingFunctionValue::create):
+ (WebCore::CSSSpringTimingFunctionValue::mass):
+ (WebCore::CSSSpringTimingFunctionValue::stiffness):
+ (WebCore::CSSSpringTimingFunctionValue::damping):
+ (WebCore::CSSSpringTimingFunctionValue::initialVelocity):
+ (WebCore::CSSSpringTimingFunctionValue::CSSSpringTimingFunctionValue):
+ Modernize and add support for the spring function.
+
+ * css/CSSToStyleMap.cpp:
+ (WebCore::CSSToStyleMap::mapAnimationTimingFunction):
+ Pipe the spring function into the animation.
+
+ * css/CSSValue.cpp:
+ (WebCore::CSSValue::equals):
+ (WebCore::CSSValue::cssText):
+ (WebCore::CSSValue::destroy):
+ * css/CSSValue.h:
+ (WebCore::CSSValue::isSpringTimingFunctionValue):
+ Add support for the spring function.
+
+ * page/Settings.in:
+ Add a setting to control if the spring function is enabled.
+
+ * page/animation/AnimationBase.cpp:
+ (WebCore::solveSpringFunction):
+ (WebCore::AnimationBase::progress):
+ Add support for solving the spring function. Since the spring requires time to be absolute,
+ get the real time by multiplying the ratio t, to the total duration.
+
+ * platform/animation/TimingFunction.cpp:
+ (WebCore::operator<<):
+ * platform/animation/TimingFunction.h:
+ (WebCore::TimingFunction::~TimingFunction):
+ (WebCore::TimingFunction::isSpringTimingFunction):
+ Add support for the spring timing function.
+
+ * platform/graphics/SpringSolver.h: Added.
+ (WebCore::SpringSolver::SpringSolver):
+ (WebCore::SpringSolver::solve):
+ Add a Spring solver that matches the one in CoreAnimation.
+
+ * platform/graphics/ca/GraphicsLayerCA.cpp:
+ (WebCore::GraphicsLayerCA::createAnimationFromKeyframes):
+ (WebCore::GraphicsLayerCA::appendToUncommittedAnimations):
+ (WebCore::GraphicsLayerCA::createBasicAnimation):
+ (WebCore::GraphicsLayerCA::createSpringAnimation):
+ (WebCore::GraphicsLayerCA::setupAnimation):
+ * platform/graphics/ca/GraphicsLayerCA.h:
+ Map animations with spring timing functions to CASpringAnimations.
+
+ * platform/graphics/ca/PlatformCAAnimation.cpp:
+ (WebCore::operator<<):
+ (WebCore::PlatformCAAnimation::isBasicAnimation):
+ * platform/graphics/ca/PlatformCAAnimation.h:
+ (WebCore::PlatformCAAnimation::setActualStartTimeIfNeeded):
+ (WebCore::PlatformCAAnimation::PlatformCAAnimation):
+ * platform/graphics/ca/cocoa/PlatformCAAnimationCocoa.mm:
+ (WebCore::toCAMediaTimingFunction):
+ (PlatformCAAnimationCocoa::PlatformCAAnimationCocoa):
+ (PlatformCAAnimationCocoa::setTimingFunction):
+ (PlatformCAAnimationCocoa::copyTimingFunctionFrom):
+ (PlatformCAAnimationCocoa::setFromValue):
+ (PlatformCAAnimationCocoa::copyFromValueFrom):
+ (PlatformCAAnimationCocoa::setToValue):
+ (PlatformCAAnimationCocoa::copyToValueFrom):
+ Add a new type of PlatformCAAnimation, Spring, which is a sub-type of Basic.
+
2016-06-07 Chris Dumez <cdu...@apple.com>
Implement EventListenerOptions argument to addEventListener
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (201758 => 201759)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-06-07 18:15:31 UTC (rev 201759)
@@ -2764,6 +2764,7 @@
7C74D43C1882400400E5ED57 /* UTextProviderUTF16.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C74D43A1882400400E5ED57 /* UTextProviderUTF16.h */; };
7C7941E41C56C29300A4C58E /* DataDetectorsCoreSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7C7941E21C56C29300A4C58E /* DataDetectorsCoreSoftLink.mm */; };
7C7941E51C56C29300A4C58E /* DataDetectorsCoreSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C7941E31C56C29300A4C58E /* DataDetectorsCoreSoftLink.h */; };
+ 7C83DE861D04CC5D00FEBCF3 /* SpringSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C83DE851D04CBD400FEBCF3 /* SpringSolver.h */; };
7C91A38F1B498ABE003F9EFA /* JSNodeOrString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C91A38D1B498ABE003F9EFA /* JSNodeOrString.cpp */; };
7C91A3901B498ABE003F9EFA /* JSNodeOrString.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C91A38E1B498ABE003F9EFA /* JSNodeOrString.h */; };
7C93F3491AA6BA5E00A98BAB /* CompiledContentExtension.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C93F3471AA6BA5E00A98BAB /* CompiledContentExtension.cpp */; };
@@ -10430,6 +10431,7 @@
7C74D43A1882400400E5ED57 /* UTextProviderUTF16.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UTextProviderUTF16.h; sourceTree = "<group>"; };
7C7941E21C56C29300A4C58E /* DataDetectorsCoreSoftLink.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DataDetectorsCoreSoftLink.mm; sourceTree = "<group>"; };
7C7941E31C56C29300A4C58E /* DataDetectorsCoreSoftLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataDetectorsCoreSoftLink.h; sourceTree = "<group>"; };
+ 7C83DE851D04CBD400FEBCF3 /* SpringSolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpringSolver.h; sourceTree = "<group>"; };
7C91A38D1B498ABE003F9EFA /* JSNodeOrString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSNodeOrString.cpp; sourceTree = "<group>"; };
7C91A38E1B498ABE003F9EFA /* JSNodeOrString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSNodeOrString.h; sourceTree = "<group>"; };
7C93F3471AA6BA5E00A98BAB /* CompiledContentExtension.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CompiledContentExtension.cpp; sourceTree = "<group>"; };
@@ -22064,6 +22066,7 @@
0F3DD44E12F5EA1B000D9190 /* ShadowBlur.h */,
CD641EB21818F5ED00EE4C41 /* SourceBufferPrivate.h */,
CDC8B5AC1804AE5D0016E685 /* SourceBufferPrivateClient.h */,
+ 7C83DE851D04CBD400FEBCF3 /* SpringSolver.h */,
B23540F00D00782E002382FA /* StringTruncator.cpp */,
B23540F10D00782E002382FA /* StringTruncator.h */,
849F77750EFEC6200090849D /* StrokeStyleApplier.h */,
@@ -27840,6 +27843,7 @@
BC8B854B0E7C7F5600AB6984 /* ScrollbarTheme.h in Headers */,
BC14028B0E83680800319717 /* ScrollbarThemeComposite.h in Headers */,
44C991860F3D1EBE00586670 /* ScrollbarThemeIOS.h in Headers */,
+ 7C83DE861D04CC5D00FEBCF3 /* SpringSolver.h in Headers */,
BC8B853E0E7C7F1100AB6984 /* ScrollbarThemeMac.h in Headers */,
0FE71406142170B800DB33BA /* ScrollbarThemeMock.h in Headers */,
5D925B680F64D4DD00B847F0 /* ScrollBehavior.h in Headers */,
Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (201758 => 201759)
--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2016-06-07 18:15:31 UTC (rev 201759)
@@ -1498,10 +1498,10 @@
{
switch (timingFunction->type()) {
case TimingFunction::CubicBezierFunction: {
- const CubicBezierTimingFunction* bezierTimingFunction = static_cast<const CubicBezierTimingFunction*>(timingFunction);
- if (bezierTimingFunction->timingFunctionPreset() != CubicBezierTimingFunction::Custom) {
+ auto& function = *static_cast<const CubicBezierTimingFunction*>(timingFunction);
+ if (function.timingFunctionPreset() != CubicBezierTimingFunction::Custom) {
CSSValueID valueId = CSSValueInvalid;
- switch (bezierTimingFunction->timingFunctionPreset()) {
+ switch (function.timingFunctionPreset()) {
case CubicBezierTimingFunction::Ease:
valueId = CSSValueEase;
break;
@@ -1512,18 +1512,22 @@
valueId = CSSValueEaseOut;
break;
default:
- ASSERT(bezierTimingFunction->timingFunctionPreset() == CubicBezierTimingFunction::EaseInOut);
+ ASSERT(function.timingFunctionPreset() == CubicBezierTimingFunction::EaseInOut);
valueId = CSSValueEaseInOut;
break;
}
return CSSValuePool::singleton().createIdentifierValue(valueId);
}
- return CSSCubicBezierTimingFunctionValue::create(bezierTimingFunction->x1(), bezierTimingFunction->y1(), bezierTimingFunction->x2(), bezierTimingFunction->y2());
+ return CSSCubicBezierTimingFunctionValue::create(function.x1(), function.y1(), function.x2(), function.y2());
}
case TimingFunction::StepsFunction: {
- const StepsTimingFunction* stepsTimingFunction = static_cast<const StepsTimingFunction*>(timingFunction);
- return CSSStepsTimingFunctionValue::create(stepsTimingFunction->numberOfSteps(), stepsTimingFunction->stepAtStart());
+ auto& function = *static_cast<const StepsTimingFunction*>(timingFunction);
+ return CSSStepsTimingFunctionValue::create(function.numberOfSteps(), function.stepAtStart());
}
+ case TimingFunction::SpringFunction: {
+ auto& function = *static_cast<const SpringTimingFunction*>(timingFunction);
+ return CSSSpringTimingFunctionValue::create(function.mass(), function.stiffness(), function.damping(), function.initialVelocity());
+ }
default:
ASSERT(timingFunction->type() == TimingFunction::LinearFunction);
return CSSValuePool::singleton().createIdentifierValue(CSSValueLinear);
Modified: trunk/Source/WebCore/css/CSSParser.cpp (201758 => 201759)
--- trunk/Source/WebCore/css/CSSParser.cpp 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/Source/WebCore/css/CSSParser.cpp 2016-06-07 18:15:31 UTC (rev 201759)
@@ -270,6 +270,7 @@
#if ENABLE(IOS_TEXT_AUTOSIZING)
textAutosizingEnabled = settings->textAutosizingEnabled();
#endif
+ springTimingFunctionEnabled = settings->springTimingFunctionEnabled();
}
#if PLATFORM(IOS)
@@ -291,7 +292,8 @@
#endif
&& a.needsSiteSpecificQuirks == b.needsSiteSpecificQuirks
&& a.enforcesCSSMIMETypeInNoQuirksMode == b.enforcesCSSMIMETypeInNoQuirksMode
- && a.useLegacyBackgroundSizeShorthandBehavior == b.useLegacyBackgroundSizeShorthandBehavior;
+ && a.useLegacyBackgroundSizeShorthandBehavior == b.useLegacyBackgroundSizeShorthandBehavior
+ && a.springTimingFunctionEnabled == b.springTimingFunctionEnabled;
}
CSSParser::CSSParser(const CSSParserContext& context)
@@ -5157,23 +5159,38 @@
return true;
}
-bool CSSParser::parseCubicBezierTimingFunctionValue(CSSParserValueList& args, double& result)
+bool CSSParser::isSpringTimingFunctionEnabled() const
{
+ return m_context.springTimingFunctionEnabled;
+}
+
+Optional<double> CSSParser::parseCubicBezierTimingFunctionValue(CSSParserValueList& args)
+{
ValueWithCalculation argumentWithCalculation(*args.current());
if (!validateUnit(argumentWithCalculation, FNumber))
- return false;
- result = parsedDouble(argumentWithCalculation);
+ return Nullopt;
+ Optional<double> result = parsedDouble(argumentWithCalculation);
CSSParserValue* nextValue = args.next();
if (!nextValue) {
// The last number in the function has no comma after it, so we're done.
- return true;
+ return result;
}
if (!isComma(nextValue))
- return false;
+ return Nullopt;
args.next();
- return true;
+ return result;
}
+Optional<double> CSSParser::parseSpringTimingFunctionValue(CSSParserValueList& args)
+{
+ ValueWithCalculation argumentWithCalculation(*args.current());
+ if (!validateUnit(argumentWithCalculation, FNumber))
+ return Nullopt;
+ Optional<double> result = parsedDouble(argumentWithCalculation);
+ args.next();
+ return result;
+}
+
RefPtr<CSSValue> CSSParser::parseAnimationTimingFunction()
{
CSSParserValue& value = *m_valueList->current();
@@ -5219,27 +5236,58 @@
}
if (equalLettersIgnoringASCIICase(value.function->name, "cubic-bezier(")) {
- // For cubic bezier, 4 values must be specified.
+ // For cubic bezier, 4 values must be specified (comma-separated).
if (!args || args->size() != 7)
return nullptr;
// There are two points specified. The x values must be between 0 and 1 but the y values can exceed this range.
- double x1, y1, x2, y2;
- if (!parseCubicBezierTimingFunctionValue(*args, x1))
+ auto x1 = parseCubicBezierTimingFunctionValue(*args);
+ if (!x1 || x1.value() < 0 || x1.value() > 1)
return nullptr;
- if (x1 < 0 || x1 > 1)
+
+ auto y1 = parseCubicBezierTimingFunctionValue(*args);
+ if (!y1)
return nullptr;
- if (!parseCubicBezierTimingFunctionValue(*args, y1))
+
+ auto x2 = parseCubicBezierTimingFunctionValue(*args);
+ if (!x2 || x2.value() < 0 || x2.value() > 1)
return nullptr;
- if (!parseCubicBezierTimingFunctionValue(*args, x2))
+
+ auto y2 = parseCubicBezierTimingFunctionValue(*args);
+ if (!y2)
return nullptr;
- if (x2 < 0 || x2 > 1)
+
+ return CSSCubicBezierTimingFunctionValue::create(x1.value(), y1.value(), x2.value(), y2.value());
+ }
+
+ if (isSpringTimingFunctionEnabled() && equalLettersIgnoringASCIICase(value.function->name, "spring(")) {
+ // For a spring, 4 values must be specified (space-separated).
+ // FIXME: Make the arguments all optional.
+ if (!args || args->size() != 4)
return nullptr;
- if (!parseCubicBezierTimingFunctionValue(*args, y2))
+
+ // Mass must be greater than 0.
+ auto mass = parseSpringTimingFunctionValue(*args);
+ if (!mass || mass.value() <= 0)
return nullptr;
- return CSSCubicBezierTimingFunctionValue::create(x1, y1, x2, y2);
+ // Stiffness must be greater than 0.
+ auto stiffness = parseSpringTimingFunctionValue(*args);
+ if (!stiffness || stiffness.value() <= 0)
+ return nullptr;
+
+ // Damping coefficient must be greater than or equal to 0.
+ auto damping = parseSpringTimingFunctionValue(*args);
+ if (!damping || damping.value() < 0)
+ return nullptr;
+
+ // Initial velocity may have any value.
+ auto initialVelocity = parseSpringTimingFunctionValue(*args);
+ if (!initialVelocity)
+ return nullptr;
+
+ return CSSSpringTimingFunctionValue::create(mass.value(), stiffness.value(), damping.value(), initialVelocity.value());
}
return nullptr;
Modified: trunk/Source/WebCore/css/CSSParser.h (201758 => 201759)
--- trunk/Source/WebCore/css/CSSParser.h 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/Source/WebCore/css/CSSParser.h 2016-06-07 18:15:31 UTC (rev 201759)
@@ -214,11 +214,14 @@
static Vector<double> parseKeyframeSelector(const String&);
bool parseTransformOriginShorthand(RefPtr<CSSPrimitiveValue>&, RefPtr<CSSPrimitiveValue>&, RefPtr<CSSValue>&);
- bool parseCubicBezierTimingFunctionValue(CSSParserValueList& args, double& result);
+ Optional<double> parseCubicBezierTimingFunctionValue(CSSParserValueList&);
+ Optional<double> parseSpringTimingFunctionValue(CSSParserValueList&);
bool parseAnimationProperty(CSSPropertyID, RefPtr<CSSValue>&, AnimationParseContext&);
bool parseTransitionShorthand(CSSPropertyID, bool important);
bool parseAnimationShorthand(CSSPropertyID, bool important);
+ bool isSpringTimingFunctionEnabled() const;
+
RefPtr<CSSPrimitiveValue> parseColumnWidth();
RefPtr<CSSPrimitiveValue> parseColumnCount();
bool parseColumnsShorthand(bool important);
Modified: trunk/Source/WebCore/css/CSSParserMode.h (201758 => 201759)
--- trunk/Source/WebCore/css/CSSParserMode.h 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/Source/WebCore/css/CSSParserMode.h 2016-06-07 18:15:31 UTC (rev 201759)
@@ -73,6 +73,7 @@
bool needsSiteSpecificQuirks { false };
bool enforcesCSSMIMETypeInNoQuirksMode { true };
bool useLegacyBackgroundSizeShorthandBehavior { false };
+ bool springTimingFunctionEnabled { false };
};
bool operator==(const CSSParserContext&, const CSSParserContext&);
Modified: trunk/Source/WebCore/css/CSSTimingFunctionValue.cpp (201758 => 201759)
--- trunk/Source/WebCore/css/CSSTimingFunctionValue.cpp 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/Source/WebCore/css/CSSTimingFunctionValue.cpp 2016-06-07 18:15:31 UTC (rev 201759)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2013, 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,17 +26,23 @@
#include "config.h"
#include "CSSTimingFunctionValue.h"
-#include <wtf/text/WTFString.h>
+#include <wtf/text/StringBuilder.h>
namespace WebCore {
String CSSCubicBezierTimingFunctionValue::customCSSText() const
{
- return "cubic-bezier("
- + String::number(m_x1) + ", "
- + String::number(m_y1) + ", "
- + String::number(m_x2) + ", "
- + String::number(m_y2) + ')';
+ StringBuilder builder;
+ builder.appendLiteral("cubic-bezier(");
+ builder.appendNumber(m_x1);
+ builder.appendLiteral(", ");
+ builder.appendNumber(m_y1);
+ builder.appendLiteral(", ");
+ builder.appendNumber(m_x2);
+ builder.appendLiteral(", ");
+ builder.appendNumber(m_y2);
+ builder.append(')');
+ return builder.toString();
}
bool CSSCubicBezierTimingFunctionValue::equals(const CSSCubicBezierTimingFunctionValue& other) const
@@ -44,10 +50,16 @@
return m_x1 == other.m_x1 && m_x2 == other.m_x2 && m_y1 == other.m_y1 && m_y2 == other.m_y2;
}
-
String CSSStepsTimingFunctionValue::customCSSText() const
{
- return "steps(" + String::number(m_steps) + ", " + (m_stepAtStart ? "start" : "end") + ')';
+ StringBuilder builder;
+ builder.appendLiteral("steps(");
+ builder.appendNumber(m_steps);
+ if (m_stepAtStart)
+ builder.appendLiteral(", start)");
+ else
+ builder.appendLiteral(", end)");
+ return builder.toString();
}
bool CSSStepsTimingFunctionValue::equals(const CSSStepsTimingFunctionValue& other) const
@@ -55,4 +67,25 @@
return m_steps == other.m_steps && m_stepAtStart == other.m_stepAtStart;
}
+String CSSSpringTimingFunctionValue::customCSSText() const
+{
+ StringBuilder builder;
+ builder.appendLiteral("spring(");
+ builder.appendNumber(m_mass);
+ builder.append(' ');
+ builder.appendNumber(m_stiffness);
+ builder.append(' ');
+ builder.appendNumber(m_damping);
+ builder.append(' ');
+ builder.appendNumber(m_initialVelocity);
+ builder.append(')');
+ return builder.toString();
+}
+
+bool CSSSpringTimingFunctionValue::equals(const CSSSpringTimingFunctionValue& other) const
+{
+ return m_mass == other.m_mass && m_stiffness == other.m_stiffness && m_damping == other.m_damping && m_initialVelocity == other.m_initialVelocity;
+}
+
+
} // namespace WebCore
Modified: trunk/Source/WebCore/css/CSSTimingFunctionValue.h (201758 => 201759)
--- trunk/Source/WebCore/css/CSSTimingFunctionValue.h 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/Source/WebCore/css/CSSTimingFunctionValue.h 2016-06-07 18:15:31 UTC (rev 201759)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008, 2012, 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -89,9 +89,42 @@
bool m_stepAtStart;
};
+class CSSSpringTimingFunctionValue : public CSSValue {
+public:
+ static Ref<CSSSpringTimingFunctionValue> create(double mass, double stiffness, double damping, double initialVelocity)
+ {
+ return adoptRef(*new CSSSpringTimingFunctionValue(mass, stiffness, damping, initialVelocity));
+ }
+
+ double mass() const { return m_mass; }
+ double stiffness() const { return m_stiffness; }
+ double damping() const { return m_damping; }
+ double initialVelocity() const { return m_initialVelocity; }
+
+ String customCSSText() const;
+
+ bool equals(const CSSSpringTimingFunctionValue&) const;
+
+private:
+ CSSSpringTimingFunctionValue(double mass, double stiffness, double damping, double initialVelocity)
+ : CSSValue(SpringTimingFunctionClass)
+ , m_mass(mass)
+ , m_stiffness(stiffness)
+ , m_damping(damping)
+ , m_initialVelocity(initialVelocity)
+ {
+ }
+
+ double m_mass;
+ double m_stiffness;
+ double m_damping;
+ double m_initialVelocity;
+};
+
} // namespace WebCore
SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSCubicBezierTimingFunctionValue, isCubicBezierTimingFunctionValue())
SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSStepsTimingFunctionValue, isStepsTimingFunctionValue())
+SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSSpringTimingFunctionValue, isSpringTimingFunctionValue())
#endif // CSSTimingFunctionValue_h
Modified: trunk/Source/WebCore/css/CSSToStyleMap.cpp (201758 => 201759)
--- trunk/Source/WebCore/css/CSSToStyleMap.cpp 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/Source/WebCore/css/CSSToStyleMap.cpp 2016-06-07 18:15:31 UTC (rev 201759)
@@ -510,6 +510,9 @@
} else if (is<CSSStepsTimingFunctionValue>(value)) {
auto& stepsTimingFunction = downcast<CSSStepsTimingFunctionValue>(value);
animation.setTimingFunction(StepsTimingFunction::create(stepsTimingFunction.numberOfSteps(), stepsTimingFunction.stepAtStart()));
+ } else if (is<CSSSpringTimingFunctionValue>(value)) {
+ auto& springTimingFunction = downcast<CSSSpringTimingFunctionValue>(value);
+ animation.setTimingFunction(SpringTimingFunction::create(springTimingFunction.mass(), springTimingFunction.stiffness(), springTimingFunction.damping(), springTimingFunction.initialVelocity()));
}
}
Modified: trunk/Source/WebCore/css/CSSValue.cpp (201758 => 201759)
--- trunk/Source/WebCore/css/CSSValue.cpp 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/Source/WebCore/css/CSSValue.cpp 2016-06-07 18:15:31 UTC (rev 201759)
@@ -226,6 +226,8 @@
return compareCSSValues<CSSCubicBezierTimingFunctionValue>(*this, other);
case StepsTimingFunctionClass:
return compareCSSValues<CSSStepsTimingFunctionValue>(*this, other);
+ case SpringTimingFunctionClass:
+ return compareCSSValues<CSSSpringTimingFunctionValue>(*this, other);
case UnicodeRangeClass:
return compareCSSValues<CSSUnicodeRangeValue>(*this, other);
case ValueListClass:
@@ -332,6 +334,8 @@
return downcast<CSSCubicBezierTimingFunctionValue>(*this).customCSSText();
case StepsTimingFunctionClass:
return downcast<CSSStepsTimingFunctionValue>(*this).customCSSText();
+ case SpringTimingFunctionClass:
+ return downcast<CSSSpringTimingFunctionValue>(*this).customCSSText();
case UnicodeRangeClass:
return downcast<CSSUnicodeRangeValue>(*this).customCSSText();
case ValueListClass:
@@ -457,6 +461,9 @@
case StepsTimingFunctionClass:
delete downcast<CSSStepsTimingFunctionValue>(this);
return;
+ case SpringTimingFunctionClass:
+ delete downcast<CSSSpringTimingFunctionValue>(this);
+ return;
case UnicodeRangeClass:
delete downcast<CSSUnicodeRangeValue>(this);
return;
Modified: trunk/Source/WebCore/css/CSSValue.h (201758 => 201759)
--- trunk/Source/WebCore/css/CSSValue.h 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/Source/WebCore/css/CSSValue.h 2016-06-07 18:15:31 UTC (rev 201759)
@@ -104,6 +104,7 @@
bool isShadowValue() const { return m_classType == ShadowClass; }
bool isCubicBezierTimingFunctionValue() const { return m_classType == CubicBezierTimingFunctionClass; }
bool isStepsTimingFunctionValue() const { return m_classType == StepsTimingFunctionClass; }
+ bool isSpringTimingFunctionValue() const { return m_classType == SpringTimingFunctionClass; }
bool isWebKitCSSTransformValue() const { return m_classType == WebKitCSSTransformClass; }
bool isLineBoxContainValue() const { return m_classType == LineBoxContainClass; }
bool isCalcValue() const {return m_classType == CalculationClass; }
@@ -161,6 +162,7 @@
// Timing function classes.
CubicBezierTimingFunctionClass,
StepsTimingFunctionClass,
+ SpringTimingFunctionClass,
// Other class types.
AspectRatioClass,
Modified: trunk/Source/WebCore/page/Settings.in (201758 => 201759)
--- trunk/Source/WebCore/page/Settings.in 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/Source/WebCore/page/Settings.in 2016-06-07 18:15:31 UTC (rev 201759)
@@ -267,3 +267,5 @@
selectionPaintingWithoutSelectionGapsEnabled initial=false
shouldConvertInvalidURLsToBlank initial=true
+
+springTimingFunctionEnabled initial=false
Modified: trunk/Source/WebCore/page/animation/AnimationBase.cpp (201758 => 201759)
--- trunk/Source/WebCore/page/animation/AnimationBase.cpp 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/Source/WebCore/page/animation/AnimationBase.cpp 2016-06-07 18:15:31 UTC (rev 201759)
@@ -41,6 +41,7 @@
#include "RenderBox.h"
#include "RenderStyle.h"
#include "RenderView.h"
+#include "SpringSolver.h"
#include "UnitBezier.h"
#include <algorithm>
#include <wtf/CurrentTime.h>
@@ -70,6 +71,12 @@
return floor(numSteps * t) / numSteps;
}
+static inline double solveSpringFunction(double mass, double stiffness, double damping, double initialVelocity, double t, double duration)
+{
+ SpringSolver solver(mass, stiffness, damping, initialVelocity);
+ return solver.solve(t * duration);
+}
+
AnimationBase::AnimationBase(const Animation& animation, RenderElement* renderer, CompositeAnimation* compositeAnimation)
: m_object(renderer)
, m_compositeAnimation(compositeAnimation)
@@ -648,13 +655,17 @@
switch (timingFunction->type()) {
case TimingFunction::CubicBezierFunction: {
- const CubicBezierTimingFunction* function = static_cast<const CubicBezierTimingFunction*>(timingFunction);
- return solveCubicBezierFunction(function->x1(), function->y1(), function->x2(), function->y2(), fractionalTime, m_animation->duration());
+ auto& function = *static_cast<const CubicBezierTimingFunction*>(timingFunction);
+ return solveCubicBezierFunction(function.x1(), function.y1(), function.x2(), function.y2(), fractionalTime, m_animation->duration());
}
case TimingFunction::StepsFunction: {
- const StepsTimingFunction* stepsTimingFunction = static_cast<const StepsTimingFunction*>(timingFunction);
- return solveStepsFunction(stepsTimingFunction->numberOfSteps(), stepsTimingFunction->stepAtStart(), fractionalTime);
+ auto& function = *static_cast<const StepsTimingFunction*>(timingFunction);
+ return solveStepsFunction(function.numberOfSteps(), function.stepAtStart(), fractionalTime);
}
+ case TimingFunction::SpringFunction: {
+ auto& function = *static_cast<const SpringTimingFunction*>(timingFunction);
+ return solveSpringFunction(function.mass(), function.stiffness(), function.damping(), function.initialVelocity(), fractionalTime, m_animation->duration());
+ }
case TimingFunction::LinearFunction:
return fractionalTime;
}
Modified: trunk/Source/WebCore/platform/animation/TimingFunction.cpp (201758 => 201759)
--- trunk/Source/WebCore/platform/animation/TimingFunction.cpp 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/Source/WebCore/platform/animation/TimingFunction.cpp 2016-06-07 18:15:31 UTC (rev 201759)
@@ -37,16 +37,21 @@
ts << "linear";
break;
case TimingFunction::CubicBezierFunction: {
- const CubicBezierTimingFunction& cubicBezierFunction = static_cast<const CubicBezierTimingFunction&>(timingFunction);
- ts << "cubic-bezier(" << cubicBezierFunction.x1() << ", " << cubicBezierFunction.y1() << ", " << cubicBezierFunction.x2() << ", " << cubicBezierFunction.y2() << ")";
+ auto& function = static_cast<const CubicBezierTimingFunction&>(timingFunction);
+ ts << "cubic-bezier(" << function.x1() << ", " << function.y1() << ", " << function.x2() << ", " << function.y2() << ")";
break;
}
case TimingFunction::StepsFunction: {
- const StepsTimingFunction& stepsFunction = static_cast<const StepsTimingFunction&>(timingFunction);
- ts << "steps(" << stepsFunction.numberOfSteps() << ", " << (stepsFunction.stepAtStart() ? "start" : "end") << ")";
+ auto& function = static_cast<const StepsTimingFunction&>(timingFunction);
+ ts << "steps(" << function.numberOfSteps() << ", " << (function.stepAtStart() ? "start" : "end") << ")";
break;
}
+ case TimingFunction::SpringFunction: {
+ auto& function = static_cast<const SpringTimingFunction&>(timingFunction);
+ ts << "spring(" << function.mass() << " " << function.stiffness() << " " << function.damping() << " " << function.initialVelocity() << ")";
+ break;
}
+ }
return ts;
}
Modified: trunk/Source/WebCore/platform/animation/TimingFunction.h (201758 => 201759)
--- trunk/Source/WebCore/platform/animation/TimingFunction.h 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/Source/WebCore/platform/animation/TimingFunction.h 2016-06-07 18:15:31 UTC (rev 201759)
@@ -36,7 +36,7 @@
virtual PassRefPtr<TimingFunction> clone() const = 0;
enum TimingFunctionType {
- LinearFunction, CubicBezierFunction, StepsFunction
+ LinearFunction, CubicBezierFunction, StepsFunction, SpringFunction
};
virtual ~TimingFunction() { }
@@ -46,6 +46,7 @@
bool isLinearTimingFunction() const { return m_type == LinearFunction; }
bool isCubicBezierTimingFunction() const { return m_type == CubicBezierFunction; }
bool isStepsTimingFunction() const { return m_type == StepsFunction; }
+ bool isSpringTimingFunction() const { return m_type == SpringFunction; }
virtual bool operator==(const TimingFunction& other) = 0;
@@ -58,7 +59,7 @@
TimingFunctionType m_type;
};
-class LinearTimingFunction : public TimingFunction {
+class LinearTimingFunction final : public TimingFunction {
public:
static PassRefPtr<LinearTimingFunction> create()
{
@@ -84,7 +85,7 @@
}
};
-class CubicBezierTimingFunction : public TimingFunction {
+class CubicBezierTimingFunction final : public TimingFunction {
public:
enum TimingFunctionPreset {
Ease,
@@ -185,7 +186,7 @@
TimingFunctionPreset m_timingFunctionPreset;
};
-class StepsTimingFunction : public TimingFunction {
+class StepsTimingFunction final : public TimingFunction {
public:
static PassRefPtr<StepsTimingFunction> create(int steps, bool stepAtStart)
@@ -231,6 +232,63 @@
bool m_stepAtStart;
};
+class SpringTimingFunction final : public TimingFunction {
+public:
+ static Ref<SpringTimingFunction> create(double mass, double stiffness, double damping, double initialVelocity)
+ {
+ return adoptRef(*new SpringTimingFunction(mass, stiffness, damping, initialVelocity));
+ }
+
+ static Ref<SpringTimingFunction> create()
+ {
+ // This create() function should only be used by the argument decoders, and it is expected that
+ // real values will be filled in using setValues().
+ return create(0, 0, 0, 0);
+ }
+
+ bool operator==(const TimingFunction& other) override
+ {
+ if (other.isSpringTimingFunction()) {
+ const SpringTimingFunction& otherString = *static_cast<const SpringTimingFunction*>(&other);
+ return m_mass == otherString.m_mass && m_stiffness == otherString.m_stiffness && m_damping == otherString.m_damping && m_initialVelocity == otherString.m_initialVelocity;
+ }
+ return false;
+ }
+
+ double mass() const { return m_mass; }
+ double stiffness() const { return m_stiffness; }
+ double damping() const { return m_damping; }
+ double initialVelocity() const { return m_initialVelocity; }
+
+ void setValues(double mass, double stiffness, double damping, double initialVelocity)
+ {
+ m_mass = mass;
+ m_stiffness = stiffness;
+ m_damping = damping;
+ m_initialVelocity = initialVelocity;
+ }
+
+private:
+ explicit SpringTimingFunction(double mass, double stiffness, double damping, double initialVelocity)
+ : TimingFunction(SpringFunction)
+ , m_mass(mass)
+ , m_stiffness(stiffness)
+ , m_damping(damping)
+ , m_initialVelocity(initialVelocity)
+ {
+ }
+
+ PassRefPtr<TimingFunction> clone() const override
+ {
+ return adoptRef(new SpringTimingFunction(m_mass, m_stiffness, m_damping, m_initialVelocity));
+ }
+
+ double m_mass;
+ double m_stiffness;
+ double m_damping;
+ double m_initialVelocity;
+};
+
class TextStream;
WEBCORE_EXPORT TextStream& operator<<(TextStream&, const TimingFunction&);
Added: trunk/Source/WebCore/platform/graphics/SpringSolver.h (0 => 201759)
--- trunk/Source/WebCore/platform/graphics/SpringSolver.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/SpringSolver.h 2016-06-07 18:15:31 UTC (rev 201759)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace WebCore {
+
+class SpringSolver {
+public:
+ SpringSolver(double mass, double stiffness, double damping, double initialVelocity)
+ {
+ m_w0 = std::sqrt(stiffness / mass);
+ m_zeta = damping / (2 * std::sqrt(stiffness * mass));
+
+ if (m_zeta < 1) {
+ // Under-damped.
+ m_wd = m_w0 * std::sqrt(1 - m_zeta * m_zeta);
+ m_A = 1;
+ m_B = (m_zeta * m_w0 + -initialVelocity) / m_wd;
+ } else {
+ // Critically damped (ignoring over-damped case for now).
+ m_A = 1;
+ m_B = -initialVelocity + m_w0;
+ }
+ }
+
+ double solve(double t)
+ {
+ if (m_zeta < 1) {
+ // Under-damped
+ t = std::exp(-t * m_zeta * m_w0) * (m_A * std::cos(m_wd * t) + m_B * std::sin(m_wd * t));
+ } else {
+ // Critically damped (ignoring over-damped case for now).
+ t = (m_A + m_B * t) * std::exp(-t * m_w0);
+ }
+
+ // Map range from [1..0] to [0..1].
+ return 1 - t;
+ }
+
+private:
+ double m_w0;
+ double m_zeta;
+ double m_wd;
+ double m_A;
+ double m_B;
+};
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (201758 => 201759)
--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp 2016-06-07 18:15:31 UTC (rev 201759)
@@ -2743,7 +2743,10 @@
caAnimation = createKeyframeAnimation(animation, propertyIdToString(valueList.property()), additive);
valuesOK = setAnimationKeyframes(valueList, animation, caAnimation.get());
} else {
- caAnimation = createBasicAnimation(animation, propertyIdToString(valueList.property()), additive);
+ if (animation->timingFunction()->isSpringTimingFunction())
+ caAnimation = createSpringAnimation(animation, propertyIdToString(valueList.property()), additive);
+ else
+ caAnimation = createBasicAnimation(animation, propertyIdToString(valueList.property()), additive);
valuesOK = setAnimationEndpoints(valueList, animation, caAnimation.get());
}
@@ -2767,7 +2770,10 @@
caAnimation = createKeyframeAnimation(animation, propertyIdToString(valueList.property()), additive);
validMatrices = setTransformAnimationKeyframes(valueList, animation, caAnimation.get(), animationIndex, transformOp, isMatrixAnimation, boxSize);
} else {
- caAnimation = createBasicAnimation(animation, propertyIdToString(valueList.property()), additive);
+ if (animation->timingFunction()->isSpringTimingFunction())
+ caAnimation = createSpringAnimation(animation, propertyIdToString(valueList.property()), additive);
+ else
+ caAnimation = createBasicAnimation(animation, propertyIdToString(valueList.property()), additive);
validMatrices = setTransformAnimationEndpoints(valueList, animation, caAnimation.get(), animationIndex, transformOp, isMatrixAnimation, boxSize);
}
@@ -2901,13 +2907,20 @@
return basicAnim;
}
-PassRefPtr<PlatformCAAnimation>GraphicsLayerCA::createKeyframeAnimation(const Animation* anim, const String& keyPath, bool additive)
+PassRefPtr<PlatformCAAnimation> GraphicsLayerCA::createKeyframeAnimation(const Animation* anim, const String& keyPath, bool additive)
{
RefPtr<PlatformCAAnimation> keyframeAnim = createPlatformCAAnimation(PlatformCAAnimation::Keyframe, keyPath);
setupAnimation(keyframeAnim.get(), anim, additive);
return keyframeAnim;
}
+RefPtr<PlatformCAAnimation> GraphicsLayerCA::createSpringAnimation(const Animation* anim, const String& keyPath, bool additive)
+{
+ auto basicAnim = createPlatformCAAnimation(PlatformCAAnimation::Spring, keyPath);
+ setupAnimation(basicAnim.get(), anim, additive);
+ return basicAnim;
+}
+
void GraphicsLayerCA::setupAnimation(PlatformCAAnimation* propertyAnim, const Animation* anim, bool additive)
{
double duration = anim->duration();
Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h (201758 => 201759)
--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h 2016-06-07 18:15:31 UTC (rev 201759)
@@ -242,6 +242,7 @@
// Return autoreleased animation (use RetainPtr?)
PassRefPtr<PlatformCAAnimation> createBasicAnimation(const Animation*, const String& keyPath, bool additive);
PassRefPtr<PlatformCAAnimation> createKeyframeAnimation(const Animation*, const String&, bool additive);
+ RefPtr<PlatformCAAnimation> createSpringAnimation(const Animation*, const String&, bool additive);
void setupAnimation(PlatformCAAnimation*, const Animation*, bool additive);
const TimingFunction* timingFunctionForAnimationValue(const AnimationValue&, const Animation&);
Modified: trunk/Source/WebCore/platform/graphics/ca/PlatformCAAnimation.cpp (201758 => 201759)
--- trunk/Source/WebCore/platform/graphics/ca/PlatformCAAnimation.cpp 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/Source/WebCore/platform/graphics/ca/PlatformCAAnimation.cpp 2016-06-07 18:15:31 UTC (rev 201759)
@@ -35,6 +35,7 @@
switch (type) {
case PlatformCAAnimation::Basic: ts << "basic"; break;
case PlatformCAAnimation::Keyframe: ts << "keyframe"; break;
+ case PlatformCAAnimation::Spring: ts << "spring"; break;
}
return ts;
}
@@ -69,4 +70,9 @@
return ts;
}
+bool PlatformCAAnimation::isBasicAnimation() const
+{
+ return animationType() == Basic || animationType() == Spring;
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/ca/PlatformCAAnimation.h (201758 => 201759)
--- trunk/Source/WebCore/platform/graphics/ca/PlatformCAAnimation.h 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/Source/WebCore/platform/graphics/ca/PlatformCAAnimation.h 2016-06-07 18:15:31 UTC (rev 201759)
@@ -41,7 +41,7 @@
class PlatformCAAnimation : public RefCounted<PlatformCAAnimation> {
public:
- enum AnimationType { Basic, Keyframe };
+ enum AnimationType { Basic, Keyframe, Spring };
enum FillModeType { NoFillMode, Forwards, Backwards, Both };
enum ValueFunctionType { NoValueFunction, RotateX, RotateY, RotateZ, ScaleX, ScaleY, ScaleZ, Scale, TranslateX, TranslateY, TranslateZ, Translate };
@@ -123,6 +123,8 @@
if (beginTime() <= 0)
setBeginTime(t);
}
+
+ bool isBasicAnimation() const;
protected:
PlatformCAAnimation(AnimationType type = Basic)
Modified: trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCAAnimationCocoa.mm (201758 => 201759)
--- trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCAAnimationCocoa.mm 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCAAnimationCocoa.mm 2016-06-07 18:15:31 UTC (rev 201759)
@@ -23,11 +23,12 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "config.h"
+#import "config.h"
#import "PlatformCAAnimationCocoa.h"
#import "FloatConversion.h"
#import "PlatformCAFilters.h"
+#import "QuartzCoreSPI.h"
#import "TimingFunction.h"
#import <QuartzCore/QuartzCore.h>
#import <wtf/text/WTFString.h>
@@ -161,20 +162,30 @@
PlatformCAAnimationCocoa::PlatformCAAnimationCocoa(AnimationType type, const String& keyPath)
: PlatformCAAnimation(type)
{
- if (type == Basic)
+ switch (type) {
+ case Basic:
m_animation = [CABasicAnimation animationWithKeyPath:keyPath];
- else
+ break;
+ case Keyframe:
m_animation = [CAKeyframeAnimation animationWithKeyPath:keyPath];
+ break;
+ case Spring:
+ m_animation = [CASpringAnimation animationWithKeyPath:keyPath];
+ break;
+ }
}
PlatformCAAnimationCocoa::PlatformCAAnimationCocoa(PlatformAnimationRef animation)
{
- if ([static_cast<CAAnimation*>(animation) isKindOfClass:[CABasicAnimation class]])
- setType(Basic);
- else if ([static_cast<CAAnimation*>(animation) isKindOfClass:[CAKeyframeAnimation class]])
+ if ([static_cast<CAAnimation*>(animation) isKindOfClass:[CABasicAnimation class]]) {
+ if ([static_cast<CAAnimation*>(animation) isKindOfClass:[CASpringAnimation class]])
+ setType(Spring);
+ else
+ setType(Basic);
+ } else if ([static_cast<CAAnimation*>(animation) isKindOfClass:[CAKeyframeAnimation class]])
setType(Keyframe);
else {
- ASSERT(0);
+ ASSERT_NOT_REACHED();
return;
}
@@ -305,7 +316,27 @@
void PlatformCAAnimationCocoa::setTimingFunction(const TimingFunction* value, bool reverse)
{
- [m_animation setTimingFunction:toCAMediaTimingFunction(value, reverse)];
+ switch (animationType()) {
+ case Basic:
+ case Keyframe:
+ [m_animation setTimingFunction:toCAMediaTimingFunction(value, reverse)];
+ break;
+ case Spring:
+ if (value->isSpringTimingFunction()) {
+ // FIXME: Handle reverse.
+ auto& function = *static_cast<const SpringTimingFunction*>(value);
+ CASpringAnimation *springAnimation = (CASpringAnimation *)m_animation.get();
+ springAnimation.mass = function.mass();
+ springAnimation.stiffness = function.stiffness();
+ springAnimation.damping = function.damping();
+#if PLATFORM(IOS) || PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
+ springAnimation.initialVelocity = function.initialVelocity();
+#else
+ springAnimation.velocity = function.initialVelocity();
+#endif
+ }
+ break;
+ }
}
void PlatformCAAnimationCocoa::copyTimingFunctionFrom(const PlatformCAAnimation& value)
@@ -346,14 +377,14 @@
void PlatformCAAnimationCocoa::setFromValue(float value)
{
- if (animationType() != Basic)
+ if (!isBasicAnimation())
return;
[static_cast<CABasicAnimation*>(m_animation.get()) setFromValue:[NSNumber numberWithDouble:value]];
}
void PlatformCAAnimationCocoa::setFromValue(const WebCore::TransformationMatrix& value)
{
- if (animationType() != Basic)
+ if (!isBasicAnimation())
return;
[static_cast<CABasicAnimation*>(m_animation.get()) setFromValue:[NSValue valueWithCATransform3D:value]];
@@ -361,7 +392,7 @@
void PlatformCAAnimationCocoa::setFromValue(const FloatPoint3D& value)
{
- if (animationType() != Basic)
+ if (!isBasicAnimation())
return;
NSArray* array = [NSArray arrayWithObjects:
@@ -374,7 +405,7 @@
void PlatformCAAnimationCocoa::setFromValue(const WebCore::Color& value)
{
- if (animationType() != Basic)
+ if (!isBasicAnimation())
return;
NSArray* array = [NSArray arrayWithObjects:
@@ -394,7 +425,7 @@
void PlatformCAAnimationCocoa::copyFromValueFrom(const PlatformCAAnimation& value)
{
- if (animationType() != Basic || value.animationType() != Basic)
+ if (!isBasicAnimation() || !value.isBasicAnimation())
return;
CABasicAnimation* otherAnimation = static_cast<CABasicAnimation*>(downcast<PlatformCAAnimationCocoa>(value).m_animation.get());
@@ -403,14 +434,14 @@
void PlatformCAAnimationCocoa::setToValue(float value)
{
- if (animationType() != Basic)
+ if (!isBasicAnimation())
return;
[static_cast<CABasicAnimation*>(m_animation.get()) setToValue:[NSNumber numberWithDouble:value]];
}
void PlatformCAAnimationCocoa::setToValue(const WebCore::TransformationMatrix& value)
{
- if (animationType() != Basic)
+ if (!isBasicAnimation())
return;
[static_cast<CABasicAnimation*>(m_animation.get()) setToValue:[NSValue valueWithCATransform3D:value]];
@@ -418,7 +449,7 @@
void PlatformCAAnimationCocoa::setToValue(const FloatPoint3D& value)
{
- if (animationType() != Basic)
+ if (!isBasicAnimation())
return;
NSArray* array = [NSArray arrayWithObjects:
@@ -431,7 +462,7 @@
void PlatformCAAnimationCocoa::setToValue(const WebCore::Color& value)
{
- if (animationType() != Basic)
+ if (!isBasicAnimation())
return;
NSArray* array = [NSArray arrayWithObjects:
@@ -451,7 +482,7 @@
void PlatformCAAnimationCocoa::copyToValueFrom(const PlatformCAAnimation& value)
{
- if (animationType() != Basic || value.animationType() != Basic)
+ if (!isBasicAnimation() || !value.isBasicAnimation())
return;
CABasicAnimation* otherAnimation = static_cast<CABasicAnimation*>(downcast<PlatformCAAnimationCocoa>(value).m_animation.get());
Modified: trunk/Source/WebCore/platform/spi/cocoa/QuartzCoreSPI.h (201758 => 201759)
--- trunk/Source/WebCore/platform/spi/cocoa/QuartzCoreSPI.h 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/Source/WebCore/platform/spi/cocoa/QuartzCoreSPI.h 2016-06-07 18:15:31 UTC (rev 201759)
@@ -141,6 +141,19 @@
@property BOOL inheritsSecurity;
@end
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED <= 101000
+@interface CASpringAnimation : CABasicAnimation
+@property CGFloat mass;
+@property CGFloat stiffness;
+@property CGFloat damping;
+@property CGFloat velocity;
+@end
+#else
+@interface CASpringAnimation (Private)
+@property CGFloat velocity;
+@end
+#endif
+
#endif // __OBJC__
#endif
Modified: trunk/Source/WebKit2/ChangeLog (201758 => 201759)
--- trunk/Source/WebKit2/ChangeLog 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/Source/WebKit2/ChangeLog 2016-06-07 18:15:31 UTC (rev 201759)
@@ -1,3 +1,25 @@
+2016-06-05 Sam Weinig <s...@webkit.org>
+
+ Add experimental support for spring based CSS animations
+ https://bugs.webkit.org/show_bug.cgi?id=158403
+
+ Reviewed by Dean Jackson.
+
+ * Shared/WebCoreArgumentCoders.cpp:
+ (IPC::ArgumentCoder<StepsTimingFunction>::decode):
+ (IPC::ArgumentCoder<SpringTimingFunction>::encode):
+ (IPC::ArgumentCoder<SpringTimingFunction>::decode):
+ (IPC::ArgumentCoder<FloatPoint>::encode):
+ * Shared/WebCoreArgumentCoders.h:
+ * Shared/WebPreferencesDefinitions.h:
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::updatePreferences):
+ * WebProcess/WebPage/mac/PlatformCAAnimationRemote.mm:
+ (WebKit::PlatformCAAnimationRemote::Properties::encode):
+ (WebKit::PlatformCAAnimationRemote::Properties::decode):
+ (WebKit::addAnimationToLayer):
+ Pipe through support for the Spring animation.
+
2016-06-07 Michael Catanzaro <mcatanz...@igalia.com>
[GTK] Hide GTK+ 2 plugins if GTK+ 2 plugin process was built but is not installed
Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp (201758 => 201759)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp 2016-06-07 18:15:31 UTC (rev 201759)
@@ -365,7 +365,15 @@
encoder << steps->stepAtStart();
break;
}
+ case TimingFunction::SpringFunction: {
+ const SpringTimingFunction* spring = static_cast<const SpringTimingFunction*>(timingFunction);
+ encoder << spring->mass();
+ encoder << spring->stiffness();
+ encoder << spring->damping();
+ encoder << spring->initialVelocity();
+ break;
}
+ }
}
bool decodeTimingFunction(ArgumentDecoder& decoder, RefPtr<TimingFunction>& timingFunction)
@@ -413,7 +421,24 @@
timingFunction = StepsTimingFunction::create(numberOfSteps, stepAtStart);
return true;
}
+ case TimingFunction::SpringFunction: {
+ double mass;
+ if (!decoder.decode(mass))
+ return false;
+ double stiffness;
+ if (!decoder.decode(stiffness))
+ return false;
+ double damping;
+ if (!decoder.decode(damping))
+ return false;
+ double initialVelocity;
+ if (!decoder.decode(initialVelocity))
+ return false;
+
+ timingFunction = SpringTimingFunction::create(mass, stiffness, damping, initialVelocity);
+ return true;
}
+ }
return false;
}
Modified: trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp (201758 => 201759)
--- trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp 2016-06-07 18:15:31 UTC (rev 201759)
@@ -265,6 +265,40 @@
return true;
}
+void ArgumentCoder<SpringTimingFunction>::encode(ArgumentEncoder& encoder, const SpringTimingFunction& timingFunction)
+{
+ encoder.encodeEnum(timingFunction.type());
+
+ encoder << timingFunction.mass();
+ encoder << timingFunction.stiffness();
+ encoder << timingFunction.damping();
+ encoder << timingFunction.initialVelocity();
+}
+
+bool ArgumentCoder<SpringTimingFunction>::decode(ArgumentDecoder& decoder, SpringTimingFunction& timingFunction)
+{
+ // Type is decoded by the caller.
+ double mass;
+ if (!decoder.decode(mass))
+ return false;
+
+ double stiffness;
+ if (!decoder.decode(stiffness))
+ return false;
+
+ double damping;
+ if (!decoder.decode(damping))
+ return false;
+
+ double initialVelocity;
+ if (!decoder.decode(initialVelocity))
+ return false;
+
+ timingFunction.setValues(mass, stiffness, damping, initialVelocity);
+
+ return true;
+}
+
void ArgumentCoder<FloatPoint>::encode(ArgumentEncoder& encoder, const FloatPoint& floatPoint)
{
SimpleArgumentCoder<FloatPoint>::encode(encoder, floatPoint);
Modified: trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.h (201758 => 201759)
--- trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.h 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.h 2016-06-07 18:15:31 UTC (rev 201759)
@@ -60,6 +60,7 @@
class ResourceRequest;
class ResourceResponse;
class SessionID;
+class SpringTimingFunction;
class StepsTimingFunction;
class StickyPositionViewportConstraints;
class TextCheckingRequestData;
@@ -151,6 +152,11 @@
static bool decode(ArgumentDecoder&, WebCore::StepsTimingFunction&);
};
+template<> struct ArgumentCoder<WebCore::SpringTimingFunction> {
+ static void encode(ArgumentEncoder&, const WebCore::SpringTimingFunction&);
+ static bool decode(ArgumentDecoder&, WebCore::SpringTimingFunction&);
+};
+
template<> struct ArgumentCoder<WebCore::CertificateInfo> {
static void encode(ArgumentEncoder&, const WebCore::CertificateInfo&);
static bool decode(ArgumentDecoder&, WebCore::CertificateInfo&);
Modified: trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h (201758 => 201759)
--- trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h 2016-06-07 18:15:31 UTC (rev 201759)
@@ -293,6 +293,7 @@
macro(CSSGridLayoutEnabled, cssGridLayoutEnabled, Bool, bool, true, "CSS Grid", "CSS Grid Layout Module support") \
macro(CustomElementsEnabled, customElementsEnabled, Bool, bool, true, "Custom Elements", "HTML Custom Elements prototype") \
macro(WebGL2Enabled, webGL2Enabled, Bool, bool, true, "WebGL 2.0", "WebGL 2 prototype") \
+ macro(SpringTimingFunctionEnabled, springTimingFunctionEnabled, Bool, bool, true, "CSS Spring Animations", "CSS Spring Animation prototype") \
\
#if PLATFORM(COCOA)
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (201758 => 201759)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2016-06-07 18:15:31 UTC (rev 201759)
@@ -3150,6 +3150,8 @@
RuntimeEnabledFeatures::sharedFeatures().setWebGL2Enabled(store.getBoolValueForKey(WebPreferencesKey::webGL2EnabledKey()));
#endif
+ settings.setSpringTimingFunctionEnabled(store.getBoolValueForKey(WebPreferencesKey::springTimingFunctionEnabledKey()));
+
bool processSuppressionEnabled = store.getBoolValueForKey(WebPreferencesKey::pageVisibilityBasedProcessSuppressionEnabledKey());
if (m_processSuppressionEnabled != processSuppressionEnabled) {
m_processSuppressionEnabled = processSuppressionEnabled;
Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCAAnimationRemote.mm (201758 => 201759)
--- trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCAAnimationRemote.mm 2016-06-07 18:13:26 UTC (rev 201758)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCAAnimationRemote.mm 2016-06-07 18:15:31 UTC (rev 201759)
@@ -196,6 +196,10 @@
case TimingFunction::StepsFunction:
encoder << *static_cast<StepsTimingFunction*>(timingFunction.get());
break;
+
+ case TimingFunction::SpringFunction:
+ encoder << *static_cast<SpringTimingFunction*>(timingFunction.get());
+ break;
}
}
}
@@ -282,6 +286,12 @@
if (!decoder.decode(*static_cast<StepsTimingFunction*>(timingFunction.get())))
return false;
break;
+
+ case TimingFunction::SpringFunction:
+ timingFunction = SpringTimingFunction::create();
+ if (!decoder.decode(*static_cast<SpringTimingFunction*>(timingFunction.get())))
+ return false;
+ break;
}
properties.timingFunctions.uncheckedAppend(timingFunction.release());
@@ -754,7 +764,29 @@
caAnimation = keyframeAnimation;
break;
}
+ case PlatformCAAnimation::Spring: {
+ RetainPtr<CASpringAnimation> springAnimation;
+ springAnimation = [CASpringAnimation animationWithKeyPath:properties.keyPath];
+
+ if (properties.keyValues.size() > 1) {
+ [springAnimation setFromValue:animationValueFromKeyframeValue(properties.keyValues[0])];
+ [springAnimation setToValue:animationValueFromKeyframeValue(properties.keyValues[1])];
+ }
+
+ if (properties.timingFunctions.size()) {
+ auto& timingFunction = properties.timingFunctions[0];
+ if (timingFunction->isSpringTimingFunction()) {
+ auto& function = *static_cast<const SpringTimingFunction*>(timingFunction.get());
+ [springAnimation setMass:function.mass()];
+ [springAnimation setStiffness:function.stiffness()];
+ [springAnimation setDamping:function.damping()];
+ [springAnimation setInitialVelocity:function.initialVelocity()];
+ }
+ }
+ caAnimation = springAnimation;
+ break;
}
+ }
[caAnimation setBeginTime:properties.beginTime];
[caAnimation setDuration:properties.duration];