Bug 216293

Summary: Small cleanup in RenderTheme
Product: WebKit Reporter: Myles C. Maxfield <mmaxfield>
Component: New BugsAssignee: Myles C. Maxfield <mmaxfield>
Status: RESOLVED FIXED    
Severity: Normal CC: changseok, darin, dino, esprehn+autocc, ews-watchlist, glenn, jonlee, kondapallykalyan, pdr, simon.fraser, thorton, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch darin: review+

Myles C. Maxfield
Reported 2020-09-08 16:52:59 PDT
Small cleanup in RenderTheme
Attachments
Patch (18.60 KB, patch)
2020-09-08 17:10 PDT, Myles C. Maxfield
no flags
Patch (16.43 KB, patch)
2020-09-08 20:07 PDT, Myles C. Maxfield
darin: review+
Myles C. Maxfield
Comment 1 2020-09-08 17:10:07 PDT
Darin Adler
Comment 2 2020-09-08 17:23:20 PDT
Comment on attachment 408287 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=408287&action=review > Source/WebCore/rendering/RenderTheme.cpp:1286 > +#define NumSystemFonts 10 This can be constexpr; does not need to be "define": constexpr auto numSystemFonts = 10; > Source/WebCore/rendering/RenderTheme.cpp:1288 > + FontCascadeDescription& caption() { return (*this)[0]; } Seems to me you could just use an array here and use indices in the code below and don’t need the named getters. > Source/WebCore/rendering/RenderTheme.cpp:1298 > + static_assert(NumSystemFonts == 10); This seems pointless given the number is defined just above. > Source/WebCore/rendering/RenderThemeCocoa.mm:209 > + for (auto& description : (*this)) { > + if (description.isAbsoluteSize()) > + return false; > + } > + return true; Could write this with std::all_of or none_of: return std:: all_of(std::begin(descriptions), std::end(descriptions), [] (auto& description) ( return !description.isAbsoluteSize(); });
Myles C. Maxfield
Comment 3 2020-09-08 20:07:29 PDT
Darin Adler
Comment 4 2020-09-10 16:59:31 PDT
Comment on attachment 408304 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=408304&action=review > Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp:82 > + auto atomStringComparison = [](const AtomString& lhs, const AtomString& rhs) { I think this name doesn’t say the thing it should, which is that this is the most-efficient comparison, comparison by pointer, with the drawback that it sorts things in pseudo-random, non-useful order. I think I would call this compareAsPointer; no need to state the types of the arguments. But maybe you have a different idea about the name. The name atomStringComparison would be a fine name for comparing the string by code point, or code unit, or case folded ASCII, or whatever, and none of those are what want to use here. > Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp:85 > + static auto strings { makeNeverDestroyed([&atomStringComparison] { Not 100% sure about the { } vs. = for the initialization, what is inside the lambda and what is outside, and other such things. I would have been tempted to write "const", but I suppose that’s not needed. > Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp:91 > + auto result = std::binary_search(strings.get().begin(), strings.get().end(), string, atomStringComparison); > + if (result) No need for a local variable "result" here.
Myles C. Maxfield
Comment 5 2020-09-10 18:51:46 PDT
Radar WebKit Bug Importer
Comment 6 2020-09-10 18:52:16 PDT
Note You need to log in before you can comment on or make changes to this bug.