haikuwebkit/Source/WTF/wtf/WeakObjCPtr.h

127 lines
3.4 KiB
C
Raw Permalink Normal View History

/*
* Copyright (C) 2013-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
Regression(AsyncPolicyDelegates): Box.app login Window is blank https://bugs.webkit.org/show_bug.cgi?id=185832 <rdar://problem/40307871> Reviewed by Geoffrey Garen. Source/WebKit: Moved WeakObjCPtr.h header from WebKit/ to wtf/ so that it can be used in WebKitLegacy code. * UIProcess/API/Cocoa/WKBrowsingContextController.mm: * UIProcess/API/Cocoa/WKBrowsingContextControllerInternal.h: * UIProcess/API/Cocoa/WKConnection.mm: * UIProcess/API/Cocoa/WKHTTPCookieStore.mm: * UIProcess/API/Cocoa/WKProcessGroup.mm: * UIProcess/API/Cocoa/WKProcessPool.mm: * UIProcess/API/Cocoa/WKScriptMessage.mm: * UIProcess/API/Cocoa/WKWebView.mm: * UIProcess/API/Cocoa/WKWebViewConfiguration.mm: * UIProcess/API/Cocoa/_WKAutomationSession.mm: * UIProcess/API/Cocoa/_WKDownload.mm: * UIProcess/API/Cocoa/_WKElementAction.mm: * UIProcess/ApplicationStateTracker.h: * UIProcess/Cocoa/AutomationClient.h: * UIProcess/Cocoa/AutomationSessionClient.h: * UIProcess/Cocoa/DiagnosticLoggingClient.h: * UIProcess/Cocoa/DownloadClient.h: * UIProcess/Cocoa/FindClient.h: * UIProcess/Cocoa/FullscreenClient.h: * UIProcess/Cocoa/IconLoadingDelegate.h: * UIProcess/Cocoa/NavigationState.h: * UIProcess/Cocoa/UIDelegate.h: * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm: * UIProcess/Cocoa/WKReloadFrameErrorRecoveryAttempter.mm: * UIProcess/Cocoa/WebViewImpl.h: * UIProcess/ios/ViewGestureControllerIOS.mm: * UIProcess/ios/WKActionSheetAssistant.mm: * UIProcess/ios/WKContentViewInteraction.mm: * UIProcess/ios/WKPDFView.mm: (-[WKPDFView web_setContentProviderData:suggestedFilename:]): * UIProcess/ios/WKScrollView.mm: * UIProcess/mac/WKInspectorViewController.mm: * UIProcess/mac/WKInspectorWKWebView.mm: * WebKit.xcodeproj/project.pbxproj: * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm: Source/WebKitLegacy/mac: We used to have a bug where where we would fail to wait for the policy decision for the navigation response from the client and the load would keep going, racing with the client's policy decision. If the client did not respond in time, the behavior would be the same as "Use" policy action. Box.app fails to make any policy decision in its decidePolicyForMIMEType delegate but the load happened to proceed anyway due to our bug. Now that we've fixed the WebKit bug, however, the load would hang because the completion handler for the decidePolicyForNavigationResponse would never get called. To work around the issue, I made the policy listener weak on the WebFrameLoaderClient instead of retaining it. If the policy listener object gets destroyed because getting resolved, we now use "Use" policy action in its dealloc function to maintain previous behavior. * WebCoreSupport/WebFrameLoaderClient.h: * WebCoreSupport/WebFrameLoaderClient.mm: (WebFrameLoaderClient::cancelPolicyCheck): (WebFrameLoaderClient::setUpPolicyListener): (-[WebFramePolicyListener dealloc]): Source/WTF: Moved WeakObjCPtr.h from WebKit2 to WTF with RetainPtr.h, so that it can be used in WebKitLegacy code. * WTF.xcodeproj/project.pbxproj: * wtf/WeakObjCPtr.h: Renamed from Source/WebKit/Shared/mac/WeakObjCPtr.h. Tools: Add API test coverage. * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebKit/cocoa/WeakObjCPtr.mm: * TestWebKitAPI/Tests/mac/NoPolicyDelegateResponse.mm: Added. (-[NoPolicyDelegateDecisionDelegate webView:decidePolicyForNavigationAction:request:frame:decisionListener:]): (-[NoPolicyDelegateDecisionDelegate webView:decidePolicyForMIMEType:request:frame:decisionListener:]): (-[NoPolicyDelegateDecisionDelegate webView:didFinishLoadForFrame:]): (TestWebKitAPI::TEST): * TestWebKitAPI/cocoa/TestWKWebView.mm: (-[WKWebView _isBackground]): Canonical link: https://commits.webkit.org/201333@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232082 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-05-22 22:41:06 +00:00
#pragma once
#include <objc/runtime.h>
#include <type_traits>
#include <wtf/RetainPtr.h>
[Cocoa] More tweaks and refactoring to prepare for ARC https://bugs.webkit.org/show_bug.cgi?id=188245 Reviewed by Dan Bernstein. Source/JavaScriptCore: * API/JSValue.mm: Use __unsafe_unretained. (JSContainerConvertor::convert): Use auto for compatibility with the above. * API/JSWrapperMap.mm: (allocateConstructorForCustomClass): Use CFTypeRef instead of Protocol *. (-[JSWrapperMap initWithGlobalContextRef:]): Use __unsafe_unretained. * heap/Heap.cpp: Updated include for rename: FoundationSPI.h -> objcSPI.h. Source/WebCore: * bridge/objc/objc_instance.mm: Updated include for rename: FoundationSPI.h -> objcSPI.h. * platform/ios/wak/WebCoreThread.mm: Ditto. Source/WebKit: * Platform/cocoa/WKCrashReporter.mm: (WebKit::setCrashLogMessage): Refactor into a separate function for clarity. (WebKit::setCrashReportApplicationSpecificInformation): Use a bridging cast. * Shared/mac/PasteboardTypes.mm: (WebKit::PasteboardTypes::forEditing): Use a bridging cast. * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm: (WebKit::convertToNPNNString): Added. Uses CFStringRef rather than NSString so we can manually manage the autoreleasing. (WebKit::initializeKeyboardEvent): Use convertToNPNNString. (WebKit::NetscapePlugin::sendComplexTextInput): Ditto. * WebProcess/Plugins/PDF/PDFPlugin.mm: Use __unsafe_unretained explicitly for a parent pointer. We could consider moving to __weak after switching to ARC. Source/WebKitLegacy/mac: * Carbon/CarbonUtils.m: Updated include for rename: FoundationSPI.h -> objcSPI.h. * Carbon/CarbonWindowFrame.m: (-[CarbonWindowFrame dealloc]): Deleted. It was empty. * DOM/DOM.mm: (-[DOMElement _imageTIFFRepresentation]): Use a bridging cast. (-[DOMNodeFilter finalize]): Deleted. WebKit no longer supports Objective-C garbage collection so this method isn't useful. * DOM/DOMXPath.mm: (-[DOMNativeXPathNSResolver finalize]): Deleted. WebKit no longer supports Objective-C garbage collection so this method isn't useful. * History/WebHistory.mm: (-[WebHistoryPrivate data]): Allocate an NSData instead of casting from a CFData. * Misc/WebElementDictionary.mm: (addLookupKey): Use a bridging cast. (cacheValueForKey): Ditto. (-[WebElementDictionary _fillCache]): Ditto. (-[WebElementDictionary objectForKey:]): Ditto. * Misc/WebKitNSStringExtras.mm: (-[NSString _web_drawAtPoint:font:textColor:]): Use a bridging cast. (-[NSString _web_widthWithFont:]): Ditto. (-[NSString _webkit_stringByTrimmingWhitespace]): Ditto. * Misc/WebLocalizableStrings.mm: (WebLocalizedString): Use a bridging cast. * Misc/WebNSDataExtras.mm: (-[NSString _web_capitalizeRFC822HeaderFieldName]): Use a bridging cast and use CFBridgingRelease instead of calling autorelease directly. (-[NSData _webkit_parseRFC822HeaderFields]): Use NSString methods instead of a mix of CFString and NSString. Also simplified logic a bit, and cut down on the amount of explicit release and autorelease. * Misc/WebNSDictionaryExtras.h: Deleted unused methods. * Misc/WebNSDictionaryExtras.m: (-[NSDictionary _webkit_intForKey:]): Deleted. (-[NSMutableDictionary _webkit_setInt:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setFloat:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setBool:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setLongLong:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setUnsignedLongLong:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setUnsignedInt:forKey:]): Deleted. * Misc/WebStringTruncator.mm: (fontFromNSFont): Use a bridging cast. * Plugins/Hosted/NetscapePluginHostManager.mm: (WebKit::preferredBundleLocalizationName): Use a bridging cast and CFBridgingRelease. * Plugins/Hosted/NetscapePluginInstanceProxy.mm: (WebKit::NetscapePluginInstanceProxy::cleanup): Use a bridging cast. (WebKit::NetscapePluginInstanceProxy::status): Ditto. (WebKit::NetscapePluginInstanceProxy::loadURL): Ditto. (WebKit::NetscapePluginInstanceProxy::demarshalValueFromArray): Ditto. * Plugins/Hosted/ProxyInstance.mm: (WebKit::ProxyInstance::getPropertyNames): Ditto. * Plugins/WebBasePluginPackage.mm: (-[WebBasePluginPackage _objectForInfoDictionaryKey:]): Ditto. * Plugins/WebNetscapePluginEventHandlerCocoa.mm: (WebNetscapePluginEventHandlerCocoa::platformWindow): Ditto. * Plugins/WebNetscapePluginPackage.mm: (-[WebNetscapePluginPackage _initWithPath:]): Ditto. * Plugins/WebNetscapePluginView.mm: (-[WebNetscapePluginView _postURL:target:len:buf:file:notifyData:sendNotification:allowHeaders:]): Use bridging casts and use RetainPtr insteead of an explicit CFRelease. (-[WebNetscapePluginView status:]): Use a bridging cast. (-[WebNetscapePluginView popUpContextMenu:]): Ditto. * Plugins/WebPluginController.mm: (-[WebPluginController _cancelOutstandingChecks]): Use a bridging cast. * Plugins/WebPluginDatabase.mm: (checkCandidate): Use explicit __strong for out argument types. * Plugins/npapi.mm: (pluginViewForInstance): Use a bridging cast. * Storage/WebDatabaseManager.mm: (-[WebDatabaseManager detailsForDatabase:withOrigin:]): Use modern boxing instead of explicit NSNumber and NSDictionary calls. * WebCoreSupport/WebContextMenuClient.mm: (WebContextMenuClient::speak): Remove an unnecessary copy/autorelease pair. * WebCoreSupport/WebEditorClient.mm: (WebEditorClient::handleKeyboardEvent): Added a missing typecast. (WebEditorClient::handleInputMethodKeydown): Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: (WebFrameNetworkingContext::sourceApplicationAuditData const): Use a bridging cast. * WebCoreSupport/WebSecurityOriginPrivate.h: Forward declare WebSecurityOriginPrivate as a struct rather than an Objective-C class, since that's how it's defined. * WebInspector/WebNodeHighlighter.mm: Added missing includes. * WebView/WebFullScreenController.mm: (-[WebFullScreenController enterFullScreen:]): Use a bridging cast. * WebView/WebHTMLView.mm: (-[WebHTMLView _writeSelectionWithPasteboardTypes:toPasteboard:cachedAttributedString:]): Ditto. (-[WebHTMLView pasteboard:provideDataForType:]): Ditto. * WebView/WebImmediateActionController.mm: (-[WebImmediateActionController performHitTestAtPoint:]): Removed redundant code to go down to the document and then back to the frame. (-[WebImmediateActionController immediateActionRecognizerDidUpdateAnimation:]): Ditto. (-[WebImmediateActionController immediateActionRecognizerDidCancelAnimation:]): Ditto. (-[WebImmediateActionController immediateActionRecognizerDidCompleteAnimation:]): Ditto. * WebView/WebJSPDFDoc.mm: (jsPDFDocInitialize): Removed some unneeded type casting. (jsPDFDocFinalize): Ditto. (jsPDFDocPrint): Use a bridging cast. * WebView/WebPDFView.mm: (_applicationInfoForMIMEType): Use bridging casts. * WebView/WebPreferences.mm: (-[WebPreferences _setIntegerValue:forKey:]): Use boxing and setObject directly instead of methods from WebNSDictionaryExtras. (-[WebPreferences _setUnsignedIntValue:forKey:]): Ditto. (-[WebPreferences _setFloatValue:forKey:]): Ditto. (-[WebPreferences _setBoolValue:forKey:]): Ditto. (-[WebPreferences _setLongLongValue:forKey:]): Ditto. (-[WebPreferences _setUnsignedLongLongValue:forKey:]): Ditto. * WebView/WebView.mm: (-[WebView _removeFromAllWebViewsSet]): Use bridging cast. (-[WebView _addToAllWebViewsSet]): Ditto. (+[WebView closeAllWebViews]): Use a modern for loop instead of NSEnumerator. (-[WebView _windowVisibilityChanged:]): Moved this into the internal category so it can be called from WebViewData methods. * WebView/WebViewData.mm: Added an import so we can call an internal WebView method, _windowVisibilityChanged:. * WebView/WebViewInternal.h: Declared _windowVisibilityChanged: so it can be called from WebViewData methods. Source/WTF: * WTF.xcodeproj/project.pbxproj: Updated for rename: FoundationSPI.h -> objcSPI.h. * wtf/BlockPtr.h: Added missing include of "StdLibExtras.h". Also re-sorted includes. * wtf/HashFunctions.h: Add function for "__unsafe_unretained id". * wtf/HashTraits.h: Add traits for "__unsafe_unretained id". * wtf/PlatformMac.cmake: Updated for rename: FoundationSPI.h -> objcSPI.h. * wtf/WeakObjCPtr.h: Use mutable instead of const_cast, and write a version that uses __weak explicitly under ARC. Also moved function declarations from here to objcSPI.h. * wtf/cocoa/AutodrainedPool.cpp: Updated include for rename: FoundationSPI.h -> objcSPI.h. * wtf/spi/cocoa/objcSPI.h: Renamed from FoundationSPI.h and added the additional functions used by WeakObjCPtr.h. Also changed to both include the internal header and the function definitions when compiling with USE(APPLE_INTERNAL_SDK), helping us check that function definitions match. Tools: * DumpRenderTree/TestNetscapePlugIn/PluginObject.h: Use const void* for a CFTypeRef instead of void*. * DumpRenderTree/TestNetscapePlugIn/PluginObjectMac.mm: (createCoreAnimationLayer): Use CFBridgingRetain. * DumpRenderTree/mac/AccessibilityUIElementMac.mm: (AccessibilityUIElement::lineTextMarkerRangeForTextMarker): Use bridging casts. (AccessibilityUIElement::textMarkerRangeForElement): Ditto. (AccessibilityUIElement::selectedTextMarkerRange): Ditto. (AccessibilityUIElement::textMarkerRangeLength): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute): Ditto. (AccessibilityUIElement::indexForTextMarker): Ditto. (AccessibilityUIElement::textMarkerForIndex): Ditto. (AccessibilityUIElement::isTextMarkerValid): Ditto. (AccessibilityUIElement::previousTextMarker): Ditto. (AccessibilityUIElement::nextTextMarker): Ditto. (AccessibilityUIElement::stringForTextMarkerRange): Ditto. (createJSStringRef): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRange): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions): Ditto. (AccessibilityUIElement::textMarkerRangeForMarkers): Ditto. (AccessibilityUIElement::startTextMarkerForTextMarkerRange): Ditto. (AccessibilityUIElement::endTextMarkerForTextMarkerRange): Ditto. (AccessibilityUIElement::endTextMarkerForBounds): Ditto. (AccessibilityUIElement::startTextMarkerForBounds): Ditto. (AccessibilityUIElement::textMarkerForPoint): Ditto. (AccessibilityUIElement::accessibilityElementForTextMarker): Ditto. (AccessibilityUIElement::startTextMarker): Ditto. (AccessibilityUIElement::endTextMarker): Ditto. (AccessibilityUIElement::setSelectedVisibleTextRange): Ditto. (AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousWordStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextWordEndTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::paragraphTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousParagraphStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextParagraphEndTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::sentenceTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousSentenceStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextSentenceEndTextMarkerForTextMarker): Ditto. * DumpRenderTree/mac/DumpRenderTree.mm: (resetWebPreferencesToConsistentValues): Use bridging cast. (dumpFramesAsText): Ditto. (dumpBackForwardListForAllWindows): Use a modern for loop instead of CFArray functions to iterate the array. (dump): Use bridging cast. (runTest): Ditto. * DumpRenderTree/mac/DumpRenderTreePasteboard.mm: (+[LocalPasteboard alloc]): Use class_createInstance instead of NSAllocateObject. (toUTI): Return a RetainPtr<CFStringRef>. (-[LocalPasteboard types]): Use the above and bridging casts. (-[LocalPasteboard availableTypeFromArray:]): Ditto. (-[LocalPasteboard setData:forType:]): Ditto. (-[LocalPasteboard dataForType:]): Ditto. (-[LocalPasteboard setPropertyList:forType:]): Use NSPropertyListSerialization instead of CFPropertyList. (-[LocalPasteboard setString:forType:]): Use NSString method instead of CFStringCreateExternalRepresentation. * DumpRenderTree/mac/MockGeolocationProvider.h: Put CFTypeRef in a HashSet instead of an Objective-C object pointer type. * DumpRenderTree/mac/MockGeolocationProvider.mm: (-[MockGeolocationProvider registerWebView:]): Update for above. (-[MockGeolocationProvider unregisterWebView:]): Ditto. (-[MockGeolocationProvider timerFired]): Ditto. * DumpRenderTree/mac/MockWebNotificationProvider.h: Use CFTypeRef in HashMap and HashSet instead of an Objective-C object pointer type. * DumpRenderTree/mac/MockWebNotificationProvider.mm: (-[MockWebNotificationProvider registerWebView:]): Update for above. (-[MockWebNotificationProvider unregisterWebView:]): Ditto. (-[MockWebNotificationProvider showNotification:fromWebView:]): Ditto. (-[MockWebNotificationProvider cancelNotification:]): Ditto. (-[MockWebNotificationProvider simulateWebNotificationClick:]): Ditto. * DumpRenderTree/mac/ObjCPlugin.m: (-[JSObjC retainObject:]): Use CFRetain instead of -[NSObject retain]. * DumpRenderTree/mac/TestRunnerMac.mm: (TestRunner::addDisallowedURL): Use bridging cast. (TestRunner::applicationCacheDiskUsageForOrigin): Ditto. (TestRunner::clearApplicationCacheForOrigin): Ditto. (originsArrayToJS): Ditto. (TestRunner::copyDecodedHostName): Ditto. (TestRunner::copyEncodedHostName): Ditto. (TestRunner::queueLoad): Ditto. (TestRunner::setDomainRelaxationForbiddenForURLScheme): Ditto. (TestRunner::setMockGeolocationPositionUnavailableError): Ditto. (TestRunner::setUserStyleSheetLocation): Ditto. (TestRunner::setValueForUser): Ditto. (TestRunner::overridePreference): Ditto. (TestRunner::execCommand): Ditto. (TestRunner::findString): Ditto. (TestRunner::isCommandEnabled): Ditto. (TestRunner::addOriginAccessWhitelistEntry): Ditto. (TestRunner::removeOriginAccessWhitelistEntry): Ditto. (TestRunner::addUserScript): Ditto. (TestRunner::addUserStyleSheet): Ditto. (TestRunner::evaluateInWebInspector): Ditto. (TestRunner::evaluateScriptInIsolatedWorld): Ditto. (TestRunner::authenticateSession): Ditto. (TestRunner::grantWebNotificationPermission): Ditto. (TestRunner::denyWebNotificationPermission): Ditto. * TestRunnerShared/cocoa/LayoutTestSpellChecker.mm: (-[LayoutTestSpellChecker setResultsFromJSObject:inContext:]): Ditto. * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm: (WTR::AccessibilityUIElement::lineTextMarkerRangeForTextMarker): Use bridging cast. (WTR::AccessibilityUIElement::textMarkerRangeForElement): Ditto. (WTR::AccessibilityUIElement::previousTextMarker): Ditto. (WTR::AccessibilityUIElement::nextTextMarker): Ditto. (WTR::AccessibilityUIElement::textMarkerRangeForMarkers): Ditto. (WTR::AccessibilityUIElement::selectedTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::startTextMarkerForTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::endTextMarkerForTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::endTextMarkerForBounds): Ditto. (WTR::AccessibilityUIElement::startTextMarkerForBounds): Ditto. (WTR::AccessibilityUIElement::textMarkerForPoint): Ditto. (WTR::AccessibilityUIElement::textMarkerForIndex): Ditto. (WTR::AccessibilityUIElement::startTextMarker): Ditto. (WTR::AccessibilityUIElement::endTextMarker): Ditto. (WTR::AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousWordStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextWordEndTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::paragraphTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousParagraphStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextParagraphEndTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::sentenceTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousSentenceStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextSentenceEndTextMarkerForTextMarker): Ditto. * WebKitTestRunner/PlatformMac.cmake: Added WebKitTestRunnerWindow.h and .mm files. * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: Ditto. * WebKitTestRunner/mac/EventSenderProxy.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. * WebKitTestRunner/mac/PlatformWebViewMac.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. Moved WebKitTestRunnerWindow class into a separate file. (WTR::PlatformWebView::keyWindow): Call +[WebKitTestRunnerWindow _WTR_keyWindow] instead of have a second copy of the implementation. * WebKitTestRunner/mac/WebKitTestRunnerEvent.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. Also removed "using namespace". (+[WebKitTestRunnerEvent mouseLocation]): Updated for above. * WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm: (+[LocalPasteboard alloc]): Use class_createInstance instead of NSAllocateObject. (-[LocalPasteboard availableTypeFromArray:]): Use modern for loop. (-[LocalPasteboard setData:forType:]): Reordered method to be a tiny bit more efficient. (-[LocalPasteboard setPropertyList:forType:]): Use NSPropertyListSerialization instead of CFPropertyList. (-[LocalPasteboard setString:forType:]): Use NSString method instead of CFStringCreateExternalRepresentation. * WebKitTestRunner/mac/WebKitTestRunnerWindow.h: Moved declaration of WebKitTestRunnerWindow here so it can be included by files that need to know what the type is and that it inherits from NSWindow. * WebKitTestRunner/mac/WebKitTestRunnerWindow.mm: Added. Moved implementation here. (+[WebKitTestRunnerWindow _WTR_keyWindow]): Use modern for loop instead of the old, messier implementation. Canonical link: https://commits.webkit.org/203508@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234685 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-08-08 02:39:12 +00:00
#include <wtf/spi/cocoa/objcSPI.h>
// Because ARC enablement is a compile-time choice, and we compile this header
// both ways, we need a separate copy of our code when ARC is enabled.
#if __has_feature(objc_arc)
#define WeakObjCPtr WeakObjCPtrArc
#endif
Regression(AsyncPolicyDelegates): Box.app login Window is blank https://bugs.webkit.org/show_bug.cgi?id=185832 <rdar://problem/40307871> Reviewed by Geoffrey Garen. Source/WebKit: Moved WeakObjCPtr.h header from WebKit/ to wtf/ so that it can be used in WebKitLegacy code. * UIProcess/API/Cocoa/WKBrowsingContextController.mm: * UIProcess/API/Cocoa/WKBrowsingContextControllerInternal.h: * UIProcess/API/Cocoa/WKConnection.mm: * UIProcess/API/Cocoa/WKHTTPCookieStore.mm: * UIProcess/API/Cocoa/WKProcessGroup.mm: * UIProcess/API/Cocoa/WKProcessPool.mm: * UIProcess/API/Cocoa/WKScriptMessage.mm: * UIProcess/API/Cocoa/WKWebView.mm: * UIProcess/API/Cocoa/WKWebViewConfiguration.mm: * UIProcess/API/Cocoa/_WKAutomationSession.mm: * UIProcess/API/Cocoa/_WKDownload.mm: * UIProcess/API/Cocoa/_WKElementAction.mm: * UIProcess/ApplicationStateTracker.h: * UIProcess/Cocoa/AutomationClient.h: * UIProcess/Cocoa/AutomationSessionClient.h: * UIProcess/Cocoa/DiagnosticLoggingClient.h: * UIProcess/Cocoa/DownloadClient.h: * UIProcess/Cocoa/FindClient.h: * UIProcess/Cocoa/FullscreenClient.h: * UIProcess/Cocoa/IconLoadingDelegate.h: * UIProcess/Cocoa/NavigationState.h: * UIProcess/Cocoa/UIDelegate.h: * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm: * UIProcess/Cocoa/WKReloadFrameErrorRecoveryAttempter.mm: * UIProcess/Cocoa/WebViewImpl.h: * UIProcess/ios/ViewGestureControllerIOS.mm: * UIProcess/ios/WKActionSheetAssistant.mm: * UIProcess/ios/WKContentViewInteraction.mm: * UIProcess/ios/WKPDFView.mm: (-[WKPDFView web_setContentProviderData:suggestedFilename:]): * UIProcess/ios/WKScrollView.mm: * UIProcess/mac/WKInspectorViewController.mm: * UIProcess/mac/WKInspectorWKWebView.mm: * WebKit.xcodeproj/project.pbxproj: * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm: Source/WebKitLegacy/mac: We used to have a bug where where we would fail to wait for the policy decision for the navigation response from the client and the load would keep going, racing with the client's policy decision. If the client did not respond in time, the behavior would be the same as "Use" policy action. Box.app fails to make any policy decision in its decidePolicyForMIMEType delegate but the load happened to proceed anyway due to our bug. Now that we've fixed the WebKit bug, however, the load would hang because the completion handler for the decidePolicyForNavigationResponse would never get called. To work around the issue, I made the policy listener weak on the WebFrameLoaderClient instead of retaining it. If the policy listener object gets destroyed because getting resolved, we now use "Use" policy action in its dealloc function to maintain previous behavior. * WebCoreSupport/WebFrameLoaderClient.h: * WebCoreSupport/WebFrameLoaderClient.mm: (WebFrameLoaderClient::cancelPolicyCheck): (WebFrameLoaderClient::setUpPolicyListener): (-[WebFramePolicyListener dealloc]): Source/WTF: Moved WeakObjCPtr.h from WebKit2 to WTF with RetainPtr.h, so that it can be used in WebKitLegacy code. * WTF.xcodeproj/project.pbxproj: * wtf/WeakObjCPtr.h: Renamed from Source/WebKit/Shared/mac/WeakObjCPtr.h. Tools: Add API test coverage. * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebKit/cocoa/WeakObjCPtr.mm: * TestWebKitAPI/Tests/mac/NoPolicyDelegateResponse.mm: Added. (-[NoPolicyDelegateDecisionDelegate webView:decidePolicyForNavigationAction:request:frame:decisionListener:]): (-[NoPolicyDelegateDecisionDelegate webView:decidePolicyForMIMEType:request:frame:decisionListener:]): (-[NoPolicyDelegateDecisionDelegate webView:didFinishLoadForFrame:]): (TestWebKitAPI::TEST): * TestWebKitAPI/cocoa/TestWKWebView.mm: (-[WKWebView _isBackground]): Canonical link: https://commits.webkit.org/201333@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232082 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-05-22 22:41:06 +00:00
namespace WTF {
template<typename T> class WeakObjCPtr {
public:
[Cocoa] More tweaks and refactoring to prepare for ARC https://bugs.webkit.org/show_bug.cgi?id=188245 Reviewed by Dan Bernstein. Source/JavaScriptCore: * API/JSValue.mm: Use __unsafe_unretained. (JSContainerConvertor::convert): Use auto for compatibility with the above. * API/JSWrapperMap.mm: (allocateConstructorForCustomClass): Use CFTypeRef instead of Protocol *. (-[JSWrapperMap initWithGlobalContextRef:]): Use __unsafe_unretained. * heap/Heap.cpp: Updated include for rename: FoundationSPI.h -> objcSPI.h. Source/WebCore: * bridge/objc/objc_instance.mm: Updated include for rename: FoundationSPI.h -> objcSPI.h. * platform/ios/wak/WebCoreThread.mm: Ditto. Source/WebKit: * Platform/cocoa/WKCrashReporter.mm: (WebKit::setCrashLogMessage): Refactor into a separate function for clarity. (WebKit::setCrashReportApplicationSpecificInformation): Use a bridging cast. * Shared/mac/PasteboardTypes.mm: (WebKit::PasteboardTypes::forEditing): Use a bridging cast. * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm: (WebKit::convertToNPNNString): Added. Uses CFStringRef rather than NSString so we can manually manage the autoreleasing. (WebKit::initializeKeyboardEvent): Use convertToNPNNString. (WebKit::NetscapePlugin::sendComplexTextInput): Ditto. * WebProcess/Plugins/PDF/PDFPlugin.mm: Use __unsafe_unretained explicitly for a parent pointer. We could consider moving to __weak after switching to ARC. Source/WebKitLegacy/mac: * Carbon/CarbonUtils.m: Updated include for rename: FoundationSPI.h -> objcSPI.h. * Carbon/CarbonWindowFrame.m: (-[CarbonWindowFrame dealloc]): Deleted. It was empty. * DOM/DOM.mm: (-[DOMElement _imageTIFFRepresentation]): Use a bridging cast. (-[DOMNodeFilter finalize]): Deleted. WebKit no longer supports Objective-C garbage collection so this method isn't useful. * DOM/DOMXPath.mm: (-[DOMNativeXPathNSResolver finalize]): Deleted. WebKit no longer supports Objective-C garbage collection so this method isn't useful. * History/WebHistory.mm: (-[WebHistoryPrivate data]): Allocate an NSData instead of casting from a CFData. * Misc/WebElementDictionary.mm: (addLookupKey): Use a bridging cast. (cacheValueForKey): Ditto. (-[WebElementDictionary _fillCache]): Ditto. (-[WebElementDictionary objectForKey:]): Ditto. * Misc/WebKitNSStringExtras.mm: (-[NSString _web_drawAtPoint:font:textColor:]): Use a bridging cast. (-[NSString _web_widthWithFont:]): Ditto. (-[NSString _webkit_stringByTrimmingWhitespace]): Ditto. * Misc/WebLocalizableStrings.mm: (WebLocalizedString): Use a bridging cast. * Misc/WebNSDataExtras.mm: (-[NSString _web_capitalizeRFC822HeaderFieldName]): Use a bridging cast and use CFBridgingRelease instead of calling autorelease directly. (-[NSData _webkit_parseRFC822HeaderFields]): Use NSString methods instead of a mix of CFString and NSString. Also simplified logic a bit, and cut down on the amount of explicit release and autorelease. * Misc/WebNSDictionaryExtras.h: Deleted unused methods. * Misc/WebNSDictionaryExtras.m: (-[NSDictionary _webkit_intForKey:]): Deleted. (-[NSMutableDictionary _webkit_setInt:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setFloat:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setBool:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setLongLong:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setUnsignedLongLong:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setUnsignedInt:forKey:]): Deleted. * Misc/WebStringTruncator.mm: (fontFromNSFont): Use a bridging cast. * Plugins/Hosted/NetscapePluginHostManager.mm: (WebKit::preferredBundleLocalizationName): Use a bridging cast and CFBridgingRelease. * Plugins/Hosted/NetscapePluginInstanceProxy.mm: (WebKit::NetscapePluginInstanceProxy::cleanup): Use a bridging cast. (WebKit::NetscapePluginInstanceProxy::status): Ditto. (WebKit::NetscapePluginInstanceProxy::loadURL): Ditto. (WebKit::NetscapePluginInstanceProxy::demarshalValueFromArray): Ditto. * Plugins/Hosted/ProxyInstance.mm: (WebKit::ProxyInstance::getPropertyNames): Ditto. * Plugins/WebBasePluginPackage.mm: (-[WebBasePluginPackage _objectForInfoDictionaryKey:]): Ditto. * Plugins/WebNetscapePluginEventHandlerCocoa.mm: (WebNetscapePluginEventHandlerCocoa::platformWindow): Ditto. * Plugins/WebNetscapePluginPackage.mm: (-[WebNetscapePluginPackage _initWithPath:]): Ditto. * Plugins/WebNetscapePluginView.mm: (-[WebNetscapePluginView _postURL:target:len:buf:file:notifyData:sendNotification:allowHeaders:]): Use bridging casts and use RetainPtr insteead of an explicit CFRelease. (-[WebNetscapePluginView status:]): Use a bridging cast. (-[WebNetscapePluginView popUpContextMenu:]): Ditto. * Plugins/WebPluginController.mm: (-[WebPluginController _cancelOutstandingChecks]): Use a bridging cast. * Plugins/WebPluginDatabase.mm: (checkCandidate): Use explicit __strong for out argument types. * Plugins/npapi.mm: (pluginViewForInstance): Use a bridging cast. * Storage/WebDatabaseManager.mm: (-[WebDatabaseManager detailsForDatabase:withOrigin:]): Use modern boxing instead of explicit NSNumber and NSDictionary calls. * WebCoreSupport/WebContextMenuClient.mm: (WebContextMenuClient::speak): Remove an unnecessary copy/autorelease pair. * WebCoreSupport/WebEditorClient.mm: (WebEditorClient::handleKeyboardEvent): Added a missing typecast. (WebEditorClient::handleInputMethodKeydown): Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: (WebFrameNetworkingContext::sourceApplicationAuditData const): Use a bridging cast. * WebCoreSupport/WebSecurityOriginPrivate.h: Forward declare WebSecurityOriginPrivate as a struct rather than an Objective-C class, since that's how it's defined. * WebInspector/WebNodeHighlighter.mm: Added missing includes. * WebView/WebFullScreenController.mm: (-[WebFullScreenController enterFullScreen:]): Use a bridging cast. * WebView/WebHTMLView.mm: (-[WebHTMLView _writeSelectionWithPasteboardTypes:toPasteboard:cachedAttributedString:]): Ditto. (-[WebHTMLView pasteboard:provideDataForType:]): Ditto. * WebView/WebImmediateActionController.mm: (-[WebImmediateActionController performHitTestAtPoint:]): Removed redundant code to go down to the document and then back to the frame. (-[WebImmediateActionController immediateActionRecognizerDidUpdateAnimation:]): Ditto. (-[WebImmediateActionController immediateActionRecognizerDidCancelAnimation:]): Ditto. (-[WebImmediateActionController immediateActionRecognizerDidCompleteAnimation:]): Ditto. * WebView/WebJSPDFDoc.mm: (jsPDFDocInitialize): Removed some unneeded type casting. (jsPDFDocFinalize): Ditto. (jsPDFDocPrint): Use a bridging cast. * WebView/WebPDFView.mm: (_applicationInfoForMIMEType): Use bridging casts. * WebView/WebPreferences.mm: (-[WebPreferences _setIntegerValue:forKey:]): Use boxing and setObject directly instead of methods from WebNSDictionaryExtras. (-[WebPreferences _setUnsignedIntValue:forKey:]): Ditto. (-[WebPreferences _setFloatValue:forKey:]): Ditto. (-[WebPreferences _setBoolValue:forKey:]): Ditto. (-[WebPreferences _setLongLongValue:forKey:]): Ditto. (-[WebPreferences _setUnsignedLongLongValue:forKey:]): Ditto. * WebView/WebView.mm: (-[WebView _removeFromAllWebViewsSet]): Use bridging cast. (-[WebView _addToAllWebViewsSet]): Ditto. (+[WebView closeAllWebViews]): Use a modern for loop instead of NSEnumerator. (-[WebView _windowVisibilityChanged:]): Moved this into the internal category so it can be called from WebViewData methods. * WebView/WebViewData.mm: Added an import so we can call an internal WebView method, _windowVisibilityChanged:. * WebView/WebViewInternal.h: Declared _windowVisibilityChanged: so it can be called from WebViewData methods. Source/WTF: * WTF.xcodeproj/project.pbxproj: Updated for rename: FoundationSPI.h -> objcSPI.h. * wtf/BlockPtr.h: Added missing include of "StdLibExtras.h". Also re-sorted includes. * wtf/HashFunctions.h: Add function for "__unsafe_unretained id". * wtf/HashTraits.h: Add traits for "__unsafe_unretained id". * wtf/PlatformMac.cmake: Updated for rename: FoundationSPI.h -> objcSPI.h. * wtf/WeakObjCPtr.h: Use mutable instead of const_cast, and write a version that uses __weak explicitly under ARC. Also moved function declarations from here to objcSPI.h. * wtf/cocoa/AutodrainedPool.cpp: Updated include for rename: FoundationSPI.h -> objcSPI.h. * wtf/spi/cocoa/objcSPI.h: Renamed from FoundationSPI.h and added the additional functions used by WeakObjCPtr.h. Also changed to both include the internal header and the function definitions when compiling with USE(APPLE_INTERNAL_SDK), helping us check that function definitions match. Tools: * DumpRenderTree/TestNetscapePlugIn/PluginObject.h: Use const void* for a CFTypeRef instead of void*. * DumpRenderTree/TestNetscapePlugIn/PluginObjectMac.mm: (createCoreAnimationLayer): Use CFBridgingRetain. * DumpRenderTree/mac/AccessibilityUIElementMac.mm: (AccessibilityUIElement::lineTextMarkerRangeForTextMarker): Use bridging casts. (AccessibilityUIElement::textMarkerRangeForElement): Ditto. (AccessibilityUIElement::selectedTextMarkerRange): Ditto. (AccessibilityUIElement::textMarkerRangeLength): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute): Ditto. (AccessibilityUIElement::indexForTextMarker): Ditto. (AccessibilityUIElement::textMarkerForIndex): Ditto. (AccessibilityUIElement::isTextMarkerValid): Ditto. (AccessibilityUIElement::previousTextMarker): Ditto. (AccessibilityUIElement::nextTextMarker): Ditto. (AccessibilityUIElement::stringForTextMarkerRange): Ditto. (createJSStringRef): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRange): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions): Ditto. (AccessibilityUIElement::textMarkerRangeForMarkers): Ditto. (AccessibilityUIElement::startTextMarkerForTextMarkerRange): Ditto. (AccessibilityUIElement::endTextMarkerForTextMarkerRange): Ditto. (AccessibilityUIElement::endTextMarkerForBounds): Ditto. (AccessibilityUIElement::startTextMarkerForBounds): Ditto. (AccessibilityUIElement::textMarkerForPoint): Ditto. (AccessibilityUIElement::accessibilityElementForTextMarker): Ditto. (AccessibilityUIElement::startTextMarker): Ditto. (AccessibilityUIElement::endTextMarker): Ditto. (AccessibilityUIElement::setSelectedVisibleTextRange): Ditto. (AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousWordStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextWordEndTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::paragraphTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousParagraphStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextParagraphEndTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::sentenceTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousSentenceStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextSentenceEndTextMarkerForTextMarker): Ditto. * DumpRenderTree/mac/DumpRenderTree.mm: (resetWebPreferencesToConsistentValues): Use bridging cast. (dumpFramesAsText): Ditto. (dumpBackForwardListForAllWindows): Use a modern for loop instead of CFArray functions to iterate the array. (dump): Use bridging cast. (runTest): Ditto. * DumpRenderTree/mac/DumpRenderTreePasteboard.mm: (+[LocalPasteboard alloc]): Use class_createInstance instead of NSAllocateObject. (toUTI): Return a RetainPtr<CFStringRef>. (-[LocalPasteboard types]): Use the above and bridging casts. (-[LocalPasteboard availableTypeFromArray:]): Ditto. (-[LocalPasteboard setData:forType:]): Ditto. (-[LocalPasteboard dataForType:]): Ditto. (-[LocalPasteboard setPropertyList:forType:]): Use NSPropertyListSerialization instead of CFPropertyList. (-[LocalPasteboard setString:forType:]): Use NSString method instead of CFStringCreateExternalRepresentation. * DumpRenderTree/mac/MockGeolocationProvider.h: Put CFTypeRef in a HashSet instead of an Objective-C object pointer type. * DumpRenderTree/mac/MockGeolocationProvider.mm: (-[MockGeolocationProvider registerWebView:]): Update for above. (-[MockGeolocationProvider unregisterWebView:]): Ditto. (-[MockGeolocationProvider timerFired]): Ditto. * DumpRenderTree/mac/MockWebNotificationProvider.h: Use CFTypeRef in HashMap and HashSet instead of an Objective-C object pointer type. * DumpRenderTree/mac/MockWebNotificationProvider.mm: (-[MockWebNotificationProvider registerWebView:]): Update for above. (-[MockWebNotificationProvider unregisterWebView:]): Ditto. (-[MockWebNotificationProvider showNotification:fromWebView:]): Ditto. (-[MockWebNotificationProvider cancelNotification:]): Ditto. (-[MockWebNotificationProvider simulateWebNotificationClick:]): Ditto. * DumpRenderTree/mac/ObjCPlugin.m: (-[JSObjC retainObject:]): Use CFRetain instead of -[NSObject retain]. * DumpRenderTree/mac/TestRunnerMac.mm: (TestRunner::addDisallowedURL): Use bridging cast. (TestRunner::applicationCacheDiskUsageForOrigin): Ditto. (TestRunner::clearApplicationCacheForOrigin): Ditto. (originsArrayToJS): Ditto. (TestRunner::copyDecodedHostName): Ditto. (TestRunner::copyEncodedHostName): Ditto. (TestRunner::queueLoad): Ditto. (TestRunner::setDomainRelaxationForbiddenForURLScheme): Ditto. (TestRunner::setMockGeolocationPositionUnavailableError): Ditto. (TestRunner::setUserStyleSheetLocation): Ditto. (TestRunner::setValueForUser): Ditto. (TestRunner::overridePreference): Ditto. (TestRunner::execCommand): Ditto. (TestRunner::findString): Ditto. (TestRunner::isCommandEnabled): Ditto. (TestRunner::addOriginAccessWhitelistEntry): Ditto. (TestRunner::removeOriginAccessWhitelistEntry): Ditto. (TestRunner::addUserScript): Ditto. (TestRunner::addUserStyleSheet): Ditto. (TestRunner::evaluateInWebInspector): Ditto. (TestRunner::evaluateScriptInIsolatedWorld): Ditto. (TestRunner::authenticateSession): Ditto. (TestRunner::grantWebNotificationPermission): Ditto. (TestRunner::denyWebNotificationPermission): Ditto. * TestRunnerShared/cocoa/LayoutTestSpellChecker.mm: (-[LayoutTestSpellChecker setResultsFromJSObject:inContext:]): Ditto. * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm: (WTR::AccessibilityUIElement::lineTextMarkerRangeForTextMarker): Use bridging cast. (WTR::AccessibilityUIElement::textMarkerRangeForElement): Ditto. (WTR::AccessibilityUIElement::previousTextMarker): Ditto. (WTR::AccessibilityUIElement::nextTextMarker): Ditto. (WTR::AccessibilityUIElement::textMarkerRangeForMarkers): Ditto. (WTR::AccessibilityUIElement::selectedTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::startTextMarkerForTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::endTextMarkerForTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::endTextMarkerForBounds): Ditto. (WTR::AccessibilityUIElement::startTextMarkerForBounds): Ditto. (WTR::AccessibilityUIElement::textMarkerForPoint): Ditto. (WTR::AccessibilityUIElement::textMarkerForIndex): Ditto. (WTR::AccessibilityUIElement::startTextMarker): Ditto. (WTR::AccessibilityUIElement::endTextMarker): Ditto. (WTR::AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousWordStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextWordEndTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::paragraphTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousParagraphStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextParagraphEndTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::sentenceTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousSentenceStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextSentenceEndTextMarkerForTextMarker): Ditto. * WebKitTestRunner/PlatformMac.cmake: Added WebKitTestRunnerWindow.h and .mm files. * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: Ditto. * WebKitTestRunner/mac/EventSenderProxy.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. * WebKitTestRunner/mac/PlatformWebViewMac.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. Moved WebKitTestRunnerWindow class into a separate file. (WTR::PlatformWebView::keyWindow): Call +[WebKitTestRunnerWindow _WTR_keyWindow] instead of have a second copy of the implementation. * WebKitTestRunner/mac/WebKitTestRunnerEvent.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. Also removed "using namespace". (+[WebKitTestRunnerEvent mouseLocation]): Updated for above. * WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm: (+[LocalPasteboard alloc]): Use class_createInstance instead of NSAllocateObject. (-[LocalPasteboard availableTypeFromArray:]): Use modern for loop. (-[LocalPasteboard setData:forType:]): Reordered method to be a tiny bit more efficient. (-[LocalPasteboard setPropertyList:forType:]): Use NSPropertyListSerialization instead of CFPropertyList. (-[LocalPasteboard setString:forType:]): Use NSString method instead of CFStringCreateExternalRepresentation. * WebKitTestRunner/mac/WebKitTestRunnerWindow.h: Moved declaration of WebKitTestRunnerWindow here so it can be included by files that need to know what the type is and that it inherits from NSWindow. * WebKitTestRunner/mac/WebKitTestRunnerWindow.mm: Added. Moved implementation here. (+[WebKitTestRunnerWindow _WTR_keyWindow]): Use modern for loop instead of the old, messier implementation. Canonical link: https://commits.webkit.org/203508@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234685 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-08-08 02:39:12 +00:00
using ValueType = typename std::remove_pointer<T>::type;
[Cocoa] More tweaks and refactoring to prepare for ARC https://bugs.webkit.org/show_bug.cgi?id=188245 Reviewed by Dan Bernstein. Source/JavaScriptCore: * API/JSValue.mm: Use __unsafe_unretained. (JSContainerConvertor::convert): Use auto for compatibility with the above. * API/JSWrapperMap.mm: (allocateConstructorForCustomClass): Use CFTypeRef instead of Protocol *. (-[JSWrapperMap initWithGlobalContextRef:]): Use __unsafe_unretained. * heap/Heap.cpp: Updated include for rename: FoundationSPI.h -> objcSPI.h. Source/WebCore: * bridge/objc/objc_instance.mm: Updated include for rename: FoundationSPI.h -> objcSPI.h. * platform/ios/wak/WebCoreThread.mm: Ditto. Source/WebKit: * Platform/cocoa/WKCrashReporter.mm: (WebKit::setCrashLogMessage): Refactor into a separate function for clarity. (WebKit::setCrashReportApplicationSpecificInformation): Use a bridging cast. * Shared/mac/PasteboardTypes.mm: (WebKit::PasteboardTypes::forEditing): Use a bridging cast. * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm: (WebKit::convertToNPNNString): Added. Uses CFStringRef rather than NSString so we can manually manage the autoreleasing. (WebKit::initializeKeyboardEvent): Use convertToNPNNString. (WebKit::NetscapePlugin::sendComplexTextInput): Ditto. * WebProcess/Plugins/PDF/PDFPlugin.mm: Use __unsafe_unretained explicitly for a parent pointer. We could consider moving to __weak after switching to ARC. Source/WebKitLegacy/mac: * Carbon/CarbonUtils.m: Updated include for rename: FoundationSPI.h -> objcSPI.h. * Carbon/CarbonWindowFrame.m: (-[CarbonWindowFrame dealloc]): Deleted. It was empty. * DOM/DOM.mm: (-[DOMElement _imageTIFFRepresentation]): Use a bridging cast. (-[DOMNodeFilter finalize]): Deleted. WebKit no longer supports Objective-C garbage collection so this method isn't useful. * DOM/DOMXPath.mm: (-[DOMNativeXPathNSResolver finalize]): Deleted. WebKit no longer supports Objective-C garbage collection so this method isn't useful. * History/WebHistory.mm: (-[WebHistoryPrivate data]): Allocate an NSData instead of casting from a CFData. * Misc/WebElementDictionary.mm: (addLookupKey): Use a bridging cast. (cacheValueForKey): Ditto. (-[WebElementDictionary _fillCache]): Ditto. (-[WebElementDictionary objectForKey:]): Ditto. * Misc/WebKitNSStringExtras.mm: (-[NSString _web_drawAtPoint:font:textColor:]): Use a bridging cast. (-[NSString _web_widthWithFont:]): Ditto. (-[NSString _webkit_stringByTrimmingWhitespace]): Ditto. * Misc/WebLocalizableStrings.mm: (WebLocalizedString): Use a bridging cast. * Misc/WebNSDataExtras.mm: (-[NSString _web_capitalizeRFC822HeaderFieldName]): Use a bridging cast and use CFBridgingRelease instead of calling autorelease directly. (-[NSData _webkit_parseRFC822HeaderFields]): Use NSString methods instead of a mix of CFString and NSString. Also simplified logic a bit, and cut down on the amount of explicit release and autorelease. * Misc/WebNSDictionaryExtras.h: Deleted unused methods. * Misc/WebNSDictionaryExtras.m: (-[NSDictionary _webkit_intForKey:]): Deleted. (-[NSMutableDictionary _webkit_setInt:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setFloat:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setBool:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setLongLong:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setUnsignedLongLong:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setUnsignedInt:forKey:]): Deleted. * Misc/WebStringTruncator.mm: (fontFromNSFont): Use a bridging cast. * Plugins/Hosted/NetscapePluginHostManager.mm: (WebKit::preferredBundleLocalizationName): Use a bridging cast and CFBridgingRelease. * Plugins/Hosted/NetscapePluginInstanceProxy.mm: (WebKit::NetscapePluginInstanceProxy::cleanup): Use a bridging cast. (WebKit::NetscapePluginInstanceProxy::status): Ditto. (WebKit::NetscapePluginInstanceProxy::loadURL): Ditto. (WebKit::NetscapePluginInstanceProxy::demarshalValueFromArray): Ditto. * Plugins/Hosted/ProxyInstance.mm: (WebKit::ProxyInstance::getPropertyNames): Ditto. * Plugins/WebBasePluginPackage.mm: (-[WebBasePluginPackage _objectForInfoDictionaryKey:]): Ditto. * Plugins/WebNetscapePluginEventHandlerCocoa.mm: (WebNetscapePluginEventHandlerCocoa::platformWindow): Ditto. * Plugins/WebNetscapePluginPackage.mm: (-[WebNetscapePluginPackage _initWithPath:]): Ditto. * Plugins/WebNetscapePluginView.mm: (-[WebNetscapePluginView _postURL:target:len:buf:file:notifyData:sendNotification:allowHeaders:]): Use bridging casts and use RetainPtr insteead of an explicit CFRelease. (-[WebNetscapePluginView status:]): Use a bridging cast. (-[WebNetscapePluginView popUpContextMenu:]): Ditto. * Plugins/WebPluginController.mm: (-[WebPluginController _cancelOutstandingChecks]): Use a bridging cast. * Plugins/WebPluginDatabase.mm: (checkCandidate): Use explicit __strong for out argument types. * Plugins/npapi.mm: (pluginViewForInstance): Use a bridging cast. * Storage/WebDatabaseManager.mm: (-[WebDatabaseManager detailsForDatabase:withOrigin:]): Use modern boxing instead of explicit NSNumber and NSDictionary calls. * WebCoreSupport/WebContextMenuClient.mm: (WebContextMenuClient::speak): Remove an unnecessary copy/autorelease pair. * WebCoreSupport/WebEditorClient.mm: (WebEditorClient::handleKeyboardEvent): Added a missing typecast. (WebEditorClient::handleInputMethodKeydown): Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: (WebFrameNetworkingContext::sourceApplicationAuditData const): Use a bridging cast. * WebCoreSupport/WebSecurityOriginPrivate.h: Forward declare WebSecurityOriginPrivate as a struct rather than an Objective-C class, since that's how it's defined. * WebInspector/WebNodeHighlighter.mm: Added missing includes. * WebView/WebFullScreenController.mm: (-[WebFullScreenController enterFullScreen:]): Use a bridging cast. * WebView/WebHTMLView.mm: (-[WebHTMLView _writeSelectionWithPasteboardTypes:toPasteboard:cachedAttributedString:]): Ditto. (-[WebHTMLView pasteboard:provideDataForType:]): Ditto. * WebView/WebImmediateActionController.mm: (-[WebImmediateActionController performHitTestAtPoint:]): Removed redundant code to go down to the document and then back to the frame. (-[WebImmediateActionController immediateActionRecognizerDidUpdateAnimation:]): Ditto. (-[WebImmediateActionController immediateActionRecognizerDidCancelAnimation:]): Ditto. (-[WebImmediateActionController immediateActionRecognizerDidCompleteAnimation:]): Ditto. * WebView/WebJSPDFDoc.mm: (jsPDFDocInitialize): Removed some unneeded type casting. (jsPDFDocFinalize): Ditto. (jsPDFDocPrint): Use a bridging cast. * WebView/WebPDFView.mm: (_applicationInfoForMIMEType): Use bridging casts. * WebView/WebPreferences.mm: (-[WebPreferences _setIntegerValue:forKey:]): Use boxing and setObject directly instead of methods from WebNSDictionaryExtras. (-[WebPreferences _setUnsignedIntValue:forKey:]): Ditto. (-[WebPreferences _setFloatValue:forKey:]): Ditto. (-[WebPreferences _setBoolValue:forKey:]): Ditto. (-[WebPreferences _setLongLongValue:forKey:]): Ditto. (-[WebPreferences _setUnsignedLongLongValue:forKey:]): Ditto. * WebView/WebView.mm: (-[WebView _removeFromAllWebViewsSet]): Use bridging cast. (-[WebView _addToAllWebViewsSet]): Ditto. (+[WebView closeAllWebViews]): Use a modern for loop instead of NSEnumerator. (-[WebView _windowVisibilityChanged:]): Moved this into the internal category so it can be called from WebViewData methods. * WebView/WebViewData.mm: Added an import so we can call an internal WebView method, _windowVisibilityChanged:. * WebView/WebViewInternal.h: Declared _windowVisibilityChanged: so it can be called from WebViewData methods. Source/WTF: * WTF.xcodeproj/project.pbxproj: Updated for rename: FoundationSPI.h -> objcSPI.h. * wtf/BlockPtr.h: Added missing include of "StdLibExtras.h". Also re-sorted includes. * wtf/HashFunctions.h: Add function for "__unsafe_unretained id". * wtf/HashTraits.h: Add traits for "__unsafe_unretained id". * wtf/PlatformMac.cmake: Updated for rename: FoundationSPI.h -> objcSPI.h. * wtf/WeakObjCPtr.h: Use mutable instead of const_cast, and write a version that uses __weak explicitly under ARC. Also moved function declarations from here to objcSPI.h. * wtf/cocoa/AutodrainedPool.cpp: Updated include for rename: FoundationSPI.h -> objcSPI.h. * wtf/spi/cocoa/objcSPI.h: Renamed from FoundationSPI.h and added the additional functions used by WeakObjCPtr.h. Also changed to both include the internal header and the function definitions when compiling with USE(APPLE_INTERNAL_SDK), helping us check that function definitions match. Tools: * DumpRenderTree/TestNetscapePlugIn/PluginObject.h: Use const void* for a CFTypeRef instead of void*. * DumpRenderTree/TestNetscapePlugIn/PluginObjectMac.mm: (createCoreAnimationLayer): Use CFBridgingRetain. * DumpRenderTree/mac/AccessibilityUIElementMac.mm: (AccessibilityUIElement::lineTextMarkerRangeForTextMarker): Use bridging casts. (AccessibilityUIElement::textMarkerRangeForElement): Ditto. (AccessibilityUIElement::selectedTextMarkerRange): Ditto. (AccessibilityUIElement::textMarkerRangeLength): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute): Ditto. (AccessibilityUIElement::indexForTextMarker): Ditto. (AccessibilityUIElement::textMarkerForIndex): Ditto. (AccessibilityUIElement::isTextMarkerValid): Ditto. (AccessibilityUIElement::previousTextMarker): Ditto. (AccessibilityUIElement::nextTextMarker): Ditto. (AccessibilityUIElement::stringForTextMarkerRange): Ditto. (createJSStringRef): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRange): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions): Ditto. (AccessibilityUIElement::textMarkerRangeForMarkers): Ditto. (AccessibilityUIElement::startTextMarkerForTextMarkerRange): Ditto. (AccessibilityUIElement::endTextMarkerForTextMarkerRange): Ditto. (AccessibilityUIElement::endTextMarkerForBounds): Ditto. (AccessibilityUIElement::startTextMarkerForBounds): Ditto. (AccessibilityUIElement::textMarkerForPoint): Ditto. (AccessibilityUIElement::accessibilityElementForTextMarker): Ditto. (AccessibilityUIElement::startTextMarker): Ditto. (AccessibilityUIElement::endTextMarker): Ditto. (AccessibilityUIElement::setSelectedVisibleTextRange): Ditto. (AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousWordStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextWordEndTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::paragraphTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousParagraphStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextParagraphEndTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::sentenceTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousSentenceStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextSentenceEndTextMarkerForTextMarker): Ditto. * DumpRenderTree/mac/DumpRenderTree.mm: (resetWebPreferencesToConsistentValues): Use bridging cast. (dumpFramesAsText): Ditto. (dumpBackForwardListForAllWindows): Use a modern for loop instead of CFArray functions to iterate the array. (dump): Use bridging cast. (runTest): Ditto. * DumpRenderTree/mac/DumpRenderTreePasteboard.mm: (+[LocalPasteboard alloc]): Use class_createInstance instead of NSAllocateObject. (toUTI): Return a RetainPtr<CFStringRef>. (-[LocalPasteboard types]): Use the above and bridging casts. (-[LocalPasteboard availableTypeFromArray:]): Ditto. (-[LocalPasteboard setData:forType:]): Ditto. (-[LocalPasteboard dataForType:]): Ditto. (-[LocalPasteboard setPropertyList:forType:]): Use NSPropertyListSerialization instead of CFPropertyList. (-[LocalPasteboard setString:forType:]): Use NSString method instead of CFStringCreateExternalRepresentation. * DumpRenderTree/mac/MockGeolocationProvider.h: Put CFTypeRef in a HashSet instead of an Objective-C object pointer type. * DumpRenderTree/mac/MockGeolocationProvider.mm: (-[MockGeolocationProvider registerWebView:]): Update for above. (-[MockGeolocationProvider unregisterWebView:]): Ditto. (-[MockGeolocationProvider timerFired]): Ditto. * DumpRenderTree/mac/MockWebNotificationProvider.h: Use CFTypeRef in HashMap and HashSet instead of an Objective-C object pointer type. * DumpRenderTree/mac/MockWebNotificationProvider.mm: (-[MockWebNotificationProvider registerWebView:]): Update for above. (-[MockWebNotificationProvider unregisterWebView:]): Ditto. (-[MockWebNotificationProvider showNotification:fromWebView:]): Ditto. (-[MockWebNotificationProvider cancelNotification:]): Ditto. (-[MockWebNotificationProvider simulateWebNotificationClick:]): Ditto. * DumpRenderTree/mac/ObjCPlugin.m: (-[JSObjC retainObject:]): Use CFRetain instead of -[NSObject retain]. * DumpRenderTree/mac/TestRunnerMac.mm: (TestRunner::addDisallowedURL): Use bridging cast. (TestRunner::applicationCacheDiskUsageForOrigin): Ditto. (TestRunner::clearApplicationCacheForOrigin): Ditto. (originsArrayToJS): Ditto. (TestRunner::copyDecodedHostName): Ditto. (TestRunner::copyEncodedHostName): Ditto. (TestRunner::queueLoad): Ditto. (TestRunner::setDomainRelaxationForbiddenForURLScheme): Ditto. (TestRunner::setMockGeolocationPositionUnavailableError): Ditto. (TestRunner::setUserStyleSheetLocation): Ditto. (TestRunner::setValueForUser): Ditto. (TestRunner::overridePreference): Ditto. (TestRunner::execCommand): Ditto. (TestRunner::findString): Ditto. (TestRunner::isCommandEnabled): Ditto. (TestRunner::addOriginAccessWhitelistEntry): Ditto. (TestRunner::removeOriginAccessWhitelistEntry): Ditto. (TestRunner::addUserScript): Ditto. (TestRunner::addUserStyleSheet): Ditto. (TestRunner::evaluateInWebInspector): Ditto. (TestRunner::evaluateScriptInIsolatedWorld): Ditto. (TestRunner::authenticateSession): Ditto. (TestRunner::grantWebNotificationPermission): Ditto. (TestRunner::denyWebNotificationPermission): Ditto. * TestRunnerShared/cocoa/LayoutTestSpellChecker.mm: (-[LayoutTestSpellChecker setResultsFromJSObject:inContext:]): Ditto. * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm: (WTR::AccessibilityUIElement::lineTextMarkerRangeForTextMarker): Use bridging cast. (WTR::AccessibilityUIElement::textMarkerRangeForElement): Ditto. (WTR::AccessibilityUIElement::previousTextMarker): Ditto. (WTR::AccessibilityUIElement::nextTextMarker): Ditto. (WTR::AccessibilityUIElement::textMarkerRangeForMarkers): Ditto. (WTR::AccessibilityUIElement::selectedTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::startTextMarkerForTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::endTextMarkerForTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::endTextMarkerForBounds): Ditto. (WTR::AccessibilityUIElement::startTextMarkerForBounds): Ditto. (WTR::AccessibilityUIElement::textMarkerForPoint): Ditto. (WTR::AccessibilityUIElement::textMarkerForIndex): Ditto. (WTR::AccessibilityUIElement::startTextMarker): Ditto. (WTR::AccessibilityUIElement::endTextMarker): Ditto. (WTR::AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousWordStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextWordEndTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::paragraphTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousParagraphStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextParagraphEndTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::sentenceTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousSentenceStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextSentenceEndTextMarkerForTextMarker): Ditto. * WebKitTestRunner/PlatformMac.cmake: Added WebKitTestRunnerWindow.h and .mm files. * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: Ditto. * WebKitTestRunner/mac/EventSenderProxy.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. * WebKitTestRunner/mac/PlatformWebViewMac.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. Moved WebKitTestRunnerWindow class into a separate file. (WTR::PlatformWebView::keyWindow): Call +[WebKitTestRunnerWindow _WTR_keyWindow] instead of have a second copy of the implementation. * WebKitTestRunner/mac/WebKitTestRunnerEvent.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. Also removed "using namespace". (+[WebKitTestRunnerEvent mouseLocation]): Updated for above. * WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm: (+[LocalPasteboard alloc]): Use class_createInstance instead of NSAllocateObject. (-[LocalPasteboard availableTypeFromArray:]): Use modern for loop. (-[LocalPasteboard setData:forType:]): Reordered method to be a tiny bit more efficient. (-[LocalPasteboard setPropertyList:forType:]): Use NSPropertyListSerialization instead of CFPropertyList. (-[LocalPasteboard setString:forType:]): Use NSString method instead of CFStringCreateExternalRepresentation. * WebKitTestRunner/mac/WebKitTestRunnerWindow.h: Moved declaration of WebKitTestRunnerWindow here so it can be included by files that need to know what the type is and that it inherits from NSWindow. * WebKitTestRunner/mac/WebKitTestRunnerWindow.mm: Added. Moved implementation here. (+[WebKitTestRunnerWindow _WTR_keyWindow]): Use modern for loop instead of the old, messier implementation. Canonical link: https://commits.webkit.org/203508@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234685 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-08-08 02:39:12 +00:00
WeakObjCPtr() = default;
WeakObjCPtr(ValueType *ptr)
[Cocoa] More tweaks and refactoring to prepare for ARC https://bugs.webkit.org/show_bug.cgi?id=188245 Reviewed by Dan Bernstein. Source/JavaScriptCore: * API/JSValue.mm: Use __unsafe_unretained. (JSContainerConvertor::convert): Use auto for compatibility with the above. * API/JSWrapperMap.mm: (allocateConstructorForCustomClass): Use CFTypeRef instead of Protocol *. (-[JSWrapperMap initWithGlobalContextRef:]): Use __unsafe_unretained. * heap/Heap.cpp: Updated include for rename: FoundationSPI.h -> objcSPI.h. Source/WebCore: * bridge/objc/objc_instance.mm: Updated include for rename: FoundationSPI.h -> objcSPI.h. * platform/ios/wak/WebCoreThread.mm: Ditto. Source/WebKit: * Platform/cocoa/WKCrashReporter.mm: (WebKit::setCrashLogMessage): Refactor into a separate function for clarity. (WebKit::setCrashReportApplicationSpecificInformation): Use a bridging cast. * Shared/mac/PasteboardTypes.mm: (WebKit::PasteboardTypes::forEditing): Use a bridging cast. * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm: (WebKit::convertToNPNNString): Added. Uses CFStringRef rather than NSString so we can manually manage the autoreleasing. (WebKit::initializeKeyboardEvent): Use convertToNPNNString. (WebKit::NetscapePlugin::sendComplexTextInput): Ditto. * WebProcess/Plugins/PDF/PDFPlugin.mm: Use __unsafe_unretained explicitly for a parent pointer. We could consider moving to __weak after switching to ARC. Source/WebKitLegacy/mac: * Carbon/CarbonUtils.m: Updated include for rename: FoundationSPI.h -> objcSPI.h. * Carbon/CarbonWindowFrame.m: (-[CarbonWindowFrame dealloc]): Deleted. It was empty. * DOM/DOM.mm: (-[DOMElement _imageTIFFRepresentation]): Use a bridging cast. (-[DOMNodeFilter finalize]): Deleted. WebKit no longer supports Objective-C garbage collection so this method isn't useful. * DOM/DOMXPath.mm: (-[DOMNativeXPathNSResolver finalize]): Deleted. WebKit no longer supports Objective-C garbage collection so this method isn't useful. * History/WebHistory.mm: (-[WebHistoryPrivate data]): Allocate an NSData instead of casting from a CFData. * Misc/WebElementDictionary.mm: (addLookupKey): Use a bridging cast. (cacheValueForKey): Ditto. (-[WebElementDictionary _fillCache]): Ditto. (-[WebElementDictionary objectForKey:]): Ditto. * Misc/WebKitNSStringExtras.mm: (-[NSString _web_drawAtPoint:font:textColor:]): Use a bridging cast. (-[NSString _web_widthWithFont:]): Ditto. (-[NSString _webkit_stringByTrimmingWhitespace]): Ditto. * Misc/WebLocalizableStrings.mm: (WebLocalizedString): Use a bridging cast. * Misc/WebNSDataExtras.mm: (-[NSString _web_capitalizeRFC822HeaderFieldName]): Use a bridging cast and use CFBridgingRelease instead of calling autorelease directly. (-[NSData _webkit_parseRFC822HeaderFields]): Use NSString methods instead of a mix of CFString and NSString. Also simplified logic a bit, and cut down on the amount of explicit release and autorelease. * Misc/WebNSDictionaryExtras.h: Deleted unused methods. * Misc/WebNSDictionaryExtras.m: (-[NSDictionary _webkit_intForKey:]): Deleted. (-[NSMutableDictionary _webkit_setInt:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setFloat:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setBool:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setLongLong:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setUnsignedLongLong:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setUnsignedInt:forKey:]): Deleted. * Misc/WebStringTruncator.mm: (fontFromNSFont): Use a bridging cast. * Plugins/Hosted/NetscapePluginHostManager.mm: (WebKit::preferredBundleLocalizationName): Use a bridging cast and CFBridgingRelease. * Plugins/Hosted/NetscapePluginInstanceProxy.mm: (WebKit::NetscapePluginInstanceProxy::cleanup): Use a bridging cast. (WebKit::NetscapePluginInstanceProxy::status): Ditto. (WebKit::NetscapePluginInstanceProxy::loadURL): Ditto. (WebKit::NetscapePluginInstanceProxy::demarshalValueFromArray): Ditto. * Plugins/Hosted/ProxyInstance.mm: (WebKit::ProxyInstance::getPropertyNames): Ditto. * Plugins/WebBasePluginPackage.mm: (-[WebBasePluginPackage _objectForInfoDictionaryKey:]): Ditto. * Plugins/WebNetscapePluginEventHandlerCocoa.mm: (WebNetscapePluginEventHandlerCocoa::platformWindow): Ditto. * Plugins/WebNetscapePluginPackage.mm: (-[WebNetscapePluginPackage _initWithPath:]): Ditto. * Plugins/WebNetscapePluginView.mm: (-[WebNetscapePluginView _postURL:target:len:buf:file:notifyData:sendNotification:allowHeaders:]): Use bridging casts and use RetainPtr insteead of an explicit CFRelease. (-[WebNetscapePluginView status:]): Use a bridging cast. (-[WebNetscapePluginView popUpContextMenu:]): Ditto. * Plugins/WebPluginController.mm: (-[WebPluginController _cancelOutstandingChecks]): Use a bridging cast. * Plugins/WebPluginDatabase.mm: (checkCandidate): Use explicit __strong for out argument types. * Plugins/npapi.mm: (pluginViewForInstance): Use a bridging cast. * Storage/WebDatabaseManager.mm: (-[WebDatabaseManager detailsForDatabase:withOrigin:]): Use modern boxing instead of explicit NSNumber and NSDictionary calls. * WebCoreSupport/WebContextMenuClient.mm: (WebContextMenuClient::speak): Remove an unnecessary copy/autorelease pair. * WebCoreSupport/WebEditorClient.mm: (WebEditorClient::handleKeyboardEvent): Added a missing typecast. (WebEditorClient::handleInputMethodKeydown): Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: (WebFrameNetworkingContext::sourceApplicationAuditData const): Use a bridging cast. * WebCoreSupport/WebSecurityOriginPrivate.h: Forward declare WebSecurityOriginPrivate as a struct rather than an Objective-C class, since that's how it's defined. * WebInspector/WebNodeHighlighter.mm: Added missing includes. * WebView/WebFullScreenController.mm: (-[WebFullScreenController enterFullScreen:]): Use a bridging cast. * WebView/WebHTMLView.mm: (-[WebHTMLView _writeSelectionWithPasteboardTypes:toPasteboard:cachedAttributedString:]): Ditto. (-[WebHTMLView pasteboard:provideDataForType:]): Ditto. * WebView/WebImmediateActionController.mm: (-[WebImmediateActionController performHitTestAtPoint:]): Removed redundant code to go down to the document and then back to the frame. (-[WebImmediateActionController immediateActionRecognizerDidUpdateAnimation:]): Ditto. (-[WebImmediateActionController immediateActionRecognizerDidCancelAnimation:]): Ditto. (-[WebImmediateActionController immediateActionRecognizerDidCompleteAnimation:]): Ditto. * WebView/WebJSPDFDoc.mm: (jsPDFDocInitialize): Removed some unneeded type casting. (jsPDFDocFinalize): Ditto. (jsPDFDocPrint): Use a bridging cast. * WebView/WebPDFView.mm: (_applicationInfoForMIMEType): Use bridging casts. * WebView/WebPreferences.mm: (-[WebPreferences _setIntegerValue:forKey:]): Use boxing and setObject directly instead of methods from WebNSDictionaryExtras. (-[WebPreferences _setUnsignedIntValue:forKey:]): Ditto. (-[WebPreferences _setFloatValue:forKey:]): Ditto. (-[WebPreferences _setBoolValue:forKey:]): Ditto. (-[WebPreferences _setLongLongValue:forKey:]): Ditto. (-[WebPreferences _setUnsignedLongLongValue:forKey:]): Ditto. * WebView/WebView.mm: (-[WebView _removeFromAllWebViewsSet]): Use bridging cast. (-[WebView _addToAllWebViewsSet]): Ditto. (+[WebView closeAllWebViews]): Use a modern for loop instead of NSEnumerator. (-[WebView _windowVisibilityChanged:]): Moved this into the internal category so it can be called from WebViewData methods. * WebView/WebViewData.mm: Added an import so we can call an internal WebView method, _windowVisibilityChanged:. * WebView/WebViewInternal.h: Declared _windowVisibilityChanged: so it can be called from WebViewData methods. Source/WTF: * WTF.xcodeproj/project.pbxproj: Updated for rename: FoundationSPI.h -> objcSPI.h. * wtf/BlockPtr.h: Added missing include of "StdLibExtras.h". Also re-sorted includes. * wtf/HashFunctions.h: Add function for "__unsafe_unretained id". * wtf/HashTraits.h: Add traits for "__unsafe_unretained id". * wtf/PlatformMac.cmake: Updated for rename: FoundationSPI.h -> objcSPI.h. * wtf/WeakObjCPtr.h: Use mutable instead of const_cast, and write a version that uses __weak explicitly under ARC. Also moved function declarations from here to objcSPI.h. * wtf/cocoa/AutodrainedPool.cpp: Updated include for rename: FoundationSPI.h -> objcSPI.h. * wtf/spi/cocoa/objcSPI.h: Renamed from FoundationSPI.h and added the additional functions used by WeakObjCPtr.h. Also changed to both include the internal header and the function definitions when compiling with USE(APPLE_INTERNAL_SDK), helping us check that function definitions match. Tools: * DumpRenderTree/TestNetscapePlugIn/PluginObject.h: Use const void* for a CFTypeRef instead of void*. * DumpRenderTree/TestNetscapePlugIn/PluginObjectMac.mm: (createCoreAnimationLayer): Use CFBridgingRetain. * DumpRenderTree/mac/AccessibilityUIElementMac.mm: (AccessibilityUIElement::lineTextMarkerRangeForTextMarker): Use bridging casts. (AccessibilityUIElement::textMarkerRangeForElement): Ditto. (AccessibilityUIElement::selectedTextMarkerRange): Ditto. (AccessibilityUIElement::textMarkerRangeLength): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute): Ditto. (AccessibilityUIElement::indexForTextMarker): Ditto. (AccessibilityUIElement::textMarkerForIndex): Ditto. (AccessibilityUIElement::isTextMarkerValid): Ditto. (AccessibilityUIElement::previousTextMarker): Ditto. (AccessibilityUIElement::nextTextMarker): Ditto. (AccessibilityUIElement::stringForTextMarkerRange): Ditto. (createJSStringRef): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRange): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions): Ditto. (AccessibilityUIElement::textMarkerRangeForMarkers): Ditto. (AccessibilityUIElement::startTextMarkerForTextMarkerRange): Ditto. (AccessibilityUIElement::endTextMarkerForTextMarkerRange): Ditto. (AccessibilityUIElement::endTextMarkerForBounds): Ditto. (AccessibilityUIElement::startTextMarkerForBounds): Ditto. (AccessibilityUIElement::textMarkerForPoint): Ditto. (AccessibilityUIElement::accessibilityElementForTextMarker): Ditto. (AccessibilityUIElement::startTextMarker): Ditto. (AccessibilityUIElement::endTextMarker): Ditto. (AccessibilityUIElement::setSelectedVisibleTextRange): Ditto. (AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousWordStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextWordEndTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::paragraphTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousParagraphStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextParagraphEndTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::sentenceTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousSentenceStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextSentenceEndTextMarkerForTextMarker): Ditto. * DumpRenderTree/mac/DumpRenderTree.mm: (resetWebPreferencesToConsistentValues): Use bridging cast. (dumpFramesAsText): Ditto. (dumpBackForwardListForAllWindows): Use a modern for loop instead of CFArray functions to iterate the array. (dump): Use bridging cast. (runTest): Ditto. * DumpRenderTree/mac/DumpRenderTreePasteboard.mm: (+[LocalPasteboard alloc]): Use class_createInstance instead of NSAllocateObject. (toUTI): Return a RetainPtr<CFStringRef>. (-[LocalPasteboard types]): Use the above and bridging casts. (-[LocalPasteboard availableTypeFromArray:]): Ditto. (-[LocalPasteboard setData:forType:]): Ditto. (-[LocalPasteboard dataForType:]): Ditto. (-[LocalPasteboard setPropertyList:forType:]): Use NSPropertyListSerialization instead of CFPropertyList. (-[LocalPasteboard setString:forType:]): Use NSString method instead of CFStringCreateExternalRepresentation. * DumpRenderTree/mac/MockGeolocationProvider.h: Put CFTypeRef in a HashSet instead of an Objective-C object pointer type. * DumpRenderTree/mac/MockGeolocationProvider.mm: (-[MockGeolocationProvider registerWebView:]): Update for above. (-[MockGeolocationProvider unregisterWebView:]): Ditto. (-[MockGeolocationProvider timerFired]): Ditto. * DumpRenderTree/mac/MockWebNotificationProvider.h: Use CFTypeRef in HashMap and HashSet instead of an Objective-C object pointer type. * DumpRenderTree/mac/MockWebNotificationProvider.mm: (-[MockWebNotificationProvider registerWebView:]): Update for above. (-[MockWebNotificationProvider unregisterWebView:]): Ditto. (-[MockWebNotificationProvider showNotification:fromWebView:]): Ditto. (-[MockWebNotificationProvider cancelNotification:]): Ditto. (-[MockWebNotificationProvider simulateWebNotificationClick:]): Ditto. * DumpRenderTree/mac/ObjCPlugin.m: (-[JSObjC retainObject:]): Use CFRetain instead of -[NSObject retain]. * DumpRenderTree/mac/TestRunnerMac.mm: (TestRunner::addDisallowedURL): Use bridging cast. (TestRunner::applicationCacheDiskUsageForOrigin): Ditto. (TestRunner::clearApplicationCacheForOrigin): Ditto. (originsArrayToJS): Ditto. (TestRunner::copyDecodedHostName): Ditto. (TestRunner::copyEncodedHostName): Ditto. (TestRunner::queueLoad): Ditto. (TestRunner::setDomainRelaxationForbiddenForURLScheme): Ditto. (TestRunner::setMockGeolocationPositionUnavailableError): Ditto. (TestRunner::setUserStyleSheetLocation): Ditto. (TestRunner::setValueForUser): Ditto. (TestRunner::overridePreference): Ditto. (TestRunner::execCommand): Ditto. (TestRunner::findString): Ditto. (TestRunner::isCommandEnabled): Ditto. (TestRunner::addOriginAccessWhitelistEntry): Ditto. (TestRunner::removeOriginAccessWhitelistEntry): Ditto. (TestRunner::addUserScript): Ditto. (TestRunner::addUserStyleSheet): Ditto. (TestRunner::evaluateInWebInspector): Ditto. (TestRunner::evaluateScriptInIsolatedWorld): Ditto. (TestRunner::authenticateSession): Ditto. (TestRunner::grantWebNotificationPermission): Ditto. (TestRunner::denyWebNotificationPermission): Ditto. * TestRunnerShared/cocoa/LayoutTestSpellChecker.mm: (-[LayoutTestSpellChecker setResultsFromJSObject:inContext:]): Ditto. * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm: (WTR::AccessibilityUIElement::lineTextMarkerRangeForTextMarker): Use bridging cast. (WTR::AccessibilityUIElement::textMarkerRangeForElement): Ditto. (WTR::AccessibilityUIElement::previousTextMarker): Ditto. (WTR::AccessibilityUIElement::nextTextMarker): Ditto. (WTR::AccessibilityUIElement::textMarkerRangeForMarkers): Ditto. (WTR::AccessibilityUIElement::selectedTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::startTextMarkerForTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::endTextMarkerForTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::endTextMarkerForBounds): Ditto. (WTR::AccessibilityUIElement::startTextMarkerForBounds): Ditto. (WTR::AccessibilityUIElement::textMarkerForPoint): Ditto. (WTR::AccessibilityUIElement::textMarkerForIndex): Ditto. (WTR::AccessibilityUIElement::startTextMarker): Ditto. (WTR::AccessibilityUIElement::endTextMarker): Ditto. (WTR::AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousWordStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextWordEndTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::paragraphTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousParagraphStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextParagraphEndTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::sentenceTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousSentenceStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextSentenceEndTextMarkerForTextMarker): Ditto. * WebKitTestRunner/PlatformMac.cmake: Added WebKitTestRunnerWindow.h and .mm files. * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: Ditto. * WebKitTestRunner/mac/EventSenderProxy.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. * WebKitTestRunner/mac/PlatformWebViewMac.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. Moved WebKitTestRunnerWindow class into a separate file. (WTR::PlatformWebView::keyWindow): Call +[WebKitTestRunnerWindow _WTR_keyWindow] instead of have a second copy of the implementation. * WebKitTestRunner/mac/WebKitTestRunnerEvent.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. Also removed "using namespace". (+[WebKitTestRunnerEvent mouseLocation]): Updated for above. * WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm: (+[LocalPasteboard alloc]): Use class_createInstance instead of NSAllocateObject. (-[LocalPasteboard availableTypeFromArray:]): Use modern for loop. (-[LocalPasteboard setData:forType:]): Reordered method to be a tiny bit more efficient. (-[LocalPasteboard setPropertyList:forType:]): Use NSPropertyListSerialization instead of CFPropertyList. (-[LocalPasteboard setString:forType:]): Use NSString method instead of CFStringCreateExternalRepresentation. * WebKitTestRunner/mac/WebKitTestRunnerWindow.h: Moved declaration of WebKitTestRunnerWindow here so it can be included by files that need to know what the type is and that it inherits from NSWindow. * WebKitTestRunner/mac/WebKitTestRunnerWindow.mm: Added. Moved implementation here. (+[WebKitTestRunnerWindow _WTR_keyWindow]): Use modern for loop instead of the old, messier implementation. Canonical link: https://commits.webkit.org/203508@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234685 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-08-08 02:39:12 +00:00
#if __has_feature(objc_arc)
: m_weakReference(ptr)
#endif
{
[Cocoa] More tweaks and refactoring to prepare for ARC https://bugs.webkit.org/show_bug.cgi?id=188245 Reviewed by Dan Bernstein. Source/JavaScriptCore: * API/JSValue.mm: Use __unsafe_unretained. (JSContainerConvertor::convert): Use auto for compatibility with the above. * API/JSWrapperMap.mm: (allocateConstructorForCustomClass): Use CFTypeRef instead of Protocol *. (-[JSWrapperMap initWithGlobalContextRef:]): Use __unsafe_unretained. * heap/Heap.cpp: Updated include for rename: FoundationSPI.h -> objcSPI.h. Source/WebCore: * bridge/objc/objc_instance.mm: Updated include for rename: FoundationSPI.h -> objcSPI.h. * platform/ios/wak/WebCoreThread.mm: Ditto. Source/WebKit: * Platform/cocoa/WKCrashReporter.mm: (WebKit::setCrashLogMessage): Refactor into a separate function for clarity. (WebKit::setCrashReportApplicationSpecificInformation): Use a bridging cast. * Shared/mac/PasteboardTypes.mm: (WebKit::PasteboardTypes::forEditing): Use a bridging cast. * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm: (WebKit::convertToNPNNString): Added. Uses CFStringRef rather than NSString so we can manually manage the autoreleasing. (WebKit::initializeKeyboardEvent): Use convertToNPNNString. (WebKit::NetscapePlugin::sendComplexTextInput): Ditto. * WebProcess/Plugins/PDF/PDFPlugin.mm: Use __unsafe_unretained explicitly for a parent pointer. We could consider moving to __weak after switching to ARC. Source/WebKitLegacy/mac: * Carbon/CarbonUtils.m: Updated include for rename: FoundationSPI.h -> objcSPI.h. * Carbon/CarbonWindowFrame.m: (-[CarbonWindowFrame dealloc]): Deleted. It was empty. * DOM/DOM.mm: (-[DOMElement _imageTIFFRepresentation]): Use a bridging cast. (-[DOMNodeFilter finalize]): Deleted. WebKit no longer supports Objective-C garbage collection so this method isn't useful. * DOM/DOMXPath.mm: (-[DOMNativeXPathNSResolver finalize]): Deleted. WebKit no longer supports Objective-C garbage collection so this method isn't useful. * History/WebHistory.mm: (-[WebHistoryPrivate data]): Allocate an NSData instead of casting from a CFData. * Misc/WebElementDictionary.mm: (addLookupKey): Use a bridging cast. (cacheValueForKey): Ditto. (-[WebElementDictionary _fillCache]): Ditto. (-[WebElementDictionary objectForKey:]): Ditto. * Misc/WebKitNSStringExtras.mm: (-[NSString _web_drawAtPoint:font:textColor:]): Use a bridging cast. (-[NSString _web_widthWithFont:]): Ditto. (-[NSString _webkit_stringByTrimmingWhitespace]): Ditto. * Misc/WebLocalizableStrings.mm: (WebLocalizedString): Use a bridging cast. * Misc/WebNSDataExtras.mm: (-[NSString _web_capitalizeRFC822HeaderFieldName]): Use a bridging cast and use CFBridgingRelease instead of calling autorelease directly. (-[NSData _webkit_parseRFC822HeaderFields]): Use NSString methods instead of a mix of CFString and NSString. Also simplified logic a bit, and cut down on the amount of explicit release and autorelease. * Misc/WebNSDictionaryExtras.h: Deleted unused methods. * Misc/WebNSDictionaryExtras.m: (-[NSDictionary _webkit_intForKey:]): Deleted. (-[NSMutableDictionary _webkit_setInt:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setFloat:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setBool:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setLongLong:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setUnsignedLongLong:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setUnsignedInt:forKey:]): Deleted. * Misc/WebStringTruncator.mm: (fontFromNSFont): Use a bridging cast. * Plugins/Hosted/NetscapePluginHostManager.mm: (WebKit::preferredBundleLocalizationName): Use a bridging cast and CFBridgingRelease. * Plugins/Hosted/NetscapePluginInstanceProxy.mm: (WebKit::NetscapePluginInstanceProxy::cleanup): Use a bridging cast. (WebKit::NetscapePluginInstanceProxy::status): Ditto. (WebKit::NetscapePluginInstanceProxy::loadURL): Ditto. (WebKit::NetscapePluginInstanceProxy::demarshalValueFromArray): Ditto. * Plugins/Hosted/ProxyInstance.mm: (WebKit::ProxyInstance::getPropertyNames): Ditto. * Plugins/WebBasePluginPackage.mm: (-[WebBasePluginPackage _objectForInfoDictionaryKey:]): Ditto. * Plugins/WebNetscapePluginEventHandlerCocoa.mm: (WebNetscapePluginEventHandlerCocoa::platformWindow): Ditto. * Plugins/WebNetscapePluginPackage.mm: (-[WebNetscapePluginPackage _initWithPath:]): Ditto. * Plugins/WebNetscapePluginView.mm: (-[WebNetscapePluginView _postURL:target:len:buf:file:notifyData:sendNotification:allowHeaders:]): Use bridging casts and use RetainPtr insteead of an explicit CFRelease. (-[WebNetscapePluginView status:]): Use a bridging cast. (-[WebNetscapePluginView popUpContextMenu:]): Ditto. * Plugins/WebPluginController.mm: (-[WebPluginController _cancelOutstandingChecks]): Use a bridging cast. * Plugins/WebPluginDatabase.mm: (checkCandidate): Use explicit __strong for out argument types. * Plugins/npapi.mm: (pluginViewForInstance): Use a bridging cast. * Storage/WebDatabaseManager.mm: (-[WebDatabaseManager detailsForDatabase:withOrigin:]): Use modern boxing instead of explicit NSNumber and NSDictionary calls. * WebCoreSupport/WebContextMenuClient.mm: (WebContextMenuClient::speak): Remove an unnecessary copy/autorelease pair. * WebCoreSupport/WebEditorClient.mm: (WebEditorClient::handleKeyboardEvent): Added a missing typecast. (WebEditorClient::handleInputMethodKeydown): Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: (WebFrameNetworkingContext::sourceApplicationAuditData const): Use a bridging cast. * WebCoreSupport/WebSecurityOriginPrivate.h: Forward declare WebSecurityOriginPrivate as a struct rather than an Objective-C class, since that's how it's defined. * WebInspector/WebNodeHighlighter.mm: Added missing includes. * WebView/WebFullScreenController.mm: (-[WebFullScreenController enterFullScreen:]): Use a bridging cast. * WebView/WebHTMLView.mm: (-[WebHTMLView _writeSelectionWithPasteboardTypes:toPasteboard:cachedAttributedString:]): Ditto. (-[WebHTMLView pasteboard:provideDataForType:]): Ditto. * WebView/WebImmediateActionController.mm: (-[WebImmediateActionController performHitTestAtPoint:]): Removed redundant code to go down to the document and then back to the frame. (-[WebImmediateActionController immediateActionRecognizerDidUpdateAnimation:]): Ditto. (-[WebImmediateActionController immediateActionRecognizerDidCancelAnimation:]): Ditto. (-[WebImmediateActionController immediateActionRecognizerDidCompleteAnimation:]): Ditto. * WebView/WebJSPDFDoc.mm: (jsPDFDocInitialize): Removed some unneeded type casting. (jsPDFDocFinalize): Ditto. (jsPDFDocPrint): Use a bridging cast. * WebView/WebPDFView.mm: (_applicationInfoForMIMEType): Use bridging casts. * WebView/WebPreferences.mm: (-[WebPreferences _setIntegerValue:forKey:]): Use boxing and setObject directly instead of methods from WebNSDictionaryExtras. (-[WebPreferences _setUnsignedIntValue:forKey:]): Ditto. (-[WebPreferences _setFloatValue:forKey:]): Ditto. (-[WebPreferences _setBoolValue:forKey:]): Ditto. (-[WebPreferences _setLongLongValue:forKey:]): Ditto. (-[WebPreferences _setUnsignedLongLongValue:forKey:]): Ditto. * WebView/WebView.mm: (-[WebView _removeFromAllWebViewsSet]): Use bridging cast. (-[WebView _addToAllWebViewsSet]): Ditto. (+[WebView closeAllWebViews]): Use a modern for loop instead of NSEnumerator. (-[WebView _windowVisibilityChanged:]): Moved this into the internal category so it can be called from WebViewData methods. * WebView/WebViewData.mm: Added an import so we can call an internal WebView method, _windowVisibilityChanged:. * WebView/WebViewInternal.h: Declared _windowVisibilityChanged: so it can be called from WebViewData methods. Source/WTF: * WTF.xcodeproj/project.pbxproj: Updated for rename: FoundationSPI.h -> objcSPI.h. * wtf/BlockPtr.h: Added missing include of "StdLibExtras.h". Also re-sorted includes. * wtf/HashFunctions.h: Add function for "__unsafe_unretained id". * wtf/HashTraits.h: Add traits for "__unsafe_unretained id". * wtf/PlatformMac.cmake: Updated for rename: FoundationSPI.h -> objcSPI.h. * wtf/WeakObjCPtr.h: Use mutable instead of const_cast, and write a version that uses __weak explicitly under ARC. Also moved function declarations from here to objcSPI.h. * wtf/cocoa/AutodrainedPool.cpp: Updated include for rename: FoundationSPI.h -> objcSPI.h. * wtf/spi/cocoa/objcSPI.h: Renamed from FoundationSPI.h and added the additional functions used by WeakObjCPtr.h. Also changed to both include the internal header and the function definitions when compiling with USE(APPLE_INTERNAL_SDK), helping us check that function definitions match. Tools: * DumpRenderTree/TestNetscapePlugIn/PluginObject.h: Use const void* for a CFTypeRef instead of void*. * DumpRenderTree/TestNetscapePlugIn/PluginObjectMac.mm: (createCoreAnimationLayer): Use CFBridgingRetain. * DumpRenderTree/mac/AccessibilityUIElementMac.mm: (AccessibilityUIElement::lineTextMarkerRangeForTextMarker): Use bridging casts. (AccessibilityUIElement::textMarkerRangeForElement): Ditto. (AccessibilityUIElement::selectedTextMarkerRange): Ditto. (AccessibilityUIElement::textMarkerRangeLength): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute): Ditto. (AccessibilityUIElement::indexForTextMarker): Ditto. (AccessibilityUIElement::textMarkerForIndex): Ditto. (AccessibilityUIElement::isTextMarkerValid): Ditto. (AccessibilityUIElement::previousTextMarker): Ditto. (AccessibilityUIElement::nextTextMarker): Ditto. (AccessibilityUIElement::stringForTextMarkerRange): Ditto. (createJSStringRef): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRange): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions): Ditto. (AccessibilityUIElement::textMarkerRangeForMarkers): Ditto. (AccessibilityUIElement::startTextMarkerForTextMarkerRange): Ditto. (AccessibilityUIElement::endTextMarkerForTextMarkerRange): Ditto. (AccessibilityUIElement::endTextMarkerForBounds): Ditto. (AccessibilityUIElement::startTextMarkerForBounds): Ditto. (AccessibilityUIElement::textMarkerForPoint): Ditto. (AccessibilityUIElement::accessibilityElementForTextMarker): Ditto. (AccessibilityUIElement::startTextMarker): Ditto. (AccessibilityUIElement::endTextMarker): Ditto. (AccessibilityUIElement::setSelectedVisibleTextRange): Ditto. (AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousWordStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextWordEndTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::paragraphTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousParagraphStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextParagraphEndTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::sentenceTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousSentenceStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextSentenceEndTextMarkerForTextMarker): Ditto. * DumpRenderTree/mac/DumpRenderTree.mm: (resetWebPreferencesToConsistentValues): Use bridging cast. (dumpFramesAsText): Ditto. (dumpBackForwardListForAllWindows): Use a modern for loop instead of CFArray functions to iterate the array. (dump): Use bridging cast. (runTest): Ditto. * DumpRenderTree/mac/DumpRenderTreePasteboard.mm: (+[LocalPasteboard alloc]): Use class_createInstance instead of NSAllocateObject. (toUTI): Return a RetainPtr<CFStringRef>. (-[LocalPasteboard types]): Use the above and bridging casts. (-[LocalPasteboard availableTypeFromArray:]): Ditto. (-[LocalPasteboard setData:forType:]): Ditto. (-[LocalPasteboard dataForType:]): Ditto. (-[LocalPasteboard setPropertyList:forType:]): Use NSPropertyListSerialization instead of CFPropertyList. (-[LocalPasteboard setString:forType:]): Use NSString method instead of CFStringCreateExternalRepresentation. * DumpRenderTree/mac/MockGeolocationProvider.h: Put CFTypeRef in a HashSet instead of an Objective-C object pointer type. * DumpRenderTree/mac/MockGeolocationProvider.mm: (-[MockGeolocationProvider registerWebView:]): Update for above. (-[MockGeolocationProvider unregisterWebView:]): Ditto. (-[MockGeolocationProvider timerFired]): Ditto. * DumpRenderTree/mac/MockWebNotificationProvider.h: Use CFTypeRef in HashMap and HashSet instead of an Objective-C object pointer type. * DumpRenderTree/mac/MockWebNotificationProvider.mm: (-[MockWebNotificationProvider registerWebView:]): Update for above. (-[MockWebNotificationProvider unregisterWebView:]): Ditto. (-[MockWebNotificationProvider showNotification:fromWebView:]): Ditto. (-[MockWebNotificationProvider cancelNotification:]): Ditto. (-[MockWebNotificationProvider simulateWebNotificationClick:]): Ditto. * DumpRenderTree/mac/ObjCPlugin.m: (-[JSObjC retainObject:]): Use CFRetain instead of -[NSObject retain]. * DumpRenderTree/mac/TestRunnerMac.mm: (TestRunner::addDisallowedURL): Use bridging cast. (TestRunner::applicationCacheDiskUsageForOrigin): Ditto. (TestRunner::clearApplicationCacheForOrigin): Ditto. (originsArrayToJS): Ditto. (TestRunner::copyDecodedHostName): Ditto. (TestRunner::copyEncodedHostName): Ditto. (TestRunner::queueLoad): Ditto. (TestRunner::setDomainRelaxationForbiddenForURLScheme): Ditto. (TestRunner::setMockGeolocationPositionUnavailableError): Ditto. (TestRunner::setUserStyleSheetLocation): Ditto. (TestRunner::setValueForUser): Ditto. (TestRunner::overridePreference): Ditto. (TestRunner::execCommand): Ditto. (TestRunner::findString): Ditto. (TestRunner::isCommandEnabled): Ditto. (TestRunner::addOriginAccessWhitelistEntry): Ditto. (TestRunner::removeOriginAccessWhitelistEntry): Ditto. (TestRunner::addUserScript): Ditto. (TestRunner::addUserStyleSheet): Ditto. (TestRunner::evaluateInWebInspector): Ditto. (TestRunner::evaluateScriptInIsolatedWorld): Ditto. (TestRunner::authenticateSession): Ditto. (TestRunner::grantWebNotificationPermission): Ditto. (TestRunner::denyWebNotificationPermission): Ditto. * TestRunnerShared/cocoa/LayoutTestSpellChecker.mm: (-[LayoutTestSpellChecker setResultsFromJSObject:inContext:]): Ditto. * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm: (WTR::AccessibilityUIElement::lineTextMarkerRangeForTextMarker): Use bridging cast. (WTR::AccessibilityUIElement::textMarkerRangeForElement): Ditto. (WTR::AccessibilityUIElement::previousTextMarker): Ditto. (WTR::AccessibilityUIElement::nextTextMarker): Ditto. (WTR::AccessibilityUIElement::textMarkerRangeForMarkers): Ditto. (WTR::AccessibilityUIElement::selectedTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::startTextMarkerForTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::endTextMarkerForTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::endTextMarkerForBounds): Ditto. (WTR::AccessibilityUIElement::startTextMarkerForBounds): Ditto. (WTR::AccessibilityUIElement::textMarkerForPoint): Ditto. (WTR::AccessibilityUIElement::textMarkerForIndex): Ditto. (WTR::AccessibilityUIElement::startTextMarker): Ditto. (WTR::AccessibilityUIElement::endTextMarker): Ditto. (WTR::AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousWordStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextWordEndTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::paragraphTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousParagraphStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextParagraphEndTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::sentenceTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousSentenceStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextSentenceEndTextMarkerForTextMarker): Ditto. * WebKitTestRunner/PlatformMac.cmake: Added WebKitTestRunnerWindow.h and .mm files. * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: Ditto. * WebKitTestRunner/mac/EventSenderProxy.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. * WebKitTestRunner/mac/PlatformWebViewMac.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. Moved WebKitTestRunnerWindow class into a separate file. (WTR::PlatformWebView::keyWindow): Call +[WebKitTestRunnerWindow _WTR_keyWindow] instead of have a second copy of the implementation. * WebKitTestRunner/mac/WebKitTestRunnerEvent.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. Also removed "using namespace". (+[WebKitTestRunnerEvent mouseLocation]): Updated for above. * WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm: (+[LocalPasteboard alloc]): Use class_createInstance instead of NSAllocateObject. (-[LocalPasteboard availableTypeFromArray:]): Use modern for loop. (-[LocalPasteboard setData:forType:]): Reordered method to be a tiny bit more efficient. (-[LocalPasteboard setPropertyList:forType:]): Use NSPropertyListSerialization instead of CFPropertyList. (-[LocalPasteboard setString:forType:]): Use NSString method instead of CFStringCreateExternalRepresentation. * WebKitTestRunner/mac/WebKitTestRunnerWindow.h: Moved declaration of WebKitTestRunnerWindow here so it can be included by files that need to know what the type is and that it inherits from NSWindow. * WebKitTestRunner/mac/WebKitTestRunnerWindow.mm: Added. Moved implementation here. (+[WebKitTestRunnerWindow _WTR_keyWindow]): Use modern for loop instead of the old, messier implementation. Canonical link: https://commits.webkit.org/203508@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234685 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-08-08 02:39:12 +00:00
#if !__has_feature(objc_arc)
objc_initWeak(&m_weakReference, ptr);
[Cocoa] More tweaks and refactoring to prepare for ARC https://bugs.webkit.org/show_bug.cgi?id=188245 Reviewed by Dan Bernstein. Source/JavaScriptCore: * API/JSValue.mm: Use __unsafe_unretained. (JSContainerConvertor::convert): Use auto for compatibility with the above. * API/JSWrapperMap.mm: (allocateConstructorForCustomClass): Use CFTypeRef instead of Protocol *. (-[JSWrapperMap initWithGlobalContextRef:]): Use __unsafe_unretained. * heap/Heap.cpp: Updated include for rename: FoundationSPI.h -> objcSPI.h. Source/WebCore: * bridge/objc/objc_instance.mm: Updated include for rename: FoundationSPI.h -> objcSPI.h. * platform/ios/wak/WebCoreThread.mm: Ditto. Source/WebKit: * Platform/cocoa/WKCrashReporter.mm: (WebKit::setCrashLogMessage): Refactor into a separate function for clarity. (WebKit::setCrashReportApplicationSpecificInformation): Use a bridging cast. * Shared/mac/PasteboardTypes.mm: (WebKit::PasteboardTypes::forEditing): Use a bridging cast. * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm: (WebKit::convertToNPNNString): Added. Uses CFStringRef rather than NSString so we can manually manage the autoreleasing. (WebKit::initializeKeyboardEvent): Use convertToNPNNString. (WebKit::NetscapePlugin::sendComplexTextInput): Ditto. * WebProcess/Plugins/PDF/PDFPlugin.mm: Use __unsafe_unretained explicitly for a parent pointer. We could consider moving to __weak after switching to ARC. Source/WebKitLegacy/mac: * Carbon/CarbonUtils.m: Updated include for rename: FoundationSPI.h -> objcSPI.h. * Carbon/CarbonWindowFrame.m: (-[CarbonWindowFrame dealloc]): Deleted. It was empty. * DOM/DOM.mm: (-[DOMElement _imageTIFFRepresentation]): Use a bridging cast. (-[DOMNodeFilter finalize]): Deleted. WebKit no longer supports Objective-C garbage collection so this method isn't useful. * DOM/DOMXPath.mm: (-[DOMNativeXPathNSResolver finalize]): Deleted. WebKit no longer supports Objective-C garbage collection so this method isn't useful. * History/WebHistory.mm: (-[WebHistoryPrivate data]): Allocate an NSData instead of casting from a CFData. * Misc/WebElementDictionary.mm: (addLookupKey): Use a bridging cast. (cacheValueForKey): Ditto. (-[WebElementDictionary _fillCache]): Ditto. (-[WebElementDictionary objectForKey:]): Ditto. * Misc/WebKitNSStringExtras.mm: (-[NSString _web_drawAtPoint:font:textColor:]): Use a bridging cast. (-[NSString _web_widthWithFont:]): Ditto. (-[NSString _webkit_stringByTrimmingWhitespace]): Ditto. * Misc/WebLocalizableStrings.mm: (WebLocalizedString): Use a bridging cast. * Misc/WebNSDataExtras.mm: (-[NSString _web_capitalizeRFC822HeaderFieldName]): Use a bridging cast and use CFBridgingRelease instead of calling autorelease directly. (-[NSData _webkit_parseRFC822HeaderFields]): Use NSString methods instead of a mix of CFString and NSString. Also simplified logic a bit, and cut down on the amount of explicit release and autorelease. * Misc/WebNSDictionaryExtras.h: Deleted unused methods. * Misc/WebNSDictionaryExtras.m: (-[NSDictionary _webkit_intForKey:]): Deleted. (-[NSMutableDictionary _webkit_setInt:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setFloat:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setBool:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setLongLong:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setUnsignedLongLong:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setUnsignedInt:forKey:]): Deleted. * Misc/WebStringTruncator.mm: (fontFromNSFont): Use a bridging cast. * Plugins/Hosted/NetscapePluginHostManager.mm: (WebKit::preferredBundleLocalizationName): Use a bridging cast and CFBridgingRelease. * Plugins/Hosted/NetscapePluginInstanceProxy.mm: (WebKit::NetscapePluginInstanceProxy::cleanup): Use a bridging cast. (WebKit::NetscapePluginInstanceProxy::status): Ditto. (WebKit::NetscapePluginInstanceProxy::loadURL): Ditto. (WebKit::NetscapePluginInstanceProxy::demarshalValueFromArray): Ditto. * Plugins/Hosted/ProxyInstance.mm: (WebKit::ProxyInstance::getPropertyNames): Ditto. * Plugins/WebBasePluginPackage.mm: (-[WebBasePluginPackage _objectForInfoDictionaryKey:]): Ditto. * Plugins/WebNetscapePluginEventHandlerCocoa.mm: (WebNetscapePluginEventHandlerCocoa::platformWindow): Ditto. * Plugins/WebNetscapePluginPackage.mm: (-[WebNetscapePluginPackage _initWithPath:]): Ditto. * Plugins/WebNetscapePluginView.mm: (-[WebNetscapePluginView _postURL:target:len:buf:file:notifyData:sendNotification:allowHeaders:]): Use bridging casts and use RetainPtr insteead of an explicit CFRelease. (-[WebNetscapePluginView status:]): Use a bridging cast. (-[WebNetscapePluginView popUpContextMenu:]): Ditto. * Plugins/WebPluginController.mm: (-[WebPluginController _cancelOutstandingChecks]): Use a bridging cast. * Plugins/WebPluginDatabase.mm: (checkCandidate): Use explicit __strong for out argument types. * Plugins/npapi.mm: (pluginViewForInstance): Use a bridging cast. * Storage/WebDatabaseManager.mm: (-[WebDatabaseManager detailsForDatabase:withOrigin:]): Use modern boxing instead of explicit NSNumber and NSDictionary calls. * WebCoreSupport/WebContextMenuClient.mm: (WebContextMenuClient::speak): Remove an unnecessary copy/autorelease pair. * WebCoreSupport/WebEditorClient.mm: (WebEditorClient::handleKeyboardEvent): Added a missing typecast. (WebEditorClient::handleInputMethodKeydown): Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: (WebFrameNetworkingContext::sourceApplicationAuditData const): Use a bridging cast. * WebCoreSupport/WebSecurityOriginPrivate.h: Forward declare WebSecurityOriginPrivate as a struct rather than an Objective-C class, since that's how it's defined. * WebInspector/WebNodeHighlighter.mm: Added missing includes. * WebView/WebFullScreenController.mm: (-[WebFullScreenController enterFullScreen:]): Use a bridging cast. * WebView/WebHTMLView.mm: (-[WebHTMLView _writeSelectionWithPasteboardTypes:toPasteboard:cachedAttributedString:]): Ditto. (-[WebHTMLView pasteboard:provideDataForType:]): Ditto. * WebView/WebImmediateActionController.mm: (-[WebImmediateActionController performHitTestAtPoint:]): Removed redundant code to go down to the document and then back to the frame. (-[WebImmediateActionController immediateActionRecognizerDidUpdateAnimation:]): Ditto. (-[WebImmediateActionController immediateActionRecognizerDidCancelAnimation:]): Ditto. (-[WebImmediateActionController immediateActionRecognizerDidCompleteAnimation:]): Ditto. * WebView/WebJSPDFDoc.mm: (jsPDFDocInitialize): Removed some unneeded type casting. (jsPDFDocFinalize): Ditto. (jsPDFDocPrint): Use a bridging cast. * WebView/WebPDFView.mm: (_applicationInfoForMIMEType): Use bridging casts. * WebView/WebPreferences.mm: (-[WebPreferences _setIntegerValue:forKey:]): Use boxing and setObject directly instead of methods from WebNSDictionaryExtras. (-[WebPreferences _setUnsignedIntValue:forKey:]): Ditto. (-[WebPreferences _setFloatValue:forKey:]): Ditto. (-[WebPreferences _setBoolValue:forKey:]): Ditto. (-[WebPreferences _setLongLongValue:forKey:]): Ditto. (-[WebPreferences _setUnsignedLongLongValue:forKey:]): Ditto. * WebView/WebView.mm: (-[WebView _removeFromAllWebViewsSet]): Use bridging cast. (-[WebView _addToAllWebViewsSet]): Ditto. (+[WebView closeAllWebViews]): Use a modern for loop instead of NSEnumerator. (-[WebView _windowVisibilityChanged:]): Moved this into the internal category so it can be called from WebViewData methods. * WebView/WebViewData.mm: Added an import so we can call an internal WebView method, _windowVisibilityChanged:. * WebView/WebViewInternal.h: Declared _windowVisibilityChanged: so it can be called from WebViewData methods. Source/WTF: * WTF.xcodeproj/project.pbxproj: Updated for rename: FoundationSPI.h -> objcSPI.h. * wtf/BlockPtr.h: Added missing include of "StdLibExtras.h". Also re-sorted includes. * wtf/HashFunctions.h: Add function for "__unsafe_unretained id". * wtf/HashTraits.h: Add traits for "__unsafe_unretained id". * wtf/PlatformMac.cmake: Updated for rename: FoundationSPI.h -> objcSPI.h. * wtf/WeakObjCPtr.h: Use mutable instead of const_cast, and write a version that uses __weak explicitly under ARC. Also moved function declarations from here to objcSPI.h. * wtf/cocoa/AutodrainedPool.cpp: Updated include for rename: FoundationSPI.h -> objcSPI.h. * wtf/spi/cocoa/objcSPI.h: Renamed from FoundationSPI.h and added the additional functions used by WeakObjCPtr.h. Also changed to both include the internal header and the function definitions when compiling with USE(APPLE_INTERNAL_SDK), helping us check that function definitions match. Tools: * DumpRenderTree/TestNetscapePlugIn/PluginObject.h: Use const void* for a CFTypeRef instead of void*. * DumpRenderTree/TestNetscapePlugIn/PluginObjectMac.mm: (createCoreAnimationLayer): Use CFBridgingRetain. * DumpRenderTree/mac/AccessibilityUIElementMac.mm: (AccessibilityUIElement::lineTextMarkerRangeForTextMarker): Use bridging casts. (AccessibilityUIElement::textMarkerRangeForElement): Ditto. (AccessibilityUIElement::selectedTextMarkerRange): Ditto. (AccessibilityUIElement::textMarkerRangeLength): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute): Ditto. (AccessibilityUIElement::indexForTextMarker): Ditto. (AccessibilityUIElement::textMarkerForIndex): Ditto. (AccessibilityUIElement::isTextMarkerValid): Ditto. (AccessibilityUIElement::previousTextMarker): Ditto. (AccessibilityUIElement::nextTextMarker): Ditto. (AccessibilityUIElement::stringForTextMarkerRange): Ditto. (createJSStringRef): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRange): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions): Ditto. (AccessibilityUIElement::textMarkerRangeForMarkers): Ditto. (AccessibilityUIElement::startTextMarkerForTextMarkerRange): Ditto. (AccessibilityUIElement::endTextMarkerForTextMarkerRange): Ditto. (AccessibilityUIElement::endTextMarkerForBounds): Ditto. (AccessibilityUIElement::startTextMarkerForBounds): Ditto. (AccessibilityUIElement::textMarkerForPoint): Ditto. (AccessibilityUIElement::accessibilityElementForTextMarker): Ditto. (AccessibilityUIElement::startTextMarker): Ditto. (AccessibilityUIElement::endTextMarker): Ditto. (AccessibilityUIElement::setSelectedVisibleTextRange): Ditto. (AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousWordStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextWordEndTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::paragraphTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousParagraphStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextParagraphEndTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::sentenceTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousSentenceStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextSentenceEndTextMarkerForTextMarker): Ditto. * DumpRenderTree/mac/DumpRenderTree.mm: (resetWebPreferencesToConsistentValues): Use bridging cast. (dumpFramesAsText): Ditto. (dumpBackForwardListForAllWindows): Use a modern for loop instead of CFArray functions to iterate the array. (dump): Use bridging cast. (runTest): Ditto. * DumpRenderTree/mac/DumpRenderTreePasteboard.mm: (+[LocalPasteboard alloc]): Use class_createInstance instead of NSAllocateObject. (toUTI): Return a RetainPtr<CFStringRef>. (-[LocalPasteboard types]): Use the above and bridging casts. (-[LocalPasteboard availableTypeFromArray:]): Ditto. (-[LocalPasteboard setData:forType:]): Ditto. (-[LocalPasteboard dataForType:]): Ditto. (-[LocalPasteboard setPropertyList:forType:]): Use NSPropertyListSerialization instead of CFPropertyList. (-[LocalPasteboard setString:forType:]): Use NSString method instead of CFStringCreateExternalRepresentation. * DumpRenderTree/mac/MockGeolocationProvider.h: Put CFTypeRef in a HashSet instead of an Objective-C object pointer type. * DumpRenderTree/mac/MockGeolocationProvider.mm: (-[MockGeolocationProvider registerWebView:]): Update for above. (-[MockGeolocationProvider unregisterWebView:]): Ditto. (-[MockGeolocationProvider timerFired]): Ditto. * DumpRenderTree/mac/MockWebNotificationProvider.h: Use CFTypeRef in HashMap and HashSet instead of an Objective-C object pointer type. * DumpRenderTree/mac/MockWebNotificationProvider.mm: (-[MockWebNotificationProvider registerWebView:]): Update for above. (-[MockWebNotificationProvider unregisterWebView:]): Ditto. (-[MockWebNotificationProvider showNotification:fromWebView:]): Ditto. (-[MockWebNotificationProvider cancelNotification:]): Ditto. (-[MockWebNotificationProvider simulateWebNotificationClick:]): Ditto. * DumpRenderTree/mac/ObjCPlugin.m: (-[JSObjC retainObject:]): Use CFRetain instead of -[NSObject retain]. * DumpRenderTree/mac/TestRunnerMac.mm: (TestRunner::addDisallowedURL): Use bridging cast. (TestRunner::applicationCacheDiskUsageForOrigin): Ditto. (TestRunner::clearApplicationCacheForOrigin): Ditto. (originsArrayToJS): Ditto. (TestRunner::copyDecodedHostName): Ditto. (TestRunner::copyEncodedHostName): Ditto. (TestRunner::queueLoad): Ditto. (TestRunner::setDomainRelaxationForbiddenForURLScheme): Ditto. (TestRunner::setMockGeolocationPositionUnavailableError): Ditto. (TestRunner::setUserStyleSheetLocation): Ditto. (TestRunner::setValueForUser): Ditto. (TestRunner::overridePreference): Ditto. (TestRunner::execCommand): Ditto. (TestRunner::findString): Ditto. (TestRunner::isCommandEnabled): Ditto. (TestRunner::addOriginAccessWhitelistEntry): Ditto. (TestRunner::removeOriginAccessWhitelistEntry): Ditto. (TestRunner::addUserScript): Ditto. (TestRunner::addUserStyleSheet): Ditto. (TestRunner::evaluateInWebInspector): Ditto. (TestRunner::evaluateScriptInIsolatedWorld): Ditto. (TestRunner::authenticateSession): Ditto. (TestRunner::grantWebNotificationPermission): Ditto. (TestRunner::denyWebNotificationPermission): Ditto. * TestRunnerShared/cocoa/LayoutTestSpellChecker.mm: (-[LayoutTestSpellChecker setResultsFromJSObject:inContext:]): Ditto. * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm: (WTR::AccessibilityUIElement::lineTextMarkerRangeForTextMarker): Use bridging cast. (WTR::AccessibilityUIElement::textMarkerRangeForElement): Ditto. (WTR::AccessibilityUIElement::previousTextMarker): Ditto. (WTR::AccessibilityUIElement::nextTextMarker): Ditto. (WTR::AccessibilityUIElement::textMarkerRangeForMarkers): Ditto. (WTR::AccessibilityUIElement::selectedTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::startTextMarkerForTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::endTextMarkerForTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::endTextMarkerForBounds): Ditto. (WTR::AccessibilityUIElement::startTextMarkerForBounds): Ditto. (WTR::AccessibilityUIElement::textMarkerForPoint): Ditto. (WTR::AccessibilityUIElement::textMarkerForIndex): Ditto. (WTR::AccessibilityUIElement::startTextMarker): Ditto. (WTR::AccessibilityUIElement::endTextMarker): Ditto. (WTR::AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousWordStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextWordEndTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::paragraphTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousParagraphStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextParagraphEndTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::sentenceTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousSentenceStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextSentenceEndTextMarkerForTextMarker): Ditto. * WebKitTestRunner/PlatformMac.cmake: Added WebKitTestRunnerWindow.h and .mm files. * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: Ditto. * WebKitTestRunner/mac/EventSenderProxy.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. * WebKitTestRunner/mac/PlatformWebViewMac.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. Moved WebKitTestRunnerWindow class into a separate file. (WTR::PlatformWebView::keyWindow): Call +[WebKitTestRunnerWindow _WTR_keyWindow] instead of have a second copy of the implementation. * WebKitTestRunner/mac/WebKitTestRunnerEvent.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. Also removed "using namespace". (+[WebKitTestRunnerEvent mouseLocation]): Updated for above. * WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm: (+[LocalPasteboard alloc]): Use class_createInstance instead of NSAllocateObject. (-[LocalPasteboard availableTypeFromArray:]): Use modern for loop. (-[LocalPasteboard setData:forType:]): Reordered method to be a tiny bit more efficient. (-[LocalPasteboard setPropertyList:forType:]): Use NSPropertyListSerialization instead of CFPropertyList. (-[LocalPasteboard setString:forType:]): Use NSString method instead of CFStringCreateExternalRepresentation. * WebKitTestRunner/mac/WebKitTestRunnerWindow.h: Moved declaration of WebKitTestRunnerWindow here so it can be included by files that need to know what the type is and that it inherits from NSWindow. * WebKitTestRunner/mac/WebKitTestRunnerWindow.mm: Added. Moved implementation here. (+[WebKitTestRunnerWindow _WTR_keyWindow]): Use modern for loop instead of the old, messier implementation. Canonical link: https://commits.webkit.org/203508@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234685 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-08-08 02:39:12 +00:00
#endif
}
[Cocoa] More tweaks and refactoring to prepare for ARC https://bugs.webkit.org/show_bug.cgi?id=188245 Reviewed by Dan Bernstein. Source/JavaScriptCore: * API/JSValue.mm: Use __unsafe_unretained. (JSContainerConvertor::convert): Use auto for compatibility with the above. * API/JSWrapperMap.mm: (allocateConstructorForCustomClass): Use CFTypeRef instead of Protocol *. (-[JSWrapperMap initWithGlobalContextRef:]): Use __unsafe_unretained. * heap/Heap.cpp: Updated include for rename: FoundationSPI.h -> objcSPI.h. Source/WebCore: * bridge/objc/objc_instance.mm: Updated include for rename: FoundationSPI.h -> objcSPI.h. * platform/ios/wak/WebCoreThread.mm: Ditto. Source/WebKit: * Platform/cocoa/WKCrashReporter.mm: (WebKit::setCrashLogMessage): Refactor into a separate function for clarity. (WebKit::setCrashReportApplicationSpecificInformation): Use a bridging cast. * Shared/mac/PasteboardTypes.mm: (WebKit::PasteboardTypes::forEditing): Use a bridging cast. * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm: (WebKit::convertToNPNNString): Added. Uses CFStringRef rather than NSString so we can manually manage the autoreleasing. (WebKit::initializeKeyboardEvent): Use convertToNPNNString. (WebKit::NetscapePlugin::sendComplexTextInput): Ditto. * WebProcess/Plugins/PDF/PDFPlugin.mm: Use __unsafe_unretained explicitly for a parent pointer. We could consider moving to __weak after switching to ARC. Source/WebKitLegacy/mac: * Carbon/CarbonUtils.m: Updated include for rename: FoundationSPI.h -> objcSPI.h. * Carbon/CarbonWindowFrame.m: (-[CarbonWindowFrame dealloc]): Deleted. It was empty. * DOM/DOM.mm: (-[DOMElement _imageTIFFRepresentation]): Use a bridging cast. (-[DOMNodeFilter finalize]): Deleted. WebKit no longer supports Objective-C garbage collection so this method isn't useful. * DOM/DOMXPath.mm: (-[DOMNativeXPathNSResolver finalize]): Deleted. WebKit no longer supports Objective-C garbage collection so this method isn't useful. * History/WebHistory.mm: (-[WebHistoryPrivate data]): Allocate an NSData instead of casting from a CFData. * Misc/WebElementDictionary.mm: (addLookupKey): Use a bridging cast. (cacheValueForKey): Ditto. (-[WebElementDictionary _fillCache]): Ditto. (-[WebElementDictionary objectForKey:]): Ditto. * Misc/WebKitNSStringExtras.mm: (-[NSString _web_drawAtPoint:font:textColor:]): Use a bridging cast. (-[NSString _web_widthWithFont:]): Ditto. (-[NSString _webkit_stringByTrimmingWhitespace]): Ditto. * Misc/WebLocalizableStrings.mm: (WebLocalizedString): Use a bridging cast. * Misc/WebNSDataExtras.mm: (-[NSString _web_capitalizeRFC822HeaderFieldName]): Use a bridging cast and use CFBridgingRelease instead of calling autorelease directly. (-[NSData _webkit_parseRFC822HeaderFields]): Use NSString methods instead of a mix of CFString and NSString. Also simplified logic a bit, and cut down on the amount of explicit release and autorelease. * Misc/WebNSDictionaryExtras.h: Deleted unused methods. * Misc/WebNSDictionaryExtras.m: (-[NSDictionary _webkit_intForKey:]): Deleted. (-[NSMutableDictionary _webkit_setInt:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setFloat:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setBool:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setLongLong:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setUnsignedLongLong:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setUnsignedInt:forKey:]): Deleted. * Misc/WebStringTruncator.mm: (fontFromNSFont): Use a bridging cast. * Plugins/Hosted/NetscapePluginHostManager.mm: (WebKit::preferredBundleLocalizationName): Use a bridging cast and CFBridgingRelease. * Plugins/Hosted/NetscapePluginInstanceProxy.mm: (WebKit::NetscapePluginInstanceProxy::cleanup): Use a bridging cast. (WebKit::NetscapePluginInstanceProxy::status): Ditto. (WebKit::NetscapePluginInstanceProxy::loadURL): Ditto. (WebKit::NetscapePluginInstanceProxy::demarshalValueFromArray): Ditto. * Plugins/Hosted/ProxyInstance.mm: (WebKit::ProxyInstance::getPropertyNames): Ditto. * Plugins/WebBasePluginPackage.mm: (-[WebBasePluginPackage _objectForInfoDictionaryKey:]): Ditto. * Plugins/WebNetscapePluginEventHandlerCocoa.mm: (WebNetscapePluginEventHandlerCocoa::platformWindow): Ditto. * Plugins/WebNetscapePluginPackage.mm: (-[WebNetscapePluginPackage _initWithPath:]): Ditto. * Plugins/WebNetscapePluginView.mm: (-[WebNetscapePluginView _postURL:target:len:buf:file:notifyData:sendNotification:allowHeaders:]): Use bridging casts and use RetainPtr insteead of an explicit CFRelease. (-[WebNetscapePluginView status:]): Use a bridging cast. (-[WebNetscapePluginView popUpContextMenu:]): Ditto. * Plugins/WebPluginController.mm: (-[WebPluginController _cancelOutstandingChecks]): Use a bridging cast. * Plugins/WebPluginDatabase.mm: (checkCandidate): Use explicit __strong for out argument types. * Plugins/npapi.mm: (pluginViewForInstance): Use a bridging cast. * Storage/WebDatabaseManager.mm: (-[WebDatabaseManager detailsForDatabase:withOrigin:]): Use modern boxing instead of explicit NSNumber and NSDictionary calls. * WebCoreSupport/WebContextMenuClient.mm: (WebContextMenuClient::speak): Remove an unnecessary copy/autorelease pair. * WebCoreSupport/WebEditorClient.mm: (WebEditorClient::handleKeyboardEvent): Added a missing typecast. (WebEditorClient::handleInputMethodKeydown): Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: (WebFrameNetworkingContext::sourceApplicationAuditData const): Use a bridging cast. * WebCoreSupport/WebSecurityOriginPrivate.h: Forward declare WebSecurityOriginPrivate as a struct rather than an Objective-C class, since that's how it's defined. * WebInspector/WebNodeHighlighter.mm: Added missing includes. * WebView/WebFullScreenController.mm: (-[WebFullScreenController enterFullScreen:]): Use a bridging cast. * WebView/WebHTMLView.mm: (-[WebHTMLView _writeSelectionWithPasteboardTypes:toPasteboard:cachedAttributedString:]): Ditto. (-[WebHTMLView pasteboard:provideDataForType:]): Ditto. * WebView/WebImmediateActionController.mm: (-[WebImmediateActionController performHitTestAtPoint:]): Removed redundant code to go down to the document and then back to the frame. (-[WebImmediateActionController immediateActionRecognizerDidUpdateAnimation:]): Ditto. (-[WebImmediateActionController immediateActionRecognizerDidCancelAnimation:]): Ditto. (-[WebImmediateActionController immediateActionRecognizerDidCompleteAnimation:]): Ditto. * WebView/WebJSPDFDoc.mm: (jsPDFDocInitialize): Removed some unneeded type casting. (jsPDFDocFinalize): Ditto. (jsPDFDocPrint): Use a bridging cast. * WebView/WebPDFView.mm: (_applicationInfoForMIMEType): Use bridging casts. * WebView/WebPreferences.mm: (-[WebPreferences _setIntegerValue:forKey:]): Use boxing and setObject directly instead of methods from WebNSDictionaryExtras. (-[WebPreferences _setUnsignedIntValue:forKey:]): Ditto. (-[WebPreferences _setFloatValue:forKey:]): Ditto. (-[WebPreferences _setBoolValue:forKey:]): Ditto. (-[WebPreferences _setLongLongValue:forKey:]): Ditto. (-[WebPreferences _setUnsignedLongLongValue:forKey:]): Ditto. * WebView/WebView.mm: (-[WebView _removeFromAllWebViewsSet]): Use bridging cast. (-[WebView _addToAllWebViewsSet]): Ditto. (+[WebView closeAllWebViews]): Use a modern for loop instead of NSEnumerator. (-[WebView _windowVisibilityChanged:]): Moved this into the internal category so it can be called from WebViewData methods. * WebView/WebViewData.mm: Added an import so we can call an internal WebView method, _windowVisibilityChanged:. * WebView/WebViewInternal.h: Declared _windowVisibilityChanged: so it can be called from WebViewData methods. Source/WTF: * WTF.xcodeproj/project.pbxproj: Updated for rename: FoundationSPI.h -> objcSPI.h. * wtf/BlockPtr.h: Added missing include of "StdLibExtras.h". Also re-sorted includes. * wtf/HashFunctions.h: Add function for "__unsafe_unretained id". * wtf/HashTraits.h: Add traits for "__unsafe_unretained id". * wtf/PlatformMac.cmake: Updated for rename: FoundationSPI.h -> objcSPI.h. * wtf/WeakObjCPtr.h: Use mutable instead of const_cast, and write a version that uses __weak explicitly under ARC. Also moved function declarations from here to objcSPI.h. * wtf/cocoa/AutodrainedPool.cpp: Updated include for rename: FoundationSPI.h -> objcSPI.h. * wtf/spi/cocoa/objcSPI.h: Renamed from FoundationSPI.h and added the additional functions used by WeakObjCPtr.h. Also changed to both include the internal header and the function definitions when compiling with USE(APPLE_INTERNAL_SDK), helping us check that function definitions match. Tools: * DumpRenderTree/TestNetscapePlugIn/PluginObject.h: Use const void* for a CFTypeRef instead of void*. * DumpRenderTree/TestNetscapePlugIn/PluginObjectMac.mm: (createCoreAnimationLayer): Use CFBridgingRetain. * DumpRenderTree/mac/AccessibilityUIElementMac.mm: (AccessibilityUIElement::lineTextMarkerRangeForTextMarker): Use bridging casts. (AccessibilityUIElement::textMarkerRangeForElement): Ditto. (AccessibilityUIElement::selectedTextMarkerRange): Ditto. (AccessibilityUIElement::textMarkerRangeLength): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute): Ditto. (AccessibilityUIElement::indexForTextMarker): Ditto. (AccessibilityUIElement::textMarkerForIndex): Ditto. (AccessibilityUIElement::isTextMarkerValid): Ditto. (AccessibilityUIElement::previousTextMarker): Ditto. (AccessibilityUIElement::nextTextMarker): Ditto. (AccessibilityUIElement::stringForTextMarkerRange): Ditto. (createJSStringRef): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRange): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions): Ditto. (AccessibilityUIElement::textMarkerRangeForMarkers): Ditto. (AccessibilityUIElement::startTextMarkerForTextMarkerRange): Ditto. (AccessibilityUIElement::endTextMarkerForTextMarkerRange): Ditto. (AccessibilityUIElement::endTextMarkerForBounds): Ditto. (AccessibilityUIElement::startTextMarkerForBounds): Ditto. (AccessibilityUIElement::textMarkerForPoint): Ditto. (AccessibilityUIElement::accessibilityElementForTextMarker): Ditto. (AccessibilityUIElement::startTextMarker): Ditto. (AccessibilityUIElement::endTextMarker): Ditto. (AccessibilityUIElement::setSelectedVisibleTextRange): Ditto. (AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousWordStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextWordEndTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::paragraphTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousParagraphStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextParagraphEndTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::sentenceTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousSentenceStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextSentenceEndTextMarkerForTextMarker): Ditto. * DumpRenderTree/mac/DumpRenderTree.mm: (resetWebPreferencesToConsistentValues): Use bridging cast. (dumpFramesAsText): Ditto. (dumpBackForwardListForAllWindows): Use a modern for loop instead of CFArray functions to iterate the array. (dump): Use bridging cast. (runTest): Ditto. * DumpRenderTree/mac/DumpRenderTreePasteboard.mm: (+[LocalPasteboard alloc]): Use class_createInstance instead of NSAllocateObject. (toUTI): Return a RetainPtr<CFStringRef>. (-[LocalPasteboard types]): Use the above and bridging casts. (-[LocalPasteboard availableTypeFromArray:]): Ditto. (-[LocalPasteboard setData:forType:]): Ditto. (-[LocalPasteboard dataForType:]): Ditto. (-[LocalPasteboard setPropertyList:forType:]): Use NSPropertyListSerialization instead of CFPropertyList. (-[LocalPasteboard setString:forType:]): Use NSString method instead of CFStringCreateExternalRepresentation. * DumpRenderTree/mac/MockGeolocationProvider.h: Put CFTypeRef in a HashSet instead of an Objective-C object pointer type. * DumpRenderTree/mac/MockGeolocationProvider.mm: (-[MockGeolocationProvider registerWebView:]): Update for above. (-[MockGeolocationProvider unregisterWebView:]): Ditto. (-[MockGeolocationProvider timerFired]): Ditto. * DumpRenderTree/mac/MockWebNotificationProvider.h: Use CFTypeRef in HashMap and HashSet instead of an Objective-C object pointer type. * DumpRenderTree/mac/MockWebNotificationProvider.mm: (-[MockWebNotificationProvider registerWebView:]): Update for above. (-[MockWebNotificationProvider unregisterWebView:]): Ditto. (-[MockWebNotificationProvider showNotification:fromWebView:]): Ditto. (-[MockWebNotificationProvider cancelNotification:]): Ditto. (-[MockWebNotificationProvider simulateWebNotificationClick:]): Ditto. * DumpRenderTree/mac/ObjCPlugin.m: (-[JSObjC retainObject:]): Use CFRetain instead of -[NSObject retain]. * DumpRenderTree/mac/TestRunnerMac.mm: (TestRunner::addDisallowedURL): Use bridging cast. (TestRunner::applicationCacheDiskUsageForOrigin): Ditto. (TestRunner::clearApplicationCacheForOrigin): Ditto. (originsArrayToJS): Ditto. (TestRunner::copyDecodedHostName): Ditto. (TestRunner::copyEncodedHostName): Ditto. (TestRunner::queueLoad): Ditto. (TestRunner::setDomainRelaxationForbiddenForURLScheme): Ditto. (TestRunner::setMockGeolocationPositionUnavailableError): Ditto. (TestRunner::setUserStyleSheetLocation): Ditto. (TestRunner::setValueForUser): Ditto. (TestRunner::overridePreference): Ditto. (TestRunner::execCommand): Ditto. (TestRunner::findString): Ditto. (TestRunner::isCommandEnabled): Ditto. (TestRunner::addOriginAccessWhitelistEntry): Ditto. (TestRunner::removeOriginAccessWhitelistEntry): Ditto. (TestRunner::addUserScript): Ditto. (TestRunner::addUserStyleSheet): Ditto. (TestRunner::evaluateInWebInspector): Ditto. (TestRunner::evaluateScriptInIsolatedWorld): Ditto. (TestRunner::authenticateSession): Ditto. (TestRunner::grantWebNotificationPermission): Ditto. (TestRunner::denyWebNotificationPermission): Ditto. * TestRunnerShared/cocoa/LayoutTestSpellChecker.mm: (-[LayoutTestSpellChecker setResultsFromJSObject:inContext:]): Ditto. * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm: (WTR::AccessibilityUIElement::lineTextMarkerRangeForTextMarker): Use bridging cast. (WTR::AccessibilityUIElement::textMarkerRangeForElement): Ditto. (WTR::AccessibilityUIElement::previousTextMarker): Ditto. (WTR::AccessibilityUIElement::nextTextMarker): Ditto. (WTR::AccessibilityUIElement::textMarkerRangeForMarkers): Ditto. (WTR::AccessibilityUIElement::selectedTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::startTextMarkerForTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::endTextMarkerForTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::endTextMarkerForBounds): Ditto. (WTR::AccessibilityUIElement::startTextMarkerForBounds): Ditto. (WTR::AccessibilityUIElement::textMarkerForPoint): Ditto. (WTR::AccessibilityUIElement::textMarkerForIndex): Ditto. (WTR::AccessibilityUIElement::startTextMarker): Ditto. (WTR::AccessibilityUIElement::endTextMarker): Ditto. (WTR::AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousWordStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextWordEndTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::paragraphTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousParagraphStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextParagraphEndTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::sentenceTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousSentenceStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextSentenceEndTextMarkerForTextMarker): Ditto. * WebKitTestRunner/PlatformMac.cmake: Added WebKitTestRunnerWindow.h and .mm files. * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: Ditto. * WebKitTestRunner/mac/EventSenderProxy.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. * WebKitTestRunner/mac/PlatformWebViewMac.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. Moved WebKitTestRunnerWindow class into a separate file. (WTR::PlatformWebView::keyWindow): Call +[WebKitTestRunnerWindow _WTR_keyWindow] instead of have a second copy of the implementation. * WebKitTestRunner/mac/WebKitTestRunnerEvent.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. Also removed "using namespace". (+[WebKitTestRunnerEvent mouseLocation]): Updated for above. * WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm: (+[LocalPasteboard alloc]): Use class_createInstance instead of NSAllocateObject. (-[LocalPasteboard availableTypeFromArray:]): Use modern for loop. (-[LocalPasteboard setData:forType:]): Reordered method to be a tiny bit more efficient. (-[LocalPasteboard setPropertyList:forType:]): Use NSPropertyListSerialization instead of CFPropertyList. (-[LocalPasteboard setString:forType:]): Use NSString method instead of CFStringCreateExternalRepresentation. * WebKitTestRunner/mac/WebKitTestRunnerWindow.h: Moved declaration of WebKitTestRunnerWindow here so it can be included by files that need to know what the type is and that it inherits from NSWindow. * WebKitTestRunner/mac/WebKitTestRunnerWindow.mm: Added. Moved implementation here. (+[WebKitTestRunnerWindow _WTR_keyWindow]): Use modern for loop instead of the old, messier implementation. Canonical link: https://commits.webkit.org/203508@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234685 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-08-08 02:39:12 +00:00
#if !__has_feature(objc_arc)
WeakObjCPtr(const WeakObjCPtr& other)
{
[Cocoa] More tweaks and refactoring to prepare for ARC https://bugs.webkit.org/show_bug.cgi?id=188245 Reviewed by Dan Bernstein. Source/JavaScriptCore: * API/JSValue.mm: Use __unsafe_unretained. (JSContainerConvertor::convert): Use auto for compatibility with the above. * API/JSWrapperMap.mm: (allocateConstructorForCustomClass): Use CFTypeRef instead of Protocol *. (-[JSWrapperMap initWithGlobalContextRef:]): Use __unsafe_unretained. * heap/Heap.cpp: Updated include for rename: FoundationSPI.h -> objcSPI.h. Source/WebCore: * bridge/objc/objc_instance.mm: Updated include for rename: FoundationSPI.h -> objcSPI.h. * platform/ios/wak/WebCoreThread.mm: Ditto. Source/WebKit: * Platform/cocoa/WKCrashReporter.mm: (WebKit::setCrashLogMessage): Refactor into a separate function for clarity. (WebKit::setCrashReportApplicationSpecificInformation): Use a bridging cast. * Shared/mac/PasteboardTypes.mm: (WebKit::PasteboardTypes::forEditing): Use a bridging cast. * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm: (WebKit::convertToNPNNString): Added. Uses CFStringRef rather than NSString so we can manually manage the autoreleasing. (WebKit::initializeKeyboardEvent): Use convertToNPNNString. (WebKit::NetscapePlugin::sendComplexTextInput): Ditto. * WebProcess/Plugins/PDF/PDFPlugin.mm: Use __unsafe_unretained explicitly for a parent pointer. We could consider moving to __weak after switching to ARC. Source/WebKitLegacy/mac: * Carbon/CarbonUtils.m: Updated include for rename: FoundationSPI.h -> objcSPI.h. * Carbon/CarbonWindowFrame.m: (-[CarbonWindowFrame dealloc]): Deleted. It was empty. * DOM/DOM.mm: (-[DOMElement _imageTIFFRepresentation]): Use a bridging cast. (-[DOMNodeFilter finalize]): Deleted. WebKit no longer supports Objective-C garbage collection so this method isn't useful. * DOM/DOMXPath.mm: (-[DOMNativeXPathNSResolver finalize]): Deleted. WebKit no longer supports Objective-C garbage collection so this method isn't useful. * History/WebHistory.mm: (-[WebHistoryPrivate data]): Allocate an NSData instead of casting from a CFData. * Misc/WebElementDictionary.mm: (addLookupKey): Use a bridging cast. (cacheValueForKey): Ditto. (-[WebElementDictionary _fillCache]): Ditto. (-[WebElementDictionary objectForKey:]): Ditto. * Misc/WebKitNSStringExtras.mm: (-[NSString _web_drawAtPoint:font:textColor:]): Use a bridging cast. (-[NSString _web_widthWithFont:]): Ditto. (-[NSString _webkit_stringByTrimmingWhitespace]): Ditto. * Misc/WebLocalizableStrings.mm: (WebLocalizedString): Use a bridging cast. * Misc/WebNSDataExtras.mm: (-[NSString _web_capitalizeRFC822HeaderFieldName]): Use a bridging cast and use CFBridgingRelease instead of calling autorelease directly. (-[NSData _webkit_parseRFC822HeaderFields]): Use NSString methods instead of a mix of CFString and NSString. Also simplified logic a bit, and cut down on the amount of explicit release and autorelease. * Misc/WebNSDictionaryExtras.h: Deleted unused methods. * Misc/WebNSDictionaryExtras.m: (-[NSDictionary _webkit_intForKey:]): Deleted. (-[NSMutableDictionary _webkit_setInt:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setFloat:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setBool:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setLongLong:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setUnsignedLongLong:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setUnsignedInt:forKey:]): Deleted. * Misc/WebStringTruncator.mm: (fontFromNSFont): Use a bridging cast. * Plugins/Hosted/NetscapePluginHostManager.mm: (WebKit::preferredBundleLocalizationName): Use a bridging cast and CFBridgingRelease. * Plugins/Hosted/NetscapePluginInstanceProxy.mm: (WebKit::NetscapePluginInstanceProxy::cleanup): Use a bridging cast. (WebKit::NetscapePluginInstanceProxy::status): Ditto. (WebKit::NetscapePluginInstanceProxy::loadURL): Ditto. (WebKit::NetscapePluginInstanceProxy::demarshalValueFromArray): Ditto. * Plugins/Hosted/ProxyInstance.mm: (WebKit::ProxyInstance::getPropertyNames): Ditto. * Plugins/WebBasePluginPackage.mm: (-[WebBasePluginPackage _objectForInfoDictionaryKey:]): Ditto. * Plugins/WebNetscapePluginEventHandlerCocoa.mm: (WebNetscapePluginEventHandlerCocoa::platformWindow): Ditto. * Plugins/WebNetscapePluginPackage.mm: (-[WebNetscapePluginPackage _initWithPath:]): Ditto. * Plugins/WebNetscapePluginView.mm: (-[WebNetscapePluginView _postURL:target:len:buf:file:notifyData:sendNotification:allowHeaders:]): Use bridging casts and use RetainPtr insteead of an explicit CFRelease. (-[WebNetscapePluginView status:]): Use a bridging cast. (-[WebNetscapePluginView popUpContextMenu:]): Ditto. * Plugins/WebPluginController.mm: (-[WebPluginController _cancelOutstandingChecks]): Use a bridging cast. * Plugins/WebPluginDatabase.mm: (checkCandidate): Use explicit __strong for out argument types. * Plugins/npapi.mm: (pluginViewForInstance): Use a bridging cast. * Storage/WebDatabaseManager.mm: (-[WebDatabaseManager detailsForDatabase:withOrigin:]): Use modern boxing instead of explicit NSNumber and NSDictionary calls. * WebCoreSupport/WebContextMenuClient.mm: (WebContextMenuClient::speak): Remove an unnecessary copy/autorelease pair. * WebCoreSupport/WebEditorClient.mm: (WebEditorClient::handleKeyboardEvent): Added a missing typecast. (WebEditorClient::handleInputMethodKeydown): Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: (WebFrameNetworkingContext::sourceApplicationAuditData const): Use a bridging cast. * WebCoreSupport/WebSecurityOriginPrivate.h: Forward declare WebSecurityOriginPrivate as a struct rather than an Objective-C class, since that's how it's defined. * WebInspector/WebNodeHighlighter.mm: Added missing includes. * WebView/WebFullScreenController.mm: (-[WebFullScreenController enterFullScreen:]): Use a bridging cast. * WebView/WebHTMLView.mm: (-[WebHTMLView _writeSelectionWithPasteboardTypes:toPasteboard:cachedAttributedString:]): Ditto. (-[WebHTMLView pasteboard:provideDataForType:]): Ditto. * WebView/WebImmediateActionController.mm: (-[WebImmediateActionController performHitTestAtPoint:]): Removed redundant code to go down to the document and then back to the frame. (-[WebImmediateActionController immediateActionRecognizerDidUpdateAnimation:]): Ditto. (-[WebImmediateActionController immediateActionRecognizerDidCancelAnimation:]): Ditto. (-[WebImmediateActionController immediateActionRecognizerDidCompleteAnimation:]): Ditto. * WebView/WebJSPDFDoc.mm: (jsPDFDocInitialize): Removed some unneeded type casting. (jsPDFDocFinalize): Ditto. (jsPDFDocPrint): Use a bridging cast. * WebView/WebPDFView.mm: (_applicationInfoForMIMEType): Use bridging casts. * WebView/WebPreferences.mm: (-[WebPreferences _setIntegerValue:forKey:]): Use boxing and setObject directly instead of methods from WebNSDictionaryExtras. (-[WebPreferences _setUnsignedIntValue:forKey:]): Ditto. (-[WebPreferences _setFloatValue:forKey:]): Ditto. (-[WebPreferences _setBoolValue:forKey:]): Ditto. (-[WebPreferences _setLongLongValue:forKey:]): Ditto. (-[WebPreferences _setUnsignedLongLongValue:forKey:]): Ditto. * WebView/WebView.mm: (-[WebView _removeFromAllWebViewsSet]): Use bridging cast. (-[WebView _addToAllWebViewsSet]): Ditto. (+[WebView closeAllWebViews]): Use a modern for loop instead of NSEnumerator. (-[WebView _windowVisibilityChanged:]): Moved this into the internal category so it can be called from WebViewData methods. * WebView/WebViewData.mm: Added an import so we can call an internal WebView method, _windowVisibilityChanged:. * WebView/WebViewInternal.h: Declared _windowVisibilityChanged: so it can be called from WebViewData methods. Source/WTF: * WTF.xcodeproj/project.pbxproj: Updated for rename: FoundationSPI.h -> objcSPI.h. * wtf/BlockPtr.h: Added missing include of "StdLibExtras.h". Also re-sorted includes. * wtf/HashFunctions.h: Add function for "__unsafe_unretained id". * wtf/HashTraits.h: Add traits for "__unsafe_unretained id". * wtf/PlatformMac.cmake: Updated for rename: FoundationSPI.h -> objcSPI.h. * wtf/WeakObjCPtr.h: Use mutable instead of const_cast, and write a version that uses __weak explicitly under ARC. Also moved function declarations from here to objcSPI.h. * wtf/cocoa/AutodrainedPool.cpp: Updated include for rename: FoundationSPI.h -> objcSPI.h. * wtf/spi/cocoa/objcSPI.h: Renamed from FoundationSPI.h and added the additional functions used by WeakObjCPtr.h. Also changed to both include the internal header and the function definitions when compiling with USE(APPLE_INTERNAL_SDK), helping us check that function definitions match. Tools: * DumpRenderTree/TestNetscapePlugIn/PluginObject.h: Use const void* for a CFTypeRef instead of void*. * DumpRenderTree/TestNetscapePlugIn/PluginObjectMac.mm: (createCoreAnimationLayer): Use CFBridgingRetain. * DumpRenderTree/mac/AccessibilityUIElementMac.mm: (AccessibilityUIElement::lineTextMarkerRangeForTextMarker): Use bridging casts. (AccessibilityUIElement::textMarkerRangeForElement): Ditto. (AccessibilityUIElement::selectedTextMarkerRange): Ditto. (AccessibilityUIElement::textMarkerRangeLength): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute): Ditto. (AccessibilityUIElement::indexForTextMarker): Ditto. (AccessibilityUIElement::textMarkerForIndex): Ditto. (AccessibilityUIElement::isTextMarkerValid): Ditto. (AccessibilityUIElement::previousTextMarker): Ditto. (AccessibilityUIElement::nextTextMarker): Ditto. (AccessibilityUIElement::stringForTextMarkerRange): Ditto. (createJSStringRef): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRange): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions): Ditto. (AccessibilityUIElement::textMarkerRangeForMarkers): Ditto. (AccessibilityUIElement::startTextMarkerForTextMarkerRange): Ditto. (AccessibilityUIElement::endTextMarkerForTextMarkerRange): Ditto. (AccessibilityUIElement::endTextMarkerForBounds): Ditto. (AccessibilityUIElement::startTextMarkerForBounds): Ditto. (AccessibilityUIElement::textMarkerForPoint): Ditto. (AccessibilityUIElement::accessibilityElementForTextMarker): Ditto. (AccessibilityUIElement::startTextMarker): Ditto. (AccessibilityUIElement::endTextMarker): Ditto. (AccessibilityUIElement::setSelectedVisibleTextRange): Ditto. (AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousWordStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextWordEndTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::paragraphTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousParagraphStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextParagraphEndTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::sentenceTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousSentenceStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextSentenceEndTextMarkerForTextMarker): Ditto. * DumpRenderTree/mac/DumpRenderTree.mm: (resetWebPreferencesToConsistentValues): Use bridging cast. (dumpFramesAsText): Ditto. (dumpBackForwardListForAllWindows): Use a modern for loop instead of CFArray functions to iterate the array. (dump): Use bridging cast. (runTest): Ditto. * DumpRenderTree/mac/DumpRenderTreePasteboard.mm: (+[LocalPasteboard alloc]): Use class_createInstance instead of NSAllocateObject. (toUTI): Return a RetainPtr<CFStringRef>. (-[LocalPasteboard types]): Use the above and bridging casts. (-[LocalPasteboard availableTypeFromArray:]): Ditto. (-[LocalPasteboard setData:forType:]): Ditto. (-[LocalPasteboard dataForType:]): Ditto. (-[LocalPasteboard setPropertyList:forType:]): Use NSPropertyListSerialization instead of CFPropertyList. (-[LocalPasteboard setString:forType:]): Use NSString method instead of CFStringCreateExternalRepresentation. * DumpRenderTree/mac/MockGeolocationProvider.h: Put CFTypeRef in a HashSet instead of an Objective-C object pointer type. * DumpRenderTree/mac/MockGeolocationProvider.mm: (-[MockGeolocationProvider registerWebView:]): Update for above. (-[MockGeolocationProvider unregisterWebView:]): Ditto. (-[MockGeolocationProvider timerFired]): Ditto. * DumpRenderTree/mac/MockWebNotificationProvider.h: Use CFTypeRef in HashMap and HashSet instead of an Objective-C object pointer type. * DumpRenderTree/mac/MockWebNotificationProvider.mm: (-[MockWebNotificationProvider registerWebView:]): Update for above. (-[MockWebNotificationProvider unregisterWebView:]): Ditto. (-[MockWebNotificationProvider showNotification:fromWebView:]): Ditto. (-[MockWebNotificationProvider cancelNotification:]): Ditto. (-[MockWebNotificationProvider simulateWebNotificationClick:]): Ditto. * DumpRenderTree/mac/ObjCPlugin.m: (-[JSObjC retainObject:]): Use CFRetain instead of -[NSObject retain]. * DumpRenderTree/mac/TestRunnerMac.mm: (TestRunner::addDisallowedURL): Use bridging cast. (TestRunner::applicationCacheDiskUsageForOrigin): Ditto. (TestRunner::clearApplicationCacheForOrigin): Ditto. (originsArrayToJS): Ditto. (TestRunner::copyDecodedHostName): Ditto. (TestRunner::copyEncodedHostName): Ditto. (TestRunner::queueLoad): Ditto. (TestRunner::setDomainRelaxationForbiddenForURLScheme): Ditto. (TestRunner::setMockGeolocationPositionUnavailableError): Ditto. (TestRunner::setUserStyleSheetLocation): Ditto. (TestRunner::setValueForUser): Ditto. (TestRunner::overridePreference): Ditto. (TestRunner::execCommand): Ditto. (TestRunner::findString): Ditto. (TestRunner::isCommandEnabled): Ditto. (TestRunner::addOriginAccessWhitelistEntry): Ditto. (TestRunner::removeOriginAccessWhitelistEntry): Ditto. (TestRunner::addUserScript): Ditto. (TestRunner::addUserStyleSheet): Ditto. (TestRunner::evaluateInWebInspector): Ditto. (TestRunner::evaluateScriptInIsolatedWorld): Ditto. (TestRunner::authenticateSession): Ditto. (TestRunner::grantWebNotificationPermission): Ditto. (TestRunner::denyWebNotificationPermission): Ditto. * TestRunnerShared/cocoa/LayoutTestSpellChecker.mm: (-[LayoutTestSpellChecker setResultsFromJSObject:inContext:]): Ditto. * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm: (WTR::AccessibilityUIElement::lineTextMarkerRangeForTextMarker): Use bridging cast. (WTR::AccessibilityUIElement::textMarkerRangeForElement): Ditto. (WTR::AccessibilityUIElement::previousTextMarker): Ditto. (WTR::AccessibilityUIElement::nextTextMarker): Ditto. (WTR::AccessibilityUIElement::textMarkerRangeForMarkers): Ditto. (WTR::AccessibilityUIElement::selectedTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::startTextMarkerForTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::endTextMarkerForTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::endTextMarkerForBounds): Ditto. (WTR::AccessibilityUIElement::startTextMarkerForBounds): Ditto. (WTR::AccessibilityUIElement::textMarkerForPoint): Ditto. (WTR::AccessibilityUIElement::textMarkerForIndex): Ditto. (WTR::AccessibilityUIElement::startTextMarker): Ditto. (WTR::AccessibilityUIElement::endTextMarker): Ditto. (WTR::AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousWordStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextWordEndTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::paragraphTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousParagraphStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextParagraphEndTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::sentenceTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousSentenceStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextSentenceEndTextMarkerForTextMarker): Ditto. * WebKitTestRunner/PlatformMac.cmake: Added WebKitTestRunnerWindow.h and .mm files. * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: Ditto. * WebKitTestRunner/mac/EventSenderProxy.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. * WebKitTestRunner/mac/PlatformWebViewMac.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. Moved WebKitTestRunnerWindow class into a separate file. (WTR::PlatformWebView::keyWindow): Call +[WebKitTestRunnerWindow _WTR_keyWindow] instead of have a second copy of the implementation. * WebKitTestRunner/mac/WebKitTestRunnerEvent.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. Also removed "using namespace". (+[WebKitTestRunnerEvent mouseLocation]): Updated for above. * WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm: (+[LocalPasteboard alloc]): Use class_createInstance instead of NSAllocateObject. (-[LocalPasteboard availableTypeFromArray:]): Use modern for loop. (-[LocalPasteboard setData:forType:]): Reordered method to be a tiny bit more efficient. (-[LocalPasteboard setPropertyList:forType:]): Use NSPropertyListSerialization instead of CFPropertyList. (-[LocalPasteboard setString:forType:]): Use NSString method instead of CFStringCreateExternalRepresentation. * WebKitTestRunner/mac/WebKitTestRunnerWindow.h: Moved declaration of WebKitTestRunnerWindow here so it can be included by files that need to know what the type is and that it inherits from NSWindow. * WebKitTestRunner/mac/WebKitTestRunnerWindow.mm: Added. Moved implementation here. (+[WebKitTestRunnerWindow _WTR_keyWindow]): Use modern for loop instead of the old, messier implementation. Canonical link: https://commits.webkit.org/203508@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234685 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-08-08 02:39:12 +00:00
objc_copyWeak(&m_weakReference, &other.m_weakReference);
}
WeakObjCPtr(WeakObjCPtr&& other)
{
objc_moveWeak(&m_weakReference, &other.m_weakReference);
}
~WeakObjCPtr()
{
objc_destroyWeak(&m_weakReference);
}
[Cocoa] More tweaks and refactoring to prepare for ARC https://bugs.webkit.org/show_bug.cgi?id=188245 Reviewed by Dan Bernstein. Source/JavaScriptCore: * API/JSValue.mm: Use __unsafe_unretained. (JSContainerConvertor::convert): Use auto for compatibility with the above. * API/JSWrapperMap.mm: (allocateConstructorForCustomClass): Use CFTypeRef instead of Protocol *. (-[JSWrapperMap initWithGlobalContextRef:]): Use __unsafe_unretained. * heap/Heap.cpp: Updated include for rename: FoundationSPI.h -> objcSPI.h. Source/WebCore: * bridge/objc/objc_instance.mm: Updated include for rename: FoundationSPI.h -> objcSPI.h. * platform/ios/wak/WebCoreThread.mm: Ditto. Source/WebKit: * Platform/cocoa/WKCrashReporter.mm: (WebKit::setCrashLogMessage): Refactor into a separate function for clarity. (WebKit::setCrashReportApplicationSpecificInformation): Use a bridging cast. * Shared/mac/PasteboardTypes.mm: (WebKit::PasteboardTypes::forEditing): Use a bridging cast. * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm: (WebKit::convertToNPNNString): Added. Uses CFStringRef rather than NSString so we can manually manage the autoreleasing. (WebKit::initializeKeyboardEvent): Use convertToNPNNString. (WebKit::NetscapePlugin::sendComplexTextInput): Ditto. * WebProcess/Plugins/PDF/PDFPlugin.mm: Use __unsafe_unretained explicitly for a parent pointer. We could consider moving to __weak after switching to ARC. Source/WebKitLegacy/mac: * Carbon/CarbonUtils.m: Updated include for rename: FoundationSPI.h -> objcSPI.h. * Carbon/CarbonWindowFrame.m: (-[CarbonWindowFrame dealloc]): Deleted. It was empty. * DOM/DOM.mm: (-[DOMElement _imageTIFFRepresentation]): Use a bridging cast. (-[DOMNodeFilter finalize]): Deleted. WebKit no longer supports Objective-C garbage collection so this method isn't useful. * DOM/DOMXPath.mm: (-[DOMNativeXPathNSResolver finalize]): Deleted. WebKit no longer supports Objective-C garbage collection so this method isn't useful. * History/WebHistory.mm: (-[WebHistoryPrivate data]): Allocate an NSData instead of casting from a CFData. * Misc/WebElementDictionary.mm: (addLookupKey): Use a bridging cast. (cacheValueForKey): Ditto. (-[WebElementDictionary _fillCache]): Ditto. (-[WebElementDictionary objectForKey:]): Ditto. * Misc/WebKitNSStringExtras.mm: (-[NSString _web_drawAtPoint:font:textColor:]): Use a bridging cast. (-[NSString _web_widthWithFont:]): Ditto. (-[NSString _webkit_stringByTrimmingWhitespace]): Ditto. * Misc/WebLocalizableStrings.mm: (WebLocalizedString): Use a bridging cast. * Misc/WebNSDataExtras.mm: (-[NSString _web_capitalizeRFC822HeaderFieldName]): Use a bridging cast and use CFBridgingRelease instead of calling autorelease directly. (-[NSData _webkit_parseRFC822HeaderFields]): Use NSString methods instead of a mix of CFString and NSString. Also simplified logic a bit, and cut down on the amount of explicit release and autorelease. * Misc/WebNSDictionaryExtras.h: Deleted unused methods. * Misc/WebNSDictionaryExtras.m: (-[NSDictionary _webkit_intForKey:]): Deleted. (-[NSMutableDictionary _webkit_setInt:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setFloat:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setBool:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setLongLong:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setUnsignedLongLong:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setUnsignedInt:forKey:]): Deleted. * Misc/WebStringTruncator.mm: (fontFromNSFont): Use a bridging cast. * Plugins/Hosted/NetscapePluginHostManager.mm: (WebKit::preferredBundleLocalizationName): Use a bridging cast and CFBridgingRelease. * Plugins/Hosted/NetscapePluginInstanceProxy.mm: (WebKit::NetscapePluginInstanceProxy::cleanup): Use a bridging cast. (WebKit::NetscapePluginInstanceProxy::status): Ditto. (WebKit::NetscapePluginInstanceProxy::loadURL): Ditto. (WebKit::NetscapePluginInstanceProxy::demarshalValueFromArray): Ditto. * Plugins/Hosted/ProxyInstance.mm: (WebKit::ProxyInstance::getPropertyNames): Ditto. * Plugins/WebBasePluginPackage.mm: (-[WebBasePluginPackage _objectForInfoDictionaryKey:]): Ditto. * Plugins/WebNetscapePluginEventHandlerCocoa.mm: (WebNetscapePluginEventHandlerCocoa::platformWindow): Ditto. * Plugins/WebNetscapePluginPackage.mm: (-[WebNetscapePluginPackage _initWithPath:]): Ditto. * Plugins/WebNetscapePluginView.mm: (-[WebNetscapePluginView _postURL:target:len:buf:file:notifyData:sendNotification:allowHeaders:]): Use bridging casts and use RetainPtr insteead of an explicit CFRelease. (-[WebNetscapePluginView status:]): Use a bridging cast. (-[WebNetscapePluginView popUpContextMenu:]): Ditto. * Plugins/WebPluginController.mm: (-[WebPluginController _cancelOutstandingChecks]): Use a bridging cast. * Plugins/WebPluginDatabase.mm: (checkCandidate): Use explicit __strong for out argument types. * Plugins/npapi.mm: (pluginViewForInstance): Use a bridging cast. * Storage/WebDatabaseManager.mm: (-[WebDatabaseManager detailsForDatabase:withOrigin:]): Use modern boxing instead of explicit NSNumber and NSDictionary calls. * WebCoreSupport/WebContextMenuClient.mm: (WebContextMenuClient::speak): Remove an unnecessary copy/autorelease pair. * WebCoreSupport/WebEditorClient.mm: (WebEditorClient::handleKeyboardEvent): Added a missing typecast. (WebEditorClient::handleInputMethodKeydown): Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: (WebFrameNetworkingContext::sourceApplicationAuditData const): Use a bridging cast. * WebCoreSupport/WebSecurityOriginPrivate.h: Forward declare WebSecurityOriginPrivate as a struct rather than an Objective-C class, since that's how it's defined. * WebInspector/WebNodeHighlighter.mm: Added missing includes. * WebView/WebFullScreenController.mm: (-[WebFullScreenController enterFullScreen:]): Use a bridging cast. * WebView/WebHTMLView.mm: (-[WebHTMLView _writeSelectionWithPasteboardTypes:toPasteboard:cachedAttributedString:]): Ditto. (-[WebHTMLView pasteboard:provideDataForType:]): Ditto. * WebView/WebImmediateActionController.mm: (-[WebImmediateActionController performHitTestAtPoint:]): Removed redundant code to go down to the document and then back to the frame. (-[WebImmediateActionController immediateActionRecognizerDidUpdateAnimation:]): Ditto. (-[WebImmediateActionController immediateActionRecognizerDidCancelAnimation:]): Ditto. (-[WebImmediateActionController immediateActionRecognizerDidCompleteAnimation:]): Ditto. * WebView/WebJSPDFDoc.mm: (jsPDFDocInitialize): Removed some unneeded type casting. (jsPDFDocFinalize): Ditto. (jsPDFDocPrint): Use a bridging cast. * WebView/WebPDFView.mm: (_applicationInfoForMIMEType): Use bridging casts. * WebView/WebPreferences.mm: (-[WebPreferences _setIntegerValue:forKey:]): Use boxing and setObject directly instead of methods from WebNSDictionaryExtras. (-[WebPreferences _setUnsignedIntValue:forKey:]): Ditto. (-[WebPreferences _setFloatValue:forKey:]): Ditto. (-[WebPreferences _setBoolValue:forKey:]): Ditto. (-[WebPreferences _setLongLongValue:forKey:]): Ditto. (-[WebPreferences _setUnsignedLongLongValue:forKey:]): Ditto. * WebView/WebView.mm: (-[WebView _removeFromAllWebViewsSet]): Use bridging cast. (-[WebView _addToAllWebViewsSet]): Ditto. (+[WebView closeAllWebViews]): Use a modern for loop instead of NSEnumerator. (-[WebView _windowVisibilityChanged:]): Moved this into the internal category so it can be called from WebViewData methods. * WebView/WebViewData.mm: Added an import so we can call an internal WebView method, _windowVisibilityChanged:. * WebView/WebViewInternal.h: Declared _windowVisibilityChanged: so it can be called from WebViewData methods. Source/WTF: * WTF.xcodeproj/project.pbxproj: Updated for rename: FoundationSPI.h -> objcSPI.h. * wtf/BlockPtr.h: Added missing include of "StdLibExtras.h". Also re-sorted includes. * wtf/HashFunctions.h: Add function for "__unsafe_unretained id". * wtf/HashTraits.h: Add traits for "__unsafe_unretained id". * wtf/PlatformMac.cmake: Updated for rename: FoundationSPI.h -> objcSPI.h. * wtf/WeakObjCPtr.h: Use mutable instead of const_cast, and write a version that uses __weak explicitly under ARC. Also moved function declarations from here to objcSPI.h. * wtf/cocoa/AutodrainedPool.cpp: Updated include for rename: FoundationSPI.h -> objcSPI.h. * wtf/spi/cocoa/objcSPI.h: Renamed from FoundationSPI.h and added the additional functions used by WeakObjCPtr.h. Also changed to both include the internal header and the function definitions when compiling with USE(APPLE_INTERNAL_SDK), helping us check that function definitions match. Tools: * DumpRenderTree/TestNetscapePlugIn/PluginObject.h: Use const void* for a CFTypeRef instead of void*. * DumpRenderTree/TestNetscapePlugIn/PluginObjectMac.mm: (createCoreAnimationLayer): Use CFBridgingRetain. * DumpRenderTree/mac/AccessibilityUIElementMac.mm: (AccessibilityUIElement::lineTextMarkerRangeForTextMarker): Use bridging casts. (AccessibilityUIElement::textMarkerRangeForElement): Ditto. (AccessibilityUIElement::selectedTextMarkerRange): Ditto. (AccessibilityUIElement::textMarkerRangeLength): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute): Ditto. (AccessibilityUIElement::indexForTextMarker): Ditto. (AccessibilityUIElement::textMarkerForIndex): Ditto. (AccessibilityUIElement::isTextMarkerValid): Ditto. (AccessibilityUIElement::previousTextMarker): Ditto. (AccessibilityUIElement::nextTextMarker): Ditto. (AccessibilityUIElement::stringForTextMarkerRange): Ditto. (createJSStringRef): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRange): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions): Ditto. (AccessibilityUIElement::textMarkerRangeForMarkers): Ditto. (AccessibilityUIElement::startTextMarkerForTextMarkerRange): Ditto. (AccessibilityUIElement::endTextMarkerForTextMarkerRange): Ditto. (AccessibilityUIElement::endTextMarkerForBounds): Ditto. (AccessibilityUIElement::startTextMarkerForBounds): Ditto. (AccessibilityUIElement::textMarkerForPoint): Ditto. (AccessibilityUIElement::accessibilityElementForTextMarker): Ditto. (AccessibilityUIElement::startTextMarker): Ditto. (AccessibilityUIElement::endTextMarker): Ditto. (AccessibilityUIElement::setSelectedVisibleTextRange): Ditto. (AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousWordStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextWordEndTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::paragraphTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousParagraphStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextParagraphEndTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::sentenceTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousSentenceStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextSentenceEndTextMarkerForTextMarker): Ditto. * DumpRenderTree/mac/DumpRenderTree.mm: (resetWebPreferencesToConsistentValues): Use bridging cast. (dumpFramesAsText): Ditto. (dumpBackForwardListForAllWindows): Use a modern for loop instead of CFArray functions to iterate the array. (dump): Use bridging cast. (runTest): Ditto. * DumpRenderTree/mac/DumpRenderTreePasteboard.mm: (+[LocalPasteboard alloc]): Use class_createInstance instead of NSAllocateObject. (toUTI): Return a RetainPtr<CFStringRef>. (-[LocalPasteboard types]): Use the above and bridging casts. (-[LocalPasteboard availableTypeFromArray:]): Ditto. (-[LocalPasteboard setData:forType:]): Ditto. (-[LocalPasteboard dataForType:]): Ditto. (-[LocalPasteboard setPropertyList:forType:]): Use NSPropertyListSerialization instead of CFPropertyList. (-[LocalPasteboard setString:forType:]): Use NSString method instead of CFStringCreateExternalRepresentation. * DumpRenderTree/mac/MockGeolocationProvider.h: Put CFTypeRef in a HashSet instead of an Objective-C object pointer type. * DumpRenderTree/mac/MockGeolocationProvider.mm: (-[MockGeolocationProvider registerWebView:]): Update for above. (-[MockGeolocationProvider unregisterWebView:]): Ditto. (-[MockGeolocationProvider timerFired]): Ditto. * DumpRenderTree/mac/MockWebNotificationProvider.h: Use CFTypeRef in HashMap and HashSet instead of an Objective-C object pointer type. * DumpRenderTree/mac/MockWebNotificationProvider.mm: (-[MockWebNotificationProvider registerWebView:]): Update for above. (-[MockWebNotificationProvider unregisterWebView:]): Ditto. (-[MockWebNotificationProvider showNotification:fromWebView:]): Ditto. (-[MockWebNotificationProvider cancelNotification:]): Ditto. (-[MockWebNotificationProvider simulateWebNotificationClick:]): Ditto. * DumpRenderTree/mac/ObjCPlugin.m: (-[JSObjC retainObject:]): Use CFRetain instead of -[NSObject retain]. * DumpRenderTree/mac/TestRunnerMac.mm: (TestRunner::addDisallowedURL): Use bridging cast. (TestRunner::applicationCacheDiskUsageForOrigin): Ditto. (TestRunner::clearApplicationCacheForOrigin): Ditto. (originsArrayToJS): Ditto. (TestRunner::copyDecodedHostName): Ditto. (TestRunner::copyEncodedHostName): Ditto. (TestRunner::queueLoad): Ditto. (TestRunner::setDomainRelaxationForbiddenForURLScheme): Ditto. (TestRunner::setMockGeolocationPositionUnavailableError): Ditto. (TestRunner::setUserStyleSheetLocation): Ditto. (TestRunner::setValueForUser): Ditto. (TestRunner::overridePreference): Ditto. (TestRunner::execCommand): Ditto. (TestRunner::findString): Ditto. (TestRunner::isCommandEnabled): Ditto. (TestRunner::addOriginAccessWhitelistEntry): Ditto. (TestRunner::removeOriginAccessWhitelistEntry): Ditto. (TestRunner::addUserScript): Ditto. (TestRunner::addUserStyleSheet): Ditto. (TestRunner::evaluateInWebInspector): Ditto. (TestRunner::evaluateScriptInIsolatedWorld): Ditto. (TestRunner::authenticateSession): Ditto. (TestRunner::grantWebNotificationPermission): Ditto. (TestRunner::denyWebNotificationPermission): Ditto. * TestRunnerShared/cocoa/LayoutTestSpellChecker.mm: (-[LayoutTestSpellChecker setResultsFromJSObject:inContext:]): Ditto. * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm: (WTR::AccessibilityUIElement::lineTextMarkerRangeForTextMarker): Use bridging cast. (WTR::AccessibilityUIElement::textMarkerRangeForElement): Ditto. (WTR::AccessibilityUIElement::previousTextMarker): Ditto. (WTR::AccessibilityUIElement::nextTextMarker): Ditto. (WTR::AccessibilityUIElement::textMarkerRangeForMarkers): Ditto. (WTR::AccessibilityUIElement::selectedTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::startTextMarkerForTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::endTextMarkerForTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::endTextMarkerForBounds): Ditto. (WTR::AccessibilityUIElement::startTextMarkerForBounds): Ditto. (WTR::AccessibilityUIElement::textMarkerForPoint): Ditto. (WTR::AccessibilityUIElement::textMarkerForIndex): Ditto. (WTR::AccessibilityUIElement::startTextMarker): Ditto. (WTR::AccessibilityUIElement::endTextMarker): Ditto. (WTR::AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousWordStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextWordEndTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::paragraphTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousParagraphStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextParagraphEndTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::sentenceTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousSentenceStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextSentenceEndTextMarkerForTextMarker): Ditto. * WebKitTestRunner/PlatformMac.cmake: Added WebKitTestRunnerWindow.h and .mm files. * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: Ditto. * WebKitTestRunner/mac/EventSenderProxy.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. * WebKitTestRunner/mac/PlatformWebViewMac.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. Moved WebKitTestRunnerWindow class into a separate file. (WTR::PlatformWebView::keyWindow): Call +[WebKitTestRunnerWindow _WTR_keyWindow] instead of have a second copy of the implementation. * WebKitTestRunner/mac/WebKitTestRunnerEvent.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. Also removed "using namespace". (+[WebKitTestRunnerEvent mouseLocation]): Updated for above. * WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm: (+[LocalPasteboard alloc]): Use class_createInstance instead of NSAllocateObject. (-[LocalPasteboard availableTypeFromArray:]): Use modern for loop. (-[LocalPasteboard setData:forType:]): Reordered method to be a tiny bit more efficient. (-[LocalPasteboard setPropertyList:forType:]): Use NSPropertyListSerialization instead of CFPropertyList. (-[LocalPasteboard setString:forType:]): Use NSString method instead of CFStringCreateExternalRepresentation. * WebKitTestRunner/mac/WebKitTestRunnerWindow.h: Moved declaration of WebKitTestRunnerWindow here so it can be included by files that need to know what the type is and that it inherits from NSWindow. * WebKitTestRunner/mac/WebKitTestRunnerWindow.mm: Added. Moved implementation here. (+[WebKitTestRunnerWindow _WTR_keyWindow]): Use modern for loop instead of the old, messier implementation. Canonical link: https://commits.webkit.org/203508@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234685 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-08-08 02:39:12 +00:00
#endif
WeakObjCPtr& operator=(ValueType *ptr)
{
[Cocoa] More tweaks and refactoring to prepare for ARC https://bugs.webkit.org/show_bug.cgi?id=188245 Reviewed by Dan Bernstein. Source/JavaScriptCore: * API/JSValue.mm: Use __unsafe_unretained. (JSContainerConvertor::convert): Use auto for compatibility with the above. * API/JSWrapperMap.mm: (allocateConstructorForCustomClass): Use CFTypeRef instead of Protocol *. (-[JSWrapperMap initWithGlobalContextRef:]): Use __unsafe_unretained. * heap/Heap.cpp: Updated include for rename: FoundationSPI.h -> objcSPI.h. Source/WebCore: * bridge/objc/objc_instance.mm: Updated include for rename: FoundationSPI.h -> objcSPI.h. * platform/ios/wak/WebCoreThread.mm: Ditto. Source/WebKit: * Platform/cocoa/WKCrashReporter.mm: (WebKit::setCrashLogMessage): Refactor into a separate function for clarity. (WebKit::setCrashReportApplicationSpecificInformation): Use a bridging cast. * Shared/mac/PasteboardTypes.mm: (WebKit::PasteboardTypes::forEditing): Use a bridging cast. * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm: (WebKit::convertToNPNNString): Added. Uses CFStringRef rather than NSString so we can manually manage the autoreleasing. (WebKit::initializeKeyboardEvent): Use convertToNPNNString. (WebKit::NetscapePlugin::sendComplexTextInput): Ditto. * WebProcess/Plugins/PDF/PDFPlugin.mm: Use __unsafe_unretained explicitly for a parent pointer. We could consider moving to __weak after switching to ARC. Source/WebKitLegacy/mac: * Carbon/CarbonUtils.m: Updated include for rename: FoundationSPI.h -> objcSPI.h. * Carbon/CarbonWindowFrame.m: (-[CarbonWindowFrame dealloc]): Deleted. It was empty. * DOM/DOM.mm: (-[DOMElement _imageTIFFRepresentation]): Use a bridging cast. (-[DOMNodeFilter finalize]): Deleted. WebKit no longer supports Objective-C garbage collection so this method isn't useful. * DOM/DOMXPath.mm: (-[DOMNativeXPathNSResolver finalize]): Deleted. WebKit no longer supports Objective-C garbage collection so this method isn't useful. * History/WebHistory.mm: (-[WebHistoryPrivate data]): Allocate an NSData instead of casting from a CFData. * Misc/WebElementDictionary.mm: (addLookupKey): Use a bridging cast. (cacheValueForKey): Ditto. (-[WebElementDictionary _fillCache]): Ditto. (-[WebElementDictionary objectForKey:]): Ditto. * Misc/WebKitNSStringExtras.mm: (-[NSString _web_drawAtPoint:font:textColor:]): Use a bridging cast. (-[NSString _web_widthWithFont:]): Ditto. (-[NSString _webkit_stringByTrimmingWhitespace]): Ditto. * Misc/WebLocalizableStrings.mm: (WebLocalizedString): Use a bridging cast. * Misc/WebNSDataExtras.mm: (-[NSString _web_capitalizeRFC822HeaderFieldName]): Use a bridging cast and use CFBridgingRelease instead of calling autorelease directly. (-[NSData _webkit_parseRFC822HeaderFields]): Use NSString methods instead of a mix of CFString and NSString. Also simplified logic a bit, and cut down on the amount of explicit release and autorelease. * Misc/WebNSDictionaryExtras.h: Deleted unused methods. * Misc/WebNSDictionaryExtras.m: (-[NSDictionary _webkit_intForKey:]): Deleted. (-[NSMutableDictionary _webkit_setInt:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setFloat:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setBool:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setLongLong:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setUnsignedLongLong:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setUnsignedInt:forKey:]): Deleted. * Misc/WebStringTruncator.mm: (fontFromNSFont): Use a bridging cast. * Plugins/Hosted/NetscapePluginHostManager.mm: (WebKit::preferredBundleLocalizationName): Use a bridging cast and CFBridgingRelease. * Plugins/Hosted/NetscapePluginInstanceProxy.mm: (WebKit::NetscapePluginInstanceProxy::cleanup): Use a bridging cast. (WebKit::NetscapePluginInstanceProxy::status): Ditto. (WebKit::NetscapePluginInstanceProxy::loadURL): Ditto. (WebKit::NetscapePluginInstanceProxy::demarshalValueFromArray): Ditto. * Plugins/Hosted/ProxyInstance.mm: (WebKit::ProxyInstance::getPropertyNames): Ditto. * Plugins/WebBasePluginPackage.mm: (-[WebBasePluginPackage _objectForInfoDictionaryKey:]): Ditto. * Plugins/WebNetscapePluginEventHandlerCocoa.mm: (WebNetscapePluginEventHandlerCocoa::platformWindow): Ditto. * Plugins/WebNetscapePluginPackage.mm: (-[WebNetscapePluginPackage _initWithPath:]): Ditto. * Plugins/WebNetscapePluginView.mm: (-[WebNetscapePluginView _postURL:target:len:buf:file:notifyData:sendNotification:allowHeaders:]): Use bridging casts and use RetainPtr insteead of an explicit CFRelease. (-[WebNetscapePluginView status:]): Use a bridging cast. (-[WebNetscapePluginView popUpContextMenu:]): Ditto. * Plugins/WebPluginController.mm: (-[WebPluginController _cancelOutstandingChecks]): Use a bridging cast. * Plugins/WebPluginDatabase.mm: (checkCandidate): Use explicit __strong for out argument types. * Plugins/npapi.mm: (pluginViewForInstance): Use a bridging cast. * Storage/WebDatabaseManager.mm: (-[WebDatabaseManager detailsForDatabase:withOrigin:]): Use modern boxing instead of explicit NSNumber and NSDictionary calls. * WebCoreSupport/WebContextMenuClient.mm: (WebContextMenuClient::speak): Remove an unnecessary copy/autorelease pair. * WebCoreSupport/WebEditorClient.mm: (WebEditorClient::handleKeyboardEvent): Added a missing typecast. (WebEditorClient::handleInputMethodKeydown): Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: (WebFrameNetworkingContext::sourceApplicationAuditData const): Use a bridging cast. * WebCoreSupport/WebSecurityOriginPrivate.h: Forward declare WebSecurityOriginPrivate as a struct rather than an Objective-C class, since that's how it's defined. * WebInspector/WebNodeHighlighter.mm: Added missing includes. * WebView/WebFullScreenController.mm: (-[WebFullScreenController enterFullScreen:]): Use a bridging cast. * WebView/WebHTMLView.mm: (-[WebHTMLView _writeSelectionWithPasteboardTypes:toPasteboard:cachedAttributedString:]): Ditto. (-[WebHTMLView pasteboard:provideDataForType:]): Ditto. * WebView/WebImmediateActionController.mm: (-[WebImmediateActionController performHitTestAtPoint:]): Removed redundant code to go down to the document and then back to the frame. (-[WebImmediateActionController immediateActionRecognizerDidUpdateAnimation:]): Ditto. (-[WebImmediateActionController immediateActionRecognizerDidCancelAnimation:]): Ditto. (-[WebImmediateActionController immediateActionRecognizerDidCompleteAnimation:]): Ditto. * WebView/WebJSPDFDoc.mm: (jsPDFDocInitialize): Removed some unneeded type casting. (jsPDFDocFinalize): Ditto. (jsPDFDocPrint): Use a bridging cast. * WebView/WebPDFView.mm: (_applicationInfoForMIMEType): Use bridging casts. * WebView/WebPreferences.mm: (-[WebPreferences _setIntegerValue:forKey:]): Use boxing and setObject directly instead of methods from WebNSDictionaryExtras. (-[WebPreferences _setUnsignedIntValue:forKey:]): Ditto. (-[WebPreferences _setFloatValue:forKey:]): Ditto. (-[WebPreferences _setBoolValue:forKey:]): Ditto. (-[WebPreferences _setLongLongValue:forKey:]): Ditto. (-[WebPreferences _setUnsignedLongLongValue:forKey:]): Ditto. * WebView/WebView.mm: (-[WebView _removeFromAllWebViewsSet]): Use bridging cast. (-[WebView _addToAllWebViewsSet]): Ditto. (+[WebView closeAllWebViews]): Use a modern for loop instead of NSEnumerator. (-[WebView _windowVisibilityChanged:]): Moved this into the internal category so it can be called from WebViewData methods. * WebView/WebViewData.mm: Added an import so we can call an internal WebView method, _windowVisibilityChanged:. * WebView/WebViewInternal.h: Declared _windowVisibilityChanged: so it can be called from WebViewData methods. Source/WTF: * WTF.xcodeproj/project.pbxproj: Updated for rename: FoundationSPI.h -> objcSPI.h. * wtf/BlockPtr.h: Added missing include of "StdLibExtras.h". Also re-sorted includes. * wtf/HashFunctions.h: Add function for "__unsafe_unretained id". * wtf/HashTraits.h: Add traits for "__unsafe_unretained id". * wtf/PlatformMac.cmake: Updated for rename: FoundationSPI.h -> objcSPI.h. * wtf/WeakObjCPtr.h: Use mutable instead of const_cast, and write a version that uses __weak explicitly under ARC. Also moved function declarations from here to objcSPI.h. * wtf/cocoa/AutodrainedPool.cpp: Updated include for rename: FoundationSPI.h -> objcSPI.h. * wtf/spi/cocoa/objcSPI.h: Renamed from FoundationSPI.h and added the additional functions used by WeakObjCPtr.h. Also changed to both include the internal header and the function definitions when compiling with USE(APPLE_INTERNAL_SDK), helping us check that function definitions match. Tools: * DumpRenderTree/TestNetscapePlugIn/PluginObject.h: Use const void* for a CFTypeRef instead of void*. * DumpRenderTree/TestNetscapePlugIn/PluginObjectMac.mm: (createCoreAnimationLayer): Use CFBridgingRetain. * DumpRenderTree/mac/AccessibilityUIElementMac.mm: (AccessibilityUIElement::lineTextMarkerRangeForTextMarker): Use bridging casts. (AccessibilityUIElement::textMarkerRangeForElement): Ditto. (AccessibilityUIElement::selectedTextMarkerRange): Ditto. (AccessibilityUIElement::textMarkerRangeLength): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute): Ditto. (AccessibilityUIElement::indexForTextMarker): Ditto. (AccessibilityUIElement::textMarkerForIndex): Ditto. (AccessibilityUIElement::isTextMarkerValid): Ditto. (AccessibilityUIElement::previousTextMarker): Ditto. (AccessibilityUIElement::nextTextMarker): Ditto. (AccessibilityUIElement::stringForTextMarkerRange): Ditto. (createJSStringRef): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRange): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions): Ditto. (AccessibilityUIElement::textMarkerRangeForMarkers): Ditto. (AccessibilityUIElement::startTextMarkerForTextMarkerRange): Ditto. (AccessibilityUIElement::endTextMarkerForTextMarkerRange): Ditto. (AccessibilityUIElement::endTextMarkerForBounds): Ditto. (AccessibilityUIElement::startTextMarkerForBounds): Ditto. (AccessibilityUIElement::textMarkerForPoint): Ditto. (AccessibilityUIElement::accessibilityElementForTextMarker): Ditto. (AccessibilityUIElement::startTextMarker): Ditto. (AccessibilityUIElement::endTextMarker): Ditto. (AccessibilityUIElement::setSelectedVisibleTextRange): Ditto. (AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousWordStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextWordEndTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::paragraphTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousParagraphStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextParagraphEndTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::sentenceTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousSentenceStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextSentenceEndTextMarkerForTextMarker): Ditto. * DumpRenderTree/mac/DumpRenderTree.mm: (resetWebPreferencesToConsistentValues): Use bridging cast. (dumpFramesAsText): Ditto. (dumpBackForwardListForAllWindows): Use a modern for loop instead of CFArray functions to iterate the array. (dump): Use bridging cast. (runTest): Ditto. * DumpRenderTree/mac/DumpRenderTreePasteboard.mm: (+[LocalPasteboard alloc]): Use class_createInstance instead of NSAllocateObject. (toUTI): Return a RetainPtr<CFStringRef>. (-[LocalPasteboard types]): Use the above and bridging casts. (-[LocalPasteboard availableTypeFromArray:]): Ditto. (-[LocalPasteboard setData:forType:]): Ditto. (-[LocalPasteboard dataForType:]): Ditto. (-[LocalPasteboard setPropertyList:forType:]): Use NSPropertyListSerialization instead of CFPropertyList. (-[LocalPasteboard setString:forType:]): Use NSString method instead of CFStringCreateExternalRepresentation. * DumpRenderTree/mac/MockGeolocationProvider.h: Put CFTypeRef in a HashSet instead of an Objective-C object pointer type. * DumpRenderTree/mac/MockGeolocationProvider.mm: (-[MockGeolocationProvider registerWebView:]): Update for above. (-[MockGeolocationProvider unregisterWebView:]): Ditto. (-[MockGeolocationProvider timerFired]): Ditto. * DumpRenderTree/mac/MockWebNotificationProvider.h: Use CFTypeRef in HashMap and HashSet instead of an Objective-C object pointer type. * DumpRenderTree/mac/MockWebNotificationProvider.mm: (-[MockWebNotificationProvider registerWebView:]): Update for above. (-[MockWebNotificationProvider unregisterWebView:]): Ditto. (-[MockWebNotificationProvider showNotification:fromWebView:]): Ditto. (-[MockWebNotificationProvider cancelNotification:]): Ditto. (-[MockWebNotificationProvider simulateWebNotificationClick:]): Ditto. * DumpRenderTree/mac/ObjCPlugin.m: (-[JSObjC retainObject:]): Use CFRetain instead of -[NSObject retain]. * DumpRenderTree/mac/TestRunnerMac.mm: (TestRunner::addDisallowedURL): Use bridging cast. (TestRunner::applicationCacheDiskUsageForOrigin): Ditto. (TestRunner::clearApplicationCacheForOrigin): Ditto. (originsArrayToJS): Ditto. (TestRunner::copyDecodedHostName): Ditto. (TestRunner::copyEncodedHostName): Ditto. (TestRunner::queueLoad): Ditto. (TestRunner::setDomainRelaxationForbiddenForURLScheme): Ditto. (TestRunner::setMockGeolocationPositionUnavailableError): Ditto. (TestRunner::setUserStyleSheetLocation): Ditto. (TestRunner::setValueForUser): Ditto. (TestRunner::overridePreference): Ditto. (TestRunner::execCommand): Ditto. (TestRunner::findString): Ditto. (TestRunner::isCommandEnabled): Ditto. (TestRunner::addOriginAccessWhitelistEntry): Ditto. (TestRunner::removeOriginAccessWhitelistEntry): Ditto. (TestRunner::addUserScript): Ditto. (TestRunner::addUserStyleSheet): Ditto. (TestRunner::evaluateInWebInspector): Ditto. (TestRunner::evaluateScriptInIsolatedWorld): Ditto. (TestRunner::authenticateSession): Ditto. (TestRunner::grantWebNotificationPermission): Ditto. (TestRunner::denyWebNotificationPermission): Ditto. * TestRunnerShared/cocoa/LayoutTestSpellChecker.mm: (-[LayoutTestSpellChecker setResultsFromJSObject:inContext:]): Ditto. * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm: (WTR::AccessibilityUIElement::lineTextMarkerRangeForTextMarker): Use bridging cast. (WTR::AccessibilityUIElement::textMarkerRangeForElement): Ditto. (WTR::AccessibilityUIElement::previousTextMarker): Ditto. (WTR::AccessibilityUIElement::nextTextMarker): Ditto. (WTR::AccessibilityUIElement::textMarkerRangeForMarkers): Ditto. (WTR::AccessibilityUIElement::selectedTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::startTextMarkerForTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::endTextMarkerForTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::endTextMarkerForBounds): Ditto. (WTR::AccessibilityUIElement::startTextMarkerForBounds): Ditto. (WTR::AccessibilityUIElement::textMarkerForPoint): Ditto. (WTR::AccessibilityUIElement::textMarkerForIndex): Ditto. (WTR::AccessibilityUIElement::startTextMarker): Ditto. (WTR::AccessibilityUIElement::endTextMarker): Ditto. (WTR::AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousWordStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextWordEndTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::paragraphTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousParagraphStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextParagraphEndTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::sentenceTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousSentenceStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextSentenceEndTextMarkerForTextMarker): Ditto. * WebKitTestRunner/PlatformMac.cmake: Added WebKitTestRunnerWindow.h and .mm files. * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: Ditto. * WebKitTestRunner/mac/EventSenderProxy.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. * WebKitTestRunner/mac/PlatformWebViewMac.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. Moved WebKitTestRunnerWindow class into a separate file. (WTR::PlatformWebView::keyWindow): Call +[WebKitTestRunnerWindow _WTR_keyWindow] instead of have a second copy of the implementation. * WebKitTestRunner/mac/WebKitTestRunnerEvent.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. Also removed "using namespace". (+[WebKitTestRunnerEvent mouseLocation]): Updated for above. * WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm: (+[LocalPasteboard alloc]): Use class_createInstance instead of NSAllocateObject. (-[LocalPasteboard availableTypeFromArray:]): Use modern for loop. (-[LocalPasteboard setData:forType:]): Reordered method to be a tiny bit more efficient. (-[LocalPasteboard setPropertyList:forType:]): Use NSPropertyListSerialization instead of CFPropertyList. (-[LocalPasteboard setString:forType:]): Use NSString method instead of CFStringCreateExternalRepresentation. * WebKitTestRunner/mac/WebKitTestRunnerWindow.h: Moved declaration of WebKitTestRunnerWindow here so it can be included by files that need to know what the type is and that it inherits from NSWindow. * WebKitTestRunner/mac/WebKitTestRunnerWindow.mm: Added. Moved implementation here. (+[WebKitTestRunnerWindow _WTR_keyWindow]): Use modern for loop instead of the old, messier implementation. Canonical link: https://commits.webkit.org/203508@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234685 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-08-08 02:39:12 +00:00
#if __has_feature(objc_arc)
m_weakReference = ptr;
#else
objc_storeWeak(&m_weakReference, ptr);
[Cocoa] More tweaks and refactoring to prepare for ARC https://bugs.webkit.org/show_bug.cgi?id=188245 Reviewed by Dan Bernstein. Source/JavaScriptCore: * API/JSValue.mm: Use __unsafe_unretained. (JSContainerConvertor::convert): Use auto for compatibility with the above. * API/JSWrapperMap.mm: (allocateConstructorForCustomClass): Use CFTypeRef instead of Protocol *. (-[JSWrapperMap initWithGlobalContextRef:]): Use __unsafe_unretained. * heap/Heap.cpp: Updated include for rename: FoundationSPI.h -> objcSPI.h. Source/WebCore: * bridge/objc/objc_instance.mm: Updated include for rename: FoundationSPI.h -> objcSPI.h. * platform/ios/wak/WebCoreThread.mm: Ditto. Source/WebKit: * Platform/cocoa/WKCrashReporter.mm: (WebKit::setCrashLogMessage): Refactor into a separate function for clarity. (WebKit::setCrashReportApplicationSpecificInformation): Use a bridging cast. * Shared/mac/PasteboardTypes.mm: (WebKit::PasteboardTypes::forEditing): Use a bridging cast. * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm: (WebKit::convertToNPNNString): Added. Uses CFStringRef rather than NSString so we can manually manage the autoreleasing. (WebKit::initializeKeyboardEvent): Use convertToNPNNString. (WebKit::NetscapePlugin::sendComplexTextInput): Ditto. * WebProcess/Plugins/PDF/PDFPlugin.mm: Use __unsafe_unretained explicitly for a parent pointer. We could consider moving to __weak after switching to ARC. Source/WebKitLegacy/mac: * Carbon/CarbonUtils.m: Updated include for rename: FoundationSPI.h -> objcSPI.h. * Carbon/CarbonWindowFrame.m: (-[CarbonWindowFrame dealloc]): Deleted. It was empty. * DOM/DOM.mm: (-[DOMElement _imageTIFFRepresentation]): Use a bridging cast. (-[DOMNodeFilter finalize]): Deleted. WebKit no longer supports Objective-C garbage collection so this method isn't useful. * DOM/DOMXPath.mm: (-[DOMNativeXPathNSResolver finalize]): Deleted. WebKit no longer supports Objective-C garbage collection so this method isn't useful. * History/WebHistory.mm: (-[WebHistoryPrivate data]): Allocate an NSData instead of casting from a CFData. * Misc/WebElementDictionary.mm: (addLookupKey): Use a bridging cast. (cacheValueForKey): Ditto. (-[WebElementDictionary _fillCache]): Ditto. (-[WebElementDictionary objectForKey:]): Ditto. * Misc/WebKitNSStringExtras.mm: (-[NSString _web_drawAtPoint:font:textColor:]): Use a bridging cast. (-[NSString _web_widthWithFont:]): Ditto. (-[NSString _webkit_stringByTrimmingWhitespace]): Ditto. * Misc/WebLocalizableStrings.mm: (WebLocalizedString): Use a bridging cast. * Misc/WebNSDataExtras.mm: (-[NSString _web_capitalizeRFC822HeaderFieldName]): Use a bridging cast and use CFBridgingRelease instead of calling autorelease directly. (-[NSData _webkit_parseRFC822HeaderFields]): Use NSString methods instead of a mix of CFString and NSString. Also simplified logic a bit, and cut down on the amount of explicit release and autorelease. * Misc/WebNSDictionaryExtras.h: Deleted unused methods. * Misc/WebNSDictionaryExtras.m: (-[NSDictionary _webkit_intForKey:]): Deleted. (-[NSMutableDictionary _webkit_setInt:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setFloat:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setBool:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setLongLong:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setUnsignedLongLong:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setUnsignedInt:forKey:]): Deleted. * Misc/WebStringTruncator.mm: (fontFromNSFont): Use a bridging cast. * Plugins/Hosted/NetscapePluginHostManager.mm: (WebKit::preferredBundleLocalizationName): Use a bridging cast and CFBridgingRelease. * Plugins/Hosted/NetscapePluginInstanceProxy.mm: (WebKit::NetscapePluginInstanceProxy::cleanup): Use a bridging cast. (WebKit::NetscapePluginInstanceProxy::status): Ditto. (WebKit::NetscapePluginInstanceProxy::loadURL): Ditto. (WebKit::NetscapePluginInstanceProxy::demarshalValueFromArray): Ditto. * Plugins/Hosted/ProxyInstance.mm: (WebKit::ProxyInstance::getPropertyNames): Ditto. * Plugins/WebBasePluginPackage.mm: (-[WebBasePluginPackage _objectForInfoDictionaryKey:]): Ditto. * Plugins/WebNetscapePluginEventHandlerCocoa.mm: (WebNetscapePluginEventHandlerCocoa::platformWindow): Ditto. * Plugins/WebNetscapePluginPackage.mm: (-[WebNetscapePluginPackage _initWithPath:]): Ditto. * Plugins/WebNetscapePluginView.mm: (-[WebNetscapePluginView _postURL:target:len:buf:file:notifyData:sendNotification:allowHeaders:]): Use bridging casts and use RetainPtr insteead of an explicit CFRelease. (-[WebNetscapePluginView status:]): Use a bridging cast. (-[WebNetscapePluginView popUpContextMenu:]): Ditto. * Plugins/WebPluginController.mm: (-[WebPluginController _cancelOutstandingChecks]): Use a bridging cast. * Plugins/WebPluginDatabase.mm: (checkCandidate): Use explicit __strong for out argument types. * Plugins/npapi.mm: (pluginViewForInstance): Use a bridging cast. * Storage/WebDatabaseManager.mm: (-[WebDatabaseManager detailsForDatabase:withOrigin:]): Use modern boxing instead of explicit NSNumber and NSDictionary calls. * WebCoreSupport/WebContextMenuClient.mm: (WebContextMenuClient::speak): Remove an unnecessary copy/autorelease pair. * WebCoreSupport/WebEditorClient.mm: (WebEditorClient::handleKeyboardEvent): Added a missing typecast. (WebEditorClient::handleInputMethodKeydown): Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: (WebFrameNetworkingContext::sourceApplicationAuditData const): Use a bridging cast. * WebCoreSupport/WebSecurityOriginPrivate.h: Forward declare WebSecurityOriginPrivate as a struct rather than an Objective-C class, since that's how it's defined. * WebInspector/WebNodeHighlighter.mm: Added missing includes. * WebView/WebFullScreenController.mm: (-[WebFullScreenController enterFullScreen:]): Use a bridging cast. * WebView/WebHTMLView.mm: (-[WebHTMLView _writeSelectionWithPasteboardTypes:toPasteboard:cachedAttributedString:]): Ditto. (-[WebHTMLView pasteboard:provideDataForType:]): Ditto. * WebView/WebImmediateActionController.mm: (-[WebImmediateActionController performHitTestAtPoint:]): Removed redundant code to go down to the document and then back to the frame. (-[WebImmediateActionController immediateActionRecognizerDidUpdateAnimation:]): Ditto. (-[WebImmediateActionController immediateActionRecognizerDidCancelAnimation:]): Ditto. (-[WebImmediateActionController immediateActionRecognizerDidCompleteAnimation:]): Ditto. * WebView/WebJSPDFDoc.mm: (jsPDFDocInitialize): Removed some unneeded type casting. (jsPDFDocFinalize): Ditto. (jsPDFDocPrint): Use a bridging cast. * WebView/WebPDFView.mm: (_applicationInfoForMIMEType): Use bridging casts. * WebView/WebPreferences.mm: (-[WebPreferences _setIntegerValue:forKey:]): Use boxing and setObject directly instead of methods from WebNSDictionaryExtras. (-[WebPreferences _setUnsignedIntValue:forKey:]): Ditto. (-[WebPreferences _setFloatValue:forKey:]): Ditto. (-[WebPreferences _setBoolValue:forKey:]): Ditto. (-[WebPreferences _setLongLongValue:forKey:]): Ditto. (-[WebPreferences _setUnsignedLongLongValue:forKey:]): Ditto. * WebView/WebView.mm: (-[WebView _removeFromAllWebViewsSet]): Use bridging cast. (-[WebView _addToAllWebViewsSet]): Ditto. (+[WebView closeAllWebViews]): Use a modern for loop instead of NSEnumerator. (-[WebView _windowVisibilityChanged:]): Moved this into the internal category so it can be called from WebViewData methods. * WebView/WebViewData.mm: Added an import so we can call an internal WebView method, _windowVisibilityChanged:. * WebView/WebViewInternal.h: Declared _windowVisibilityChanged: so it can be called from WebViewData methods. Source/WTF: * WTF.xcodeproj/project.pbxproj: Updated for rename: FoundationSPI.h -> objcSPI.h. * wtf/BlockPtr.h: Added missing include of "StdLibExtras.h". Also re-sorted includes. * wtf/HashFunctions.h: Add function for "__unsafe_unretained id". * wtf/HashTraits.h: Add traits for "__unsafe_unretained id". * wtf/PlatformMac.cmake: Updated for rename: FoundationSPI.h -> objcSPI.h. * wtf/WeakObjCPtr.h: Use mutable instead of const_cast, and write a version that uses __weak explicitly under ARC. Also moved function declarations from here to objcSPI.h. * wtf/cocoa/AutodrainedPool.cpp: Updated include for rename: FoundationSPI.h -> objcSPI.h. * wtf/spi/cocoa/objcSPI.h: Renamed from FoundationSPI.h and added the additional functions used by WeakObjCPtr.h. Also changed to both include the internal header and the function definitions when compiling with USE(APPLE_INTERNAL_SDK), helping us check that function definitions match. Tools: * DumpRenderTree/TestNetscapePlugIn/PluginObject.h: Use const void* for a CFTypeRef instead of void*. * DumpRenderTree/TestNetscapePlugIn/PluginObjectMac.mm: (createCoreAnimationLayer): Use CFBridgingRetain. * DumpRenderTree/mac/AccessibilityUIElementMac.mm: (AccessibilityUIElement::lineTextMarkerRangeForTextMarker): Use bridging casts. (AccessibilityUIElement::textMarkerRangeForElement): Ditto. (AccessibilityUIElement::selectedTextMarkerRange): Ditto. (AccessibilityUIElement::textMarkerRangeLength): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute): Ditto. (AccessibilityUIElement::indexForTextMarker): Ditto. (AccessibilityUIElement::textMarkerForIndex): Ditto. (AccessibilityUIElement::isTextMarkerValid): Ditto. (AccessibilityUIElement::previousTextMarker): Ditto. (AccessibilityUIElement::nextTextMarker): Ditto. (AccessibilityUIElement::stringForTextMarkerRange): Ditto. (createJSStringRef): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRange): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions): Ditto. (AccessibilityUIElement::textMarkerRangeForMarkers): Ditto. (AccessibilityUIElement::startTextMarkerForTextMarkerRange): Ditto. (AccessibilityUIElement::endTextMarkerForTextMarkerRange): Ditto. (AccessibilityUIElement::endTextMarkerForBounds): Ditto. (AccessibilityUIElement::startTextMarkerForBounds): Ditto. (AccessibilityUIElement::textMarkerForPoint): Ditto. (AccessibilityUIElement::accessibilityElementForTextMarker): Ditto. (AccessibilityUIElement::startTextMarker): Ditto. (AccessibilityUIElement::endTextMarker): Ditto. (AccessibilityUIElement::setSelectedVisibleTextRange): Ditto. (AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousWordStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextWordEndTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::paragraphTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousParagraphStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextParagraphEndTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::sentenceTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousSentenceStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextSentenceEndTextMarkerForTextMarker): Ditto. * DumpRenderTree/mac/DumpRenderTree.mm: (resetWebPreferencesToConsistentValues): Use bridging cast. (dumpFramesAsText): Ditto. (dumpBackForwardListForAllWindows): Use a modern for loop instead of CFArray functions to iterate the array. (dump): Use bridging cast. (runTest): Ditto. * DumpRenderTree/mac/DumpRenderTreePasteboard.mm: (+[LocalPasteboard alloc]): Use class_createInstance instead of NSAllocateObject. (toUTI): Return a RetainPtr<CFStringRef>. (-[LocalPasteboard types]): Use the above and bridging casts. (-[LocalPasteboard availableTypeFromArray:]): Ditto. (-[LocalPasteboard setData:forType:]): Ditto. (-[LocalPasteboard dataForType:]): Ditto. (-[LocalPasteboard setPropertyList:forType:]): Use NSPropertyListSerialization instead of CFPropertyList. (-[LocalPasteboard setString:forType:]): Use NSString method instead of CFStringCreateExternalRepresentation. * DumpRenderTree/mac/MockGeolocationProvider.h: Put CFTypeRef in a HashSet instead of an Objective-C object pointer type. * DumpRenderTree/mac/MockGeolocationProvider.mm: (-[MockGeolocationProvider registerWebView:]): Update for above. (-[MockGeolocationProvider unregisterWebView:]): Ditto. (-[MockGeolocationProvider timerFired]): Ditto. * DumpRenderTree/mac/MockWebNotificationProvider.h: Use CFTypeRef in HashMap and HashSet instead of an Objective-C object pointer type. * DumpRenderTree/mac/MockWebNotificationProvider.mm: (-[MockWebNotificationProvider registerWebView:]): Update for above. (-[MockWebNotificationProvider unregisterWebView:]): Ditto. (-[MockWebNotificationProvider showNotification:fromWebView:]): Ditto. (-[MockWebNotificationProvider cancelNotification:]): Ditto. (-[MockWebNotificationProvider simulateWebNotificationClick:]): Ditto. * DumpRenderTree/mac/ObjCPlugin.m: (-[JSObjC retainObject:]): Use CFRetain instead of -[NSObject retain]. * DumpRenderTree/mac/TestRunnerMac.mm: (TestRunner::addDisallowedURL): Use bridging cast. (TestRunner::applicationCacheDiskUsageForOrigin): Ditto. (TestRunner::clearApplicationCacheForOrigin): Ditto. (originsArrayToJS): Ditto. (TestRunner::copyDecodedHostName): Ditto. (TestRunner::copyEncodedHostName): Ditto. (TestRunner::queueLoad): Ditto. (TestRunner::setDomainRelaxationForbiddenForURLScheme): Ditto. (TestRunner::setMockGeolocationPositionUnavailableError): Ditto. (TestRunner::setUserStyleSheetLocation): Ditto. (TestRunner::setValueForUser): Ditto. (TestRunner::overridePreference): Ditto. (TestRunner::execCommand): Ditto. (TestRunner::findString): Ditto. (TestRunner::isCommandEnabled): Ditto. (TestRunner::addOriginAccessWhitelistEntry): Ditto. (TestRunner::removeOriginAccessWhitelistEntry): Ditto. (TestRunner::addUserScript): Ditto. (TestRunner::addUserStyleSheet): Ditto. (TestRunner::evaluateInWebInspector): Ditto. (TestRunner::evaluateScriptInIsolatedWorld): Ditto. (TestRunner::authenticateSession): Ditto. (TestRunner::grantWebNotificationPermission): Ditto. (TestRunner::denyWebNotificationPermission): Ditto. * TestRunnerShared/cocoa/LayoutTestSpellChecker.mm: (-[LayoutTestSpellChecker setResultsFromJSObject:inContext:]): Ditto. * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm: (WTR::AccessibilityUIElement::lineTextMarkerRangeForTextMarker): Use bridging cast. (WTR::AccessibilityUIElement::textMarkerRangeForElement): Ditto. (WTR::AccessibilityUIElement::previousTextMarker): Ditto. (WTR::AccessibilityUIElement::nextTextMarker): Ditto. (WTR::AccessibilityUIElement::textMarkerRangeForMarkers): Ditto. (WTR::AccessibilityUIElement::selectedTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::startTextMarkerForTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::endTextMarkerForTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::endTextMarkerForBounds): Ditto. (WTR::AccessibilityUIElement::startTextMarkerForBounds): Ditto. (WTR::AccessibilityUIElement::textMarkerForPoint): Ditto. (WTR::AccessibilityUIElement::textMarkerForIndex): Ditto. (WTR::AccessibilityUIElement::startTextMarker): Ditto. (WTR::AccessibilityUIElement::endTextMarker): Ditto. (WTR::AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousWordStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextWordEndTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::paragraphTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousParagraphStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextParagraphEndTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::sentenceTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousSentenceStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextSentenceEndTextMarkerForTextMarker): Ditto. * WebKitTestRunner/PlatformMac.cmake: Added WebKitTestRunnerWindow.h and .mm files. * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: Ditto. * WebKitTestRunner/mac/EventSenderProxy.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. * WebKitTestRunner/mac/PlatformWebViewMac.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. Moved WebKitTestRunnerWindow class into a separate file. (WTR::PlatformWebView::keyWindow): Call +[WebKitTestRunnerWindow _WTR_keyWindow] instead of have a second copy of the implementation. * WebKitTestRunner/mac/WebKitTestRunnerEvent.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. Also removed "using namespace". (+[WebKitTestRunnerEvent mouseLocation]): Updated for above. * WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm: (+[LocalPasteboard alloc]): Use class_createInstance instead of NSAllocateObject. (-[LocalPasteboard availableTypeFromArray:]): Use modern for loop. (-[LocalPasteboard setData:forType:]): Reordered method to be a tiny bit more efficient. (-[LocalPasteboard setPropertyList:forType:]): Use NSPropertyListSerialization instead of CFPropertyList. (-[LocalPasteboard setString:forType:]): Use NSString method instead of CFStringCreateExternalRepresentation. * WebKitTestRunner/mac/WebKitTestRunnerWindow.h: Moved declaration of WebKitTestRunnerWindow here so it can be included by files that need to know what the type is and that it inherits from NSWindow. * WebKitTestRunner/mac/WebKitTestRunnerWindow.mm: Added. Moved implementation here. (+[WebKitTestRunnerWindow _WTR_keyWindow]): Use modern for loop instead of the old, messier implementation. Canonical link: https://commits.webkit.org/203508@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234685 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-08-08 02:39:12 +00:00
#endif
return *this;
}
bool operator!() const
{
return !get();
}
RetainPtr<ValueType> get() const;
ValueType *getAutoreleased() const
{
[Cocoa] More tweaks and refactoring to prepare for ARC https://bugs.webkit.org/show_bug.cgi?id=188245 Reviewed by Dan Bernstein. Source/JavaScriptCore: * API/JSValue.mm: Use __unsafe_unretained. (JSContainerConvertor::convert): Use auto for compatibility with the above. * API/JSWrapperMap.mm: (allocateConstructorForCustomClass): Use CFTypeRef instead of Protocol *. (-[JSWrapperMap initWithGlobalContextRef:]): Use __unsafe_unretained. * heap/Heap.cpp: Updated include for rename: FoundationSPI.h -> objcSPI.h. Source/WebCore: * bridge/objc/objc_instance.mm: Updated include for rename: FoundationSPI.h -> objcSPI.h. * platform/ios/wak/WebCoreThread.mm: Ditto. Source/WebKit: * Platform/cocoa/WKCrashReporter.mm: (WebKit::setCrashLogMessage): Refactor into a separate function for clarity. (WebKit::setCrashReportApplicationSpecificInformation): Use a bridging cast. * Shared/mac/PasteboardTypes.mm: (WebKit::PasteboardTypes::forEditing): Use a bridging cast. * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm: (WebKit::convertToNPNNString): Added. Uses CFStringRef rather than NSString so we can manually manage the autoreleasing. (WebKit::initializeKeyboardEvent): Use convertToNPNNString. (WebKit::NetscapePlugin::sendComplexTextInput): Ditto. * WebProcess/Plugins/PDF/PDFPlugin.mm: Use __unsafe_unretained explicitly for a parent pointer. We could consider moving to __weak after switching to ARC. Source/WebKitLegacy/mac: * Carbon/CarbonUtils.m: Updated include for rename: FoundationSPI.h -> objcSPI.h. * Carbon/CarbonWindowFrame.m: (-[CarbonWindowFrame dealloc]): Deleted. It was empty. * DOM/DOM.mm: (-[DOMElement _imageTIFFRepresentation]): Use a bridging cast. (-[DOMNodeFilter finalize]): Deleted. WebKit no longer supports Objective-C garbage collection so this method isn't useful. * DOM/DOMXPath.mm: (-[DOMNativeXPathNSResolver finalize]): Deleted. WebKit no longer supports Objective-C garbage collection so this method isn't useful. * History/WebHistory.mm: (-[WebHistoryPrivate data]): Allocate an NSData instead of casting from a CFData. * Misc/WebElementDictionary.mm: (addLookupKey): Use a bridging cast. (cacheValueForKey): Ditto. (-[WebElementDictionary _fillCache]): Ditto. (-[WebElementDictionary objectForKey:]): Ditto. * Misc/WebKitNSStringExtras.mm: (-[NSString _web_drawAtPoint:font:textColor:]): Use a bridging cast. (-[NSString _web_widthWithFont:]): Ditto. (-[NSString _webkit_stringByTrimmingWhitespace]): Ditto. * Misc/WebLocalizableStrings.mm: (WebLocalizedString): Use a bridging cast. * Misc/WebNSDataExtras.mm: (-[NSString _web_capitalizeRFC822HeaderFieldName]): Use a bridging cast and use CFBridgingRelease instead of calling autorelease directly. (-[NSData _webkit_parseRFC822HeaderFields]): Use NSString methods instead of a mix of CFString and NSString. Also simplified logic a bit, and cut down on the amount of explicit release and autorelease. * Misc/WebNSDictionaryExtras.h: Deleted unused methods. * Misc/WebNSDictionaryExtras.m: (-[NSDictionary _webkit_intForKey:]): Deleted. (-[NSMutableDictionary _webkit_setInt:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setFloat:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setBool:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setLongLong:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setUnsignedLongLong:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setUnsignedInt:forKey:]): Deleted. * Misc/WebStringTruncator.mm: (fontFromNSFont): Use a bridging cast. * Plugins/Hosted/NetscapePluginHostManager.mm: (WebKit::preferredBundleLocalizationName): Use a bridging cast and CFBridgingRelease. * Plugins/Hosted/NetscapePluginInstanceProxy.mm: (WebKit::NetscapePluginInstanceProxy::cleanup): Use a bridging cast. (WebKit::NetscapePluginInstanceProxy::status): Ditto. (WebKit::NetscapePluginInstanceProxy::loadURL): Ditto. (WebKit::NetscapePluginInstanceProxy::demarshalValueFromArray): Ditto. * Plugins/Hosted/ProxyInstance.mm: (WebKit::ProxyInstance::getPropertyNames): Ditto. * Plugins/WebBasePluginPackage.mm: (-[WebBasePluginPackage _objectForInfoDictionaryKey:]): Ditto. * Plugins/WebNetscapePluginEventHandlerCocoa.mm: (WebNetscapePluginEventHandlerCocoa::platformWindow): Ditto. * Plugins/WebNetscapePluginPackage.mm: (-[WebNetscapePluginPackage _initWithPath:]): Ditto. * Plugins/WebNetscapePluginView.mm: (-[WebNetscapePluginView _postURL:target:len:buf:file:notifyData:sendNotification:allowHeaders:]): Use bridging casts and use RetainPtr insteead of an explicit CFRelease. (-[WebNetscapePluginView status:]): Use a bridging cast. (-[WebNetscapePluginView popUpContextMenu:]): Ditto. * Plugins/WebPluginController.mm: (-[WebPluginController _cancelOutstandingChecks]): Use a bridging cast. * Plugins/WebPluginDatabase.mm: (checkCandidate): Use explicit __strong for out argument types. * Plugins/npapi.mm: (pluginViewForInstance): Use a bridging cast. * Storage/WebDatabaseManager.mm: (-[WebDatabaseManager detailsForDatabase:withOrigin:]): Use modern boxing instead of explicit NSNumber and NSDictionary calls. * WebCoreSupport/WebContextMenuClient.mm: (WebContextMenuClient::speak): Remove an unnecessary copy/autorelease pair. * WebCoreSupport/WebEditorClient.mm: (WebEditorClient::handleKeyboardEvent): Added a missing typecast. (WebEditorClient::handleInputMethodKeydown): Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: (WebFrameNetworkingContext::sourceApplicationAuditData const): Use a bridging cast. * WebCoreSupport/WebSecurityOriginPrivate.h: Forward declare WebSecurityOriginPrivate as a struct rather than an Objective-C class, since that's how it's defined. * WebInspector/WebNodeHighlighter.mm: Added missing includes. * WebView/WebFullScreenController.mm: (-[WebFullScreenController enterFullScreen:]): Use a bridging cast. * WebView/WebHTMLView.mm: (-[WebHTMLView _writeSelectionWithPasteboardTypes:toPasteboard:cachedAttributedString:]): Ditto. (-[WebHTMLView pasteboard:provideDataForType:]): Ditto. * WebView/WebImmediateActionController.mm: (-[WebImmediateActionController performHitTestAtPoint:]): Removed redundant code to go down to the document and then back to the frame. (-[WebImmediateActionController immediateActionRecognizerDidUpdateAnimation:]): Ditto. (-[WebImmediateActionController immediateActionRecognizerDidCancelAnimation:]): Ditto. (-[WebImmediateActionController immediateActionRecognizerDidCompleteAnimation:]): Ditto. * WebView/WebJSPDFDoc.mm: (jsPDFDocInitialize): Removed some unneeded type casting. (jsPDFDocFinalize): Ditto. (jsPDFDocPrint): Use a bridging cast. * WebView/WebPDFView.mm: (_applicationInfoForMIMEType): Use bridging casts. * WebView/WebPreferences.mm: (-[WebPreferences _setIntegerValue:forKey:]): Use boxing and setObject directly instead of methods from WebNSDictionaryExtras. (-[WebPreferences _setUnsignedIntValue:forKey:]): Ditto. (-[WebPreferences _setFloatValue:forKey:]): Ditto. (-[WebPreferences _setBoolValue:forKey:]): Ditto. (-[WebPreferences _setLongLongValue:forKey:]): Ditto. (-[WebPreferences _setUnsignedLongLongValue:forKey:]): Ditto. * WebView/WebView.mm: (-[WebView _removeFromAllWebViewsSet]): Use bridging cast. (-[WebView _addToAllWebViewsSet]): Ditto. (+[WebView closeAllWebViews]): Use a modern for loop instead of NSEnumerator. (-[WebView _windowVisibilityChanged:]): Moved this into the internal category so it can be called from WebViewData methods. * WebView/WebViewData.mm: Added an import so we can call an internal WebView method, _windowVisibilityChanged:. * WebView/WebViewInternal.h: Declared _windowVisibilityChanged: so it can be called from WebViewData methods. Source/WTF: * WTF.xcodeproj/project.pbxproj: Updated for rename: FoundationSPI.h -> objcSPI.h. * wtf/BlockPtr.h: Added missing include of "StdLibExtras.h". Also re-sorted includes. * wtf/HashFunctions.h: Add function for "__unsafe_unretained id". * wtf/HashTraits.h: Add traits for "__unsafe_unretained id". * wtf/PlatformMac.cmake: Updated for rename: FoundationSPI.h -> objcSPI.h. * wtf/WeakObjCPtr.h: Use mutable instead of const_cast, and write a version that uses __weak explicitly under ARC. Also moved function declarations from here to objcSPI.h. * wtf/cocoa/AutodrainedPool.cpp: Updated include for rename: FoundationSPI.h -> objcSPI.h. * wtf/spi/cocoa/objcSPI.h: Renamed from FoundationSPI.h and added the additional functions used by WeakObjCPtr.h. Also changed to both include the internal header and the function definitions when compiling with USE(APPLE_INTERNAL_SDK), helping us check that function definitions match. Tools: * DumpRenderTree/TestNetscapePlugIn/PluginObject.h: Use const void* for a CFTypeRef instead of void*. * DumpRenderTree/TestNetscapePlugIn/PluginObjectMac.mm: (createCoreAnimationLayer): Use CFBridgingRetain. * DumpRenderTree/mac/AccessibilityUIElementMac.mm: (AccessibilityUIElement::lineTextMarkerRangeForTextMarker): Use bridging casts. (AccessibilityUIElement::textMarkerRangeForElement): Ditto. (AccessibilityUIElement::selectedTextMarkerRange): Ditto. (AccessibilityUIElement::textMarkerRangeLength): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute): Ditto. (AccessibilityUIElement::indexForTextMarker): Ditto. (AccessibilityUIElement::textMarkerForIndex): Ditto. (AccessibilityUIElement::isTextMarkerValid): Ditto. (AccessibilityUIElement::previousTextMarker): Ditto. (AccessibilityUIElement::nextTextMarker): Ditto. (AccessibilityUIElement::stringForTextMarkerRange): Ditto. (createJSStringRef): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRange): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions): Ditto. (AccessibilityUIElement::textMarkerRangeForMarkers): Ditto. (AccessibilityUIElement::startTextMarkerForTextMarkerRange): Ditto. (AccessibilityUIElement::endTextMarkerForTextMarkerRange): Ditto. (AccessibilityUIElement::endTextMarkerForBounds): Ditto. (AccessibilityUIElement::startTextMarkerForBounds): Ditto. (AccessibilityUIElement::textMarkerForPoint): Ditto. (AccessibilityUIElement::accessibilityElementForTextMarker): Ditto. (AccessibilityUIElement::startTextMarker): Ditto. (AccessibilityUIElement::endTextMarker): Ditto. (AccessibilityUIElement::setSelectedVisibleTextRange): Ditto. (AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousWordStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextWordEndTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::paragraphTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousParagraphStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextParagraphEndTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::sentenceTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousSentenceStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextSentenceEndTextMarkerForTextMarker): Ditto. * DumpRenderTree/mac/DumpRenderTree.mm: (resetWebPreferencesToConsistentValues): Use bridging cast. (dumpFramesAsText): Ditto. (dumpBackForwardListForAllWindows): Use a modern for loop instead of CFArray functions to iterate the array. (dump): Use bridging cast. (runTest): Ditto. * DumpRenderTree/mac/DumpRenderTreePasteboard.mm: (+[LocalPasteboard alloc]): Use class_createInstance instead of NSAllocateObject. (toUTI): Return a RetainPtr<CFStringRef>. (-[LocalPasteboard types]): Use the above and bridging casts. (-[LocalPasteboard availableTypeFromArray:]): Ditto. (-[LocalPasteboard setData:forType:]): Ditto. (-[LocalPasteboard dataForType:]): Ditto. (-[LocalPasteboard setPropertyList:forType:]): Use NSPropertyListSerialization instead of CFPropertyList. (-[LocalPasteboard setString:forType:]): Use NSString method instead of CFStringCreateExternalRepresentation. * DumpRenderTree/mac/MockGeolocationProvider.h: Put CFTypeRef in a HashSet instead of an Objective-C object pointer type. * DumpRenderTree/mac/MockGeolocationProvider.mm: (-[MockGeolocationProvider registerWebView:]): Update for above. (-[MockGeolocationProvider unregisterWebView:]): Ditto. (-[MockGeolocationProvider timerFired]): Ditto. * DumpRenderTree/mac/MockWebNotificationProvider.h: Use CFTypeRef in HashMap and HashSet instead of an Objective-C object pointer type. * DumpRenderTree/mac/MockWebNotificationProvider.mm: (-[MockWebNotificationProvider registerWebView:]): Update for above. (-[MockWebNotificationProvider unregisterWebView:]): Ditto. (-[MockWebNotificationProvider showNotification:fromWebView:]): Ditto. (-[MockWebNotificationProvider cancelNotification:]): Ditto. (-[MockWebNotificationProvider simulateWebNotificationClick:]): Ditto. * DumpRenderTree/mac/ObjCPlugin.m: (-[JSObjC retainObject:]): Use CFRetain instead of -[NSObject retain]. * DumpRenderTree/mac/TestRunnerMac.mm: (TestRunner::addDisallowedURL): Use bridging cast. (TestRunner::applicationCacheDiskUsageForOrigin): Ditto. (TestRunner::clearApplicationCacheForOrigin): Ditto. (originsArrayToJS): Ditto. (TestRunner::copyDecodedHostName): Ditto. (TestRunner::copyEncodedHostName): Ditto. (TestRunner::queueLoad): Ditto. (TestRunner::setDomainRelaxationForbiddenForURLScheme): Ditto. (TestRunner::setMockGeolocationPositionUnavailableError): Ditto. (TestRunner::setUserStyleSheetLocation): Ditto. (TestRunner::setValueForUser): Ditto. (TestRunner::overridePreference): Ditto. (TestRunner::execCommand): Ditto. (TestRunner::findString): Ditto. (TestRunner::isCommandEnabled): Ditto. (TestRunner::addOriginAccessWhitelistEntry): Ditto. (TestRunner::removeOriginAccessWhitelistEntry): Ditto. (TestRunner::addUserScript): Ditto. (TestRunner::addUserStyleSheet): Ditto. (TestRunner::evaluateInWebInspector): Ditto. (TestRunner::evaluateScriptInIsolatedWorld): Ditto. (TestRunner::authenticateSession): Ditto. (TestRunner::grantWebNotificationPermission): Ditto. (TestRunner::denyWebNotificationPermission): Ditto. * TestRunnerShared/cocoa/LayoutTestSpellChecker.mm: (-[LayoutTestSpellChecker setResultsFromJSObject:inContext:]): Ditto. * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm: (WTR::AccessibilityUIElement::lineTextMarkerRangeForTextMarker): Use bridging cast. (WTR::AccessibilityUIElement::textMarkerRangeForElement): Ditto. (WTR::AccessibilityUIElement::previousTextMarker): Ditto. (WTR::AccessibilityUIElement::nextTextMarker): Ditto. (WTR::AccessibilityUIElement::textMarkerRangeForMarkers): Ditto. (WTR::AccessibilityUIElement::selectedTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::startTextMarkerForTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::endTextMarkerForTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::endTextMarkerForBounds): Ditto. (WTR::AccessibilityUIElement::startTextMarkerForBounds): Ditto. (WTR::AccessibilityUIElement::textMarkerForPoint): Ditto. (WTR::AccessibilityUIElement::textMarkerForIndex): Ditto. (WTR::AccessibilityUIElement::startTextMarker): Ditto. (WTR::AccessibilityUIElement::endTextMarker): Ditto. (WTR::AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousWordStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextWordEndTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::paragraphTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousParagraphStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextParagraphEndTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::sentenceTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousSentenceStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextSentenceEndTextMarkerForTextMarker): Ditto. * WebKitTestRunner/PlatformMac.cmake: Added WebKitTestRunnerWindow.h and .mm files. * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: Ditto. * WebKitTestRunner/mac/EventSenderProxy.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. * WebKitTestRunner/mac/PlatformWebViewMac.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. Moved WebKitTestRunnerWindow class into a separate file. (WTR::PlatformWebView::keyWindow): Call +[WebKitTestRunnerWindow _WTR_keyWindow] instead of have a second copy of the implementation. * WebKitTestRunner/mac/WebKitTestRunnerEvent.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. Also removed "using namespace". (+[WebKitTestRunnerEvent mouseLocation]): Updated for above. * WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm: (+[LocalPasteboard alloc]): Use class_createInstance instead of NSAllocateObject. (-[LocalPasteboard availableTypeFromArray:]): Use modern for loop. (-[LocalPasteboard setData:forType:]): Reordered method to be a tiny bit more efficient. (-[LocalPasteboard setPropertyList:forType:]): Use NSPropertyListSerialization instead of CFPropertyList. (-[LocalPasteboard setString:forType:]): Use NSString method instead of CFStringCreateExternalRepresentation. * WebKitTestRunner/mac/WebKitTestRunnerWindow.h: Moved declaration of WebKitTestRunnerWindow here so it can be included by files that need to know what the type is and that it inherits from NSWindow. * WebKitTestRunner/mac/WebKitTestRunnerWindow.mm: Added. Moved implementation here. (+[WebKitTestRunnerWindow _WTR_keyWindow]): Use modern for loop instead of the old, messier implementation. Canonical link: https://commits.webkit.org/203508@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234685 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-08-08 02:39:12 +00:00
#if __has_feature(objc_arc)
return static_cast<ValueType *>(m_weakReference);
#else
return static_cast<ValueType *>(objc_loadWeak(&m_weakReference));
#endif
}
[Mac WK2] WebViewImpl should hold a weak pointer to its WKWebView or WKView https://bugs.webkit.org/show_bug.cgi?id=175302 <rdar://problem/33762116> Reviewed by Tim Horton. Source/WebKit: Refactor WebViewImpl's m_view from a raw pointer to a WeakObjCPtr to ensure that it is automatically cleared out when the WKWebView or WKView are destroyed, and also changes several places where we implicitly block capture the WebViewImpl to only capture a WeakPtr to the WebViewImpl. Most of the changes here are boilerplate adjustments for how m_view is now a weak pointer. Test: WKWebViewMacEditingTests.DoNotCrashWhenInterpretingKeyEventWhileDeallocatingView. * Shared/mac/WeakObjCPtr.h: (WebKit::WeakObjCPtr::operator ValueType * const): * UIProcess/Cocoa/WebViewImpl.h: * UIProcess/Cocoa/WebViewImpl.mm: (WebKit::WebViewImpl::updateTouchBar): (WebKit::WebViewImpl::updateMediaTouchBar): (WebKit::WebViewImpl::WebViewImpl): (WebKit::WebViewImpl::~WebViewImpl): (WebKit::WebViewImpl::window): (WebKit::WebViewImpl::resignFirstResponder): (WebKit::WebViewImpl::isFocused const): (WebKit::WebViewImpl::renewGState): (WebKit::WebViewImpl::setFrameAndScrollBy): (WebKit::WebViewImpl::updateWindowAndViewFrames): (WebKit::WebViewImpl::updateLayer): (WebKit::WebViewImpl::printOperationWithPrintInfo): (WebKit::WebViewImpl::updateContentInsetsIfAutomatic): (WebKit::WebViewImpl::setLayoutMode): (WebKit::WebViewImpl::intrinsicDeviceScaleFactor const): (WebKit::WebViewImpl::windowDidBecomeKey): (WebKit::WebViewImpl::windowDidResignKey): (WebKit::WebViewImpl::windowDidChangeScreen): (WebKit::WebViewImpl::mightBeginDragWhileInactive): (WebKit::WebViewImpl::acceptsFirstMouse): (WebKit::WebViewImpl::shouldDelayWindowOrderingForEvent): (WebKit::WebViewImpl::windowResizeMouseLocationIsInVisibleScrollerThumb): (WebKit::WebViewImpl::viewWillMoveToWindow): (WebKit::WebViewImpl::viewDidMoveToWindow): (WebKit::WebViewImpl::viewDidChangeBackingProperties): (WebKit::WebViewImpl::hitTest): (WebKit::WebViewImpl::postFakeMouseMovedEventForFlagsChangedEvent): (WebKit::WebViewImpl::colorSpace): (WebKit::WebViewImpl::prepareForMoveToWindow): (WebKit::WebViewImpl::notifyInputContextAboutDiscardedComposition): (WebKit::WebViewImpl::pressureChangeWithEvent): (WebKit::WebViewImpl::fullScreenWindowController): (WebKit::WebViewImpl::executeSavedCommandBySelector): (WebKit::WebViewImpl::validRequestorForSendAndReturnTypes): (WebKit::WebViewImpl::handleRequestedCandidates): (WebKit::WebViewImpl::preferencesDidChange): (WebKit::WebViewImpl::setTextIndicator): (WebKit::WebViewImpl::dismissContentRelativeChildWindowsFromViewOnly): (WebKit::WebViewImpl::accessibilityRegisterUIProcessTokens): (WebKit::WebViewImpl::sendToolTipMouseExited): (WebKit::WebViewImpl::sendToolTipMouseEntered): (WebKit::WebViewImpl::toolTipChanged): (WebKit::WebViewImpl::setAcceleratedCompositingRootLayer): (WebKit::WebViewImpl::updateThumbnailViewLayer): (WebKit::WebViewImpl::setInspectorAttachmentView): (WebKit::WebViewImpl::inspectorAttachmentView): (WebKit::WebViewImpl::draggedImage): (WebKit::WebViewImpl::draggingEntered): (WebKit::WebViewImpl::draggingUpdated): (WebKit::WebViewImpl::draggingExited): (WebKit::WebViewImpl::performDragOperation): (WebKit::WebViewImpl::hitTestForDragTypes): (WebKit::WebViewImpl::startWindowDrag): (WebKit::WebViewImpl::dragImageForView): (WebKit::WebViewImpl::setPromisedDataForImage): (WebKit::WebViewImpl::setPromisedDataForAttachment): (WebKit::WebViewImpl::takeViewSnapshot): (WebKit::WebViewImpl::scrollWheel): (WebKit::WebViewImpl::magnifyWithEvent): (WebKit::WebViewImpl::rotateWithEvent): (WebKit::WebViewImpl::doneWithKeyEvent): (WebKit::WebViewImpl::interpretKeyEvent): (WebKit::WebViewImpl::firstRectForCharacterRange): (WebKit::WebViewImpl::characterIndexForPoint): (WebKit::WebViewImpl::performKeyEquivalent): (WebKit::WebViewImpl::keyUp): (WebKit::WebViewImpl::keyDown): (WebKit::WebViewImpl::mouseMoved): (WebKit::WebViewImpl::windowIsFrontWindowUnderMouse): (WebKit::WebViewImpl::userInterfaceLayoutDirection): Tools: Adds a new unit test checking that delayed event processing in text input context does not cause unwanted behaviors. See WebKit ChangeLog for more details. * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/TestWebKitAPI/mac/AppKitSPI.h: Renamed from Tools/TestWebKitAPI/Tests/TestWebKitAPI/mac/NSTextInputClientSPI.h. * TestWebKitAPI/Tests/mac/WKWebViewMacEditingTests.mm: Renamed from Tools/TestWebKitAPI/Tests/mac/WKWebViewSelectionTests.mm. (-[SlowTextInputContext handleEventByInputMethod:completionHandler:]): (-[SlowTextInputContext handleEvent:completionHandler:]): (-[SlowInputWebView inputContext]): (-[SlowInputWebView _web_superInputContext]): (TEST): Canonical link: https://commits.webkit.org/192055@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220418 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-08 20:45:21 +00:00
explicit operator ValueType *() const { return getAutoreleased(); }
private:
[Cocoa] More tweaks and refactoring to prepare for ARC https://bugs.webkit.org/show_bug.cgi?id=188245 Reviewed by Dan Bernstein. Source/JavaScriptCore: * API/JSValue.mm: Use __unsafe_unretained. (JSContainerConvertor::convert): Use auto for compatibility with the above. * API/JSWrapperMap.mm: (allocateConstructorForCustomClass): Use CFTypeRef instead of Protocol *. (-[JSWrapperMap initWithGlobalContextRef:]): Use __unsafe_unretained. * heap/Heap.cpp: Updated include for rename: FoundationSPI.h -> objcSPI.h. Source/WebCore: * bridge/objc/objc_instance.mm: Updated include for rename: FoundationSPI.h -> objcSPI.h. * platform/ios/wak/WebCoreThread.mm: Ditto. Source/WebKit: * Platform/cocoa/WKCrashReporter.mm: (WebKit::setCrashLogMessage): Refactor into a separate function for clarity. (WebKit::setCrashReportApplicationSpecificInformation): Use a bridging cast. * Shared/mac/PasteboardTypes.mm: (WebKit::PasteboardTypes::forEditing): Use a bridging cast. * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm: (WebKit::convertToNPNNString): Added. Uses CFStringRef rather than NSString so we can manually manage the autoreleasing. (WebKit::initializeKeyboardEvent): Use convertToNPNNString. (WebKit::NetscapePlugin::sendComplexTextInput): Ditto. * WebProcess/Plugins/PDF/PDFPlugin.mm: Use __unsafe_unretained explicitly for a parent pointer. We could consider moving to __weak after switching to ARC. Source/WebKitLegacy/mac: * Carbon/CarbonUtils.m: Updated include for rename: FoundationSPI.h -> objcSPI.h. * Carbon/CarbonWindowFrame.m: (-[CarbonWindowFrame dealloc]): Deleted. It was empty. * DOM/DOM.mm: (-[DOMElement _imageTIFFRepresentation]): Use a bridging cast. (-[DOMNodeFilter finalize]): Deleted. WebKit no longer supports Objective-C garbage collection so this method isn't useful. * DOM/DOMXPath.mm: (-[DOMNativeXPathNSResolver finalize]): Deleted. WebKit no longer supports Objective-C garbage collection so this method isn't useful. * History/WebHistory.mm: (-[WebHistoryPrivate data]): Allocate an NSData instead of casting from a CFData. * Misc/WebElementDictionary.mm: (addLookupKey): Use a bridging cast. (cacheValueForKey): Ditto. (-[WebElementDictionary _fillCache]): Ditto. (-[WebElementDictionary objectForKey:]): Ditto. * Misc/WebKitNSStringExtras.mm: (-[NSString _web_drawAtPoint:font:textColor:]): Use a bridging cast. (-[NSString _web_widthWithFont:]): Ditto. (-[NSString _webkit_stringByTrimmingWhitespace]): Ditto. * Misc/WebLocalizableStrings.mm: (WebLocalizedString): Use a bridging cast. * Misc/WebNSDataExtras.mm: (-[NSString _web_capitalizeRFC822HeaderFieldName]): Use a bridging cast and use CFBridgingRelease instead of calling autorelease directly. (-[NSData _webkit_parseRFC822HeaderFields]): Use NSString methods instead of a mix of CFString and NSString. Also simplified logic a bit, and cut down on the amount of explicit release and autorelease. * Misc/WebNSDictionaryExtras.h: Deleted unused methods. * Misc/WebNSDictionaryExtras.m: (-[NSDictionary _webkit_intForKey:]): Deleted. (-[NSMutableDictionary _webkit_setInt:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setFloat:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setBool:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setLongLong:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setUnsignedLongLong:forKey:]): Deleted. (-[NSMutableDictionary _webkit_setUnsignedInt:forKey:]): Deleted. * Misc/WebStringTruncator.mm: (fontFromNSFont): Use a bridging cast. * Plugins/Hosted/NetscapePluginHostManager.mm: (WebKit::preferredBundleLocalizationName): Use a bridging cast and CFBridgingRelease. * Plugins/Hosted/NetscapePluginInstanceProxy.mm: (WebKit::NetscapePluginInstanceProxy::cleanup): Use a bridging cast. (WebKit::NetscapePluginInstanceProxy::status): Ditto. (WebKit::NetscapePluginInstanceProxy::loadURL): Ditto. (WebKit::NetscapePluginInstanceProxy::demarshalValueFromArray): Ditto. * Plugins/Hosted/ProxyInstance.mm: (WebKit::ProxyInstance::getPropertyNames): Ditto. * Plugins/WebBasePluginPackage.mm: (-[WebBasePluginPackage _objectForInfoDictionaryKey:]): Ditto. * Plugins/WebNetscapePluginEventHandlerCocoa.mm: (WebNetscapePluginEventHandlerCocoa::platformWindow): Ditto. * Plugins/WebNetscapePluginPackage.mm: (-[WebNetscapePluginPackage _initWithPath:]): Ditto. * Plugins/WebNetscapePluginView.mm: (-[WebNetscapePluginView _postURL:target:len:buf:file:notifyData:sendNotification:allowHeaders:]): Use bridging casts and use RetainPtr insteead of an explicit CFRelease. (-[WebNetscapePluginView status:]): Use a bridging cast. (-[WebNetscapePluginView popUpContextMenu:]): Ditto. * Plugins/WebPluginController.mm: (-[WebPluginController _cancelOutstandingChecks]): Use a bridging cast. * Plugins/WebPluginDatabase.mm: (checkCandidate): Use explicit __strong for out argument types. * Plugins/npapi.mm: (pluginViewForInstance): Use a bridging cast. * Storage/WebDatabaseManager.mm: (-[WebDatabaseManager detailsForDatabase:withOrigin:]): Use modern boxing instead of explicit NSNumber and NSDictionary calls. * WebCoreSupport/WebContextMenuClient.mm: (WebContextMenuClient::speak): Remove an unnecessary copy/autorelease pair. * WebCoreSupport/WebEditorClient.mm: (WebEditorClient::handleKeyboardEvent): Added a missing typecast. (WebEditorClient::handleInputMethodKeydown): Ditto. * WebCoreSupport/WebFrameNetworkingContext.mm: (WebFrameNetworkingContext::sourceApplicationAuditData const): Use a bridging cast. * WebCoreSupport/WebSecurityOriginPrivate.h: Forward declare WebSecurityOriginPrivate as a struct rather than an Objective-C class, since that's how it's defined. * WebInspector/WebNodeHighlighter.mm: Added missing includes. * WebView/WebFullScreenController.mm: (-[WebFullScreenController enterFullScreen:]): Use a bridging cast. * WebView/WebHTMLView.mm: (-[WebHTMLView _writeSelectionWithPasteboardTypes:toPasteboard:cachedAttributedString:]): Ditto. (-[WebHTMLView pasteboard:provideDataForType:]): Ditto. * WebView/WebImmediateActionController.mm: (-[WebImmediateActionController performHitTestAtPoint:]): Removed redundant code to go down to the document and then back to the frame. (-[WebImmediateActionController immediateActionRecognizerDidUpdateAnimation:]): Ditto. (-[WebImmediateActionController immediateActionRecognizerDidCancelAnimation:]): Ditto. (-[WebImmediateActionController immediateActionRecognizerDidCompleteAnimation:]): Ditto. * WebView/WebJSPDFDoc.mm: (jsPDFDocInitialize): Removed some unneeded type casting. (jsPDFDocFinalize): Ditto. (jsPDFDocPrint): Use a bridging cast. * WebView/WebPDFView.mm: (_applicationInfoForMIMEType): Use bridging casts. * WebView/WebPreferences.mm: (-[WebPreferences _setIntegerValue:forKey:]): Use boxing and setObject directly instead of methods from WebNSDictionaryExtras. (-[WebPreferences _setUnsignedIntValue:forKey:]): Ditto. (-[WebPreferences _setFloatValue:forKey:]): Ditto. (-[WebPreferences _setBoolValue:forKey:]): Ditto. (-[WebPreferences _setLongLongValue:forKey:]): Ditto. (-[WebPreferences _setUnsignedLongLongValue:forKey:]): Ditto. * WebView/WebView.mm: (-[WebView _removeFromAllWebViewsSet]): Use bridging cast. (-[WebView _addToAllWebViewsSet]): Ditto. (+[WebView closeAllWebViews]): Use a modern for loop instead of NSEnumerator. (-[WebView _windowVisibilityChanged:]): Moved this into the internal category so it can be called from WebViewData methods. * WebView/WebViewData.mm: Added an import so we can call an internal WebView method, _windowVisibilityChanged:. * WebView/WebViewInternal.h: Declared _windowVisibilityChanged: so it can be called from WebViewData methods. Source/WTF: * WTF.xcodeproj/project.pbxproj: Updated for rename: FoundationSPI.h -> objcSPI.h. * wtf/BlockPtr.h: Added missing include of "StdLibExtras.h". Also re-sorted includes. * wtf/HashFunctions.h: Add function for "__unsafe_unretained id". * wtf/HashTraits.h: Add traits for "__unsafe_unretained id". * wtf/PlatformMac.cmake: Updated for rename: FoundationSPI.h -> objcSPI.h. * wtf/WeakObjCPtr.h: Use mutable instead of const_cast, and write a version that uses __weak explicitly under ARC. Also moved function declarations from here to objcSPI.h. * wtf/cocoa/AutodrainedPool.cpp: Updated include for rename: FoundationSPI.h -> objcSPI.h. * wtf/spi/cocoa/objcSPI.h: Renamed from FoundationSPI.h and added the additional functions used by WeakObjCPtr.h. Also changed to both include the internal header and the function definitions when compiling with USE(APPLE_INTERNAL_SDK), helping us check that function definitions match. Tools: * DumpRenderTree/TestNetscapePlugIn/PluginObject.h: Use const void* for a CFTypeRef instead of void*. * DumpRenderTree/TestNetscapePlugIn/PluginObjectMac.mm: (createCoreAnimationLayer): Use CFBridgingRetain. * DumpRenderTree/mac/AccessibilityUIElementMac.mm: (AccessibilityUIElement::lineTextMarkerRangeForTextMarker): Use bridging casts. (AccessibilityUIElement::textMarkerRangeForElement): Ditto. (AccessibilityUIElement::selectedTextMarkerRange): Ditto. (AccessibilityUIElement::textMarkerRangeLength): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute): Ditto. (AccessibilityUIElement::indexForTextMarker): Ditto. (AccessibilityUIElement::textMarkerForIndex): Ditto. (AccessibilityUIElement::isTextMarkerValid): Ditto. (AccessibilityUIElement::previousTextMarker): Ditto. (AccessibilityUIElement::nextTextMarker): Ditto. (AccessibilityUIElement::stringForTextMarkerRange): Ditto. (createJSStringRef): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRange): Ditto. (AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions): Ditto. (AccessibilityUIElement::textMarkerRangeForMarkers): Ditto. (AccessibilityUIElement::startTextMarkerForTextMarkerRange): Ditto. (AccessibilityUIElement::endTextMarkerForTextMarkerRange): Ditto. (AccessibilityUIElement::endTextMarkerForBounds): Ditto. (AccessibilityUIElement::startTextMarkerForBounds): Ditto. (AccessibilityUIElement::textMarkerForPoint): Ditto. (AccessibilityUIElement::accessibilityElementForTextMarker): Ditto. (AccessibilityUIElement::startTextMarker): Ditto. (AccessibilityUIElement::endTextMarker): Ditto. (AccessibilityUIElement::setSelectedVisibleTextRange): Ditto. (AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousWordStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextWordEndTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::paragraphTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousParagraphStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextParagraphEndTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::sentenceTextMarkerRangeForTextMarker): Ditto. (AccessibilityUIElement::previousSentenceStartTextMarkerForTextMarker): Ditto. (AccessibilityUIElement::nextSentenceEndTextMarkerForTextMarker): Ditto. * DumpRenderTree/mac/DumpRenderTree.mm: (resetWebPreferencesToConsistentValues): Use bridging cast. (dumpFramesAsText): Ditto. (dumpBackForwardListForAllWindows): Use a modern for loop instead of CFArray functions to iterate the array. (dump): Use bridging cast. (runTest): Ditto. * DumpRenderTree/mac/DumpRenderTreePasteboard.mm: (+[LocalPasteboard alloc]): Use class_createInstance instead of NSAllocateObject. (toUTI): Return a RetainPtr<CFStringRef>. (-[LocalPasteboard types]): Use the above and bridging casts. (-[LocalPasteboard availableTypeFromArray:]): Ditto. (-[LocalPasteboard setData:forType:]): Ditto. (-[LocalPasteboard dataForType:]): Ditto. (-[LocalPasteboard setPropertyList:forType:]): Use NSPropertyListSerialization instead of CFPropertyList. (-[LocalPasteboard setString:forType:]): Use NSString method instead of CFStringCreateExternalRepresentation. * DumpRenderTree/mac/MockGeolocationProvider.h: Put CFTypeRef in a HashSet instead of an Objective-C object pointer type. * DumpRenderTree/mac/MockGeolocationProvider.mm: (-[MockGeolocationProvider registerWebView:]): Update for above. (-[MockGeolocationProvider unregisterWebView:]): Ditto. (-[MockGeolocationProvider timerFired]): Ditto. * DumpRenderTree/mac/MockWebNotificationProvider.h: Use CFTypeRef in HashMap and HashSet instead of an Objective-C object pointer type. * DumpRenderTree/mac/MockWebNotificationProvider.mm: (-[MockWebNotificationProvider registerWebView:]): Update for above. (-[MockWebNotificationProvider unregisterWebView:]): Ditto. (-[MockWebNotificationProvider showNotification:fromWebView:]): Ditto. (-[MockWebNotificationProvider cancelNotification:]): Ditto. (-[MockWebNotificationProvider simulateWebNotificationClick:]): Ditto. * DumpRenderTree/mac/ObjCPlugin.m: (-[JSObjC retainObject:]): Use CFRetain instead of -[NSObject retain]. * DumpRenderTree/mac/TestRunnerMac.mm: (TestRunner::addDisallowedURL): Use bridging cast. (TestRunner::applicationCacheDiskUsageForOrigin): Ditto. (TestRunner::clearApplicationCacheForOrigin): Ditto. (originsArrayToJS): Ditto. (TestRunner::copyDecodedHostName): Ditto. (TestRunner::copyEncodedHostName): Ditto. (TestRunner::queueLoad): Ditto. (TestRunner::setDomainRelaxationForbiddenForURLScheme): Ditto. (TestRunner::setMockGeolocationPositionUnavailableError): Ditto. (TestRunner::setUserStyleSheetLocation): Ditto. (TestRunner::setValueForUser): Ditto. (TestRunner::overridePreference): Ditto. (TestRunner::execCommand): Ditto. (TestRunner::findString): Ditto. (TestRunner::isCommandEnabled): Ditto. (TestRunner::addOriginAccessWhitelistEntry): Ditto. (TestRunner::removeOriginAccessWhitelistEntry): Ditto. (TestRunner::addUserScript): Ditto. (TestRunner::addUserStyleSheet): Ditto. (TestRunner::evaluateInWebInspector): Ditto. (TestRunner::evaluateScriptInIsolatedWorld): Ditto. (TestRunner::authenticateSession): Ditto. (TestRunner::grantWebNotificationPermission): Ditto. (TestRunner::denyWebNotificationPermission): Ditto. * TestRunnerShared/cocoa/LayoutTestSpellChecker.mm: (-[LayoutTestSpellChecker setResultsFromJSObject:inContext:]): Ditto. * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm: (WTR::AccessibilityUIElement::lineTextMarkerRangeForTextMarker): Use bridging cast. (WTR::AccessibilityUIElement::textMarkerRangeForElement): Ditto. (WTR::AccessibilityUIElement::previousTextMarker): Ditto. (WTR::AccessibilityUIElement::nextTextMarker): Ditto. (WTR::AccessibilityUIElement::textMarkerRangeForMarkers): Ditto. (WTR::AccessibilityUIElement::selectedTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::startTextMarkerForTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::endTextMarkerForTextMarkerRange): Ditto. (WTR::AccessibilityUIElement::endTextMarkerForBounds): Ditto. (WTR::AccessibilityUIElement::startTextMarkerForBounds): Ditto. (WTR::AccessibilityUIElement::textMarkerForPoint): Ditto. (WTR::AccessibilityUIElement::textMarkerForIndex): Ditto. (WTR::AccessibilityUIElement::startTextMarker): Ditto. (WTR::AccessibilityUIElement::endTextMarker): Ditto. (WTR::AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousWordStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextWordEndTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::paragraphTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousParagraphStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextParagraphEndTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::sentenceTextMarkerRangeForTextMarker): Ditto. (WTR::AccessibilityUIElement::previousSentenceStartTextMarkerForTextMarker): Ditto. (WTR::AccessibilityUIElement::nextSentenceEndTextMarkerForTextMarker): Ditto. * WebKitTestRunner/PlatformMac.cmake: Added WebKitTestRunnerWindow.h and .mm files. * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: Ditto. * WebKitTestRunner/mac/EventSenderProxy.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. * WebKitTestRunner/mac/PlatformWebViewMac.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. Moved WebKitTestRunnerWindow class into a separate file. (WTR::PlatformWebView::keyWindow): Call +[WebKitTestRunnerWindow _WTR_keyWindow] instead of have a second copy of the implementation. * WebKitTestRunner/mac/WebKitTestRunnerEvent.mm: Add include of WebKitTestRunnerWindow.h so we can use the type and know it inherits from NSWindow. Also removed "using namespace". (+[WebKitTestRunnerEvent mouseLocation]): Updated for above. * WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm: (+[LocalPasteboard alloc]): Use class_createInstance instead of NSAllocateObject. (-[LocalPasteboard availableTypeFromArray:]): Use modern for loop. (-[LocalPasteboard setData:forType:]): Reordered method to be a tiny bit more efficient. (-[LocalPasteboard setPropertyList:forType:]): Use NSPropertyListSerialization instead of CFPropertyList. (-[LocalPasteboard setString:forType:]): Use NSString method instead of CFStringCreateExternalRepresentation. * WebKitTestRunner/mac/WebKitTestRunnerWindow.h: Moved declaration of WebKitTestRunnerWindow here so it can be included by files that need to know what the type is and that it inherits from NSWindow. * WebKitTestRunner/mac/WebKitTestRunnerWindow.mm: Added. Moved implementation here. (+[WebKitTestRunnerWindow _WTR_keyWindow]): Use modern for loop instead of the old, messier implementation. Canonical link: https://commits.webkit.org/203508@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234685 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-08-08 02:39:12 +00:00
#if __has_feature(objc_arc)
mutable __weak id m_weakReference { nullptr };
#else
mutable id m_weakReference { nullptr };
#endif
};
#ifdef __OBJC__
template<typename T>
RetainPtr<typename WeakObjCPtr<T>::ValueType> WeakObjCPtr<T>::get() const
{
#if __has_feature(objc_arc)
return static_cast<typename WeakObjCPtr<T>::ValueType *>(m_weakReference);
#else
return adoptNS(objc_loadWeakRetained(&m_weakReference));
#endif
}
#endif
Regression(AsyncPolicyDelegates): Box.app login Window is blank https://bugs.webkit.org/show_bug.cgi?id=185832 <rdar://problem/40307871> Reviewed by Geoffrey Garen. Source/WebKit: Moved WeakObjCPtr.h header from WebKit/ to wtf/ so that it can be used in WebKitLegacy code. * UIProcess/API/Cocoa/WKBrowsingContextController.mm: * UIProcess/API/Cocoa/WKBrowsingContextControllerInternal.h: * UIProcess/API/Cocoa/WKConnection.mm: * UIProcess/API/Cocoa/WKHTTPCookieStore.mm: * UIProcess/API/Cocoa/WKProcessGroup.mm: * UIProcess/API/Cocoa/WKProcessPool.mm: * UIProcess/API/Cocoa/WKScriptMessage.mm: * UIProcess/API/Cocoa/WKWebView.mm: * UIProcess/API/Cocoa/WKWebViewConfiguration.mm: * UIProcess/API/Cocoa/_WKAutomationSession.mm: * UIProcess/API/Cocoa/_WKDownload.mm: * UIProcess/API/Cocoa/_WKElementAction.mm: * UIProcess/ApplicationStateTracker.h: * UIProcess/Cocoa/AutomationClient.h: * UIProcess/Cocoa/AutomationSessionClient.h: * UIProcess/Cocoa/DiagnosticLoggingClient.h: * UIProcess/Cocoa/DownloadClient.h: * UIProcess/Cocoa/FindClient.h: * UIProcess/Cocoa/FullscreenClient.h: * UIProcess/Cocoa/IconLoadingDelegate.h: * UIProcess/Cocoa/NavigationState.h: * UIProcess/Cocoa/UIDelegate.h: * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm: * UIProcess/Cocoa/WKReloadFrameErrorRecoveryAttempter.mm: * UIProcess/Cocoa/WebViewImpl.h: * UIProcess/ios/ViewGestureControllerIOS.mm: * UIProcess/ios/WKActionSheetAssistant.mm: * UIProcess/ios/WKContentViewInteraction.mm: * UIProcess/ios/WKPDFView.mm: (-[WKPDFView web_setContentProviderData:suggestedFilename:]): * UIProcess/ios/WKScrollView.mm: * UIProcess/mac/WKInspectorViewController.mm: * UIProcess/mac/WKInspectorWKWebView.mm: * WebKit.xcodeproj/project.pbxproj: * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm: Source/WebKitLegacy/mac: We used to have a bug where where we would fail to wait for the policy decision for the navigation response from the client and the load would keep going, racing with the client's policy decision. If the client did not respond in time, the behavior would be the same as "Use" policy action. Box.app fails to make any policy decision in its decidePolicyForMIMEType delegate but the load happened to proceed anyway due to our bug. Now that we've fixed the WebKit bug, however, the load would hang because the completion handler for the decidePolicyForNavigationResponse would never get called. To work around the issue, I made the policy listener weak on the WebFrameLoaderClient instead of retaining it. If the policy listener object gets destroyed because getting resolved, we now use "Use" policy action in its dealloc function to maintain previous behavior. * WebCoreSupport/WebFrameLoaderClient.h: * WebCoreSupport/WebFrameLoaderClient.mm: (WebFrameLoaderClient::cancelPolicyCheck): (WebFrameLoaderClient::setUpPolicyListener): (-[WebFramePolicyListener dealloc]): Source/WTF: Moved WeakObjCPtr.h from WebKit2 to WTF with RetainPtr.h, so that it can be used in WebKitLegacy code. * WTF.xcodeproj/project.pbxproj: * wtf/WeakObjCPtr.h: Renamed from Source/WebKit/Shared/mac/WeakObjCPtr.h. Tools: Add API test coverage. * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebKit/cocoa/WeakObjCPtr.mm: * TestWebKitAPI/Tests/mac/NoPolicyDelegateResponse.mm: Added. (-[NoPolicyDelegateDecisionDelegate webView:decidePolicyForNavigationAction:request:frame:decisionListener:]): (-[NoPolicyDelegateDecisionDelegate webView:decidePolicyForMIMEType:request:frame:decisionListener:]): (-[NoPolicyDelegateDecisionDelegate webView:didFinishLoadForFrame:]): (TestWebKitAPI::TEST): * TestWebKitAPI/cocoa/TestWKWebView.mm: (-[WKWebView _isBackground]): Canonical link: https://commits.webkit.org/201333@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232082 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-05-22 22:41:06 +00:00
} // namespace WTF
Regression(AsyncPolicyDelegates): Box.app login Window is blank https://bugs.webkit.org/show_bug.cgi?id=185832 <rdar://problem/40307871> Reviewed by Geoffrey Garen. Source/WebKit: Moved WeakObjCPtr.h header from WebKit/ to wtf/ so that it can be used in WebKitLegacy code. * UIProcess/API/Cocoa/WKBrowsingContextController.mm: * UIProcess/API/Cocoa/WKBrowsingContextControllerInternal.h: * UIProcess/API/Cocoa/WKConnection.mm: * UIProcess/API/Cocoa/WKHTTPCookieStore.mm: * UIProcess/API/Cocoa/WKProcessGroup.mm: * UIProcess/API/Cocoa/WKProcessPool.mm: * UIProcess/API/Cocoa/WKScriptMessage.mm: * UIProcess/API/Cocoa/WKWebView.mm: * UIProcess/API/Cocoa/WKWebViewConfiguration.mm: * UIProcess/API/Cocoa/_WKAutomationSession.mm: * UIProcess/API/Cocoa/_WKDownload.mm: * UIProcess/API/Cocoa/_WKElementAction.mm: * UIProcess/ApplicationStateTracker.h: * UIProcess/Cocoa/AutomationClient.h: * UIProcess/Cocoa/AutomationSessionClient.h: * UIProcess/Cocoa/DiagnosticLoggingClient.h: * UIProcess/Cocoa/DownloadClient.h: * UIProcess/Cocoa/FindClient.h: * UIProcess/Cocoa/FullscreenClient.h: * UIProcess/Cocoa/IconLoadingDelegate.h: * UIProcess/Cocoa/NavigationState.h: * UIProcess/Cocoa/UIDelegate.h: * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm: * UIProcess/Cocoa/WKReloadFrameErrorRecoveryAttempter.mm: * UIProcess/Cocoa/WebViewImpl.h: * UIProcess/ios/ViewGestureControllerIOS.mm: * UIProcess/ios/WKActionSheetAssistant.mm: * UIProcess/ios/WKContentViewInteraction.mm: * UIProcess/ios/WKPDFView.mm: (-[WKPDFView web_setContentProviderData:suggestedFilename:]): * UIProcess/ios/WKScrollView.mm: * UIProcess/mac/WKInspectorViewController.mm: * UIProcess/mac/WKInspectorWKWebView.mm: * WebKit.xcodeproj/project.pbxproj: * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm: Source/WebKitLegacy/mac: We used to have a bug where where we would fail to wait for the policy decision for the navigation response from the client and the load would keep going, racing with the client's policy decision. If the client did not respond in time, the behavior would be the same as "Use" policy action. Box.app fails to make any policy decision in its decidePolicyForMIMEType delegate but the load happened to proceed anyway due to our bug. Now that we've fixed the WebKit bug, however, the load would hang because the completion handler for the decidePolicyForNavigationResponse would never get called. To work around the issue, I made the policy listener weak on the WebFrameLoaderClient instead of retaining it. If the policy listener object gets destroyed because getting resolved, we now use "Use" policy action in its dealloc function to maintain previous behavior. * WebCoreSupport/WebFrameLoaderClient.h: * WebCoreSupport/WebFrameLoaderClient.mm: (WebFrameLoaderClient::cancelPolicyCheck): (WebFrameLoaderClient::setUpPolicyListener): (-[WebFramePolicyListener dealloc]): Source/WTF: Moved WeakObjCPtr.h from WebKit2 to WTF with RetainPtr.h, so that it can be used in WebKitLegacy code. * WTF.xcodeproj/project.pbxproj: * wtf/WeakObjCPtr.h: Renamed from Source/WebKit/Shared/mac/WeakObjCPtr.h. Tools: Add API test coverage. * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebKit/cocoa/WeakObjCPtr.mm: * TestWebKitAPI/Tests/mac/NoPolicyDelegateResponse.mm: Added. (-[NoPolicyDelegateDecisionDelegate webView:decidePolicyForNavigationAction:request:frame:decisionListener:]): (-[NoPolicyDelegateDecisionDelegate webView:decidePolicyForMIMEType:request:frame:decisionListener:]): (-[NoPolicyDelegateDecisionDelegate webView:didFinishLoadForFrame:]): (TestWebKitAPI::TEST): * TestWebKitAPI/cocoa/TestWKWebView.mm: (-[WKWebView _isBackground]): Canonical link: https://commits.webkit.org/201333@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232082 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-05-22 22:41:06 +00:00
using WTF::WeakObjCPtr;