Skip to content
Permalink
Browse files
Make ResizeObserver and IntersectionObserver timing match other browsers
https://bugs.webkit.org/show_bug.cgi?id=245946

Reviewed by Simon Fraser.

Run IntersectionObservers after ResizeObservers to match Blink and Gecko.

Imported the test from web-platform-tests/wpt#36216

* LayoutTests/imported/w3c/web-platform-tests/resize-observer/ordering-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/resize-observer/ordering.html: Added.
* Source/WebCore/page/Page.cpp:
(WebCore::Page::updateRendering):

Canonical link: https://commits.webkit.org/255132@main
  • Loading branch information
rniwa committed Oct 4, 2022
1 parent e289f6f commit 565a28303653d49dcb47855db613dcdbcf9519be
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
@@ -0,0 +1,3 @@

PASS ResizeObserver and IntersectionObserver ordering

@@ -0,0 +1,25 @@
<!doctype html>
<title>ResizeObserver and IntersectionObserver ordering</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(function(t) {
let sawResize = false;
let sawIo = false;
let resizeObserver = new ResizeObserver(t.step_func(function() {
assert_false(sawIo, "ResizeObserver notification should be delivered before IntersectionObserver notification");
sawResize = true;
resizeObserver.disconnect();
}));

let io = new IntersectionObserver(t.step_func_done(function() {
assert_true(sawResize, "IntersectionObserver notification should be delivered after ResizeObserver notification");
sawIo = true;
io.disconnect();
}));

resizeObserver.observe(document.documentElement);
io.observe(document.documentElement);
});
</script>

@@ -1688,14 +1688,14 @@ void Page::updateRendering()

layoutIfNeeded();

runProcessingStep(RenderingUpdateStep::IntersectionObservations, [] (Document& document) {
document.updateIntersectionObservations();
});

runProcessingStep(RenderingUpdateStep::ResizeObservations, [&] (Document& document) {
document.updateResizeObservations(*this);
});

runProcessingStep(RenderingUpdateStep::IntersectionObservations, [] (Document& document) {
document.updateIntersectionObservations();
});

runProcessingStep(RenderingUpdateStep::Images, [] (Document& document) {
for (auto& image : document.cachedResourceLoader().allCachedSVGImages()) {
if (auto* page = image->internalPage())

0 comments on commit 565a283

Please sign in to comment.