@@ -139,7 +139,7 @@ It is modeled after {{MutationObserver}} and {{IntersectionObserver}}.
139139
140140<pre class="idl">
141141 enum ResizeObserverBoxOptions {
142- "border-box", "content-box", "scroll-box"
142+ "border-box", "content-box", "scroll-box", "device-pixel-border-box"
143143 };
144144</pre>
145145
@@ -148,6 +148,12 @@ ResizeObserver can observe different kinds of CSS sizes:
148148* {{border-box}} : size of <a>box border area</a> as defined in CSS2.
149149* {{content-box}} : size of <a>content area</a> as defined in CSS2.
150150* {{scroll-box}} : the <a>scrollport</a> of the <a>scroll container</a> .
151+ * {{device-pixel-border-box}} : border-box size in device pixels.
152+
153+ {{device-pixel-border-box}} is slightly different from other sizes.
154+ It can only be observed for {{HTMLCanvasElement}} .
155+ It can change even when css has only changed location due to rounding,
156+ because device-pixel sizes are never fractional.
151157
152158<pre class="idl">
153159 dictionary ResizeObserverOptions {
@@ -162,10 +168,10 @@ In this case, author will need to use multiple ResizeObservers.
162168
163169<pre highlight="js">
164170 // Observe the content-box
165- ro.observe(document.querySelector('#menu' ));
171+ ro.observe(document.querySelector('#menu' ), { box: 'content-box' } );
166172
167173 // Observe just the border box. Replaces previous observation.
168- ro.observe(document.querySelector('#menu' ), 'border-box' );
174+ ro.observe(document.querySelector('#menu' ), { box: 'border-box' } );
169175</pre>
170176
171177<p class="note"> This does not have any impact on which box dimensions are returned to the defined callback when the event is fired,
@@ -196,11 +202,21 @@ interface ResizeObserver {
196202 ::
197203 Adds target to the list of observed elements.
198204
199- 1. If |target| is in {{ResizeObserver/observationTargets}} slot, call unobserve(<var> target</var> ).
205+ 1. If |options|.box is "device-pixel-border-box" and |target|'s interface is not
206+ {{HTMLCanvasElement}} then raise an error.
207+
208+ 1. Create new {{ErrorEvent}} |error|, with message
209+ "Only <canvas> elements can observe 'device-pixel-border-box' ."
210+
211+ 2. Report an exception |error|.
200212
201- 2. Let |resizeObservation| be new {{ResizeObservation}} ( <var> target </var> , <var> options </var> ) .
213+ 3. Return .
202214
203- 3. Add the |resizeObservation| to the <var> observationTargets</var> slot.
215+ 2. If |target| is in {{ResizeObserver/observationTargets}} slot, call unobserve(<var> target</var> ).
216+
217+ 3. Let |resizeObservation| be new {{ResizeObservation}} (<var> target</var> , <var> options</var> ).
218+
219+ 4. Add the |resizeObservation| to the <var> observationTargets</var> slot.
204220
205221 : <dfn method for="ResizeObserver">unobserve(target)</dfn>
206222 ::
@@ -218,6 +234,8 @@ interface ResizeObserver {
218234
219235 2. Clear the {{ResizeObserver/activeTargets}} list.
220236
237+ 3. Remove |this| from {{Document}} .<var> resizeObservers</var> slot.
238+
221239</div>
222240
223241<h3 id="resize-observer-callback">ResizeObserverCallback</h3>
@@ -239,11 +257,12 @@ interface ResizeObserverEntry {
239257 readonly attribute ResizeObserverSize borderBoxSize;
240258 readonly attribute ResizeObserverSize contentSize;
241259 readonly attribute ResizeObserverSize scrollSize;
260+ readonly attribute ResizeObserverSize devicePixelBorderBoxSize;
242261};
243262</pre>
244263
245- <p class="issue"> Do we only want to return the box(es) that were requested to be observed, or all?</p>
246- <p class="issue"> Do we want to add a note explaining that contentRect is for compatibility reasons, and might be depreciated?</p>
264+ <p class="issue"> Do we only want to return the box(es) that were requested to be observed, or all? Leaning: all </p>
265+ <p class="issue"> Do we want to add a note explaining that contentRect is for compatibility reasons, and might be depreciated? Leaning: yes </p>
247266
248267<div dfn-type="attribute" dfn-for="ResizeObserverEntry">
249268 : <dfn>target</dfn>
@@ -261,6 +280,9 @@ interface ResizeObserverEntry {
261280 : <dfn>scrollSize</dfn>
262281 ::
263282 {{Element}} 's <a>scrollport</a> when {{ResizeObserverCallback}} is invoked.
283+ : <dfn>devicePixelBorderBoxSize</dfn>
284+ ::
285+ {{Element}} 's <a>border box</a> size in device pixels when {{ResizeObserverCallback}} is invoked.
264286</div>
265287
266288<div dfn-type="method" dfn-for="ResizeObserverEntry">
@@ -279,15 +301,18 @@ interface ResizeObserverEntry {
279301 5. Set |this|.{{ResizeObserverEntry/scrollSize}} slot to result of <a href="#calculate-box-size">
280302 computing size given |target| and specificSize of "scroll-box"</a> .
281303
282- 6. Set |this|.{{ResizeObserverEntry/contentRect}} to logical |this|.{{ResizeObserverEntry/contentSize}} .
304+ 6. Set |this|.{{ResizeObserverEntry/devicePixelBorderBox}} slot to result of <a href="#calculate-box-size">
305+ computing size given |target| and specificSize of "device-pixel-border-box"</a> .
283306
284- 7. If |target| is not an SVG element do these steps:
307+ 7. Set |this|.{{ResizeObserverEntry/contentRect}} to logical |this|.{{ResizeObserverEntry/contentSize}} .
308+
309+ 8. If |target| is not an SVG element do these steps:
285310
286311 1. Set |this|.|contentRect|.top to |target|.<a>padding top</a> .
287312
288313 2. Set |this|.|contentRect|.left to |target|.<a>padding left</a> .
289314
290- 8 . If |target| is an SVG element do these steps:
315+ 9 . If |target| is an SVG element do these steps:
291316
292317 1. Set |this|.|contentRect|.top and |this|.contentRect.left to 0.
293318
@@ -302,9 +327,12 @@ interface ResizeObserverEntry {
302327
303328<p class="issue"> We're covering the dimensions of the extra boxes, do we want to also cover their positions similiar to that of the initial contentRect?</p>
304329
305- <h3 id="resize-observation-interface">ResizeObservation</h3>
306- ResizeObservation holds observation information for a single {{Element}} . This
307- interface is not visible to Javascript.
330+ <h2 id="processing-model">Processing Model</h2>
331+
332+ <h3 id="resize-observation-interface">ResizeObservation example struct</h3>
333+ <p class="note"> This section is not normative. ResizeObservation is an example struct that can be used in implementation of Resize Observer. It is being
334+ included here in order to help provide clarity during the processing model. It effectively holds observation information for a single {{Element}} . This
335+ interface is not visible to Javascript.</p>
308336
309337<pre class="idl">
310338[Constructor(Element target)
@@ -344,40 +372,8 @@ interface ResizeObservation {
344372
345373 3. Return false.
346374
347- : <dfn method lt="computeSize(size)">computeSize(size)</dfn>
348- ::
349- 1. If |target| is not an SVG element
350-
351- 1. If |size| is "bounding-box"
352-
353- 1. Set |computedSize|.inlineSize to target's border-box inline size.
354-
355- 2. Set |computedSize|.blockSize to target's border-box block size.
356-
357- 2. If |size| is "content-box"
358-
359- 1. Set |computedSize|.inlineSize to target's content-box inline size.
360-
361- 2. Set |computedSize|.blockSize to target's content-box block size.
362-
363- 3. If |size| is "scoll-box"
364-
365- 1. Set |computedSize|.inlineSize to target's scrollport inline size.
366-
367- 2. Set |computedSize|.blockSize to target's scrollport block size.
368-
369- 2. If |target| is an SVG element
370-
371- 1. Set |computedSize|.inlineSize to target's bounding box inline size.
372-
373- 2. Set |computedSize|.blockSize to target's bounding box block size.
374-
375- 3. return |computedSize|
376-
377375</div>
378376
379- <h2 id="processing-model">Processing Model</h2>
380-
381377<h3 id="internal-slot-definitions">Internal Slot Definitions</h3>
382378
383379<h4 id="document-slots">Document</h4>
@@ -497,6 +493,9 @@ run these steps:
497493
498494 3. Matching size is |entry|.{{ResizeObserverEntry/scrollSize}} if |observation|.{{ResizeObservation/observedBox}} is "scroll-box"
499495
496+ 4. Matching size is |entry|.{{ResizeObserverEntry/devicePixelBorderBoxSize}}
497+ if |observation|.{ResizeObservation/observedBox}} is "device-pixel-border-box"
498+
500499 4. Set |targetDepth| to the result of <a>calculate depth for node</a> for |observation|.{{ResizeObservation/target}} .
501500
502501 5. Set |shallowestTargetDepth| to |targetDepth| if |targetDepth| < |shallowestTargetDepth|
@@ -513,9 +512,9 @@ To <dfn>deliver resize loop error notification</dfn> run these steps:
513512
514513 1. Create a new {{ErrorEvent}} .
515514
516- 2. Initialize event's message slot to "ResizeObserver loop completed with undelivered notifications.".
515+ 2. Initialize | event| 's message slot to "ResizeObserver loop completed with undelivered notifications.".
517516
518- 3. Dispach the event to document's window .
517+ 3. Report the exception |event| .
519518
520519<h4 id="calculate-depth-for-node-h">Calculate depth for node</h4>
521520
@@ -629,4 +628,4 @@ For each fully active Document in docs, run the following steps for that Documen
629628
6306296. If {{Document}} <a>has skipped observations</a> then <a>deliver resize loop error notification</a>
631630
632- 7. Update the rendering or user interface of {{Document}} and its browsing context to reflect the current state.
631+ 7. Update the rendering or user interface of {{Document}} and its browsing context to reflect the current state.
0 commit comments