Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 58742734b4594e5e330d19ce31b1dfda33e675b9
      
https://github.com/WebKit/WebKit/commit/58742734b4594e5e330d19ce31b1dfda33e675b9
  Author: Razvan Caliman <[email protected]>
  Date:   2025-10-29 (Wed, 29 Oct 2025)

  Changed paths:
    A LayoutTests/inspector/css/setStyleTextAfterSetStyleSheetText-expected.txt
    A LayoutTests/inspector/css/setStyleTextAfterSetStyleSheetText.html
    M Source/WebCore/inspector/InspectorStyleSheet.cpp

  Log Message:
  -----------
  Web Inspector: Styles added via "add new rule" are not always applied
https://bugs.webkit.org/show_bug.cgi?id=301281
rdar://103548968

Reviewed by Devin Rousso.

`InspectorCSSAgent::setStyleText()` fails when attempted after 
`InspectorCSSAgent::setStyleSheetText()`
without an intermediary request to get the updated style data to Web Inspector 
frontend.

Setting the whole stylesheet text, `Inspector::ParsedStyleSheet::setText()` 
will nullify
the rule source data `m_sourceData`, a list of `CSSRuleSourceData` with 
information
about each CSS rule used by Web Inspector for mapping and mutations.

`InspectorStyleSheet::reparseStyleSheet()` does not rebuild this list.

Instead, this list is rebuilt by `InspectorStyleSheet::ensureParsedDataReady()`
when requesting updated styles data for the frontend. Order or operations or a 
race condition
can result in a sequence where the rule source data is missing when attempting 
a rule mutation.

This patch ensures the `m_sourceData` is rebuilt before updating the text of a 
CSS rule.
It follows precedent for changing the rule header text or deleting a rule.

Test: inspector/css/setStyleTextAfterSetStyleSheetText.html
* LayoutTests/inspector/css/setStyleTextAfterSetStyleSheetText-expected.txt: 
Added.
* LayoutTests/inspector/css/setStyleTextAfterSetStyleSheetText.html: Added.
* Source/WebCore/inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyleSheet::setRuleStyleText):

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



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

Reply via email to