Skip to content

Commit

Permalink
Set Resize Observer's last reported size to -1x-1 initially.
Browse files Browse the repository at this point in the history
It used to be 0x0, but changed per the CSSWG resolution:
w3c/csswg-drafts#3664
Sits behind pref `dom.resize_observer.last_reported_size_invalid`.

Differential Revision: https://phabricator.services.mozilla.com/D155710

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1785305
gecko-commit: 14e81415cae10e0699145eb052b49d369f5ee427
gecko-reviewers: emilio
  • Loading branch information
dshin-moz authored and jgraham committed Sep 22, 2022
1 parent 71b7458 commit 93ab3ee
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 19 deletions.
25 changes: 18 additions & 7 deletions resize-observer/notify.html
Original file line number Diff line number Diff line change
Expand Up @@ -194,27 +194,38 @@

function test6() {
let helper = new ResizeTestHelper(
"test6: inline element does not notify",
"test6: inline element notifies once with 0x0.",
[
{
setup: observer => {
observer.observe(inline);
observer.observe(t1);
t1.style.width = "66px";
inline.style.width = "66px";
},
notify: (entries, observer) => {
assert_equals(entries.length, 1, "inline elements must not trigger notifications");
assert_equals(entries[0].target, t1, "inline elements must not trigger notifications");
assert_equals(entries.length, 1, "observing inline element triggers notification");
assert_equals(entries[0].target, inline, "observing inline element triggers notification");
assert_equals(entries[0].contentRect.width, 0);
assert_equals(entries[0].contentRect.height, 0);
return true; // Delay next step
}
},
{
setup: observer => {
inline.style.width = "66px";
},
notify: (entries, observer) => {
assert_unreached("resizing inline element should not cause resize notifications");
},
timeout: () => {
// expected
}
},
{ // "inline element that becomes block should notify",
setup: observer => {
inline.style.display = "block";
},
notify: (entries, observer) => {
assert_equals(entries[0].target, inline);
assert_equals(entries.length, 1, "inline element becoming a non-zero sized block triggers a notification");
assert_equals(entries[0].target, inline, "inline element becoming a non-zero sized block triggers a notification");
}
}
]);
Expand Down
18 changes: 14 additions & 4 deletions resize-observer/observe.html
Original file line number Diff line number Diff line change
Expand Up @@ -719,16 +719,26 @@

let helper = new ResizeTestHelper(
// See: https://drafts.csswg.org/resize-observer/#intro.
"test16: observations do not fire for non-replaced inline elements",
"test16: observations fire once with 0x0 size for non-replaced inline elements",
[
{
setup: observer => {
observer.observe(t);
},
notify: entries => {
assert_unreached("No observation should fire for non box element")
},
timeout: () => {}
assert_equals(entries.length, 1, "1 pending notification");
assert_equals(entries[0].target, t, "target is t");
assert_equals(entries[0].contentRect.width, 0, "target width");
assert_equals(entries[0].contentRect.height, 0, "target height");
assert_equals(entries[0].contentBoxSize[0].inlineSize, 0,
"target content-box inline size");
assert_equals(entries[0].contentBoxSize[0].blockSize, 0,
"target content-box block size");
assert_equals(entries[0].borderBoxSize[0].inlineSize, 0,
"target border-box inline size");
assert_equals(entries[0].borderBoxSize[0].blockSize, 0,
"target border-box block size");
}
}
]);

Expand Down
16 changes: 8 additions & 8 deletions resize-observer/svg.html
Original file line number Diff line number Diff line change
Expand Up @@ -345,21 +345,21 @@
observer.observe(view);
},
notify: (entries, observer) => {
assert_unreached("no entries should be observed on <view> Element");
},
timeout: () => {
// expected
assert_equals(entries.length, 1);
assert_equals(entries[0].target, view);
assert_equals(entries[0].contentRect.width, 0);
assert_equals(entries[0].contentRect.height, 0);
}
},
{
setup: observer => {
observer.observe(stop);
},
notify: (entries, observer) => {
assert_unreached("no entries should be observed on <stop> Element");
},
timeout: () => {
// expected
assert_equals(entries.length, 1);
assert_equals(entries[0].target, stop);
assert_equals(entries[0].contentRect.width, 0);
assert_equals(entries[0].contentRect.height, 0);
}
},
]);
Expand Down

0 comments on commit 93ab3ee

Please sign in to comment.