Make `aspectRatio` property spec compliant
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18.9k
- Forks
- 1.6k
- Avg merge
- 1m
- Merged PRs (30d)
- 1
Description
Report
Issues and Steps to Reproduce
The following can be added as gentest/fixtures/YGAspectRatioTest.html. Note that for the tests containing text, the test generation script/template will need support added for measuring text and generating a measure function (https://github.com/facebook/yoga/issues/1296)
<div id="aspect_ratio_flex_column_fill_height" style="display: flex; flex-direction: column; align-items: start; height: 100px; width: 100px;">
<div style="width: 40px; aspect-ratio: 2;"></div>
</div>
<div id="aspect_ratio_flex_column_fill_max_height" style="display: flex; flex-direction: column; align-items: start; height: 100px; width: 100px;">
<div style="max-width: 40px; aspect-ratio: 2;">HHHHHHHHHHHHHHHHHHHHHH</div>
</div>
<div id="aspect_ratio_flex_column_fill_max_width" style="display: flex; flex-direction: column; align-items: start; height: 100px; width: 100px;">
<div style="max-height: 20px; aspect-ratio: 2;">HHHHHHHH</div>
</div>
<div id="aspect_ratio_flex_column_fill_min_height" style="display: flex; flex-direction: column; align-items: start; height: 100px; width: 100px;">
<div style="min-width: 40px; aspect-ratio: 2;"></div>
</div>
<div id="aspect_ratio_flex_column_fill_min_width" style="display: flex; flex-direction: column; align-items: start; height: 100px; width: 100px;">
<div style="min-height: 40px; aspect-ratio: 2;">
</div>
</div>
<div id="aspect_ratio_flex_column_fill_width" style="display: flex; flex-direction: column; align-items: start; height: 100px; width: 100px;">
<div style="height: 40px; aspect-ratio: 2;"></div>
</div>
<div id="aspect_ratio_flex_column_fill_width_flex" style="display: grid; flex-direction: column; height: 100px; width: 100px;">
<div style="height: 50px; aspect-ratio: 2;"></div>
</div>
<div id="aspect_ratio_flex_column_stretch_fill_height" style="display: flex; flex-direction: column; height: 100px; width: 100px;">
<div style="width: 40px; aspect-ratio: 2;"></div>
</div>
<div id="aspect_ratio_flex_column_stretch_fill_max_height" style="display: flex; flex-direction: column; height: 100px; width: 100px;">
<div style="max-width: 40px; aspect-ratio: 2;">HHHHHHHHHHHHHHHHHHHHHH</div>
</div>
<div id="aspect_ratio_flex_column_stretch_fill_max_width" style="display: flex; flex-direction: column; height: 100px; width: 100px;">
<div style="max-height: 20px; aspect-ratio: 2;">HHHHHHHH</div>
</div>
<div id="xaspect_ratio_flex_column_stretch_fill_min_height" style="display: flex; flex-direction: column; height: 100px; width: 100px;">
<div style="min-width: 40px; aspect-ratio: 2;"></div>
</div>
<div id="xaspect_ratio_flex_column_stretch_fill_min_width" style="display: flex; flex-direction: column; height: 100px; width: 100px;">
<div style="min-height: 40px; aspect-ratio: 2;">
</div>
</div>
<div id="aspect_ratio_flex_column_stretch_fill_width" style="display: flex; flex-direction: column; height: 100px; width: 100px;">
<div style="height: 40px; aspect-ratio: 2;"></div>
</div>
<div id="aspect_ratio_flex_row_fill_height" style="display: flex; align-items: start; height: 100px; width: 100px;">
<div style="width: 40px; aspect-ratio: 2;"></div>
</div>
<div id="aspect_ratio_flex_row_fill_max_height" style="display: flex; align-items: start; height: 100px; width: 100px;">
<div style="max-width: 40px; aspect-ratio: 2;">HHHHHHHHHHHHHHHHHHHHHH</div>
</div>
<div id="aspect_ratio_flex_row_fill_max_width" style="display: flex; align-items: start; height: 100px; width: 100px;">
<div style="max-height: 20px; aspect-ratio: 2;">HHHHHHHH</div>
</div>
<div id="aspect_ratio_flex_row_fill_min_height" style="display: flex; align-items: start; height: 100px; width: 100px;">
<div style="min-width: 40px; aspect-ratio: 2;"></div>
</div>
<div id="aspect_ratio_flex_row_fill_min_width" style="display: flex; align-items: start; height: 100px; width: 100px;">
<div style="min-height: 40px; aspect-ratio: 2;">
</div>
</div>
<div id="aspect_ratio_flex_row_fill_width" style="display: flex; align-items: start; height: 100px; width: 100px;">
<div style="height: 40px; aspect-ratio: 2;"></div>
</div>
<div id="aspect_ratio_flex_row_fill_width_flex" style="display: grid; align-items: start; height: 100px; width: 100px;">
<div style="height: 50px; aspect-ratio: 2;"></div>
</div>
<div id="aspect_ratio_flex_row_stretch_fill_height" style="display: flex; height: 100px; width: 100px;">
<div style="width: 40px; aspect-ratio: 2;"></div>
</div>
<div id="aspect_ratio_flex_row_stretch_fill_max_height" style="display: flex; height: 100px; width: 100px;">
<div style="max-width: 40px; aspect-ratio: 2;">HHHHHHHHHHHHHHHHHHHHHH</div>
</div>
<div id="aspect_ratio_flex_row_stretch_fill_max_width" style="display: flex; height: 100px; width: 100px;">
<div style="max-height: 20px; aspect-ratio: 2;">HHHHHHHH</div>
</div>
<div id="aspect_ratio_flex_row_stretch_fill_min_height" style="display: flex; height: 100px; width: 100px;">
<div style="min-width: 40px; aspect-ratio: 2;"></div>
</div>
<div id="aspect_ratio_flex_row_stretch_fill_min_width" style="display: flex; height: 100px; width: 100px;">
<div style="min-height: 40px; aspect-ratio: 2;"></div>
</div>
<div id="aspect_ratio_flex_row_stretch_fill_width" style="display: flex; height: 100px; width: 100px;">
<div style="height: 40px; aspect-ratio: 2;"></div>
</div>
<div id="absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset" style="display: flex; width: 400px; height: 300px;">
<div style="position: absolute; top: 5%; bottom: 5%; left: 5%; right: 5%; aspect-ratio: 3;"></div>
</div>
<div id="absolute_aspect_ratio_fill_height" style="display: flex; width: 400px; height: 300px;">
<div style="position: absolute; top: 5%; left: 5%; width: 50%; aspect-ratio: 3;"></div>
</div>
<div id="absolute_aspect_ratio_fill_height_from_inset" style="display: flex; width: 400px; height: 300px;">
<div style="position: absolute; top: 5%; left: 10%; right: 10%; aspect-ratio: 3;"></div>
</div>
<div id="absolute_aspect_ratio_fill_max_height" style="display: flex; width: 400px; height: 300px;">
<div style="position: absolute; max-width: 50px; aspect-ratio: 3;">HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH</div>
</div>
<div id="absolute_aspect_ratio_fill_max_width" style="display: flex; width: 400px; height: 300px;">
<div style="position: absolute; max-height: 50px; aspect-ratio: 0.5;">HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH</div>
</div>
<div id="absolute_aspect_ratio_fill_min_height" style="display: flex; width: 400px; height: 300px;">
<div style="position: absolute; min-width: 50px; aspect-ratio: 3;"></div>
</div>
<div id="absolute_aspect_ratio_fill_min_width" style="display: flex; width: 400px; height: 300px;">
<div style="position: absolute; min-height: 50px; aspect-ratio: 0.5;"></div>
</div>
<div id="absolute_aspect_ratio_fill_width" style="display: flex; width: 400px; height: 300px;">
<div style="position: absolute; top: 5%; left: 5%; height: 20%; aspect-ratio: 3;"></div>
</div>
<div id="absolute_aspect_ratio_fill_width_from_inset" style="display: flex; width: 400px; height: 300px;">
<div style="position: absolute; top: 30%; bottom: 50%; aspect-ratio: 3;"></div>
</div>
<div id="absolute_aspect_ratio_height_overrides_inset" style="display: flex; width: 400px; height: 300px;">
<div style="position: absolute; top: 30%; bottom: 50%; height: 10%; aspect-ratio: 3;"></div>
</div>
<div id="absolute_aspect_ratio_width_overrides_inset" style="display: flex; width: 400px; height: 300px;">
<div style="position: absolute; top: 5%; left: 10%; right: 10%; width: 40%; aspect-ratio: 3;"></div>
</div>
Expected Behavior
Tests should pass
Actual Behavior
Tests fail
Link to Code
See https://github.com/facebook/yoga/blob/974473aa99a2432b2f083446fc5ff9f71c4a3b08/website/contents/properties/aspect-ratio.md?plain=1#L2 which documents Yoga's aspectRatio support as non-standard
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the documented behavior in website/contents/properties/aspect-ratio.md and the aspect-ratio implementation and layout tests in the repository. Add gentest/fixtures/YGAspectRatioTest.html from the report, noting that text cases depend on the generator work in issue #1296. Done means the listed flex and absolute-positioned aspect-ratio cases pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100