Closed Bug 1660122 Opened 5 years ago Closed 5 years ago

Let nsIFrame::GetIntrinsicRatio() work for both non-replaced and replaced elements

Categories

(Core :: Layout, enhancement, P3)

All
Unspecified
enhancement

Tracking

()

RESOLVED FIXED
83 Branch
Tracking Status
firefox83 --- fixed

People

(Reporter: boris, Assigned: TYLin)

References

(Blocks 1 open bug)

Details

Attachments

(8 files)

Now, nsIFrame::GetIntrinsicRatio() is only for replaced-elements. For non-replaced elements, we expect it is 0. However, aspect-ratio property works for both non-replaced and replaced elements, and it is defined as "intrinsic aspect ratio" for all the cases indeed. So for readability and maintenance, we may have to update the return type of this function. At least we should make sure it can tell the difference for 1/0, 0/1, and auto value.

Now, this method is just an alias of GetIntrinsicRatio().

Depends on D91225

For now, GetAspectRatio() is just an alias for GetIntrinicRatio(). In
Part 7, we're going to have GetAspectRatio() consider aspect-ratio
property so that each replaced elements only need to report their
intrinsic ratio via GetIntrinicRatio. Non-replaced element can also call
GetAspectRatio() to get the ratio suitable to calculate layout size.

As of this patch, all the replaced elements' GetIntrinsicRatio()
consider aspect-ratio properties (added in bug 1639963), so most of the
existing callers [1] should call GetAspectRatio() instead to retain the
behavior after Part 7. We adapt these callers in this patch.

[1] Exceptions include 1) a caller in nsIFrame::ComputeSize() checking
the frame has no intrinsic ratio; 2) other frame classes implementing
nsIFrame::GetIntrinsicRatio() by calling their parent's
GetIntrinicRatio(). nsSubDocumentFrame::GetIntrinicRatio() is an
example.

Depends on D91226

IsXULDisplayType() is going to be used in GetAspectRatio() in the next part.

Also rename it to IsXULDisplayStyle() because nsStyleDisplay often has
"Style"-suffix for related helpers.

Depends on D91227

This patch moves the preferred aspect-ratio calculation from each
replaced elements' GetIntrinicRatio() into GetAspectRatio(), because
they share the same logic.

For nsImageFrame, the cached mIntrinsicRatio now stores only the image's
intrinsic ratio, not considering the aspect-ratio property.

This also makes us pass some of the aspect-ratio tests because we change
GetIntrinicRatio() into GetAspectRatio() in
nsLayoutUtils::IntrinsicForAxis() in Part5, which is used by nsBlockFrame
(via nsLayoutUtils::IntrinsicForContainer) to implement GetMinISize().

Depends on D91228

Assignee: nobody → aethanyc
Status: NEW → ASSIGNED
Blocks: 1667501

This function doesn't consider aspect-ratio property anymore. Hence the
rename.

Depends on D91229

Pushed by aethanyc@gmail.com: https://hg.mozilla.org/integration/autoland/rev/3730e389f359 Part 1 - Convert GetPosterImageSize into a nsVideoFrame's method, and mark some other methods 'const'. r=boris https://hg.mozilla.org/integration/autoland/rev/8776ac19cb23 Part 2 - Mark more methods in nsHTMLCanvasFrame and nsSubDocumentFrame 'const'. r=boris https://hg.mozilla.org/integration/autoland/rev/daa98d9d594b Part 3 - Make nsIFrame::GetIntrinsicRatio() a const method. r=boris https://hg.mozilla.org/integration/autoland/rev/ed2d90d8c3a0 Part 4 - Remove nsImageFrame::GetComputedIntrinsicRatio(). r=boris https://hg.mozilla.org/integration/autoland/rev/7774e55b520c Part 5 - Add nsIFrame::GetAspectRatio() skeleton, and adapt existing callers. r=emilio https://hg.mozilla.org/integration/autoland/rev/6685d0128466 Part 6 - Move static function IsXULDisplayType() into nsStyleDisplay. r=emilio https://hg.mozilla.org/integration/autoland/rev/a81a1a6e1c0f Part 7 - Implement GetAspectRatio(). r=emilio https://hg.mozilla.org/integration/autoland/rev/0bb66029c0d1 Part 8 - Rename ComputeAspectRatio() to ComputeIntrinsicRatio(). r=boris
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/25860 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.

Attachment

General

Created:
Updated:
Size: