Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (290456 => 290457)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2022-02-24 21:16:24 UTC (rev 290456)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2022-02-24 21:19:40 UTC (rev 290457)
@@ -1,3 +1,17 @@
+2022-02-24 Oriol Brufau <[email protected]>
+
+ [css-cascade] Support 'revert' in @keyframes
+ https://bugs.webkit.org/show_bug.cgi?id=237073
+
+ Reviewed by Darin Adler.
+
+ Expect tests to pass.
+
+ * web-platform-tests/css/css-cascade/revert-val-006-expected.txt:
+ * web-platform-tests/css/css-cascade/revert-val-007-expected.txt:
+ * web-platform-tests/css/css-cascade/revert-val-008-expected.txt:
+ * web-platform-tests/css/css-cascade/revert-val-010-expected.txt:
+
2022-02-24 Alan Bujtas <[email protected]>
[IFC][Integration] Enable non-paginated vertical-rl writing mode
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/revert-val-006-expected.txt (290456 => 290457)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/revert-val-006-expected.txt 2022-02-24 21:16:24 UTC (rev 290456)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/revert-val-006-expected.txt 2022-02-24 21:19:40 UTC (rev 290457)
@@ -1,3 +1,3 @@
-FAIL The revert keyword works with @keyframes assert_equals: expected "21.440001px" but got "0px"
+PASS The revert keyword works with @keyframes
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/revert-val-007-expected.txt (290456 => 290457)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/revert-val-007-expected.txt 2022-02-24 21:16:24 UTC (rev 290456)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/revert-val-007-expected.txt 2022-02-24 21:19:40 UTC (rev 290457)
@@ -1,3 +1,3 @@
-FAIL A @keyframe animation with revert works when applied to multiple identical elements assert_equals: expected "21.440001px" but got "0px"
+PASS A @keyframe animation with revert works when applied to multiple identical elements
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/revert-val-008-expected.txt (290456 => 290457)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/revert-val-008-expected.txt 2022-02-24 21:16:24 UTC (rev 290456)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/revert-val-008-expected.txt 2022-02-24 21:19:40 UTC (rev 290457)
@@ -1,3 +1,3 @@
-FAIL The revert keyword works in the final frame of a web animation assert_between_exclusive: expected a number greater than 21 and less than 42 but got 15
+PASS The revert keyword works in the final frame of a web animation
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/revert-val-010-expected.txt (290456 => 290457)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/revert-val-010-expected.txt 2022-02-24 21:16:24 UTC (rev 290456)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/revert-val-010-expected.txt 2022-02-24 21:19:40 UTC (rev 290457)
@@ -1,3 +1,3 @@
-FAIL The revert works when appearing in setKeyframes assert_equals: expected 42 but got 31
+PASS The revert works when appearing in setKeyframes
Modified: trunk/Source/WebCore/ChangeLog (290456 => 290457)
--- trunk/Source/WebCore/ChangeLog 2022-02-24 21:16:24 UTC (rev 290456)
+++ trunk/Source/WebCore/ChangeLog 2022-02-24 21:19:40 UTC (rev 290457)
@@ -1,3 +1,31 @@
+2022-02-24 Oriol Brufau <[email protected]>
+
+ [css-cascade] Support 'revert' in @keyframes
+ https://bugs.webkit.org/show_bug.cgi?id=237073
+
+ Reviewed by Darin Adler.
+
+ Resolver::styleForKeyframe was constructing a RenderStyle with only the
+ styles specified in the @keyframes. But not taking into account the UA
+ and user rules that affect the element meant that 'revert' was broken.
+ Since Builder::applyProperty didn't find the declarations from other
+ origins, 'revert' just behaved as 'unset'.
+
+ This patch solves it by detecting if the @keyframes has a 'revert' value
+ and in that case it collects the UA and user rules so that it can be
+ resolved properly.
+
+ Tests: imported/w3c/web-platform-tests/css/css-cascade/revert-val-006.html
+ imported/w3c/web-platform-tests/css/css-cascade/revert-val-007.html
+ imported/w3c/web-platform-tests/css/css-cascade/revert-val-008.html
+ imported/w3c/web-platform-tests/css/css-cascade/revert-val-010.html
+
+ * style/ElementRuleCollector.cpp:
+ (WebCore::Style::ElementRuleCollector::addAuthorKeyframeRules):
+ * style/ElementRuleCollector.h:
+ * style/StyleResolver.cpp:
+ (WebCore::Style::Resolver::styleForKeyframe):
+
2022-02-24 Devin Rousso <[email protected]>
REGRESSION(r290436): fix build failures
Modified: trunk/Source/WebCore/style/ElementRuleCollector.cpp (290456 => 290457)
--- trunk/Source/WebCore/style/ElementRuleCollector.cpp 2022-02-24 21:16:24 UTC (rev 290456)
+++ trunk/Source/WebCore/style/ElementRuleCollector.cpp 2022-02-24 21:19:40 UTC (rev 290457)
@@ -29,6 +29,7 @@
#include "config.h"
#include "ElementRuleCollector.h"
+#include "CSSKeyframeRule.h"
#include "CSSRuleList.h"
#include "CSSSelector.h"
#include "CSSValueKeywords.h"
@@ -649,5 +650,11 @@
declarationsForOrigin(m_result, declarationOrigin).append(WTFMove(matchedProperties));
}
+void ElementRuleCollector::addAuthorKeyframeRules(const StyleRuleKeyframe& keyframe)
+{
+ ASSERT(m_result.authorDeclarations.isEmpty());
+ m_result.authorDeclarations.append({ &keyframe.properties(), SelectorChecker::MatchAll, propertyAllowlistForPseudoId(m_pseudoElementRequest.pseudoId) });
}
+
+}
} // namespace WebCore
Modified: trunk/Source/WebCore/style/ElementRuleCollector.h (290456 => 290457)
--- trunk/Source/WebCore/style/ElementRuleCollector.h 2022-02-24 21:16:24 UTC (rev 290456)
+++ trunk/Source/WebCore/style/ElementRuleCollector.h 2022-02-24 21:19:40 UTC (rev 290457)
@@ -93,6 +93,8 @@
const Relations& styleRelations() const { return m_styleRelations; }
bool didMatchUncommonAttributeSelector() const { return m_didMatchUncommonAttributeSelector; }
+ void addAuthorKeyframeRules(const StyleRuleKeyframe&);
+
private:
void addElementStyleProperties(const StyleProperties*, bool isCacheable = true, FromStyleAttribute = FromStyleAttribute::No);
Modified: trunk/Source/WebCore/style/StyleResolver.cpp (290456 => 290457)
--- trunk/Source/WebCore/style/StyleResolver.cpp 2022-02-24 21:16:24 UTC (rev 290456)
+++ trunk/Source/WebCore/style/StyleResolver.cpp 2022-02-24 21:19:40 UTC (rev 290457)
@@ -277,8 +277,20 @@
std::unique_ptr<RenderStyle> Resolver::styleForKeyframe(const Element& element, const RenderStyle& elementStyle, const ResolutionContext& context, const StyleRuleKeyframe& keyframe, KeyframeValue& keyframeValue)
{
- MatchResult result;
- result.authorDeclarations.append({ &keyframe.properties(), SelectorChecker::MatchAll, propertyAllowlistForPseudoId(elementStyle.styleType()) });
+ // Add all the animating properties to the keyframe.
+ unsigned propertyCount = keyframe.properties().propertyCount();
+ bool hasRevert = false;
+ for (unsigned i = 0; i < propertyCount; ++i) {
+ auto propertyReference = keyframe.properties().propertyAt(i);
+ auto property = CSSProperty::resolveDirectionAwareProperty(propertyReference.id(), elementStyle.direction(), elementStyle.writingMode());
+ // The animation-composition and animation-timing-function within keyframes are special
+ // because they are not animated; they just describe the composite operation and timing
+ // function between this keyframe and the next.
+ if (property != CSSPropertyAnimationTimingFunction && property != CSSPropertyAnimationComposition)
+ keyframeValue.addProperty(property);
+ if (auto* value = propertyReference.value(); value && value->isRevertValue())
+ hasRevert = true;
+ }
auto state = State(element, nullptr, context.documentElementStyle);
@@ -285,23 +297,22 @@
state.setStyle(RenderStyle::clonePtr(elementStyle));
state.setParentStyle(RenderStyle::clonePtr(context.parentStyle ? *context.parentStyle : elementStyle));
- Builder builder(*state.style(), builderContext(state), result, CascadeLevel::Author);
+ ElementRuleCollector collector(element, m_ruleSets, context.selectorMatchingState);
+ collector.setPseudoElementRequest({ elementStyle.styleType() });
+ if (hasRevert) {
+ // In the animation origin, 'revert' rolls back the cascaded value to the user level.
+ // Therefore, we need to collect UA and user rules.
+ collector.setMedium(&m_mediaQueryEvaluator);
+ collector.matchUARules();
+ collector.matchUserRules();
+ }
+ collector.addAuthorKeyframeRules(keyframe);
+ Builder builder(*state.style(), builderContext(state), collector.matchResult(), CascadeLevel::Author);
builder.applyAllProperties();
Adjuster adjuster(document(), *state.parentStyle(), nullptr, nullptr);
adjuster.adjust(*state.style(), state.userAgentAppearanceStyle());
- // Add all the animating properties to the keyframe.
- unsigned propertyCount = keyframe.properties().propertyCount();
- for (unsigned i = 0; i < propertyCount; ++i) {
- auto property = CSSProperty::resolveDirectionAwareProperty(keyframe.properties().propertyAt(i).id(), elementStyle.direction(), elementStyle.writingMode());
- // The animation-composition and animation-timing-function within keyframes are special
- // because they are not animated; they just describe the composite operation and timing
- // function between this keyframe and the next.
- if (property != CSSPropertyAnimationTimingFunction && property != CSSPropertyAnimationComposition)
- keyframeValue.addProperty(property);
- }
-
return state.takeStyle();
}