Closed Bug 1675852 Opened 1 year ago Closed 1 year ago

Fix the size of <svg> with no intrinsic size and no preferred aspect-ratio

Categories

(Core :: Layout, defect)

defect

Tracking

()

RESOLVED FIXED
84 Branch
Tracking Status
firefox84 --- fixed

People

(Reporter: TYLin, Assigned: TYLin)

Details

Attachments

(3 files)

This is a follow-up to my comment at https://phabricator.services.mozilla.com/D95578?id=361777#inline-540295.

There are users in our code base that can be replaced by the fallback intrinsic size defined at
https://searchfox.org/mozilla-central/rev/a5d9abfda1e26b1207db9549549ab0bdd73f735d/layout/base/LayoutConstants.h#82-91

While I'm at this, I notice the <svg> in vertical writing-mode with no intrinsic size and no preferred aspect-ratio is rendered 150x300, where Chrome and Safari is rendered 300x150.

data:text/html,<svg style="writing-mode:vertical-rl; background:green">

Per https://drafts.csswg.org/css-sizing-3/#intrinsic-sizes,

... Otherwise, use 300px for the width and/or 150px for the height as needed.

So it's size should be 300x150 regardless of its writing mode value.

This is a preparation of the next part.

Technically, we only need the nsSize's two-argument constructor and
BaseCoord's operator* to be 'constexpr', but for the sake of
completeness, I also make all other BaseCoord's methods 'constexpr'.

CSSPixel::ToAppUnits() requires computation at runtime. Since most of
the layout computations require nscoord, this patch defines extra
intrinsic sizes in app units.

Depends on D96257

Per spec https://drafts.csswg.org/css-sizing-3/#intrinsic-contribution,
for the replaced elements with no intrinsic size and no preferred aspect
ratio, the fallback size is '300px' for the width and '150px' for the
height, regardless of the writing-mode value.

Without this patch, Firefox fails the last subtest, i.e. <svg> with
vertical writing-mode. Both Chrome and Safari render all the subtests as
300x150.

Depends on D96258

Attachment #9186359 - Attachment description: Bug 1675852 Part 3 - Use fallback 300px width and 150px height for vertical <svg> with no intrinsic size and no aspect ratio. → Bug 1675852 Part 3 - Use fallback 300px width and 150px height in ComputeSizeWithIntrinsicDimensions().
Pushed by aethanyc@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/8bff4e360a04
Part 1 - Mark more methods 'constexpr' in BaseCoord and nsSize. r=emilio
https://hg.mozilla.org/integration/autoland/rev/781d08ba2608
Part 2 - Define extra fallback intrinsic sizes in app units. r=emilio
https://hg.mozilla.org/integration/autoland/rev/a49a06261673
Part 3 - Use fallback 300px width and 150px height in ComputeSizeWithIntrinsicDimensions(). r=emilio
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/26469 for changes under testing/web-platform/tests
Upstream PR merged by moz-wptsync-bot
You need to log in before you can comment on or make changes to this bug.