Skip to content

🎥 Make videos programmatically with React

Fix SVG outline polygons in WebKit at non-unit zoom

Jonny Burger306ccf438fd1
diff --git a/packages/sdk/src/get-box-quads-polyfill-internals.js b/packages/sdk/src/get-box-quads-polyfill-internals.js
index 94be7ce6b5..b2b06f9d8b 100644
--- a/packages/sdk/src/get-box-quads-polyfill-internals.js
+++ b/packages/sdk/src/get-box-quads-polyfill-internals.js
@@ -713,11 +713,10 @@ export function getBoxQuads(node, options) {
new DOMPoint(x1, y1),
new DOMPoint(x0, y1),
];
- const screenCtm = !hasTransformedHtmlAncestor(
- node,
- relativeTo,
- options?.iframes,
- )
+ // getScreenCTM returns viewport coordinates, so transforms on relativeTo
+ // and its ancestors matter too. WebKit omits ancestor CSS transforms;
+ // use the transform walk even when the zoom host is above relativeTo.
+ const screenCtm = !hasTransformedHtmlAncestor(node, options?.iframes)
? node.getScreenCTM()
: null;
if (screenCtm) {
@@ -1192,14 +1191,10 @@ function isZeroAngleValue(value) {
return Number.isFinite(angle) && Math.abs(angle) < 1e-10;
}
-function hasTransformedHtmlAncestor(node, relativeTo, iframes) {
+function hasTransformedHtmlAncestor(node, iframes) {
const win = node.ownerDocument.defaultView ?? window;
let element = getParentElementIncludingSlots(node, iframes);
- while (
- element &&
- element !== relativeTo &&
- element !== node.ownerDocument.documentElement
- ) {
+ while (element) {
if (element instanceof win.HTMLElement) {
const css = getCachedComputedStyle(element);
if (
@@ -1210,6 +1205,9 @@ function hasTransformedHtmlAncestor(node, relativeTo, iframes) {
return true;
}
}
+ if (element === node.ownerDocument.documentElement) {
+ break;
+ }
element = getParentElementIncludingSlots(element, iframes);
}
return false;
diff --git a/packages/sdk/src/use-canvas-outline-measurements.ts b/packages/sdk/src/use-canvas-outline-measurements.ts
index b49e811e80..93b2ebf404 100644
--- a/packages/sdk/src/use-canvas-outline-measurements.ts
+++ b/packages/sdk/src/use-canvas-outline-measurements.ts
@@ -103,6 +103,9 @@ export const useCanvasOutlineMeasurements = ({
const ownerWindow = contentRoot.ownerDocument.defaultView;
const onCommit = () => {
+ // Composition mutations and resizes invalidate geometry; commits only
+ // refresh discovered nodes so zoom and pan keep the cache. CSS/SMIL
+ // animation and styles changed outside contentRoot need another trigger.
if (
targets.some(
(target) =>