Remove `InlineFormattingContext::font_metrics`
In the current implementation, only block-level jobs get dispatched onto rayon thread pool during box tree construction, and I was looking into whether the current block level jobs can be further parallelized, during which I found that it's the InlineFormattingContext::font_metrics field that's stopping InlineItems in the same InlineFormattingContext from being processed in parallel.
https://github.com/servo/servo/blob/224ca771c05c0962c5f8e5a6459c0c66f6277cf4/components/layout/flow/inline/mod.rs#L153-L155
https://github.com/servo/servo/blob/224ca771c05c0962c5f8e5a6459c0c66f6277cf4/components/layout/flow/inline/mod.rs#L196-L202
font_metrics right now gets used when a TextRunSegment uses the index to get the corresponding info like metrics etc. However, these info can be easily obtained from a FontRef as well, and thus I was wondering if anyone who's familiar with the design could explain why not just store a FontRef in the TextRunSegment (and some other types if necessary)? There's always one indirection anyway whether to use a index and the font_metrics Vec or to store a FontRef
I've tried implementing this on my local machine and it seems to work fine. I can open a PR if this sounds OK.
Your suggestion seems reasonable though maybe I would need to see your change to say for sure.
Your suggestion seems reasonable though maybe I would need to see your change to say for sure.
I'll open a PR and let you review :)
@mrobinson I've opened a draft PR #41208