Bug 164608

Summary: keyframes do not work when defined inside a style in a shadowRoot
Product: WebKit Reporter: Keanu Lee <webkit>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: buildbot, cdumez, commit-queue, dino, koivisto, rniwa, simon.fraser, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari Technology Preview   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=186837
Bug Depends on:    
Bug Blocks: 148695    
Attachments:
Description Flags
patch
darin: review+, buildbot: commit-queue-
Archive of layout-test-results from ews102 for mac-yosemite
none
patch none

Description Keanu Lee 2016-11-10 12:31:16 PST
@keyframes defined inside shadow roots don't work:

http://jsbin.com/yibeca/edit?html,output


However, @keyframes defined in the main document work inside shadow roots:

http://jsbin.com/pelaqob/edit?html,output
Comment 1 Radar WebKit Bug Importer 2016-11-10 16:42:54 PST
<rdar://problem/29210251>
Comment 2 Dean Jackson 2016-11-14 16:06:56 PST
It appears that KeyframeAnimation::resolveKeyframeStyles() calls into Element::styleResolver(), but that gets null for containingShadowRoot() so returns the Document's style resolver.

I think the keyframes rule is in the shadow root's style resolver. But I'm not sure if containingShadowRoot should be null here.
Comment 3 Dean Jackson 2016-11-14 16:08:57 PST
The animation is connected to the x-foo element. I don't really understand the shadow tree - which style resolver should that get?
Comment 4 Ryosuke Niwa 2016-11-14 16:44:51 PST
It's a bit tricker than that. If the keyframe is used by a rule inside the shadow tree, then it should see the keyframe rule but the rule outside the shadow tree shouldn't see it.
Comment 5 Antti Koivisto 2016-12-05 07:41:25 PST
Created attachment 296138 [details]
patch
Comment 6 Sam Weinig 2016-12-05 08:40:49 PST
Comment on attachment 296138 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=296138&action=review

> Source/WebCore/ChangeLog:17
> +        Test: fast/shadow-dom/shadow-host-animation.html

I don't see this test in the patch.  Did you forget to add it?
Comment 7 Darin Adler 2016-12-05 09:20:00 PST
Comment on attachment 296138 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=296138&action=review

> Source/WebCore/page/animation/KeyframeAnimation.cpp:369
> +    auto* styleScope = Style::Scope::forOrdinal(element, m_animation->name().scopeOrdinal);
> +    if (styleScope)
> +        styleScope->resolver().keyframeStylesForAnimation(*m_object->element(), m_unanimatedStyle.get(), m_keyframes);

Could define the variable inside the if.

> Source/WebCore/platform/animation/Animation.cpp:167
> -const String& Animation::initialName()
> +Style::ScopedName Animation::initialName()
>  {
>      static NeverDestroyed<String> initialValue(ASCIILiteral("none"));
> -    return initialValue;
> +    return { initialValue.get(), Style::ScopeOrdinal::Element };
>  }

Could just have this return const Style::ScopedName& instead and have the global be a NeverDestroyed<Style::ScopedName>; would be slightly more efficient.
Comment 8 Build Bot 2016-12-05 10:00:44 PST
Comment on attachment 296138 [details]
patch

Attachment 296138 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/2627250

New failing tests:
media/modern-media-controls/media-controller/media-controller-resize.html
Comment 9 Build Bot 2016-12-05 10:00:48 PST
Created attachment 296153 [details]
Archive of layout-test-results from ews102 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews102  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 10 Antti Koivisto 2016-12-05 11:54:27 PST
Created attachment 296168 [details]
patch

Slightly simplified version.
Comment 11 WebKit Commit Bot 2016-12-05 14:42:54 PST
Comment on attachment 296168 [details]
patch

Clearing flags on attachment: 296168

Committed r209352: <http://trac.webkit.org/changeset/209352>
Comment 12 WebKit Commit Bot 2016-12-05 14:42:59 PST
All reviewed patches have been landed.  Closing bug.