Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b4683be67ca86c0dbd0b6ac46feae17cc6ac0539
      
https://github.com/WebKit/WebKit/commit/b4683be67ca86c0dbd0b6ac46feae17cc6ac0539
  Author: Alex Christensen <[email protected]>
  Date:   2026-09-28 (Mon, 28 Sep 2026)

  Changed paths:
    M Source/WebKit/UIProcess/WebPageProxy.h
    M Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
    M Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm
    M Source/WebKit/WebProcess/WebPage/WebPage.h
    M Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
    M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/SiteIsolation.mm

  Log Message:
  -----------
  Focusing an element in an iframe should not scroll the main frame
https://bugs.webkit.org/show_bug.cgi?id=325526
rdar://185728362

Reviewed by Ryosuke Niwa and Zak Ridouh.

320242@main wasn't quite complete.

FocusedElementInformation rects were computed with contentsToRootView in the 
iframe's process, which
already subtracts the iframe's scroll offset. The UI process then converted 
them to main frame
coordinates with ContentsToRootViewRects. That runs contentsToRootView on the 
parent process's
RemoteFrameView, whose scroll position is synced from the iframe, so the 
iframe's scroll offset was
subtracted a second time. The resulting interactionRect was far above the 
element, often at a negative
y. It also no longer overlapped the EditorState selection rect, which is 
converted correctly in the web
process. So -[WKWebView _zoomToFocusRect:...] got an empty selection rect and 
scrolled the main frame
to the top.

Fix this by computing interactionRect, nextNodeRect, previousNodeRect and 
lastInteractionLocation in
main frame coordinates in the web process, using contentsToMainFrameView and
convertToRootViewAcrossIsolatedFrames, the same way EditorState is. Remove the 
asynchronous UI process
conversion, which also stops focus updates from waiting on a round trip through 
other processes.

Test: Tools/TestWebKitAPI/Tests/WebKit/WKWebView/SiteIsolation.mm

* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::elementDidFocus):
(WebKit::WebPageProxy::updateFocusedElementInformation):
(WebKit::WebPageProxy::convertFocusedElementInformationRectsToMainFrameCoordinates):
 Deleted.
* Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
(WebKit::WebPage::mainFrameViewInteractionBounds):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::mainFrameViewBounds):
(WebKit::WebPage::focusedElementInformationWithoutLayout):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/SiteIsolation.mm:
(TestWebKitAPI::(SiteIsolation, ZoomToRevealFocusedElementRect)):
(TestWebKitAPI::(SiteIsolation, 
ZoomToRevealFocusedElementRectIsInMainFrameCoordinates)): Deleted.

Canonical link: https://commits.webkit.org/322105@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to