Bug 164608 - keyframes do not work when defined inside a style in a shadowRoot
Summary: keyframes do not work when defined inside a style in a shadowRoot
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks: 148695
  Show dependency treegraph
 
Reported: 2016-11-10 12:31 PST by Keanu Lee
Modified: 2018-06-25 14:59 PDT (History)
8 users (show)

See Also:


Attachments
patch (40.01 KB, patch)
2016-12-05 07:41 PST, Antti Koivisto
darin: review+
buildbot: commit-queue-
Details | Formatted Diff | Diff
Archive of layout-test-results from ews102 for mac-yosemite (1.14 MB, application/zip)
2016-12-05 10:00 PST, Build Bot
no flags Details
patch (41.11 KB, patch)
2016-12-05 11:54 PST, Antti Koivisto
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.