Closed Bug 938175 Opened 11 years ago Closed 6 years ago

Reorganize how we handle detecting that we need to restyle for an attribute change

Categories

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

x86
macOS
enhancement

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: bzbarsky, Unassigned)

References

(Blocks 3 open bugs)

Details

(Keywords: perf)

Right now we handle this as follows:

1)  All attr changes call AttributeWillChange and AttributeChanged
2)  Presshell notifies frame constructor which does HasAttributeDependentStyle on
    the style set which does it on all the ruleprocessors.

What this means is a bunch of virtual function calls on the rule processors.  Twice.

Some things we can improve:

* Have a single data structure on the style set that we build from the ruleprocessors that can do HasAttributeDependentStyle, since we don't actually care _which_ ruleprocessor is causing the restyle (though in the past we've talked about making use of that information to limit which selector matching we redo...).
* Have a fast way to check whether the style system might care about some attribute at all (e.g. if there are no selectors using it) and skip notifying the style system at all in those cases.  Sadly, this won't help things like "id" or "class" much.
* Have a fast way to check whether the attribute is ever used negated and if not skip the AttributeChanged notification to the style system on removeAttribute calls.
Cameron, does this sound like something you might have time and inclination to work on?
Flags: needinfo?(cam)
Severity: normal → enhancement
Keywords: perf
Priority: -- → P4
Inclination, yes.  Time, not sure.  I'll move the needinfo? to myself, to keep it in mind, but someone should feel free to steal.
Flags: needinfo?(cam)
Flags: needinfo?(cam)
Blocks: 1092586
Blocks: 664818
This should mostly be better with the new style system.  It's a bit different now we use snapshots.

(In reply to Boris Zbarsky [:bz] (no decent commit message means r-) from comment #0)
> Some things we can improve:
> 
> * Have a single data structure on the style set that we build from the
> ruleprocessors that can do HasAttributeDependentStyle, since we don't
> actually care _which_ ruleprocessor is causing the restyle (though in the
> past we've talked about making use of that information to limit which
> selector matching we redo...).

We have a data structure per cascade level, but there aren't virtual calls involved, so it shouldn't be as bad.

> * Have a fast way to check whether the style system might care about some
> attribute at all (e.g. if there are no selectors using it) and skip
> notifying the style system at all in those cases.  Sadly, this won't help
> things like "id" or "class" much.

Yes, we do that too now.

> * Have a fast way to check whether the attribute is ever used negated and if
> not skip the AttributeChanged notification to the style system on
> removeAttribute calls.

I don't think we do this.  But perhaps it doesn't matter as much with RestyleManager::AttributeChanged no longer doing virtual calls.
Status: NEW → RESOLVED
Closed: 6 years ago
Flags: needinfo?(cam)
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.