[csswg-drafts] [cssom-view] Add "sticky" to the features argument to the window.open() method (#12361)

cathiechen has just created a new issue for https://github.com/w3c/csswg-drafts:

== [cssom-view] Add "sticky" to the features argument to the window.open() method ==
This is a follow-up discussion of [window onmove event issue](https://github.com/w3c/csswg-drafts/issues/7693).
Here, we propose to add a new option("sticky") to window.open's features to make the created window following the movement of the current window. Let's call the new created one as a sticky window.
For instance, we can use
`window.open("./sub-001.html", "_blank", "left=0,top=0,width=200,height=200,sticky");`
to create a sticky window, and it will follow the movement of the current window.

We also propose to add functions to manage the sticky windows:
1. `removeAllStickyWindows()` to let current window remove all the sticky windows.
2. `addStickyFeature()`, to make itself as a sticky window to its opener, if they are not cross-origin.
3. `removeStickyFeature()`, to remove itself from its opener's sticky windows.

The "sticky" feature is only effective if the created window is with opener, and they are not cross-origin.
The connection remains if they navigate inside the same origin.
If either window navigates to a cross-origin page, this connection will be broken.

To implement, the current window's frame keeps a weak reference to the sticky window's frame, let's call it a sticky frame.
When the screen rect of the current window changes, it checks its sticky frame, and uses `moveBy` to move the sticky window. 
If the sticky frame is detached, as the current window's frame only keeps a weak reference, so it won't block the release of the sticky frame. Therefore, we need to check if sticky window is still attached when we try to `moveBy` it.

We do not define the relative position, for we already have `left` and `top`, we don't want to make the situation complex. This feature focuses on following the movement of the windows.

A window could support multi sticky windows.

There are still some corner cases that need to be addressed, such as the cross-displays problem and the cross-virtual displays problem. For more details, please see [the explainer](https://github.com/Igalia/explainers/blob/main/window-sticky-feature/README.md).

@frivoal @emilio 


Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/12361 using your GitHub account


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

Received on Wednesday, 18 June 2025 09:29:22 UTC