Bug 218098 - Duplicate checks in overridingContainingBlockContentXXX()
Summary: Duplicate checks in overridingContainingBlockContentXXX()
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-10-22 13:44 PDT by Sergio Villar Senin
Modified: 2021-04-30 09:18 PDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergio Villar Senin 2020-10-22 13:44:47 PDT
RenderBoxModelObject.h defines overridingContainingBlockContentWidth() and overridingContainingBlockContentHeight(). Both of them return an Optional<LayoutUnit> apparently to deal with the case of not having an overriding size in the containing block. However the very same file also defines hasOverridingContainingBlockContentWidth() and hasOverridingContainingBlockContentHeight(). This means that there are multiple occurrences of:

if (hasOverridingContainingBlockContentWidth())
    if (auto width = overridingContainingBlockContentWidth())
       return width.value();

duplicating the checks. We should figure out why that was done like this and remove the extra check if needed.

Note that RenderBox.h replicates the same pattern with hasOverridingContainingBlockContentLogical{Height|Width}()
Comment 1 Radar WebKit Bug Importer 2020-10-29 13:45:16 PDT
<rdar://problem/70823764>
Comment 2 Rob Buis 2021-04-30 09:18:18 PDT
This is probably not possible. The code wants to distinguish between nullopt as in "there is nothing set" and "there is something set but it is not a number":
    if (logicalHeight.isPercentOrCalculated() && hasOverridingContainingBlockContentLogicalHeight())
        return overridingContainingBlockContentLogicalHeight() == WTF::nullopt;

It may be possible to set some magic value not nullopt for "there is something set but it is not a number" but I don't think it is worth it personally.