Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 2c0f6fd37a286e28225a59ea83c9e6fb15a43298
      
https://github.com/WebKit/WebKit/commit/2c0f6fd37a286e28225a59ea83c9e6fb15a43298
  Author: Elijah Sawyers <[email protected]>
  Date:   2025-08-12 (Tue, 12 Aug 2025)

  Changed paths:
    M Source/WTF/wtf/PlatformEnableCocoa.h
    M Source/WebCore/Headers.cmake
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebCore/contentextensions/ContentExtension.cpp
    M Source/WebCore/contentextensions/ContentExtensionCompiler.cpp
    M Source/WebCore/contentextensions/ContentExtensionError.cpp
    M Source/WebCore/contentextensions/ContentExtensionError.h
    M Source/WebCore/contentextensions/ContentExtensionParser.cpp
    M Source/WebCore/contentextensions/ContentExtensionRule.cpp
    M Source/WebCore/contentextensions/ContentExtensionRule.h
    M Source/WebCore/contentextensions/ContentExtensionsBackend.cpp
    A Source/WebCore/contentextensions/ContentRuleListMatchedRule.h
    M Source/WebCore/page/ChromeClient.h
    M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
    M Source/WebKit/UIProcess/API/APINavigationClient.h
    M Source/WebKit/UIProcess/Cocoa/NavigationState.h
    M Source/WebKit/UIProcess/Cocoa/NavigationState.mm
    M Source/WebKit/UIProcess/WebPageProxy.cpp
    M Source/WebKit/UIProcess/WebPageProxy.h
    M Source/WebKit/UIProcess/WebPageProxy.messages.in
    M Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp
    M Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h
    M Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp

  Log Message:
  -----------
  Serialize dNR rule identifiers in content extension rule lists
https://bugs.webkit.org/show_bug.cgi?id=297155
rdar://157890918

Reviewed by Brian Weinstein.

This patch makes it possible to specify an identifier for a content extension 
rule. This is working
toward implementing the onRuleMatchedDebug API for dNR, which isn't currently 
possible because the
rule identifiers are destroyed when the dNR rules are converted into content 
extension rules.

The idea behind this patch is that we store the rule identifier with its 
serialized action, meaning
that we cannot combine actions, which does have slight memory implications. 
However, most dNR rules
contain conditions and wouldn't have their actions combined during compilation 
anyways. As for the
identifiers themselves, we have a 100k rule limit, and each identifier is a 32 
bit unsigned integer,
so at most, we're using 0.4MB more memory.

The serialized actions now have the form:

[
  one byte for the variant,
  X bytes for extra information (like string size and selector for 
css-display-none actions),
  four bytes for the identifier,
  ...
]

There's a lot more to do to get this to work, like implementing the dNR API and 
wiring up this new
notification. Also, there are smaller things such as conditional serializing of 
the identifiers and
adding more information to the object that's included with the published 
notification.

See sub-tasks of: rdar://71867958

Wrote new tests to validate that the rules are being serialized as expected. 
Tests for the
notification will be written once we wire up the functionality to the web 
extensions controller.
See: rdar://157878200.

* Source/WTF/wtf/PlatformEnableCocoa.h:
* Source/WebCore/Headers.cmake:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/contentextensions/ContentExtension.cpp:
(WebCore::ContentExtensions::ContentExtension::findFirstIgnoreRule const):
* Source/WebCore/contentextensions/ContentExtensionCompiler.cpp:
(WebCore::ContentExtensions::serializeActions):
(WebCore::ContentExtensions::compileRuleList):
* Source/WebCore/contentextensions/ContentExtensionError.cpp:
(WebCore::ContentExtensions::contentExtensionErrorCategory):
* Source/WebCore/contentextensions/ContentExtensionError.h:
* Source/WebCore/contentextensions/ContentExtensionParser.cpp:
(WebCore::ContentExtensions::loadRule):
(WebCore::ContentExtensions::loadEncodedRules):
* Source/WebCore/contentextensions/ContentExtensionRule.cpp:
(WebCore::ContentExtensions::ContentExtensionRule::ContentExtensionRule):
(WebCore::ContentExtensions::DeserializedAction::deserialize):
* Source/WebCore/contentextensions/ContentExtensionRule.h:
(WebCore::ContentExtensions::ContentExtensionRule::identifier const):
(WebCore::ContentExtensions::ContentExtensionRule::isolatedCopy const):
(WebCore::ContentExtensions::ContentExtensionRule::isolatedCopy):
* Source/WebCore/contentextensions/ContentExtensionsBackend.cpp:
(WebCore::ContentExtensions::ContentExtensionsBackend::processContentRuleListsForLoad):
* Source/WebCore/contentextensions/ContentRuleListMatchedRule.h: Added.
* Source/WebCore/page/ChromeClient.h:
(WebCore::ChromeClient::contentRuleListMatchedRule):
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Source/WebKit/UIProcess/API/APINavigationClient.h:
(API::NavigationClient::contentRuleListMatchedRule):
* Source/WebKit/UIProcess/Cocoa/NavigationState.h:
* Source/WebKit/UIProcess/Cocoa/NavigationState.mm:
(WebKit::NavigationState::NavigationClient::contentRuleListMatchedRule):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::contentRuleListMatchedRule):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebPageProxy.messages.in:
* Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::contentRuleListMatchedRule):
* Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h:
* 
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/xcshareddata/xcschemes/TestWebKitAPI.xcscheme:
* Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:
(TestWebKitAPI::TEST_F(ContentExtensionTest, InvalidJSON)):
(TestWebKitAPI::TEST_F(ContentExtensionTest, RuleIdentifiers)):

Canonical link: https://commits.webkit.org/298570@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