Bug 224549 - Move FocusRemovalEventsMode into FocusOptions
Summary: Move FocusRemovalEventsMode into FocusOptions
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Manuel Rego Casasnovas
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-04-14 08:23 PDT by Manuel Rego Casasnovas
Modified: 2021-04-15 15:27 PDT (History)
12 users (show)

See Also:


Attachments
Patch (15.82 KB, patch)
2021-04-14 08:25 PDT, Manuel Rego Casasnovas
no flags Details | Formatted Diff | Diff
Patch (15.89 KB, patch)
2021-04-14 13:22 PDT, Manuel Rego Casasnovas
no flags Details | Formatted Diff | Diff
Patch for landing (9.27 KB, patch)
2021-04-15 00:15 PDT, Manuel Rego Casasnovas
no flags Details | Formatted Diff | Diff
Patch for landing (9.27 KB, patch)
2021-04-15 01:34 PDT, Manuel Rego Casasnovas
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch for landing (9.34 KB, patch)
2021-04-15 02:23 PDT, Manuel Rego Casasnovas
no flags Details | Formatted Diff | Diff
Patch (1.98 KB, patch)
2021-04-15 12:51 PDT, Manuel Rego Casasnovas
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Manuel Rego Casasnovas 2021-04-14 08:23:33 PDT
Move FocusRemovalEventsMode into FocusOptions
Comment 1 Manuel Rego Casasnovas 2021-04-14 08:25:20 PDT
Created attachment 425984 [details]
Patch
Comment 2 Manuel Rego Casasnovas 2021-04-14 13:22:52 PDT
Created attachment 426041 [details]
Patch
Comment 3 Manuel Rego Casasnovas 2021-04-14 13:24:06 PDT
Comment on attachment 426041 [details]
Patch

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

> Source/WebCore/dom/Document.cpp:4363
> +        FocusOptions focusOptions = { };
> +        focusOptions.removalEventsMode = FocusRemovalEventsMode::DoNotDispatch;
> +        setFocusedElement(nullptr, focusOptions);

I've initially used the following line here, but it doesn't build on Windows port due to the C++ version:
      setFocusedElement(nullptr, { .removalEventsMode = FocusRemovalEventsMode::DoNotDispatch });
Comment 4 Darin Adler 2021-04-14 16:00:17 PDT
Comment on attachment 426041 [details]
Patch

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

>> Source/WebCore/dom/Document.cpp:4363
>> +        setFocusedElement(nullptr, focusOptions);
> 
> I've initially used the following line here, but it doesn't build on Windows port due to the C++ version:
>       setFocusedElement(nullptr, { .removalEventsMode = FocusRemovalEventsMode::DoNotDispatch });

Yes, I think that might be a C++20 feature and we can’t start using those yet. But soon I hope!

But maybe you could write something like this:

    setFocusedElement(nullptr, { { }, { }, { FocusRemovalEventsMode::DoNotDispatch }, { } });

While it’s not super-beautiful, there’s no chance of the FocusRemovalEventsMode ending up in the wrong structure element, nor of anything else being set to a non-default value.

> Source/WebCore/dom/FocusRemovalEventsMode.h:30
> +enum class FocusRemovalEventsMode { Dispatch, DoNotDispatch };

Do we really need a separate header for this? Can we just put this into FocusOptions.h and include that everywhere this is needed?

I’m willing to have a separate header for a single enumeration if it’s really helpful but it would be good to avoid if possible.
Comment 5 Manuel Rego Casasnovas 2021-04-15 00:15:19 PDT
Created attachment 426079 [details]
Patch for landing
Comment 6 Manuel Rego Casasnovas 2021-04-15 00:24:03 PDT
Thanks for the quick review.

(In reply to Darin Adler from comment #4)
> Comment on attachment 426041 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=426041&action=review
> 
> >> Source/WebCore/dom/Document.cpp:4363
> >> +        setFocusedElement(nullptr, focusOptions);
> > 
> > I've initially used the following line here, but it doesn't build on Windows port due to the C++ version:
> >       setFocusedElement(nullptr, { .removalEventsMode = FocusRemovalEventsMode::DoNotDispatch });
> 
> Yes, I think that might be a C++20 feature and we can’t start using those
> yet. But soon I hope!
> 
> But maybe you could write something like this:
> 
>     setFocusedElement(nullptr, { { }, { }, {
> FocusRemovalEventsMode::DoNotDispatch }, { } });
> 
> While it’s not super-beautiful, there’s no chance of the
> FocusRemovalEventsMode ending up in the wrong structure element, nor of
> anything else being set to a non-default value.

Yeah that works, thanks for the suggestion.

> > Source/WebCore/dom/FocusRemovalEventsMode.h:30
> > +enum class FocusRemovalEventsMode { Dispatch, DoNotDispatch };
> 
> Do we really need a separate header for this? Can we just put this into
> FocusOptions.h and include that everywhere this is needed?
> 
> I’m willing to have a separate header for a single enumeration if it’s
> really helpful but it would be good to avoid if possible.

Yeah I don't think it's needed, I've merged it into FocusOptions (I was mimicking what is done for FocusDirection, but maybe that's separated just because it's older than FocusOptions).
Comment 7 Manuel Rego Casasnovas 2021-04-15 01:34:48 PDT
Created attachment 426081 [details]
Patch for landing
Comment 8 Manuel Rego Casasnovas 2021-04-15 02:18:51 PDT
(In reply to Manuel Rego Casasnovas from comment #6)
> Thanks for the quick review.
> 
> (In reply to Darin Adler from comment #4)
> > Comment on attachment 426041 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=426041&action=review
> > 
> > >> Source/WebCore/dom/Document.cpp:4363
> > >> +        setFocusedElement(nullptr, focusOptions);
> > > 
> > > I've initially used the following line here, but it doesn't build on Windows port due to the C++ version:
> > >       setFocusedElement(nullptr, { .removalEventsMode = FocusRemovalEventsMode::DoNotDispatch });
> > 
> > Yes, I think that might be a C++20 feature and we can’t start using those
> > yet. But soon I hope!
> > 
> > But maybe you could write something like this:
> > 
> >     setFocusedElement(nullptr, { { }, { }, {
> > FocusRemovalEventsMode::DoNotDispatch }, { } });
> > 
> > While it’s not super-beautiful, there’s no chance of the
> > FocusRemovalEventsMode ending up in the wrong structure element, nor of
> > anything else being set to a non-default value.
> 
> Yeah that works, thanks for the suggestion.

Actually that only worked on Linux ports, not on Mac. So I'm coming back to the code in the first patch.
Comment 9 Manuel Rego Casasnovas 2021-04-15 02:23:46 PDT
Created attachment 426089 [details]
Patch for landing
Comment 10 EWS 2021-04-15 04:01:33 PDT
Committed r276016 (236568@main): <https://commits.webkit.org/236568@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 426089 [details].
Comment 11 Radar WebKit Bug Importer 2021-04-15 04:02:34 PDT
<rdar://problem/76695885>
Comment 12 Darin Adler 2021-04-15 07:52:25 PDT
(In reply to Manuel Rego Casasnovas from comment #8)
> Actually that only worked on Linux ports, not on Mac. So I'm coming back to
> the code in the first patch.

Would eventually like to know what didn’t work on Mac about this. Not important, but curious. I suppose I can try it myself.
Comment 13 Manuel Rego Casasnovas 2021-04-15 12:49:18 PDT
(In reply to Darin Adler from comment #12)
> (In reply to Manuel Rego Casasnovas from comment #8)
> > Actually that only worked on Linux ports, not on Mac. So I'm coming back to
> > the code in the first patch.
> 
> Would eventually like to know what didn’t work on Mac about this. Not
> important, but curious. I suppose I can try it myself.

The error was:
./dom/Document.cpp:4360:48: error: braces around scalar initializer [-Werror,-Wbraced-scalar-init]

I've been now testing on a Mac machine and the problem was that I was using too many braces.
This works fine on Mac:
    setFocusedElement(nullptr, { { }, { }, FocusRemovalEventsMode::DoNotDispatch, { } });

I'll upload a follow-up patch to change this.
Comment 14 Manuel Rego Casasnovas 2021-04-15 12:51:47 PDT
Reopening to attach new patch.
Comment 15 Manuel Rego Casasnovas 2021-04-15 12:51:53 PDT
Created attachment 426128 [details]
Patch
Comment 16 EWS 2021-04-15 15:27:54 PDT
Committed r276077 (236590@main): <https://commits.webkit.org/236590@main>

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