Skip to content

Commit f42dc0c

Browse files
miguel-heygenclaude
andcommitted
fix(engine): keep offsetLeft/offsetTop for position, only use getBoundingClientRect for size
Reverts the position change from 617f861 that broke style-7/8/10-prod baselines. The getBoundingClientRect-based relative positioning (videoRect.left - parentRect.left) doesn't match offsetLeft in nested compositions with transforms, borders, or padding on ancestors. Fix: use getBoundingClientRect only for width/height (fixes #1009 bottom gap), keep offsetLeft/offsetTop for position (correct for nested comps). Restores the 3 original baselines that were incorrectly regenerated. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent fa8cbf7 commit f42dc0c

7 files changed

Lines changed: 651 additions & 1387 deletions

File tree

packages/engine/src/services/screenshotService.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -436,24 +436,20 @@ export async function injectVideoFramesBatch(
436436
// stack vertically — the <img> lands below the video and gets clipped
437437
// by any overflow:hidden ancestor (e.g., border-radius wrappers).
438438
//
439-
// Use getBoundingClientRect for replacement geometry — it reflects the
440-
// CSS layout box reliably across platforms. offset* properties can
441-
// report stale or compositor-dependent values on macOS Chrome when the
442-
// browser pool shares one process across workers, causing the <img> to
443-
// be sized smaller than the CSS box (bottom-gap regression #1009).
439+
// Size: getBoundingClientRect reflects the CSS layout box reliably.
440+
// offset* can report stale values on macOS Chrome with pooled browsers
441+
// (bottom-gap regression #1009).
442+
// Position: keep offsetLeft/offsetTop — they give the correct position
443+
// relative to offsetParent in nested compositions where
444+
// getBoundingClientRect-based math breaks due to transforms/borders.
444445
{
445446
const videoRect = video.getBoundingClientRect();
446-
const parentRect = video.offsetParent
447-
? video.offsetParent.getBoundingClientRect()
448-
: { left: 0, top: 0 };
449-
const relLeft = Math.round(videoRect.left - parentRect.left);
450-
const relTop = Math.round(videoRect.top - parentRect.top);
451-
const w = Math.round(videoRect.width);
452-
const h = Math.round(videoRect.height);
447+
const w = Math.round(videoRect.width) || video.offsetWidth;
448+
const h = Math.round(videoRect.height) || video.offsetHeight;
453449
img.style.position = "absolute";
454450
img.style.inset = "auto";
455-
img.style.left = `${relLeft}px`;
456-
img.style.top = `${relTop}px`;
451+
img.style.left = `${video.offsetLeft}px`;
452+
img.style.top = `${video.offsetTop}px`;
457453
img.style.right = "auto";
458454
img.style.bottom = "auto";
459455
img.style.width = `${w}px`;

packages/producer/tests/style-10-prod/output/compiled.html

Lines changed: 633 additions & 1365 deletions
Large diffs are not rendered by default.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:d25147399c18dcabba31b7ac79094a954f1d9fc8c8899aa769f2c28a70fd3caa
3-
size 11406696
2+
oid sha256:f09f5074edd21e2431171bfc7c7e9ed1ca6e5104a347721ac13ecadb625fe10a
3+
size 4884784

packages/producer/tests/style-7-prod/output/compiled.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@
198198
font-style: normal;
199199
font-weight: 800;
200200
font-display: block;
201-
}</style><style data-hyperframes-text-rendering="true">html,body,*{text-rendering:geometricPrecision}</style>
201+
}</style>
202202
<meta charset="UTF-8">
203203
<meta name="viewport" content="width=device-width, initial-scale=1.0">
204204
<title>Editor Agent - Velvet Standard</title>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:b1e2ce13f6479ee7db821bb5e10c1de32e6749a23bf0df6690a34e93c2f598ab
3-
size 5530424
2+
oid sha256:3f65d173a65ebf2702818121b58d57b405c96762916c75a90e58b9b058bab7cc
3+
size 12305451

packages/producer/tests/style-8-prod/output/compiled.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@
262262
font-style: normal;
263263
font-weight: 900;
264264
font-display: block;
265-
}</style><style data-hyperframes-text-rendering="true">html,body,*{text-rendering:geometricPrecision}</style>
265+
}</style>
266266
<meta charset="UTF-8">
267267
<meta name="viewport" content="width=device-width, initial-scale=1.0">
268268
<title>Editor Agent - Henryk Tomaszewski Style</title>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:3274cddfb6d8c42b3d18675261d1e90ac37b483ac237ee4c28437be6468b94c1
3-
size 13138233
2+
oid sha256:a005acdf38870cea1e4bb2e870bbd662ebb26dba60539481cda77a4cb719f42e
3+
size 14507933

0 commit comments

Comments
 (0)