Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 6df1cac064f436e42dcaca9b07887b7651b4474e
https://github.com/WebKit/WebKit/commit/6df1cac064f436e42dcaca9b07887b7651b4474e
Author: Cole Carley <[email protected]>
Date: 2026-06-10 (Wed, 10 Jun 2026)
Changed paths:
M Source/WebKit/WebProcess/WebPage/FindController.cpp
Log Message:
-----------
Find in page sometimes finds the first match twice
https://bugs.webkit.org/show_bug.cgi?id=316044
rdar://177107959
Reviewed by Megan Gardner.
There are a three cases when creating a new find session:
1. First find session with nothing in the search box
2. Nth find session without a search term in the search box
3. Nth find session with a search term in the search box
Case 3 is our problem case. When a new session is created, Safari clears
the current selection and performs a search for that string, which marks
all the matches on the page. Many times, WebKit would perform the search
and set the selection, then Safari would clear it as apart of its find
session set up. This seems to be the result of IPC overhead. This causes
the first match to be found twice because findString uses the current
selection to find the next match.
I believe clearing the selection at the beginning of a find session is
the correct thing to do, so I addressed the issue by, removing the first call
to findString. Instead, I have Safari pass _WKFindOptionsShowOverlay to
_countStringMatches, which both highlights all the string matches and reports
the count.
This way, if the user presses cmd-F and a previous search term is in the
search box, all the matches will be marked, but none will be highlighted
until they explicitly search or press the next button.
* Source/WebKit/WebProcess/WebPage/FindController.cpp:
(WebKit::FindController::countStringMatches):
(WebKit::FindController::updateFindUIAfterFindingAllMatches):
* test.html: Added.
Canonical link: https://commits.webkit.org/314911@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications