返回 DeepSeek-Reasonix
layout.ts
根目录 / desktop / electron / src / main / browser / layout.ts
1 import type { BrowserLayoutRect } from "../../shared/ipc.js";
2
3 // DOM geometry is in CSS pixels; native View bounds are in device-independent
4 // pixels. Display scale (devicePixelRatio) must not be applied a second time.
5 export function browserLayoutInDIP(rect: BrowserLayoutRect | null, zoom: number): BrowserLayoutRect | null {
6 if (rect === null) return null;
7 if (!Number.isFinite(zoom) || zoom <= 0) throw new Error("invalid renderer zoom factor");
8 return { x: rect.x * zoom, y: rect.y * zoom, width: rect.width * zoom, height: rect.height * zoom };
9 }
10
10 lines TYPESCRIPT