Bug 217551 - Use WebPreference definitions from shared configuration files in WebCore (Part 1)
Summary: Use WebPreference definitions from shared configuration files in WebCore (Par...
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: Sam Weinig
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-10-09 19:57 PDT by Sam Weinig
Modified: 2020-10-10 13:13 PDT (History)
12 users (show)

See Also:


Attachments
Patch (141.32 KB, patch)
2020-10-09 19:59 PDT, Sam Weinig
no flags Details | Formatted Diff | Diff
Patch (141.47 KB, patch)
2020-10-10 08:46 PDT, Sam Weinig
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (146.06 KB, patch)
2020-10-10 09:18 PDT, Sam Weinig
no flags Details | Formatted Diff | Diff
Patch (149.32 KB, patch)
2020-10-10 11:36 PDT, Sam Weinig
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sam Weinig 2020-10-09 19:57:11 PDT
Use WebPreference definitions from shared configuration files in WebCore
Comment 1 Sam Weinig 2020-10-09 19:59:24 PDT Comment hidden (obsolete)
Comment 2 Sam Weinig 2020-10-10 08:46:21 PDT Comment hidden (obsolete)
Comment 3 Sam Weinig 2020-10-10 09:18:28 PDT Comment hidden (obsolete)
Comment 4 Sam Weinig 2020-10-10 09:27:05 PDT Comment hidden (obsolete)
Comment 5 Sam Weinig 2020-10-10 11:36:00 PDT
Created attachment 411012 [details]
Patch
Comment 6 Darin Adler 2020-10-10 12:34:03 PDT
Comment on attachment 411012 [details]
Patch

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

> Source/WTF/ChangeLog:20
> +        This also adds some new keys from WebCore's Settings.yaml:

Not thrilled with the "webcore" prefix.

> Source/WTF/ChangeLog:21
> +        - 'webcoreOnChange: *' called by WebCore::Settings when the setting changes.

There’s something really strange about having WebCore function names in WTF. I could easily imagine overlooking these when doing a global search.
Comment 7 EWS 2020-10-10 12:50:01 PDT
Committed r268313: <https://trac.webkit.org/changeset/268313>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 411012 [details].
Comment 8 Radar WebKit Bug Importer 2020-10-10 12:50:16 PDT
<rdar://problem/70174046>
Comment 9 Sam Weinig 2020-10-10 12:58:26 PDT
(In reply to Darin Adler from comment #6)
> Comment on attachment 411012 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=411012&action=review
> 
> > Source/WTF/ChangeLog:20
> > +        This also adds some new keys from WebCore's Settings.yaml:
> 
> Not thrilled with the "webcore" prefix.

Is it the capitalization? Would "WebCore" work better for you, or just the idea of WebCore being mentioned in WTF?

> 
> > Source/WTF/ChangeLog:21
> > +        - 'webcoreOnChange: *' called by WebCore::Settings when the setting changes.
> 
> There’s something really strange about having WebCore function names in WTF.
> I could easily imagine overlooking these when doing a global search.

I agree completely, though not yet sure on how to resolve this. I have a few ideas though:

One option, that I don't love all that much, is to have something in WebCore be able to augment the WebPreferences*.yaml files with more data. I like the centrality of having all the data in one place of the WebPreferences*.yaml and that defeats it a bit.

Another option would be to change things around a bit, and instead of generating Settings, we generate a new class, SettingsGenerated, that a hand written Settings class derives from. Then, in the SettingsGenerated, we could do something like have each setter have a virtual didSetFoo() function, that is initially empty and only overriden by Settings if wanted. e.g.

class SettingsGenerated : public SettingsBase {
public:
    bool allowFileAccessFromFileURLs() const { return m_allowFileAccessFromFileURLs; }
    void setAllowFileAccessFromFileURLs(bool value) { m_allowFileAccessFromFileURLs = value; didSetAllowFileAccessFromFileURLs(); }
    virtual void didSetAllowFileAccessFromFileURLs() { }

    bool authorAndUserStylesEnabled() const { return m_authorAndUserStylesEnabled; }
    void setAuthorAndUserStylesEnabled(bool value) { m_authorAndUserStylesEnabled = value; didSetAuthorAndUserStylesEnabled(); }
    virtual void didSetAuthorAndUserStylesEnabled() { }

    ...
};


class Settings final : public SettingsGenerated {
public:
    virtual void didSetAuthorAndUserStylesEnabled() override { setNeedsRecalcStyleInAllFrames(); }
};
Comment 10 Darin Adler 2020-10-10 13:01:30 PDT
(In reply to Sam Weinig from comment #9)
> > Not thrilled with the "webcore" prefix.
> 
> Is it the capitalization? Would "WebCore" work better for you, or just the
> idea of WebCore being mentioned in WTF?

I think it’s a combination of the capitalization and also the feeling that inside WebKit, WebCore shouldn’t have to go by its full name. In the past I named functions things like "core" and maybe that was not great.

> Another option would be to change things around a bit, and instead of
> generating Settings, we generate a new class, SettingsGenerated, that a hand
> written Settings class derives from. Then, in the SettingsGenerated, we
> could do something like have each setter have a virtual didSetFoo()
> function, that is initially empty and only overriden by Settings if wanted.

I like this as long as the compiler can hep us check that we overrode correctly. Strangely it would help us if we were using virtual functions but I’m not sure that you can use override on a non-virtual function.
Comment 11 Darin Adler 2020-10-10 13:13:36 PDT
(In reply to Darin Adler from comment #10)
> > Another option would be to change things around a bit, and instead of
> > generating Settings, we generate a new class, SettingsGenerated, that a hand
> > written Settings class derives from. Then, in the SettingsGenerated, we
> > could do something like have each setter have a virtual didSetFoo()
> > function, that is initially empty and only overriden by Settings if wanted.

A little sad that these would all be virtual functions, but otherwise seems a good pattern. Could also have these be functions on a passed in class to a class template.