Skip to content

Commit

Permalink
Prefer Ref/RefPtr over CheckedPtr/CheckedRef for stack pointers to re…
Browse files Browse the repository at this point in the history
…fcounted objects

https://bugs.webkit.org/show_bug.cgi?id=266802

Reviewed by Ryosuke Niwa.

* Source/WebCore/page/Page.cpp:
(WebCore::Page::outermostFullscreenDocument const):
* Source/WebCore/rendering/RenderTextControlSingleLine.cpp:
(WebCore::RenderTextControlSingleLine::layout):
* Source/WebKit/UIProcess/Media/AudioSessionRoutingArbitratorProxy.h:
* Source/WebKit/UIProcess/Media/cocoa/AudioSessionRoutingArbitratorProxyCocoa.mm:
(WebKit::AudioSessionRoutingArbitratorProxy::~AudioSessionRoutingArbitratorProxy):
* Source/WebKit/UIProcess/Network/CustomProtocols/LegacyCustomProtocolManagerProxy.cpp:
(WebKit::LegacyCustomProtocolManagerProxy::~LegacyCustomProtocolManagerProxy):
(WebKit::LegacyCustomProtocolManagerProxy::invalidate):
* Source/WebKit/UIProcess/Network/CustomProtocols/LegacyCustomProtocolManagerProxy.h:

Canonical link: https://commits.webkit.org/272467@main
  • Loading branch information
cdumez committed Dec 23, 2023
1 parent d7611e7 commit 623da6e
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Source/WebCore/page/Page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3789,8 +3789,8 @@ Document* Page::outermostFullscreenDocument() const
if (!localMainFrame)
return nullptr;

CheckedPtr<Document> outermostFullscreenDocument = nullptr;
CheckedPtr currentDocument = localMainFrame->document();
RefPtr<Document> outermostFullscreenDocument;
RefPtr currentDocument = localMainFrame->document();
while (currentDocument) {
auto* fullscreenElement = currentDocument->fullscreenManager().fullscreenElement();
if (!fullscreenElement)
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/rendering/RenderTextControlSingleLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void RenderTextControlSingleLine::layout()
if (!inputElement().hasAutoFillStrongPasswordButton())
return nullptr;

CheckedPtr autoFillButtonElement = inputElement().autoFillButtonElement();
RefPtr autoFillButtonElement = inputElement().autoFillButtonElement();
if (!autoFillButtonElement)
return nullptr;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class AudioSessionRoutingArbitratorProxy
void beginRoutingArbitrationWithCategory(WebCore::AudioSession::CategoryType, ArbitrationCallback&&);
void endRoutingArbitration();

CheckedRef<WebProcessProxy> m_process;
WeakRef<WebProcessProxy> m_process;
WebCore::AudioSession::CategoryType m_category { WebCore::AudioSession::CategoryType::None };
ArbitrationStatus m_arbitrationStatus { ArbitrationStatus::None };
WallTime m_arbitrationUpdateTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

AudioSessionRoutingArbitratorProxy::~AudioSessionRoutingArbitratorProxy()
{
// Unable to ref the process because it may have started destruction.
CheckedRef checkedProcess = m_process.get();
checkedProcess->removeMessageReceiver(Messages::AudioSessionRoutingArbitratorProxy::messageReceiverName(), destinationId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Ref<NetworkProcessProxy> LegacyCustomProtocolManagerProxy::protectedProcess()

LegacyCustomProtocolManagerProxy::~LegacyCustomProtocolManagerProxy()
{
// Unable to ref the network process as it may have started destruction.
CheckedRef checkedProcess = m_networkProcessProxy.get();
checkedProcess->removeMessageReceiver(Messages::LegacyCustomProtocolManagerProxy::messageReceiverName());
invalidate();
Expand All @@ -61,6 +62,7 @@ void LegacyCustomProtocolManagerProxy::stopLoading(LegacyCustomProtocolID custom

void LegacyCustomProtocolManagerProxy::invalidate()
{
// Unable to ref the network process as it may have started destruction.
CheckedRef checkedProcess = m_networkProcessProxy.get();
checkedProcess->customProtocolManagerClient().invalidate(*this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class LegacyCustomProtocolManagerProxy : public IPC::MessageReceiver {
// IPC::MessageReceiver
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;

CheckedRef<NetworkProcessProxy> m_networkProcessProxy;
WeakRef<NetworkProcessProxy> m_networkProcessProxy;
};

} // namespace WebKit

0 comments on commit 623da6e

Please sign in to comment.