Branch: refs/heads/main Home: https://github.com/WebKit/WebKit Commit: 2047aa6f9356073f2eac55f0ea91d31bd024717a https://github.com/WebKit/WebKit/commit/2047aa6f9356073f2eac55f0ea91d31bd024717a Author: Sam Weinig <s...@webkit.org> Date: 2024-09-01 (Sun, 01 Sep 2024)
Changed paths: M LayoutTests/fast/css/animation-steps-calculated-value-expected.txt M LayoutTests/fast/css/animation-steps-calculated-value.html M LayoutTests/imported/w3c/web-platform-tests/css/css-easing/linear-timing-functions-syntax-expected.txt M LayoutTests/imported/w3c/web-platform-tests/css/css-easing/linear-timing-functions-syntax.html M LayoutTests/imported/w3c/web-platform-tests/css/css-easing/timing-functions-syntax-computed-expected.txt M LayoutTests/imported/w3c/web-platform-tests/css/css-easing/timing-functions-syntax-computed.html M LayoutTests/imported/w3c/web-platform-tests/css/css-easing/timing-functions-syntax-invalid-expected.txt M LayoutTests/imported/w3c/web-platform-tests/css/css-easing/timing-functions-syntax-invalid.html M LayoutTests/imported/w3c/web-platform-tests/css/css-easing/timing-functions-syntax-valid-expected.txt M LayoutTests/imported/w3c/web-platform-tests/css/css-easing/timing-functions-syntax-valid.html M Source/WTF/wtf/text/TextStream.cpp M Source/WTF/wtf/text/TextStream.h M Source/WebCore/Sources.txt M Source/WebCore/WebCore.xcodeproj/project.pbxproj M Source/WebCore/animation/AnimationEffect.cpp M Source/WebCore/animation/AnimationEffect.h M Source/WebCore/animation/AnimationEffect.idl M Source/WebCore/animation/CustomEffect.cpp M Source/WebCore/animation/CustomEffect.h M Source/WebCore/animation/CustomEffect.idl M Source/WebCore/animation/DocumentTimeline.cpp M Source/WebCore/animation/KeyframeEffect.cpp M Source/WebCore/css/CSSPrimitiveValue.cpp M Source/WebCore/css/CSSPrimitiveValue.h M Source/WebCore/css/CSSTimingFunctionValue.cpp M Source/WebCore/css/CSSTimingFunctionValue.h M Source/WebCore/css/CSSToStyleMap.cpp M Source/WebCore/css/CSSToStyleMap.h M Source/WebCore/css/ComputedStyleExtractor.cpp M Source/WebCore/css/parser/CSSPropertyParser.cpp A Source/WebCore/css/parser/CSSPropertyParserConsumer+TimingFunction.cpp A Source/WebCore/css/parser/CSSPropertyParserConsumer+TimingFunction.h M Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp M Source/WebCore/css/parser/CSSPropertyParserHelpers.h M Source/WebCore/css/process-css-properties.py M Source/WebCore/platform/animation/TimingFunction.cpp M Source/WebCore/platform/animation/TimingFunction.h M Source/WebCore/style/StyleBuilderConverter.h M Source/WebCore/style/StyleResolver.cpp Log Message: ----------- CSS timing functions should not eagerly evaluate calc() https://bugs.webkit.org/show_bug.cgi?id=278925 Reviewed by Darin Adler. The CSS timing functions were using the RawResolver to eagerly evaluate calc() during parsing, which results in incorrect serialization of specified values and doesn't allow for use of relative lengths in the calculations. Instead, calc() evaluation should be delayed until style building. This change updates the timing function CSS values to store unevaluated primitives and resolve calc() at style building time. It still doesn't allow for use of relative lengths, as not all call sites can trivially pass in conversion data, so that is deferred to a follow up. While making this change, parsing has been extracted into its own file and resolution to TimingFunction types has been moved out of platform/ (which was a layering violation) and into CSSTimingFunctionValues.h/cpp. Additionally, a helper to parse timing functions from strings has been added so that callers don't have to invoke the entire CSS parser when only timing functions are needed. * LayoutTests/imported/w3c/web-platform-tests/css/css-easing/linear-timing-functions-syntax-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-easing/linear-timing-functions-syntax.html: * LayoutTests/imported/w3c/web-platform-tests/css/css-easing/timing-functions-syntax-computed-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-easing/timing-functions-syntax-computed.html: * LayoutTests/imported/w3c/web-platform-tests/css/css-easing/timing-functions-syntax-invalid-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-easing/timing-functions-syntax-invalid.html: * LayoutTests/imported/w3c/web-platform-tests/css/css-easing/timing-functions-syntax-valid-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-easing/timing-functions-syntax-valid.html: - Update timing function tests with cases that involve calc(). * Source/WTF/wtf/text/TextStream.cpp: (WTF::TextStream::operator<<): * Source/WTF/wtf/text/TextStream.h: - Add support for FormattedCSSNumber to TextStream. Remove unnecessary allocation when serializing HexNumberBuffer. * Source/WebCore/Sources.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: - Add files: CSSPropertyParserConsumer+TimingFunction.h/cpp * Source/WebCore/animation/AnimationEffect.cpp: * Source/WebCore/animation/AnimationEffect.h: * Source/WebCore/animation/AnimationEffect.idl: * Source/WebCore/animation/CustomEffect.cpp: * Source/WebCore/animation/CustomEffect.h: * Source/WebCore/animation/CustomEffect.idl: * Source/WebCore/animation/DocumentTimeline.cpp: * Source/WebCore/animation/KeyframeEffect.cpp: - Pipe the Document around so that callers switching from TimingFunction::createFromCSSText to CSSPropertyParserHelpers::parseTimingFunction can have a valid CSSParserContext. This is important since it dictates if spring() is allowed or not. * Source/WebCore/css/CSSPrimitiveValue.cpp: * Source/WebCore/css/CSSPrimitiveValue.h: - Add helper, isOne(), to test if the value is exactly 1, returns std::nullopt for calc() like similar functions. * Source/WebCore/css/CSSTimingFunctionValue.cpp: (WebCore::createTimingFunction): - Move logic from TimingFunction::createFromCSSText to CSSTimingFunctionValue. This centralizes things and avoids the layering violation. (WebCore::CSSLinearTimingFunctionValue::createTimingFunction const): - Rather than running the "create-a-linear-easing-function" at parse time, which is not possible in the presence of calc(), it is now deferred to style building time and moved here. * Source/WebCore/css/CSSTimingFunctionValue.h: - Store the parsed forms of the parameters to allow late resolution of calc at style building. * Source/WebCore/css/CSSToStyleMap.cpp: * Source/WebCore/css/CSSToStyleMap.h: - Forward to the new Style::BuilderConverter::convertTimingFunction(). * Source/WebCore/css/ComputedStyleExtractor.cpp: (WebCore::valueForAnimationTimingFunction): - Update computed value creation to create the appropriate primitive value parameters for the easing functions. * Source/WebCore/css/parser/CSSPropertyParser.cpp: - Add include for call to consumeTimingFunction. * Source/WebCore/css/parser/CSSPropertyParserConsumer+TimingFunction.cpp: Added. * Source/WebCore/css/parser/CSSPropertyParserConsumer+TimingFunction.h: Added. * Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp: * Source/WebCore/css/parser/CSSPropertyParserHelpers.h: - Moved consumer implementations from CSSPropertyParserHelpers, and rework them by removing the eager evaluation of calc via RawResolver. * Source/WebCore/css/process-css-properties.py: - Add include for generated callers of consumeTimingFunction(). * Source/WebCore/platform/animation/TimingFunction.cpp: * Source/WebCore/platform/animation/TimingFunction.h: (WebCore::TimingFunction::cssText const): (WebCore::TimingFunction::createFromCSSText): Deleted. (WebCore::TimingFunction::createFromCSSValue): Deleted. - Moved code directly dealing with CSS types to CSSTimingFunctionValue.h/cpp. - The serialization code remains and has been update to match CSS semantics by using FormattedCSSNumber for numerics. Ideally this would go away as well with callers using the serialization in CSSTimingFunctionValue, but that is an existing issue and requires a bit of refactoring that was too much for this change as is. * Source/WebCore/style/StyleBuilderConverter.h: (WebCore::Style::BuilderConverter::convertTimingFunction): - Add converter for TimingFunction which forwards to createTimingFunction(). * Source/WebCore/style/StyleResolver.cpp: (WebCore::Style::Resolver::keyframeRulesForName const): (WebCore::Style::Resolver::keyframeStylesForAnimation): - Replace use of TimingFunction::createFromCSSValue() with its replacement createTimingFunction(). Canonical link: https://commits.webkit.org/283036@main To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications _______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes