Introducing the "X" use flag to firefox, so it will able to build without X dependencies.
To make it work, the ebuild should apply patches from the upstream bug:
before it is implemented upstream.
Personally feel it would be better to wait for upstream to include it in a future release rather than add here.
The semi-related upcoming NPAPI code cleanup will remove the need to depend on gtk2 as well.
looks like it has been (partially) implemented upstream:
I will do some testing and see if it works. Maybe a temporary implementation could be made in the live ebuild?
It's not that easy like it sounds.
Even if we ignore the maintenance burden of such a custom patch, LTO/PGO will require virtualx because we have nothing similar for wayland yet. Therefore it's not worth to spend time on this yet from my POV.