Bug 222550 - Remove document accessor on CSSFontSelector
Summary: Remove document accessor on CSSFontSelector
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: Chris Lord
URL:
Keywords: InRadar
Depends on:
Blocks: 202793
  Show dependency treegraph
 
Reported: 2021-03-01 07:18 PST by Chris Lord
Modified: 2021-03-02 02:15 PST (History)
8 users (show)

See Also:


Attachments
Patch (10.25 KB, patch)
2021-03-01 07:39 PST, Chris Lord
no flags Details | Formatted Diff | Diff
Patch (10.69 KB, patch)
2021-03-02 01:46 PST, Chris Lord
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Lord 2021-03-01 07:18:19 PST
Previous work (see bug 208351) removes some instances of unnecessary Document dependence where ScriptExecutionContext would do and make it easier to alter things to be Worker-compatible in the future. Removing CSSFontSelector::document() in favour of ::scriptExecutionContext() would be another step that would help in this process.
Comment 1 Chris Lord 2021-03-01 07:39:02 PST
Created attachment 421825 [details]
Patch
Comment 2 Darin Adler 2021-03-01 12:23:30 PST
Comment on attachment 421825 [details]
Patch

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

So many pointers. Are these all truly optional with meaningful null cases? Can any be changed to references?

> Source/WebCore/css/CSSFontFace.cpp:77
> +            const Settings::Values* settings = context ? &context->settingsValues() : nullptr;

I think auto instead of const Settings::Values* would be better.

> Source/WebCore/css/CSSFontFace.cpp:97
> +    const Settings::Values* settings = context ? &context->settingsValues() : nullptr;

Ditto.

> Source/WebCore/css/CSSFontFace.h:31
> +#include "Settings.h"

A real shame that Settings::Values means adding more header dependencies like this.

Can we remove any other forward declarations or includes since Settings.h pulls in more?

> Source/WebCore/css/CSSFontSelector.cpp:236
> +    return m_document.get();

Need a comment to explain why we hold a document yet return only a script execution context; generally that’s a bad pattern that we try to avoid. Presumably the reason is that we intend to eventually not hold a document?
Comment 3 Chris Lord 2021-03-01 16:30:47 PST
(In reply to Darin Adler from comment #2)
> Comment on attachment 421825 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=421825&action=review
> 
> So many pointers. Are these all truly optional with meaningful null cases?
> Can any be changed to references?

Is this in regards to the constructor? I can certainly take a look.

> > Source/WebCore/css/CSSFontFace.cpp:77
> > +            const Settings::Values* settings = context ? &context->settingsValues() : nullptr;
> 
> I think auto instead of const Settings::Values* would be better.
> 
> > Source/WebCore/css/CSSFontFace.cpp:97
> > +    const Settings::Values* settings = context ? &context->settingsValues() : nullptr;
> 
> Ditto.

Sure, I think for some reason I was under the impression that auto wouldn't work, probably from a different version of the patch with some ambiguity here...

> > Source/WebCore/css/CSSFontFace.h:31
> > +#include "Settings.h"
> 
> A real shame that Settings::Values means adding more header dependencies
> like this.
> 
> Can we remove any other forward declarations or includes since Settings.h
> pulls in more?

I'll take a look and see if there's anything I can trim.

> > Source/WebCore/css/CSSFontSelector.cpp:236
> > +    return m_document.get();
> 
> Need a comment to explain why we hold a document yet return only a script
> execution context; generally that’s a bad pattern that we try to avoid.
> Presumably the reason is that we intend to eventually not hold a document?

That's right, I can add a comment to this effect. I already have the follow-up patches that allow construction with a generic ScriptExecutionContext, so hopefully there won't be too big a time with this slightly confusing behaviour.
Comment 4 Chris Lord 2021-03-02 01:46:15 PST
Created attachment 421916 [details]
Patch
Comment 5 EWS 2021-03-02 02:14:01 PST
Committed r273726: <https://commits.webkit.org/r273726>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 421916 [details].
Comment 6 Radar WebKit Bug Importer 2021-03-02 02:15:20 PST
<rdar://problem/74919118>