Skip to content

Commit 7d39c09

Browse files
committed
Address remaining safer CPP warnings in WebKit/WebProcess/InjectedBundle
https://bugs.webkit.org/show_bug.cgi?id=301909 Reviewed by Anne van Kesteren. * Source/WebCore/dom/Document.cpp: (WebCore::Document::protectedBodyOrFrameset const): * Source/WebCore/dom/Document.h: * Source/WebCore/dom/Range.h: * Source/WebKit/SaferCPPExpectations/UncheckedCallArgsCheckerExpectations: * Source/WebKit/SaferCPPExpectations/UncountedCallArgsCheckerExpectations: * Source/WebKit/SaferCPPExpectations/UnretainedCallArgsCheckerExpectations: * Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundle.cpp: (WKBundlePostSynchronousMessage): (WKBundleCreateWKDataFromUInt8Array): * Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleDOMWindowExtension.cpp: (WKBundleDOMWindowExtensionCreate): * Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp: (WKBundleFrameCopyChildFrames): (WKBundleFrameGetPage): (WKBundleFrameCreateHitTestResult): * Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp: (WKBundleHitTestResultCopyNodeHandle): (WKBundleHitTestResultCopyURLElementHandle): * Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp: (WKBundleNodeHandleCreate): (WKBundleNodeHandleCopyDocument): (WKBundleNodeHandleCopySnapshotWithOptions): (WKBundleNodeHandleCopyDocumentFrame): (WKBundleNodeHandleCopyHTMLIFrameElementContentFrame): (WKBundleNodeHandleCopyOwningDocumentFrame): * Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp: (WKBundleFrameCreateFrameHandle): (WKBundlePageCopyContextMenuItems): (WKBundlePageCopyContextMenuAtPointInWindow): (WKBundlePageCreateSnapshotWithOptions): (WKBundlePageCreateSnapshotInViewCoordinates): (WKBundlePageCreateSnapshotInDocumentCoordinates): (WKBundlePageCreateScaledSnapshotInDocumentCoordinates): (WKBundlePageCopyTrackedRepaintRects): (WKBundlePagePostSynchronousMessageForTesting): (WKBundlePageCreateCaptionUserPreferencesTestingModeToken): (WKBundlePageCopyFrameTextForTesting): * Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp: (WKBundlePageOverlayCreate): * Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.cpp: (WKBundleRangeHandleCreate): (WKBundleRangeHandleCopySnapshotWithOptions): (WKBundleRangeHandleCopyDocumentFrame): * Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.cpp: (WKBundleScriptWorldCreateWorld): * Source/WebKit/WebProcess/InjectedBundle/API/c/mac/WKBundleMac.mm: (WKBundleGetParameters): * Source/WebKit/WebProcess/InjectedBundle/API/c/mac/WKBundlePageBannerMac.mm: (WKBundlePageBannerCreateBannerWithCALayer): (WKBundlePageBannerGetLayer): * Source/WebKit/WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm: (-[WKDOMDocument body]): * Source/WebKit/WebProcess/InjectedBundle/API/mac/WKDOMInternals.h: * Source/WebKit/WebProcess/InjectedBundle/API/mac/WKDOMInternals.mm: (WebKit::WKDOMNodeClassSingleton): (WebKit::createWrapper): (WebKit::toProtectedWebCoreNode): (WebKit::toProtectedWebCoreDocument): (WebKit::toWebCoreRange): (WebKit::toProtectedWebCoreRange): (WebKit::WKDOMNodeClass): Deleted. * Source/WebKit/WebProcess/InjectedBundle/API/mac/WKDOMNode.mm: (-[WKDOMNode insertNode:before:]): (-[WKDOMNode appendChild:]): (-[WKDOMNode removeChild:]): (-[WKDOMNode document]): (-[WKDOMNode parentNode]): (-[WKDOMNode firstChild]): (-[WKDOMNode lastChild]): (-[WKDOMNode previousSibling]): (-[WKDOMNode nextSibling]): (-[WKDOMNode textRects]): (-[WKDOMNode _copyBundleNodeHandleRef]): * Source/WebKit/WebProcess/InjectedBundle/API/mac/WKDOMRange.mm: (-[WKDOMRange initWithDocument:]): (-[WKDOMRange selectNode:]): (-[WKDOMRange selectNodeContents:]): (-[WKDOMRange startContainer]): (-[WKDOMRange endContainer]): (-[WKDOMRange text]): (-[WKDOMRange textRects]): (-[WKDOMRange _copyBundleRangeHandleRef]): * Source/WebKit/WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.mm: (-[WKDOMTextIterator initWithRange:]): * Source/WebKit/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.mm: (protectedBundle): (-[WKWebProcessPlugInController dealloc]): (didCreatePage): (willDestroyPage): (-[WKWebProcessPlugInController _setPrincipalClassInstance:]): (-[WKWebProcessPlugInController parameters]): (-[WKWebProcessPlugInController extendClassesForParameterCoder:]): (-[WKWebProcessPlugInController _bundleRef]): * Source/WebKit/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm: (protectedPage): (didStartProvisionalLoadForFrame): (didReceiveServerRedirectForProvisionalLoadForFrame): (didFinishLoadForFrame): (didClearWindowObjectForFrame): (globalObjectIsAvailableForFrame): (serviceWorkerGlobalObjectIsAvailableForFrame): (willInjectUserScriptForFrame): (didRemoveFrameFromHierarchy): (didCommitLoadForFrame): (didFinishDocumentLoadForFrame): (didFailProvisionalLoadWithErrorForFrame): (didFailLoadWithErrorForFrame): (didSameDocumentNavigationForFrame): (didLayoutForFrame): (didFirstVisuallyNonEmptyLayoutForFrame): (didHandleOnloadEventsForFrame): (willSendRequestForFrame): (didInitiateLoadForResource): (didReceiveResponseForResource): (didFinishLoadForResource): (didFailLoadForResource): (-[WKWebProcessPlugInBrowserContextController setLoadDelegate:]): (-[WKWebProcessPlugInBrowserContextController dealloc]): (-[WKWebProcessPlugInBrowserContextController mainFrameDocument]): (-[WKWebProcessPlugInBrowserContextController selectedRange]): (-[WKWebProcessPlugInBrowserContextController _bundlePageRef]): (-[WKWebProcessPlugInBrowserContextController _setFormDelegate:]): (-[WKWebProcessPlugInBrowserContextController _setEditingDelegate:]): (-[WKWebProcessPlugInBrowserContextController _usesNonPersistentWebsiteDataStore]): Canonical link: https://commits.webkit.org/302531@main
1 parent 86a2114 commit 7d39c09

25 files changed

+151
-136
lines changed

Source/WebCore/dom/Document.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4194,6 +4194,11 @@ HTMLElement* Document::bodyOrFrameset() const
41944194
return nullptr;
41954195
}
41964196

4197+
RefPtr<HTMLElement> Document::protectedBodyOrFrameset() const
4198+
{
4199+
return bodyOrFrameset();
4200+
}
4201+
41974202
ExceptionOr<void> Document::setBodyOrFrameset(RefPtr<HTMLElement>&& newBody)
41984203
{
41994204
if (!is<HTMLBodyElement>(newBody) && !is<HTMLFrameSetElement>(newBody))

Source/WebCore/dom/Document.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,6 +1241,7 @@ class Document
12411241
// This is the "body element" as defined by HTML5, the first body or frameset child of the
12421242
// document element. See https://html.spec.whatwg.org/multipage/dom.html#the-body-element-2.
12431243
WEBCORE_EXPORT HTMLElement* bodyOrFrameset() const;
1244+
WEBCORE_EXPORT RefPtr<HTMLElement> protectedBodyOrFrameset() const;
12441245
WEBCORE_EXPORT ExceptionOr<void> setBodyOrFrameset(RefPtr<HTMLElement>&&);
12451246

12461247
Location* location() const;

Source/WebCore/dom/Range.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ class Range final : public AbstractRange, public CanMakeSingleThreadWeakPtr<Rang
4949
WEBCORE_EXPORT ~Range();
5050

5151
Node& startContainer() const final { return m_start.container(); }
52-
Ref<Node> protectedStartContainer() const;
52+
WEBCORE_EXPORT Ref<Node> protectedStartContainer() const;
5353
unsigned startOffset() const final { return m_start.offset(); }
5454
Node& endContainer() const final { return m_end.container(); }
55-
Ref<Node> protectedEndContainer() const;
55+
WEBCORE_EXPORT Ref<Node> protectedEndContainer() const;
5656
unsigned endOffset() const final { return m_end.offset(); }
5757
bool collapsed() const final { return m_start == m_end; }
5858
WEBCORE_EXPORT Node* commonAncestorContainer() const;

Source/WebKit/SaferCPPExpectations/UncheckedCallArgsCheckerExpectations

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ Platform/IPC/ArgumentCoders.h
1414
[ iOS ] UIProcess/ios/WKContentViewInteraction.mm
1515
[ iOS ] UIProcess/ios/WebPageProxyIOS.mm
1616
[ iOS ] UIProcess/ios/fullscreen/WKFullScreenViewController.mm
17-
WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm
18-
WebProcess/InjectedBundle/API/mac/WKDOMNode.mm
19-
WebProcess/InjectedBundle/API/mac/WKDOMRange.mm
20-
WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm
2117
[ iOS ] WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm
2218
[ iOS ] WebProcess/WebPage/WebFoundTextRangeController.cpp
2319
[ iOS ] WebProcess/WebPage/ios/FindControllerIOS.mm

Source/WebKit/SaferCPPExpectations/UncountedCallArgsCheckerExpectations

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,6 @@ Platform/IPC/ArgumentCoders.h
4848
[ iOS ] UIProcess/ios/fullscreen/WKFullScreenViewController.mm
4949
[ iOS ] UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm
5050
[ iOS ] WebProcess/GPU/media/ios/RemoteMediaSessionHelper.cpp
51-
WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp
52-
WebProcess/InjectedBundle/API/c/mac/WKBundleMac.mm
53-
[ Mac ] WebProcess/InjectedBundle/API/c/mac/WKBundlePageBannerMac.mm
54-
WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm
55-
WebProcess/InjectedBundle/API/mac/WKDOMNode.mm
56-
WebProcess/InjectedBundle/API/mac/WKDOMRange.mm
57-
WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.mm
58-
WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.mm
59-
WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm
6051
[ iOS ] WebProcess/Network/NetworkProcessConnection.cpp
6152
[ iOS ] WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm
6253
[ iOS ] WebProcess/WebCoreSupport/WebChromeClientCocoa.mm

Source/WebKit/SaferCPPExpectations/UnretainedCallArgsCheckerExpectations

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@
6464
[ iOS ] UIProcess/ios/forms/WKFormSelectPopover.mm
6565
[ iOS ] UIProcess/ios/fullscreen/WKFullScreenViewController.mm
6666
[ iOS ] UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm
67-
WebProcess/InjectedBundle/API/mac/WKDOMInternals.mm
68-
WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.mm
69-
WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm
7067
WebProcess/Plugins/PDF/PDFIncrementalLoader.mm
7168
WebProcess/Plugins/PDF/PDFPluginChoiceAnnotation.mm
7269
WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm

Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundle.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void WKBundlePostSynchronousMessage(WKBundleRef bundleRef, WKStringRef messageNa
7373
RefPtr<API::Object> returnData;
7474
WebKit::toProtectedImpl(bundleRef)->postSynchronousMessage(WebKit::toWTFString(messageNameRef), WebKit::toProtectedImpl(messageBodyRef).get(), returnData);
7575
if (returnRetainedDataRef)
76-
SUPPRESS_UNCOUNTED_ARG *returnRetainedDataRef = WebKit::toAPI(returnData.leakRef());
76+
*returnRetainedDataRef = WebKit::toAPILeakingRef(WTFMove(returnData));
7777
}
7878

7979
void WKBundleGarbageCollectJavaScriptObjects(WKBundleRef bundleRef)
@@ -153,7 +153,7 @@ void WKBundleReleaseMemory(WKBundleRef)
153153

154154
WKDataRef WKBundleCreateWKDataFromUInt8Array(WKBundleRef bundle, JSContextRef context, JSValueRef data)
155155
{
156-
SUPPRESS_UNCOUNTED_ARG return WebKit::toAPI(&WebKit::toProtectedImpl(bundle)->createWebDataFromUint8Array(context, data).leakRef());
156+
return WebKit::toAPILeakingRef(WebKit::toProtectedImpl(bundle)->createWebDataFromUint8Array(context, data));
157157
}
158158

159159
int WKBundleNumberOfPages(WKBundleRef bundleRef, WKBundleFrameRef frameRef, double pageWidthInPixels, double pageHeightInPixels)

Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleDOMWindowExtension.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ WKTypeID WKBundleDOMWindowExtensionGetTypeID()
4040
WKBundleDOMWindowExtensionRef WKBundleDOMWindowExtensionCreate(WKBundleFrameRef frame, WKBundleScriptWorldRef world)
4141
{
4242
RefPtr<WebKit::InjectedBundleDOMWindowExtension> extension = WebKit::InjectedBundleDOMWindowExtension::create(WebKit::toProtectedImpl(frame).get(), WebKit::toProtectedImpl(world).get());
43-
SUPPRESS_UNCOUNTED_ARG return toAPI(extension.leakRef());
43+
return toAPILeakingRef(WTFMove(extension));
4444
}
4545

4646
WKBundleFrameRef WKBundleDOMWindowExtensionGetFrame(WKBundleDOMWindowExtensionRef extension)

Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ WKFrameLoadState WKBundleFrameGetFrameLoadState(WKBundleFrameRef frameRef)
9595

9696
WKArrayRef WKBundleFrameCopyChildFrames(WKBundleFrameRef frameRef)
9797
{
98-
SUPPRESS_UNCOUNTED_ARG return WebKit::toAPI(&WebKit::toImpl(frameRef)->childFrames().leakRef());
98+
return WebKit::toAPILeakingRef(WebKit::toProtectedImpl(frameRef)->childFrames());
9999
}
100100

101101
JSGlobalContextRef WKBundleFrameGetJavaScriptContext(WKBundleFrameRef frameRef)
@@ -140,7 +140,7 @@ unsigned WKBundleFrameGetPendingUnloadCount(WKBundleFrameRef frameRef)
140140

141141
WKBundlePageRef WKBundleFrameGetPage(WKBundleFrameRef frameRef)
142142
{
143-
return toAPI(WebKit::toProtectedImpl(frameRef)->page());
143+
return toAPI(WebKit::toProtectedImpl(frameRef)->protectedPage().get());
144144
}
145145

146146
void WKBundleFrameStopLoading(WKBundleFrameRef frameRef)
@@ -270,7 +270,7 @@ bool WKBundleFrameCallShouldCloseOnWebView(WKBundleFrameRef frameRef)
270270
WKBundleHitTestResultRef WKBundleFrameCreateHitTestResult(WKBundleFrameRef frameRef, WKPoint point)
271271
{
272272
ASSERT(frameRef);
273-
return WebKit::toAPI(WebKit::toProtectedImpl(frameRef)->hitTest(WebKit::toIntPoint(point)).leakRef());
273+
return WebKit::toAPILeakingRef(WebKit::toProtectedImpl(frameRef)->hitTest(WebKit::toIntPoint(point)));
274274
}
275275

276276
WKSecurityOriginRef WKBundleFrameCopySecurityOrigin(WKBundleFrameRef frameRef)

Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ WKTypeID WKBundleHitTestResultGetTypeID()
4242
WKBundleNodeHandleRef WKBundleHitTestResultCopyNodeHandle(WKBundleHitTestResultRef hitTestResultRef)
4343
{
4444
RefPtr<WebKit::InjectedBundleNodeHandle> nodeHandle = WebKit::toProtectedImpl(hitTestResultRef)->nodeHandle();
45-
SUPPRESS_UNCOUNTED_ARG return toAPI(nodeHandle.leakRef());
45+
return toAPILeakingRef(WTFMove(nodeHandle));
4646
}
4747

4848
WKBundleNodeHandleRef WKBundleHitTestResultCopyURLElementHandle(WKBundleHitTestResultRef hitTestResultRef)
4949
{
5050
RefPtr<WebKit::InjectedBundleNodeHandle> urlElementNodeHandle = WebKit::toProtectedImpl(hitTestResultRef)->urlElementHandle();
51-
SUPPRESS_UNCOUNTED_ARG return toAPI(urlElementNodeHandle.leakRef());
51+
return toAPILeakingRef(WTFMove(urlElementNodeHandle));
5252
}
5353

5454
WKBundleFrameRef WKBundleHitTestResultGetFrame(WKBundleHitTestResultRef)

0 commit comments

Comments
 (0)