Bug 209883 - Remove some PLATFORM(IOS_FAMILY) guards in TextFieldInputType
Summary: Remove some PLATFORM(IOS_FAMILY) guards in TextFieldInputType
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Wenson Hsieh
URL:
Keywords: DoNotImportToRadar
Depends on:
Blocks:
 
Reported: 2020-04-01 15:03 PDT by Wenson Hsieh
Modified: 2020-04-01 17:35 PDT (History)
11 users (show)

See Also:


Attachments
Patch (10.79 KB, patch)
2020-04-01 15:09 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff
Patch (10.79 KB, patch)
2020-04-01 15:18 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff
v2 (5.54 KB, patch)
2020-04-01 16:05 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff
Patch for landing (5.52 KB, patch)
2020-04-01 16:20 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Wenson Hsieh 2020-04-01 15:03:21 PDT
Consult a client hook at runtime instead to keep the implementation platform-agnostic(-ish).
Comment 1 Wenson Hsieh 2020-04-01 15:09:35 PDT
Created attachment 395208 [details]
Patch
Comment 2 Wenson Hsieh 2020-04-01 15:18:58 PDT
Created attachment 395210 [details]
Patch
Comment 3 Darin Adler 2020-04-01 15:25:04 PDT
Comment on attachment 395210 [details]
Patch

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

> Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp:814
> +#if PLATFORM(IOS_FAMILY)
> +    return true;
> +#else
> +    return false;
> +#endif

If this is just a platform conditional, do we really need to use the client design pattern? Or perhaps there is some way this is likely to be dynamic in the future that we are preparing for?

The client system is mildly elaborate and is worthwhile mainly when we want a true separation of concerns between WebCore and WebKit layers, not just for platform differences.
Comment 4 Darin Adler 2020-04-01 15:25:34 PDT
The idea of having this be a runtime check seems fine. But calling across framework boundaries to a client seems like it might be overkill.
Comment 5 Wenson Hsieh 2020-04-01 15:27:45 PDT
(In reply to Darin Adler from comment #4)
> The idea of having this be a runtime check seems fine. But calling across
> framework boundaries to a client seems like it might be overkill.

Fair point! Perhaps this would be cleaner?

bool TextFieldInputType::shouldOnlyShowDataListDropdownButtonWhenFocusedOrEdited() const
{
#if PLATFORM(IOS_FAMILY)
    return true;
#else
    return false;
#endif
}

(...instead of all the client plumbing).
Comment 6 Darin Adler 2020-04-01 15:29:59 PDT
Yes, seems better.
Comment 7 Darin Adler 2020-04-01 15:31:01 PDT
Another possible consideration is that sometimes we want a way to change something like this for test purposes so we can test both code paths on both platforms.
Comment 8 Darin Adler 2020-04-01 15:31:42 PDT
One thing like this, that we established a bit of a design pattern for, is the "editing behaviors".
Comment 9 Wenson Hsieh 2020-04-01 15:48:15 PDT
(In reply to Darin Adler from comment #8)
> One thing like this, that we established a bit of a design pattern for, is
> the "editing behaviors".

I see! This *might* be sufficiently relevant to editing that it could be refactored into an editing behavior, but I’m not sure we have a need for it quite yet (even for testing).

Would you be okay with leaving it as a helper function on TextFieldInputType that returns a bool?
Comment 10 Wenson Hsieh 2020-04-01 16:05:14 PDT
Created attachment 395218 [details]
v2
Comment 11 Darin Adler 2020-04-01 16:09:56 PDT
(In reply to Wenson Hsieh from comment #9)
> Would you be okay with leaving it as a helper function on TextFieldInputType
> that returns a bool?

Yes. Can always tweak it again later.
Comment 12 Darin Adler 2020-04-01 16:10:26 PDT
(In reply to Darin Adler from comment #11)
> (In reply to Wenson Hsieh from comment #9)
> > Would you be okay with leaving it as a helper function on TextFieldInputType
> > that returns a bool?
> 
> Yes. Can always tweak it again later.

For example, could just change it to a static member function.
Comment 13 Wenson Hsieh 2020-04-01 16:13:36 PDT
(In reply to Darin Adler from comment #12)
> (In reply to Darin Adler from comment #11)
> > (In reply to Wenson Hsieh from comment #9)
> > > Would you be okay with leaving it as a helper function on TextFieldInputType
> > > that returns a bool?
> > 
> > Yes. Can always tweak it again later.
> 
> For example, could just change it to a static member function.

Ah, sure — since this isn’t something that varies between instances of TextFieldInputType, a static helper makes more sense. I’ll tweak the patch to make it static and go with that. Thanks for the feedback!
Comment 14 Wenson Hsieh 2020-04-01 16:20:01 PDT
Created attachment 395220 [details]
Patch for landing
Comment 15 EWS 2020-04-01 17:35:08 PDT
Committed r259375: <https://trac.webkit.org/changeset/259375>

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