Bug 223504 - [css-grid] Set hasIntrinsicWidth & hasIntrinsicHeight properties for SVG element's intrinsic size
Summary: [css-grid] Set hasIntrinsicWidth & hasIntrinsicHeight properties for SVG elem...
Status: REOPENED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Wenson Hsieh
URL:
Keywords: InRadar, WPTImpact
Depends on:
Blocks: 216145
  Show dependency treegraph
 
Reported: 2021-03-19 02:47 PDT by zsun
Modified: 2023-08-07 15:46 PDT (History)
23 users (show)

See Also:


Attachments
Patch (8.73 KB, patch)
2021-03-19 03:26 PDT, zsun
no flags Details | Formatted Diff | Diff
Patch (8.83 KB, patch)
2021-04-06 04:15 PDT, zsun
no flags Details | Formatted Diff | Diff
Patch (7.96 KB, patch)
2021-04-06 07:24 PDT, zsun
no flags Details | Formatted Diff | Diff
Patch (8.45 KB, patch)
2021-04-09 05:18 PDT, zsun
no flags Details | Formatted Diff | Diff
Rebase the original fix (18.60 KB, patch)
2022-02-27 17:12 PST, Wenson Hsieh
ews-feeder: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description zsun 2021-03-19 02:47:05 PDT
The following WPT tests on stretched SVGs without an aspect-ratio are failing in WebKit:

css/css-grid/alignment/grid-item-no-aspect-ratio-stretch-6.html
css/css-grid/alignment/grid-item-no-aspect-ratio-stretch-7.html
Comment 1 zsun 2021-03-19 03:26:49 PDT
Created attachment 423712 [details]
Patch
Comment 2 Javier Fernandez 2021-03-24 10:18:17 PDT
Comment on attachment 423712 [details]
Patch

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

> Source/WebCore/rendering/svg/RenderSVGRoot.cpp:83
> +    intrinsicSize.hasWidth = svgSVGElement().hasIntrinsicWidth();

I'm not sure I understand well enough the meaning of the hasWidth/hasHeight attributes. Looking at how you are using it, wouldn't be a clearer name something like "isIntrinsicWidth/isIntrinsiHeight"  ?
Comment 3 Radar WebKit Bug Importer 2021-03-26 02:48:13 PDT
<rdar://problem/75879440>
Comment 4 zsun 2021-04-02 03:46:08 PDT
(In reply to Javier Fernandez from comment #2)
> Comment on attachment 423712 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=423712&action=review
> 
> > Source/WebCore/rendering/svg/RenderSVGRoot.cpp:83
> > +    intrinsicSize.hasWidth = svgSVGElement().hasIntrinsicWidth();
> 
> I'm not sure I understand well enough the meaning of the hasWidth/hasHeight
> attributes. Looking at how you are using it, wouldn't be a clearer name
> something like "isIntrinsicWidth/isIntrinsiHeight"  ?

hasWidth/hasHeight here means that whether width/height has been set. Since we are introducing these properties in FloatSize.h, I thought it might be better to make it more generic. When we call intrinsicSize.*, we know that we are referring width/height of the intrinsicSize. Also it's to be inline with has_width/has_height in Chromium for this situation.
Comment 5 zsun 2021-04-06 04:15:02 PDT
Created attachment 425263 [details]
Patch
Comment 6 zsun 2021-04-06 07:24:48 PDT
Created attachment 425275 [details]
Patch
Comment 7 Javier Fernandez 2021-04-09 04:42:21 PDT
Comment on attachment 425275 [details]
Patch

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

r=me

> Source/WebCore/rendering/RenderReplaced.cpp:630
> +    bool hasIntrinsicHeight = constrainedSize.hasIntrinsicHeight || constrainedSize.height() > 0;

I'd suggest a comment here to note that we are only updating the hasIntrinsicHeight flag for SVG elements, but that ideally, we would like to use it in all the cases and get rid of the constrainedSize.height() > 0 clause.
Comment 8 zsun 2021-04-09 05:18:30 PDT
Created attachment 425614 [details]
Patch
Comment 9 EWS 2021-04-09 12:05:14 PDT
Committed r275772 (236347@main): <https://commits.webkit.org/236347@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 425614 [details].
Comment 10 Simon Fraser (smfr) 2022-02-16 16:57:05 PST
Comment on attachment 425614 [details]
Patch

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

> Source/WebCore/platform/graphics/FloatSize.h:76
> +    bool hasIntrinsicWidth = false;
> +    bool hasIntrinsicHeight = false;

Why are these here?
Comment 11 Simon Fraser (smfr) 2022-02-16 17:05:29 PST
Comment on attachment 425614 [details]
Patch

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

>> Source/WebCore/platform/graphics/FloatSize.h:76
>> +    bool hasIntrinsicHeight = false;
> 
> Why are these here?

This increased the size of FloatSize, FloatRect and all classes that use them, and means that FloatSize no longer fits into a 64-bit register. It's also a layering violation; it makes no sense for this basic geometry class to hold information related to layout.
Comment 12 Tim Horton 2022-02-16 17:17:43 PST
Reverting in https://bugs.webkit.org/show_bug.cgi?id=236743, reopening.
Comment 13 Wenson Hsieh 2022-02-27 17:12:11 PST
Created attachment 453361 [details]
Rebase the original fix
Comment 14 Wenson Hsieh 2022-02-27 17:14:42 PST
(In reply to Tim Horton from comment #12)
> Reverting in https://bugs.webkit.org/show_bug.cgi?id=236743, reopening.

(Let's also ensure these WPT fixes don't get lost moving forward due to the revert)

I uploaded a version of Ziran's original change that doesn't add the new flags to FloatSize (but instead plumbs them as arguments through the affected rendering codepaths).
Comment 15 zsun 2022-02-28 02:44:06 PST
Thanks very much Wenson for helping with this. Sorry that I didn't manage to find time last week to look into it.

I think Wenson's patch pretty much wraps up what I initially intended to achieve but without increasing FloatSize. Thanks for the lovely solution.
Comment 16 Wenson Hsieh 2022-02-28 12:59:43 PST
Comment on attachment 453361 [details]
Rebase the original fix

(iOS WK2 failures seem unrelated)
Comment 17 Darin Adler 2022-02-28 14:59:48 PST
Comment on attachment 453361 [details]
Rebase the original fix

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

> Source/WebCore/rendering/RenderBox.h:615
> +    virtual void computeIntrinsicRatioInformation(FloatSize& /* intrinsicSize */, double& /* intrinsicRatio */, bool& /* hasIntrinsicWidth */, bool& /* hasIntrinsicHeight */) const { }

In future I think this needs to start returning a structure, not take 4 out arguments.
Comment 18 Wenson Hsieh 2022-02-28 16:15:23 PST
Comment on attachment 453361 [details]
Rebase the original fix

(In reply to Darin Adler from comment #17)
> Comment on attachment 453361 [details]
> Rebase the original fix
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=453361&action=review
> 
> > Source/WebCore/rendering/RenderBox.h:615
> > +    virtual void computeIntrinsicRatioInformation(FloatSize& /* intrinsicSize */, double& /* intrinsicRatio */, bool& /* hasIntrinsicWidth */, bool& /* hasIntrinsicHeight */) const { }
> 
> In future I think this needs to start returning a structure, not take 4 out
> arguments.

Sounds good! Since this patch touches all of the method signatures anyways, I think we should just do it as a part of this change.
Comment 19 Ahmad Saleem 2023-08-07 15:46:16 PDT
Based on Comment 0, we only have now 'grid-item-no-aspect-ratio-stretch-6.html' and we are still failing this and other two as well:

https://wpt.fyi/results/css/css-grid/alignment?label=master&label=experimental&aligned&q=grid-item-no-aspect-ratio-stretch-

Adding 'WPTImpact' tag as well for tracking purposes.