[webkit-changes] [WebKit/WebKit] fe6870: Remove reference cycle from WebExtensionAction.

Ariel Young noreply at github.com
Wed Sep 4 01:54:50 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: fe6870e03d07b9bdf52df972d3b15214e3ce30eb
      https://github.com/WebKit/WebKit/commit/fe6870e03d07b9bdf52df972d3b15214e3ce30eb
  Author: Ari Young <ari_young at apple.com>
  Date:   2024-09-04 (Wed, 04 Sep 2024)

  Changed paths:
    M Source/WebKit/UIProcess/API/Cocoa/WKWebExtensionAction.mm
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionActionCocoa.mm
    M Source/WebKit/UIProcess/Extensions/WebExtensionAction.h

  Log Message:
  -----------
  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



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list