Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove reference cycle from WebExtensionAction.
https://webkit.org/b/278800 rdar://134866275 Reviewed by Timothy Hatcher. This patch removes a reference cycle previously present in WebExtensionAction. Since actions are stored in a WeakHashMap within WebExtensionContext where the key is either a WebExtensionWindow or a WebExtensionTab, and since each action would store a strong reference to whatever window or tab was used as its key, this forms a reference cycle. This fix changes the m_tab and m_window instance variables on WebExtensionAction to be of type std::optional<WeakPtr<..>>. This patch also contains supporting changes within the class to handle this new type. * Source/WebKit/UIProcess/API/Cocoa/WKWebExtensionAction.mm: (-[WKWebExtensionAction associatedTab]): Take reference to an action's tab in a RefPtr rather than a raw pointer to prevent it dropping out while in use. * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionActionCocoa.mm: (WebKit::WebExtensionAction::tab const): Made method const, moved implementation to .mm file, updated to handle optional member variable. (WebKit::WebExtensionAction::window const): Made method const, moved implementation to .mm file, updated to handle optional member variable. (WebKit::WebExtensionAction::fallbackAction const): Updated to handle new type of m_tab (optional<WeakPtr<..>>) (WebKit::WebExtensionAction::platformMenuItems const): Use tab getter rather than member variable * Source/WebKit/UIProcess/Extensions/WebExtensionAction.h: (WebKit::WebExtensionAction::tab): Deleted (moved implementation to WebExtensionActionCocoa.mm). (WebKit::WebExtensionAction::window): Deleted (moved implementation to WebExtensionActionCocoa.mm). Canonical link: https://commits.webkit.org/283143@main
- Loading branch information