Open Bug 2000035 Opened 1 month ago Updated 22 days ago

Expand `AnchorResolvedSize` to also handle `stretch` and its aliases

Categories

(Core :: Layout, task)

task

Tracking

()

People

(Reporter: dholbert, Unassigned)

References

(Blocks 2 open bugs)

Details

We have this type AnchorResolvedSize, which is sort of a wrapped StyleSize with special semantics:
https://searchfox.org/firefox-main/rev/4fd0fa7e5814c0b51f1dd075821988377bc56cc1/layout/style/nsStyleStruct.h#800-801

using AnchorResolvedSize =
    mozilla::UniqueOrNonOwningPtr<const mozilla::StyleSize>;

This is what the various nsStylePosition::Get{Height,Width} (and Get{Min,Max}Height) properties return now. The point is to resolve anchor-size() functions internally as-needed before returning an answer, using some context params that get passed in. This has the nice result that downstream code (working with a AnchorResolvedSize) doesn't need to worry about checking for or resolving anchor-size() functions at all.

I'd like to extend this type so that it will also resolve stretch and its prefixed aliases as well. This will help us de-duplicate some lazy 'stretch'-resolution code, and it'll help us prove that we don't need to worry about handling/resolving stretch in downstream code.

Naming might be ContextKeywordResolvedSize, with the idea being that this is a StyleSize where the keywords that depend only on context (rather than the content/intrinsic sizing) have already been resolved.

We'll probably want to rename (or wrap) AnchorPosResolutionParams in a name that's similarly-generalized, too. We'll need to add a bit of additional context in order to resolve stretch -- specifically the containing block size and the frame's margin and borderPadding (and box-sizing, though we can already discover that with the existing params).

Blocks: 1933604

Hopefully we can manage with just a single ResolvedSize type.

Depends on: 2004170
You need to log in before you can comment on or make changes to this bug.