Skip to content

Track Responsive-Design carousel resize events - #579

Open
issackjohn wants to merge 1 commit into
WebKit:mainfrom
issackjohn:track-carousel-resize-events
Open

Track Responsive-Design carousel resize events#579
issackjohn wants to merge 1 commit into
WebKit:mainfrom
issackjohn:track-carousel-resize-events

Conversation

@issackjohn

Copy link
Copy Markdown
Contributor

Follow-up to the review feedback on #453, which asked to track the number of resize events so we can verify consistency across browsers.

  • Add PageElement.observeResizeEvents() to count distinct content-box width changes delivered by ResizeObserver. The first delivery seeds the baseline and is not counted, and repeated deliveries of the same width are ignored.
  • Observe the recipe carousel during ReduceWidthIn5Steps and IncreaseWidthIn5Steps, and log the observed count so the numbers can be compared across browsers.
  • Add unittests covering baseline seeding, distinct width changes, and duplicate-width deliveries.

@netlify

netlify Bot commented Jul 24, 2026

Copy link
Copy Markdown

Deploy Preview for webkit-speedometer-preview ready!

Name Link
🔨 Latest commit 6e98693
🔍 Latest deploy log https://app.netlify.com/projects/webkit-speedometer-preview/deploys/6a63f7686dd9220008a05d6b
😎 Deploy Preview https://deploy-preview-579--webkit-speedometer-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Follow-up to the review feedback on WebKit#453, which asked to track the number
of resize events so we can verify consistency across browsers.

- Add PageElement.observeResizeEvents() to count distinct content-box width
  changes delivered by ResizeObserver. The first delivery seeds the baseline
  and is not counted, and repeated deliveries of the same width are ignored.
- Observe the recipe carousel during ReduceWidthIn5Steps and
  IncreaseWidthIn5Steps, and log the observed count so the numbers can be
  compared across browsers.
- Add unittests covering baseline seeding, distinct width changes, and
  duplicate-width deliveries.
@issackjohn
issackjohn force-pushed the track-carousel-resize-events branch from 226cbbf to 6e98693 Compare July 24, 2026 23:38
@issackjohn
issackjohn requested a review from camillobruni August 4, 2026 06:17
@issackjohn

Copy link
Copy Markdown
Contributor Author

@camillobruni PTAL :)

// Resolves on the first delivery so callers can seed a baseline before resizing.
const ready = new Promise((resolve) => {
markReady = resolve;
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a specific use-case you had in mind for detaching observer setup and sarting it?

I think we could just either:

  • always await this promise here
  • just not await it and assume we that we migth be off by 1? (e.g. just don't count it) and we have to make sure that at the time we stop, we have handlede all events.

const contentBoxSize = entry.contentBoxSize;
const inlineSize = Array.isArray(contentBoxSize) ? contentBoxSize[0]?.inlineSize : contentBoxSize?.inlineSize;
const width = inlineSize ?? entry.contentRect.width;
// The first delivery seeds the baseline width without counting it as a change.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I was a bit confused about "delivery" :) I "callback" might be more common?

},
disconnect() {
observer.disconnect();
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to have a single stop() api here that disconnects and returns the count?
I don't tihnk we would want to manually interact with the underlaying observer in any other way.

if (count)
console.warn(`IncreaseWidthIn5Steps: recipe-carousel ResizeObserver delivered ${count} coalesced width change(s).`);
else
console.warn("IncreaseWidthIn5Steps: recipe-carousel ResizeObserver delivered 0 width changes; expected width changes during iframe resize.");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe add a helper to print this message?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants