1- ## ` updateRendering() `
1+ ## ` renderPriority ` attribute.
2+
3+ _ Note that issues referenced in this document can refer to either the
4+ ` renderPriority ` attribute or ` updateRendering() ` JavaScript API. The issues
5+ discussed apply to both._
26
37### TL;DR
4- updateRendering() is an asynchronous JavaScript function on Element which
5- requests that the rendering for the element be updated in preparation for
6- display.
8+ The ` renderPriority ` attribute is an HTML attribute that informs the User
9+ Agent to keep the element's rendering state updated with a specified priority.
10+
11+ (Note that the ` renderPriority ` name is a
12+ [ placeholder name] ( https://github.com/WICG/display-locking/issues/200 ) )
713
814### Motivation
915The web includes a number of features and heuristics (such as
10- content-visibility, containment and others) that allow the user-agent to skip
16+ content-visibility, containment and others) that allow the User Agent to skip
1117rendering work for elements and contents of elements. This is done with the
1218intent to allow other content, animations and interactions to remain smooth and
1319get as much CPU time as possible. However, there are situations where this
@@ -16,38 +22,71 @@ words, if the website intends to show an element whose contents are currently
1622skipped, then skipping work may cause jank when the contents are ultimately
1723presented.
1824
19- ### Proposal
20- The proposal is to add the following function, which lets the user-agent know
21- that the element’s contents should be updated in preparation for display:
22-
23- Signature: ` Promise Element.updateRendering(Priority?) `
25+ ### Proposal: ` renderPriority ` element attribute
26+ When present, this attribute informs the User Agent that it should keep the
27+ element and its subtree updated according to the specified priority. The timing
28+ and frequency of updates are kept in the User Agent's control to allow
29+ flexibility in prioritizing this work.
2430
25- The function takes a Priority as an argument, with the following proposed values,
26- following [ the postTask API] ( https://wicg.github.io/scheduling-apis/#sec-task-priorities )
27- example.
28-
29- * ` user-blocking ` is the highest priority, and is meant to be used for updates
31+ The values that the attribute takes inform the User Agent of developer intent:
32+ * ` userBlocking ` is the highest priority, and is meant to be used for updates
3033 that are blocking the user’s ability to interact with the page, such as
3134 rendering the core experience or responding to user input.
3235
33- * ` user-visible ` is the second highest priority, and is meant to be used for
36+ * ` userVisible ` is the second highest priority, and is meant to be used for
3437 updates that visible to the user but not necessarily blocking user actions,
3538 such as rendering secondary parts of the page. This is the default priority.
3639
37- * ` background ` is the lowest priority, and is meant to be used for updates that
38- are not time-critical, such as background updates for speculative layout.
40+ * ` background ` is the lowest priority which permits updates, and is meant to be
41+ used for updates that are not time-critical, such as background updates for
42+ speculative layout.
43+
44+ * ` never ` is the value that skips rendering updates. Note that this value only
45+ has an effect if the rendering of the page would already have been skipped --
46+ See Notes and Clarification below.
47+
48+ * ` auto ` is the default priority, which allows the User Agent select an
49+ approriate priotization for rendering work.
50+
51+ Note that the attribute values follow [ the postTask API] ( https://wicg.github.io/scheduling-apis/#sec-task-priorities )
52+ example.
53+
54+
55+ ### Interaction with ` content-visibility `
56+ Since the User Agent typically keeps rendering state of subtrees up-to-date,
57+ this feature would be a no-op in a majority of cases. For instance, having
58+ ` renderPriority ` on a visible, on screen, element would not have to do any
59+ work since the rendering state of such an element is already kept up to date.
60+ (Note that it is an [ open question] ( https://github.com/WICG/display-locking/issues/202 )
61+ whether the behavior of visible elements with ` renderPriority ` should cause
62+ asynchronous updates)
3963
40- The function returns a promise which resolves when the contents of the element
41- are ready to be displayed to screen. Note that repeated calls to
42- updateRendering() returns new promises, with the ultimate priority of the
43- request being the highest requested priority.
64+ We're proposing this feature as an enhancement for the ` content-visibility ` CSS
65+ property. For example, when ` content-visibity: hidden ` property is applied to
66+ the element, it ensures that the element's subtree is not visible and that its
67+ rendering state is not updated to save CPU time. Adding ` renderPriority ` on
68+ such an element, however, would cause the User Agent to continually process its
69+ rendering with a given priority.
4470
45- ### Notes
46- If the User Agent does not optimize rendering of elements, then the
47- function can return a resolved promise for every call. Note that a successful
48- resolution of the promise does not provide strong guarantees of performance:
49- bringing the element on screen may partially or fully invalidate the work that
50- has been prepared. The User Agent should prepare the element and its contents
51- as much as it deems is necessary for presentation
71+ ### Notes and Clarifications
72+ * If the User Agent does not optimize rendering of elements, by skipping work,
73+ then the attribute has no effect.
5274
75+ * Setting the attribute on an element whose rendering state is not updated due
76+ to ` display: none ` , ancestor style that prevents update (e.g. ancestor
77+ ` content-visibility: hidden ` ), or similar styles has no effect. In other
78+ words, this attribute would not force rendering state to be updated on
79+ elements whose rendering work is required to be skipped. ([ more
80+ details] ( https://github.com/WICG/display-locking/issues/199 ) ). Note that this
81+ does _ not_ include elements that themselves have ` content-visibility: hidden `
82+ style, since their rendering is updated and the attribute would cause the
83+ subtree to be udpated as well.
5384
85+ * Setting the attribute on an element that contains descendants with
86+ ` content-visibility: hidden ` , ` display: none ` , or similar styles would not
87+ cause the contents of such elements to be updated. This is a consequence of
88+ the fact that a fully updated parent element has all its rendering work
89+ completed without updating such descendants. ([ more details] ( https://github.com/WICG/display-locking/issues/196 ) ).
90+ If such an update is desired, a ` renderPriority ` attribute should be set on
91+ such elements. Note that recursive ` renderPriority ` settings may be considered
92+ in the future.
0 commit comments