Skip to content

Commit 40b4548

Browse files
committed
Add syntax that is compatible with fragments'
1 parent cc7e434 commit 40b4548

File tree

1 file changed

+31
-20
lines changed

1 file changed

+31
-20
lines changed

resize-observer-1/Overview.bs

+31-20
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ ResizeObserver's notifications can be used to respond to changes in {{Element}}'
9191
<pre highlight="js">
9292
// In response to resize, elipse paints an elipse inside a canvas
9393
document.querySelector('#elipse').handleResize = entry => {
94-
entry.target.width = entry.borderBoxSize.inlineSize;
95-
entry.target.height = entry.borderBoxSize.blockSize;
94+
entry.target.width = entry.borderBoxSize[0].inlineSize;
95+
entry.target.height = entry.borderBoxSize[0].blockSize;
9696
let rx = Math.floor(entry.target.width / 2);
9797
let ry = Math.floor(entry.target.height / 2);
9898
let ctx = entry.target.getContext('2d');
@@ -103,7 +103,7 @@ ResizeObserver's notifications can be used to respond to changes in {{Element}}'
103103
// In response to resize, change title visibility depending on width
104104
document.querySelector('#menu').handleResize = entry => {
105105
let title = entry.target.querySelector(".title")
106-
if (entry.borderBoxSize.inlineSize < 40)
106+
if (entry.borderBoxSize[0].inlineSize < 40)
107107
title.style.display = "none";
108108
else
109109
title.style.display = "inline-block";
@@ -115,8 +115,8 @@ ResizeObserver's notifications can be used to respond to changes in {{Element}}'
115115
console.log('watching element:', entry.target);
116116
console.log(entry.contentRect.top,' is ', cs.paddingTop);
117117
console.log(entry.contentRect.left,' is ', cs.paddingLeft);
118-
console.log(entry.borderBoxSize.inlineSize,' is ', cs.width);
119-
console.log(entry.borderBoxSize.blockSize,' is ', cs.height);
118+
console.log(entry.borderBoxSize[0].inlineSize,' is ', cs.width);
119+
console.log(entry.borderBoxSize[0].blockSize,' is ', cs.height);
120120
if (entry.target.handleResize)
121121
entry.target.handleResize(entry);
122122
}
@@ -247,9 +247,9 @@ This callback delivers {{ResizeObserver}}'s notifications. It is invoked by a
247247
interface ResizeObserverEntry {
248248
readonly attribute Element target;
249249
readonly attribute DOMRectReadOnly contentRect;
250-
readonly attribute ResizeObserverSize borderBoxSize;
251-
readonly attribute ResizeObserverSize contentBoxSize;
252-
readonly attribute ResizeObserverSize devicePixelContentBoxSize;
250+
readonly attribute sequence&lt;ResizeObserverSize> borderBoxSize;
251+
readonly attribute sequence&lt;ResizeObserverSize> contentBoxSize;
252+
readonly attribute sequence&lt;ResizeObserverSize> devicePixelContentBoxSize;
253253
};
254254
</pre>
255255

@@ -264,15 +264,26 @@ interface ResizeObserverEntry {
264264
{{Element}}'s <a>content rect</a> when {{ResizeObserverCallback}} is invoked.
265265
: <dfn>borderBoxSize</dfn>
266266
::
267-
{{Element}}'s <a>border box</a> size when {{ResizeObserverCallback}} is invoked.
267+
A sequence containing the {{Element}}'s <a>border box</a> size when {{ResizeObserverCallback}} is invoked.
268268
: <dfn>contentBoxSize</dfn>
269269
::
270-
{{Element}}'s <a>content rect</a> size when {{ResizeObserverCallback}} is invoked.
270+
A sequence containing the {{Element}}'s <a>content rect</a> size when {{ResizeObserverCallback}} is invoked.
271271
: <dfn>devicePixelContentBoxSize</dfn>
272272
::
273-
{{Element}}'s <a>content rect</a> size in integral device pixels when {{ResizeObserverCallback}} is invoked.
273+
A sequence containing the {{Element}}'s <a>content rect</a> size in integral device pixels when {{ResizeObserverCallback}} is invoked.
274+
274275
</div>
275276

277+
<p class="note">
278+
The box size properties are exposed as sequences in order to support elements that have multiple fragments,
279+
which occur in <a>multi-column</a> scenarios.
280+
However the current definitions of <a>content rect</a> and <a>border box</a>
281+
do not mention how those boxes are affected by <a>multi-column</a> layout.
282+
In this spec, there will only be a single ResizeObserverSize returned in the sequences,
283+
which will correspond to the dimensions of the first column.
284+
A future version of this spec will extend the returned sequences to contain the per-fragment size information.
285+
</p>
286+
276287
<div dfn-type="method" dfn-for="ResizeObserverEntry">
277288
: <dfn constructor lt="ResizeObserverEntry(target)">new ResizeObserverEntry(target)</dfn>
278289
::
@@ -323,16 +334,16 @@ interface is not visible to Javascript.</p>
323334
interface ResizeObservation {
324335
readonly attribute Element target;
325336
readonly attribute ResizeObserverBoxOptions observedBox;
326-
readonly attribute ResizeObserverSize lastReportedSize;
337+
readonly attribute sequence&lt;ResizeObserverSize> lastReportedSizes;
327338
};
328339
</pre>
329340
<div dfn-type="attribute" dfn-for="ResizeObservation">
330341
: <dfn>target</dfn>
331342
:: The observed {{Element}}.
332343
: <dfn>observedBox</dfn>
333344
:: Which box is being observed.
334-
: <dfn>lastReportedSize</dfn>
335-
:: Last reported size.
345+
: <dfn>lastReportedSizes</dfn>
346+
:: Ordered sequence of last reported sizes.
336347
</div>
337348
<div dfn-type="method" dfn-for="ResizeObservation">
338349
: <dfn constructor lt="ResizeObservation(target, options)">new ResizeObservation(target, observedBox)</dfn>
@@ -343,14 +354,14 @@ interface ResizeObservation {
343354

344355
3. Set |this| internal {{ResizeObservation/observedBox}} slot to |observedBox|
345356

346-
4. Set |this| internal {{ResizeObservation/lastReportedSize}} slot to (0,0)
357+
4. Set |this| internal {{ResizeObservation/lastReportedSizes}} slot to [(0,0)]
347358

348359
: <dfn method lt="isActive()">isActive()</dfn>
349360
::
350361

351362
1. Set |currentSize| by <a>calculate box size</a> given |target| and |observedBox|.
352363

353-
2. Return true if |currentSize| is not equal to this.{{ResizeObservation/lastReportedSize}}.
364+
2. Return true if |currentSize| is not equal to the first entry in this.{{ResizeObservation/lastReportedSizes}}.
354365

355366
3. Return false.
356367

@@ -467,13 +478,13 @@ run these steps:
467478

468479
2. Add |entry| to |entries|.
469480

470-
3. Set |observation|.{{lastReportedSize}} to matching |entry| size.
481+
3. Set |observation|.{{lastReportedSizes}} to matching |entry| sizes.
471482

472-
1. Matching size is |entry|.{{ResizeObserverEntry/borderBoxSize}} if |observation|.{{ResizeObservation/observedBox}} is "border-box"
483+
1. Matching sizes are |entry|.{{ResizeObserverEntry/borderBoxSize}} if |observation|.{{ResizeObservation/observedBox}} is "border-box"
473484

474-
2. Matching size is |entry|.{{ResizeObserverEntry/contentBoxSize}} if |observation|.{{ResizeObservation/observedBox}} is "content-box"
485+
2. Matching sizes are |entry|.{{ResizeObserverEntry/contentBoxSize}} if |observation|.{{ResizeObservation/observedBox}} is "content-box"
475486

476-
3. Matching size is |entry|.{{ResizeObserverEntry/devicePixelContentBoxSize}} if |observation|.{{ResizeObservation/observedBox}} is "device-pixel-content-box"
487+
3. Matching sizes are |entry|.{{ResizeObserverEntry/devicePixelContentBoxSize}} if |observation|.{{ResizeObservation/observedBox}} is "device-pixel-content-box"
477488

478489
4. Set |targetDepth| to the result of <a>calculate depth for node</a> for |observation|.{{ResizeObservation/target}}.
479490

0 commit comments

Comments
 (0)