Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: fe7b1ac8b3e9a04206e3d6fcca7671e8ec627d6c
      
https://github.com/WebKit/WebKit/commit/fe7b1ac8b3e9a04206e3d6fcca7671e8ec627d6c
  Author: Anuj Panta <[email protected]>
  Date:   2026-10-07 (Wed, 07 Oct 2026)

  Changed paths:
    M 
LayoutTests/http/tests/site-isolation/inspector/debugger/resources/site-isolation-debugger-test-utilities.js
    A 
LayoutTests/http/tests/site-isolation/inspector/dom/element-selection-frame-target-expected.txt
    A 
LayoutTests/http/tests/site-isolation/inspector/dom/element-selection-frame-target.html
    M 
LayoutTests/http/tests/site-isolation/inspector/dom/highlight-frame-target.html
    A 
LayoutTests/http/tests/site-isolation/inspector/dom/hover-into-remote-frame-clears-page-highlight-expected.txt
    A 
LayoutTests/http/tests/site-isolation/inspector/dom/hover-into-remote-frame-clears-page-highlight.html
    M 
LayoutTests/http/tests/site-isolation/inspector/dom/layout-overlays-frame-target.html
    A 
LayoutTests/http/tests/site-isolation/inspector/dom/resources/hover-inner-frame.html
    A 
LayoutTests/http/tests/site-isolation/inspector/dom/resources/hover-middle-frame.html
    M Source/JavaScriptCore/inspector/protocol/DOM.json
    M Source/WebCore/inspector/InspectorInstrumentation.cpp
    M Source/WebCore/inspector/InspectorInstrumentation.h
    M Source/WebCore/inspector/agents/InspectorDOMAgent.cpp
    M Source/WebCore/inspector/agents/InspectorDOMAgent.h
    M Source/WebCore/inspector/agents/frame/FrameDOMAgent.cpp
    M Source/WebCore/inspector/agents/frame/FrameDOMAgent.h
    M Source/WebCore/inspector/agents/frame/FrameDOMAgentStubs.cpp
    M Source/WebCore/page/EventHandler.cpp
    M Source/WebCore/page/EventHandler.h
    M Source/WebInspectorUI/UserInterface/Controllers/DOMManager.js
    M Source/WebInspectorUI/UserInterface/Models/DOMNode.js
    M Source/WebInspectorUI/UserInterface/Protocol/DOMObserver.js
    M Source/WebKit/UIProcess/WebPageProxy.cpp
    M Source/WebKit/UIProcess/WebPageProxy.h
    M Source/WebKit/UIProcess/WebPageProxyInternals.h
    M Source/WebKit/WebProcess/Inspector/WebInspectorBackendClient.cpp
    M Source/WebKit/WebProcess/Inspector/WebInspectorBackendClient.h
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.h
    M Source/WebKit/WebProcess/WebPage/WebPage.messages.in

  Log Message:
  -----------
  Implement DOM.setInspectModeEnabled for FrameDOMAgent
https://bugs.webkit.org/show_bug.cgi?id=316139
rdar://179175840

Reviewed by BJ Burg.

Implements setInspectModeEnabled for FrameDOMAgent, replacing the stub that
returned "Not supported for frame targets", so the element picker works inside a
cross-origin iframe. The agent gains its own search state and the hover, tap and
click hooks that drive it.

The hover hook is always dispatched with the page's agents, so the frame agent
cannot be found through them and is resolved from the hit-tested frame instead.
The tap hook likewise resolves agents from the tapped node's frame, since its 
hit
test descends into subframes.

Only one agent owns selection for a given frame: a frame agent owns it when its
frame is a local root other than the main frame (ownsElementSelection()), and 
the
page agent keeps the main frame and same-process nested frames, whose frame 
overlay
is not hosted yet. The page agent cedes hover to a frame that owns selection.

The click needs arbitration now that two agents can search at once.
handleMousePressEvent() runs the hook at the top of the function and returns as
soon as an agent claims the click, long before it hands the event to the 
subframe.
So the page agent cedes when the highlighted node owns a frame that owns 
selection,
and the frame agent is asked first when the event reaches its frame. A 
cross-process
frame is assumed to own selection, since its agent cannot be reached.

Three things need coordinating once two targets can draw and select:

- Each hover clears the hovered node of every other frame in its local root. A 
local
  root's process gets no event once the cursor moves to another process, so
  WebPageProxy remembers which frame handled the last mouse move and sends
  MouseDidLeaveLocalRoot to it when that changes.

- DOMObserver.inspect() early-returned for frame targets, so a selection inside 
a
  frame never reached the frontend and the toolbar button stayed lit after the
  backend had left selection mode.

- inspectModeEnabled now fans out to every target rather than only the main one,
  including targets added while

WebInspectorBackendClient::highoverlay its own surface
only for localMainOrRootFrame(), so a process with several local roots drew only
one of them. It now checks isRo

setSearchingForNode() deliberatckend client:
elementSelectionChanged() is page-wide UI state that every frame target would
fight over as the frontend enabturn.

Also renames m_highlightOverlay and exceptTargets to
excludedTargets, and drops "itml" from highlightRect and highlightQuad.

Tests: 
http/tests/site-isolation/inspector/dom/element-selection-frame-target.html

* 
LayoutTests/http/tests/site-isolation/inspector/debugger/resources/site-isolation-debugger-test-utilities.js:
(TestPage.registerInitializer.window.waitForFrameTargetForURLContaining.async 
waitForFrameTargetForURLContaining):
* 
LayoutTests/http/tests/site-isolation/inspector/dom/element-selection-frame-target-expected.txt:
 Added.
* 
LayoutTests/http/tests/site-isolation/inspector/dom/element-selection-frame-target.html:
 Added.
* 
LayoutTests/http/tests/site-isolation/inspector/dom/highlight-frame-target.html:
* 
LayoutTests/http/tests/site-isolation/inspector/dom/hover-into-remote-frame-clears-page-highlight-expected.txt:
 Added.
* 
LayoutTests/http/tests/site-isolation/inspector/dom/hover-into-remote-frame-clears-page-highlight.html:
 Added.
* 
LayoutTests/http/tests/site-isolation/inspector/dom/layout-overlays-frame-target.html:
* 
LayoutTests/http/tests/site-isolation/inspector/dom/resources/hover-inner-frame.html:
 Added.
* 
LayoutTests/http/tests/site-isolation/inspector/dom/resources/hover-middle-frame.html:
 Added.
* Source/JavaScriptCore/inspector/protocol/DOM.json:
* Source/WebCore/inspector/InspectorInstrumentation.cpp:
(WebCore::clearMousedOverNodes):
(WebCore::InspectorInstrumentation::mouseDidMoveOverElementImpl):
(WebCore::InspectorInstrumentation::mouseDidMoveOverRemoteFrameImpl):
(WebCore::InspectorInstrumentation::mouseDidLeaveLocalRootImpl):
(WebCore::InspectorInstrumentation::handleTouchEventImpl):
(WebCore::InspectorInstrumentation::handleMousePressImpl):
* Source/WebCore/inspector/InspectorInstrumentation.h:
(WebCore::InspectorInstrumentation::mouseDidMoveOverRemoteFrame):
(WebCore::InspectorInstrumentation::mouseDidLeaveLocalRoot):
(WebCore::InspectorInstrumentation::handleTouchEvent):
* Source/WebCore/inspector/agents/InspectorDOMAgent.cpp:
(WebCore::frameOwnsElementSelection):
(WebCore::frameOwnerNodeOwnsElementSelection):
(WebCore::InspectorDOMAgent::handleMousePress):
(WebCore::InspectorDOMAgent::mouseDidMoveOverElement):
(WebCore::InspectorDOMAgent::mouseDidMoveOverRemoteFrame):
(WebCore::InspectorDOMAgent::highlightMousedOverNode):
* Source/WebCore/inspector/agents/InspectorDOMAgent.h:
* Source/WebCore/inspector/agents/frame/FrameDOMAgent.cpp:
(WebCore::FrameDOMAgent::willDestroyFrontendAndBackend):
(WebCore::FrameDOMAgent::setDocument):
(WebCore::FrameDOMAgent::setInspectModeEnabled):
(WebCore::FrameDOMAgent::setSearchingForNode):
(WebCore::FrameDOMAgent::ownsElementSelection const):
(WebCore::FrameDOMAgent::highlightMousedOverNode):
(WebCore::FrameDOMAgent::mouseDidMoveOverElement):
(WebCore::FrameDOMAgent::mouseDidLeaveFrame):
(WebCore::FrameDOMAgent::handleTouchEvent):
(WebCore::FrameDOMAgent::handleMousePress):
(WebCore::FrameDOMAgent::inspect):
(WebCore::FrameDOMAgent::focusNode):
* Source/WebCore/inspector/agents/frame/FrameDOMAgent.h:
* Source/WebCore/inspector/agents/frame/FrameDOMAgentStubs.cpp:
(WebCore::FrameDOMAgent::setInspectModeEnabled): Deleted.
* Source/WebCore/page/EventHandler.cpp:
(WebCore::EventHandler::mouseMoved):
(WebCore::EventHandler::mouseDidLeaveLocalRoot):
(WebCore::EventHandler::handleTouchEvent):
* Source/WebCore/page/EventHandler.h:
* Source/WebInspectorUI/UserInterface/Controllers/DOMManager.js:
(WI.DOMManager.prototype._initializeFrameTarget):
(WI.DOMManager.prototype.inspectElement):
(WI.DOMManager.prototype.inspectElementInFrameTarget):
(WI.DOMManager.prototype._didInspectNodeInTarget):
(WI.DOMManager.prototype._setInspectModeEnabledForTarget):
(WI.DOMManager.prototype.highlightDOMNodeList):
(WI.DOMManager.prototype.hideDOMNodeHighlight):
(WI.DOMManager.prototype.set inspectModeEnabled):
* Source/WebInspectorUI/UserInterface/Models/DOMNode.js:
(WI.DOMNode.prototype.highlight):
* Source/WebInspectorUI/UserInterface/Protocol/DOMObserver.js:
(WI.DOMObserver.prototype.inspect):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::sendMouseEvent):
(WebKit::WebPageProxy::mouseMoveWasHandledInFrame):
(WebKit::WebPageProxy::resetStateAfterProcessExited):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebPageProxyInternals.h:
* Source/WebKit/WebProcess/Inspector/WebInspectorBackendClient.cpp:
(WebKit::WebInspectorBackendClient::highlight):
(WebKit::WebInspectorBackendClient::hideHighlight):
(WebKit::WebInspectorBackendClient::highlightFrame):
(WebKit::WebInspectorBackendClient::willMoveToPage):
* Source/WebKit/WebProcess/Inspector/WebInspectorBackendClient.h:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::mouseDidLeaveLocalRoot):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:

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



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

Reply via email to