fix(engine): layer a timed HDR overlay that has no id above the video

This commit is contained in:
Miguel Angel Simon Sierra
2026-10-28 04:35:09 -04:00
parent 1fda6a4507
commit 21660e1f2c
2 changed files with 19 additions and 5 deletions
@@ -95,4 +95,19 @@ describe.skipIf(!hasBrowser)("HDR stacking of content inside an HDR element's ho
ids.filter((id) => id !== "host"),
);
});
it("puts a timed overlay without an id in a layer above the HDR video", async () => {
await page.setContent(PAGE.replace('<div id="title"', '<div class="label" data-start="0"'));
const stacking = await queryElementStacking(page, new Set(["hdr"]));
const unitId = await page.$eval(
".label",
(el, attr) => el.getAttribute(attr),
HDR_LAYER_UNIT_ATTR,
);
expect(unitId).toBeTruthy();
expect(groupIntoLayers(stacking).map((l) => (l.type === "hdr" ? "hdr" : l.elementIds))).toEqual(
[["host"], "hdr", [unitId]],
);
});
});
@@ -846,16 +846,18 @@ export async function queryElementStacking(
}
const hdrElements: Element[] = [];
const described = new Set<Element>();
for (const el of elements) {
// Report the render id so callers can match these back to the media list.
// `||`, not `??`: `__hfMediaId` yields "" for an element with neither id.
const id = window.__hfMediaId?.(el) || el.id;
if (!id) continue;
results.push(describe(el, id));
described.add(el);
if (hdrSet.has(id)) hdrElements.push(el);
}
// Untimed content that paints above an HDR element (a later sibling of it or of an
// Content without its own entry that paints above an HDR element (a later sibling of it or of an
// ancestor, or one with a higher z-index) is its own layer, so the HDR blit stays under it.
const lastHdrBelow = new Map<Element, Element>();
for (const hdrEl of hdrElements) {
@@ -871,10 +873,7 @@ export async function queryElementStacking(
afterNode = true;
continue;
}
if (
sibling.hasAttribute("data-start") ||
sibling.matches("script,style,template,link,meta")
)
if (described.has(sibling) || sibling.matches("script,style,template,link,meta"))
continue;
if (sibling.id.startsWith(prefix) || sibling.id.startsWith(canvasPrefix)) continue;
const siblingZ = getEffectiveZIndex(sibling);