[Cocoa] Update uses of wrapper template functions in WebKit for clarity, simplicity...
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 20 Aug 2018 00:53:34 +0000 (00:53 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 20 Aug 2018 00:53:34 +0000 (00:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=188735

Reviewed by Dan Bernstein.

Because of argument-dependent lookup, there should never be a reason to call
the wrapper function as WebKit::wrapper or API::wrapper unless there is a need
to resolve a name conflict, so removed the explicit namespacing.

* UIProcess/API/C/mac/WKPagePrivateMac.mm:
(WKPageLoadURLRequestReturningNavigation): Removed explicit null check and
leakRef/autorelease pair, both done by the wrapper template function now.

* UIProcess/API/Cocoa/WKBackForwardList.mm:
(toWKBackForwardListItem): Deleted.
(-[WKBackForwardList currentItem]): Use wrapper instead of toWKBackForwardListItem.
(-[WKBackForwardList backItem]): Ditto.
(-[WKBackForwardList forwardItem]): Ditto.
(-[WKBackForwardList itemAtIndex:]): Ditto.
(-[WKBackForwardList backList]): Removed leakRef/autorelease pair.
(-[WKBackForwardList forwardList]): Ditto.

* UIProcess/API/Cocoa/WKContentRuleListStore.mm:
(+[WKContentRuleListStore defaultStore]): Removed explicit WebKit namespace.
(+[WKContentRuleListStore storeWithURL:]): Fixed a storage leak by removing leakRef,
which was not balanced. This is not a copy or create function, so it should not
return an object that requires a release to balance it.
(-[WKContentRuleListStore _compileContentRuleListForIdentifier:encodedContentRuleList:completionHandler:releasesArgument:]):
Removed explicit WebKit namespace and unneeded get().
(-[WKContentRuleListStore lookUpContentRuleListForIdentifier:completionHandler:]):
Removed explicit WebKit namespace.
(+[WKContentRuleListStore defaultStoreWithLegacyFilename]): Ditto.
(+[WKContentRuleListStore storeWithURLAndLegacyFilename:]): Fixed storage leak,
as above in storeWithURL.

* UIProcess/API/Cocoa/WKFrameInfo.mm:
(-[WKFrameInfo _handle]): Removed explicit WebKit namespace.
* UIProcess/API/Cocoa/WKHTTPCookieStore.mm:
(WKHTTPCookieStoreObserver::cookiesDidChange): Ditto.

* UIProcess/API/Cocoa/WKNavigationAction.mm:
(-[WKNavigationAction sourceFrame]): Removed explicit null check, now done by
the wrapper template function.
(-[WKNavigationAction targetFrame]): Ditto.
(-[WKNavigationAction _userInitiatedAction]): Ditto.
(-[WKNavigationAction _mainFrameNavigation]): Ditto.

* UIProcess/API/Cocoa/WKOpenPanelParameters.mm:
(-[WKOpenPanelParameters _acceptedMIMETypes]): Removed leakRef/autorelease pair,
now done by the wrapper template function.
(-[WKOpenPanelParameters _acceptedFileExtensions]): Ditto.

* UIProcess/API/Cocoa/WKPreferences.mm:
(-[WKPreferences copyWithZone:]): Use retain instead of leakRef; slightly clearer
for when we convert to ARC.
(+[WKPreferences _experimentalFeatures]): Removed leakRef/autorelease pair,
now done by the wrapper template function.

* UIProcess/API/Cocoa/WKProcessPool.mm:
(-[WKProcessPool _configuration]): Fixed a storage leak by removing leakRef,
which was not balanced. This is not a copy or create function, so it should not
return an object that requires a release to balance it.

* UIProcess/API/Cocoa/WKURLSchemeTaskInternal.h:
Replaced inline wrapper function with WrapperTraits structure template specialization.

* UIProcess/API/Cocoa/WKUserScript.mm:
(-[WKUserScript _userContentWorld]): Removed explicit API namespace.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView loadRequest:]): Removed explicit null check and
leakRef/autorelease pair, both done by the wrapper template function now.
(-[WKWebView loadFileURL:allowingReadAccessToURL:]): Ditto.
(-[WKWebView loadData:MIMEType:characterEncodingName:baseURL:]): Ditto.
(-[WKWebView goToBackForwardListItem:]): Ditto.
(-[WKWebView goBack]): Ditto.
(-[WKWebView goForward]): Ditto.
(-[WKWebView reload]): Ditto.
(-[WKWebView reloadFromOrigin]): Ditto.
(-[WKWebView _didInsertAttachment:withSource:]): Removed leakRef/autorelease pairs,
now done by the wrapper template function.
(-[WKWebView _didRemoveAttachment:]): Ditto.
(-[WKWebView _loadData:MIMEType:characterEncodingName:baseURL:userData:]): Removed
explicit null check and leakRef/autorelease pair, both done by the wrapper template
function now.
(-[WKWebView _loadRequest:shouldOpenExternalURLs:]): Ditto.
(-[WKWebView _reloadWithoutContentBlockers]): Ditto.
(-[WKWebView _reloadExpiredOnly]): Ditto.
(-[WKWebView _sessionStateData]): Removed explicit leakRef/autorelease pair, done
by the wrapper template function now. Also, the old version explicitly dereferenced
and would not work when the result of encodeLegacySessionState was null. Decided
not to add a call to releaseNonNull to preserve that possibly-incorrect optimization,
instead allowing the wrapper function to generate code to handle the null case.
(-[WKWebView _sessionState]): Use the Objective-C autorelease instead of adoptNS
and RetainPtr's autorelease.
(-[WKWebView _sessionStateWithFilter:]): Ditto.
(-[WKWebView _restoreSessionState:andNavigate:]): Removed explicit null check and
leakRef/autorelease pair, both done by the wrapper template function now.
(-[WKWebView _insertAttachmentWithFilename:contentType:data:options:completion:]):
Removed explicit leakRef/autorelease pair, done by the wrapper template function now.
(-[WKWebView _diagnosticLoggingDelegate]): Replaced a leakRef/autorelease pair with
use of RetainPtr's autorelease.
(-[WKWebView _findDelegate]): Ditto.

* UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(-[WKWebViewConfiguration _applicationManifest]): Removed explicit null check,
done by the wrapper template function now.

* UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
(+[WKWebsiteDataStore defaultDataStore]): Removed explicit WebKit namespace
and unneeded call to get().
(+[WKWebsiteDataStore nonPersistentDataStore]): Removed explicit WebKit namespace
and leakRef/autorelease pair, done by the wrapper template function now.
(-[WKWebsiteDataStore httpCookieStore]): Removed explicit WebKit namespace.

* UIProcess/API/Cocoa/_WKApplicationManifest.mm:
(+[_WKApplicationManifest applicationManifestFromJSON:manifestURL:documentURL:]):
Removed explicit leakRef/autorelease pair, done by the wrapper template function now.
* UIProcess/API/Cocoa/_WKGeolocationPosition.mm:
(WebKit::wrapper): Ditto.

* UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
(-[_WKProcessPoolConfiguration copyWithZone:]): Use retain instead of leakRef;
slightly clearer for when we convert to ARC.

* UIProcess/API/Cocoa/_WKUserContentWorld.mm:
(+[_WKUserContentWorld worldWithName:]): Removed explicit leakRef/autorelease pair,
done by the wrapper template function now.

* UIProcess/API/Cocoa/_WKWebsitePolicies.mm:
(-[_WKWebsitePolicies websiteDataStore]): Removed explicit null check, done by
the wrapper template function now.

* UIProcess/Cocoa/NavigationState.mm:
(WebKit::NavigationState::NavigationClient::didChangeBackForwardList): Removed
explicit null check, done by the wrapper template function now.
(WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction): Ditto.
(WebKit::NavigationState::NavigationClient::didStartProvisionalNavigation): Ditto.
(WebKit::NavigationState::NavigationClient::didReceiveServerRedirectForProvisionalNavigation): Ditto.
(WebKit::NavigationState::NavigationClient::didFailProvisionalNavigationWithError): Ditto.
(WebKit::NavigationState::NavigationClient::didFailProvisionalLoadInSubframeWithError): Ditto.
(WebKit::NavigationState::NavigationClient::didCommitNavigation): Ditto.
(WebKit::NavigationState::NavigationClient::didFinishDocumentLoad): Ditto.
(WebKit::NavigationState::NavigationClient::didFinishNavigation): Ditto.
(WebKit::NavigationState::NavigationClient::didFailNavigationWithError): Ditto.
(WebKit::NavigationState::NavigationClient::didSameDocumentNavigation): Ditto.

* UIProcess/Cocoa/SessionStateCoding.mm:
(WebKit::encodeSessionState): Removed explicit leakRef/autorelease pair, done
by the wrapper template function now. Also, the old version explicitly dereferenced
and would not work when the result of encodeLegacySessionState was null. Decided
not to add a call to releaseNonNull to preserve that possibly-incorrect optimization,
instead allowing the wrapper function to generate code to handle the null case.

* UIProcess/mac/WKInspectorViewController.mm:
(-[WKInspectorViewController configuration]): Removed explicit WebKit namespace.

* WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm:
(+[WKWebProcessPlugInFrame lookUpFrameFromHandle:]): Removed explicit null check,
done by the wrapper template function now.
(-[WKWebProcessPlugInFrame hitTest:]): Removed explicit leakRef/autorelease pair, done
by the wrapper template function now. Also, the old version explicitly dereferenced
and would not work when the result of hitTest was null. Decided not to add a call to
releaseNonNull to preserve that possibly-incorrect optimization, instead allowing the
wrapper function to generate code to handle the null case.
(-[WKWebProcessPlugInFrame childFrames]): Removed explicit leakRef/autorelease pair,
done by the wrapper template function now.
(-[WKWebProcessPlugInFrame handle]): Ditto.
(-[WKWebProcessPlugInFrame _parentFrame]): Removed explicit null check, done by the
wrapper template function now.

* WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInHitTestResult.mm:
(-[WKWebProcessPlugInHitTestResult nodeHandle]): Removed explicit null check and
leakRef/autorelease pair, both done by the wrapper template function now.
* WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.mm:
(+[WKWebProcessPlugInNodeHandle nodeHandleWithJSValue:inContext:]): Ditto.
(-[WKWebProcessPlugInNodeHandle htmlIFrameElementContentFrame]): Ditto.
(-[WKWebProcessPlugInNodeHandle HTMLTableCellElementCellAbove]): Ditto.
(-[WKWebProcessPlugInNodeHandle frame]): Ditto.
* WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInRangeHandle.mm:
(+[WKWebProcessPlugInRangeHandle rangeHandleWithJSValue:inContext:]): Ditto.
(-[WKWebProcessPlugInRangeHandle frame]): Ditto.
* WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInScriptWorld.mm:
(+[WKWebProcessPlugInScriptWorld world]): Ditto.
* WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:
(-[WKWebProcessPlugInBrowserContextController mainFrame]): Ditto.
(+[WKWebProcessPlugInBrowserContextController lookUpBrowsingContextFromHandle:]): Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235022 268f45cc-cd09-0410-ab3c-d52691b4dbfc

29 files changed:
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/C/mac/WKPagePrivateMac.mm
Source/WebKit/UIProcess/API/Cocoa/WKBackForwardList.mm
Source/WebKit/UIProcess/API/Cocoa/WKContentRuleListStore.mm
Source/WebKit/UIProcess/API/Cocoa/WKFrameInfo.mm
Source/WebKit/UIProcess/API/Cocoa/WKHTTPCookieStore.mm
Source/WebKit/UIProcess/API/Cocoa/WKNavigationAction.mm
Source/WebKit/UIProcess/API/Cocoa/WKOpenPanelParameters.mm
Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm
Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm
Source/WebKit/UIProcess/API/Cocoa/WKURLSchemeTaskInternal.h
Source/WebKit/UIProcess/API/Cocoa/WKUserScript.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm
Source/WebKit/UIProcess/API/Cocoa/_WKApplicationManifest.mm
Source/WebKit/UIProcess/API/Cocoa/_WKGeolocationPosition.mm
Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm
Source/WebKit/UIProcess/API/Cocoa/_WKUserContentWorld.mm
Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm
Source/WebKit/UIProcess/Cocoa/NavigationState.mm
Source/WebKit/UIProcess/Cocoa/SessionStateCoding.mm
Source/WebKit/UIProcess/mac/WKInspectorViewController.mm
Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm
Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInHitTestResult.mm
Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.mm
Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInRangeHandle.mm
Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInScriptWorld.mm
Source/WebKit/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm

index 028de97..0bb1a95 100644 (file)
@@ -1,5 +1,195 @@
 2018-08-19  Darin Adler  <darin@apple.com>
 
+        [Cocoa] Update uses of wrapper template functions in WebKit for clarity, simplicity, better ARC readiness
+        https://bugs.webkit.org/show_bug.cgi?id=188735
+
+        Reviewed by Dan Bernstein.
+
+        Because of argument-dependent lookup, there should never be a reason to call
+        the wrapper function as WebKit::wrapper or API::wrapper unless there is a need
+        to resolve a name conflict, so removed the explicit namespacing.
+
+        * UIProcess/API/C/mac/WKPagePrivateMac.mm:
+        (WKPageLoadURLRequestReturningNavigation): Removed explicit null check and
+        leakRef/autorelease pair, both done by the wrapper template function now.
+
+        * UIProcess/API/Cocoa/WKBackForwardList.mm:
+        (toWKBackForwardListItem): Deleted.
+        (-[WKBackForwardList currentItem]): Use wrapper instead of toWKBackForwardListItem.
+        (-[WKBackForwardList backItem]): Ditto.
+        (-[WKBackForwardList forwardItem]): Ditto.
+        (-[WKBackForwardList itemAtIndex:]): Ditto.
+        (-[WKBackForwardList backList]): Removed leakRef/autorelease pair.
+        (-[WKBackForwardList forwardList]): Ditto.
+
+        * UIProcess/API/Cocoa/WKContentRuleListStore.mm:
+        (+[WKContentRuleListStore defaultStore]): Removed explicit WebKit namespace.
+        (+[WKContentRuleListStore storeWithURL:]): Fixed a storage leak by removing leakRef,
+        which was not balanced. This is not a copy or create function, so it should not
+        return an object that requires a release to balance it.
+        (-[WKContentRuleListStore _compileContentRuleListForIdentifier:encodedContentRuleList:completionHandler:releasesArgument:]):
+        Removed explicit WebKit namespace and unneeded get().
+        (-[WKContentRuleListStore lookUpContentRuleListForIdentifier:completionHandler:]):
+        Removed explicit WebKit namespace.
+        (+[WKContentRuleListStore defaultStoreWithLegacyFilename]): Ditto.
+        (+[WKContentRuleListStore storeWithURLAndLegacyFilename:]): Fixed storage leak,
+        as above in storeWithURL.
+
+        * UIProcess/API/Cocoa/WKFrameInfo.mm:
+        (-[WKFrameInfo _handle]): Removed explicit WebKit namespace.
+        * UIProcess/API/Cocoa/WKHTTPCookieStore.mm:
+        (WKHTTPCookieStoreObserver::cookiesDidChange): Ditto.
+
+        * UIProcess/API/Cocoa/WKNavigationAction.mm:
+        (-[WKNavigationAction sourceFrame]): Removed explicit null check, now done by
+        the wrapper template function.
+        (-[WKNavigationAction targetFrame]): Ditto.
+        (-[WKNavigationAction _userInitiatedAction]): Ditto.
+        (-[WKNavigationAction _mainFrameNavigation]): Ditto.
+
+        * UIProcess/API/Cocoa/WKOpenPanelParameters.mm:
+        (-[WKOpenPanelParameters _acceptedMIMETypes]): Removed leakRef/autorelease pair,
+        now done by the wrapper template function.
+        (-[WKOpenPanelParameters _acceptedFileExtensions]): Ditto.
+
+        * UIProcess/API/Cocoa/WKPreferences.mm:
+        (-[WKPreferences copyWithZone:]): Use retain instead of leakRef; slightly clearer
+        for when we convert to ARC.
+        (+[WKPreferences _experimentalFeatures]): Removed leakRef/autorelease pair,
+        now done by the wrapper template function.
+
+        * UIProcess/API/Cocoa/WKProcessPool.mm:
+        (-[WKProcessPool _configuration]): Fixed a storage leak by removing leakRef,
+        which was not balanced. This is not a copy or create function, so it should not
+        return an object that requires a release to balance it.
+
+        * UIProcess/API/Cocoa/WKURLSchemeTaskInternal.h:
+        Replaced inline wrapper function with WrapperTraits structure template specialization.
+
+        * UIProcess/API/Cocoa/WKUserScript.mm:
+        (-[WKUserScript _userContentWorld]): Removed explicit API namespace.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView loadRequest:]): Removed explicit null check and
+        leakRef/autorelease pair, both done by the wrapper template function now.
+        (-[WKWebView loadFileURL:allowingReadAccessToURL:]): Ditto.
+        (-[WKWebView loadData:MIMEType:characterEncodingName:baseURL:]): Ditto.
+        (-[WKWebView goToBackForwardListItem:]): Ditto.
+        (-[WKWebView goBack]): Ditto.
+        (-[WKWebView goForward]): Ditto.
+        (-[WKWebView reload]): Ditto.
+        (-[WKWebView reloadFromOrigin]): Ditto.
+        (-[WKWebView _didInsertAttachment:withSource:]): Removed leakRef/autorelease pairs,
+        now done by the wrapper template function.
+        (-[WKWebView _didRemoveAttachment:]): Ditto.
+        (-[WKWebView _loadData:MIMEType:characterEncodingName:baseURL:userData:]): Removed
+        explicit null check and leakRef/autorelease pair, both done by the wrapper template
+        function now.
+        (-[WKWebView _loadRequest:shouldOpenExternalURLs:]): Ditto.
+        (-[WKWebView _reloadWithoutContentBlockers]): Ditto.
+        (-[WKWebView _reloadExpiredOnly]): Ditto.
+        (-[WKWebView _sessionStateData]): Removed explicit leakRef/autorelease pair, done
+        by the wrapper template function now. Also, the old version explicitly dereferenced
+        and would not work when the result of encodeLegacySessionState was null. Decided
+        not to add a call to releaseNonNull to preserve that possibly-incorrect optimization,
+        instead allowing the wrapper function to generate code to handle the null case.
+        (-[WKWebView _sessionState]): Use the Objective-C autorelease instead of adoptNS
+        and RetainPtr's autorelease.
+        (-[WKWebView _sessionStateWithFilter:]): Ditto.
+        (-[WKWebView _restoreSessionState:andNavigate:]): Removed explicit null check and
+        leakRef/autorelease pair, both done by the wrapper template function now.
+        (-[WKWebView _insertAttachmentWithFilename:contentType:data:options:completion:]):
+        Removed explicit leakRef/autorelease pair, done by the wrapper template function now.
+        (-[WKWebView _diagnosticLoggingDelegate]): Replaced a leakRef/autorelease pair with
+        use of RetainPtr's autorelease.
+        (-[WKWebView _findDelegate]): Ditto.
+
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+        (-[WKWebViewConfiguration _applicationManifest]): Removed explicit null check,
+        done by the wrapper template function now.
+
+        * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
+        (+[WKWebsiteDataStore defaultDataStore]): Removed explicit WebKit namespace
+        and unneeded call to get().
+        (+[WKWebsiteDataStore nonPersistentDataStore]): Removed explicit WebKit namespace
+        and leakRef/autorelease pair, done by the wrapper template function now.
+        (-[WKWebsiteDataStore httpCookieStore]): Removed explicit WebKit namespace.
+
+        * UIProcess/API/Cocoa/_WKApplicationManifest.mm:
+        (+[_WKApplicationManifest applicationManifestFromJSON:manifestURL:documentURL:]):
+        Removed explicit leakRef/autorelease pair, done by the wrapper template function now.
+        * UIProcess/API/Cocoa/_WKGeolocationPosition.mm:
+        (WebKit::wrapper): Ditto.
+
+        * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
+        (-[_WKProcessPoolConfiguration copyWithZone:]): Use retain instead of leakRef;
+        slightly clearer for when we convert to ARC.
+
+        * UIProcess/API/Cocoa/_WKUserContentWorld.mm:
+        (+[_WKUserContentWorld worldWithName:]): Removed explicit leakRef/autorelease pair,
+        done by the wrapper template function now.
+
+        * UIProcess/API/Cocoa/_WKWebsitePolicies.mm:
+        (-[_WKWebsitePolicies websiteDataStore]): Removed explicit null check, done by
+        the wrapper template function now.
+
+        * UIProcess/Cocoa/NavigationState.mm:
+        (WebKit::NavigationState::NavigationClient::didChangeBackForwardList): Removed
+        explicit null check, done by the wrapper template function now.
+        (WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction): Ditto.
+        (WebKit::NavigationState::NavigationClient::didStartProvisionalNavigation): Ditto.
+        (WebKit::NavigationState::NavigationClient::didReceiveServerRedirectForProvisionalNavigation): Ditto.
+        (WebKit::NavigationState::NavigationClient::didFailProvisionalNavigationWithError): Ditto.
+        (WebKit::NavigationState::NavigationClient::didFailProvisionalLoadInSubframeWithError): Ditto.
+        (WebKit::NavigationState::NavigationClient::didCommitNavigation): Ditto.
+        (WebKit::NavigationState::NavigationClient::didFinishDocumentLoad): Ditto.
+        (WebKit::NavigationState::NavigationClient::didFinishNavigation): Ditto.
+        (WebKit::NavigationState::NavigationClient::didFailNavigationWithError): Ditto.
+        (WebKit::NavigationState::NavigationClient::didSameDocumentNavigation): Ditto.
+
+        * UIProcess/Cocoa/SessionStateCoding.mm:
+        (WebKit::encodeSessionState): Removed explicit leakRef/autorelease pair, done
+        by the wrapper template function now. Also, the old version explicitly dereferenced
+        and would not work when the result of encodeLegacySessionState was null. Decided
+        not to add a call to releaseNonNull to preserve that possibly-incorrect optimization,
+        instead allowing the wrapper function to generate code to handle the null case.
+
+        * UIProcess/mac/WKInspectorViewController.mm:
+        (-[WKInspectorViewController configuration]): Removed explicit WebKit namespace.
+
+        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm:
+        (+[WKWebProcessPlugInFrame lookUpFrameFromHandle:]): Removed explicit null check,
+        done by the wrapper template function now.
+        (-[WKWebProcessPlugInFrame hitTest:]): Removed explicit leakRef/autorelease pair, done
+        by the wrapper template function now. Also, the old version explicitly dereferenced
+        and would not work when the result of hitTest was null. Decided not to add a call to
+        releaseNonNull to preserve that possibly-incorrect optimization, instead allowing the
+        wrapper function to generate code to handle the null case.
+        (-[WKWebProcessPlugInFrame childFrames]): Removed explicit leakRef/autorelease pair,
+        done by the wrapper template function now.
+        (-[WKWebProcessPlugInFrame handle]): Ditto.
+        (-[WKWebProcessPlugInFrame _parentFrame]): Removed explicit null check, done by the
+        wrapper template function now.
+
+        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInHitTestResult.mm:
+        (-[WKWebProcessPlugInHitTestResult nodeHandle]): Removed explicit null check and
+        leakRef/autorelease pair, both done by the wrapper template function now.
+        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.mm:
+        (+[WKWebProcessPlugInNodeHandle nodeHandleWithJSValue:inContext:]): Ditto.
+        (-[WKWebProcessPlugInNodeHandle htmlIFrameElementContentFrame]): Ditto.
+        (-[WKWebProcessPlugInNodeHandle HTMLTableCellElementCellAbove]): Ditto.
+        (-[WKWebProcessPlugInNodeHandle frame]): Ditto.
+        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInRangeHandle.mm:
+        (+[WKWebProcessPlugInRangeHandle rangeHandleWithJSValue:inContext:]): Ditto.
+        (-[WKWebProcessPlugInRangeHandle frame]): Ditto.
+        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInScriptWorld.mm:
+        (+[WKWebProcessPlugInScriptWorld world]): Ditto.
+        * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:
+        (-[WKWebProcessPlugInBrowserContextController mainFrame]): Ditto.
+        (+[WKWebProcessPlugInBrowserContextController lookUpBrowsingContextFromHandle:]): Ditto.
+
+2018-08-19  Darin Adler  <darin@apple.com>
+
         [Cocoa] Consolidate inline "wrapper" functions in WebKit API into function templates and WrapperTraits
         https://bugs.webkit.org/show_bug.cgi?id=188733
 
index 2eb36b5..1994f3d 100644 (file)
@@ -143,12 +143,7 @@ bool WKPageIsURLKnownHSTSHost(WKPageRef page, WKURLRef url)
 WKNavigation *WKPageLoadURLRequestReturningNavigation(WKPageRef pageRef, WKURLRequestRef urlRequestRef)
 {
     auto resourceRequest = toImpl(urlRequestRef)->resourceRequest();
-    auto navigation = toImpl(pageRef)->loadRequest(WTFMove(resourceRequest));
-
-    if (!navigation)
-        return nil;
-
-    return [API::wrapper(*navigation.leakRef()) autorelease];
+    return wrapper(toImpl(pageRef)->loadRequest(WTFMove(resourceRequest)));
 }
 #endif
 
index 2c96965..79e5d23 100644 (file)
@@ -44,42 +44,34 @@ using namespace WebKit;
     [super dealloc];
 }
 
-static WKBackForwardListItem *toWKBackForwardListItem(WebBackForwardListItem* item)
-{
-    if (!item)
-        return nil;
-
-    return wrapper(*item);
-}
-
 - (WKBackForwardListItem *)currentItem
 {
-    return toWKBackForwardListItem(_list->currentItem());
+    return wrapper(_list->currentItem());
 }
 
 - (WKBackForwardListItem *)backItem
 {
-    return toWKBackForwardListItem(_list->backItem());
+    return wrapper(_list->backItem());
 }
 
 - (WKBackForwardListItem *)forwardItem
 {
-    return toWKBackForwardListItem(_list->forwardItem());
+    return wrapper(_list->forwardItem());
 }
 
 - (WKBackForwardListItem *)itemAtIndex:(NSInteger)index
 {
-    return toWKBackForwardListItem(_list->itemAtIndex(index));
+    return wrapper(_list->itemAtIndex(index));
 }
 
 - (NSArray *)backList
 {
-    return [wrapper(_list->backList().leakRef()) autorelease];
+    return wrapper(_list->backList());
 }
 
 - (NSArray *)forwardList
 {
-    return [wrapper(_list->forwardList().leakRef()) autorelease];
+    return wrapper(_list->forwardList());
 }
 
 #pragma mark WKObject protocol implementation
index 56355af..4b41b43 100644 (file)
@@ -63,14 +63,13 @@ static WKErrorCode toWKErrorCode(const std::error_code& error)
 + (instancetype)defaultStore
 {
     const bool legacyFilename = false;
-    return WebKit::wrapper(API::ContentRuleListStore::defaultStore(legacyFilename));
+    return wrapper(API::ContentRuleListStore::defaultStore(legacyFilename));
 }
 
 + (instancetype)storeWithURL:(NSURL *)url
 {
     const bool legacyFilename = false;
-    Ref<API::ContentRuleListStore> store = API::ContentRuleListStore::storeWithPath(url.absoluteURL.fileSystemRepresentation, legacyFilename);
-    return WebKit::wrapper(store.leakRef());
+    return wrapper(API::ContentRuleListStore::storeWithPath(url.absoluteURL.fileSystemRepresentation, legacyFilename));
 }
 
 - (void)compileContentRuleListForIdentifier:(NSString *)identifier encodedContentRuleList:(NSString *)encodedContentRuleList completionHandler:(void (^)(WKContentRuleList *, NSError *))completionHandler
@@ -94,7 +93,7 @@ static WKErrorCode toWKErrorCode(const std::error_code& error)
             // We want to use error.message, but here we want to only pass on CompileFailed with userInfo from the std::error_code.
             return completionHandler(nil, [NSError errorWithDomain:WKErrorDomain code:WKErrorContentRuleListStoreCompileFailed userInfo:userInfo]);
         }
-        completionHandler(WebKit::wrapper(*contentRuleList.get()), nil);
+        completionHandler(wrapper(*contentRuleList), nil);
     });
 }
 
@@ -108,7 +107,7 @@ static WKErrorCode toWKErrorCode(const std::error_code& error)
             return completionHandler(nil, [NSError errorWithDomain:WKErrorDomain code:wkError userInfo:userInfo]);
         }
 
-        completionHandler(WebKit::wrapper(*contentRuleList.get()), nil);
+        completionHandler(wrapper(*contentRuleList), nil);
     });
 }
 
@@ -180,14 +179,13 @@ static WKErrorCode toWKErrorCode(const std::error_code& error)
 + (instancetype)defaultStoreWithLegacyFilename
 {
     const bool legacyFilename = true;
-    return WebKit::wrapper(API::ContentRuleListStore::defaultStore(legacyFilename));
+    return wrapper(API::ContentRuleListStore::defaultStore(legacyFilename));
 }
 
 + (instancetype)storeWithURLAndLegacyFilename:(NSURL *)url
 {
     const bool legacyFilename = true;
-    Ref<API::ContentRuleListStore> store = API::ContentRuleListStore::storeWithPath(url.absoluteURL.fileSystemRepresentation, legacyFilename);
-    return WebKit::wrapper(store.leakRef());
+    return wrapper(API::ContentRuleListStore::storeWithPath(url.absoluteURL.fileSystemRepresentation, legacyFilename));
 }
 
 @end
index be6eb3f..3d1a6de 100644 (file)
@@ -86,7 +86,7 @@
 
 - (_WKFrameHandle *)_handle
 {
-    return WebKit::wrapper(_frameInfo->handle());
+    return wrapper(_frameInfo->handle());
 }
 
 @end
index 0a0863a..55324a1 100644 (file)
@@ -56,7 +56,7 @@ public:
 private:
     void cookiesDidChange(API::HTTPCookieStore& cookieStore) final
     {
-        [m_observer.get() cookiesDidChangeInCookieStore:WebKit::wrapper(cookieStore)];
+        [m_observer cookiesDidChangeInCookieStore:wrapper(cookieStore)];
     }
 
     WeakObjCPtr<id<WKHTTPCookieStoreObserver>> m_observer;
index 3f8ff69..c7d5905 100644 (file)
@@ -137,16 +137,12 @@ static NSInteger toNSButtonNumber(WebKit::WebMouseEvent::Button mouseButton)
 
 - (WKFrameInfo *)sourceFrame
 {
-    if (API::FrameInfo* frameInfo = _navigationAction->sourceFrame())
-        return wrapper(*frameInfo);
-    return nil;
+    return wrapper(_navigationAction->sourceFrame());
 }
 
 - (WKFrameInfo *)targetFrame
 {
-    if (API::FrameInfo* frameInfo = _navigationAction->targetFrame())
-        return wrapper(*frameInfo);
-    return nil;
+    return wrapper(_navigationAction->targetFrame());
 }
 
 - (WKNavigationType)navigationType
@@ -226,10 +222,7 @@ static NSInteger toNSButtonNumber(WebKit::WebMouseEvent::Button mouseButton)
 
 - (_WKUserInitiatedAction *)_userInitiatedAction
 {
-    auto userInitiatedAction = _navigationAction->userInitiatedAction();
-    if (userInitiatedAction)
-        return wrapper(*userInitiatedAction);
-    return nil;
+    return wrapper(_navigationAction->userInitiatedAction());
 }
 
 - (BOOL)_isRedirect
@@ -239,10 +232,7 @@ static NSInteger toNSButtonNumber(WebKit::WebMouseEvent::Button mouseButton)
 
 - (WKNavigation *)_mainFrameNavigation
 {
-    if (auto* navigation = _navigationAction->mainFrameNavigation())
-        return wrapper(*navigation);
-    
-    return nil;
+    return wrapper(_navigationAction->mainFrameNavigation());
 }
 
 @end
index 8d2509b..3dbd545 100644 (file)
 
 - (NSArray<NSString *> *)_acceptedMIMETypes
 {
-    return [wrapper(_openPanelParameters->acceptMIMETypes().leakRef()) autorelease];
+    return wrapper(_openPanelParameters->acceptMIMETypes());
 }
 
 - (NSArray<NSString *> *)_acceptedFileExtensions
 {
-    return [wrapper(_openPanelParameters->acceptFileExtensions().leakRef()) autorelease];
+    return wrapper(_openPanelParameters->acceptFileExtensions());
 }
 
 @end
index be43285..c49b476 100644 (file)
@@ -97,7 +97,7 @@
 
 - (id)copyWithZone:(NSZone *)zone
 {
-    return wrapper(_preferences->copy().leakRef());
+    return [wrapper(_preferences->copy()) retain];
 }
 
 - (CGFloat)minimumFontSize
@@ -530,7 +530,7 @@ static _WKStorageBlockingPolicy toAPI(WebCore::SecurityOrigin::StorageBlockingPo
 + (NSArray<_WKExperimentalFeature *> *)_experimentalFeatures
 {
     auto features = WebKit::WebPreferences::experimentalFeatures();
-    return [wrapper(API::Array::create(WTFMove(features)).leakRef()) autorelease];
+    return wrapper(API::Array::create(WTFMove(features)));
 }
 
 - (BOOL)_isEnabledForFeature:(_WKExperimentalFeature *)feature
index ab319e7..e390b9d 100644 (file)
@@ -126,7 +126,7 @@ static WKProcessPool *sharedProcessPool;
 
 - (_WKProcessPoolConfiguration *)_configuration
 {
-    return wrapper(_processPool->configuration().copy().leakRef());
+    return wrapper(_processPool->configuration().copy());
 }
 
 - (API::Object&)_apiObject
index 5797580..52b8748 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 
 namespace WebKit {
 
-inline id<WKURLSchemeTask> wrapper(API::URLSchemeTask& urlSchemeTask)
-{
-    ASSERT([urlSchemeTask.wrapper() isKindOfClass:[WKURLSchemeTaskImpl class]]);
-    return (id<WKURLSchemeTask>)urlSchemeTask.wrapper();
-}
+template<> struct WrapperTraits<API::URLSchemeTask> {
+    using WrapperClass = WKURLSchemeTaskImpl;
+};
 
 }
 
index 1740a22..9cf6681 100644 (file)
 
 - (_WKUserContentWorld *)_userContentWorld
 {
-    return API::wrapper(_userScript->userContentWorld());
+    return wrapper(_userScript->userContentWorld());
 }
 
 @end
index 6cb6009..f023018 100644 (file)
@@ -857,11 +857,7 @@ static void validate(WKWebViewConfiguration *configuration)
 
 - (WKNavigation *)loadRequest:(NSURLRequest *)request
 {
-    auto navigation = _page->loadRequest(request);
-    if (!navigation)
-        return nil;
-
-    return [wrapper(*navigation.leakRef()) autorelease];
+    return wrapper(_page->loadRequest(request));
 }
 
 - (WKNavigation *)loadFileURL:(NSURL *)URL allowingReadAccessToURL:(NSURL *)readAccessURL
@@ -872,11 +868,7 @@ static void validate(WKWebViewConfiguration *configuration)
     if (![readAccessURL isFileURL])
         [NSException raise:NSInvalidArgumentException format:@"%@ is not a file URL", readAccessURL];
 
-    auto navigation = _page->loadFile([URL _web_originalDataAsWTFString], [readAccessURL _web_originalDataAsWTFString]);
-    if (!navigation)
-        return nil;
-
-    return [wrapper(*navigation.leakRef()) autorelease];
+    return wrapper(_page->loadFile([URL _web_originalDataAsWTFString], [readAccessURL _web_originalDataAsWTFString]));
 }
 
 - (WKNavigation *)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL
@@ -888,20 +880,12 @@ static void validate(WKWebViewConfiguration *configuration)
 
 - (WKNavigation *)loadData:(NSData *)data MIMEType:(NSString *)MIMEType characterEncodingName:(NSString *)characterEncodingName baseURL:(NSURL *)baseURL
 {
-    auto navigation = _page->loadData({ static_cast<const uint8_t*>(data.bytes), data.length }, MIMEType, characterEncodingName, baseURL.absoluteString);
-    if (!navigation)
-        return nil;
-
-    return [wrapper(*navigation.leakRef()) autorelease];
+    return wrapper(_page->loadData({ static_cast<const uint8_t*>(data.bytes), data.length }, MIMEType, characterEncodingName, baseURL.absoluteString));
 }
 
 - (WKNavigation *)goToBackForwardListItem:(WKBackForwardListItem *)item
 {
-    auto navigation = _page->goToBackForwardItem(item._item);
-    if (!navigation)
-        return nil;
-
-    return [wrapper(*navigation.leakRef()) autorelease];
+    return wrapper(_page->goToBackForwardItem(item._item));
 }
 
 - (NSString *)title
@@ -954,20 +938,12 @@ static void validate(WKWebViewConfiguration *configuration)
 
 - (WKNavigation *)goBack
 {
-    auto navigation = _page->goBack();
-    if (!navigation)
-        return nil;
-
-    return [wrapper(*navigation.leakRef()) autorelease];
+    return wrapper(_page->goBack());
 }
 
 - (WKNavigation *)goForward
 {
-    auto navigation = _page->goForward();
-    if (!navigation)
-        return nil;
-
-    return [wrapper(*navigation.leakRef()) autorelease];
+    return wrapper(_page->goForward());
 }
 
 - (WKNavigation *)reload
@@ -976,20 +952,12 @@ static void validate(WKWebViewConfiguration *configuration)
     if (linkedOnOrAfter(WebKit::SDKVersion::FirstWithExpiredOnlyReloadBehavior))
         reloadOptions |= WebCore::ReloadOption::ExpiredOnly;
 
-    auto navigation = _page->reload(reloadOptions);
-    if (!navigation)
-        return nil;
-
-    return [wrapper(*navigation.leakRef()) autorelease];
+    return wrapper(_page->reload(reloadOptions));
 }
 
 - (WKNavigation *)reloadFromOrigin
 {
-    auto navigation = _page->reload(WebCore::ReloadOption::FromOrigin);
-    if (!navigation)
-        return nil;
-
-    return [wrapper(*navigation.leakRef()) autorelease];
+    return wrapper(_page->reload(WebCore::ReloadOption::FromOrigin));
 }
 
 - (void)stopLoading
@@ -1245,16 +1213,16 @@ static NSDictionary *dictionaryRepresentationForEditorState(const WebKit::Editor
 {
     id <WKUIDelegatePrivate> uiDelegate = (id <WKUIDelegatePrivate>)self.UIDelegate;
     if ([uiDelegate respondsToSelector:@selector(_webView:didInsertAttachment:withSource:)])
-        [uiDelegate _webView:self didInsertAttachment:[wrapper(API::Attachment::create(identifier, *_page).leakRef()) autorelease] withSource:source];
+        [uiDelegate _webView:self didInsertAttachment:wrapper(API::Attachment::create(identifier, *_page)) withSource:source];
     else if ([uiDelegate respondsToSelector:@selector(_webView:didInsertAttachment:)])
-        [uiDelegate _webView:self didInsertAttachment:[wrapper(API::Attachment::create(identifier, *_page).leakRef()) autorelease]];
+        [uiDelegate _webView:self didInsertAttachment:wrapper(API::Attachment::create(identifier, *_page))];
 }
 
 - (void)_didRemoveAttachment:(NSString *)identifier
 {
     id <WKUIDelegatePrivate> uiDelegate = (id <WKUIDelegatePrivate>)self.UIDelegate;
     if ([uiDelegate respondsToSelector:@selector(_webView:didRemoveAttachment:)])
-        [uiDelegate _webView:self didRemoveAttachment:[wrapper(API::Attachment::create(identifier, *_page).leakRef()) autorelease]];
+        [uiDelegate _webView:self didRemoveAttachment:wrapper(API::Attachment::create(identifier, *_page))];
 }
 
 #endif // ENABLE(ATTACHMENT_ELEMENT)
@@ -4223,20 +4191,12 @@ WEBCORE_COMMAND(yankAndSelect)
 
 - (WKNavigation *)_loadData:(NSData *)data MIMEType:(NSString *)MIMEType characterEncodingName:(NSString *)characterEncodingName baseURL:(NSURL *)baseURL userData:(id)userData
 {
-    auto navigation = _page->loadData({ static_cast<const uint8_t*>(data.bytes), data.length }, MIMEType, characterEncodingName, baseURL.absoluteString, WebKit::ObjCObjectGraph::create(userData).ptr());
-    if (!navigation)
-        return nil;
-
-    return [wrapper(*navigation.leakRef()) autorelease];
+    return wrapper(_page->loadData({ static_cast<const uint8_t*>(data.bytes), data.length }, MIMEType, characterEncodingName, baseURL.absoluteString, WebKit::ObjCObjectGraph::create(userData).ptr()));
 }
 
 - (WKNavigation *)_loadRequest:(NSURLRequest *)request shouldOpenExternalURLs:(BOOL)shouldOpenExternalURLs
 {
-    auto navigation = _page->loadRequest(request, shouldOpenExternalURLs ? WebCore::ShouldOpenExternalURLsPolicy::ShouldAllow : WebCore::ShouldOpenExternalURLsPolicy::ShouldNotAllow);
-    if (!navigation)
-        return nil;
-
-    return [wrapper(*navigation.leakRef()) autorelease];
+    return wrapper(_page->loadRequest(request, shouldOpenExternalURLs ? WebCore::ShouldOpenExternalURLsPolicy::ShouldAllow : WebCore::ShouldOpenExternalURLsPolicy::ShouldNotAllow));
 }
 
 - (NSArray *)_certificateChain
@@ -4314,20 +4274,12 @@ WEBCORE_COMMAND(yankAndSelect)
 
 - (WKNavigation *)_reloadWithoutContentBlockers
 {
-    auto navigation = _page->reload(WebCore::ReloadOption::DisableContentBlockers);
-    if (!navigation)
-        return nil;
-
-    return [wrapper(*navigation.leakRef()) autorelease];
+    return wrapper(_page->reload(WebCore::ReloadOption::DisableContentBlockers));
 }
 
 - (WKNavigation *)_reloadExpiredOnly
 {
-    auto navigation = _page->reload(WebCore::ReloadOption::ExpiredOnly);
-    if (!navigation)
-        return nil;
-
-    return [wrapper(*navigation.leakRef()) autorelease];
+    return wrapper(_page->reload(WebCore::ReloadOption::ExpiredOnly));
 }
 
 - (void)_killWebContentProcessAndResetState
@@ -4404,15 +4356,13 @@ WEBCORE_COMMAND(yankAndSelect)
 
 - (NSData *)_sessionStateData
 {
-    WebKit::SessionState sessionState = _page->sessionState();
-
     // FIXME: This should not use the legacy session state encoder.
-    return [wrapper(*WebKit::encodeLegacySessionState(sessionState).leakRef()) autorelease];
+    return wrapper(WebKit::encodeLegacySessionState(_page->sessionState()));
 }
 
 - (_WKSessionState *)_sessionState
 {
-    return adoptNS([[_WKSessionState alloc] _initWithSessionState:_page->sessionState()]).autorelease();
+    return [[[_WKSessionState alloc] _initWithSessionState:_page->sessionState()] autorelease];
 }
 
 - (_WKSessionState *)_sessionStateWithFilter:(BOOL (^)(WKBackForwardListItem *item))filter
@@ -4424,7 +4374,7 @@ WEBCORE_COMMAND(yankAndSelect)
         return (bool)filter(wrapper(item));
     });
 
-    return adoptNS([[_WKSessionState alloc] _initWithSessionState:sessionState]).autorelease();
+    return [[[_WKSessionState alloc] _initWithSessionState:sessionState] autorelease];
 }
 
 - (void)_restoreFromSessionStateData:(NSData *)sessionStateData
@@ -4439,11 +4389,7 @@ WEBCORE_COMMAND(yankAndSelect)
 
 - (WKNavigation *)_restoreSessionState:(_WKSessionState *)sessionState andNavigate:(BOOL)navigate
 {
-    auto navigation = _page->restoreFromSessionState(sessionState->_sessionState, navigate);
-    if (!navigation)
-        return nil;
-
-    return [wrapper(*navigation.leakRef()) autorelease];
+    return wrapper(_page->restoreFromSessionState(sessionState->_sessionState, navigate));
 }
 
 - (void)_close
@@ -4463,7 +4409,7 @@ WEBCORE_COMMAND(yankAndSelect)
             capturedHandler(error == WebKit::CallbackBase::Error::None);
     });
 
-    return [wrapper(API::Attachment::create(identifier, *_page).leakRef()) autorelease];
+    return wrapper(API::Attachment::create(identifier, *_page));
 #else
     return nil;
 #endif
@@ -4747,7 +4693,7 @@ static inline WebCore::LayoutMilestones layoutMilestones(_WKRenderingProgressEve
     if (!diagnosticLoggingClient)
         return nil;
 
-    return [static_cast<WebKit::DiagnosticLoggingClient&>(*diagnosticLoggingClient).delegate().leakRef() autorelease];
+    return static_cast<WebKit::DiagnosticLoggingClient&>(*diagnosticLoggingClient).delegate().autorelease();
 }
 
 - (void)_setDiagnosticLoggingDelegate:(id<_WKDiagnosticLoggingDelegate>)diagnosticLoggingDelegate
@@ -4761,7 +4707,7 @@ static inline WebCore::LayoutMilestones layoutMilestones(_WKRenderingProgressEve
 
 - (id <_WKFindDelegate>)_findDelegate
 {
-    return [static_cast<WebKit::FindClient&>(_page->findClient()).delegate().leakRef() autorelease];
+    return static_cast<WebKit::FindClient&>(_page->findClient()).delegate().autorelease();
 }
 
 - (void)_setFindDelegate:(id<_WKFindDelegate>)findDelegate
index 8a8052d..bf187ff 100644 (file)
@@ -849,9 +849,7 @@ static NSString *defaultApplicationNameForUserAgent()
 
 - (_WKApplicationManifest *)_applicationManifest
 {
-    if (auto* manifest = _pageConfiguration->applicationManifest())
-        return wrapper(*manifest);
-    return nil;
+    return wrapper(_pageConfiguration->applicationManifest());
 }
 
 - (void)_setApplicationManifest:(_WKApplicationManifest *)applicationManifest
index 8252322..245e707 100644 (file)
@@ -48,12 +48,12 @@ using namespace WebCore;
 
 + (WKWebsiteDataStore *)defaultDataStore
 {
-    return WebKit::wrapper(API::WebsiteDataStore::defaultDataStore().get());
+    return wrapper(API::WebsiteDataStore::defaultDataStore());
 }
 
 + (WKWebsiteDataStore *)nonPersistentDataStore
 {
-    return [WebKit::wrapper(API::WebsiteDataStore::createNonPersistentDataStore().leakRef()) autorelease];
+    return wrapper(API::WebsiteDataStore::createNonPersistentDataStore());
 }
 
 - (void)dealloc
@@ -112,7 +112,7 @@ using namespace WebCore;
 
 - (WKHTTPCookieStore *)httpCookieStore
 {
-    return WebKit::wrapper(_websiteDataStore->httpCookieStore());
+    return wrapper(_websiteDataStore->httpCookieStore());
 }
 
 static WallTime toSystemClockTime(NSDate *date)
index c753503..3edd853 100644 (file)
@@ -84,7 +84,7 @@
 + (_WKApplicationManifest *)applicationManifestFromJSON:(NSString *)json manifestURL:(NSURL *)manifestURL documentURL:(NSURL *)documentURL
 {
     auto manifest = WebCore::ApplicationManifestParser::parse(WTF::String(json), WebCore::URL(manifestURL), WebCore::URL(documentURL));
-    return [API::wrapper(API::ApplicationManifest::create(manifest).leakRef()) autorelease];
+    return wrapper(API::ApplicationManifest::create(manifest));
 }
 
 - (API::Object&)_apiObject
index 6f819df..e842602 100644 (file)
@@ -39,7 +39,7 @@ using namespace WebKit;
     if (!location)
         return nil;
 
-    return [wrapper(WebGeolocationPosition::create(WebCore::GeolocationPosition { location }).leakRef()) autorelease];
+    return wrapper(WebGeolocationPosition::create(WebCore::GeolocationPosition { location }));
 }
 
 - (void)dealloc
index 6f7767b..f2fd5de 100644 (file)
 
 - (id)copyWithZone:(NSZone *)zone
 {
-    return wrapper(_processPoolConfiguration->copy().leakRef());
+    return [wrapper(_processPoolConfiguration->copy()) retain];
 }
 
 - (NSString *)customWebContentServiceBundleIdentifier
index 4fd17f3..c0ed7f7 100644 (file)
@@ -32,7 +32,7 @@
 
 + (_WKUserContentWorld *)worldWithName:(NSString *)name
 {
-    return [wrapper(API::UserContentWorld::worldWithName(name).leakRef()) autorelease];
+    return wrapper(API::UserContentWorld::worldWithName(name));
 }
 
 + (_WKUserContentWorld *)normalWorld
index 29b7380..613554b 100644 (file)
 
 - (WKWebsiteDataStore *)websiteDataStore
 {
-    auto* store = _websitePolicies->websiteDataStore();
-    return store ? WebKit::wrapper(*store) : nil;
+    return wrapper(_websitePolicies->websiteDataStore());
 }
 
 - (void)setWebsiteDataStore:(WKWebsiteDataStore *)websiteDataStore
index 9b5385b..8f60c36 100644 (file)
@@ -435,7 +435,7 @@ bool NavigationState::NavigationClient::didChangeBackForwardList(WebPageProxy&,
         for (auto& removedItem : removed)
             [removedItems addObject:wrapper(removedItem.get())];
     }
-    [(id <WKNavigationDelegatePrivate>)navigationDelegate _webView:m_navigationState.m_webView backForwardListItemAdded:added ? wrapper(*added) : nil removed:removedItems];
+    [(id <WKNavigationDelegatePrivate>)navigationDelegate _webView:m_navigationState.m_webView backForwardListItemAdded:wrapper(added) removed:removedItems];
     return true;
 }
 
@@ -493,8 +493,8 @@ void NavigationState::NavigationClient::decidePolicyForNavigationAction(WebPageP
                 return;
             }
 
-            RetainPtr<NSURLRequest> nsURLRequest = adoptNS(wrapper(API::URLRequest::create(navigationAction->request()).leakRef()));
-            if ([NSURLConnection canHandleRequest:nsURLRequest.get()] || webPage->urlSchemeHandlerForScheme([nsURLRequest URL].scheme)) {
+            NSURLRequest *nsURLRequest = wrapper(API::URLRequest::create(navigationAction->request()));
+            if ([NSURLConnection canHandleRequest:nsURLRequest] || webPage->urlSchemeHandlerForScheme([nsURLRequest URL].scheme)) {
                 if (navigationAction->shouldPerformDownload())
                     listener->download();
                 else
@@ -664,14 +664,11 @@ void NavigationState::NavigationClient::didStartProvisionalNavigation(WebPagePro
         return;
 
     // FIXME: We should assert that navigation is not null here, but it's currently null for some navigations through the page cache.
-    WKNavigation *wkNavigation = nil;
-    if (navigation)
-        wkNavigation = wrapper(*navigation);
 
     if (m_navigationState.m_navigationDelegateMethods.webViewDidStartProvisionalNavigationUserInfo)
-        [(id <WKNavigationDelegatePrivate>)navigationDelegate _webView:m_navigationState.m_webView didStartProvisionalNavigation:wkNavigation userInfo:userInfo ? static_cast<id <NSSecureCoding>>(userInfo->wrapper()) : nil];
+        [(id <WKNavigationDelegatePrivate>)navigationDelegate _webView:m_navigationState.m_webView didStartProvisionalNavigation:wrapper(navigation) userInfo:userInfo ? static_cast<id <NSSecureCoding>>(userInfo->wrapper()) : nil];
     else
-        [navigationDelegate webView:m_navigationState.m_webView didStartProvisionalNavigation:wkNavigation];
+        [navigationDelegate webView:m_navigationState.m_webView didStartProvisionalNavigation:wrapper(navigation)];
 }
 
 void NavigationState::NavigationClient::didReceiveServerRedirectForProvisionalNavigation(WebPageProxy& page, API::Navigation* navigation, API::Object*)
@@ -684,11 +681,8 @@ void NavigationState::NavigationClient::didReceiveServerRedirectForProvisionalNa
         return;
 
     // FIXME: We should assert that navigation is not null here, but it's currently null for some navigations through the page cache.
-    WKNavigation *wkNavigation = nil;
-    if (navigation)
-        wkNavigation = wrapper(*navigation);
 
-    [navigationDelegate webView:m_navigationState.m_webView didReceiveServerRedirectForProvisionalNavigation:wkNavigation];
+    [navigationDelegate webView:m_navigationState.m_webView didReceiveServerRedirectForProvisionalNavigation:wrapper(navigation)];
 }
 
 void NavigationState::NavigationClient::willPerformClientRedirect(WebPageProxy& page, const WTF::String& urlString, double delay)
@@ -735,10 +729,7 @@ static RetainPtr<NSError> createErrorWithRecoveryAttempter(WKWebView *webView, W
 void NavigationState::NavigationClient::didFailProvisionalNavigationWithError(WebPageProxy& page, WebFrameProxy& webFrameProxy, API::Navigation* navigation, const WebCore::ResourceError& error, API::Object*)
 {
     // FIXME: We should assert that navigation is not null here, but it's currently null for some navigations through the page cache.
-    RetainPtr<WKNavigation> wkNavigation;
-    if (navigation)
-        wkNavigation = wrapper(*navigation);
-    
+
     // FIXME: Set the error on the navigation object.
 
     if (!m_navigationState.m_navigationDelegateMethods.webViewDidFailProvisionalNavigationWithError)
@@ -749,16 +740,13 @@ void NavigationState::NavigationClient::didFailProvisionalNavigationWithError(We
         return;
 
     auto errorWithRecoveryAttempter = createErrorWithRecoveryAttempter(m_navigationState.m_webView, webFrameProxy, error);
-    [navigationDelegate webView:m_navigationState.m_webView didFailProvisionalNavigation:wkNavigation.get() withError:errorWithRecoveryAttempter.get()];
+    [navigationDelegate webView:m_navigationState.m_webView didFailProvisionalNavigation:wrapper(navigation) withError:errorWithRecoveryAttempter.get()];
 }
 
 // FIXME: Shouldn't need to pass the WebFrameProxy in here. At most, a FrameHandle.
-void NavigationState::NavigationClient::didFailProvisionalLoadInSubframeWithError(WebPageProxy& page, WebFrameProxy& webFrameProxy, const SecurityOriginData& securityOrigin, API::Navigation* navigation, const WebCore::ResourceError& error, API::Object*)
+void NavigationState::NavigationClient::didFailProvisionalLoadInSubframeWithError(WebPageProxy& page, WebFrameProxy& webFrameProxy, const SecurityOriginData& securityOrigin, API::Navigation*, const WebCore::ResourceError& error, API::Object*)
 {
     // FIXME: We should assert that navigation is not null here, but it's currently null because WebPageProxy::didFailProvisionalLoadForFrame passes null.
-    RetainPtr<WKNavigation> wkNavigation;
-    if (navigation)
-        wkNavigation = wrapper(*navigation);
 
     if (!m_navigationState.m_navigationDelegateMethods.webViewNavigationDidFailProvisionalLoadInSubframeWithError)
         return;
@@ -779,11 +767,8 @@ void NavigationState::NavigationClient::didCommitNavigation(WebPageProxy& page,
         return;
 
     // FIXME: We should assert that navigation is not null here, but it's currently null for some navigations through the page cache.
-    WKNavigation *wkNavigation = nil;
-    if (navigation)
-        wkNavigation = wrapper(*navigation);
 
-    [navigationDelegate webView:m_navigationState.m_webView didCommitNavigation:wkNavigation];
+    [navigationDelegate webView:m_navigationState.m_webView didCommitNavigation:wrapper(navigation)];
 }
 
 void NavigationState::NavigationClient::didFinishDocumentLoad(WebPageProxy& page, API::Navigation* navigation, API::Object*)
@@ -796,11 +781,8 @@ void NavigationState::NavigationClient::didFinishDocumentLoad(WebPageProxy& page
         return;
 
     // FIXME: We should assert that navigation is not null here, but it's currently null for some navigations through the page cache.
-    WKNavigation *wkNavigation = nil;
-    if (navigation)
-        wkNavigation = wrapper(*navigation);
 
-    [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webView:m_navigationState.m_webView navigationDidFinishDocumentLoad:wkNavigation];
+    [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webView:m_navigationState.m_webView navigationDidFinishDocumentLoad:wrapper(navigation)];
 }
 
 void NavigationState::NavigationClient::didFinishNavigation(WebPageProxy& page, API::Navigation* navigation, API::Object*)
@@ -813,11 +795,8 @@ void NavigationState::NavigationClient::didFinishNavigation(WebPageProxy& page,
         return;
 
     // FIXME: We should assert that navigation is not null here, but it's currently null for some navigations through the page cache.
-    WKNavigation *wkNavigation = nil;
-    if (navigation)
-        wkNavigation = wrapper(*navigation);
 
-    [navigationDelegate webView:m_navigationState.m_webView didFinishNavigation:wkNavigation];
+    [navigationDelegate webView:m_navigationState.m_webView didFinishNavigation:wrapper(navigation)];
 }
 
 // FIXME: Shouldn't need to pass the WebFrameProxy in here. At most, a FrameHandle.
@@ -832,15 +811,12 @@ void NavigationState::NavigationClient::didFailNavigationWithError(WebPageProxy&
         return;
 
     // FIXME: We should assert that navigation is not null here, but it's currently null for some navigations through the page cache.
-    WKNavigation *wkNavigation = nil;
-    if (navigation)
-        wkNavigation = wrapper(*navigation);
 
     auto errorWithRecoveryAttempter = createErrorWithRecoveryAttempter(m_navigationState.m_webView, webFrameProxy, error);
     if (m_navigationState.m_navigationDelegateMethods.webViewDidFailNavigationWithErrorUserInfo)
-        [(id <WKNavigationDelegatePrivate>)navigationDelegate _webView:m_navigationState.m_webView didFailNavigation:wkNavigation withError:errorWithRecoveryAttempter.get() userInfo:userInfo ? static_cast<id <NSSecureCoding>>(userInfo->wrapper()) : nil];
+        [(id <WKNavigationDelegatePrivate>)navigationDelegate _webView:m_navigationState.m_webView didFailNavigation:wrapper(navigation) withError:errorWithRecoveryAttempter.get() userInfo:userInfo ? static_cast<id <NSSecureCoding>>(userInfo->wrapper()) : nil];
     else
-        [navigationDelegate webView:m_navigationState.m_webView didFailNavigation:wkNavigation withError:errorWithRecoveryAttempter.get()];
+        [navigationDelegate webView:m_navigationState.m_webView didFailNavigation:wrapper(navigation) withError:errorWithRecoveryAttempter.get()];
 }
 
 void NavigationState::NavigationClient::didSameDocumentNavigation(WebPageProxy&, API::Navigation* navigation, SameDocumentNavigationType navigationType, API::Object*)
@@ -853,11 +829,8 @@ void NavigationState::NavigationClient::didSameDocumentNavigation(WebPageProxy&,
         return;
 
     // FIXME: We should assert that navigationID is not zero here, but it's currently zero for some navigations through the page cache.
-    WKNavigation *wkNavigation = nil;
-    if (navigation)
-        wkNavigation = wrapper(*navigation);
 
-    [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webView:m_navigationState.m_webView navigation:wkNavigation didSameDocumentNavigation:toWKSameDocumentNavigationType(navigationType)];
+    [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webView:m_navigationState.m_webView navigation:wrapper(navigation) didSameDocumentNavigation:toWKSameDocumentNavigationType(navigationType)];
 }
 
 void NavigationState::NavigationClient::renderingProgressDidChange(WebPageProxy&, WebCore::LayoutMilestones layoutMilestones)
index 623ba46..0459183 100644 (file)
@@ -34,7 +34,7 @@ namespace WebKit {
 RetainPtr<NSData> encodeSessionState(const SessionState& sessionState)
 {
 #if WK_API_ENABLED
-    return [wrapper(*WebKit::encodeLegacySessionState(sessionState).leakRef()) autorelease];
+    return wrapper(WebKit::encodeLegacySessionState(sessionState));
 #else
     return nullptr;
 #endif
index 945214d..b701412 100644 (file)
@@ -129,7 +129,7 @@ using namespace WebKit;
         }
     }
 
-    [configuration setProcessPool: ::WebKit::wrapper(inspectorProcessPool(inspectorLevelForPage(_inspectedPage)))];
+    [configuration setProcessPool:wrapper(inspectorProcessPool(inspectorLevelForPage(_inspectedPage)))];
     [configuration _setGroupIdentifier:inspectorPageGroupIdentifierForPage(_inspectedPage)];
 
     return configuration.autorelease();
index 9f483db..96adaa9 100644 (file)
@@ -52,11 +52,7 @@ using namespace WebKit;
 
 + (instancetype)lookUpFrameFromHandle:(_WKFrameHandle *)handle
 {
-    WebFrame* webFrame = WebProcess::singleton().webFrame(handle._frameID);
-    if (!webFrame)
-        return nil;
-
-    return wrapper(*webFrame);
+    return wrapper(WebProcess::singleton().webFrame(handle._frameID));
 }
 
 - (void)dealloc
@@ -72,8 +68,7 @@ using namespace WebKit;
 
 - (WKWebProcessPlugInHitTestResult *)hitTest:(CGPoint)point
 {
-    auto hitTestResult = _frame->hitTest(WebCore::IntPoint(point));
-    return [wrapper(*hitTestResult.leakRef()) autorelease];
+    return wrapper(_frame->hitTest(WebCore::IntPoint(point)));
 }
 
 - (JSValue *)jsNodeForNodeHandle:(WKWebProcessPlugInNodeHandle *)nodeHandle inWorld:(WKWebProcessPlugInScriptWorld *)world
@@ -100,7 +95,7 @@ using namespace WebKit;
 
 - (NSArray *)childFrames
 {
-    return [wrapper(_frame->childFrames().leakRef()) autorelease];
+    return wrapper(_frame->childFrames());
 }
 
 - (BOOL)containsAnyFormElements
@@ -110,7 +105,7 @@ using namespace WebKit;
 
 - (_WKFrameHandle *)handle
 {
-    return [wrapper(API::FrameHandle::create(_frame->frameID()).leakRef()) autorelease];
+    return wrapper(API::FrameHandle::create(_frame->frameID()));
 }
 
 static RetainPtr<NSArray> collectIcons(WebCore::Frame* frame, OptionSet<WebCore::LinkIconType> iconTypes)
@@ -139,8 +134,7 @@ static RetainPtr<NSArray> collectIcons(WebCore::Frame* frame, OptionSet<WebCore:
 
 - (WKWebProcessPlugInFrame *)_parentFrame
 {
-    WebFrame *parentFrame = _frame->parentFrame();
-    return parentFrame ? wrapper(*parentFrame) : nil;
+    return wrapper(_frame->parentFrame());
 }
 
 - (BOOL)_hasCustomContentProvider
index 7ea86c9..020947c 100644 (file)
@@ -44,8 +44,7 @@ using namespace WebKit;
 
 - (WKWebProcessPlugInNodeHandle *)nodeHandle
 {
-    auto nodeHandle = _hitTestResult->nodeHandle();
-    return nodeHandle ? [wrapper(*nodeHandle.leakRef()) autorelease] : nil;
+    return wrapper(_hitTestResult->nodeHandle());
 }
 
 #pragma mark WKObject protocol implementation
index 19744c8..91cd0c4 100644 (file)
@@ -49,21 +49,13 @@ using namespace WebKit;
 + (WKWebProcessPlugInNodeHandle *)nodeHandleWithJSValue:(JSValue *)value inContext:(JSContext *)context
 {
     JSContextRef contextRef = [context JSGlobalContextRef];
-    JSObjectRef objectRef = JSValueToObject(contextRef, [value JSValueRef], 0);
-    auto nodeHandle = InjectedBundleNodeHandle::getOrCreate(contextRef, objectRef);
-    if (!nodeHandle)
-        return nil;
-
-    return [wrapper(*nodeHandle.leakRef()) autorelease];
+    JSObjectRef objectRef = JSValueToObject(contextRef, [value JSValueRef], nullptr);
+    return wrapper(InjectedBundleNodeHandle::getOrCreate(contextRef, objectRef));
 }
 
 - (WKWebProcessPlugInFrame *)htmlIFrameElementContentFrame
 {
-    auto frame = _nodeHandle->htmlIFrameElementContentFrame();
-    if (!frame)
-        return nil;
-
-    return [wrapper(*frame.leakRef()) autorelease];
+    return wrapper(_nodeHandle->htmlIFrameElementContentFrame());
 }
 
 #if PLATFORM(IOS)
@@ -191,16 +183,12 @@ static _WKAutoFillButtonType toWKAutoFillButtonType(WebCore::AutoFillButtonType
 
 - (WKWebProcessPlugInNodeHandle *)HTMLTableCellElementCellAbove
 {
-    auto nodeHandle = _nodeHandle->htmlTableCellElementCellAbove();
-    if (!nodeHandle)
-        return nil;
-
-    return [wrapper(*nodeHandle.leakRef()) autorelease];
+    return wrapper(_nodeHandle->htmlTableCellElementCellAbove());
 }
 
 - (WKWebProcessPlugInFrame *)frame
 {
-    return [wrapper(*_nodeHandle->document()->documentFrame().leakRef()) autorelease];
+    return wrapper(_nodeHandle->document()->documentFrame());
 }
 
 - (InjectedBundleNodeHandle&)_nodeHandle
index 4fcb1a4..4a8dd34 100644 (file)
@@ -52,17 +52,13 @@ using namespace WebKit;
 + (WKWebProcessPlugInRangeHandle *)rangeHandleWithJSValue:(JSValue *)value inContext:(JSContext *)context
 {
     JSContextRef contextRef = [context JSGlobalContextRef];
-    JSObjectRef objectRef = JSValueToObject(contextRef, [value JSValueRef], 0);
-    auto rangeHandle = InjectedBundleRangeHandle::getOrCreate(contextRef, objectRef);
-    if (!rangeHandle)
-        return nil;
-
-    return [wrapper(*rangeHandle.leakRef()) autorelease];
+    JSObjectRef objectRef = JSValueToObject(contextRef, [value JSValueRef], nullptr);
+    return wrapper(InjectedBundleRangeHandle::getOrCreate(contextRef, objectRef));
 }
 
 - (WKWebProcessPlugInFrame *)frame
 {
-    return [wrapper(*_rangeHandle->document()->documentFrame().leakRef()) autorelease];
+    return wrapper(_rangeHandle->document()->documentFrame());
 }
 
 - (NSString *)text
index 6eba012..ae8d906 100644 (file)
@@ -36,8 +36,7 @@ using namespace WebKit;
 
 + (WKWebProcessPlugInScriptWorld *)world
 {
-    auto scriptWorld = InjectedBundleScriptWorld::create();
-    return [wrapper(scriptWorld.leakRef()) autorelease];
+    return wrapper(InjectedBundleScriptWorld::create());
 }
 
 + (WKWebProcessPlugInScriptWorld *)normalWorld
index 1935322..28dc066 100644 (file)
@@ -385,11 +385,7 @@ static void setUpResourceLoadClient(WKWebProcessPlugInBrowserContextController *
 
 - (WKWebProcessPlugInFrame *)mainFrame
 {
-    WebFrame *webKitMainFrame = _page->mainWebFrame();
-    if (!webKitMainFrame)
-        return nil;
-
-    return wrapper(*webKitMainFrame);
+    return wrapper(_page->mainWebFrame());
 }
 
 - (WKWebProcessPlugInPageGroup *)pageGroup
@@ -420,11 +416,7 @@ static void setUpResourceLoadClient(WKWebProcessPlugInBrowserContextController *
 
 + (instancetype)lookUpBrowsingContextFromHandle:(WKBrowsingContextHandle *)handle
 {
-    WebPage* webPage = WebProcess::singleton().webPage(handle.pageID);
-    if (!webPage)
-        return nil;
-
-    return wrapper(*webPage);
+    return wrapper(WebProcess::singleton().webPage(handle.pageID));
 }
 
 - (_WKRemoteObjectRegistry *)_remoteObjectRegistry