In debug builds, calling LocalDOMWindow::getMatchedCSSRules with a null or empty pseudoElement parameter results in an assertion failure in PseudoElementRequest(). In release builds, getMatchedCSSRules incorrectly returns null. This API, while deprecated, is still exposed to Obj-C clients via -[DOMDocument getMatchedCSSRules:pseudoElement:authorOnly:], and our macOS application [1] relies on it working correctly. Our app is currently broken on the macOS Sequoia beta builds due to this bug. It looks like this is the commit that inadvertently caused the issue: https://github.com/WebKit/WebKit/commit/4d69396f11340703fd2c7cffc87e2ed11b26633f In that commit, two changes combined to create the bug: (1) The signature for Resolver::pseudoStyleRulesForElement changed (the pseudoId parameter is now a std::optional<PseudoId> instead of PseudoId) (2) The PseudoElementRequest constructor was modified to assert pseudoId != PseudoId::None When LocalDOMWindow::getMatchedCSSRules is called with an empty pseudoElement parameter, it ends up calling pseudoStyleRulesForElement with PseudoId::None, which triggers the assertion. Proposed Fix: The method getMatchedCSSRules should be changed to call pseudoStyleRulesForElement with std::nullopt instead of PseudoId::None. LocalDOMWindow.cpp:1636: - auto pseudoId = pseudoElementIdentifier ? pseudoElementIdentifier->pseudoId : PseudoId::None; + std::optional<PseudoId> pseudoId; + if (pseudoElementIdentifier) + pseudoId = pseudoElementIdentifier->pseudoId; Thanks, Jonathan [1]: https://directmailmac.com
Created attachment 471896 [details] Patch to fix LocalDOMWindow::getMatchedCSSRules
Pull request: https://github.com/WebKit/WebKit/pull/30906
Committed 281088@main (9b380bdb5e47): <https://commits.webkit.org/281088@main> Reviewed commits have been landed. Closing PR #30906 and removing active labels.
<rdar://problem/132009080>
Committed 280938.67@integration/ci/132009080_9b380bdb5e_safari-7619-branch (372659bf557d): <https://commits.webkit.org/280938.67@integration/ci/132009080_9b380bdb5e_safari-7619-branch> Reviewed commits have been landed. Closing PR #1433 and removing active labels.