Skip to content

fix: make webContents.centerSelection() work on Windows and Linux - #55916

Merged
jkleinsc merged 2 commits into
46-x-yfrom
trop/46-x-y-bp-fix-make-webcontents-centerselection-work-on-windows-and-linux-1795017697871
Nov 18, 2026
Merged

jkleinsc merged 2 commits into
46-x-yfrom
trop/46-x-y-bp-fix-make-webcontents-centerselection-work-on-windows-and-linux-1795017697871

Conversation

@trop

@trop trop Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Backport of #55909

See that PR for details.

Notes: Fixed webContents.centerSelection() so that it works on Windows and Linux.

trop Bot and others added 2 commits November 18, 2026 16:01
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]>
@trop
trop Bot requested a review from a team as a code owner November 18, 2026 16:02
@trop trop Bot added 46-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes labels Nov 18, 2026

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed this backport and didn't find any bugs. The new Chromium patch falls under the /patches/ CODEOWNERS entry, so a patch owner should still take a look.

What was reviewed (from a standalone clone, so none of the upstream Chromium source was available):

  • The new patch only removes the #if BUILDFLAG(IS_MAC)/#endif guard in WebContentsImpl::CenterSelection(). That matches its commit message, which includes an upstream CL link and says when the patch can be dropped. The patch is added to patches/chromium/.patches.
  • The new centerSelection() spec needs OS focus and is tagged serial, as spec/CLAUDE.md requires. It uses vitest matchers and waits for the selection to be centred instead of reacting to the first scroll.
  • I couldn't check that the hunk applies to the pinned web_contents_impl.cc or that the mojom/renderer path really is platform-neutral, because that code isn't in this checkout. I also didn't run the spec.
Extended reasoning...

The change adds one Chromium patch that removes a macOS-only build guard from WebContentsImpl::CenterSelection(), lists it in patches/chromium/.patches, and adds a serial-tagged spec in spec/api-web-contents.spec.ts. It touches no security-sensitive area (no IPC handlers, webPreferences, permissions or protocol handlers). It is small and matches its description. The deciding fact is that /patches/ is assigned to the patch-owners team in .github/CODEOWNERS, so I deferred instead of approving.

@jkleinsc
jkleinsc merged commit 7eb2ba9 into 46-x-y Nov 18, 2026
92 checks passed
@jkleinsc
jkleinsc deleted the trop/46-x-y-bp-fix-make-webcontents-centerselection-work-on-windows-and-linux-1795017697871 branch November 18, 2026 18:06
@release-clerk

release-clerk Bot commented Nov 18, 2026

Copy link
Copy Markdown

Release Notes Persisted

Fixed webContents.centerSelection() so that it works on Windows and Linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

46-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants