fix(geometry): preserve OOPIF scale with occupied scrollbars - #206
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
OOPIF(跨进程 iframe)的 owner content quad 包含滚动条占用的空间,而
cssLayoutViewport不包含。原实现将可见视口映射到整个内容框,额外放大了坐标和尺寸,导致观察框及元素操作的顶层坐标偏移。例如完整宽度为 200px、可见宽度为 185px 时,会额外引入200 / 185的横向缩放。修复与范围
window.innerWidth / innerHeight确定完整视口与 owner content quad 的投影比例。生产改动仅涉及
GeometryContext和resolveNodeGeometry所在的两个文件。DOMSnapshot 单位归一化、截图 CSS → DIP 转换、公共协议和依赖保持不变。本提交其余 12 个文件为回归 fixture、断言、现有 mock 适配及说明。运行成本: 每次测量每个涉及投影的 OOPIF target 最多新增一次
Runtime.evaluate。结果在单次测量内按 target 缓存,沿用现有并发限制,不跨操作复用。顶层和同进程 frame 不增加该读取。本 PR 不宣称整体观察耗时降低。回归验证
新增
evals/browser的oopif-scrollbars场景,复用已有浏览器测试入口,覆盖双层 OOPIF、页面滚动、border/padding、CSS transform、横向/纵向/双向/无占位滚动条,以及部分可见和完全不可见的控件。数值断言以独立 DOM 矩形及裁剪计算为基准,检查 snapshot 与实时几何,误差须小于 2 CSS px;通过真实鼠标事件确认目标 frame 内的按钮收到点击,并检查测量复用。
本地验证结果:
896c794:7 失败、6 通过;修复后:13/13 通过浏览器测试保留五组设备缩放 / 浏览器缩放组合:
1/1、0.8/1、1/1.25、2/1、2/0.8。复跑
需要 Node 22+ 和本地 Chrome:
BSK_GEOMETRY_CHROME=/path/to/chrome pnpm --filter @browser-skill/extension exec vitest run \ src/tools/__tests__/snapshot-coordinates.browser.test.ts测试自行创建并清理隔离浏览器。未设置
BSK_GEOMETRY_CHROME时,常规单元测试及默认 CI 会跳过真实浏览器测试。CLI fixture smoke(需连接测试扩展):
Smoke 验证嵌套 frame 的滚动条确实占位、观察到标记以及会话关闭;它不替代上述数值几何及实际点击断言。