Skip to content

Handle media <source> moves around the pointer#12511

Open
zcorpan wants to merge 2 commits into
mainfrom
zcorpan/resource-selection-move
Open

Handle media <source> moves around the pointer#12511
zcorpan wants to merge 2 commits into
mainfrom
zcorpan/resource-selection-move

Conversation

@zcorpan
Copy link
Copy Markdown
Member

@zcorpan zcorpan commented Jun 2, 2026

Also define the logic in terms of two variables instead of nodes before and after pointer.

Fixes #12500

  • At least two implementers are interested (and none opposed):
  • Tests are written and can be reviewed and commented upon at:
  • Implementation bugs are filed:
    • Chromium: …
    • Gecko: …
    • WebKit: …
    • Deno (only for timers, structured clone, base64 utils, channel messaging, module resolution, web workers, and web storage): …
    • Node.js (only for timers, structured clone, base64 utils, channel messaging, and module resolution): …
  • Corresponding HTML AAM & ARIA in HTML issues & PRs:
  • MDN issue is filed: …
  • The top of this comment includes a clear commit message to use.

(See WHATWG Working Mode: Changes for more details.)


/media.html ( diff )

Also define the logic in terms of two variables instead of nodes before and after pointer.

Fixes #12500
@zcorpan
Copy link
Copy Markdown
Member Author

zcorpan commented Jun 3, 2026

@nicolo-ribaudo

Comment thread source
to the remaining nodes.</dd>

<dt>If <var>pointerAfter</var> is <span data-x="concept-node-remove-ext">removed</span> or <span data-x="concept-node-move-ext">moved</span></dt>
<dd>Set <var>pointerAfter</var> to <var>pointerBefore</var>'s next sibling, if
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(also in the previous <dd>)

Is it implicit that if pointerBefore has no next sibling, pointerAfter is set to null?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

If pointerBefore had no next sibling, then pointerAfter would be null and it can't be removed or moved.

However, there might not be any children left after removing or moving the only child, so the <span>media element</span>'s first child should account for that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What I mean is the case where before the tree modification pointerBefore points to the second-to-last element and pointerAfter points to the last element.

When pointerAfter is removed, pointerBefore does not have a next sibling.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see that the definitions of next sibling and previous sibling would cover this, they just need to be xref'ed.

Copy link
Copy Markdown
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

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

This is much better :) It probably needs WPT tests though, when I checked there was no coverage for moving around the <source> elements.

Comment thread source
nodes in their own right. One node is the node before <var>pointer</var>, and the
other node is the node after <var>pointer</var>. Initially, let <var>pointer</var> be the position between the <var>candidate</var> node and the
next node, if there are any, or the end of the list, if it is the last node.</p>
<p>&#x231B; Let <var>pointerBefore</var> and <var>pointerAfter</var> be two variables that
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
<p>&#x231B; Let <var>pointerBefore</var> and <var>pointerAfter</var> be two variables that
<p>&#x231B; Let <var>pointerBefore</var> and <var>pointerAfter</var>

Comment thread source
has a next sibling, then set <var>pointerAfter</var> to that sibling; otherwise, set
<var>pointerAfter</var> to null.</p>

<p>As nodes are <span data-x="concept-node-insert-ext">inserted</span>, <span
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We have test coverage here for arbitrary nodes? Surprised we don't use source element insertion/removal/moving steps.

Copy link
Copy Markdown
Member

@nicolo-ribaudo nicolo-ribaudo Jun 4, 2026

Choose a reason for hiding this comment

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

Surprised we don't use source element insertion/removal/moving steps.

Agree -- (unless @zcorpan gets to it first!), it's in my "hopefully I'll get to open a PR to it" list from #12502.

We already have source element insertion/removal steps, we just need to extend them.

Comment thread source

<li><p>&#x231B; If the node after <var>pointer</var> is a <code>source</code> element,
let <var>candidate</var> be that element.</p></li>
<li><p>&#x231B; If <var>pointerAfter</var> is a <code>source</code> element, let
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

then set candidate to that element*?

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistent cross-browser behavior for mutating child <source>s of a <video>

3 participants