Repository navigation
fix: make webContents.centerSelection() work on Windows and Linux - #55950
Conversation
…5909) * fix: make webContents.centerSelection() work on Windows and Linux Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KX1hkNiiBq2fQEsXWusxpm * test: wait for the centred position in the centerSelection spec Wait until the middle of the selection is within tolerance of the middle of the viewport instead of until the page has scrolled at all, and say why we wait: centerSelection() reaches the renderer asynchronously, but the scroll itself (RevealSelection -> ScrollRectToVisible) is instant since the page does not use CSS smooth scrolling. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KX1hkNiiBq2fQEsXWusxpm --------- Co-authored-by: Claude <[email protected]> (cherry picked from commit ef8d809) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KX1hkPAirbYV7a7v3Ck4FB
There was a problem hiding this comment.
I reviewed this backport and didn't find any bugs. It adds a new Chromium patch under patches/, which has code owners, and I reviewed it from a standalone clone without the Chromium source, so it's worth having a patch owner look at it too.
What was reviewed:
- The new patch only removes the
#if BUILDFLAG(IS_MAC)/#endifpair around the body ofWebContentsImpl::CenterSelection(). Its header and commit message say why the patch is needed and when it can be dropped. It is added at the end ofpatches/chromium/.patches(line 511). - The new
centerSelection()spec is taggedserialbecause it uses a shown, focused window. It uses vitest matchers, and both helpers it uses (focusWebContents,waitUntil) exist inspec/lib/spec-helpers.ts. The docs forcontents.centerSelection()and<webview>.centerSelection()have no platform tag, so no docs change is needed. - Not done: I didn't check the hunk against Chromium 152's
web_contents_impl.cc(it's not in this clone), and I didn't run the spec or a build.
Extended reasoning...
The PR adds a two-line Chromium patch that removes a macOS-only guard in WebContentsImpl::CenterSelection(), lists it in patches/chromium/.patches, and adds a serial-tagged spec in spec/api-web-contents.spec.ts. It doesn't touch any security-sensitive code (no IPC handlers, permissions or webPreferences). /patches/ is owned by patch-owners in .github/CODEOWNERS, so I didn't approve it. The review used a standalone clone, so I couldn't check the upstream file the patch targets, and the PR checklist says the author hasn't built or tested the change.
|
Release Notes Persisted
|
Requested by David Babenko-Sanders · Slack thread
Description of Change
Manually backport #55909. See that PR for details.
CC @dsanders11
Resolved a spec conflict caused by the
disableWakeLockstests that do not exist on 44-x-y, dropped an unrelated.patchesline that came in through the union merge, and regenerated the Chromium patch against 44-x-y's Chromium 152 (line offsets and index hashes only).Checklist
npm testpasses🤖 Generated with Claude Code
https://claude.ai/code/session_01KX1hkPAirbYV7a7v3Ck4FB
Release Notes
Notes: Fixed
webContents.centerSelection()so that it works on Windows and Linux.Generated by Claude Code