Bug 235272 - Clean up some code around RenderElement::addLayers()
Summary: Clean up some code around RenderElement::addLayers()
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Simon Fraser (smfr)
URL:
Keywords: InRadar
Depends on:
Blocks: 235194
  Show dependency treegraph
 
Reported: 2022-01-15 12:51 PST by Simon Fraser (smfr)
Modified: 2022-01-18 10:46 PST (History)
12 users (show)

See Also:


Attachments
Patch (7.82 KB, patch)
2022-01-15 12:54 PST, Simon Fraser (smfr)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Fraser (smfr) 2022-01-15 12:51:14 PST
Clean up some code around RenderElement::addLayers()
Comment 1 Simon Fraser (smfr) 2022-01-15 12:54:23 PST
Created attachment 449267 [details]
Patch
Comment 2 Darin Adler 2022-01-15 14:27:38 PST
Comment on attachment 449267 [details]
Patch

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

> Source/WebCore/rendering/RenderElement.cpp:640
> +        if (!beforeChild.has_value())

You can omit the ".has_value()" if you like. But if you think including it makes the code clearer, that’s fine.

> Source/WebCore/rendering/RenderElement.cpp:643
> +        parentLayer.addChild(*downcast<RenderLayerModelObject>(currentRenderer).layer(), beforeChild.value());

I often prefer *beforeChild, treating an optional as if it was a pointer, but if you like value() better, I’m OK with it.

> Source/WebCore/rendering/RenderElement.cpp:699
> +        for (auto* child = siblingToTraverseFrom ? siblingToTraverseFrom->nextSibling() : firstChild(); child; child = child->nextSibling()) {

Seems like childAfter helper function, either member or non-member, that returns first if the argument is nullptr and nextSibling if it’s not would make this nicer to read.
Comment 3 Simon Fraser (smfr) 2022-01-18 10:05:02 PST
When dealing with optionals of bools or pointers I like using the explicit has_value() and value() functions.
Comment 4 EWS 2022-01-18 10:45:32 PST
Committed r288127 (246137@main): <https://commits.webkit.org/246137@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 449267 [details].
Comment 5 Radar WebKit Bug Importer 2022-01-18 10:46:18 PST
<rdar://problem/87722144>