Diff
Modified: trunk/Source/WebCore/ChangeLog (286544 => 286545)
--- trunk/Source/WebCore/ChangeLog 2021-12-06 17:20:08 UTC (rev 286544)
+++ trunk/Source/WebCore/ChangeLog 2021-12-06 17:46:01 UTC (rev 286545)
@@ -1,3 +1,21 @@
+2021-12-06 Alex Christensen <achristen...@webkit.org>
+
+ WKWebpagePreferences._activeContentRuleListActionPatterns should be an NSDictionary of identifier to allowed patterns
+ https://bugs.webkit.org/show_bug.cgi?id=233842
+
+ Reviewed by Timothy Hatcher.
+
+ There's no need for nil to match everything because a pattern can be written to quickly match everything.
+ There is a need for different extensions (with different identifiers) to have different active action permissions, though.
+
+ * contentextensions/ContentExtensionsBackend.cpp:
+ (WebCore::ContentExtensions::ContentExtensionsBackend::processContentRuleListsForLoad):
+ * loader/DocumentLoader.cpp:
+ (WebCore::DocumentLoader::DocumentLoader):
+ (WebCore::DocumentLoader::setActiveContentRuleListActionPatterns):
+ (WebCore::DocumentLoader::allowsActiveContentRuleListActionsForURL const):
+ * loader/DocumentLoader.h:
+
2021-12-06 Antoine Quint <grao...@webkit.org>
Clean up virtual methods on AnimationEffect
Modified: trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp (286544 => 286545)
--- trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp 2021-12-06 17:20:08 UTC (rev 286544)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp 2021-12-06 17:46:01 UTC (rev 286545)
@@ -228,11 +228,11 @@
}, [&](const IgnorePreviousRulesAction&) {
RELEASE_ASSERT_NOT_REACHED();
}, [&] (const ModifyHeadersAction& action) {
- if (initiatingDocumentLoader.allowsActiveContentRuleListActionsForURL(url))
+ if (initiatingDocumentLoader.allowsActiveContentRuleListActionsForURL(contentRuleListIdentifier, url))
results.summary.modifyHeadersActions.append(action);
}, [&] (const RedirectAction& redirectAction) {
- if (initiatingDocumentLoader.allowsActiveContentRuleListActionsForURL(url))
- results.summary.redirectActions.append({ redirectAction, m_contentExtensions.get(actionsFromContentRuleList.contentRuleListIdentifier)->extensionBaseURL() });
+ if (initiatingDocumentLoader.allowsActiveContentRuleListActionsForURL(contentRuleListIdentifier, url))
+ results.summary.redirectActions.append({ redirectAction, m_contentExtensions.get(contentRuleListIdentifier)->extensionBaseURL() });
}), action.data());
}
Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (286544 => 286545)
--- trunk/Source/WebCore/loader/DocumentLoader.cpp 2021-12-06 17:20:08 UTC (rev 286544)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp 2021-12-06 17:46:01 UTC (rev 286545)
@@ -174,10 +174,7 @@
, m_originalSubstituteDataWasValid(substituteData.isValid())
, m_substituteResourceDeliveryTimer(*this, &DocumentLoader::substituteResourceDeliveryTimerFired)
, m_applicationCacheHost(makeUnique<ApplicationCacheHost>(*this))
- , m_activeContentRuleListActionPatterns(Vector<UserContentURLPattern>())
{
- // FIXME: Vector default constructor shouldn't need to know the size of the elements,
- // so m_activeContentRuleListActionPatterns ought to be able to be initialized with an initializer list in the header without including UserContentURLPattern.h.
}
FrameLoader* DocumentLoader::frameLoader() const
@@ -2437,28 +2434,27 @@
}
#endif // ENABLE(CONTENT_FILTERING)
-void DocumentLoader::setActiveContentRuleListActionPatterns(const std::optional<HashSet<String>>& patterns)
+void DocumentLoader::setActiveContentRuleListActionPatterns(const HashMap<String, Vector<String>>& patterns)
{
- if (!patterns) {
- m_activeContentRuleListActionPatterns = std::nullopt;
- return;
+ HashMap<String, Vector<UserContentURLPattern>> parsedPatternMap;
+
+ for (auto& pair : patterns) {
+ Vector<UserContentURLPattern> patternVector;
+ patternVector.reserveInitialCapacity(pair.value.size());
+ for (auto& patternString : pair.value) {
+ UserContentURLPattern parsedPattern(patternString);
+ if (parsedPattern.isValid())
+ patternVector.uncheckedAppend(WTFMove(parsedPattern));
+ }
+ parsedPatternMap.set(pair.key, WTFMove(patternVector));
}
- Vector<WebCore::UserContentURLPattern> patternVector;
- patternVector.reserveInitialCapacity(patterns->size());
- for (auto& patternString : *patterns) {
- WebCore::UserContentURLPattern parsedPattern(patternString);
- if (parsedPattern.isValid())
- patternVector.uncheckedAppend(WTFMove(parsedPattern));
- }
- m_activeContentRuleListActionPatterns = WTFMove(patternVector);
+ m_activeContentRuleListActionPatterns = WTFMove(parsedPatternMap);
}
-bool DocumentLoader::allowsActiveContentRuleListActionsForURL(const URL& url) const
+bool DocumentLoader::allowsActiveContentRuleListActionsForURL(const String& contentRuleListIdentifier, const URL& url) const
{
- if (!m_activeContentRuleListActionPatterns)
- return true;
- for (const auto& pattern : *m_activeContentRuleListActionPatterns) {
+ for (const auto& pattern : m_activeContentRuleListActionPatterns.get(contentRuleListIdentifier)) {
if (pattern.matches(url))
return true;
}
Modified: trunk/Source/WebCore/loader/DocumentLoader.h (286544 => 286545)
--- trunk/Source/WebCore/loader/DocumentLoader.h 2021-12-06 17:20:08 UTC (rev 286544)
+++ trunk/Source/WebCore/loader/DocumentLoader.h 2021-12-06 17:46:01 UTC (rev 286545)
@@ -302,8 +302,8 @@
bool userContentExtensionsEnabled() const { return m_userContentExtensionsEnabled; }
void setUserContentExtensionsEnabled(bool enabled) { m_userContentExtensionsEnabled = enabled; }
- bool allowsActiveContentRuleListActionsForURL(const URL&) const;
- WEBCORE_EXPORT void setActiveContentRuleListActionPatterns(const std::optional<HashSet<String>>&);
+ bool allowsActiveContentRuleListActionsForURL(const String& contentRuleListIdentifier, const URL&) const;
+ WEBCORE_EXPORT void setActiveContentRuleListActionPatterns(const HashMap<String, Vector<String>>&);
#if ENABLE(DEVICE_ORIENTATION)
DeviceOrientationOrMotionPermissionState deviceOrientationAndMotionAccessState() const { return m_deviceOrientationAndMotionAccessState; }
@@ -655,7 +655,7 @@
bool m_idempotentModeAutosizingOnlyHonorsPercentages { false };
String m_customNavigatorPlatform;
bool m_userContentExtensionsEnabled { true };
- std::optional<Vector<UserContentURLPattern>> m_activeContentRuleListActionPatterns;
+ HashMap<String, Vector<UserContentURLPattern>> m_activeContentRuleListActionPatterns;
#if ENABLE(DEVICE_ORIENTATION)
DeviceOrientationOrMotionPermissionState m_deviceOrientationAndMotionAccessState { DeviceOrientationOrMotionPermissionState::Prompt };
#endif
Modified: trunk/Source/WebKit/ChangeLog (286544 => 286545)
--- trunk/Source/WebKit/ChangeLog 2021-12-06 17:20:08 UTC (rev 286544)
+++ trunk/Source/WebKit/ChangeLog 2021-12-06 17:46:01 UTC (rev 286545)
@@ -1,3 +1,19 @@
+2021-12-06 Alex Christensen <achristen...@webkit.org>
+
+ WKWebpagePreferences._activeContentRuleListActionPatterns should be an NSDictionary of identifier to allowed patterns
+ https://bugs.webkit.org/show_bug.cgi?id=233842
+
+ Reviewed by Timothy Hatcher.
+
+ * Shared/WebsitePoliciesData.cpp:
+ (WebKit::WebsitePoliciesData::decode):
+ * Shared/WebsitePoliciesData.h:
+ * UIProcess/API/APIWebsitePolicies.h:
+ * UIProcess/API/Cocoa/WKWebpagePreferences.mm:
+ (-[WKWebpagePreferences _setActiveContentRuleListActionPatterns:]):
+ (-[WKWebpagePreferences _activeContentRuleListActionPatterns]):
+ * UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h:
+
2021-12-05 Said Abou-Hallawa <s...@apple.com>
[GPU Process] Add the encoding/decoding for Filter and FilterEffect
Modified: trunk/Source/WebKit/Shared/WebsitePoliciesData.cpp (286544 => 286545)
--- trunk/Source/WebKit/Shared/WebsitePoliciesData.cpp 2021-12-06 17:20:08 UTC (rev 286544)
+++ trunk/Source/WebKit/Shared/WebsitePoliciesData.cpp 2021-12-06 17:46:01 UTC (rev 286545)
@@ -64,7 +64,7 @@
if (!contentBlockersEnabled)
return std::nullopt;
- std::optional<std::optional<HashSet<String>>> activeContentRuleListActionPatterns;
+ std::optional<HashMap<WTF::String, Vector<WTF::String>>> activeContentRuleListActionPatterns;
decoder >> activeContentRuleListActionPatterns;
if (!activeContentRuleListActionPatterns)
return std::nullopt;
Modified: trunk/Source/WebKit/Shared/WebsitePoliciesData.h (286544 => 286545)
--- trunk/Source/WebKit/Shared/WebsitePoliciesData.h 2021-12-06 17:20:08 UTC (rev 286544)
+++ trunk/Source/WebKit/Shared/WebsitePoliciesData.h 2021-12-06 17:46:01 UTC (rev 286545)
@@ -53,7 +53,7 @@
static void applyToDocumentLoader(WebsitePoliciesData&&, WebCore::DocumentLoader&);
bool contentBlockersEnabled { true };
- std::optional<HashSet<String>> activeContentRuleListActionPatterns { HashSet<String>() };
+ HashMap<WTF::String, Vector<WTF::String>> activeContentRuleListActionPatterns;
OptionSet<WebsiteAutoplayQuirk> allowedAutoplayQuirks;
WebsiteAutoplayPolicy autoplayPolicy { WebsiteAutoplayPolicy::Default };
#if ENABLE(DEVICE_ORIENTATION)
Modified: trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.h (286544 => 286545)
--- trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.h 2021-12-06 17:20:08 UTC (rev 286544)
+++ trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.h 2021-12-06 17:46:01 UTC (rev 286545)
@@ -63,8 +63,8 @@
bool contentBlockersEnabled() const { return m_contentBlockersEnabled; }
void setContentBlockersEnabled(bool enabled) { m_contentBlockersEnabled = enabled; }
- void setActiveContentRuleListActionPatterns(std::optional<HashSet<WTF::String>>&& patterns) { m_activeContentRuleListActionPatterns = WTFMove(patterns); }
- const std::optional<HashSet<WTF::String>>& activeContentRuleListActionPatterns() const { return m_activeContentRuleListActionPatterns; }
+ void setActiveContentRuleListActionPatterns(HashMap<WTF::String, Vector<WTF::String>>&& patterns) { m_activeContentRuleListActionPatterns = WTFMove(patterns); }
+ const HashMap<WTF::String, Vector<WTF::String>>& activeContentRuleListActionPatterns() const { return m_activeContentRuleListActionPatterns; }
OptionSet<WebKit::WebsiteAutoplayQuirk> allowedAutoplayQuirks() const { return m_allowedAutoplayQuirks; }
void setAllowedAutoplayQuirks(OptionSet<WebKit::WebsiteAutoplayQuirk> quirks) { m_allowedAutoplayQuirks = quirks; }
@@ -140,7 +140,7 @@
private:
// FIXME: replace most or all of these members with a WebsitePoliciesData.
bool m_contentBlockersEnabled { true };
- std::optional<HashSet<WTF::String>> m_activeContentRuleListActionPatterns { HashSet<WTF::String>() };
+ HashMap<WTF::String, Vector<WTF::String>> m_activeContentRuleListActionPatterns;
OptionSet<WebKit::WebsiteAutoplayQuirk> m_allowedAutoplayQuirks;
WebKit::WebsiteAutoplayPolicy m_autoplayPolicy { WebKit::WebsiteAutoplayPolicy::Default };
#if ENABLE(DEVICE_ORIENTATION)
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm (286544 => 286545)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm 2021-12-06 17:20:08 UTC (rev 286544)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm 2021-12-06 17:46:01 UTC (rev 286545)
@@ -141,30 +141,29 @@
return _websitePolicies->contentBlockersEnabled();
}
-- (void)_setActiveContentRuleListActionPatterns:(NSSet<NSString *> *)patterns
+- (void)_setActiveContentRuleListActionPatterns:(NSDictionary<NSString *, NSSet<NSString *> *> *)patterns
{
- if (!patterns) {
- _websitePolicies->setActiveContentRuleListActionPatterns(std::nullopt);
- return;
- }
-
- HashSet<String> patternHashSet;
- patternHashSet.reserveInitialCapacity(patterns.count);
- for (NSString *pattern in patterns)
- patternHashSet.add(pattern);
- _websitePolicies->setActiveContentRuleListActionPatterns(WTFMove(patternHashSet));
+ __block HashMap<String, Vector<String>> map;
+ [patterns enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSSet<NSString *> *value, BOOL *) {
+ Vector<String> vector;
+ vector.reserveInitialCapacity(value.count);
+ for (NSString *pattern in value)
+ vector.uncheckedAppend(pattern);
+ map.add(key, WTFMove(vector));
+ }];
+ _websitePolicies->setActiveContentRuleListActionPatterns(WTFMove(map));
}
-- (NSSet<NSString *> *)_activeContentRuleListActionPatterns
+- (NSDictionary<NSString *, NSSet<NSString *> *> *)_activeContentRuleListActionPatterns
{
- const auto& patterns = _websitePolicies->activeContentRuleListActionPatterns();
- if (!patterns)
- return nil;
-
- NSMutableSet<NSString *> *set = [NSMutableSet set];
- for (const auto& pattern : *patterns)
- [set addObject:pattern];
- return set;
+ NSMutableDictionary<NSString *, NSSet<NSString *> *> *dictionary = [NSMutableDictionary dictionary];
+ for (const auto& pair : _websitePolicies->activeContentRuleListActionPatterns()) {
+ NSMutableSet<NSString *> *set = [NSMutableSet set];
+ for (const auto& pattern : pair.value)
+ [set addObject:pattern];
+ [dictionary setObject:set forKey:pair.key];
+ }
+ return dictionary;
}
- (void)_setAllowedAutoplayQuirks:(_WKWebsiteAutoplayQuirk)allowedQuirks
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h (286544 => 286545)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h 2021-12-06 17:20:08 UTC (rev 286544)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h 2021-12-06 17:46:01 UTC (rev 286545)
@@ -69,7 +69,7 @@
@interface WKWebpagePreferences (WKPrivate)
@property (nonatomic, setter=_setContentBlockersEnabled:) BOOL _contentBlockersEnabled;
-@property (nonatomic, copy, setter=_setActiveContentRuleListActionPatterns:) NSSet<NSString *> *_activeContentRuleListActionPatterns;
+@property (nonatomic, copy, setter=_setActiveContentRuleListActionPatterns:) NSDictionary<NSString *, NSSet<NSString *> *> *_activeContentRuleListActionPatterns WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
@property (nonatomic, setter=_setAllowedAutoplayQuirks:) _WKWebsiteAutoplayQuirk _allowedAutoplayQuirks;
@property (nonatomic, setter=_setAutoplayPolicy:) _WKWebsiteAutoplayPolicy _autoplayPolicy;
@property (nonatomic, copy, setter=_setCustomHeaderFields:) NSArray<_WKCustomHeaderFields *> *_customHeaderFields;
Modified: trunk/Tools/ChangeLog (286544 => 286545)
--- trunk/Tools/ChangeLog 2021-12-06 17:20:08 UTC (rev 286544)
+++ trunk/Tools/ChangeLog 2021-12-06 17:46:01 UTC (rev 286545)
@@ -1,3 +1,14 @@
+2021-12-06 Alex Christensen <achristen...@webkit.org>
+
+ WKWebpagePreferences._activeContentRuleListActionPatterns should be an NSDictionary of identifier to allowed patterns
+ https://bugs.webkit.org/show_bug.cgi?id=233842
+
+ Reviewed by Timothy Hatcher.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm:
+ (navigationDelegateAllowingActiveActionsOnTestHost):
+ (TEST_F):
+
2021-12-05 Said Abou-Hallawa <s...@apple.com>
[GPU Process] Add the encoding/decoding for Filter and FilterEffect
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm (286544 => 286545)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm 2021-12-06 17:20:08 UTC (rev 286544)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm 2021-12-06 17:46:01 UTC (rev 286545)
@@ -499,7 +499,7 @@
{
static auto delegate = adoptNS([TestNavigationDelegate new]);
delegate.get().decidePolicyForNavigationActionWithPreferences = ^(WKNavigationAction *, WKWebpagePreferences *preferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) {
- preferences._activeContentRuleListActionPatterns = [NSSet setWithObject:@"*://testhost/*"];
+ preferences._activeContentRuleListActionPatterns = [NSDictionary dictionaryWithObject:[NSSet setWithObject:@"*://testhost/*"] forKey:@"testidentifier"];
decisionHandler(WKNavigationActionPolicyAllow, preferences);
};
return delegate;
@@ -722,13 +722,13 @@
EXPECT_EQ(preferences._activeContentRuleListActionPatterns.count, 0u);
switch (delegateAction) {
case DelegateAction::AllowAll:
- preferences._activeContentRuleListActionPatterns = nil;
+ preferences._activeContentRuleListActionPatterns = [NSDictionary dictionaryWithObject:[NSSet setWithObject:@"*://*/*"] forKey:@"testidentifier"];
break;
case DelegateAction::AllowNone:
- preferences._activeContentRuleListActionPatterns = [NSSet set];
+ preferences._activeContentRuleListActionPatterns = [NSDictionary dictionary];
break;
case DelegateAction::AllowTestHost:
- preferences._activeContentRuleListActionPatterns = [NSSet setWithObject:@"*://testhost/*"];
+ preferences._activeContentRuleListActionPatterns = [NSDictionary dictionaryWithObject:[NSSet setWithObject:@"*://testhost/*"] forKey:@"testidentifier"];
break;
}
decisionHandler(WKNavigationActionPolicyAllow, preferences);
@@ -773,7 +773,7 @@
auto delegate = adoptNS([TestNavigationDelegate new]);
delegate.get().decidePolicyForNavigationActionWithPreferences = ^(WKNavigationAction *, WKWebpagePreferences *preferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) {
- preferences._activeContentRuleListActionPatterns = nil;
+ preferences._activeContentRuleListActionPatterns = [NSDictionary dictionaryWithObject:[NSSet setWithObject:@"*://testhost/*"] forKey:@"testidentifier"];
decisionHandler(WKNavigationActionPolicyAllow, preferences);
};