Skip to content

API tweaks for Taffy calc() integration#104

Merged
nicoburns merged 2 commits intoservo:mainfrom
nicoburns:grid-calc
Jan 7, 2025
Merged

API tweaks for Taffy calc() integration#104
nicoburns merged 2 commits intoservo:mainfrom
nicoburns:grid-calc

Conversation

@nicoburns
Copy link
Copy Markdown
Collaborator

Submitted upstream as https://bugzilla.mozilla.org/show_bug.cgi?id=1939791, but don't want to wait for sync before posting Servo PR.

Changes made:

  • Make LengthPercentage::unpack and the Unpack type it returns public. Used to access the address of the boxed CalcLengthPercentage value so that it can be passed into Taffy.
  • Add OpaqueElement::from_non_null_ptr. This is used to avoid Undefined Behaviour when constructing an OpaqueElement from an index which is unlikely to be a valid memory address. Technically not related to calc() but it's a small change, and I've bundled them when submitting upstream.

This will help enable support for calc() values for CSS Grid containers/items in Servo.

@nicoburns nicoburns added the enhancement New feature or request label Jan 6, 2025
@nicoburns nicoburns added this pull request to the merge queue Jan 7, 2025
Merged via the queue into servo:main with commit 95ee4c3 Jan 7, 2025
@nicoburns nicoburns deleted the grid-calc branch January 7, 2025 01:36
github-merge-queue bot pushed a commit to servo/servo that referenced this pull request Nov 14, 2025
Depends on:

- servo/stylo#104
- #34926
- #34927
- #34948

In addition to that a `resolve_calc_value` function has been added which
resolves calc values during the layout process once a percentage
resolution basis is available.

~~There is 1 newly failing test and 1 newly failing subtest here.~~
These issues have now been fixed.

There are 8 new subtest failures in
`css/css-grid/grid-definition/grid-minimum-contribution-with-percentages.html`.
These are genuine failures, but are unrelated to the calc
implementation. The calc implementation is just exposing a pre-existing
bug around percentage resolution that also now correctly also applies to
`calc()` values containing percentages. The fix for would best be done
in a followup as it requires teaching Taffy about "compressible replaced
elements". (update: I have this
[implemented](#34948) but in the
interest of keeping it to one feature per PR I have not included it
here)

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by
`[X]` when the step is complete, and replace `___` with appropriate
data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors. It doesn't like the
git dependency on Taffy.
- [x] There are tests for these changes OR

---------

Signed-off-by: Nico Burns <[email protected]>
github-merge-queue bot pushed a commit to servo/servo that referenced this pull request Nov 14, 2025
Depends on:

- servo/stylo#104
- #34926
- #34927
- #34948

In addition to that a `resolve_calc_value` function has been added which
resolves calc values during the layout process once a percentage
resolution basis is available.

~~There is 1 newly failing test and 1 newly failing subtest here.~~
These issues have now been fixed.

There are 8 new subtest failures in
`css/css-grid/grid-definition/grid-minimum-contribution-with-percentages.html`.
These are genuine failures, but are unrelated to the calc
implementation. The calc implementation is just exposing a pre-existing
bug around percentage resolution that also now correctly also applies to
`calc()` values containing percentages. The fix for would best be done
in a followup as it requires teaching Taffy about "compressible replaced
elements". (update: I have this
[implemented](#34948) but in the
interest of keeping it to one feature per PR I have not included it
here)

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by
`[X]` when the step is complete, and replace `___` with appropriate
data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors. It doesn't like the
git dependency on Taffy.
- [x] There are tests for these changes OR

---------

Signed-off-by: Nico Burns <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants