Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: d207618b6bf4aafb72d8dd9ad1dc44d97aff565f
      
https://github.com/WebKit/WebKit/commit/d207618b6bf4aafb72d8dd9ad1dc44d97aff565f
  Author: Abrar Rahman Protyasha <[email protected]>
  Date:   2025-09-30 (Tue, 30 Sep 2025)

  Changed paths:
    A 
LayoutTests/http/tests/site-isolation/focus-click-navigation-activeElement-expected.txt
    A 
LayoutTests/http/tests/site-isolation/focus-click-navigation-activeElement.html
    M 
LayoutTests/http/tests/site-isolation/focus-tab-navigation-activeElement.html
    A 
LayoutTests/http/tests/site-isolation/resources/focus-click-navigation-iframe.html
    M LayoutTests/platform/ios/TestExpectations
    M Source/WebCore/Headers.cmake
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebCore/dom/Document.cpp
    M Source/WebCore/dom/Document.h
    M Source/WebCore/dom/Element.cpp
    M Source/WebCore/editing/FrameSelection.cpp
    M Source/WebCore/editing/cocoa/AutofillElements.cpp
    M Source/WebCore/loader/EmptyClients.h
    M Source/WebCore/page/Chrome.cpp
    M Source/WebCore/page/Chrome.h
    M Source/WebCore/page/ChromeClient.h
    M Source/WebCore/page/EventHandler.cpp
    M Source/WebCore/page/FocusController.cpp
    M Source/WebCore/page/FocusController.h
    A Source/WebCore/page/FocusControllerTypes.h
    M Source/WebKit/Scripts/webkit/messages.py
    M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
    M Source/WebKit/UIProcess/WebFrameProxy.cpp
    M Source/WebKit/UIProcess/WebPageProxy.cpp
    M Source/WebKit/UIProcess/WebPageProxy.h
    M Source/WebKit/UIProcess/WebPageProxy.messages.in
    M Source/WebKit/WebProcess/Plugins/PluginView.cpp
    M Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp
    M Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h
    M Source/WebKit/WebProcess/WebCoreSupport/WebRemoteFrameClient.cpp
    M Source/WebKit/WebProcess/WebPage/WebFrame.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.h
    M Source/WebKit/WebProcess/WebPage/WebPage.messages.in
    M Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
    M Source/WebKitLegacy/ios/WebCoreSupport/WebChromeClientIOS.h
    M Source/WebKitLegacy/ios/WebCoreSupport/WebChromeClientIOS.mm
    M Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h
    M Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm

  Log Message:
  -----------
  [Site Isolation] Clicking on the body of a frame to focus it should blur the 
active element
https://bugs.webkit.org/show_bug.cgi?id=299543
rdar://157077681

Reviewed by Wenson Hsieh.

With site isolation, a page's focus management is driven per web content
process for said process's local frame set. This means there are
multiple focus controllers when a page has cross-origin iframes loaded.
If a user clicks on a focusable element in some cross-origin iframe, the
focus controller belonging to the web content process where said iframe
is a local frame will grant focus to the element. However, some other
web content process may still think focus belongs to an element in one
of its local frames, because that is what its focus controller believes.

In this patch, we alleviate this issue by introducing the ability to
broadcast focused element changes across web content processes. This is
similar in spirit to 268570@main, which introduced the same ability
except for when a focused frame changed.

To do so, we hook into the Document::setFocusedElement() flow and teach
Chrome(Client) about other data required to correctly broadcast this
change, namely the focused local frame where the change happened and the
focus options.

More details in-line.

Test: http/tests/site-isolation/focus-click-navigation-activeElement.html

* 
LayoutTests/http/tests/site-isolation/focus-click-navigation-activeElement-expected.txt:
 Added.
* 
LayoutTests/http/tests/site-isolation/focus-click-navigation-activeElement.html:
 Added.
* LayoutTests/http/tests/site-isolation/focus-tab-navigation-activeElement.html:
* 
LayoutTests/http/tests/site-isolation/resources/focus-click-navigation-iframe.html:
 Added.
* LayoutTests/platform/ios/TestExpectations:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::setFocusedElement):
* Source/WebCore/dom/Document.h:
* Source/WebCore/dom/Element.cpp:
(WebCore::Element::focus):
(WebCore::Element::blur):
* Source/WebCore/editing/FrameSelection.cpp:
(WebCore::FrameSelection::setFocusedElementIfNeeded):
* Source/WebCore/editing/cocoa/AutofillElements.cpp:
* Source/WebCore/loader/EmptyClients.h:
* Source/WebCore/page/Chrome.cpp:
(WebCore::Chrome::focusedElementChanged):
* Source/WebCore/page/Chrome.h:
* Source/WebCore/page/ChromeClient.h:
* Source/WebCore/page/EventHandler.cpp:
(WebCore::EventHandler::dispatchMouseEvent):
* Source/WebCore/page/FocusController.cpp:
(WebCore::FocusController::setFocusedFrame):
(WebCore::FocusController::findFocusableElementDescendingIntoSubframes):
(WebCore::FocusController::setFocusedElement):

* Source/WebCore/page/FocusController.h:
We track a m_focusedFrameBeforeRemoteFocusBroadcast pointer, which
corresponds to the focused frame that got reset by a remote broadcast.
We then consult this pointer when resetting element focus because of a
remote broadcast, too.

* Source/WebCore/page/FocusControllerTypes.h: Added.
We take the liberty to pull out some types used by FocusController
for cross process coordination into this header.

* Source/WebKit/Scripts/webkit/messages.py:
(headers_for_type):
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Source/WebKit/UIProcess/WebFrameProxy.cpp:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::focusedElementChanged):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebPageProxy.messages.in:
* Source/WebKit/WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::focusPluginElement):
* Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::focusedElementChanged):
(WebKit::WebChromeClient::focusedFrameChanged):
* Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h:
* Source/WebKit/WebProcess/WebCoreSupport/WebRemoteFrameClient.cpp:
* Source/WebKit/WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::loadDidCommitInAnotherProcess):
(WebKit::WebFrame::commitProvisionalFrame):
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::elementWasFocusedInAnotherProcess):
(WebKit::WebPage::frameWasFocusedInAnotherProcess):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:
* Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::focusTextInputContextAndPlaceCaret):
* Source/WebKitLegacy/ios/WebCoreSupport/WebChromeClientIOS.h:
* Source/WebKitLegacy/ios/WebCoreSupport/WebChromeClientIOS.mm:
(WebChromeClientIOS::focusedElementChanged):
* Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h:
* Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm:
(WebChromeClient::focusedElementChanged):

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to