Bug 235175 - [css-contain] Fix contain-size-replaced-002.html
Summary: [css-contain] Fix contain-size-replaced-002.html
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Rob Buis
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-01-13 01:20 PST by Rob Buis
Modified: 2022-01-15 09:23 PST (History)
15 users (show)

See Also:


Attachments
Patch (3.32 KB, patch)
2022-01-13 01:22 PST, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (3.52 KB, patch)
2022-01-13 07:31 PST, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (3.41 KB, patch)
2022-01-14 02:23 PST, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (4.04 KB, patch)
2022-01-14 03:19 PST, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (3.61 KB, patch)
2022-01-14 06:44 PST, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (3.60 KB, patch)
2022-01-14 10:46 PST, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (3.61 KB, patch)
2022-01-15 08:10 PST, Rob Buis
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rob Buis 2022-01-13 01:20:43 PST
Fix contain-size-replaced-002.html.
Comment 1 Rob Buis 2022-01-13 01:22:15 PST
Created attachment 449034 [details]
Patch
Comment 2 Rob Buis 2022-01-13 07:31:18 PST
Created attachment 449057 [details]
Patch
Comment 3 Nikolas Zimmermann 2022-01-14 01:41:07 PST
Comment on attachment 449057 [details]
Patch

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

Unofficial review :-)

> Source/WebCore/rendering/svg/LegacyRenderSVGRoot.cpp:268
> +    if (clipViewport && (contentWidth() == LayoutUnit() || contentHeight() == LayoutUnit()))

While a decent compiler won't create LayoutUnit temporaries over and over, this is still hard to read.

One could either make use of LayoutUnits operator bool() -- however since it's marked explicit, this is also awkward:
if (clipViewport && (!bool(contentWidth()) || !bool(contentHeight())))

Therefore I'd avoid using contentWidth()/contentHeight() and instead query 'LayoutSize contentSize()', which encapsulates the logic you're looking for in the "isEmpty" function:
if (clipViewport && contentSize().isEmpty())
Comment 4 Rob Buis 2022-01-14 02:23:03 PST
Created attachment 449151 [details]
Patch
Comment 5 Rob Buis 2022-01-14 02:24:25 PST
Comment on attachment 449057 [details]
Patch

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

>> Source/WebCore/rendering/svg/LegacyRenderSVGRoot.cpp:268
>> +    if (clipViewport && (contentWidth() == LayoutUnit() || contentHeight() == LayoutUnit()))
> 
> While a decent compiler won't create LayoutUnit temporaries over and over, this is still hard to read.
> 
> One could either make use of LayoutUnits operator bool() -- however since it's marked explicit, this is also awkward:
> if (clipViewport && (!bool(contentWidth()) || !bool(contentHeight())))
> 
> Therefore I'd avoid using contentWidth()/contentHeight() and instead query 'LayoutSize contentSize()', which encapsulates the logic you're looking for in the "isEmpty" function:
> if (clipViewport && contentSize().isEmpty())

That is much better, thanks! I updated the patch.
Comment 6 Nikolas Zimmermann 2022-01-14 02:57:15 PST
Looks great, unofficial r=me.
Comment 7 Manuel Rego Casasnovas 2022-01-14 03:11:56 PST
Comment on attachment 449151 [details]
Patch

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

r=me

> Source/WebCore/rendering/svg/LegacyRenderSVGRoot.cpp:269
> +    if (clipViewport && contentSize().isEmpty())
> +        return;

One question, should we move this up on the method, to avoid doing other checks that might not be needed?
Comment 8 Rob Buis 2022-01-14 03:19:30 PST
Created attachment 449156 [details]
Patch
Comment 9 Rob Buis 2022-01-14 03:20:36 PST
Comment on attachment 449151 [details]
Patch

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

>> Source/WebCore/rendering/svg/LegacyRenderSVGRoot.cpp:269
>> +        return;
> 
> One question, should we move this up on the method, to avoid doing other checks that might not be needed?

Good comment, I think the position is okay, but I made a change regarding addRelevantRepaintedObject that I will run by Niko. Thanks for the review.
Comment 10 Nikolas Zimmermann 2022-01-14 06:16:45 PST
Comment on attachment 449156 [details]
Patch

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

> Source/WebCore/rendering/svg/LegacyRenderSVGRoot.cpp:-259
> -                page().addRelevantUnpaintedObject(this, visualOverflowRect());

You're no longer keeping track of relevant _unpainted_ objects?
Apparently we lack test coverage for this, nothing turned red :-)
Comment 11 Rob Buis 2022-01-14 06:18:56 PST
Comment on attachment 449156 [details]
Patch

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

>> Source/WebCore/rendering/svg/LegacyRenderSVGRoot.cpp:-259
>> -                page().addRelevantUnpaintedObject(this, visualOverflowRect());
> 
> You're no longer keeping track of relevant _unpainted_ objects?
> Apparently we lack test coverage for this, nothing turned red :-)

Yeah, misread the code!
Comment 12 Nikolas Zimmermann 2022-01-14 06:26:27 PST
(In reply to Rob Buis from comment #9)
> Comment on attachment 449151 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=449151&action=review
> 
> >> Source/WebCore/rendering/svg/LegacyRenderSVGRoot.cpp:269
> >> +        return;
> > 
> > One question, should we move this up on the method, to avoid doing other checks that might not be needed?
> 
> Good comment, I think the position is okay, but I made a change regarding
> addRelevantRepaintedObject that I will run by Niko. Thanks for the review.

Hmm, it depends. Apparently addRelevantRepaintedObject/UnpaintedObject is not covered by tests that the bots run at least.

Robs new condition (when viewport is clipped and either width or height are empty, bail out) is preceded by:

    if (paintInfo.phase == PaintPhase::Foreground)
        page().addRelevantRepaintedObject(this, visualOverflowRect());

In LBSE I can immediately answer what the visualOverflowRect() looks like for a SVG renderer in general. However for LegacyRenderSVGRoot and the whole legacy SVG engine we always used to have the problem that we are not exactly sure of the different coordinate systems: visualOverflowRect() is different to SVG objectBoundingBox for instance, defined related to the 'border box rect' in CSS terms. So what does that mean for SVG? Hard to answer for the legacy SVG engine, needs to be checked case-by-case.

Therefore I'm not sure: if there is an empty contentSize, why bother claiming that the LegacyRenderSVGRoot is a 'relevant repainted object' -- it's not. The visualOverflowRect() should have either empty width or height, just like the contentSize, no?

At least one should printf() the visualOverflowRect / contentSize for a few cases, to understand this better. Rego is probably right, that we should move the contentSize().isEmpty() check at least above the addRelevantRepaintedObject() section.

Who knows more about addRelevantRepaintedObject()?
Comment 13 Rob Buis 2022-01-14 06:44:48 PST
Created attachment 449168 [details]
Patch
Comment 14 Rob Buis 2022-01-14 10:46:18 PST
Created attachment 449185 [details]
Patch
Comment 15 EWS 2022-01-15 06:47:45 PST
ChangeLog entry in LayoutTests/ChangeLog contains OOPS!.
Comment 16 Rob Buis 2022-01-15 08:10:41 PST
Created attachment 449253 [details]
Patch
Comment 17 EWS 2022-01-15 09:22:48 PST
Committed r288057 (246077@main): <https://commits.webkit.org/246077@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 449253 [details].
Comment 18 Radar WebKit Bug Importer 2022-01-15 09:23:18 PST
<rdar://problem/87639203>