w3c / webappsec-permissions-policy

A mechanism to selectively enable and disable browser features and APIs
https://w3c.github.io/webappsec-permissions-policy/
Other
399 stars 155 forks source link

Layout Performance/Complexity Policy #143

Open developit opened 6 years ago

developit commented 6 years ago

There's a similar issue for overall rendering performance, but I wanted to float a more specific proposal:

Would a Feature Policy that provides guarantees about the types of layout needed for a document allow for optimizations browser cannot currently perform? I'm about as far as one can get from an expert on the subject, but intuitively it seems like a FP limiting layout to a single pass[1] could turn some heuristics/assumptions into knowns before any rendering has occurred.

Similarly, what about a Feature Policy for disabling table layouts? Or a policy that disables layout based on text size?

I don't have much insight into the feasibility of implementing these things, nor any advantages/disadvantages they might have on performance, but I wanted to start a discussion to see if this might be an avenue worth exploring.

[1]: I'm sure there's a better way to describe this, but my general understanding is that layout is more expensive when calculations are based on the layout of both an element's ancestors and its (grand)children.

Malvoz commented 6 years ago

@developit

I believe this could be a part of Content Performance Policy, unless Feature Policy is a good place for it?

developit commented 6 years ago

Hi @Malvoz - My hope was that we could find a way to incorporate some of the directives outlined in that proposal into Feature Policy, since we seem to be moving towards consolidating these types of controls into one place. Another example of this consolidation is the prospect of merging <iframe sandbox> into Feature Policy's allow attribute syntax.

Malvoz commented 6 years ago

... my general understanding is that layout is more expensive when calculations are based on the layout of both an element's ancestors and its (grand)children.

Have you had a look at CSS containment?

developit commented 6 years ago

Yup. Issue there is that it only allows controlling these things for one context (so not iframes, etc).