Skip to content

Commit

Permalink
Deploy more smart pointers in WebKit2 2023-08-17 edition
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=260371

Reviewed by Dan Glastonbury.

Deployed more use of smart pointers.

* Source/WebKit/WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp:
(WebKit::WebSearchPopupMenu::saveRecentSearches):
(WebKit::WebSearchPopupMenu::loadRecentSearches):
* Source/WebKit/WebProcess/WebCoreSupport/WebStorageConnection.cpp:
(WebKit::WebStorageConnection::getPersisted):
(WebKit::WebStorageConnection::persist):
(WebKit::WebStorageConnection::getEstimate):
(WebKit::WebStorageConnection::fileSystemGetDirectory):
* Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
(WebKit::WebPage::getPlatformEditorStateCommon const):
* Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp:
(WebKit::EventDispatcher::addScrollingTreeForPage):
(WebKit::EventDispatcher::dispatchWheelEvent):
* Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp:
(WebKit::IPCTestingAPI::JSIPCStreamClientConnection::sendSyncMessage):
* Source/WebKit/WebProcess/WebPage/WebContextMenu.cpp:
(WebKit::WebContextMenu::menuItemsWithUserData const):
* Source/WebKit/WebProcess/WebPage/WebFoundTextRangeController.cpp:
(WebKit::WebFoundTextRangeController::simpleRangeFromFoundTextRange):
* Source/WebKit/WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::contentsAsString const):
(WebKit::WebFrame::setAccessibleName):
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::reload):
(WebKit::WebPage::updateFrameSize):
(WebKit::WebPage::runJavaScript):
(WebKit::WebPage::enqueueSecurityPolicyViolationEvent):
(WebKit::WebPage::notifyReportObservers):
(WebKit::WebPage::updateWebsitePolicies):
(WebKit::WebPage::addUserScript):
(WebKit::WebPage::addUserStyleSheet):
(WebKit::WebPage::removeAllUserContent):
(WebKit::WebPage::didGetLoadDecisionForIcon):
(WebKit::WebPage::setUseIconLoadingClient):
(WebKit::WebPage::completeTextManipulation):
* Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSource.cpp:
(WebKit::RemoteRealtimeMediaSource::gpuProcessConnectionDidClose):
* Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm:
(WebKit::VideoFullscreenManager::setVideoLayerGravityEnum):

Canonical link: https://commits.webkit.org/267057@main
  • Loading branch information
rniwa committed Aug 18, 2023
1 parent fab721e commit ee34378
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ void WebProgressTrackerClient::progressFinished(LocalFrame& originatingProgressF
if (!originatingProgressFrame.isMainFrame())
return;

Ref page = *m_webPage;
page->setMainFrameProgressCompleted(true);
Ref webPage = *m_webPage;
webPage->setMainFrameProgressCompleted(true);

// Notify the bundle client.
page->injectedBundleLoaderClient().didFinishProgress(page);
webPage->injectedBundleLoaderClient().didFinishProgress(webPage);

page->send(Messages::WebPageProxy::DidFinishProgress());
webPage->send(Messages::WebPageProxy::DidFinishProgress());
}

} // namespace WebKit
2 changes: 1 addition & 1 deletion Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@
}
}

if (RefPtr enclosingListElement = enclosingList(selection.start().containerNode())) {
if (RefPtr enclosingListElement = enclosingList(RefPtr { selection.start().containerNode() }.get())) {
if (is<HTMLUListElement>(*enclosingListElement))
postLayoutData.enclosingListType = ListType::UnorderedList;
else if (is<HTMLOListElement>(*enclosingListElement))
Expand Down
6 changes: 3 additions & 3 deletions Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1085,14 +1085,14 @@ JSValueRef JSIPCStreamClientConnection::sendSyncMessage(JSContextRef context, JS

auto [destinationID, messageName, timeout] = *info;
auto& streamConnection = jsStreamConnection->connection();
auto& connection = streamConnection.connectionForTesting();
Ref connection = streamConnection.connectionForTesting();

IPC::Connection::SyncRequestID syncRequestID;
auto encoder = connection.createSyncMessageEncoder(messageName, destinationID, syncRequestID);
auto encoder = connection->createSyncMessageEncoder(messageName, destinationID, syncRequestID);
if (!prepareToSendOutOfStreamMessage(context, argumentCount, arguments, *jsStreamConnection->m_jsIPC, streamConnection, encoder.get(), destinationID, timeout, exception))
return JSValueMakeUndefined(context);

auto replyDecoderOrError = connection.sendSyncMessage(syncRequestID, WTFMove(encoder), timeout, { });
auto replyDecoderOrError = connection->sendSyncMessage(syncRequestID, WTFMove(encoder), timeout, { });
if (replyDecoderOrError.decoder) {
auto scope = DECLARE_CATCH_SCOPE(globalObject->vm());
auto* jsResult = jsResultFromReplyDecoder(globalObject, messageName, *replyDecoderOrError.decoder);
Expand Down
3 changes: 2 additions & 1 deletion Source/WebKit/WebProcess/WebPage/WebContextMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ void WebContextMenu::menuItemsWithUserData(Vector<WebContextMenuItemData> &menuI
// Give the bundle client a chance to process the menu.
const Vector<ContextMenuItem>& coreItems = menu->items();

if (m_page->injectedBundleContextMenuClient().getCustomMenuFromDefaultItems(*m_page, controller.hitTestResult(), coreItems, menuItems, controller.context(), userData))
RefPtr page = m_page.get();
if (page->injectedBundleContextMenuClient().getCustomMenuFromDefaultItems(*page, controller.hitTestResult(), coreItems, menuItems, controller.context(), userData))
return;
menuItems = kitItems(coreItems);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,11 +405,12 @@ WebCore::Document* WebFoundTextRangeController::documentForFoundTextRange(const
std::optional<WebCore::SimpleRange> WebFoundTextRangeController::simpleRangeFromFoundTextRange(WebFoundTextRange range)
{
return m_cachedFoundRanges.ensure(range, [&] () -> std::optional<WebCore::SimpleRange> {
auto* document = documentForFoundTextRange(range);
RefPtr document = documentForFoundTextRange(range);
if (!document)
return std::nullopt;

return resolveCharacterRange(makeRangeSelectingNodeContents(*document->documentElement()), { range.location, range.length }, WebCore::findIteratorOptions());
Ref documentElement = *document->documentElement();
return resolveCharacterRange(makeRangeSelectingNodeContents(documentElement), { range.location, range.length }, WebCore::findIteratorOptions());
}).iterator->value;
}

Expand Down
4 changes: 2 additions & 2 deletions Source/WebKit/WebProcess/WebPage/WebFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ String WebFrame::contentsAsString() const
if (!document)
return String();

auto documentElement = document->documentElement();
RefPtr documentElement = document->documentElement();
if (!documentElement)
return String();

Expand Down Expand Up @@ -806,7 +806,7 @@ void WebFrame::setAccessibleName(const AtomString& accessibleName)
if (!document)
return;

auto* rootObject = document->axObjectCache()->rootObject();
RefPtr rootObject = document->axObjectCache()->rootObject();
if (!rootObject)
return;

Expand Down
45 changes: 23 additions & 22 deletions Source/WebKit/WebProcess/WebPage/WebPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2078,9 +2078,10 @@ void WebPage::reload(uint64_t navigationID, OptionSet<WebCore::ReloadOption> rel
ASSERT(!m_mainFrame->coreLocalFrame()->loader().frameHasLoaded() || !m_pendingNavigationID);
m_pendingNavigationID = navigationID;

m_sandboxExtensionTracker.beginReload(m_mainFrame.ptr(), WTFMove(sandboxExtensionHandle));
if (m_page && m_mainFrame->coreLocalFrame())
m_page->userInputBridge().reloadFrame(*m_mainFrame->coreLocalFrame(), reloadOptions);
Ref mainFrame = m_mainFrame;
m_sandboxExtensionTracker.beginReload(mainFrame.ptr(), WTFMove(sandboxExtensionHandle));
if (m_page && mainFrame->coreLocalFrame())
m_page->userInputBridge().reloadFrame(*mainFrame->coreLocalFrame(), reloadOptions);
else
ASSERT_NOT_REACHED();

Expand Down Expand Up @@ -3155,15 +3156,15 @@ void WebPage::updateDrawingAreaLayerTreeFreezeState()

void WebPage::updateFrameSize(WebCore::FrameIdentifier frameID, WebCore::IntSize newSize)
{
auto* webFrame = WebProcess::singleton().webFrame(frameID);
RefPtr webFrame = WebProcess::singleton().webFrame(frameID);
if (!webFrame)
return;

auto* frame = webFrame->coreLocalFrame();
RefPtr frame = webFrame->coreLocalFrame();
if (!frame)
return;

auto* frameView = frame->view();
RefPtr frameView = frame->view();
if (!frameView)
return;

Expand Down Expand Up @@ -4200,7 +4201,7 @@ void WebPage::runJavaScript(WebFrame* frame, RunJavaScriptParameters&& parameter
RefPtr<SerializedScriptValue> serializedResultValue;
if (result) {
serializedResultValue = SerializedScriptValue::create(frame->jsContextForWorld(world.ptr()),
toRef(coreFrame->script().globalObject(world->coreWorld()), result.value()), nullptr);
toRef(coreFrame->script().globalObject(Ref { world->coreWorld() }), result.value()), nullptr);
}

IPC::DataReference dataReference;
Expand Down Expand Up @@ -4988,22 +4989,22 @@ void WebPage::addConsoleMessage(FrameIdentifier frameID, MessageSource messageSo

void WebPage::enqueueSecurityPolicyViolationEvent(FrameIdentifier frameID, SecurityPolicyViolationEventInit&& eventInit)
{
auto* frame = WebProcess::singleton().webFrame(frameID);
RefPtr frame = WebProcess::singleton().webFrame(frameID);
if (!frame)
return;
auto* coreFrame = frame->coreLocalFrame();
RefPtr coreFrame = frame->coreLocalFrame();
if (!coreFrame)
return;
if (auto* document = coreFrame->document())
if (RefPtr document = coreFrame->document())
document->enqueueSecurityPolicyViolationEvent(WTFMove(eventInit));
}

void WebPage::notifyReportObservers(FrameIdentifier frameID, Ref<WebCore::Report>&& report)
{
auto* frame = WebProcess::singleton().webFrame(frameID);
RefPtr frame = WebProcess::singleton().webFrame(frameID);
if (!frame)
return;
auto* coreFrame = frame->coreLocalFrame();
RefPtr coreFrame = frame->coreLocalFrame();
if (!coreFrame)
return;
if (RefPtr document = coreFrame->document())
Expand Down Expand Up @@ -7508,8 +7509,8 @@ void WebPage::updateWebsitePolicies(WebsitePoliciesData&& websitePolicies)
if (!m_page)
return;

auto* localMainFrame = dynamicDowncast<LocalFrame>(m_page->mainFrame());
auto* documentLoader = localMainFrame ? localMainFrame->loader().documentLoader() : nullptr;
RefPtr localMainFrame = dynamicDowncast<LocalFrame>(m_page->mainFrame());
RefPtr documentLoader = localMainFrame ? localMainFrame->loader().documentLoader() : nullptr;
if (!documentLoader)
return;

Expand All @@ -7521,7 +7522,7 @@ void WebPage::updateWebsitePolicies(WebsitePoliciesData&& websitePolicies)
#endif

#if ENABLE(META_VIEWPORT)
setCanIgnoreViewportArgumentsToAvoidExcessiveZoomIfNeeded(m_viewportConfiguration, localMainFrame, shouldIgnoreMetaViewport());
setCanIgnoreViewportArgumentsToAvoidExcessiveZoomIfNeeded(m_viewportConfiguration, localMainFrame.get(), shouldIgnoreMetaViewport());
#endif
}

Expand Down Expand Up @@ -7691,19 +7692,19 @@ void WebPage::addUserScript(String&& source, InjectedBundleScriptWorld& world, W
{
WebCore::UserScript userScript { WTFMove(source), URL(aboutBlankURL()), Vector<String>(), Vector<String>(), injectionTime, injectedFrames, WebCore::WaitForNotificationBeforeInjecting::No };

m_userContentController->addUserScript(world, WTFMove(userScript));
Ref { m_userContentController }->addUserScript(world, WTFMove(userScript));
}

void WebPage::addUserStyleSheet(const String& source, WebCore::UserContentInjectedFrames injectedFrames)
{
WebCore::UserStyleSheet userStyleSheet {source, aboutBlankURL(), Vector<String>(), Vector<String>(), injectedFrames, UserStyleUserLevel };

m_userContentController->addUserStyleSheet(InjectedBundleScriptWorld::normalWorld(), WTFMove(userStyleSheet));
Ref { m_userContentController }->addUserStyleSheet(InjectedBundleScriptWorld::normalWorld(), WTFMove(userStyleSheet));
}

void WebPage::removeAllUserContent()
{
m_userContentController->removeAllUserContent();
Ref { m_userContentController }->removeAllUserContent();
}

void WebPage::updateIntrinsicContentSizeIfNeeded(const WebCore::IntSize& size)
Expand Down Expand Up @@ -7798,10 +7799,10 @@ void WebPage::didLosePointerLock()

void WebPage::didGetLoadDecisionForIcon(bool decision, CallbackID loadIdentifier, CompletionHandler<void(const IPC::SharedBufferReference&)>&& completionHandler)
{
auto* localMainFrame = dynamicDowncast<WebCore::LocalFrame>(corePage()->mainFrame());
RefPtr localMainFrame = dynamicDowncast<WebCore::LocalFrame>(corePage()->mainFrame());
if (!localMainFrame)
return completionHandler({ });
auto* documentLoader = localMainFrame->loader().documentLoader();
RefPtr documentLoader = localMainFrame->loader().documentLoader();
if (!documentLoader)
return completionHandler({ });

Expand All @@ -7812,7 +7813,7 @@ void WebPage::didGetLoadDecisionForIcon(bool decision, CallbackID loadIdentifier

void WebPage::setUseIconLoadingClient(bool useIconLoadingClient)
{
if (auto* localMainFrame = dynamicDowncast<WebCore::LocalFrame>(corePage()->mainFrame()))
if (RefPtr localMainFrame = dynamicDowncast<WebCore::LocalFrame>(corePage()->mainFrame()))
static_cast<WebLocalFrameLoaderClient&>(localMainFrame->loader().client()).setUseIconLoadingClient(useIconLoadingClient);
}

Expand Down Expand Up @@ -8296,7 +8297,7 @@ void WebPage::completeTextManipulation(const Vector<WebCore::TextManipulationIte

auto completeManipulationForItems = [&](const Vector<WebCore::TextManipulationItem>& items) -> std::optional<Vector<TextManipulationControllerManipulationFailure>> {
ASSERT(!items.isEmpty());
auto* frame = WebProcess::singleton().webFrame(currentFrameID);
RefPtr frame = WebProcess::singleton().webFrame(currentFrameID);
if (!frame)
return std::nullopt;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void RemoteRealtimeMediaSource::gpuProcessConnectionDidClose(GPUProcessConnectio
return;

m_proxy.updateConnection();
m_manager.remoteCaptureSampleManager().didUpdateSourceConnection(m_proxy.connection());
m_manager.remoteCaptureSampleManager().didUpdateSourceConnection(Ref { m_proxy.connection() });
m_proxy.resetReady();
createRemoteMediaSource();

Expand Down
6 changes: 3 additions & 3 deletions Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -703,10 +703,10 @@ static FloatRect inlineVideoFrame(HTMLVideoElement& element)

void VideoFullscreenManager::setVideoLayerGravityEnum(PlaybackSessionContextIdentifier contextId, unsigned gravity)
{
auto& model = ensureModel(contextId);
INFO_LOG(LOGIDENTIFIER, model.logIdentifier(), gravity);
Ref model = ensureModel(contextId);
INFO_LOG(LOGIDENTIFIER, model->logIdentifier(), gravity);

model.setVideoLayerGravity((MediaPlayerEnums::VideoGravity)gravity);
model->setVideoLayerGravity((MediaPlayerEnums::VideoGravity)gravity);
}

void VideoFullscreenManager::fullscreenMayReturnToInline(PlaybackSessionContextIdentifier contextId, bool isPageVisible)
Expand Down

0 comments on commit ee34378

Please sign in to comment.