-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[ASStackLayoutSpec] Refactor baseline alignment algorithm #2892
[ASStackLayoutSpec] Refactor baseline alignment algorithm #2892
Conversation
Since this PR touches a core component of the layout system, I really appreciate reviews from @maicki, @rcancro, @appleguy, @garrettmoon and @Adlai-Holler. |
Hm, the new snapshot test cases are failing on Jenkins. They pass locally! Now sure what is going on and how to see image differences on a Jenkins machine? |
3f3e22e
to
40bc71b
Compare
Tests are all green now! It turned out text rasterization (antialiasing in particular) works a bit different on iOS 10 and that causes my new snapshot test cases which were captured on iOS 9 to fail. I will try to clean up our reference images tomorrow in a separate PR. |
40bc71b
to
b6c171a
Compare
- Baseline alignment is now part of the main stack algorithm. - ASStackBaselinePositionedLayout is no longer needed and removed.
b6c171a
to
2e44a96
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nguyenhuy Wow this is an great improvement that came out of nowhere. It may be a pre-existing issue and I'm definitely willing to land as-is if need be, but the baselineLast
case seems to be off by a pixel.
If this is caused by inconsistent rounding after the layout pass, it may be pretty tough to fix, and it's not really related to this change.
@Adlai-Holler: Great catch on the misalignment. It's indeed a pre-existing issue. These snapshots were generated based on the current implementation on master. It has something to do with the baseline difference between the texts that should be floored but instead (indirectly) ceiled. I'm investigating this but don't think it should block this PR. |
OK I created the linked issue to track the rounding error. It's time to merge this! Awesome work @nguyenhuy – improvements in many dimensions with a single diff ✨ |
The current baseline alignment algorithm is implemented as an extra step that is executed after our main stack algorithm finished. While it has served us well for a long time, this implementation has a few problems that should be addressed:
This PR does a few things: