Bug 239921 - [Modern Media Controls] the overflow button sometimes flickers
Summary: [Modern Media Controls] the overflow button sometimes flickers
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Devin Rousso
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-04-29 19:00 PDT by Devin Rousso
Modified: 2022-05-01 18:49 PDT (History)
9 users (show)

See Also:


Attachments
Patch (8.32 KB, patch)
2022-04-29 19:14 PDT, Devin Rousso
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (8.33 KB, patch)
2022-04-29 22:51 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Devin Rousso 2022-04-29 19:00:35 PDT
.
Comment 1 Devin Rousso 2022-04-29 19:00:52 PDT
<rdar://problem/91329468>
Comment 2 Devin Rousso 2022-04-29 19:14:36 PDT
Created attachment 458625 [details]
Patch
Comment 3 Devin Rousso 2022-04-29 22:51:34 PDT
Created attachment 458630 [details]
Patch
Comment 4 Eric Carlson 2022-04-30 21:25:40 PDT
Comment on attachment 458630 [details]
Patch

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

> Source/WebCore/Modules/modern-media-controls/controls/overflow-button.js:53
> +            for (let key in contextMenuOptions)
> +                return false;
> +            return true;

This is clever, but it made me think twice about what it does and how it works. Is there a more obvious, or idiomatic, way of testing for an empty object?
Comment 5 Devin Rousso 2022-05-01 17:58:22 PDT
Comment on attachment 458630 [details]
Patch

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

>> Source/WebCore/Modules/modern-media-controls/controls/overflow-button.js:53
>> +            return true;
> 
> This is clever, but it made me think twice about what it does and how it works. Is there a more obvious, or idiomatic, way of testing for an empty object?

There are other ways of doing this (e.g. `Object.getOwnPropertyNames(contextMenuOptions).length`), but the primary issue with many of them is that they require iterating _all_ of the keys before returning a result.  This approach is by far the most efficient in that it requires iterating only a single key.

Yes, that isn't a huge problem here given that we (currently) will never have more than five keys, but I'd prefer to do the optimal thing nevertheless.

FWIW this is used in Web Inspector as `isEmptyObject`, so there is some "prior art" :)
Comment 6 EWS 2022-05-01 18:49:08 PDT
Committed r293658 (250162@main): <https://commits.webkit.org/250162@main>

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