Bug 255953 - Play Animation and Pause Animation action sheet items don't appear when a sibling link covers the animation
Summary: Play Animation and Pause Animation action sheet items don't appear when a sib...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Animations (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tyler Wilcock
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-04-25 14:43 PDT by Tyler Wilcock
Modified: 2023-05-02 11:14 PDT (History)
12 users (show)

See Also:


Attachments
Patch (54.14 KB, patch)
2023-04-25 16:17 PDT, Tyler Wilcock
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (54.31 KB, patch)
2023-04-25 16:58 PDT, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (54.05 KB, patch)
2023-04-27 15:27 PDT, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (54.13 KB, patch)
2023-05-01 19:31 PDT, Tyler Wilcock
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tyler Wilcock 2023-04-25 14:43:45 PDT
Testcase:

<a href="#foo">
    <img src="animated-red-green-blue-repeat-infinite.gif" width="223" height="223" alt="Alt text">
</a>
<div style="width: 233px; height: 223px; position: absolute; top: 8px;">
    <a href="#bar" style="width: 223px; height: 223px">
        <div style="width: 233px; height: 223px;"></div>
    </a>
</div>
Comment 1 Radar WebKit Bug Importer 2023-04-25 14:44:17 PDT
<rdar://problem/108524363>
Comment 2 Tyler Wilcock 2023-04-25 16:17:29 PDT
Created attachment 466082 [details]
Patch
Comment 3 Tyler Wilcock 2023-04-25 16:58:40 PDT
Created attachment 466083 [details]
Patch
Comment 4 Tyler Wilcock 2023-04-27 15:27:22 PDT
Created attachment 466120 [details]
Patch
Comment 5 Wenson Hsieh 2023-05-01 16:49:43 PDT
Comment on attachment 466120 [details]
Patch

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

> Source/WebKit/Shared/ios/InteractionInformationRequest.cpp:98
> +    if (other.gatherAnimations != gatherAnimations)

Nit - shouldn't this be `other.gatherAnimations && !gatherAnimations`? In other words, the currently cached position information is only invalid for the incoming request in the case where we haven't gathered animations, but the incoming request wants to gather animations.

> Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h:519
> +- (BOOL)_allowAnimationControls;

Nit - `WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA))` here (we still specify availability annotations for SPI, since there may be internal clients that may depend on this information).

> Source/WebKit/UIProcess/API/Cocoa/_WKActivatedElementInfo.mm:138
> +- (instancetype)_initWithType:(_WKActivatedElementType)type URL:(NSURL *)url imageURL:(NSURL *)imageURL location:(const WebCore::IntPoint&)location title:(NSString *)title ID:(NSString *)ID rect:(CGRect)rect image:(WebKit::ShareableBitmap*)image imageMIMEType:(NSString *)imageMIMEType isAnimatedImage:(BOOL)isAnimatedImage isAnimating:(BOOL)isAnimating canShowAnimationControls:(BOOL)canShowAnimationControls animationsUnderElement:(Vector<WebCore::ElementAnimationContext>)animationsUnderElement userInfo:(NSDictionary *)userInfo

Nit - either `Vector<WebCore::ElementAnimationContext>&&` or `const Vector<WebCore::ElementAnimationContext>&` to avoid unnecessary copies.

> Source/WebKit/UIProcess/API/Cocoa/_WKActivatedElementInfo.mm:214
> +- (Vector<WebCore::ElementAnimationContext>)_animationsUnderElement

Nit - same here, `const Vector<WebCore::ElementAnimationContext>&` so that we don't copy unless necessary.

> Source/WebKit/UIProcess/WebPageProxy.h:927
> +    void performActionOnElements(uint32_t action, Vector<WebCore::ElementContext>);

Nit - `Vector<WebCore::ElementContext>&&`.

> Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm:586
> +void WebPageProxy::performActionOnElements(uint32_t action, Vector<WebCore::ElementContext> elements)

Nit - either `Vector<WebCore::ElementContext>&&` here with `WTFMove(elements)`, or `const Vector<WebCore::ElementContext>&`.

> Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:3302
> +        if (std::optional elementContext = page.contextForElement(*element))

Nit - s/std::optional/auto/

> Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:3303
> +            info.animationsAtPoint.append({ *elementContext, rendererAndImage->second.isAnimating() });

You can `WTFMove(*elementContext)` here.

> Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:3433
> +        if (auto* imageElement = dynamicDowncast<HTMLImageElement>(element))

Nit - not new in this patch, but I would use `RefPtr` here since `setAllowsAnimation` isn't a trivial setter.

> Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:3436
> +        if (auto* imageElement = dynamicDowncast<HTMLImageElement>(element))

Ditto.
Comment 6 Tyler Wilcock 2023-05-01 19:31:13 PDT
Created attachment 466166 [details]
Patch
Comment 7 Tyler Wilcock 2023-05-01 19:32:02 PDT
(In reply to Wenson Hsieh from comment #5)
> Comment on attachment 466120 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=466120&action=review
> 
> > Source/WebKit/Shared/ios/InteractionInformationRequest.cpp:98
> > +    if (other.gatherAnimations != gatherAnimations)
> 
> Nit - shouldn't this be `other.gatherAnimations && !gatherAnimations`? In
> other words, the currently cached position information is only invalid for
> the incoming request in the case where we haven't gathered animations, but
> the incoming request wants to gather animations.
Yes, great catch, thanks! Addressed all comments in latest patch.
Comment 8 EWS 2023-05-02 11:14:34 PDT
Committed 263598@main (31091c93475d): <https://commits.webkit.org/263598@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 466166 [details].