Bug 188554 - Use OptionSet for ActivityState::Flags
Summary: Use OptionSet for ActivityState::Flags
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-08-14 07:56 PDT by Antti Koivisto
Modified: 2018-08-16 05:51 PDT (History)
19 users (show)

See Also:


Attachments
patch (53.82 KB, patch)
2018-08-14 09:15 PDT, Antti Koivisto
bfulgham: review+
Details | Formatted Diff | Diff
patch (64.70 KB, patch)
2018-08-15 03:05 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff
patch (65.88 KB, patch)
2018-08-15 04:29 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff
patch (66.40 KB, patch)
2018-08-15 13:36 PDT, 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 Antti Koivisto 2018-08-14 07:56:22 PDT
Make it safer.
Comment 1 Antti Koivisto 2018-08-14 09:15:43 PDT
Created attachment 347081 [details]
patch
Comment 2 Brent Fulgham 2018-08-14 09:30:51 PDT
Comment on attachment 347081 [details]
patch

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

Looks good! r=me

> Source/WebCore/page/ActivityState.cpp:54
> +    appendIf(ActivityState::IsCapturingMedia, "capturing media");

Nice cleanup!

> Source/WebCore/page/FocusController.cpp:356
> +    m_page.setActivityState(focused ? m_activityState | ActivityState::IsFocused : m_activityState - ActivityState::IsFocused);

It's too bad we still have to use all of this bitwise math for an OptionSet. It would be much clearer to say something like "m_activityState.remove(ActivityState::IsFocused)

> Source/WebCore/page/Page.cpp:1652
> +        state -= { ActivityState::IsVisible, ActivityState::IsVisibleOrOccluded };

Again, these bitwise operators are hard to reason about when reading the code. Seems like extending OptionSet with helpful methods would make these kinds of statements easier to understand.
Comment 3 Antti Koivisto 2018-08-14 09:43:15 PDT
> Again, these bitwise operators are hard to reason about when reading the
> code. Seems like extending OptionSet with helpful methods would make these
> kinds of statements easier to understand.

Yeah, at least add/remove would be good for readability.
Comment 4 Antti Koivisto 2018-08-15 03:05:20 PDT
Created attachment 347153 [details]
patch
Comment 5 EWS Watchlist 2018-08-15 03:57:47 PDT
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See http://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Comment 6 Antti Koivisto 2018-08-15 04:29:58 PDT
Created attachment 347157 [details]
patch
Comment 7 Brent Fulgham 2018-08-15 08:02:05 PDT
/Volumes/Data/EWS/WebKit/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:2316:59: error: no member named 'AllFlags' in 'WebCore::ActivityState'
    _page->activityStateDidChange(WebCore::ActivityState::AllFlags);
                                  ~~~~~~~~~~~~~~~~~~~~~~~~^
1 error generated.
Comment 8 Antti Koivisto 2018-08-15 13:36:35 PDT
Created attachment 347204 [details]
patch
Comment 9 WebKit Commit Bot 2018-08-16 05:49:08 PDT
Comment on attachment 347204 [details]
patch

Clearing flags on attachment: 347204

Committed r234920: <https://trac.webkit.org/changeset/234920>
Comment 10 WebKit Commit Bot 2018-08-16 05:49:10 PDT
All reviewed patches have been landed.  Closing bug.
Comment 11 Radar WebKit Bug Importer 2018-08-16 05:51:30 PDT
<rdar://problem/43378163>