keyframes do not work when defined inside a style in a shadowRoot
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Dec 2016 22:42:28 +0000 (22:42 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Dec 2016 22:42:28 +0000 (22:42 +0000)
commit81c503f79350505be78388ce0c01eb1367fddced
tree7c1dc75452d0af9347408ea7d20c5a9033fb95a6
parentb6102ed1f396591a6516549d5b3b6f068c19f903
keyframes do not work when defined inside a style in a shadowRoot
https://bugs.webkit.org/show_bug.cgi?id=164608
<rdar://problem/29210251>

Reviewed by Darin Adler.

Source/WebCore:

With :host and ::slotted rules a keyframe animation affecting an element can be
defined in a style scope different from the element's own scope. Style resolver
loses the scope information when building the RenderStyle so there is no way
to find out the correct scope.

Fix by passing style scope through to style builder and including a scope association
with the animation name. Find the correct scope when resolving keyframes.

Test: fast/shadow-dom/shadow-host-animation.html

* css/CSSToStyleMap.cpp:
(WebCore::CSSToStyleMap::mapAnimationName):

    Include scope with the name.

* css/ElementRuleCollector.cpp:
(WebCore::MatchRequest::MatchRequest):
(WebCore::ElementRuleCollector::addMatchedRule):
(WebCore::ElementRuleCollector::sortAndTransferMatchedRules):
(WebCore::ElementRuleCollector::matchAuthorRules):
(WebCore::ElementRuleCollector::matchAuthorShadowPseudoElementRules):
(WebCore::ElementRuleCollector::matchHostPseudoClassRules):
(WebCore::ElementRuleCollector::matchSlottedPseudoElementRules):
(WebCore::ElementRuleCollector::collectMatchingRulesForList):

    Replace treeContextOrdinal int with Style::ScopeOrdinal enum carrying the same information.
    Simplify the code removing unnecessary use of MatchRequest struct.

(WebCore::compareRules):
* css/ElementRuleCollector.h:
* css/StyleResolver.cpp:
(WebCore::StyleResolver::MatchResult::addMatchedProperties):
(WebCore::StyleResolver::CascadedProperties::setPropertyInternal):
(WebCore::StyleResolver::CascadedProperties::set):
(WebCore::StyleResolver::CascadedProperties::setDeferred):

    Pass styleScopeOrdinal through the cascade mechanism

(WebCore::cascadeLevelForIndex):
(WebCore::StyleResolver::CascadedProperties::addMatch):
(WebCore::StyleResolver::CascadedProperties::addImportantMatches):
(WebCore::StyleResolver::CascadedProperties::Property::apply):

    Set styleScopeOrdinal in State when applying style.

(WebCore::StyleResolver::CascadedProperties::addStyleProperties): Deleted.

    Move the code to the only caller.

* css/StyleResolver.h:
(WebCore::StyleResolver::State::styleScopeOrdinal):
(WebCore::StyleResolver::State::setStyleScopeOrdinal):
* page/animation/CompositeAnimation.cpp:
(WebCore::KeyframeAnimation::KeyframeAnimation):
(WebCore::KeyframeAnimation::resolveKeyframeStyles):

    Find the correct scope for resolving keyframes based on the scope ordinal.

* platform/animation/Animation.cpp:
* platform/animation/Animation.h:

    Add m_nameStyleScopeOrdinal that tells the scope where the name is defined.

* style/StyleScope.cpp:
(WebCore::Style::Scope::forOrdinal):

    Find the scope for ordinal.

* style/StyleScope.h:

    Define ScopeOrdinal types.

(WebCore::Style::operator++):

LayoutTests:

* fast/shadow-dom/shadow-host-animation-expected.html: Added.
* fast/shadow-dom/shadow-host-animation.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209352 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/shadow-dom/shadow-host-animation-expected.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/shadow-host-animation.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSToStyleMap.cpp
Source/WebCore/css/ElementRuleCollector.cpp
Source/WebCore/css/ElementRuleCollector.h
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/css/StyleResolver.h
Source/WebCore/page/animation/KeyframeAnimation.cpp
Source/WebCore/platform/animation/Animation.cpp
Source/WebCore/platform/animation/Animation.h
Source/WebCore/style/StyleScope.cpp
Source/WebCore/style/StyleScope.h