Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: d12d6366d4fc3beb9af4d609cb4b01d0e4d43883
      
https://github.com/WebKit/WebKit/commit/d12d6366d4fc3beb9af4d609cb4b01d0e4d43883
  Author: Qianlang Chen <[email protected]>
  Date:   2026-06-24 (Wed, 24 Jun 2026)

  Changed paths:
    A 
LayoutTests/http/tests/site-isolation/inspector/css/css-frontend-routing-frame-target-expected.txt
    A 
LayoutTests/http/tests/site-isolation/inspector/css/css-frontend-routing-frame-target.html
    M Source/WebInspectorUI/UserInterface/Controllers/CSSManager.js
    M Source/WebInspectorUI/UserInterface/Models/CSSGrouping.js
    M Source/WebInspectorUI/UserInterface/Models/CSSStyleSheet.js
    M Source/WebInspectorUI/UserInterface/Models/DOMNode.js
    M Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js
    M Source/WebInspectorUI/UserInterface/Protocol/CSSObserver.js

  Log Message:
  -----------
  [Site Isolation] Web Inspector: Use FrameCSSAgent in the frontend
https://bugs.webkit.org/show_bug.cgi?id=314148

Reviewed by BJ Burg.

Route CSS commands and events through FrameCSSAgent for cross-origin
iframes, mirroring how FrameDOMAgent is already used in the frontend
for the DOM domain's commands and events. Cross-origin iframes now
go from no CSS support to partial support, while the main frame and
same-origin iframes continue to be handled by the page-target
InspectorCSSAgent unchanged, with full support.

Routing decisions key based on the existing `owningTarget` getter on
DOMNode, introduced for FrameDOMAgent. When a DOMNode's owningTarget is
a FrameTarget, CSS commands for that node go to the frame's new
CSSAgent; otherwise they fall back to the page target via
WI.assumingMainTarget(). The same predicate is used to decide whether a
styleSheetAdded event came from a frame target's CSSObserver, in which
case the style sheet is recorded with `target.identifier + ":" + rawId`
as its map key to disambiguate from page-target identifiers.

Most of the changes are mechanical owningTarget-based routing across
CSSObserver, CSSManager, CSSStyleSheet, CSSGrouping, DOMNodeStyles,
and DOMNode. The DOMNode `frame` getter now walks the parentNode chan:
after the iframe document is spliced into the page tree, the walk
reaches the iframe element which does have its frame resolved,
in a similar fashion to finding the owning target.

Out of scope and tracked separately as follow-ups:

- CSSObserver still drops nodeLayoutFlagsChanged and
  nodeLayoutContextTypeChanged for FrameTargets, since those commands'
  ownership needs to be reworked. (webkit.org/b/316844)

- Style sheet entries for the main frame are duplicated in
  WI.cssManager.styleSheets: the page target observes them via the
  shared process, and the main frame's FrameCSSAgent observes them
  again. With cross-origin-only routing, the main-frame FrameTarget's
  entries waste memory and nothing reads them. A future cleanup can
  either silence the duplicate observation in the backend or filter it
  on the frontend, if not done as part of the page target's deprecation.
  (webkit.org/b/317762)

- Editing a CSS resource through the Sources tab is currently blocked
  by Network/Page domain limitations: under SI, cross-origin iframe
  resources cannot be loaded by the page target's NetworkAgent /
  PageAgent. The CSS-side routing for setStyleSheetText is implemented
  (CSSStyleSheet.handleCurrentRevisionContentChange uses the owning
  target), but the path is unreachable end-to-end through the Sources
  tab UI until more support on the networking side of cross-origin
  inspection completes. (webkit.org/b/317760)

Test: 
http/tests/site-isolation/inspector/css/css-frontend-routing-frame-target.html

- Cover routing distinctions that tests in 
css-editing-commands-frame-target.html
  can't verify.

* 
LayoutTests/http/tests/site-isolation/inspector/css/css-frontend-routing-frame-target-expected.txt:
 Added.
* 
LayoutTests/http/tests/site-isolation/inspector/css/css-frontend-routing-frame-target.html:
 Added.
* Source/WebInspectorUI/UserInterface/Controllers/CSSManager.js:
(WI.CSSManager):
(WI.CSSManager.prototype.styleSheetForIdentifier):
(WI.CSSManager.prototype.preferredInspectorStyleSheetForFrame):
(WI.CSSManager.prototype.styleSheetChanged):
(WI.CSSManager.prototype.styleSheetAdded):
(WI.CSSManager.prototype.styleSheetRemoved):
(WI.CSSManager.prototype._styleSheetKey):
(WI.CSSManager.prototype._handleTargetRemoved):
* Source/WebInspectorUI/UserInterface/Models/CSSGrouping.js:
(WI.CSSGrouping.prototype.async setText):
* Source/WebInspectorUI/UserInterface/Models/CSSStyleSheet.js:
(WI.CSSStyleSheet):
(WI.CSSStyleSheet.prototype.get owningTarget):
(WI.CSSStyleSheet.prototype.requestContentFromBackend):
* Source/WebInspectorUI/UserInterface/Models/DOMNode.js:
(WI.DOMNode.prototype.get frame):
(WI.DOMNode.prototype.setPseudoClassEnabled):
(WI.DOMNode.prototype._markUndoableState):
* Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js:
(WI.DOMNodeStyles.prototype.refresh):
(WI.DOMNodeStyles.prototype.addRule):
(WI.DOMNodeStyles.prototype.changeStyleText):
(WI.DOMNodeStyles.prototype._parseStyleDeclarationPayload):
(WI.DOMNodeStyles.prototype._parseRulePayload):
* Source/WebInspectorUI/UserInterface/Protocol/CSSObserver.js:
(WI.CSSObserver.prototype.mediaQueryResultChanged):
(WI.CSSObserver.prototype.styleSheetChanged):
(WI.CSSObserver.prototype.styleSheetAdded):
(WI.CSSObserver.prototype.styleSheetRemoved):

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



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

Reply via email to