Tear-off widgets

Three ordinary widgets. Pull one out of the page into a new window, an always-on-top window, another tab or another origin. It keeps working there, and what you do to it is sent back and applied to the element on this page. Drag a grip outside this window, onto the dock tab, or pick a route from the menu.

The routes

There are only two ways for a piece of a page to appear in another window, and this page does both.

Show the code tearing a widget off

Each widget is ordinary markup inside a <live-region>. w.surface is that region's surface, w.content the widget's root element and win the window just opened.

  1. Load the pieces.
  2. Stream to a popup (same or another origin): post it a MessagePort and serve the surface on the other end.
  3. The window it opens. A <live-view> and a few ways to get connected. It holds no DOM from this page.
  4. Or move the real element. append() into the other window's document adopts the node. No canvas involved.
  5. Or float it as a video. The surface is a MediaStream, so classic Picture-in-Picture works.
  6. Or share it with a tab that has no link to this one, through a relay room and then WebRTC.
  7. Inside <live-region>: a shadow root with a drawable canvas and a slot. Your markup is slotted into the canvas, so it can be drawn without being moved.
  8. Inside: on every paint event, draw the element.
  9. Inside: copy the pixels to a second canvas, and black out private fields. That second canvas is the only thing that ever leaves the page.
  10. Inside: hand the copy out as an ImageBitmap or a MediaStream.
  11. Inside: replay the input that comes back on the real elements.
  12. The whole library.

What reaches another window (live)

These run in your browser now, using frames as stand-ins for the other window where a real popup would need a click.

ResultExperimentDetail

One experiment isn't run automatically because it can take the tab down:

Findings