mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-16 13:03:31 +08:00
Constraint: Keep preview zoom native through WebContentsView.setZoomFactor so screenshot and selection coordinates stay aligned. Tested: cd desktop && bun run test -- src/components/browser/BrowserSurface.test.tsx src/components/browser/computeWebviewBounds.test.ts Tested: cd desktop && bun test electron/services/preview.test.ts Tested: cd desktop && bun run lint Tested: cd desktop && bun run check:electron Tested: cd desktop && bun run build Not-tested: Windows 225% display-scaling smoke; no Windows host is available in this worktree. Confidence: medium Scope-risk: moderate
11 lines
323 B
TypeScript
11 lines
323 B
TypeScript
export type WebviewBounds = { x: number; y: number; width: number; height: number }
|
|
|
|
export function computeWebviewBounds(rect: Pick<DOMRect, 'left' | 'top' | 'width' | 'height'>): WebviewBounds {
|
|
return {
|
|
x: rect.left,
|
|
y: rect.top,
|
|
width: Math.max(0, rect.width),
|
|
height: Math.max(0, rect.height),
|
|
}
|
|
}
|