Open Bug 1445566 Opened 6 years ago Updated 2 years ago

stylo-chrome: <tab> element and its descendants are styled twice for each new tab

Categories

(Core :: CSS Parsing and Computation, enhancement, P3)

enhancement

Tracking

()

Tracking Status
firefox61 --- affected

People

(Reporter: xidorn, Unassigned)

References

(Blocks 1 open bug)

Details

Each time when we open a new tab, we style the new <tab> element and its descendants twice. The first time is when we load the binding, and the second time is when we change the select attribute on the new tab element.

When we change the selected attribute, there are two reasons that we will restyle its whole subtree:
1. it changes -moz-user-focus property on the element, [1] which is inherited
2. XBL seems to propagate the selected and visuallyselected to its descendants so we need to mark all of them to have snapshot anyway

This is an extra cost we pay for tabpaint that Gecko doesn't have, because Gecko doesn't need to style the binding subtree eagerly (the first one we do).

The number of elements affected here isn't that much (seems to be 16 elements). Given that in the first restyle of tabpaint, we styles 41 elements and that takes 2.1ms, this may potentially save us 1ms if we can avoid it... which doesn't sound very much. Probably not worth fixing.

But this is indeed a cost we have over Gecko, when script touches a newly-inserted element with binding.


[1] https://searchfox.org/mozilla-central/rev/8fa0b32c84f924c6809c690117dbd59591f79607/toolkit/content/xul.css#702-704
Xidorn: is the 2.1ms on reference machine? I know Florian used to test with a very slow hardware to measure impact of such regressions on users.
(In reply to Zibi Braniecki [:gandalf][:zibi] from comment #1)
> Xidorn: is the 2.1ms on reference machine? I know Florian used to test with
> a very slow hardware to measure impact of such regressions on users.

It's 2.1ms on my local machine based on my previous profile with tabpaint.
Hmm,how does gecko not need to style the descendants of the bound element?

We load the bindings from frame construction, then run frame construction on the children. Assuming (and it'd better be right) that that script tweaking the element doesn't run from frame construction, I don't understand how it could skip styling them, am I missing something?
Hmmm, maybe we need to style them, but frame construction only needs very few properties, specifically, they only need display, ui, and position, so probably we just end up wasting time on things which is being dropped very soon. That's probably something we cannot resolve anyway...
[Triage 2018/03/23 - P3]
Priority: -- → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.