Re: [csswg-drafts] [cssom-view] No event to track window position (#7693)

I spent some time looking in to this lately, particularly the observer/event question.

The TAG design principles do include [guidance on this specific issue](https://www.w3.org/TR/design-principles/#events-vs-observers) (and there was an earlier [discussion thread](https://github.com/w3ctag/design-principles/issues/78)):

> In general, use [EventTarget](https://dom.spec.whatwg.org/#eventtarget) and notification [Event](https://dom.spec.whatwg.org/#event)s, rather than an Observer pattern, unless an [EventTarget](https://dom.spec.whatwg.org/#eventtarget) can’t work well for your feature.
>
> ...
>
> If using events causes problems, such as unavoidable [recursion](https://www.w3.org/TR/design-principles/#guard-against-recursion), consider using an Observer pattern instead.

This seems to me to indicate that an event is probably what we want here. I'm not sure what we'd gain from having this be an Observer instead.

I see that in Blink, `resize` fires at most once per animation frame, and that seems like a good design particularly for this use case, since the point is to have a secondary window "follow" the main window around.

I'm not sure exactly where this discussion landed on iframes - would iframes not have window.move events fired at all, or would they fire when the top window moves?

I'm planning to start writing some tentative WPT tests to cover my [exploratory implementation](https://chromium-review.googlesource.com/c/chromium/src/+/4279461); should I also have a go at writing some spec language, or would someone else like to take that?

-- 
GitHub Notification of comment by alice
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7693#issuecomment-1687402322 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 22 August 2023 04:33:42 UTC