Skip to content

Commit

Permalink
Fix bugprone-use-after-move warnings in `WebExtensionContext::loadDec…
Browse files Browse the repository at this point in the history
…larativeNetRequestRules`

https://bugs.webkit.org/show_bug.cgi?id=270930
rdar://124554555

Reviewed by Timothy Hatcher.

`completionHandler` was unnecessarily being moved into several lambda captures.

* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::loadDeclarativeNetRequestRules):

Canonical link: https://commits.webkit.org/276048@main
  • Loading branch information
charliewolfe committed Mar 13, 2024
1 parent 7debec9 commit de08406
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4208,7 +4208,7 @@ void effectiveAppearanceDidChange(Inspector::ExtensionAppearance appearance) ove
compileDeclarativeNetRequestRules(allJSONData.get(), WTFMove(completionHandler));
};

auto addStaticRulesets = [this, protectedThis = Ref { *this }, completionHandler = WTFMove(completionHandler), applyDeclarativeNetRequestRules = WTFMove(applyDeclarativeNetRequestRules), allJSONData = RetainPtr { allJSONData }] () mutable {
auto addStaticRulesets = [this, protectedThis = Ref { *this }, applyDeclarativeNetRequestRules = WTFMove(applyDeclarativeNetRequestRules), allJSONData = RetainPtr { allJSONData }] () mutable {
for (auto& ruleset : extension().declarativeNetRequestRulesets()) {
if (!ruleset.enabled)
continue;
Expand All @@ -4223,8 +4223,8 @@ void effectiveAppearanceDidChange(Inspector::ExtensionAppearance appearance) ove
applyDeclarativeNetRequestRules();
};

auto addDynamicAndStaticRules = [this, protectedThis = Ref { *this }, completionHandler = WTFMove(completionHandler), addStaticRulesets = WTFMove(addStaticRulesets), allJSONData = RetainPtr { allJSONData }] () mutable {
[declarativeNetRequestDynamicRulesStore() getRulesWithCompletionHandler:makeBlockPtr([this, protectedThis = Ref { *this }, completionHandler = WTFMove(completionHandler), addStaticRulesets = WTFMove(addStaticRulesets), allJSONData = RetainPtr { allJSONData }](NSArray *rules, NSString *errorMessage) mutable {
auto addDynamicAndStaticRules = [this, protectedThis = Ref { *this }, addStaticRulesets = WTFMove(addStaticRulesets), allJSONData = RetainPtr { allJSONData }] () mutable {
[declarativeNetRequestDynamicRulesStore() getRulesWithCompletionHandler:makeBlockPtr([this, protectedThis = Ref { *this }, addStaticRulesets = WTFMove(addStaticRulesets), allJSONData = RetainPtr { allJSONData }](NSArray *rules, NSString *errorMessage) mutable {
if (!rules.count) {
m_dynamicRulesIDs.clear();
addStaticRulesets();
Expand All @@ -4248,7 +4248,7 @@ void effectiveAppearanceDidChange(Inspector::ExtensionAppearance appearance) ove
}).get()];
};

[declarativeNetRequestSessionRulesStore() getRulesWithCompletionHandler:makeBlockPtr([this, protectedThis = Ref { *this }, completionHandler = WTFMove(completionHandler), addDynamicAndStaticRules = WTFMove(addDynamicAndStaticRules), allJSONData = RetainPtr { allJSONData }](NSArray *rules, NSString *errorMessage) mutable {
[declarativeNetRequestSessionRulesStore() getRulesWithCompletionHandler:makeBlockPtr([this, protectedThis = Ref { *this }, addDynamicAndStaticRules = WTFMove(addDynamicAndStaticRules), allJSONData = RetainPtr { allJSONData }](NSArray *rules, NSString *errorMessage) mutable {
if (!rules.count) {
m_sessionRulesIDs.clear();
addDynamicAndStaticRules();
Expand Down

0 comments on commit de08406

Please sign in to comment.