Streamline JSRetainPtr, fix leaks of JSString and JSGlobalContext
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 15 Sep 2018 16:17:24 +0000 (16:17 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 15 Sep 2018 16:17:24 +0000 (16:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189455

Reviewed by Keith Miller.

Source/JavaScriptCore:

* API/JSObjectRef.cpp:
(OpaqueJSPropertyNameArray): Use Ref<OpaqueJSString> instead of
JSRetainPtr<JSStringRef>.
(JSObjectCopyPropertyNames): Remove now-unneeded use of leakRef and
adopt constructor.
(JSPropertyNameArrayGetNameAtIndex): Use ptr() instead of get() since
the array elements are now Ref.

* API/JSRetainPtr.h: While JSRetainPtr is written as a template,
it only works for two specific unrelated types, JSStringRef and
JSGlobalContextRef. Simplified the default constructor using data
member initialization. Prepared to make the adopt constructor private
(got everything compiling that way, then made it public again so that
Apple internal software will still build). Got rid of unneeded
templated constructor and assignment operator, since it's not relevant
since there is no inheritance between JSRetainPtr template types.
Added WARN_UNUSED_RETURN to leakRef as in RefPtr and RetainPtr.
Added move constructor and move assignment operator for slightly better
performance. Simplified implementations of various member functions
so they are more obviously correct, by using leakPtr in more of them
and using std::exchange to make the flow of values more obvious.

* API/JSValue.mm:
(+[JSValue valueWithNewSymbolFromDescription:inContext:]): Added a
missing JSStringRelease to fix a leak.

* API/tests/CustomGlobalObjectClassTest.c:
(customGlobalObjectClassTest): Added a JSGlobalContextRelease to fix a leak.
(globalObjectSetPrototypeTest): Ditto.
(globalObjectPrivatePropertyTest): Ditto.

* API/tests/ExecutionTimeLimitTest.cpp:
(testResetAfterTimeout): Added a call to JSStringRelease to fix a leak.
(testExecutionTimeLimit): Ditto, lots more.

* API/tests/FunctionOverridesTest.cpp:
(testFunctionOverrides): Added a call to JSStringRelease to fix a leak.

* API/tests/JSObjectGetProxyTargetTest.cpp:
(testJSObjectGetProxyTarget): Added a call to JSGlobalContextRelease to fix
a leak.

* API/tests/PingPongStackOverflowTest.cpp:
(testPingPongStackOverflow): Added calls to JSGlobalContextRelease and
JSStringRelease to fix leaks.

* API/tests/testapi.c:
(throwException): Added. Helper function for repeated idiom where we want
to throw an exception, but with additional JSStringRelease calls so we don't
have to leak just to keep the code simpler to read.
(MyObject_getProperty): Use throwException.
(MyObject_setProperty): Ditto.
(MyObject_deleteProperty): Ditto.
(isValueEqualToString): Added. Helper function for an idiom where we check
if something is a string and then if it's equal to a particular string
constant, but a version that has an additional JSStringRelease call so we
don't have to leak just to keep the code simpler to read.
(MyObject_callAsFunction): Use isValueEqualToString and throwException.
(MyObject_callAsConstructor): Ditto.
(MyObject_hasInstance): Ditto.
(globalContextNameTest): Added a JSGlobalContextRelease to fix a leak.
(testMarkingConstraintsAndHeapFinalizers): Ditto.

Source/WebCore:

* Modules/plugins/QuickTimePluginReplacement.mm:
(WebCore::jsValueWithDictionaryInContext): Adding a missing
JSStringRelease to fix a leak.

Source/WebKit:

* WebProcess/Automation/WebAutomationSessionProxy.cpp:
(WebKit::toJSString): Use adopt function instead of adopt construuctor.
(WebKit::evaluate): Ditto.
(WebKit::evaluateJavaScriptCallback): Ditto.
(WebKit::WebAutomationSessionProxy::evaluateJavaScriptFunction): Ditto.

Tools:

There is a lot of copied and pasted code for WebKit vs. Legacy WebKit
testing and even for macOS vs. iOS vs. Windows platform-specific code.
For now, this patch just makes corresponding changes to the copied code.
Later we might get better results by merging more code instead of having
all these separate copies.

* DumpRenderTree/AccessibilityController.cpp:
(AccessibilityController::makeWindowObject): Use the adopt function
instead of the special Adopt constructor of JSRetainPtr.

* DumpRenderTree/AccessibilityTextMarker.cpp: Removed unneeded include.

* DumpRenderTree/AccessibilityUIElement.cpp: Ditto.
(allAttributesCallback): Don't adopt at this level; changed the
underlying function to return a JSRetainPtr so the adopt is right next
to the call to the create or copy function.
(attributesOfLinkedUIElementsCallback): Ditto.
(attributesOfDocumentLinksCallback): Ditto.
(attributesOfChildrenCallback): Ditto.
(parameterizedAttributeNamesCallback): Ditto.
(attributesOfColumnHeadersCallback): Ditto.
(attributesOfRowHeadersCallback): Ditto.
(attributesOfColumnsCallback): Ditto.
(attributesOfRowsCallback): Ditto.
(attributesOfVisibleCellsCallback): Ditto.
(attributesOfHeaderCallback): Ditto.
(rowIndexRangeCallback): Ditto.
(columnIndexRangeCallback): Ditto.
(rangeForLineCallback): Ditto.
(boundsForRangeCallback): Ditto.
(rangeForPositionCallback): Ditto.
(stringForRangeCallback): Ditto.
(attributedStringForRangeCallback): Ditto.
(uiElementCountForSearchPredicateCallback): Use the free adopt
function instead of the adopt member function.
(uiElementForSearchPredicateCallback): Ditto.
(selectTextWithCriteriaCallback): Don't adopt at this level.
(attributedStringForElementCallback): Ditto.
(setValueCallback): Use free adopt.
(stringAttributeValueCallback): Don't adopt at this level.
(uiElementArrayAttributeValueCallback): Ditto.
(uiElementAttributeValueCallback): Ditto.
(stringForTextMarkerRangeCallback): Ditto.
(attributedStringForTextMarkerRangeCallback): Ditto.
(attributedStringForTextMarkerRangeWithOptionsCallback): Ditto.
(getARIADropEffectsCallback): Ditto.
(getClassListCallback): Ditto.
(getRoleCallback): Ditto.
(getSubroleCallback): Ditto.
(getRoleDescriptionCallback): Ditto.
(getComputedRoleStringCallback): Ditto.
(getTitleCallback): Ditto.
(getDescriptionCallback): Ditto.
(getStringValueCallback): Ditto.
(getLanguageCallback): Ditto.
(getHelpTextCallback): Ditto.
(getOrientationCallback): Ditto.
(getPathDescriptionCallback): Ditto.
(getSelectedTextRangeCallback): Ditto.
(speakAsCallback): Ditto.
(getValueDescriptionCallback): Ditto.
(getAccessibilityValueCallback): Ditto.
(getDocumentEncodingCallback): Ditto.
(getDocumentURICallback): Ditto.
(getURLCallback): Ditto.
(characterAtOffsetCallback): Ditto.
(wordAtOffsetCallback): Ditto.
(lineAtOffsetCallback): Ditto.
(sentenceAtOffsetCallback): Ditto.
(stringForSelectionCallback): Ditto.
(getIdentifierCallback): Ditto.
(getTraitsCallback): Ditto.
(supportedActionsCallback): Ditto.
(mathPostscriptsDescriptionCallback): Ditto.
(mathPrescriptsDescriptionCallback): Ditto.
(AccessibilityUIElement::rangeForLine): Updated to return JSRetainPtr.
(AccessibilityUIElement::rangeForPosition): Ditto.
(AccessibilityUIElement::speakAs): Ditto.
(AccessibilityUIElement::pathDescription const): Ditto.
(AccessibilityUIElement::stringForTextMarkerRange): Ditto.
(AccessibilityUIElement::attributedStringForTextMarkerRange): Ditto.
(AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions): Ditto.

* DumpRenderTree/AccessibilityUIElement.h: Use JSRetainPtr instead of
raw pointers for the results of the functions that create strings.
The old way was difficult to get right; the functions didn't even follow
the create/copy naming rule.

* DumpRenderTree/Bindings/CodeGeneratorDumpRenderTree.pm:
(_platformTypeConstructor): Use the adopt function instead of the
JSRetainPtr adopt constructor. Also nullptr instead of 0.

* DumpRenderTree/GCController.cpp:
(GCController::makeWindowObject): Use adopt function instead of constructor.

* DumpRenderTree/TestRunner.cpp:
(pathToLocalResourceCallback): Use adopt function instead of constructor.
(addDisallowedURLCallback): Ditto.
(addURLToRedirectCallback): Ditto.
(clearApplicationCacheForOriginCallback): Ditto.
(applicationCacheDiskUsageForOriginCallback): Ditto.
(decodeHostNameCallback): Don't adopt at this level.
(encodeHostNameCallback): Ditto.
(execCommandCallback): Use adopt instead of JSRetainPtr::adopt.
(findStringCallback): Use adopt function instead of constructor.
(isCommandEnabledCallback): Ditto.
(overridePreferenceCallback): Ditto.
(queueLoadCallback): Ditto.
(queueLoadHTMLStringCallback): Ditto.
(queueLoadingScriptCallback): Ditto.
(queueNonLoadingScriptCallback): Ditto.
(setAuthenticationPasswordCallback): Ditto.
(setAuthenticationUsernameCallback): Ditto.
(setDomainRelaxationForbiddenForURLSchemeCallback): Ditto.
(setMockGeolocationPositionUnavailableErrorCallback): Ditto.
(setPOSIXLocaleCallback): Ditto.
(setPersistentUserStyleSheetLocationCallback): Ditto.
(setUserStyleSheetLocationCallback): Ditto.
(setValueForUserCallback): Ditto.
(setWillSendRequestClearHeaderCallback): Ditto.
(setPageVisibilityCallback): Ditto.
(evaluateInWebInspectorCallback): Ditto.
(evaluateScriptInIsolatedWorldCallback): Ditto.
(evaluateScriptInIsolatedWorldAndReturnValueCallback): Ditto.
(addOriginAccessWhitelistEntryCallback): Ditto.
(removeOriginAccessWhitelistEntryCallback): Ditto.
(setScrollbarPolicyCallback): Ditto.
(addUserScriptCallback): Ditto.
(addUserStyleSheetCallback): Ditto.
(apiTestNewWindowDataLoadBaseURLCallback): Ditto.
(authenticateSessionCallback): Ditto.
(getTitleTextDirectionCallback): Ditto.
(getInspectorTestStubURLCallback): Ditto.
(simulateLegacyWebNotificationClickCallback): Ditto.
(setTextDirectionCallback): Ditto.
(grantWebNotificationPermissionCallback): Ditto.
(denyWebNotificationPermissionCallback): Ditto.
(accummulateLogsForChannel): Ditto.
(runUIScriptCallback): Ditto.
(TestRunner::makeWindowObject): Ditto.
(TestRunner::uiScriptDidComplete): Ditto.
(TestRunner::setOpenPanelFiles): Ditto.

* DumpRenderTree/TestRunner.h: Use JSRetainPtr instead of
raw pointers for the results of the functions that create strings.

* DumpRenderTree/ios/AccessibilityControllerIOS.mm:
(AccessibilityController::platformName const): Use the adopt
function instead of the adopt constructor.

* DumpRenderTree/ios/AccessibilityUIElementIOS.mm:
(createEmptyJSString): Added. This helper function makes reduces the
repetitive code to create empty strings.
(concatenateAttributeAndValue): Changed to return a JSRetainPtr.
(AccessibilityUIElement::identifier): Ditto.
(AccessibilityUIElement::traits): Ditto.
(AccessibilityUIElement::url): Ditto.
(AccessibilityUIElement::speakAs): Ditto.
(AccessibilityUIElement::stringForSelection): Ditto.
(AccessibilityUIElement::stringForRange): Ditto.
(AccessibilityUIElement::attributedStringForRange): Ditto.
(AccessibilityUIElement::attributedStringForElement): Ditto.
(AccessibilityUIElement::pathDescription const): Ditto.
(AccessibilityUIElement::stringForTextMarkerRange): Ditto.
(AccessibilityUIElement::attributedStringForTextMarkerRange): Ditto.
(AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions): Ditto.
(AccessibilityUIElement::attributesOfLinkedUIElements): Ditto.
(AccessibilityUIElement::attributesOfDocumentLinks): Ditto.
(AccessibilityUIElement::attributesOfChildren): Ditto.
(AccessibilityUIElement::allAttributes): Ditto.
(AccessibilityUIElement::stringAttributeValue): Ditto.
(AccessibilityUIElement::parameterizedAttributeNames): Ditto.
(AccessibilityUIElement::role): Ditto.
(AccessibilityUIElement::subrole): Ditto.
(AccessibilityUIElement::roleDescription): Ditto.
(AccessibilityUIElement::computedRoleString): Ditto.
(AccessibilityUIElement::title): Ditto.
(AccessibilityUIElement::description): Ditto.
(AccessibilityUIElement::orientation const): Ditto.
(AccessibilityUIElement::stringValue): Ditto.
(AccessibilityUIElement::language): Ditto.
(AccessibilityUIElement::helpText const): Ditto.
(AccessibilityUIElement::valueDescription): Ditto.
(AccessibilityUIElement::ariaDropEffects const): Ditto.
(AccessibilityUIElement::boundsForRange): Ditto.
(AccessibilityUIElement::attributesOfColumnHeaders): Ditto.
(AccessibilityUIElement::attributesOfRowHeaders): Ditto.
(AccessibilityUIElement::attributesOfColumns): Ditto.
(AccessibilityUIElement::attributesOfRows): Ditto.
(AccessibilityUIElement::attributesOfVisibleCells): Ditto.
(AccessibilityUIElement::attributesOfHeader): Ditto.
(AccessibilityUIElement::rowIndexRange): Ditto.
(AccessibilityUIElement::columnIndexRange): Ditto.
(AccessibilityUIElement::selectedTextRange): Ditto.
(AccessibilityUIElement::accessibilityValue const): Ditto.
(AccessibilityUIElement::documentEncoding): Ditto.
(AccessibilityUIElement::documentURI): Ditto.
(AccessibilityUIElement::selectTextWithCriteria): Ditto.
(AccessibilityUIElement::classList const): Ditto.

* DumpRenderTree/mac/AccessibilityCommonMac.h: Changed the
createJSStringRef method to return a JSRetainPtr.
* DumpRenderTree/mac/AccessibilityCommonMac.mm:
(-[NSString createJSStringRef]): Ditto.
(searchPredicateParameterizedAttributeForSearchCriteria): Use the
adopt function instead of the adopt constructor.
* DumpRenderTree/mac/AccessibilityControllerMac.mm:
(AccessibilityController::platformName const): Ditto.

* DumpRenderTree/mac/AccessibilityNotificationHandler.mm:
(-[NSString createJSStringRef]): Return a JSRetainPtr.
(makeValueRefForValue): Updated for the above, no adopt needed here now.
(makeObjectRefForDictionary): Ditto.
(-[AccessibilityNotificationHandler _notificationReceived:]): Ditto.

* DumpRenderTree/mac/AccessibilityUIElementMac.mm:
(createEmptyJSString): Added. This helper function makes reduces the
repetitive code to create empty strings.
(concatenateAttributeAndValue): Changed to return a JSRetainPtr.
(descriptionOfElements): Ditto.
(selectTextParameterizedAttributeForCriteria): Ditto.
(AccessibilityUIElement::attributesOfLinkedUIElements): Ditto.
(AccessibilityUIElement::attributesOfDocumentLinks): Ditto.
(AccessibilityUIElement::attributesOfChildren): Ditto.
(AccessibilityUIElement::allAttributes): Ditto.
(AccessibilityUIElement::stringAttributeValue): Ditto.
(AccessibilityUIElement::parameterizedAttributeNames): Ditto.
(AccessibilityUIElement::role): Ditto.
(AccessibilityUIElement::subrole): Ditto.
(AccessibilityUIElement::roleDescription): Ditto.
(AccessibilityUIElement::computedRoleString): Ditto.
(AccessibilityUIElement::title): Ditto.
(AccessibilityUIElement::description): Ditto.
(AccessibilityUIElement::orientation const): Ditto.
(AccessibilityUIElement::stringValue): Ditto.
(AccessibilityUIElement::language): Ditto.
(AccessibilityUIElement::helpText const): Ditto.
(AccessibilityUIElement::valueDescription): Ditto.
(AccessibilityUIElement::speakAs): Ditto.
(AccessibilityUIElement::classList const): Ditto.
(AccessibilityUIElement::ariaDropEffects const): Ditto.
(AccessibilityUIElement::rangeForLine): Ditto.
(AccessibilityUIElement::rangeForPosition): Ditto.
(AccessibilityUIElement::boundsForRange): Ditto.
(AccessibilityUIElement::stringForRange): Ditto.
(AccessibilityUIElement::attributedStringForRange): Ditto.
(AccessibilityUIElement::selectTextWithCriteria): Ditto.
(AccessibilityUIElement::attributesOfColumnHeaders): Ditto.
(AccessibilityUIElement::attributesOfRowHeaders): Ditto.
(AccessibilityUIElement::attributesOfColumns): Ditto.
(AccessibilityUIElement::attributesOfRows): Ditto.
(AccessibilityUIElement::attributesOfVisibleCells): Ditto.
(AccessibilityUIElement::attributesOfHeader): Ditto.
(AccessibilityUIElement::rowIndexRange): Ditto.
(AccessibilityUIElement::columnIndexRange): Ditto.
(AccessibilityUIElement::pathDescription const): Ditto.
(AccessibilityUIElement::selectedTextRange): Ditto.
(AccessibilityUIElement::accessibilityValue const): Ditto.
(AccessibilityUIElement::documentEncoding): Ditto.
(AccessibilityUIElement::documentURI): Ditto.
(AccessibilityUIElement::url): Ditto.
(AccessibilityUIElement::stringForTextMarkerRange): Ditto.
(createJSStringRef): Ditto.
(AccessibilityUIElement::attributedStringForTextMarkerRange): Ditto.
(AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions): Ditto.
(AccessibilityUIElement::supportedActions): Ditto.
(AccessibilityUIElement::mathPostscriptsDescription const): Ditto.
(AccessibilityUIElement::mathPrescriptsDescription const): Ditto.

* DumpRenderTree/mac/FrameLoadDelegate.mm:
(-[FrameLoadDelegate didClearWindowObjectForFrame:inIsolatedWorld:]):
Use the adopt function instead of the adopt constructor.
* DumpRenderTree/mac/TestRunnerMac.mm:
(originsArrayToJS): Ditto.
(TestRunner::copyDecodedHostName): Return a JSRetainPtr.
(TestRunner::copyEncodedHostName): Ditto.
(TestRunner::pathToLocalResource): Ditto.
(TestRunner::queueLoad): Use adopt function instead of constructor.
(TestRunner::findString): Ditto.
(TestRunner::inspectorTestStubURL): Return a JSRetainPtr.

* DumpRenderTree/win/AccessibilityControllerWin.cpp:
(AccessibilityController::winNotificationReceived): Use adopt function
instead of adopt constructor.
(AccessibilityController::platformName const): Ditto.

* DumpRenderTree/win/AccessibilityUIElementWin.cpp:
(createEmptyJSString): Added. This helper function makes reduces the
repetitive code to create empty strings.
(AccessibilityUIElement::allAttributes): Changed to return a JSRetainPtr.
(AccessibilityUIElement::attributesOfLinkedUIElements): Ditto.
(AccessibilityUIElement::attributesOfDocumentLinks): Ditto.
(AccessibilityUIElement::attributesOfChildren): Ditto.
(AccessibilityUIElement::parameterizedAttributeNames): Ditto.
(AccessibilityUIElement::role): Ditto.
(AccessibilityUIElement::subrole): Ditto.
(AccessibilityUIElement::roleDescription): Ditto.
(AccessibilityUIElement::computedRoleString): Ditto.
(AccessibilityUIElement::title): Ditto.
(AccessibilityUIElement::description): Ditto.
(AccessibilityUIElement::stringValue): Ditto.
(AccessibilityUIElement::language): Ditto.
(AccessibilityUIElement::helpText const): Ditto.
(AccessibilityUIElement::valueDescription): Ditto.
(AccessibilityUIElement::ariaDropEffects const): Ditto.
(AccessibilityUIElement::orientation const): Ditto.
(AccessibilityUIElement::attributesOfColumnHeaders): Ditto.
(AccessibilityUIElement::attributesOfRowHeaders): Ditto.
(AccessibilityUIElement::attributesOfColumns): Ditto.
(AccessibilityUIElement::attributesOfRows): Ditto.
(AccessibilityUIElement::attributesOfVisibleCells): Ditto.
(AccessibilityUIElement::attributesOfHeader): Ditto.
(AccessibilityUIElement::rowIndexRange): Ditto.
(AccessibilityUIElement::columnIndexRange): Ditto.
(AccessibilityUIElement::boundsForRange): Ditto.
(AccessibilityUIElement::stringForRange): Ditto.
(AccessibilityUIElement::attributedStringForRange): Ditto.
(AccessibilityUIElement::selectTextWithCriteria): Ditto.
(AccessibilityUIElement::selectedTextRange): Ditto.
(AccessibilityUIElement::stringAttributeValue): Ditto.
(AccessibilityUIElement::accessibilityValue const): Ditto.
(AccessibilityUIElement::documentEncoding): Ditto.
(AccessibilityUIElement::documentURI): Ditto.
(AccessibilityUIElement::url): Ditto.
(AccessibilityUIElement::classList const): Ditto.

* DumpRenderTree/win/TestRunnerWin.cpp:
(TestRunner::copyDecodedHostName): Changed to return a JSRetainPtr.
(TestRunner::copyEncodedHostName): Ditto.
(TestRunner::pathToLocalResource): Ditto.
(TestRunner::queueLoad): Ditto.
(TestRunner::findString): Ditto.
(TestRunner::inspectorTestStubURL): Ditto.

* TestRunnerShared/Bindings/JSWrapper.h:
(WTR::setProperty): Use adopt function instead of constructor.
* TestRunnerShared/UIScriptContext/UIScriptContext.cpp:
(UIScriptContext::UIScriptContext): Ditto.
(UIScriptContext::runUIScript): Ditto.
* TestRunnerShared/UIScriptContext/UIScriptController.cpp:
(WTR::toDeviceOrientation): Ditto.

* TestRunnerShared/cocoa/LayoutTestSpellChecker.mm:
(nsTextCheckingType): Changed this function to not take an rvalue
reference to a JSRetainPtr since it doesn't take ownership.
(-[LayoutTestSpellChecker setResultsFromJSObject:inContext:]): Updated
for the above change.

* TestWebKitAPI/JavaScriptTest.cpp:
(TestWebKitAPI::javaScriptCallback): Use adopt function instead of
adopt member function.

* TestWebKitAPI/Tests/WebKit/WKPageIsPlayingAudio.cpp: Removed unneeded include.
* TestWebKitAPI/Tests/WebKitCocoa/PictureInPictureDelegate.mm: Ditto.
* TestWebKitAPI/Tests/mac/DOMNodeFromJSObject.mm: Use adopt function instead of
adopt constructor.
* TestWebKitAPI/Tests/mac/JSWrapperForNodeInWebFrame.mm: Ditto.

* WebKitTestRunner/InjectedBundle/AccessibilityController.cpp:
Removed unneeded includes.
* WebKitTestRunner/InjectedBundle/AccessibilityTextMarker.cpp: Ditto.
* WebKitTestRunner/InjectedBundle/AccessibilityTextMarkerRange.cpp: Ditto.
* WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp: Ditto.

* WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm:
(_platformTypeConstructor): Use the adopt function instead of the
JSRetainPtr adopt constructor. Also nullptr instead of 0.

* WebKitTestRunner/InjectedBundle/EventSendingController.cpp:
(WTR::arrayLength): Use adopt function instead of constructor.
(WTR::parseModifierArray): Ditto.
* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::propertyValue): Ditto.
(WTR::dumpPath): Ditto.
(WTR::toJS): Ditto.
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::findString): Ditto.
(WTR::TestRunner::statisticsDidRunTelemetryCallback): Ditto.
(WTR::TestRunner::callDidReceiveAllStorageAccessEntriesCallback): Ditto.
(WTR::TestRunner::setOpenPanelFiles): Ditto.
* WebKitTestRunner/InjectedBundle/ios/AccessibilityControllerIOS.mm:
(WTR::AccessibilityController::platformName): Ditto.

* WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:
(-[NSString createJSStringRef]): Return a JSRetainPtr.
This fixes storage leaks in many functions below, which were using
the create function and putting the value right into a JSRetainPtr
without adoption.
(WTR::createEmptyJSString): Added. This helper function reduces the
repetitive code to create empty strings.
(WTR::concatenateAttributeAndValue): Return a JSRetainPtr.
(WTR::AccessibilityUIElement::attributesOfLinkedUIElements):
Use createEmptyJSString, fixing a storage leak due to missing adoption.
(WTR::AccessibilityUIElement::attributesOfDocumentLinks): Ditto.
(WTR::AccessibilityUIElement::attributesOfChildren): Ditto.
(WTR::AccessibilityUIElement::allAttributes): Ditto.
(WTR::AccessibilityUIElement::stringAttributeValue): Ditto.
(WTR::AccessibilityUIElement::parameterizedAttributeNames): Ditto.
(WTR::AccessibilityUIElement::role): Ditto.
(WTR::AccessibilityUIElement::subrole): Ditto.
(WTR::AccessibilityUIElement::roleDescription): Ditto.
(WTR::AccessibilityUIElement::computedRoleString): Ditto.
(WTR::AccessibilityUIElement::title): Ditto.
(WTR::AccessibilityUIElement::orientation const): Ditto.
(WTR::AccessibilityUIElement::language): Ditto.
(WTR::AccessibilityUIElement::valueDescription): Ditto.
(WTR::AccessibilityUIElement::ariaDropEffects const): Ditto.
(WTR::AccessibilityUIElement::boundsForRange): Ditto.
(WTR::AccessibilityUIElement::stringForRange): Removed unneeded null check.
(WTR::AccessibilityUIElement::attributedStringForRange): Ditto.
(WTR::AccessibilityUIElement::attributesOfColumnHeaders):
Use createEmptyJSString, fixing a storage leak due to missing adoption.
(WTR::AccessibilityUIElement::attributesOfRowHeaders): Ditto.
(WTR::AccessibilityUIElement::attributesOfColumns): Ditto.
(WTR::AccessibilityUIElement::attributesOfRows): Ditto.
(WTR::AccessibilityUIElement::attributesOfVisibleCells): Ditto.
(WTR::AccessibilityUIElement::attributesOfHeader): Ditto.
(WTR::AccessibilityUIElement::selectedTextRange): Ditto.
(WTR::AccessibilityUIElement::accessibilityValue const): Ditto.
(WTR::AccessibilityUIElement::documentEncoding): Ditto.
(WTR::AccessibilityUIElement::documentURI): Ditto.
(WTR::AccessibilityUIElement::stringForSelection): Removed unneeded
null check.
(WTR::AccessibilityUIElement::stringForTextMarkerRange):
Use createEmptyJSString, fixing a storage leak due to missing adoption.

* WebKitTestRunner/InjectedBundle/mac/AccessibilityCommonMac.h:
Use JSRetainPtr for the return value of createJSStringRef.
* WebKitTestRunner/InjectedBundle/mac/AccessibilityCommonMac.mm:
(-[NSString createJSStringRef]): Ditto.
(WTR::searchPredicateParameterizedAttributeForSearchCriteria): Use the
adopt function instead of the adopt constructor.
* WebKitTestRunner/InjectedBundle/mac/AccessibilityControllerMac.mm:
(WTR::AccessibilityController::platformName): Ditto

* WebKitTestRunner/InjectedBundle/mac/AccessibilityNotificationHandler.mm:
(-[NSString createJSStringRef]): Return a JSRetainPtr.
(makeValueRefForValue): Updated for above by removing adopt.
(makeObjectRefForDictionary): Ditto.
(-[AccessibilityNotificationHandler _notificationReceived:]): Ditto.

* WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
(WTR::createEmptyJSString): Added. This helper function makes reduces the
repetitive code to create empty strings.
(WTR::concatenateAttributeAndValue): Return a JSRetainPtr.
(WTR::descriptionOfElements): Ditto.
(WTR::selectTextParameterizedAttributeForCriteria): Ditto.
(WTR::AccessibilityUIElement::accessibilityValue const): Use createEmptyJSString,
fixing a storage leak due to missing adoption.
(WTR::AccessibilityUIElement::documentEncoding): Ditto.
(WTR::AccessibilityUIElement::documentURI): Ditto.
(WTR::createJSStringRef): Return a JSRetainPtr.

* WebKitTestRunner/StringFunctions.h:
(WTR::toWK): Take a const& to eliminate a little bit of reference count churn.
(WTR::toJS): Use the adopt function instead of the constructor.

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

60 files changed:
Source/JavaScriptCore/API/JSObjectRef.cpp
Source/JavaScriptCore/API/JSRetainPtr.h
Source/JavaScriptCore/API/JSValue.mm
Source/JavaScriptCore/API/tests/CustomGlobalObjectClassTest.c
Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp
Source/JavaScriptCore/API/tests/FunctionOverridesTest.cpp
Source/JavaScriptCore/API/tests/JSObjectGetProxyTargetTest.cpp
Source/JavaScriptCore/API/tests/PingPongStackOverflowTest.cpp
Source/JavaScriptCore/API/tests/testapi.c
Source/JavaScriptCore/ChangeLog
Source/WebCore/ChangeLog
Source/WebCore/Modules/plugins/QuickTimePluginReplacement.mm
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp
Tools/ChangeLog
Tools/DumpRenderTree/AccessibilityController.cpp
Tools/DumpRenderTree/AccessibilityTextMarker.cpp
Tools/DumpRenderTree/AccessibilityUIElement.cpp
Tools/DumpRenderTree/AccessibilityUIElement.h
Tools/DumpRenderTree/Bindings/CodeGeneratorDumpRenderTree.pm
Tools/DumpRenderTree/GCController.cpp
Tools/DumpRenderTree/TestRunner.cpp
Tools/DumpRenderTree/TestRunner.h
Tools/DumpRenderTree/ios/AccessibilityControllerIOS.mm
Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm
Tools/DumpRenderTree/mac/AccessibilityCommonMac.h
Tools/DumpRenderTree/mac/AccessibilityCommonMac.mm
Tools/DumpRenderTree/mac/AccessibilityControllerMac.mm
Tools/DumpRenderTree/mac/AccessibilityNotificationHandler.mm
Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm
Tools/DumpRenderTree/mac/FrameLoadDelegate.mm
Tools/DumpRenderTree/mac/TestRunnerMac.mm
Tools/DumpRenderTree/win/AccessibilityControllerWin.cpp
Tools/DumpRenderTree/win/AccessibilityUIElementWin.cpp
Tools/DumpRenderTree/win/TestRunnerWin.cpp
Tools/TestRunnerShared/Bindings/JSWrapper.h
Tools/TestRunnerShared/UIScriptContext/UIScriptContext.cpp
Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp
Tools/TestRunnerShared/cocoa/LayoutTestSpellChecker.mm
Tools/TestWebKitAPI/JavaScriptTest.cpp
Tools/TestWebKitAPI/Tests/WebKit/WKPageIsPlayingAudio.cpp
Tools/TestWebKitAPI/Tests/WebKitCocoa/PictureInPictureDelegate.mm
Tools/TestWebKitAPI/Tests/mac/DOMNodeFromJSObject.mm
Tools/TestWebKitAPI/Tests/mac/JSWrapperForNodeInWebFrame.mm
Tools/WebKitTestRunner/InjectedBundle/AccessibilityController.cpp
Tools/WebKitTestRunner/InjectedBundle/AccessibilityTextMarker.cpp
Tools/WebKitTestRunner/InjectedBundle/AccessibilityTextMarkerRange.cpp
Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp
Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm
Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp
Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityControllerIOS.mm
Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm
Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityCommonMac.h
Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityCommonMac.mm
Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityControllerMac.mm
Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityNotificationHandler.mm
Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm
Tools/WebKitTestRunner/StringFunctions.h

index 694d185..4c201f8 100644 (file)
@@ -46,7 +46,6 @@
 #include "JSFunction.h"
 #include "JSGlobalObject.h"
 #include "JSObject.h"
-#include "JSRetainPtr.h"
 #include "JSString.h"
 #include "JSValueRef.h"
 #include "ObjectConstructor.h"
@@ -763,6 +762,7 @@ JSObjectRef JSObjectCallAsConstructor(JSContextRef ctx, JSObjectRef object, size
 struct OpaqueJSPropertyNameArray {
     WTF_MAKE_FAST_ALLOCATED;
 public:
+    // FIXME: Why not inherit from RefCounted?
     OpaqueJSPropertyNameArray(VM* vm)
         : refCount(0)
         , vm(vm)
@@ -771,7 +771,7 @@ public:
     
     unsigned refCount;
     VM* vm;
-    Vector<JSRetainPtr<JSStringRef>> array;
+    Vector<Ref<OpaqueJSString>> array;
 };
 
 JSPropertyNameArrayRef JSObjectCopyPropertyNames(JSContextRef ctx, JSObjectRef object)
@@ -793,8 +793,8 @@ JSPropertyNameArrayRef JSObjectCopyPropertyNames(JSContextRef ctx, JSObjectRef o
     size_t size = array.size();
     propertyNames->array.reserveInitialCapacity(size);
     for (size_t i = 0; i < size; ++i)
-        propertyNames->array.uncheckedAppend(JSRetainPtr<JSStringRef>(Adopt, OpaqueJSString::create(array[i].string()).leakRef()));
-    
+        propertyNames->array.uncheckedAppend(OpaqueJSString::create(array[i].string()).releaseNonNull());
+
     return JSPropertyNameArrayRetain(propertyNames);
 }
 
@@ -819,7 +819,7 @@ size_t JSPropertyNameArrayGetCount(JSPropertyNameArrayRef array)
 
 JSStringRef JSPropertyNameArrayGetNameAtIndex(JSPropertyNameArrayRef array, size_t index)
 {
-    return array->array[static_cast<unsigned>(index)].get();
+    return array->array[static_cast<unsigned>(index)].ptr();
 }
 
 void JSPropertyNameAccumulatorAddName(JSPropertyNameAccumulatorRef array, JSStringRef propertyName)
index e400840..fd8412f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005, 2006, 2007, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -26,8 +26,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef JSRetainPtr_h
-#define JSRetainPtr_h
+#pragma once
 
 #include <JavaScriptCore/JSContextRef.h>
 #include <JavaScriptCore/JSStringRef.h>
@@ -42,17 +41,16 @@ enum AdoptTag { Adopt };
 
 template<typename T> class JSRetainPtr {
 public:
-    JSRetainPtr() : m_ptr(0) { }
+    JSRetainPtr() = default;
     JSRetainPtr(T ptr) : m_ptr(ptr) { if (ptr) JSRetain(ptr); }
-    JSRetainPtr(AdoptTag, T ptr) : m_ptr(ptr) { }
     JSRetainPtr(const JSRetainPtr&);
-    template<typename U> JSRetainPtr(const JSRetainPtr<U>&);
+    JSRetainPtr(JSRetainPtr&&);
     ~JSRetainPtr();
     
     T get() const { return m_ptr; }
     
     void clear();
-    T leakRef();
+    T leakRef() WARN_UNUSED_RETURN;
 
     T operator->() const { return m_ptr; }
     
@@ -60,18 +58,30 @@ public:
     explicit operator bool() const { return m_ptr; }
 
     JSRetainPtr& operator=(const JSRetainPtr&);
-    template<typename U> JSRetainPtr& operator=(const JSRetainPtr<U>&);
+    JSRetainPtr& operator=(JSRetainPtr&&);
     JSRetainPtr& operator=(T);
-    template<typename U> JSRetainPtr& operator=(U*);
 
-    void adopt(T);
-    
     void swap(JSRetainPtr&);
 
+    friend JSRetainPtr<JSStringRef> adopt(JSStringRef);
+    friend JSRetainPtr<JSGlobalContextRef> adopt(JSGlobalContextRef);
+
+    // FIXME: Make this private once Apple's internal code is updated to not rely on it.
+    // https://bugs.webkit.org/show_bug.cgi?id=189644
+    JSRetainPtr(AdoptTag, T);
+
 private:
-    T m_ptr;
+    T m_ptr { nullptr };
 };
 
+JSRetainPtr<JSStringRef> adopt(JSStringRef);
+JSRetainPtr<JSGlobalContextRef> adopt(JSGlobalContextRef);
+
+template<typename T> inline JSRetainPtr<T>::JSRetainPtr(AdoptTag, T ptr)
+    : m_ptr(ptr)
+{
+}
+
 inline JSRetainPtr<JSStringRef> adopt(JSStringRef o)
 {
     return JSRetainPtr<JSStringRef>(Adopt, o);
@@ -89,11 +99,9 @@ template<typename T> inline JSRetainPtr<T>::JSRetainPtr(const JSRetainPtr& o)
         JSRetain(m_ptr);
 }
 
-template<typename T> template<typename U> inline JSRetainPtr<T>::JSRetainPtr(const JSRetainPtr<U>& o)
-    : m_ptr(o.get())
+template<typename T> inline JSRetainPtr<T>::JSRetainPtr(JSRetainPtr&& o)
+    : m_ptr(o.leakRef())
 {
-    if (m_ptr)
-        JSRetain(m_ptr);
 }
 
 template<typename T> inline JSRetainPtr<T>::~JSRetainPtr()
@@ -104,39 +112,23 @@ template<typename T> inline JSRetainPtr<T>::~JSRetainPtr()
 
 template<typename T> inline void JSRetainPtr<T>::clear()
 {
-    if (T ptr = m_ptr) {
-        m_ptr = 0;
+    if (T ptr = leakRef())
         JSRelease(ptr);
-    }
 }
 
 template<typename T> inline T JSRetainPtr<T>::leakRef()
 {
-    T ptr = m_ptr;
-    m_ptr = 0;
-    return ptr;
+    return std::exchange(m_ptr, nullptr);
 }
 
 template<typename T> inline JSRetainPtr<T>& JSRetainPtr<T>::operator=(const JSRetainPtr<T>& o)
 {
-    T optr = o.get();
-    if (optr)
-        JSRetain(optr);
-    T ptr = m_ptr;
-    m_ptr = optr;
-    if (ptr)
-        JSRelease(ptr);
-    return *this;
+    return operator=(o.get());
 }
 
-template<typename T> template<typename U> inline JSRetainPtr<T>& JSRetainPtr<T>::operator=(const JSRetainPtr<U>& o)
+template<typename T> inline JSRetainPtr<T>& JSRetainPtr<T>::operator=(JSRetainPtr&& o)
 {
-    T optr = o.get();
-    if (optr)
-        JSRetain(optr);
-    T ptr = m_ptr;
-    m_ptr = optr;
-    if (ptr)
+    if (T ptr = std::exchange(m_ptr, o.leakRef()))
         JSRelease(ptr);
     return *this;
 }
@@ -145,28 +137,7 @@ template<typename T> inline JSRetainPtr<T>& JSRetainPtr<T>::operator=(T optr)
 {
     if (optr)
         JSRetain(optr);
-    T ptr = m_ptr;
-    m_ptr = optr;
-    if (ptr)
-        JSRelease(ptr);
-    return *this;
-}
-
-template<typename T> inline void JSRetainPtr<T>::adopt(T optr)
-{
-    T ptr = m_ptr;
-    m_ptr = optr;
-    if (ptr)
-        JSRelease(ptr);
-}
-
-template<typename T> template<typename U> inline JSRetainPtr<T>& JSRetainPtr<T>::operator=(U* optr)
-{
-    if (optr)
-        JSRetain(optr);
-    T ptr = m_ptr;
-    m_ptr = optr;
-    if (ptr)
+    if (T ptr = std::exchange(m_ptr, optr))
         JSRelease(ptr);
     return *this;
 }
@@ -210,6 +181,3 @@ template<typename T, typename U> inline bool operator!=(T* a, const JSRetainPtr<
 { 
     return a != b.get(); 
 }
-
-
-#endif // JSRetainPtr_h
index df45fc0..9e49ae2 100644 (file)
@@ -154,8 +154,10 @@ NSString * const JSPropertyDescriptorSetKey = @"set";
 
 + (JSValue *)valueWithNewSymbolFromDescription:(NSString *)description inContext:(JSContext *)context
 {
-    JSStringRef string = JSStringCreateWithCFString(reinterpret_cast<CFStringRef>(description));
-    return [JSValue valueWithJSValueRef:JSValueMakeSymbol([context JSGlobalContextRef], string) inContext:context];
+    JSStringRef string = JSStringCreateWithCFString((__bridge CFStringRef)description);
+    auto value = [JSValue valueWithJSValueRef:JSValueMakeSymbol([context JSGlobalContextRef], string) inContext:context];
+    JSStringRelease(string);
+    return value;
 }
 
 
index 9ffe233..82d2dc1 100644 (file)
@@ -101,6 +101,8 @@ void customGlobalObjectClassTest()
     JSStringRelease(script);
 
     assertTrue(executedCallback, "Executed custom global object callback");
+
+    JSGlobalContextRelease(globalContext);
 }
 
 void globalObjectSetPrototypeTest()
@@ -116,6 +118,7 @@ void globalObjectSetPrototypeTest()
     JSObjectSetPrototype(context, object, above);
     JSValueRef prototypeAfterChangingAttempt = JSObjectGetPrototype(context, object);
     assertTrue(JSValueIsStrictEqual(context, prototypeAfterChangingAttempt, originalPrototype), "Global object's [[Prototype]] cannot be changed after instantiating it");
+    JSGlobalContextRelease(context);
 }
 
 void globalObjectPrivatePropertyTest()
@@ -137,4 +140,5 @@ void globalObjectPrivatePropertyTest()
     assertTrue(JSValueIsNull(context, result), "Deleted private property is indeed no longer present");
 
     JSStringRelease(privateName);
+    JSGlobalContextRelease(context);
 }
index 637b304..ac8010a 100644 (file)
@@ -106,6 +106,7 @@ static void testResetAfterTimeout(bool& failed)
     const char* reentryScript = "100";
     JSStringRef script = JSStringCreateWithUTF8CString(reentryScript);
     v = JSEvaluateScript(context, script, nullptr, nullptr, 1, &exception);
+    JSStringRelease(script);
     if (exception) {
         printf("FAIL: Watchdog timeout was not reset.\n");
         failed = true;
@@ -181,6 +182,8 @@ int testExecutionTimeLimit()
 
             thread->waitForCompletion();
             testResetAfterTimeout(failed);
+
+            JSStringRelease(script);
         }
 
         /* Test script timeout: */
@@ -200,6 +203,7 @@ int testExecutionTimeLimit()
             auto startTime = CPUTime::forCurrentThread();
             JSEvaluateScript(context, script, nullptr, nullptr, 1, &exception);
             auto endTime = CPUTime::forCurrentThread();
+            JSStringRelease(script);
 
             if (((endTime - startTime) < timeAfterWatchdogShouldHaveFired) && shouldTerminateCallbackWasCalled)
                 printf("PASS: %s script timed out as expected.\n", tierOptions.tier);
@@ -243,6 +247,7 @@ int testExecutionTimeLimit()
             auto startTime = CPUTime::forCurrentThread();
             JSEvaluateScript(context, script, nullptr, nullptr, 1, &exception);
             auto endTime = CPUTime::forCurrentThread();
+            JSStringRelease(script);
 
             if (((endTime - startTime) < timeAfterWatchdogShouldHaveFired) && shouldTerminateCallbackWasCalled)
                 printf("PASS: %s script with infinite tail calls timed out as expected .\n", tierOptions.tier);
@@ -281,6 +286,8 @@ int testExecutionTimeLimit()
             JSEvaluateScript(context, script, nullptr, nullptr, 1, &exception);
             auto endTime = CPUTime::forCurrentThread();
             
+            JSStringRelease(script);
+
             if (((endTime - startTime) >= timeAfterWatchdogShouldHaveFired) || !shouldTerminateCallbackWasCalled) {
                 if (!((endTime - startTime) < timeAfterWatchdogShouldHaveFired))
                     printf("FAIL: %s script did not time out as expected.\n", tierOptions.tier);
@@ -318,6 +325,8 @@ int testExecutionTimeLimit()
             JSEvaluateScript(context, script, nullptr, nullptr, 1, &exception);
             auto endTime = CPUTime::forCurrentThread();
             
+            JSStringRelease(script);
+
             if (((endTime - startTime) < timeAfterWatchdogShouldHaveFired) && !shouldTerminateCallbackWasCalled)
                 printf("PASS: %s script timed out as expected when no callback is specified.\n", tierOptions.tier);
             else {
@@ -355,6 +364,8 @@ int testExecutionTimeLimit()
             JSEvaluateScript(context, script, nullptr, nullptr, 1, &exception);
             auto endTime = CPUTime::forCurrentThread();
             
+            JSStringRelease(script);
+
             if (((endTime - startTime) >= timeAfterWatchdogShouldHaveFired) && cancelTerminateCallbackWasCalled && !exception)
                 printf("PASS: %s script timeout was cancelled as expected.\n", tierOptions.tier);
             else {
@@ -393,6 +404,8 @@ int testExecutionTimeLimit()
             auto endTime = CPUTime::forCurrentThread();
             auto deltaTime = endTime - startTime;
             
+            JSStringRelease(script);
+
             if ((deltaTime >= timeBeforeExtendedDeadline) && (deltaTime < timeAfterExtendedDeadline) && (extendTerminateCallbackCalled == 2) && exception)
                 printf("PASS: %s script timeout was extended as expected.\n", tierOptions.tier);
             else {
@@ -469,6 +482,8 @@ int testExecutionTimeLimit()
                     printf("FAIL: %s script on dispatch queue timeout callback was not called.\n", tierOptions.tier);
                 failed = true;
             }
+
+            JSStringRelease(script);
         }
 #endif
 
index cf0d6dc..8389615 100644 (file)
@@ -76,6 +76,7 @@ int testFunctionOverrides()
     JSStringRef script = JSStringCreateWithUTF8CString(scriptString);
     JSValueRef exception = nullptr;
     JSValueRef resultRef = JSEvaluateScript(context, script, nullptr, nullptr, 1, &exception);
+    JSStringRelease(script);
 
     if (!JSValueIsBoolean(context, resultRef) || !JSValueToBoolean(context, resultRef))
         failed = true;
index 7f2c3fe..71821ea 100644 (file)
@@ -49,7 +49,7 @@ int testJSObjectGetProxyTarget()
     };
     
     JSContextGroupRef group = JSContextGroupCreate();
-    JSContextRef context = JSGlobalContextCreateInGroup(group, nullptr);
+    JSGlobalContextRef context = JSGlobalContextCreateInGroup(group, nullptr);
     
     ExecState* exec = toJS(context);
     VM& vm = *toJS(group);
@@ -96,7 +96,8 @@ int testJSObjectGetProxyTarget()
     test("proxy target of ProxyObject works", JSObjectGetProxyTarget(proxyObject) == array);
     
     test("proxy target of GlobalObject is the globalObject", JSObjectGetProxyTarget(globalObjectProxy) == globalObject);
-    
+
+    JSGlobalContextRelease(context);
     JSContextGroupRelease(group);
 
     printf("JSObjectGetProxyTargetTest: %s\n", overallResult ? "PASS" : "FAIL");
index 042bebf..fbe4687 100644 (file)
@@ -162,6 +162,10 @@ int testPingPongStackOverflow()
     exception = nullptr;
     JSEvaluateScript(context, script, nullptr, nullptr, 1, &exception);
 
+    JSGlobalContextRelease(context);
+    context = nullptr;
+    JSStringRelease(script);
+
     if (!exception) {
         printf("FAIL: PingPongStackOverflowError not thrown in PingPongStackOverflow test\n");
         failed = true;
index 78ad7d6..8ba0449 100644 (file)
@@ -201,6 +201,16 @@ static bool MyObject_hasProperty(JSContextRef context, JSObjectRef object, JSStr
     return false;
 }
 
+static JSValueRef throwException(JSContextRef context, JSObjectRef object, JSValueRef* exception)
+{
+    JSStringRef script = JSStringCreateWithUTF8CString("throw 'an exception'");
+    JSStringRef sourceURL = JSStringCreateWithUTF8CString("test script");
+    JSValueRef result = JSEvaluateScript(context, script, object, sourceURL, 1, exception);
+    JSStringRelease(script);
+    JSStringRelease(sourceURL);
+    return result;
+}
+
 static JSValueRef MyObject_getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
 {
     UNUSED_PARAM(context);
@@ -223,7 +233,7 @@ static JSValueRef MyObject_getProperty(JSContextRef context, JSObjectRef object,
     }
 
     if (JSStringIsEqualToUTF8CString(propertyName, "throwOnGet")) {
-        return JSEvaluateScript(context, JSStringCreateWithUTF8CString("throw 'an exception'"), object, JSStringCreateWithUTF8CString("test script"), 1, exception);
+        return throwException(context, object, exception);
     }
 
     if (JSStringIsEqualToUTF8CString(propertyName, "0")) {
@@ -245,7 +255,7 @@ static bool MyObject_setProperty(JSContextRef context, JSObjectRef object, JSStr
         return true; // pretend we set the property in order to swallow it
     
     if (JSStringIsEqualToUTF8CString(propertyName, "throwOnSet")) {
-        JSEvaluateScript(context, JSStringCreateWithUTF8CString("throw 'an exception'"), object, JSStringCreateWithUTF8CString("test script"), 1, exception);
+        throwException(context, object, exception);
     }
     
     return false;
@@ -260,7 +270,7 @@ static bool MyObject_deleteProperty(JSContextRef context, JSObjectRef object, JS
         return true;
     
     if (JSStringIsEqualToUTF8CString(propertyName, "throwOnDelete")) {
-        JSEvaluateScript(context, JSStringCreateWithUTF8CString("throw 'an exception'"), object, JSStringCreateWithUTF8CString("test script"), 1, exception);
+        throwException(context, object, exception);
         return false;
     }
 
@@ -283,6 +293,18 @@ static void MyObject_getPropertyNames(JSContextRef context, JSObjectRef object,
     JSStringRelease(propertyName);
 }
 
+static bool isValueEqualToString(JSContextRef context, JSValueRef value, const char* string)
+{
+    if (!JSValueIsString(context, value))
+        return false;
+    JSStringRef valueString = JSValueToStringCopy(context, value, NULL);
+    if (!valueString)
+        return false;
+    bool isEqual = JSStringIsEqualToUTF8CString(valueString, string);
+    JSStringRelease(valueString);
+    return isEqual;
+}
+
 static JSValueRef MyObject_callAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     UNUSED_PARAM(context);
@@ -290,8 +312,8 @@ static JSValueRef MyObject_callAsFunction(JSContextRef context, JSObjectRef obje
     UNUSED_PARAM(thisObject);
     UNUSED_PARAM(exception);
 
-    if (argumentCount > 0 && JSValueIsString(context, arguments[0]) && JSStringIsEqualToUTF8CString(JSValueToStringCopy(context, arguments[0], 0), "throwOnCall")) {
-        JSEvaluateScript(context, JSStringCreateWithUTF8CString("throw 'an exception'"), object, JSStringCreateWithUTF8CString("test script"), 1, exception);
+    if (argumentCount > 0 && isValueEqualToString(context, arguments[0], "throwOnCall")) {
+        throwException(context, object, exception);
         return JSValueMakeUndefined(context);
     }
 
@@ -306,8 +328,8 @@ static JSObjectRef MyObject_callAsConstructor(JSContextRef context, JSObjectRef
     UNUSED_PARAM(context);
     UNUSED_PARAM(object);
 
-    if (argumentCount > 0 && JSValueIsString(context, arguments[0]) && JSStringIsEqualToUTF8CString(JSValueToStringCopy(context, arguments[0], 0), "throwOnConstruct")) {
-        JSEvaluateScript(context, JSStringCreateWithUTF8CString("throw 'an exception'"), object, JSStringCreateWithUTF8CString("test script"), 1, exception);
+    if (argumentCount > 0 && isValueEqualToString(context, arguments[0], "throwOnConstruct")) {
+        throwException(context, object, exception);
         return object;
     }
 
@@ -322,8 +344,8 @@ static bool MyObject_hasInstance(JSContextRef context, JSObjectRef constructor,
     UNUSED_PARAM(context);
     UNUSED_PARAM(constructor);
 
-    if (JSValueIsString(context, possibleValue) && JSStringIsEqualToUTF8CString(JSValueToStringCopy(context, possibleValue, 0), "throwOnHasInstance")) {
-        JSEvaluateScript(context, JSStringCreateWithUTF8CString("throw 'an exception'"), constructor, JSStringCreateWithUTF8CString("test script"), 1, exception);
+    if (isValueEqualToString(context, possibleValue, "throwOnHasInstance")) {
+        throwException(context, constructor, exception);
         return false;
     }
 
@@ -1137,6 +1159,8 @@ static bool globalContextNameTest()
     JSStringRelease(fetchName1);
     JSStringRelease(fetchName2);
 
+    JSGlobalContextRelease(context);
+
     return result;
 }
 
@@ -1191,7 +1215,6 @@ static void heapFinalizer(JSContextGroupRef group, void *userData)
 static void testMarkingConstraintsAndHeapFinalizers(void)
 {
     JSContextGroupRef group;
-    JSContextRef context;
     JSWeakRef *weakRefs;
     unsigned i;
     unsigned deadCount;
@@ -1201,7 +1224,7 @@ static void testMarkingConstraintsAndHeapFinalizers(void)
     group = JSContextGroupCreate();
     expectedContextGroup = group;
     
-    context = JSGlobalContextCreateInGroup(group, NULL);
+    JSGlobalContextRef context = JSGlobalContextCreateInGroup(group, NULL);
 
     weakRefs = (JSWeakRef*)calloc(numWeakRefs, sizeof(JSWeakRef));
 
@@ -1238,7 +1261,8 @@ static void testMarkingConstraintsAndHeapFinalizers(void)
     didRunHeapFinalizer = false;
     JSSynchronousGarbageCollectForDebugging(context);
     assertTrue(!didRunHeapFinalizer, "Did not run heap finalizer");
-    
+
+    JSGlobalContextRelease(context);
     JSContextGroupRelease(group);
 
     printf("PASS: Marking Constraints and Heap Finalizers.\n");
index 66cb764..bafeb6e 100644 (file)
@@ -1,3 +1,73 @@
+2018-09-08  Darin Adler  <darin@apple.com>
+
+        Streamline JSRetainPtr, fix leaks of JSString and JSGlobalContext
+        https://bugs.webkit.org/show_bug.cgi?id=189455
+
+        Reviewed by Keith Miller.
+
+        * API/JSObjectRef.cpp:
+        (OpaqueJSPropertyNameArray): Use Ref<OpaqueJSString> instead of
+        JSRetainPtr<JSStringRef>.
+        (JSObjectCopyPropertyNames): Remove now-unneeded use of leakRef and
+        adopt constructor.
+        (JSPropertyNameArrayGetNameAtIndex): Use ptr() instead of get() since
+        the array elements are now Ref.
+
+        * API/JSRetainPtr.h: While JSRetainPtr is written as a template,
+        it only works for two specific unrelated types, JSStringRef and
+        JSGlobalContextRef. Simplified the default constructor using data
+        member initialization. Prepared to make the adopt constructor private
+        (got everything compiling that way, then made it public again so that
+        Apple internal software will still build). Got rid of unneeded
+        templated constructor and assignment operator, since it's not relevant
+        since there is no inheritance between JSRetainPtr template types.
+        Added WARN_UNUSED_RETURN to leakRef as in RefPtr and RetainPtr.
+        Added move constructor and move assignment operator for slightly better
+        performance. Simplified implementations of various member functions
+        so they are more obviously correct, by using leakPtr in more of them
+        and using std::exchange to make the flow of values more obvious.
+
+        * API/JSValue.mm:
+        (+[JSValue valueWithNewSymbolFromDescription:inContext:]): Added a
+        missing JSStringRelease to fix a leak.
+
+        * API/tests/CustomGlobalObjectClassTest.c:
+        (customGlobalObjectClassTest): Added a JSGlobalContextRelease to fix a leak.
+        (globalObjectSetPrototypeTest): Ditto.
+        (globalObjectPrivatePropertyTest): Ditto.
+
+        * API/tests/ExecutionTimeLimitTest.cpp:
+        (testResetAfterTimeout): Added a call to JSStringRelease to fix a leak.
+        (testExecutionTimeLimit): Ditto, lots more.
+
+        * API/tests/FunctionOverridesTest.cpp:
+        (testFunctionOverrides): Added a call to JSStringRelease to fix a leak.
+
+        * API/tests/JSObjectGetProxyTargetTest.cpp:
+        (testJSObjectGetProxyTarget): Added a call to JSGlobalContextRelease to fix
+        a leak.
+
+        * API/tests/PingPongStackOverflowTest.cpp:
+        (testPingPongStackOverflow): Added calls to JSGlobalContextRelease and
+        JSStringRelease to fix leaks.
+
+        * API/tests/testapi.c:
+        (throwException): Added. Helper function for repeated idiom where we want
+        to throw an exception, but with additional JSStringRelease calls so we don't
+        have to leak just to keep the code simpler to read.
+        (MyObject_getProperty): Use throwException.
+        (MyObject_setProperty): Ditto.
+        (MyObject_deleteProperty): Ditto.
+        (isValueEqualToString): Added. Helper function for an idiom where we check
+        if something is a string and then if it's equal to a particular string
+        constant, but a version that has an additional JSStringRelease call so we
+        don't have to leak just to keep the code simpler to read.
+        (MyObject_callAsFunction): Use isValueEqualToString and throwException.
+        (MyObject_callAsConstructor): Ditto.
+        (MyObject_hasInstance): Ditto.
+        (globalContextNameTest): Added a JSGlobalContextRelease to fix a leak.
+        (testMarkingConstraintsAndHeapFinalizers): Ditto.
+
 2018-09-14  Saam barati  <sbarati@apple.com>
 
         Don't dump OSRAvailabilityData in Graph::dump because a stale Availability may point to a Node that is already freed
index 09f4761..82ada9d 100644 (file)
@@ -1,3 +1,14 @@
+2018-09-08  Darin Adler  <darin@apple.com>
+
+        Streamline JSRetainPtr, fix leaks of JSString and JSGlobalContext
+        https://bugs.webkit.org/show_bug.cgi?id=189455
+
+        Reviewed by Keith Miller.
+
+        * Modules/plugins/QuickTimePluginReplacement.mm:
+        (WebCore::jsValueWithDictionaryInContext): Adding a missing
+        JSStringRelease to fix a leak.
+
 2018-09-15  Rob Buis  <rbuis@igalia.com>
 
         XMLHttpRequest::createResponseBlob() should create a Blob with type for empty response
index 3dfd97b..ca34d81 100644 (file)
@@ -308,8 +308,9 @@ static JSValue *jsValueWithDictionaryInContext(NSDictionary *dictionary, JSConte
         if (!value)
             continue;
 
-        JSStringRef name = JSStringCreateWithCFString((CFStringRef)key);
+        JSStringRef name = JSStringCreateWithCFString((__bridge CFStringRef)key);
         JSObjectSetProperty([context JSGlobalContextRef], resultObject, name, [value JSValueRef], 0, &exception);
+        JSStringRelease(name);
         if (exception)
             continue;
     }
index 54441d4..ad6ed53 100644 (file)
@@ -1,3 +1,16 @@
+2018-09-08  Darin Adler  <darin@apple.com>
+
+        Streamline JSRetainPtr, fix leaks of JSString and JSGlobalContext
+        https://bugs.webkit.org/show_bug.cgi?id=189455
+
+        Reviewed by Keith Miller.
+
+        * WebProcess/Automation/WebAutomationSessionProxy.cpp:
+        (WebKit::toJSString): Use adopt function instead of adopt construuctor.
+        (WebKit::evaluate): Ditto.
+        (WebKit::evaluateJavaScriptCallback): Ditto.
+        (WebKit::WebAutomationSessionProxy::evaluateJavaScriptFunction): Ditto.
+
 2018-09-14  Matt Lewis  <jlewis3@apple.com>
 
         Unreviewed, rolling out r236020.
index dd978b0..fa6df2a 100644 (file)
@@ -89,7 +89,7 @@ static JSObjectRef toJSArray(JSContextRef context, const Vector<T>& data, JSValu
 
 static inline JSRetainPtr<JSStringRef> toJSString(const String& string)
 {
-    return JSRetainPtr<JSStringRef>(Adopt, OpaqueJSString::create(string).leakRef());
+    return adopt(OpaqueJSString::create(string).leakRef());
 }
 
 static inline JSValueRef toJSValue(JSContextRef context, const String& string)
@@ -127,7 +127,7 @@ static JSValueRef evaluate(JSContextRef context, JSObjectRef function, JSObjectR
     if (argumentCount != 1)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto script = adopt(JSValueToStringCopy(context, arguments[0], exception));
     return JSEvaluateScript(context, script.get(), nullptr, nullptr, 0, exception);
 }
 
@@ -150,7 +150,7 @@ static JSValueRef evaluateJavaScriptCallback(JSContextRef context, JSObjectRef f
 
     uint64_t frameID = JSValueToNumber(context, arguments[0], exception);
     uint64_t callbackID = JSValueToNumber(context, arguments[1], exception);
-    JSRetainPtr<JSStringRef> result(Adopt, JSValueToStringCopy(context, arguments[2], exception));
+    auto result = adopt(JSValueToStringCopy(context, arguments[2], exception));
 
     bool resultIsErrorName = JSValueToBoolean(context, arguments[3]);
 
@@ -287,7 +287,7 @@ void WebAutomationSessionProxy::evaluateJavaScriptFunction(uint64_t pageID, uint
     JSRetainPtr<JSStringRef> exceptionMessage;
     if (JSValueIsObject(context, exception)) {
         JSValueRef nameValue = JSObjectGetProperty(context, const_cast<JSObjectRef>(exception), toJSString("name"_s).get(), nullptr);
-        JSRetainPtr<JSStringRef> exceptionName(Adopt, JSValueToStringCopy(context, nameValue, nullptr));
+        auto exceptionName = adopt(JSValueToStringCopy(context, nameValue, nullptr));
         if (exceptionName->string() == "NodeNotFound")
             errorType = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::NodeNotFound);
         else if (exceptionName->string() == "InvalidElementState")
@@ -298,9 +298,9 @@ void WebAutomationSessionProxy::evaluateJavaScriptFunction(uint64_t pageID, uint
             errorType = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::InvalidSelector);
 
         JSValueRef messageValue = JSObjectGetProperty(context, const_cast<JSObjectRef>(exception), toJSString("message"_s).get(), nullptr);
-        exceptionMessage.adopt(JSValueToStringCopy(context, messageValue, nullptr));
+        exceptionMessage = adopt(JSValueToStringCopy(context, messageValue, nullptr));
     } else
-        exceptionMessage.adopt(JSValueToStringCopy(context, exception, nullptr));
+        exceptionMessage = adopt(JSValueToStringCopy(context, exception, nullptr));
 
     didEvaluateJavaScriptFunction(frameID, callbackID, exceptionMessage->string(), errorType);
 }
index 9451030..c21d76a 100644 (file)
@@ -1,3 +1,467 @@
+2018-09-08  Darin Adler  <darin@apple.com>
+
+        Streamline JSRetainPtr, fix leaks of JSString and JSGlobalContext
+        https://bugs.webkit.org/show_bug.cgi?id=189455
+
+        Reviewed by Keith Miller.
+
+        There is a lot of copied and pasted code for WebKit vs. Legacy WebKit
+        testing and even for macOS vs. iOS vs. Windows platform-specific code.
+        For now, this patch just makes corresponding changes to the copied code.
+        Later we might get better results by merging more code instead of having
+        all these separate copies.
+
+        * DumpRenderTree/AccessibilityController.cpp:
+        (AccessibilityController::makeWindowObject): Use the adopt function
+        instead of the special Adopt constructor of JSRetainPtr.
+
+        * DumpRenderTree/AccessibilityTextMarker.cpp: Removed unneeded include.
+
+        * DumpRenderTree/AccessibilityUIElement.cpp: Ditto.
+        (allAttributesCallback): Don't adopt at this level; changed the
+        underlying function to return a JSRetainPtr so the adopt is right next
+        to the call to the create or copy function.
+        (attributesOfLinkedUIElementsCallback): Ditto.
+        (attributesOfDocumentLinksCallback): Ditto.
+        (attributesOfChildrenCallback): Ditto.
+        (parameterizedAttributeNamesCallback): Ditto.
+        (attributesOfColumnHeadersCallback): Ditto.
+        (attributesOfRowHeadersCallback): Ditto.
+        (attributesOfColumnsCallback): Ditto.
+        (attributesOfRowsCallback): Ditto.
+        (attributesOfVisibleCellsCallback): Ditto.
+        (attributesOfHeaderCallback): Ditto.
+        (rowIndexRangeCallback): Ditto.
+        (columnIndexRangeCallback): Ditto.
+        (rangeForLineCallback): Ditto.
+        (boundsForRangeCallback): Ditto.
+        (rangeForPositionCallback): Ditto.
+        (stringForRangeCallback): Ditto.
+        (attributedStringForRangeCallback): Ditto.
+        (uiElementCountForSearchPredicateCallback): Use the free adopt
+        function instead of the adopt member function.
+        (uiElementForSearchPredicateCallback): Ditto.
+        (selectTextWithCriteriaCallback): Don't adopt at this level.
+        (attributedStringForElementCallback): Ditto.
+        (setValueCallback): Use free adopt.
+        (stringAttributeValueCallback): Don't adopt at this level.
+        (uiElementArrayAttributeValueCallback): Ditto.
+        (uiElementAttributeValueCallback): Ditto.
+        (stringForTextMarkerRangeCallback): Ditto.
+        (attributedStringForTextMarkerRangeCallback): Ditto.
+        (attributedStringForTextMarkerRangeWithOptionsCallback): Ditto.
+        (getARIADropEffectsCallback): Ditto.
+        (getClassListCallback): Ditto.
+        (getRoleCallback): Ditto.
+        (getSubroleCallback): Ditto.
+        (getRoleDescriptionCallback): Ditto.
+        (getComputedRoleStringCallback): Ditto.
+        (getTitleCallback): Ditto.
+        (getDescriptionCallback): Ditto.
+        (getStringValueCallback): Ditto.
+        (getLanguageCallback): Ditto.
+        (getHelpTextCallback): Ditto.
+        (getOrientationCallback): Ditto.
+        (getPathDescriptionCallback): Ditto.
+        (getSelectedTextRangeCallback): Ditto.
+        (speakAsCallback): Ditto.
+        (getValueDescriptionCallback): Ditto.
+        (getAccessibilityValueCallback): Ditto.
+        (getDocumentEncodingCallback): Ditto.
+        (getDocumentURICallback): Ditto.
+        (getURLCallback): Ditto.
+        (characterAtOffsetCallback): Ditto.
+        (wordAtOffsetCallback): Ditto.
+        (lineAtOffsetCallback): Ditto.
+        (sentenceAtOffsetCallback): Ditto.
+        (stringForSelectionCallback): Ditto.
+        (getIdentifierCallback): Ditto.
+        (getTraitsCallback): Ditto.
+        (supportedActionsCallback): Ditto.
+        (mathPostscriptsDescriptionCallback): Ditto.
+        (mathPrescriptsDescriptionCallback): Ditto.
+        (AccessibilityUIElement::rangeForLine): Updated to return JSRetainPtr.
+        (AccessibilityUIElement::rangeForPosition): Ditto.
+        (AccessibilityUIElement::speakAs): Ditto.
+        (AccessibilityUIElement::pathDescription const): Ditto.
+        (AccessibilityUIElement::stringForTextMarkerRange): Ditto.
+        (AccessibilityUIElement::attributedStringForTextMarkerRange): Ditto.
+        (AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions): Ditto.
+
+        * DumpRenderTree/AccessibilityUIElement.h: Use JSRetainPtr instead of
+        raw pointers for the results of the functions that create strings.
+        The old way was difficult to get right; the functions didn't even follow
+        the create/copy naming rule.
+
+        * DumpRenderTree/Bindings/CodeGeneratorDumpRenderTree.pm:
+        (_platformTypeConstructor): Use the adopt function instead of the
+        JSRetainPtr adopt constructor. Also nullptr instead of 0.
+
+        * DumpRenderTree/GCController.cpp:
+        (GCController::makeWindowObject): Use adopt function instead of constructor.
+
+        * DumpRenderTree/TestRunner.cpp:
+        (pathToLocalResourceCallback): Use adopt function instead of constructor.
+        (addDisallowedURLCallback): Ditto.
+        (addURLToRedirectCallback): Ditto.
+        (clearApplicationCacheForOriginCallback): Ditto.
+        (applicationCacheDiskUsageForOriginCallback): Ditto.
+        (decodeHostNameCallback): Don't adopt at this level.
+        (encodeHostNameCallback): Ditto.
+        (execCommandCallback): Use adopt instead of JSRetainPtr::adopt.
+        (findStringCallback): Use adopt function instead of constructor.
+        (isCommandEnabledCallback): Ditto.
+        (overridePreferenceCallback): Ditto.
+        (queueLoadCallback): Ditto.
+        (queueLoadHTMLStringCallback): Ditto.
+        (queueLoadingScriptCallback): Ditto.
+        (queueNonLoadingScriptCallback): Ditto.
+        (setAuthenticationPasswordCallback): Ditto.
+        (setAuthenticationUsernameCallback): Ditto.
+        (setDomainRelaxationForbiddenForURLSchemeCallback): Ditto.
+        (setMockGeolocationPositionUnavailableErrorCallback): Ditto.
+        (setPOSIXLocaleCallback): Ditto.
+        (setPersistentUserStyleSheetLocationCallback): Ditto.
+        (setUserStyleSheetLocationCallback): Ditto.
+        (setValueForUserCallback): Ditto.
+        (setWillSendRequestClearHeaderCallback): Ditto.
+        (setPageVisibilityCallback): Ditto.
+        (evaluateInWebInspectorCallback): Ditto.
+        (evaluateScriptInIsolatedWorldCallback): Ditto.
+        (evaluateScriptInIsolatedWorldAndReturnValueCallback): Ditto.
+        (addOriginAccessWhitelistEntryCallback): Ditto.
+        (removeOriginAccessWhitelistEntryCallback): Ditto.
+        (setScrollbarPolicyCallback): Ditto.
+        (addUserScriptCallback): Ditto.
+        (addUserStyleSheetCallback): Ditto.
+        (apiTestNewWindowDataLoadBaseURLCallback): Ditto.
+        (authenticateSessionCallback): Ditto.
+        (getTitleTextDirectionCallback): Ditto.
+        (getInspectorTestStubURLCallback): Ditto.
+        (simulateLegacyWebNotificationClickCallback): Ditto.
+        (setTextDirectionCallback): Ditto.
+        (grantWebNotificationPermissionCallback): Ditto.
+        (denyWebNotificationPermissionCallback): Ditto.
+        (accummulateLogsForChannel): Ditto.
+        (runUIScriptCallback): Ditto.
+        (TestRunner::makeWindowObject): Ditto.
+        (TestRunner::uiScriptDidComplete): Ditto.
+        (TestRunner::setOpenPanelFiles): Ditto.
+
+        * DumpRenderTree/TestRunner.h: Use JSRetainPtr instead of
+        raw pointers for the results of the functions that create strings.
+
+        * DumpRenderTree/ios/AccessibilityControllerIOS.mm:
+        (AccessibilityController::platformName const): Use the adopt
+        function instead of the adopt constructor.
+
+        * DumpRenderTree/ios/AccessibilityUIElementIOS.mm:
+        (createEmptyJSString): Added. This helper function makes reduces the
+        repetitive code to create empty strings.
+        (concatenateAttributeAndValue): Changed to return a JSRetainPtr.
+        (AccessibilityUIElement::identifier): Ditto.
+        (AccessibilityUIElement::traits): Ditto.
+        (AccessibilityUIElement::url): Ditto.
+        (AccessibilityUIElement::speakAs): Ditto.
+        (AccessibilityUIElement::stringForSelection): Ditto.
+        (AccessibilityUIElement::stringForRange): Ditto.
+        (AccessibilityUIElement::attributedStringForRange): Ditto.
+        (AccessibilityUIElement::attributedStringForElement): Ditto.
+        (AccessibilityUIElement::pathDescription const): Ditto.
+        (AccessibilityUIElement::stringForTextMarkerRange): Ditto.
+        (AccessibilityUIElement::attributedStringForTextMarkerRange): Ditto.
+        (AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions): Ditto.
+        (AccessibilityUIElement::attributesOfLinkedUIElements): Ditto.
+        (AccessibilityUIElement::attributesOfDocumentLinks): Ditto.
+        (AccessibilityUIElement::attributesOfChildren): Ditto.
+        (AccessibilityUIElement::allAttributes): Ditto.
+        (AccessibilityUIElement::stringAttributeValue): Ditto.
+        (AccessibilityUIElement::parameterizedAttributeNames): Ditto.
+        (AccessibilityUIElement::role): Ditto.
+        (AccessibilityUIElement::subrole): Ditto.
+        (AccessibilityUIElement::roleDescription): Ditto.
+        (AccessibilityUIElement::computedRoleString): Ditto.
+        (AccessibilityUIElement::title): Ditto.
+        (AccessibilityUIElement::description): Ditto.
+        (AccessibilityUIElement::orientation const): Ditto.
+        (AccessibilityUIElement::stringValue): Ditto.
+        (AccessibilityUIElement::language): Ditto.
+        (AccessibilityUIElement::helpText const): Ditto.
+        (AccessibilityUIElement::valueDescription): Ditto.
+        (AccessibilityUIElement::ariaDropEffects const): Ditto.
+        (AccessibilityUIElement::boundsForRange): Ditto.
+        (AccessibilityUIElement::attributesOfColumnHeaders): Ditto.
+        (AccessibilityUIElement::attributesOfRowHeaders): Ditto.
+        (AccessibilityUIElement::attributesOfColumns): Ditto.
+        (AccessibilityUIElement::attributesOfRows): Ditto.
+        (AccessibilityUIElement::attributesOfVisibleCells): Ditto.
+        (AccessibilityUIElement::attributesOfHeader): Ditto.
+        (AccessibilityUIElement::rowIndexRange): Ditto.
+        (AccessibilityUIElement::columnIndexRange): Ditto.
+        (AccessibilityUIElement::selectedTextRange): Ditto.
+        (AccessibilityUIElement::accessibilityValue const): Ditto.
+        (AccessibilityUIElement::documentEncoding): Ditto.
+        (AccessibilityUIElement::documentURI): Ditto.
+        (AccessibilityUIElement::selectTextWithCriteria): Ditto.
+        (AccessibilityUIElement::classList const): Ditto.
+
+        * DumpRenderTree/mac/AccessibilityCommonMac.h: Changed the
+        createJSStringRef method to return a JSRetainPtr.
+        * DumpRenderTree/mac/AccessibilityCommonMac.mm:
+        (-[NSString createJSStringRef]): Ditto.
+        (searchPredicateParameterizedAttributeForSearchCriteria): Use the
+        adopt function instead of the adopt constructor.
+        * DumpRenderTree/mac/AccessibilityControllerMac.mm:
+        (AccessibilityController::platformName const): Ditto.
+
+        * DumpRenderTree/mac/AccessibilityNotificationHandler.mm:
+        (-[NSString createJSStringRef]): Return a JSRetainPtr.
+        (makeValueRefForValue): Updated for the above, no adopt needed here now.
+        (makeObjectRefForDictionary): Ditto.
+        (-[AccessibilityNotificationHandler _notificationReceived:]): Ditto.
+
+        * DumpRenderTree/mac/AccessibilityUIElementMac.mm:
+        (createEmptyJSString): Added. This helper function makes reduces the
+        repetitive code to create empty strings.
+        (concatenateAttributeAndValue): Changed to return a JSRetainPtr.
+        (descriptionOfElements): Ditto.
+        (selectTextParameterizedAttributeForCriteria): Ditto.
+        (AccessibilityUIElement::attributesOfLinkedUIElements): Ditto.
+        (AccessibilityUIElement::attributesOfDocumentLinks): Ditto.
+        (AccessibilityUIElement::attributesOfChildren): Ditto.
+        (AccessibilityUIElement::allAttributes): Ditto.
+        (AccessibilityUIElement::stringAttributeValue): Ditto.
+        (AccessibilityUIElement::parameterizedAttributeNames): Ditto.
+        (AccessibilityUIElement::role): Ditto.
+        (AccessibilityUIElement::subrole): Ditto.
+        (AccessibilityUIElement::roleDescription): Ditto.
+        (AccessibilityUIElement::computedRoleString): Ditto.
+        (AccessibilityUIElement::title): Ditto.
+        (AccessibilityUIElement::description): Ditto.
+        (AccessibilityUIElement::orientation const): Ditto.
+        (AccessibilityUIElement::stringValue): Ditto.
+        (AccessibilityUIElement::language): Ditto.
+        (AccessibilityUIElement::helpText const): Ditto.
+        (AccessibilityUIElement::valueDescription): Ditto.
+        (AccessibilityUIElement::speakAs): Ditto.
+        (AccessibilityUIElement::classList const): Ditto.
+        (AccessibilityUIElement::ariaDropEffects const): Ditto.
+        (AccessibilityUIElement::rangeForLine): Ditto.
+        (AccessibilityUIElement::rangeForPosition): Ditto.
+        (AccessibilityUIElement::boundsForRange): Ditto.
+        (AccessibilityUIElement::stringForRange): Ditto.
+        (AccessibilityUIElement::attributedStringForRange): Ditto.
+        (AccessibilityUIElement::selectTextWithCriteria): Ditto.
+        (AccessibilityUIElement::attributesOfColumnHeaders): Ditto.
+        (AccessibilityUIElement::attributesOfRowHeaders): Ditto.
+        (AccessibilityUIElement::attributesOfColumns): Ditto.
+        (AccessibilityUIElement::attributesOfRows): Ditto.
+        (AccessibilityUIElement::attributesOfVisibleCells): Ditto.
+        (AccessibilityUIElement::attributesOfHeader): Ditto.
+        (AccessibilityUIElement::rowIndexRange): Ditto.
+        (AccessibilityUIElement::columnIndexRange): Ditto.
+        (AccessibilityUIElement::pathDescription const): Ditto.
+        (AccessibilityUIElement::selectedTextRange): Ditto.
+        (AccessibilityUIElement::accessibilityValue const): Ditto.
+        (AccessibilityUIElement::documentEncoding): Ditto.
+        (AccessibilityUIElement::documentURI): Ditto.
+        (AccessibilityUIElement::url): Ditto.
+        (AccessibilityUIElement::stringForTextMarkerRange): Ditto.
+        (createJSStringRef): Ditto.
+        (AccessibilityUIElement::attributedStringForTextMarkerRange): Ditto.
+        (AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions): Ditto.
+        (AccessibilityUIElement::supportedActions): Ditto.
+        (AccessibilityUIElement::mathPostscriptsDescription const): Ditto.
+        (AccessibilityUIElement::mathPrescriptsDescription const): Ditto.
+
+        * DumpRenderTree/mac/FrameLoadDelegate.mm:
+        (-[FrameLoadDelegate didClearWindowObjectForFrame:inIsolatedWorld:]):
+        Use the adopt function instead of the adopt constructor.
+        * DumpRenderTree/mac/TestRunnerMac.mm:
+        (originsArrayToJS): Ditto.
+        (TestRunner::copyDecodedHostName): Return a JSRetainPtr.
+        (TestRunner::copyEncodedHostName): Ditto.
+        (TestRunner::pathToLocalResource): Ditto.
+        (TestRunner::queueLoad): Use adopt function instead of constructor.
+        (TestRunner::findString): Ditto.
+        (TestRunner::inspectorTestStubURL): Return a JSRetainPtr.
+
+        * DumpRenderTree/win/AccessibilityControllerWin.cpp:
+        (AccessibilityController::winNotificationReceived): Use adopt function
+        instead of adopt constructor.
+        (AccessibilityController::platformName const): Ditto.
+
+        * DumpRenderTree/win/AccessibilityUIElementWin.cpp:
+        (createEmptyJSString): Added. This helper function makes reduces the
+        repetitive code to create empty strings.
+        (AccessibilityUIElement::allAttributes): Changed to return a JSRetainPtr.
+        (AccessibilityUIElement::attributesOfLinkedUIElements): Ditto.
+        (AccessibilityUIElement::attributesOfDocumentLinks): Ditto.
+        (AccessibilityUIElement::attributesOfChildren): Ditto.
+        (AccessibilityUIElement::parameterizedAttributeNames): Ditto.
+        (AccessibilityUIElement::role): Ditto.
+        (AccessibilityUIElement::subrole): Ditto.
+        (AccessibilityUIElement::roleDescription): Ditto.
+        (AccessibilityUIElement::computedRoleString): Ditto.
+        (AccessibilityUIElement::title): Ditto.
+        (AccessibilityUIElement::description): Ditto.
+        (AccessibilityUIElement::stringValue): Ditto.
+        (AccessibilityUIElement::language): Ditto.
+        (AccessibilityUIElement::helpText const): Ditto.
+        (AccessibilityUIElement::valueDescription): Ditto.
+        (AccessibilityUIElement::ariaDropEffects const): Ditto.
+        (AccessibilityUIElement::orientation const): Ditto.
+        (AccessibilityUIElement::attributesOfColumnHeaders): Ditto.
+        (AccessibilityUIElement::attributesOfRowHeaders): Ditto.
+        (AccessibilityUIElement::attributesOfColumns): Ditto.
+        (AccessibilityUIElement::attributesOfRows): Ditto.
+        (AccessibilityUIElement::attributesOfVisibleCells): Ditto.
+        (AccessibilityUIElement::attributesOfHeader): Ditto.
+        (AccessibilityUIElement::rowIndexRange): Ditto.
+        (AccessibilityUIElement::columnIndexRange): Ditto.
+        (AccessibilityUIElement::boundsForRange): Ditto.
+        (AccessibilityUIElement::stringForRange): Ditto.
+        (AccessibilityUIElement::attributedStringForRange): Ditto.
+        (AccessibilityUIElement::selectTextWithCriteria): Ditto.
+        (AccessibilityUIElement::selectedTextRange): Ditto.
+        (AccessibilityUIElement::stringAttributeValue): Ditto.
+        (AccessibilityUIElement::accessibilityValue const): Ditto.
+        (AccessibilityUIElement::documentEncoding): Ditto.
+        (AccessibilityUIElement::documentURI): Ditto.
+        (AccessibilityUIElement::url): Ditto.
+        (AccessibilityUIElement::classList const): Ditto.
+
+        * DumpRenderTree/win/TestRunnerWin.cpp:
+        (TestRunner::copyDecodedHostName): Changed to return a JSRetainPtr.
+        (TestRunner::copyEncodedHostName): Ditto.
+        (TestRunner::pathToLocalResource): Ditto.
+        (TestRunner::queueLoad): Ditto.
+        (TestRunner::findString): Ditto.
+        (TestRunner::inspectorTestStubURL): Ditto.
+
+        * TestRunnerShared/Bindings/JSWrapper.h:
+        (WTR::setProperty): Use adopt function instead of constructor.
+        * TestRunnerShared/UIScriptContext/UIScriptContext.cpp:
+        (UIScriptContext::UIScriptContext): Ditto.
+        (UIScriptContext::runUIScript): Ditto.
+        * TestRunnerShared/UIScriptContext/UIScriptController.cpp:
+        (WTR::toDeviceOrientation): Ditto.
+
+        * TestRunnerShared/cocoa/LayoutTestSpellChecker.mm:
+        (nsTextCheckingType): Changed this function to not take an rvalue
+        reference to a JSRetainPtr since it doesn't take ownership.
+        (-[LayoutTestSpellChecker setResultsFromJSObject:inContext:]): Updated
+        for the above change.
+
+        * TestWebKitAPI/JavaScriptTest.cpp:
+        (TestWebKitAPI::javaScriptCallback): Use adopt function instead of
+        adopt member function.
+
+        * TestWebKitAPI/Tests/WebKit/WKPageIsPlayingAudio.cpp: Removed unneeded include.
+        * TestWebKitAPI/Tests/WebKitCocoa/PictureInPictureDelegate.mm: Ditto.
+        * TestWebKitAPI/Tests/mac/DOMNodeFromJSObject.mm: Use adopt function instead of
+        adopt constructor.
+        * TestWebKitAPI/Tests/mac/JSWrapperForNodeInWebFrame.mm: Ditto.
+
+        * WebKitTestRunner/InjectedBundle/AccessibilityController.cpp:
+        Removed unneeded includes.
+        * WebKitTestRunner/InjectedBundle/AccessibilityTextMarker.cpp: Ditto.
+        * WebKitTestRunner/InjectedBundle/AccessibilityTextMarkerRange.cpp: Ditto.
+        * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp: Ditto.
+
+        * WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm:
+        (_platformTypeConstructor): Use the adopt function instead of the
+        JSRetainPtr adopt constructor. Also nullptr instead of 0.
+
+        * WebKitTestRunner/InjectedBundle/EventSendingController.cpp:
+        (WTR::arrayLength): Use adopt function instead of constructor.
+        (WTR::parseModifierArray): Ditto.
+        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+        (WTR::propertyValue): Ditto.
+        (WTR::dumpPath): Ditto.
+        (WTR::toJS): Ditto.
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::findString): Ditto.
+        (WTR::TestRunner::statisticsDidRunTelemetryCallback): Ditto.
+        (WTR::TestRunner::callDidReceiveAllStorageAccessEntriesCallback): Ditto.
+        (WTR::TestRunner::setOpenPanelFiles): Ditto.
+        * WebKitTestRunner/InjectedBundle/ios/AccessibilityControllerIOS.mm:
+        (WTR::AccessibilityController::platformName): Ditto.
+
+        * WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:
+        (-[NSString createJSStringRef]): Return a JSRetainPtr.
+        This fixes storage leaks in many functions below, which were using
+        the create function and putting the value right into a JSRetainPtr
+        without adoption.
+        (WTR::createEmptyJSString): Added. This helper function reduces the
+        repetitive code to create empty strings.
+        (WTR::concatenateAttributeAndValue): Return a JSRetainPtr.
+        (WTR::AccessibilityUIElement::attributesOfLinkedUIElements):
+        Use createEmptyJSString, fixing a storage leak due to missing adoption.
+        (WTR::AccessibilityUIElement::attributesOfDocumentLinks): Ditto.
+        (WTR::AccessibilityUIElement::attributesOfChildren): Ditto.
+        (WTR::AccessibilityUIElement::allAttributes): Ditto.
+        (WTR::AccessibilityUIElement::stringAttributeValue): Ditto.
+        (WTR::AccessibilityUIElement::parameterizedAttributeNames): Ditto.
+        (WTR::AccessibilityUIElement::role): Ditto.
+        (WTR::AccessibilityUIElement::subrole): Ditto.
+        (WTR::AccessibilityUIElement::roleDescription): Ditto.
+        (WTR::AccessibilityUIElement::computedRoleString): Ditto.
+        (WTR::AccessibilityUIElement::title): Ditto.
+        (WTR::AccessibilityUIElement::orientation const): Ditto.
+        (WTR::AccessibilityUIElement::language): Ditto.
+        (WTR::AccessibilityUIElement::valueDescription): Ditto.
+        (WTR::AccessibilityUIElement::ariaDropEffects const): Ditto.
+        (WTR::AccessibilityUIElement::boundsForRange): Ditto.
+        (WTR::AccessibilityUIElement::stringForRange): Removed unneeded null check.
+        (WTR::AccessibilityUIElement::attributedStringForRange): Ditto.
+        (WTR::AccessibilityUIElement::attributesOfColumnHeaders):
+        Use createEmptyJSString, fixing a storage leak due to missing adoption.
+        (WTR::AccessibilityUIElement::attributesOfRowHeaders): Ditto.
+        (WTR::AccessibilityUIElement::attributesOfColumns): Ditto.
+        (WTR::AccessibilityUIElement::attributesOfRows): Ditto.
+        (WTR::AccessibilityUIElement::attributesOfVisibleCells): Ditto.
+        (WTR::AccessibilityUIElement::attributesOfHeader): Ditto.
+        (WTR::AccessibilityUIElement::selectedTextRange): Ditto.
+        (WTR::AccessibilityUIElement::accessibilityValue const): Ditto.
+        (WTR::AccessibilityUIElement::documentEncoding): Ditto.
+        (WTR::AccessibilityUIElement::documentURI): Ditto.
+        (WTR::AccessibilityUIElement::stringForSelection): Removed unneeded
+        null check.
+        (WTR::AccessibilityUIElement::stringForTextMarkerRange):
+        Use createEmptyJSString, fixing a storage leak due to missing adoption.
+
+        * WebKitTestRunner/InjectedBundle/mac/AccessibilityCommonMac.h:
+        Use JSRetainPtr for the return value of createJSStringRef.
+        * WebKitTestRunner/InjectedBundle/mac/AccessibilityCommonMac.mm:
+        (-[NSString createJSStringRef]): Ditto.
+        (WTR::searchPredicateParameterizedAttributeForSearchCriteria): Use the
+        adopt function instead of the adopt constructor.
+        * WebKitTestRunner/InjectedBundle/mac/AccessibilityControllerMac.mm:
+        (WTR::AccessibilityController::platformName): Ditto
+
+        * WebKitTestRunner/InjectedBundle/mac/AccessibilityNotificationHandler.mm:
+        (-[NSString createJSStringRef]): Return a JSRetainPtr.
+        (makeValueRefForValue): Updated for above by removing adopt.
+        (makeObjectRefForDictionary): Ditto.
+        (-[AccessibilityNotificationHandler _notificationReceived:]): Ditto.
+
+        * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
+        (WTR::createEmptyJSString): Added. This helper function makes reduces the
+        repetitive code to create empty strings.
+        (WTR::concatenateAttributeAndValue): Return a JSRetainPtr.
+        (WTR::descriptionOfElements): Ditto.
+        (WTR::selectTextParameterizedAttributeForCriteria): Ditto.
+        (WTR::AccessibilityUIElement::accessibilityValue const): Use createEmptyJSString,
+        fixing a storage leak due to missing adoption.
+        (WTR::AccessibilityUIElement::documentEncoding): Ditto.
+        (WTR::AccessibilityUIElement::documentURI): Ditto.
+        (WTR::createJSStringRef): Return a JSRetainPtr.
+
+        * WebKitTestRunner/StringFunctions.h:
+        (WTR::toWK): Take a const& to eliminate a little bit of reference count churn.
+        (WTR::toJS): Use the adopt function instead of the constructor.
+
 2018-09-14  Dean Jackson  <dino@grorg.org>
 
         Add Justin Michaud.
index d035dea..1a0c167 100644 (file)
@@ -30,7 +30,6 @@
 #include "AccessibilityController.h"
 
 #include "AccessibilityUIElement.h"
-#include <JavaScriptCore/JSRetainPtr.h>
 
 // Static Value Getters
 
@@ -50,7 +49,7 @@ static JSValueRef getRootElementCallback(JSContextRef context, JSObjectRef thisO
 
 void AccessibilityController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> accessibilityControllerStr(Adopt, JSStringCreateWithUTF8CString("accessibilityController"));
+    auto accessibilityControllerStr = adopt(JSStringCreateWithUTF8CString("accessibilityController"));
     
     JSClassRef classRef = getJSClass();
     JSValueRef accessibilityControllerObject = JSObjectMake(context, classRef, this);
index 1250497..e117d66 100644 (file)
@@ -27,7 +27,6 @@
 #include "AccessibilityTextMarker.h"
 
 #include "AccessibilityUIElement.h"
-#include <JavaScriptCore/JSRetainPtr.h>
 
 // MARK: AccessibilityTextMarker
 
index 0d8b159..872366f 100644 (file)
@@ -30,7 +30,6 @@
 #include "AccessibilityUIElement.h"
 
 #include <JavaScriptCore/JSObjectRef.h>
-#include <JavaScriptCore/JSRetainPtr.h>
 #include <limits.h>
 
 // Static Functions
@@ -43,67 +42,67 @@ static inline AccessibilityUIElement* toAXElement(JSObjectRef object)
 
 static JSValueRef allAttributesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> attributes(Adopt, toAXElement(thisObject)->allAttributes());
+    auto attributes = toAXElement(thisObject)->allAttributes();
     return JSValueMakeString(context, attributes.get());
 }
 
 static JSValueRef attributesOfLinkedUIElementsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> linkedUIDescription(Adopt, toAXElement(thisObject)->attributesOfLinkedUIElements());
+    auto linkedUIDescription = toAXElement(thisObject)->attributesOfLinkedUIElements();
     return JSValueMakeString(context, linkedUIDescription.get());
 }
 
 static JSValueRef attributesOfDocumentLinksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> linkedUIDescription(Adopt, toAXElement(thisObject)->attributesOfDocumentLinks());
+    auto linkedUIDescription = toAXElement(thisObject)->attributesOfDocumentLinks();
     return JSValueMakeString(context, linkedUIDescription.get());
 }
 
 static JSValueRef attributesOfChildrenCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> childrenDescription(Adopt, toAXElement(thisObject)->attributesOfChildren());
+    auto childrenDescription = toAXElement(thisObject)->attributesOfChildren();
     return JSValueMakeString(context, childrenDescription.get());
 }
 
 static JSValueRef parameterizedAttributeNamesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> parameterizedAttributeNames(Adopt, toAXElement(thisObject)->parameterizedAttributeNames());
+    auto parameterizedAttributeNames = toAXElement(thisObject)->parameterizedAttributeNames();
     return JSValueMakeString(context, parameterizedAttributeNames.get());
 }
 
 static JSValueRef attributesOfColumnHeadersCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> attributesOfColumnHeaders(Adopt, toAXElement(thisObject)->attributesOfColumnHeaders());
+    auto attributesOfColumnHeaders = toAXElement(thisObject)->attributesOfColumnHeaders();
     return JSValueMakeString(context, attributesOfColumnHeaders.get());
 }
 
 static JSValueRef attributesOfRowHeadersCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> attributesOfRowHeaders(Adopt, toAXElement(thisObject)->attributesOfRowHeaders());
+    auto attributesOfRowHeaders = toAXElement(thisObject)->attributesOfRowHeaders();
     return JSValueMakeString(context, attributesOfRowHeaders.get());
 }
 
 static JSValueRef attributesOfColumnsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> attributesOfColumns(Adopt, toAXElement(thisObject)->attributesOfColumns());
+    auto attributesOfColumns = toAXElement(thisObject)->attributesOfColumns();
     return JSValueMakeString(context, attributesOfColumns.get());
 }
 
 static JSValueRef attributesOfRowsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> attributesOfRows(Adopt, toAXElement(thisObject)->attributesOfRows());
+    auto attributesOfRows = toAXElement(thisObject)->attributesOfRows();
     return JSValueMakeString(context, attributesOfRows.get());
 }
 
 static JSValueRef attributesOfVisibleCellsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> attributesOfVisibleCells(Adopt, toAXElement(thisObject)->attributesOfVisibleCells());
+    auto attributesOfVisibleCells = toAXElement(thisObject)->attributesOfVisibleCells();
     return JSValueMakeString(context, attributesOfVisibleCells.get());
 }
 
 static JSValueRef attributesOfHeaderCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> attributesOfHeader(Adopt, toAXElement(thisObject)->attributesOfHeader());
+    auto attributesOfHeader = toAXElement(thisObject)->attributesOfHeader();
     return JSValueMakeString(context, attributesOfHeader.get());
 }
 
@@ -114,13 +113,13 @@ static JSValueRef indexInTableCallback(JSContextRef context, JSObjectRef functio
 
 static JSValueRef rowIndexRangeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> rowIndexRange(Adopt, toAXElement(thisObject)->rowIndexRange());
+    auto rowIndexRange = toAXElement(thisObject)->rowIndexRange();
     return JSValueMakeString(context, rowIndexRange.get());
 }
 
 static JSValueRef columnIndexRangeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> columnIndexRange(Adopt, toAXElement(thisObject)->columnIndexRange());
+    auto columnIndexRange = toAXElement(thisObject)->columnIndexRange();
     return JSValueMakeString(context, columnIndexRange.get());
 }
 
@@ -139,7 +138,7 @@ static JSValueRef rangeForLineCallback(JSContextRef context, JSObjectRef functio
     if (argumentCount == 1)
         indexNumber = JSValueToNumber(context, arguments[0], exception);
     
-    JSRetainPtr<JSStringRef> rangeLine(Adopt, toAXElement(thisObject)->rangeForLine(indexNumber));
+    auto rangeLine = toAXElement(thisObject)->rangeForLine(indexNumber);
     return JSValueMakeString(context, rangeLine.get());
 }
 
@@ -151,7 +150,7 @@ static JSValueRef boundsForRangeCallback(JSContextRef context, JSObjectRef funct
         length = JSValueToNumber(context, arguments[1], exception);
     }
 
-    JSRetainPtr<JSStringRef> boundsDescription(Adopt, toAXElement(thisObject)->boundsForRange(location, length));
+    auto boundsDescription = toAXElement(thisObject)->boundsForRange(location, length);
     return JSValueMakeString(context, boundsDescription.get());    
 }
 
@@ -163,7 +162,7 @@ static JSValueRef rangeForPositionCallback(JSContextRef context, JSObjectRef fun
         y = JSValueToNumber(context, arguments[1], exception);
     }
     
-    JSRetainPtr<JSStringRef> rangeDescription(Adopt, toAXElement(thisObject)->rangeForPosition(x, y));
+    auto rangeDescription = toAXElement(thisObject)->rangeForPosition(x, y);
     return JSValueMakeString(context, rangeDescription.get());    
 }
 
@@ -175,7 +174,7 @@ static JSValueRef stringForRangeCallback(JSContextRef context, JSObjectRef funct
         length = JSValueToNumber(context, arguments[1], exception);
     }
     
-    JSRetainPtr<JSStringRef> stringDescription(Adopt, toAXElement(thisObject)->stringForRange(location, length));
+    auto stringDescription = toAXElement(thisObject)->stringForRange(location, length);
     return JSValueMakeString(context, stringDescription.get());    
 }
 
@@ -187,7 +186,7 @@ static JSValueRef attributedStringForRangeCallback(JSContextRef context, JSObjec
         length = JSValueToNumber(context, arguments[1], exception);
     }
     
-    JSRetainPtr<JSStringRef> stringDescription(Adopt, toAXElement(thisObject)->attributedStringForRange(location, length));
+    auto stringDescription = toAXElement(thisObject)->attributedStringForRange(location, length);
     return JSValueMakeString(context, stringDescription.get());    
 }
 
@@ -219,7 +218,7 @@ static JSValueRef uiElementCountForSearchPredicateCallback(JSContextRef context,
         searchKey = arguments[2];
         
         if (JSValueIsString(context, arguments[3]))
-            searchText.adopt(JSValueToStringCopy(context, arguments[3], exception));
+            searchText = adopt(JSValueToStringCopy(context, arguments[3], exception));
         
         visibleOnly = JSValueToBoolean(context, arguments[4]);
         
@@ -247,7 +246,7 @@ static JSValueRef uiElementForSearchPredicateCallback(JSContextRef context, JSOb
         searchKey = arguments[2];
         
         if (JSValueIsString(context, arguments[3]))
-            searchText.adopt(JSValueToStringCopy(context, arguments[3], exception));
+            searchText = adopt(JSValueToStringCopy(context, arguments[3], exception));
         
         visibleOnly = JSValueToBoolean(context, arguments[4]);
         
@@ -263,7 +262,7 @@ static JSValueRef selectTextWithCriteriaCallback(JSContextRef context, JSObjectR
     if (argumentCount < 2 || argumentCount > 4)
         return JSValueMakeUndefined(context);
     
-    JSRetainPtr<JSStringRef> ambiguityResolution(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto ambiguityResolution = adopt(JSValueToStringCopy(context, arguments[0], exception));
     JSValueRef searchStrings = arguments[1];
     JSStringRef replacementString = nullptr;
     if (argumentCount == 3)
@@ -272,7 +271,7 @@ static JSValueRef selectTextWithCriteriaCallback(JSContextRef context, JSObjectR
     if (argumentCount == 4)
         activityString = JSValueToStringCopy(context, arguments[3], exception);
     
-    JSRetainPtr<JSStringRef> result(Adopt, toAXElement(thisObject)->selectTextWithCriteria(context, ambiguityResolution.get(), searchStrings, replacementString, activityString));
+    auto result = toAXElement(thisObject)->selectTextWithCriteria(context, ambiguityResolution.get(), searchStrings, replacementString, activityString);
     if (replacementString)
         JSStringRelease(replacementString);
     if (activityString)
@@ -371,7 +370,7 @@ static JSValueRef fieldsetAncestorElementCallback(JSContextRef context, JSObject
 
 static JSValueRef attributedStringForElementCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> stringDescription(Adopt, toAXElement(thisObject)->attributedStringForElement());
+    auto stringDescription = toAXElement(thisObject)->attributedStringForElement();
     return JSValueMakeString(context, stringDescription.get());
 }
 
@@ -474,7 +473,7 @@ static JSValueRef setValueCallback(JSContextRef context, JSObjectRef function, J
     JSRetainPtr<JSStringRef> valueText = 0;
     if (argumentCount == 1) {
         if (JSValueIsString(context, arguments[0]))
-            valueText.adopt(JSValueToStringCopy(context, arguments[0], exception));
+            valueText = adopt(JSValueToStringCopy(context, arguments[0], exception));
     }
     
     toAXElement(thisObject)->setValue(valueText.get());
@@ -591,7 +590,7 @@ static JSValueRef stringAttributeValueCallback(JSContextRef context, JSObjectRef
     JSStringRef attribute = 0;
     if (argumentCount == 1)
         attribute = JSValueToStringCopy(context, arguments[0], exception);
-    JSRetainPtr<JSStringRef> stringAttributeValue(Adopt, toAXElement(thisObject)->stringAttributeValue(attribute));
+    auto stringAttributeValue = toAXElement(thisObject)->stringAttributeValue(attribute);
     JSValueRef result = JSValueMakeString(context, stringAttributeValue.get());
     if (attribute)
         JSStringRelease(attribute);
@@ -629,7 +628,7 @@ static JSValueRef uiElementArrayAttributeValueCallback(JSContextRef context, JSO
     if (argumentCount != 1)
         return JSValueMakeUndefined(context);
     
-    JSRetainPtr<JSStringRef> attribute(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto attribute = adopt(JSValueToStringCopy(context, arguments[0], exception));
     
     Vector<AccessibilityUIElement> elements;
     toAXElement(thisObject)->uiElementArrayAttributeValue(attribute.get(), elements);
@@ -640,7 +639,7 @@ static JSValueRef uiElementAttributeValueCallback(JSContextRef context, JSObject
 {
     JSRetainPtr<JSStringRef> attribute;
     if (argumentCount == 1)
-        attribute.adopt(JSValueToStringCopy(context, arguments[0], exception));
+        attribute = adopt(JSValueToStringCopy(context, arguments[0], exception));
     
     return AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->uiElementAttributeValue(attribute.get()));
 }
@@ -883,7 +882,7 @@ static JSValueRef stringForTextMarkerRangeCallback(JSContextRef context, JSObjec
     if (argumentCount == 1)
         markerRange = toTextMarkerRange(JSValueToObject(context, arguments[0], exception));
     
-    JSRetainPtr<JSStringRef> markerRangeString(Adopt, toAXElement(thisObject)->stringForTextMarkerRange(markerRange));
+    auto markerRangeString = toAXElement(thisObject)->stringForTextMarkerRange(markerRange);
     return JSValueMakeString(context, markerRangeString.get());    
 }
 
@@ -893,7 +892,7 @@ static JSValueRef attributedStringForTextMarkerRangeCallback(JSContextRef contex
     if (argumentCount == 1)
         markerRange = toTextMarkerRange(JSValueToObject(context, arguments[0], exception));
 
-    JSRetainPtr<JSStringRef> markerRangeString(Adopt, toAXElement(thisObject)->attributedStringForTextMarkerRange(markerRange));
+    auto markerRangeString = toAXElement(thisObject)->attributedStringForTextMarkerRange(markerRange);
     return JSValueMakeString(context, markerRangeString.get());
 }
 
@@ -906,7 +905,7 @@ static JSValueRef attributedStringForTextMarkerRangeWithOptionsCallback(JSContex
         includeSpellCheck = JSValueToBoolean(context, arguments[1]);
     }
 
-    JSRetainPtr<JSStringRef> markerRangeString(Adopt, toAXElement(thisObject)->attributedStringForTextMarkerRangeWithOptions(markerRange, includeSpellCheck));
+    auto markerRangeString = toAXElement(thisObject)->attributedStringForTextMarkerRangeWithOptions(markerRange, includeSpellCheck);
     return JSValueMakeString(context, markerRangeString.get());
 }
 
@@ -1110,13 +1109,13 @@ static JSValueRef setSelectedVisibleTextRangeCallback(JSContextRef context, JSOb
 
 static JSValueRef getARIADropEffectsCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> dropEffects(Adopt, toAXElement(thisObject)->ariaDropEffects());
+    auto dropEffects = toAXElement(thisObject)->ariaDropEffects();
     return JSValueMakeString(context, dropEffects.get());
 }
 
 static JSValueRef getClassListCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> classList(Adopt, toAXElement(thisObject)->classList());
+    auto classList = toAXElement(thisObject)->classList();
     return JSValueMakeString(context, classList.get());
 }
 
@@ -1138,61 +1137,61 @@ static JSValueRef getIsValidCallback(JSContextRef context, JSObjectRef thisObjec
 
 static JSValueRef getRoleCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> role(Adopt, toAXElement(thisObject)->role());
+    auto role = toAXElement(thisObject)->role();
     return JSValueMakeString(context, role.get());
 }
 
 static JSValueRef getSubroleCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> role(Adopt, toAXElement(thisObject)->subrole());
+    auto role = toAXElement(thisObject)->subrole();
     return JSValueMakeString(context, role.get());
 }
 
 static JSValueRef getRoleDescriptionCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> roleDesc(Adopt, toAXElement(thisObject)->roleDescription());
+    auto roleDesc = toAXElement(thisObject)->roleDescription();
     return JSValueMakeString(context, roleDesc.get());
 }
 
 static JSValueRef getComputedRoleStringCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> compRole(Adopt, toAXElement(thisObject)->computedRoleString());
+    auto compRole = toAXElement(thisObject)->computedRoleString();
     return JSValueMakeString(context, compRole.get());
 }
 
 static JSValueRef getTitleCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> title(Adopt, toAXElement(thisObject)->title());
+    auto title = toAXElement(thisObject)->title();
     return JSValueMakeString(context, title.get());
 }
 
 static JSValueRef getDescriptionCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> description(Adopt, toAXElement(thisObject)->description());
+    auto description = toAXElement(thisObject)->description();
     return JSValueMakeString(context, description.get());
 }
 
 static JSValueRef getStringValueCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> stringValue(Adopt, toAXElement(thisObject)->stringValue());
+    auto stringValue = toAXElement(thisObject)->stringValue();
     return JSValueMakeString(context, stringValue.get());
 }
 
 static JSValueRef getLanguageCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> language(Adopt, toAXElement(thisObject)->language());
+    auto language = toAXElement(thisObject)->language();
     return JSValueMakeString(context, language.get());
 }
 
 static JSValueRef getHelpTextCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> language(Adopt, toAXElement(thisObject)->helpText());
+    auto language = toAXElement(thisObject)->helpText();
     return JSValueMakeString(context, language.get());
 }
 
 static JSValueRef getOrientationCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> orientation(Adopt, toAXElement(thisObject)->orientation());
+    auto orientation = toAXElement(thisObject)->orientation();
     return JSValueMakeString(context, orientation.get());
 }
 
@@ -1263,13 +1262,13 @@ static JSValueRef getInsertionPointLineNumberCallback(JSContextRef context, JSOb
 
 static JSValueRef getPathDescriptionCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> pathDescription(Adopt, toAXElement(thisObject)->pathDescription());
+    auto pathDescription = toAXElement(thisObject)->pathDescription();
     return JSValueMakeString(context, pathDescription.get());
 }
 
 static JSValueRef getSelectedTextRangeCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> selectedTextRange(Adopt, toAXElement(thisObject)->selectedTextRange());
+    auto selectedTextRange = toAXElement(thisObject)->selectedTextRange();
     return JSValueMakeString(context, selectedTextRange.get());
 }
 
@@ -1350,7 +1349,7 @@ static JSValueRef isIgnoredCallback(JSContextRef context, JSObjectRef thisObject
 
 static JSValueRef speakAsCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef*)
 {
-    JSRetainPtr<JSStringRef> speakAsString(Adopt, toAXElement(thisObject)->speakAs());
+    auto speakAsString = toAXElement(thisObject)->speakAs();
     return JSValueMakeString(context, speakAsString.get());
 }
 
@@ -1381,31 +1380,31 @@ static JSValueRef hierarchicalLevelCallback(JSContextRef context, JSObjectRef th
 
 static JSValueRef getValueDescriptionCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> valueDescription(Adopt, toAXElement(thisObject)->valueDescription());
+    auto valueDescription = toAXElement(thisObject)->valueDescription();
     return JSValueMakeString(context, valueDescription.get());
 }
 
 static JSValueRef getAccessibilityValueCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> accessibilityValue(Adopt, toAXElement(thisObject)->accessibilityValue());
+    auto accessibilityValue = toAXElement(thisObject)->accessibilityValue();
     return JSValueMakeString(context, accessibilityValue.get());
 }
 
 static JSValueRef getDocumentEncodingCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> documentEncoding(Adopt, toAXElement(thisObject)->documentEncoding());
+    auto documentEncoding = toAXElement(thisObject)->documentEncoding();
     return JSValueMakeString(context, documentEncoding.get());
 }
 
 static JSValueRef getDocumentURICallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> documentURI(Adopt, toAXElement(thisObject)->documentURI());
+    auto documentURI = toAXElement(thisObject)->documentURI();
     return JSValueMakeString(context, documentURI.get());
 }
 
 static JSValueRef getURLCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> url(Adopt, toAXElement(thisObject)->url());
+    auto url = toAXElement(thisObject)->url();
     return JSValueMakeString(context, url.get());
 }
 
@@ -1432,7 +1431,7 @@ static JSValueRef characterAtOffsetCallback(JSContextRef context, JSObjectRef fu
     if (argumentCount == 1)
         offset = JSValueToNumber(context, arguments[0], exception);
 
-    JSRetainPtr<JSStringRef> characterAtOffset(Adopt, toAXElement(thisObject)->characterAtOffset(offset));
+    auto characterAtOffset = toAXElement(thisObject)->characterAtOffset(offset);
     return JSValueMakeString(context, characterAtOffset.get());
 }
 
@@ -1442,7 +1441,7 @@ static JSValueRef wordAtOffsetCallback(JSContextRef context, JSObjectRef functio
     if (argumentCount == 1)
         offset = JSValueToNumber(context, arguments[0], exception);
 
-    JSRetainPtr<JSStringRef> wordAtOffset(Adopt, toAXElement(thisObject)->wordAtOffset(offset));
+    auto wordAtOffset = toAXElement(thisObject)->wordAtOffset(offset);
     return JSValueMakeString(context, wordAtOffset.get());
 }
 
@@ -1452,7 +1451,7 @@ static JSValueRef lineAtOffsetCallback(JSContextRef context, JSObjectRef functio
     if (argumentCount == 1)
         offset = JSValueToNumber(context, arguments[0], exception);
 
-    JSRetainPtr<JSStringRef> lineAtOffset(Adopt, toAXElement(thisObject)->lineAtOffset(offset));
+    auto lineAtOffset = toAXElement(thisObject)->lineAtOffset(offset);
     return JSValueMakeString(context, lineAtOffset.get());
 }
 
@@ -1462,7 +1461,7 @@ static JSValueRef sentenceAtOffsetCallback(JSContextRef context, JSObjectRef fun
     if (argumentCount == 1)
         offset = JSValueToNumber(context, arguments[0], exception);
 
-    JSRetainPtr<JSStringRef> sentenceAtOffset(Adopt, toAXElement(thisObject)->sentenceAtOffset(offset));
+    auto sentenceAtOffset = toAXElement(thisObject)->sentenceAtOffset(offset);
     return JSValueMakeString(context, sentenceAtOffset.get());
 }
 
@@ -1480,20 +1479,20 @@ static JSValueRef getIsTextAreaCallback(JSContextRef context, JSObjectRef thisOb
 
 static JSValueRef stringForSelectionCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> labelString(Adopt, toAXElement(thisObject)->stringForSelection());
+    auto labelString = toAXElement(thisObject)->stringForSelection();
     return JSValueMakeString(context, labelString.get());
 }
 
 static JSValueRef getIdentifierCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> valueString(Adopt, toAXElement(thisObject)->identifier());
+    auto valueString = toAXElement(thisObject)->identifier();
     return JSValueMakeString(context, valueString.get());
 }
 
 
 static JSValueRef getTraitsCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> valueString(Adopt, toAXElement(thisObject)->traits());
+    auto valueString = toAXElement(thisObject)->traits();
     return JSValueMakeString(context, valueString.get());
 }
 
@@ -1534,19 +1533,19 @@ static JSValueRef textMarkerRangeMatchesTextNearMarkersCallback(JSContextRef con
 #if PLATFORM(MAC) && !PLATFORM(IOS)
 static JSValueRef supportedActionsCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> valueString(Adopt, toAXElement(thisObject)->supportedActions());
+    auto valueString = toAXElement(thisObject)->supportedActions();
     return JSValueMakeString(context, valueString.get());
 }
 
 static JSValueRef mathPostscriptsDescriptionCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> valueString(Adopt, toAXElement(thisObject)->mathPostscriptsDescription());
+    auto valueString = toAXElement(thisObject)->mathPostscriptsDescription();
     return JSValueMakeString(context, valueString.get());
 }
 
 static JSValueRef mathPrescriptsDescriptionCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> valueString(Adopt, toAXElement(thisObject)->mathPrescriptsDescription());
+    auto valueString = toAXElement(thisObject)->mathPrescriptsDescription();
     return JSValueMakeString(context, valueString.get());
 }
 
@@ -1556,8 +1555,8 @@ static JSValueRef mathPrescriptsDescriptionCallback(JSContextRef context, JSObje
 
 // Unsupported methods on various platforms.
 #if !PLATFORM(MAC) || PLATFORM(IOS)
-JSStringRef AccessibilityUIElement::rangeForLine(int line) { return 0; }
-JSStringRef AccessibilityUIElement::rangeForPosition(int, int) { return 0; }
+JSRetainPtr<JSStringRef> AccessibilityUIElement::rangeForLine(int line) { return 0; }
+JSRetainPtr<JSStringRef> AccessibilityUIElement::rangeForPosition(int, int) { return 0; }
 void AccessibilityUIElement::setSelectedChild(AccessibilityUIElement*) const { }
 void AccessibilityUIElement::setSelectedChildAtIndex(unsigned) const { }
 void AccessibilityUIElement::removeSelectionAtIndex(unsigned) const { }
@@ -1567,8 +1566,8 @@ AccessibilityUIElement AccessibilityUIElement::uiElementAttributeValue(JSStringR
 #endif
 
 #if !PLATFORM(MAC) && !PLATFORM(IOS)
-JSStringRef AccessibilityUIElement::speakAs() { return nullptr; }
-JSStringRef AccessibilityUIElement::pathDescription() const { return 0; }
+JSRetainPtr<JSStringRef> AccessibilityUIElement::speakAs() { return nullptr; }
+JSRetainPtr<JSStringRef> AccessibilityUIElement::pathDescription() const { return 0; }
 void AccessibilityUIElement::setValue(JSStringRef) { }
 #endif
 
@@ -1660,17 +1659,17 @@ AccessibilityTextMarker AccessibilityUIElement::nextTextMarker(AccessibilityText
     return 0;
 }
 
-JSStringRef AccessibilityUIElement::stringForTextMarkerRange(AccessibilityTextMarkerRange*)
+JSRetainPtr<JSStringRef> AccessibilityUIElement::stringForTextMarkerRange(AccessibilityTextMarkerRange*)
 {
     return 0;
 }
 
-JSStringRef AccessibilityUIElement::attributedStringForTextMarkerRange(AccessibilityTextMarkerRange*)
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForTextMarkerRange(AccessibilityTextMarkerRange*)
 {
     return nullptr;
 }
 
-JSStringRef AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions(AccessibilityTextMarkerRange*, bool includeSpellCheck)
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions(AccessibilityTextMarkerRange*, bool includeSpellCheck)
 {
     return nullptr;
 }
index 634ce8a..3457811 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef AccessibilityUIElement_h
-#define AccessibilityUIElement_h
+#pragma once
 
 #include "AccessibilityTextMarker.h"
 #include <JavaScriptCore/JSObjectRef.h>
+#include <JavaScriptCore/JSRetainPtr.h>
 #include <wtf/Platform.h>
 #include <wtf/Vector.h>
 
@@ -91,20 +91,20 @@ public:
     void removeSelection();
 
     // Methods - platform-independent implementations
-    JSStringRef allAttributes();
-    JSStringRef attributesOfLinkedUIElements();
+    JSRetainPtr<JSStringRef> allAttributes();
+    JSRetainPtr<JSStringRef> attributesOfLinkedUIElements();
     AccessibilityUIElement linkedUIElementAtIndex(unsigned);
     
-    JSStringRef attributesOfDocumentLinks();
-    JSStringRef attributesOfChildren();
-    JSStringRef parameterizedAttributeNames();
+    JSRetainPtr<JSStringRef> attributesOfDocumentLinks();
+    JSRetainPtr<JSStringRef> attributesOfChildren();
+    JSRetainPtr<JSStringRef> parameterizedAttributeNames();
     void increment();
     void decrement();
     void showMenu();
     void press();
 
     // Attributes - platform-independent implementations
-    JSStringRef stringAttributeValue(JSStringRef attribute);
+    JSRetainPtr<JSStringRef> stringAttributeValue(JSStringRef attribute);
     double numberAttributeValue(JSStringRef attribute);
     void uiElementArrayAttributeValue(JSStringRef attribute, Vector<AccessibilityUIElement>& elements) const;
     AccessibilityUIElement uiElementAttributeValue(JSStringRef attribute) const;    
@@ -115,18 +115,18 @@ public:
     bool isPressActionSupported();
     bool isIncrementActionSupported();
     bool isDecrementActionSupported();
-    JSStringRef role();
-    JSStringRef subrole();
-    JSStringRef roleDescription();
-    JSStringRef computedRoleString();
-    JSStringRef title();
-    JSStringRef description();
-    JSStringRef language();
-    JSStringRef stringValue();
-    JSStringRef accessibilityValue() const;
+    JSRetainPtr<JSStringRef> role();
+    JSRetainPtr<JSStringRef> subrole();
+    JSRetainPtr<JSStringRef> roleDescription();
+    JSRetainPtr<JSStringRef> computedRoleString();
+    JSRetainPtr<JSStringRef> title();
+    JSRetainPtr<JSStringRef> description();
+    JSRetainPtr<JSStringRef> language();
+    JSRetainPtr<JSStringRef> stringValue();
+    JSRetainPtr<JSStringRef> accessibilityValue() const;
     void setValue(JSStringRef);
-    JSStringRef helpText() const;
-    JSStringRef orientation() const;
+    JSRetainPtr<JSStringRef> helpText() const;
+    JSRetainPtr<JSStringRef> orientation() const;
     double x();
     double y();
     double width();
@@ -134,10 +134,10 @@ public:
     double intValue() const;
     double minValue();
     double maxValue();
-    JSStringRef pathDescription() const;
-    JSStringRef valueDescription();
+    JSRetainPtr<JSStringRef> pathDescription() const;
+    JSRetainPtr<JSStringRef> valueDescription();
     int insertionPointLineNumber();
-    JSStringRef selectedTextRange();
+    JSRetainPtr<JSStringRef> selectedTextRange();
     bool isEnabled();
     bool isRequired() const;
     
@@ -167,24 +167,24 @@ public:
     int hierarchicalLevel() const;
     double clickPointX();
     double clickPointY();
-    JSStringRef documentEncoding();
-    JSStringRef documentURI();
-    JSStringRef url();
-    JSStringRef classList() const;
+    JSRetainPtr<JSStringRef> documentEncoding();
+    JSRetainPtr<JSStringRef> documentURI();
+    JSRetainPtr<JSStringRef> url();
+    JSRetainPtr<JSStringRef> classList() const;
 
     // CSS3-speech properties.
-    JSStringRef speakAs();
+    JSRetainPtr<JSStringRef> speakAs();
     
     // Table-specific attributes
-    JSStringRef attributesOfColumnHeaders();
-    JSStringRef attributesOfRowHeaders();
-    JSStringRef attributesOfColumns();
-    JSStringRef attributesOfRows();
-    JSStringRef attributesOfVisibleCells();
-    JSStringRef attributesOfHeader();
+    JSRetainPtr<JSStringRef> attributesOfColumnHeaders();
+    JSRetainPtr<JSStringRef> attributesOfRowHeaders();
+    JSRetainPtr<JSStringRef> attributesOfColumns();
+    JSRetainPtr<JSStringRef> attributesOfRows();
+    JSRetainPtr<JSStringRef> attributesOfVisibleCells();
+    JSRetainPtr<JSStringRef> attributesOfHeader();
     int indexInTable();
-    JSStringRef rowIndexRange();
-    JSStringRef columnIndexRange();
+    JSRetainPtr<JSStringRef> rowIndexRange();
+    JSRetainPtr<JSStringRef> columnIndexRange();
     int rowCount();
     int columnCount();
     void rowHeaders(Vector<AccessibilityUIElement>& elements) const;
@@ -204,23 +204,23 @@ public:
     // ARIA Drag and Drop
     bool ariaIsGrabbed() const;
     // A space concatentated string of all the drop effects.
-    JSStringRef ariaDropEffects() const;
+    JSRetainPtr<JSStringRef> ariaDropEffects() const;
     
     // Parameterized attributes
     int lineForIndex(int);
-    JSStringRef rangeForLine(int);
-    JSStringRef rangeForPosition(int x, int y);
-    JSStringRef boundsForRange(unsigned location, unsigned length);
+    JSRetainPtr<JSStringRef> rangeForLine(int);
+    JSRetainPtr<JSStringRef> rangeForPosition(int x, int y);
+    JSRetainPtr<JSStringRef> boundsForRange(unsigned location, unsigned length);
     void setSelectedTextRange(unsigned location, unsigned length);
-    JSStringRef stringForRange(unsigned location, unsigned length);
-    JSStringRef attributedStringForRange(unsigned location, unsigned length);
+    JSRetainPtr<JSStringRef> stringForRange(unsigned location, unsigned length);
+    JSRetainPtr<JSStringRef> attributedStringForRange(unsigned location, unsigned length);
     bool attributedStringRangeIsMisspelled(unsigned location, unsigned length);
     unsigned uiElementCountForSearchPredicate(JSContextRef, AccessibilityUIElement* startElement, bool isDirectionNext, JSValueRef searchKey, JSStringRef searchText, bool visibleOnly, bool immediateDescendantsOnly);
     AccessibilityUIElement uiElementForSearchPredicate(JSContextRef, AccessibilityUIElement* startElement, bool isDirectionNext, JSValueRef searchKey, JSStringRef searchText, bool visibleOnly, bool immediateDescendantsOnly);
-    JSStringRef selectTextWithCriteria(JSContextRef, JSStringRef ambiguityResolution, JSValueRef searchStrings, JSStringRef replacementString, JSStringRef activity);
+    JSRetainPtr<JSStringRef> selectTextWithCriteria(JSContextRef, JSStringRef ambiguityResolution, JSValueRef searchStrings, JSStringRef replacementString, JSStringRef activity);
 #if PLATFORM(IOS)
     void elementsForRange(unsigned location, unsigned length, Vector<AccessibilityUIElement>& elements);
-    JSStringRef stringForSelection();
+    JSRetainPtr<JSStringRef> stringForSelection();
     void increaseTextSelection();
     void decreaseTextSelection();
     AccessibilityUIElement linkedElement();
@@ -232,15 +232,15 @@ public:
     
     bool hasContainedByFieldsetTrait();
     AccessibilityUIElement fieldsetAncestorElement();
-    JSStringRef attributedStringForElement();
+    JSRetainPtr<JSStringRef> attributedStringForElement();
 #endif
 
 #if PLATFORM(GTK)
     // Text-specific
-    JSStringRef characterAtOffset(int offset);
-    JSStringRef wordAtOffset(int offset);
-    JSStringRef lineAtOffset(int offset);
-    JSStringRef sentenceAtOffset(int offset);
+    JSRetainPtr<JSStringRef> characterAtOffset(int offset);
+    JSRetainPtr<JSStringRef> wordAtOffset(int offset);
+    JSRetainPtr<JSStringRef> lineAtOffset(int offset);
+    JSRetainPtr<JSStringRef> sentenceAtOffset(int offset);
 #endif
 
     // Table-specific
@@ -278,9 +278,9 @@ public:
     void resetSelectedTextMarkerRange();
     bool setSelectedVisibleTextRange(AccessibilityTextMarkerRange*);
     
-    JSStringRef stringForTextMarkerRange(AccessibilityTextMarkerRange*);
-    JSStringRef attributedStringForTextMarkerRange(AccessibilityTextMarkerRange*);
-    JSStringRef attributedStringForTextMarkerRangeWithOptions(AccessibilityTextMarkerRange*, bool includeSpellCheck);
+    JSRetainPtr<JSStringRef> stringForTextMarkerRange(AccessibilityTextMarkerRange*);
+    JSRetainPtr<JSStringRef> attributedStringForTextMarkerRange(AccessibilityTextMarkerRange*);
+    JSRetainPtr<JSStringRef> attributedStringForTextMarkerRangeWithOptions(AccessibilityTextMarkerRange*, bool includeSpellCheck);
     int textMarkerRangeLength(AccessibilityTextMarkerRange*);
     bool attributedStringForTextMarkerRangeContainsAttribute(JSStringRef, AccessibilityTextMarkerRange*);
     int indexForTextMarker(AccessibilityTextMarker*);
@@ -298,8 +298,8 @@ public:
     void removeNotificationListener();
     
 #if PLATFORM(IOS)
-    JSStringRef traits();
-    JSStringRef identifier();
+    JSRetainPtr<JSStringRef> traits();
+    JSRetainPtr<JSStringRef> identifier();
     int elementTextPosition();
     int elementTextLength();
     AccessibilityUIElement headerElementAtIndex(unsigned);
@@ -315,11 +315,11 @@ public:
 
 #if PLATFORM(MAC) && !PLATFORM(IOS)
     // Returns an ordered list of supported actions for an element.
-    JSStringRef supportedActions();
+    JSRetainPtr<JSStringRef> supportedActions();
     
     // A general description of the elements making up multiscript pre/post objects.
-    JSStringRef mathPostscriptsDescription() const;
-    JSStringRef mathPrescriptsDescription() const;
+    JSRetainPtr<JSStringRef> mathPostscriptsDescription() const;
+    JSRetainPtr<JSStringRef> mathPrescriptsDescription() const;
 #endif
     
 private:
@@ -335,5 +335,3 @@ private:
     RefPtr<AccessibilityNotificationHandler> m_notificationHandler;
 #endif
 };
-
-#endif // AccessibilityUIElement_h
index b2c786c..c3152db 100644 (file)
@@ -434,8 +434,8 @@ sub _platformTypeConstructor
     return "JSValueToNullableBoolean(context, $argumentName)" if $type->name eq "boolean" && $type->isNullable;
     return "JSValueToBoolean(context, $argumentName)" if $type->name eq "boolean";
     return "$argumentName" if $type->name eq "object";
-    return "JSRetainPtr<JSStringRef>(Adopt, JSValueToStringCopy(context, $argumentName, 0))" if $$self{codeGenerator}->IsStringType($type);
-    return "JSValueToNumber(context, $argumentName, 0)" if $$self{codeGenerator}->IsPrimitiveType($type);
+    return "adopt(JSValueToStringCopy(context, $argumentName, nullptr))" if $$self{codeGenerator}->IsStringType($type);
+    return "JSValueToNumber(context, $argumentName, nullptr)" if $$self{codeGenerator}->IsPrimitiveType($type);
     return "to" . _implementationClassName($type) . "(context, $argumentName)";
 }
 
index 781a828..4a37bf3 100644 (file)
@@ -73,7 +73,7 @@ static JSValueRef getJSObjectCountCallback(JSContextRef context, JSObjectRef fun
 
 void GCController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> gcControllerStr(Adopt, JSStringCreateWithUTF8CString("GCController"));
+    auto gcControllerStr = adopt(JSStringCreateWithUTF8CString("GCController"));
 
     JSClassRef classRef = getJSClass();
     JSValueRef gcControllerObject = JSObjectMake(context, classRef, this);
index a5c0d80..24a0c66 100644 (file)
@@ -289,10 +289,10 @@ static JSValueRef pathToLocalResourceCallback(JSContextRef context, JSObjectRef
         return JSValueMakeUndefined(context);
 
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
-    JSRetainPtr<JSStringRef> localPath(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto localPath = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
 
-    JSRetainPtr<JSStringRef> convertedPath(Adopt, controller->pathToLocalResource(context, localPath.get()));
+    auto convertedPath = controller->pathToLocalResource(context, localPath.get());
     if (!convertedPath)
         return JSValueMakeUndefined(context);
 
@@ -383,7 +383,7 @@ static JSValueRef addDisallowedURLCallback(JSContextRef context, JSObjectRef fun
     if (argumentCount < 1)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto url = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
 
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
@@ -397,10 +397,10 @@ static JSValueRef addURLToRedirectCallback(JSContextRef context, JSObjectRef fun
     if (argumentCount < 2)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> origin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto origin = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
 
-    JSRetainPtr<JSStringRef> destination(Adopt, JSValueToStringCopy(context, arguments[1], exception));
+    auto destination = adopt(JSValueToStringCopy(context, arguments[1], exception));
     ASSERT(!*exception);
 
     size_t maxLength = JSStringGetMaximumUTF8CStringSize(origin.get());
@@ -439,7 +439,7 @@ static JSValueRef clearApplicationCacheForOriginCallback(JSContextRef context, J
     if (argumentCount < 1)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> originURL(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto originURL = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
 
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
@@ -453,7 +453,7 @@ static JSValueRef applicationCacheDiskUsageForOriginCallback(JSContextRef contex
     if (argumentCount < 1)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> originURL(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto originURL = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
     
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
@@ -500,11 +500,11 @@ static JSValueRef decodeHostNameCallback(JSContextRef context, JSObjectRef funct
     if (argumentCount < 1)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto name = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
 
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
-    JSRetainPtr<JSStringRef> decodedHostName(Adopt, controller->copyDecodedHostName(name.get()));
+    auto decodedHostName = controller->copyDecodedHostName(name.get());
     return JSValueMakeString(context, decodedHostName.get());
 }
 
@@ -541,11 +541,11 @@ static JSValueRef encodeHostNameCallback(JSContextRef context, JSObjectRef funct
     if (argumentCount < 1)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto name = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
 
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
-    JSRetainPtr<JSStringRef> encodedHostName(Adopt, controller->copyEncodedHostName(name.get()));
+    auto encodedHostName = controller->copyEncodedHostName(name.get());
     return JSValueMakeString(context, encodedHostName.get());
 }
 
@@ -555,17 +555,17 @@ static JSValueRef execCommandCallback(JSContextRef context, JSObjectRef function
     if (argumentCount < 1)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto name = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
 
     // Ignoring the second parameter (userInterface), as this command emulates a manual action.
 
     JSRetainPtr<JSStringRef> value;
     if (argumentCount >= 3) {
-        value.adopt(JSValueToStringCopy(context, arguments[2], exception));
+        value = adopt(JSValueToStringCopy(context, arguments[2], exception));
         ASSERT(!*exception);
     } else
-        value.adopt(JSStringCreateWithUTF8CString(""));
+        value = adopt(JSStringCreateWithUTF8CString(""));
 
 
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
@@ -580,7 +580,7 @@ static JSValueRef findStringCallback(JSContextRef context, JSObjectRef function,
     if (argumentCount < 2)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> target(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto target = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
 
     JSObjectRef options = JSValueToObject(context, arguments[1], exception);
@@ -605,7 +605,7 @@ static JSValueRef isCommandEnabledCallback(JSContextRef context, JSObjectRef fun
     if (argumentCount < 1)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto name = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
 
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
@@ -618,9 +618,9 @@ static JSValueRef overridePreferenceCallback(JSContextRef context, JSObjectRef f
     if (argumentCount < 2)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> key(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto key = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
-    JSRetainPtr<JSStringRef> value(Adopt, JSValueToStringCopy(context, arguments[1], exception));
+    auto value = adopt(JSValueToStringCopy(context, arguments[1], exception));
     ASSERT(!*exception);
 
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
@@ -698,15 +698,15 @@ static JSValueRef queueLoadCallback(JSContextRef context, JSObjectRef function,
     if (argumentCount < 1)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto url = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
 
     JSRetainPtr<JSStringRef> target;
     if (argumentCount >= 2) {
-        target.adopt(JSValueToStringCopy(context, arguments[1], exception));
+        target = adopt(JSValueToStringCopy(context, arguments[1], exception));
         ASSERT(!*exception);
     } else
-        target.adopt(JSStringCreateWithUTF8CString(""));
+        target = adopt(JSStringCreateWithUTF8CString(""));
 
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
     controller->queueLoad(url.get(), target.get());
@@ -720,21 +720,20 @@ static JSValueRef queueLoadHTMLStringCallback(JSContextRef context, JSObjectRef
     if (argumentCount < 1)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> content(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto content = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
 
     JSRetainPtr<JSStringRef> baseURL;
     if (argumentCount >= 2) {
-        baseURL.adopt(JSValueToStringCopy(context, arguments[1], exception));
+        baseURL = adopt(JSValueToStringCopy(context, arguments[1], exception));
         ASSERT(!*exception);
     } else
-        baseURL.adopt(JSStringCreateWithUTF8CString(""));
+        baseURL = adopt(JSStringCreateWithUTF8CString(""));
 
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
 
     if (argumentCount >= 3) {
-        JSRetainPtr<JSStringRef> unreachableURL;
-        unreachableURL.adopt(JSValueToStringCopy(context, arguments[2], exception));
+        auto unreachableURL = adopt(JSValueToStringCopy(context, arguments[2], exception));
         ASSERT(!*exception);
         controller->queueLoadAlternateHTMLString(content.get(), baseURL.get(), unreachableURL.get());
         return JSValueMakeUndefined(context);
@@ -762,7 +761,7 @@ static JSValueRef queueLoadingScriptCallback(JSContextRef context, JSObjectRef f
     if (argumentCount < 1)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto script = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
 
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
@@ -778,7 +777,7 @@ static JSValueRef queueNonLoadingScriptCallback(JSContextRef context, JSObjectRe
     if (argumentCount < 1)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto script = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
 
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
@@ -832,7 +831,7 @@ static JSValueRef setAuthenticationPasswordCallback(JSContextRef context, JSObje
     if (argumentCount < 1)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> password(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto password = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
 
     size_t maxLength = JSStringGetMaximumUTF8CStringSize(password.get());
@@ -852,7 +851,7 @@ static JSValueRef setAuthenticationUsernameCallback(JSContextRef context, JSObje
     if (argumentCount < 1)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> username(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto username = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
 
     size_t maxLength = JSStringGetMaximumUTF8CStringSize(username.get());
@@ -955,7 +954,7 @@ static JSValueRef setDomainRelaxationForbiddenForURLSchemeCallback(JSContextRef
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
 
     bool forbidden = JSValueToBoolean(context, arguments[0]);
-    JSRetainPtr<JSStringRef> scheme(Adopt, JSValueToStringCopy(context, arguments[1], 0));
+    auto scheme = adopt(JSValueToStringCopy(context, arguments[1], 0));
     controller->setDomainRelaxationForbiddenForURLScheme(forbidden, scheme.get());
 
     return JSValueMakeUndefined(context);
@@ -1037,7 +1036,7 @@ static JSValueRef setMockGeolocationPositionUnavailableErrorCallback(JSContextRe
     if (argumentCount != 1)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> message(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto message = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
 
     TestRunner* controller = reinterpret_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
@@ -1100,7 +1099,7 @@ static JSValueRef setPOSIXLocaleCallback(JSContextRef context, JSObjectRef funct
         return JSValueMakeUndefined(context);
 
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
-    JSRetainPtr<JSStringRef> locale(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto locale = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
     controller->setPOSIXLocale(locale.get());
 
@@ -1137,7 +1136,7 @@ static JSValueRef setPersistentUserStyleSheetLocationCallback(JSContextRef conte
     if (argumentCount < 1)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> path(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto path = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
 
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
@@ -1313,7 +1312,7 @@ static JSValueRef setUserStyleSheetLocationCallback(JSContextRef context, JSObje
     if (argumentCount < 1)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> path(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto path = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
 
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
@@ -1328,7 +1327,7 @@ static JSValueRef setValueForUserCallback(JSContextRef context, JSObjectRef func
     if (argumentCount != 2)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> value(Adopt, JSValueToStringCopy(context, arguments[1], exception));
+    auto value = adopt(JSValueToStringCopy(context, arguments[1], exception));
     ASSERT(!*exception);
 
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
@@ -1343,7 +1342,7 @@ static JSValueRef setWillSendRequestClearHeaderCallback(JSContextRef context, JS
     if (argumentCount < 1)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> header(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto header = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
 
     size_t maxLength = JSStringGetMaximumUTF8CStringSize(header.get());
@@ -1455,7 +1454,7 @@ static JSValueRef setPageVisibilityCallback(JSContextRef context, JSObjectRef fu
     if (argumentCount < 1)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> visibility(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto visibility = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
 
     size_t maxLength = JSStringGetMaximumUTF8CStringSize(visibility.get());
@@ -1510,7 +1509,7 @@ static JSValueRef closeWebInspectorCallback(JSContextRef context, JSObjectRef fu
 static JSValueRef evaluateInWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
-    JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto script = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
 
     controller->evaluateInWebInspector(script.get());
@@ -1522,7 +1521,7 @@ static JSValueRef evaluateScriptInIsolatedWorldCallback(JSContextRef context, JS
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
     double worldID = JSValueToNumber(context, arguments[0], exception);
     ASSERT(!*exception);
-    JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[1], exception));
+    auto script = adopt(JSValueToStringCopy(context, arguments[1], exception));
     ASSERT(!*exception);
 
     controller->evaluateScriptInIsolatedWorld(static_cast<unsigned>(worldID), JSContextGetGlobalObject(context), script.get());
@@ -1534,7 +1533,7 @@ static JSValueRef evaluateScriptInIsolatedWorldAndReturnValueCallback(JSContextR
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
     double worldID = JSValueToNumber(context, arguments[0], exception);
     ASSERT(!*exception);
-    JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[1], exception));
+    auto script = adopt(JSValueToStringCopy(context, arguments[1], exception));
     ASSERT(!*exception);
 
     controller->evaluateScriptInIsolatedWorldAndReturnValue(static_cast<unsigned>(worldID), JSContextGetGlobalObject(context), script.get());
@@ -1553,11 +1552,11 @@ static JSValueRef addOriginAccessWhitelistEntryCallback(JSContextRef context, JS
     if (argumentCount != 4)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> sourceOrigin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto sourceOrigin = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
-    JSRetainPtr<JSStringRef> destinationProtocol(Adopt, JSValueToStringCopy(context, arguments[1], exception));
+    auto destinationProtocol = adopt(JSValueToStringCopy(context, arguments[1], exception));
     ASSERT(!*exception);
-    JSRetainPtr<JSStringRef> destinationHost(Adopt, JSValueToStringCopy(context, arguments[2], exception));
+    auto destinationHost = adopt(JSValueToStringCopy(context, arguments[2], exception));
     ASSERT(!*exception);
     bool allowDestinationSubdomains = JSValueToBoolean(context, arguments[3]);
 
@@ -1571,11 +1570,11 @@ static JSValueRef removeOriginAccessWhitelistEntryCallback(JSContextRef context,
     if (argumentCount != 4)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> sourceOrigin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto sourceOrigin = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
-    JSRetainPtr<JSStringRef> destinationProtocol(Adopt, JSValueToStringCopy(context, arguments[1], exception));
+    auto destinationProtocol = adopt(JSValueToStringCopy(context, arguments[1], exception));
     ASSERT(!*exception);
-    JSRetainPtr<JSStringRef> destinationHost(Adopt, JSValueToStringCopy(context, arguments[2], exception));
+    auto destinationHost = adopt(JSValueToStringCopy(context, arguments[2], exception));
     ASSERT(!*exception);
     bool allowDestinationSubdomains = JSValueToBoolean(context, arguments[3]);
 
@@ -1589,9 +1588,9 @@ static JSValueRef setScrollbarPolicyCallback(JSContextRef context, JSObjectRef,
     if (argumentCount != 2)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> orientation(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto orientation = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
-    JSRetainPtr<JSStringRef> policy(Adopt, JSValueToStringCopy(context, arguments[1], exception));
+    auto policy = adopt(JSValueToStringCopy(context, arguments[1], exception));
     ASSERT(!*exception);
 
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
@@ -1604,7 +1603,7 @@ static JSValueRef addUserScriptCallback(JSContextRef context, JSObjectRef, JSObj
     if (argumentCount != 3)
         return JSValueMakeUndefined(context);
     
-    JSRetainPtr<JSStringRef> source(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto source = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
     bool runAtStart = JSValueToBoolean(context, arguments[1]);
     bool allFrames = JSValueToBoolean(context, arguments[2]);
@@ -1619,7 +1618,7 @@ static JSValueRef addUserStyleSheetCallback(JSContextRef context, JSObjectRef, J
     if (argumentCount != 2)
         return JSValueMakeUndefined(context);
     
-    JSRetainPtr<JSStringRef> source(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto source = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
     bool allFrames = JSValueToBoolean(context, arguments[1]);
    
@@ -1645,10 +1644,10 @@ static JSValueRef apiTestNewWindowDataLoadBaseURLCallback(JSContextRef context,
     if (argumentCount != 2)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> utf8Data(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto utf8Data = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
 
-    JSRetainPtr<JSStringRef> baseURL(Adopt, JSValueToStringCopy(context, arguments[1], exception));
+    auto baseURL = adopt(JSValueToStringCopy(context, arguments[1], exception));
     ASSERT(!*exception);
         
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
@@ -1688,11 +1687,11 @@ static JSValueRef authenticateSessionCallback(JSContextRef context, JSObjectRef,
     if (argumentCount != 3)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto url = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
-    JSRetainPtr<JSStringRef> username(Adopt, JSValueToStringCopy(context, arguments[1], exception));
+    auto username = adopt(JSValueToStringCopy(context, arguments[1], exception));
     ASSERT(!*exception);
-    JSRetainPtr<JSStringRef> password(Adopt, JSValueToStringCopy(context, arguments[2], exception));
+    auto password = adopt(JSValueToStringCopy(context, arguments[2], exception));
     ASSERT(!*exception);
 
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
@@ -1855,14 +1854,14 @@ static JSValueRef getSecureEventInputIsEnabledCallback(JSContextRef context, JSO
 static JSValueRef getTitleTextDirectionCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
-    JSRetainPtr<JSStringRef> titleDirection(Adopt, JSStringCreateWithUTF8CString(controller->titleTextDirection().c_str()));
+    auto titleDirection = adopt(JSStringCreateWithUTF8CString(controller->titleTextDirection().c_str()));
     return JSValueMakeString(context, titleDirection.get());
 }
 
 static JSValueRef getInspectorTestStubURLCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
-    JSRetainPtr<JSStringRef> url(Adopt, controller->inspectorTestStubURL());
+    auto url = controller->inspectorTestStubURL();
     return JSValueMakeString(context, url.get());
 }
 
@@ -1899,7 +1898,7 @@ static JSValueRef ignoreLegacyWebNotificationPermissionRequestsCallback(JSContex
 static JSValueRef simulateLegacyWebNotificationClickCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject)); 
-    JSRetainPtr<JSStringRef> title(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto title = adopt(JSValueToStringCopy(context, arguments[0], exception));
     controller->simulateLegacyWebNotificationClick(title.get());
     return JSValueMakeUndefined(context);
 }
@@ -1907,7 +1906,7 @@ static JSValueRef simulateLegacyWebNotificationClickCallback(JSContextRef contex
 static JSValueRef setTextDirectionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     if (argumentCount == 1) {
-        JSRetainPtr<JSStringRef> direction(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+        auto direction = adopt(JSValueToStringCopy(context, arguments[0], exception));
         TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
         controller->setTextDirection(direction.get());
     }
@@ -1956,7 +1955,7 @@ static JSValueRef grantWebNotificationPermissionCallback(JSContextRef context, J
 
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
 
-    JSRetainPtr<JSStringRef> origin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto origin = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
     controller->grantWebNotificationPermission(origin.get());
 
@@ -1971,7 +1970,7 @@ static JSValueRef denyWebNotificationPermissionCallback(JSContextRef context, JS
 
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
 
-    JSRetainPtr<JSStringRef> origin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto origin = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
     controller->denyWebNotificationPermission(origin.get());
 
@@ -2035,7 +2034,7 @@ static JSValueRef accummulateLogsForChannel(JSContextRef context, JSObjectRef fu
     if (argumentCount < 1)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> channel(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    auto channel = adopt(JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
 
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
@@ -2049,7 +2048,7 @@ static JSValueRef runUIScriptCallback(JSContextRef context, JSObjectRef, JSObjec
     if (argumentCount < 1)
         return JSValueMakeUndefined(context);
 
-    JSRetainPtr<JSStringRef> script = argumentCount > 0 ? JSRetainPtr<JSStringRef>(Adopt, JSValueToStringCopy(context, arguments[0], 0)) : JSRetainPtr<JSStringRef>();
+    auto script = argumentCount > 0 ? adopt(JSValueToStringCopy(context, arguments[0], 0)) : JSRetainPtr<JSStringRef>();
     JSValueRef callback = argumentCount > 1 ? arguments[1] : JSValueMakeUndefined(context);
 
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
@@ -2068,7 +2067,7 @@ static void testRunnerObjectFinalize(JSObjectRef object)
 
 void TestRunner::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> testRunnerStr(Adopt, JSStringCreateWithUTF8CString("testRunner"));
+    auto testRunnerStr = adopt(JSStringCreateWithUTF8CString("testRunner"));
     ref();
 
     JSClassRef classRef = getJSClass();
@@ -2464,7 +2463,7 @@ void TestRunner::callUIScriptCallback(unsigned callbackID, JSStringRef result)
 
 void TestRunner::uiScriptDidComplete(const String& result, unsigned callbackID)
 {
-    JSRetainPtr<JSStringRef> stringRef(Adopt, JSStringCreateWithUTF8CString(result.utf8().data()));
+    auto stringRef = adopt(JSStringCreateWithUTF8CString(result.utf8().data()));
     callUIScriptCallback(callbackID, stringRef.get());
 }
 
@@ -2479,7 +2478,7 @@ void TestRunner::setOpenPanelFiles(JSContextRef context, JSValueRef filesValue)
         return;
 
     JSObjectRef files = JSValueToObject(context, filesValue, nullptr);
-    static auto lengthProperty = JSRetainPtr<JSStringRef>(Adopt, JSStringCreateWithUTF8CString("length"));
+    static auto lengthProperty = adopt(JSStringCreateWithUTF8CString("length"));
     JSValueRef filesLengthValue = JSObjectGetProperty(context, files, lengthProperty.get(), nullptr);
     if (!JSValueIsNumber(context, filesLengthValue))
         return;
@@ -2491,7 +2490,7 @@ void TestRunner::setOpenPanelFiles(JSContextRef context, JSValueRef filesValue)
         if (!JSValueIsString(context, fileValue))
             continue;
 
-        auto file = JSRetainPtr<JSStringRef>(Adopt, JSValueToStringCopy(context, fileValue, nullptr));
+        auto file = adopt(JSValueToStringCopy(context, fileValue, nullptr));
         size_t fileBufferSize = JSStringGetMaximumUTF8CStringSize(file.get()) + 1;
         auto fileBuffer = std::make_unique<char[]>(fileBufferSize);
         JSStringGetUTF8CString(file.get(), fileBuffer.get(), fileBufferSize);
index 4b50245..b512283 100644 (file)
@@ -66,8 +66,8 @@ public:
     void clearBackForwardList();
     void clearPersistentUserStyleSheet();
     bool callShouldCloseOnWebView();
-    JSStringRef copyDecodedHostName(JSStringRef name);
-    JSStringRef copyEncodedHostName(JSStringRef name);
+    JSRetainPtr<JSStringRef> copyDecodedHostName(JSStringRef name);
+    JSRetainPtr<JSStringRef> copyEncodedHostName(JSStringRef name);
     void dispatchPendingLoadRequests();
     void display();
     void displayAndTrackRepaints();
@@ -83,7 +83,7 @@ public:
     int numberOfPendingGeolocationPermissionRequests();
     bool isGeolocationProviderActive();
     void overridePreference(JSStringRef key, JSStringRef value);
-    JSStringRef pathToLocalResource(JSContextRef, JSStringRef url);
+    JSRetainPtr<JSStringRef> pathToLocalResource(JSContextRef, JSStringRef url);
     void queueBackNavigation(int howFarBackward);
     void queueForwardNavigation(int howFarForward);
     void queueLoad(JSStringRef url, JSStringRef target);
@@ -319,7 +319,7 @@ public:
     void showWebInspector();
     void closeWebInspector();
     void evaluateInWebInspector(JSStringRef script);
-    JSStringRef inspectorTestStubURL();
+    JSRetainPtr<JSStringRef> inspectorTestStubURL();
 
     void evaluateScriptInIsolatedWorld(unsigned worldID, JSObjectRef globalObject, JSStringRef script);
     void evaluateScriptInIsolatedWorldAndReturnValue(unsigned worldID, JSObjectRef globalObject, JSStringRef script);
index 54e4a70..61e01f5 100644 (file)
@@ -155,6 +155,5 @@ bool AccessibilityController::enhancedAccessibilityEnabled()
 
 JSRetainPtr<JSStringRef> AccessibilityController::platformName() const
 {
-    JSRetainPtr<JSStringRef> platformName(Adopt, JSStringCreateWithUTF8CString("ios"));
-    return platformName;
+    return adopt(JSStringCreateWithUTF8CString("ios"));
 }
index bb6969e..c94814b 100644 (file)
@@ -30,8 +30,6 @@
 #import "AccessibilityCommonMac.h"
 #import "AccessibilityNotificationHandler.h"
 #import <Foundation/Foundation.h>
-#import <JavaScriptCore/JSRetainPtr.h>
-#import <JavaScriptCore/JSStringRef.h>
 #import <JavaScriptCore/JSStringRefCF.h>
 #import <WebCore/TextGranularity.h>
 #import <WebKit/WebFrame.h>
@@ -123,7 +121,12 @@ AccessibilityUIElement::~AccessibilityUIElement()
 - (CGPathRef)_accessibilityPath;
 @end
 
-static JSStringRef concatenateAttributeAndValue(NSString* attribute, NSString* value)
+static JSRetainPtr<JSStringRef> createEmptyJSString()
+{
+    return adopt(JSStringCreateWithCharacters(nullptr, 0));
+}
+
+static JSRetainPtr<JSStringRef> concatenateAttributeAndValue(NSString *attribute, NSString *value)
 {
     Vector<UniChar> buffer([attribute length]);
     [attribute getCharacters:buffer.data()];
@@ -133,13 +136,13 @@ static JSStringRef concatenateAttributeAndValue(NSString* attribute, NSString* v
     Vector<UniChar> valueBuffer([value length]);
     [value getCharacters:valueBuffer.data()];
     buffer.appendVector(valueBuffer);
-    
-    return JSStringCreateWithCharacters(buffer.data(), buffer.size());
+
+    return adopt(JSStringCreateWithCharacters(buffer.data(), buffer.size()));
 }
 
 #pragma mark iPhone Attributes
 
-JSStringRef AccessibilityUIElement::identifier()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::identifier()
 {
     return concatenateAttributeAndValue(@"AXIdentifier", [m_element accessibilityIdentifier]);
 }
@@ -154,7 +157,7 @@ bool AccessibilityUIElement::isSearchField() const
     return ([m_element accessibilityTraits] & [m_element _axSearchFieldTrait]) == [m_element _axSearchFieldTrait];
 }
 
-JSStringRef AccessibilityUIElement::traits()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::traits()
 {
     return concatenateAttributeAndValue(@"AXTraits", [NSString stringWithFormat:@"%qu", [m_element accessibilityTraits]]);
 }
@@ -187,10 +190,10 @@ AccessibilityUIElement AccessibilityUIElement::fieldsetAncestorElement()
 }
 
 
-JSStringRef AccessibilityUIElement::url()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::url()
 {
     NSURL *url = [m_element accessibilityURL];
-    return [[url absoluteString] createJSStringRef];    
+    return [[url absoluteString] createJSStringRef];
 }
 
 double AccessibilityUIElement::x()
@@ -360,30 +363,24 @@ void AccessibilityUIElement::decreaseTextSelection()
     [m_element accessibilityModifySelection:WebCore::CharacterGranularity increase:NO];    
 }
 
-JSStringRef AccessibilityUIElement::speakAs()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::speakAs()
 {
     return [[[m_element accessibilitySpeechHint] componentsJoinedByString:@", "] createJSStringRef];
 }
 
-JSStringRef AccessibilityUIElement::stringForSelection() 
+JSRetainPtr<JSStringRef> AccessibilityUIElement::stringForSelection()
 { 
     NSString *stringForRange = [m_element selectionRangeString];
-    if (!stringForRange)
-        return 0;
-    
     return [stringForRange createJSStringRef];
 }
 
-JSStringRef AccessibilityUIElement::stringForRange(unsigned location, unsigned length) 
+JSRetainPtr<JSStringRef> AccessibilityUIElement::stringForRange(unsigned location, unsigned length)
 { 
     NSString *stringForRange = [m_element stringForRange:NSMakeRange(location, length)];
-    if (!stringForRange)
-        return 0;
-    
     return [stringForRange createJSStringRef];
 }
 
-JSStringRef AccessibilityUIElement::attributedStringForRange(unsigned location, unsigned length)
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForRange(unsigned location, unsigned length)
 {
     NSRange range = NSMakeRange(location, length);
     NSAttributedString* string = [m_element attributedStringForRange:range];
@@ -394,7 +391,7 @@ JSStringRef AccessibilityUIElement::attributedStringForRange(unsigned location,
     return [stringWithAttrs createJSStringRef];
 }
 
-JSStringRef AccessibilityUIElement::attributedStringForElement()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForElement()
 {
     NSAttributedString *string = [m_element attributedStringForElement];
     if (![string isKindOfClass:[NSAttributedString class]])
@@ -444,7 +441,7 @@ static void _CGPathEnumerationIteration(void *info, const CGPathElement *element
     }
 }
 
-JSStringRef AccessibilityUIElement::pathDescription() const
+JSRetainPtr<JSStringRef> AccessibilityUIElement::pathDescription() const
 {
     NSMutableString *result = [NSMutableString stringWithString:@"\nStart Path\n"];
     CGPathRef pathRef = [m_element _accessibilityPath];
@@ -545,20 +542,20 @@ AccessibilityTextMarker AccessibilityUIElement::nextTextMarker(AccessibilityText
     return AccessibilityTextMarker(nextMarker);
 }
 
-JSStringRef AccessibilityUIElement::stringForTextMarkerRange(AccessibilityTextMarkerRange* markerRange)
+JSRetainPtr<JSStringRef> AccessibilityUIElement::stringForTextMarkerRange(AccessibilityTextMarkerRange* markerRange)
 {
     id textMarkers = (id)markerRange->platformTextMarkerRange();
     if (!textMarkers || ![textMarkers isKindOfClass:[NSArray class]])
-        return JSStringCreateWithCharacters(0, 0);
+        return createEmptyJSString();
     return [[m_element stringForTextMarkers:textMarkers] createJSStringRef];
 }
 
-JSStringRef AccessibilityUIElement::attributedStringForTextMarkerRange(AccessibilityTextMarkerRange*)
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForTextMarkerRange(AccessibilityTextMarkerRange*)
 {
     return nullptr;
 }
 
-JSStringRef AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions(AccessibilityTextMarkerRange*, bool)
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions(AccessibilityTextMarkerRange*, bool)
 {
     return nullptr;
 }
@@ -670,27 +667,27 @@ void AccessibilityUIElement::getDocumentLinks(Vector<AccessibilityUIElement>& el
 {
 }
 
-JSStringRef AccessibilityUIElement::attributesOfLinkedUIElements()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfLinkedUIElements()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::attributesOfDocumentLinks()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfDocumentLinks()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::attributesOfChildren()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfChildren()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::allAttributes()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::allAttributes()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::stringAttributeValue(JSStringRef attribute)
+JSRetainPtr<JSStringRef> AccessibilityUIElement::stringAttributeValue(JSStringRef attribute)
 {
     if (JSStringIsEqualToUTF8CString(attribute, "AXPlaceholderValue"))
         return [[m_element accessibilityPlaceholderValue] createJSStringRef];
@@ -704,7 +701,7 @@ JSStringRef AccessibilityUIElement::stringAttributeValue(JSStringRef attribute)
     if (JSStringIsEqualToUTF8CString(attribute, "AXSortDirection"))
         return [[m_element accessibilitySortDirection] createJSStringRef];
     
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 bool AccessibilityUIElement::isPressActionSupported()
@@ -741,19 +738,19 @@ bool AccessibilityUIElement::isAttributeSupported(JSStringRef attribute)
     return false;
 }
 
-JSStringRef AccessibilityUIElement::parameterizedAttributeNames()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::parameterizedAttributeNames()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::role()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::role()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::subrole()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::subrole()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 bool AccessibilityUIElement::scrollPageUp()
@@ -775,43 +772,42 @@ bool AccessibilityUIElement::scrollPageRight()
     return [m_element accessibilityScroll:UIAccessibilityScrollDirectionRight];
 }
 
-JSStringRef AccessibilityUIElement::roleDescription()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::roleDescription()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::computedRoleString()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::computedRoleString()
 {
-    // FIXME: implement
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::title()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::title()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::description()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::description()
 {
     return concatenateAttributeAndValue(@"AXLabel", [m_element accessibilityLabel]);
 }
 
-JSStringRef AccessibilityUIElement::orientation() const
+JSRetainPtr<JSStringRef> AccessibilityUIElement::orientation() const
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::stringValue()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::stringValue()
 {
     return concatenateAttributeAndValue(@"AXValue", [m_element accessibilityValue]);
 }
 
-JSStringRef AccessibilityUIElement::language()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::language()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::helpText() const
+JSRetainPtr<JSStringRef> AccessibilityUIElement::helpText() const
 {
     return concatenateAttributeAndValue(@"AXHint", [m_element accessibilityHint]);
 }
@@ -836,9 +832,9 @@ void AccessibilityUIElement::setValue(JSStringRef valueText)
     [m_element _accessibilitySetValue:[NSString stringWithJSStringRef:valueText]];
 }
 
-JSStringRef AccessibilityUIElement::valueDescription()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::valueDescription()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 int AccessibilityUIElement::insertionPointLineNumber()
@@ -895,9 +891,9 @@ bool AccessibilityUIElement::ariaIsGrabbed() const
     return false;
 }
 
-JSStringRef AccessibilityUIElement::ariaDropEffects() const
+JSRetainPtr<JSStringRef> AccessibilityUIElement::ariaDropEffects() const
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 int AccessibilityUIElement::lineForIndex(int index)
@@ -905,39 +901,39 @@ int AccessibilityUIElement::lineForIndex(int index)
     return -1;
 }
 
-JSStringRef AccessibilityUIElement::boundsForRange(unsigned location, unsigned length)
+JSRetainPtr<JSStringRef> AccessibilityUIElement::boundsForRange(unsigned location, unsigned length)
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::attributesOfColumnHeaders()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfColumnHeaders()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::attributesOfRowHeaders()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfRowHeaders()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::attributesOfColumns()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfColumns()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::attributesOfRows()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfRows()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::attributesOfVisibleCells()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfVisibleCells()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::attributesOfHeader()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfHeader()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 int AccessibilityUIElement::rowCount()
@@ -955,18 +951,18 @@ int AccessibilityUIElement::indexInTable()
     return -1;
 }
 
-JSStringRef AccessibilityUIElement::rowIndexRange()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::rowIndexRange()
 {
     NSRange range = [m_element accessibilityRowRange];
     NSMutableString* rangeDescription = [NSMutableString stringWithFormat:@"{%lu, %lu}", (unsigned long)range.location, (unsigned long)range.length];
     return [rangeDescription createJSStringRef];
 }
 
-JSStringRef AccessibilityUIElement::columnIndexRange()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::columnIndexRange()
 {
     NSRange range = [m_element accessibilityColumnRange];
     NSMutableString* rangeDescription = [NSMutableString stringWithFormat:@"{%lu, %lu}", (unsigned long)range.location, (unsigned long)range.length];
-    return [rangeDescription createJSStringRef];    
+    return [rangeDescription createJSStringRef];
 }
 
 AccessibilityUIElement AccessibilityUIElement::cellForColumnAndRow(unsigned col, unsigned row)
@@ -989,9 +985,9 @@ void AccessibilityUIElement::scrollToGlobalPoint(int x, int y)
     // FIXME: implement
 }
 
-JSStringRef AccessibilityUIElement::selectedTextRange()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::selectedTextRange()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 void AccessibilityUIElement::assistiveTechnologySimulatedFocus()
@@ -1022,10 +1018,10 @@ void AccessibilityUIElement::press()
     [m_element _accessibilityActivate];
 }
 
-JSStringRef AccessibilityUIElement::accessibilityValue() const
+JSRetainPtr<JSStringRef> AccessibilityUIElement::accessibilityValue() const
 {
     // FIXME: implement
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 void AccessibilityUIElement::clearSelectedChildren() const
@@ -1033,14 +1029,14 @@ void AccessibilityUIElement::clearSelectedChildren() const
     // FIXME: implement
 }
 
-JSStringRef AccessibilityUIElement::documentEncoding()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::documentEncoding()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::documentURI()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::documentURI()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 bool AccessibilityUIElement::addNotificationListener(JSObjectRef functionCallback)
@@ -1174,7 +1170,7 @@ AccessibilityUIElement AccessibilityUIElement::uiElementForSearchPredicate(JSCon
     return AccessibilityUIElement([value firstObject]);
 }
 
-JSStringRef AccessibilityUIElement::selectTextWithCriteria(JSContextRef context, JSStringRef ambiguityResolution, JSValueRef searchStrings, JSStringRef replacementString, JSStringRef activity)
+JSRetainPtr<JSStringRef> AccessibilityUIElement::selectTextWithCriteria(JSContextRef context, JSStringRef ambiguityResolution, JSValueRef searchStrings, JSStringRef replacementString, JSStringRef activity)
 {
     // FIXME: Implement.
     return nullptr;
@@ -1197,7 +1193,7 @@ double AccessibilityUIElement::numberAttributeValue(JSStringRef attribute)
     return 0;
 }
 
-JSStringRef AccessibilityUIElement::classList() const
+JSRetainPtr<JSStringRef> AccessibilityUIElement::classList() const
 {
     // FIXME: implement
     return nullptr;
index a532127..2f013a1 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef AccessibilityCommonMac_h
-#define AccessibilityCommonMac_h
+#pragma once
 
 #import "AccessibilityUIElement.h"
-
-#import <JavaScriptCore/JSStringRef.h>
+#import <JavaScriptCore/JSRetainPtr.h>
 
 // If an unsupported attribute is passed in, it will raise an accessibility exception. These are usually caught by the Accessibility Runtime to inform
 // the AX client app of the error. However, DRT is the AX client app, so it must catch these exceptions.
 #define BEGIN_AX_OBJC_EXCEPTIONS @try {
 #define END_AX_OBJC_EXCEPTIONS } @catch(NSException *e) { if (![[e name] isEqualToString:NSAccessibilityException]) @throw; }
 
-
 @interface NSString (JSStringRefAdditions)
 + (NSString *)stringWithJSStringRef:(JSStringRef)jsStringRef;
-- (JSStringRef)createJSStringRef;
+- (JSRetainPtr<JSStringRef>)createJSStringRef;
 @end
 
 extern NSDictionary *searchPredicateParameterizedAttributeForSearchCriteria(JSContextRef, AccessibilityUIElement *startElement, bool isDirectionNext, unsigned resultsLimit, JSValueRef searchKey, JSStringRef searchText, bool visibleOnly, bool immediateDescendantsOnly);
-
-#endif // AccessibilityCommonMac_h
index 6597cad..0b867ad 100644 (file)
@@ -31,8 +31,6 @@
 #import "config.h"
 #import "AccessibilityCommonMac.h"
 
-#import <JavaScriptCore/JSRetainPtr.h>
-#import <JavaScriptCore/JSStringRef.h>
 #import <JavaScriptCore/JSStringRefCF.h>
 
 @implementation NSString (JSStringRefAdditions)
@@ -45,9 +43,9 @@
     return CFBridgingRelease(JSStringCopyCFString(kCFAllocatorDefault, jsStringRef));
 }
 
-- (JSStringRef)createJSStringRef
+- (JSRetainPtr<JSStringRef>)createJSStringRef
 {
-    return JSStringCreateWithCFString((__bridge CFStringRef)self);
+    return adopt(JSStringCreateWithCFString((__bridge CFStringRef)self));
 }
 
 NSDictionary *searchPredicateParameterizedAttributeForSearchCriteria(JSContextRef context, AccessibilityUIElement *startElement, bool isDirectionNext, unsigned resultsLimit, JSValueRef searchKey, JSStringRef searchText, bool visibleOnly, bool immediateDescendantsOnly)
@@ -64,14 +62,14 @@ NSDictionary *searchPredicateParameterizedAttributeForSearchCriteria(JSContextRe
     if (searchKey) {
         id searchKeyParameter = nil;
         if (JSValueIsString(context, searchKey)) {
-            JSRetainPtr<JSStringRef> searchKeyString(Adopt, JSValueToStringCopy(context, searchKey, nullptr));
+            auto searchKeyString = adopt(JSValueToStringCopy(context, searchKey, nullptr));
             if (searchKeyString)
                 searchKeyParameter = [NSString stringWithJSStringRef:searchKeyString.get()];
         } else if (JSValueIsObject(context, searchKey)) {
             JSObjectRef searchKeyArray = JSValueToObject(context, searchKey, nullptr);
             unsigned searchKeyArrayLength = 0;
             
-            JSRetainPtr<JSStringRef> lengthPropertyString(Adopt, JSStringCreateWithUTF8CString("length"));
+            auto lengthPropertyString = adopt(JSStringCreateWithUTF8CString("length"));
             JSValueRef searchKeyArrayLengthValue = JSObjectGetProperty(context, searchKeyArray, lengthPropertyString.get(), nullptr);
             if (searchKeyArrayLengthValue && JSValueIsNumber(context, searchKeyArrayLengthValue))
                 searchKeyArrayLength = static_cast<unsigned>(JSValueToNumber(context, searchKeyArrayLengthValue, nullptr));
index 6b54455..51f031d 100644 (file)
@@ -158,6 +158,5 @@ bool AccessibilityController::enhancedAccessibilityEnabled()
 
 JSRetainPtr<JSStringRef> AccessibilityController::platformName() const
 {
-    JSRetainPtr<JSStringRef> platformName(Adopt, JSStringCreateWithUTF8CString("mac"));
-    return platformName;
+    return adopt(JSStringCreateWithUTF8CString("mac"));
 }
index 03aa9c6..9d7ff6e 100644 (file)
@@ -34,7 +34,6 @@
 #import "AccessibilityUIElement.h"
 
 #import <JavaScriptCore/JSRetainPtr.h>
-#import <JavaScriptCore/JSStringRef.h>
 #import <JavaScriptCore/JSStringRefCF.h>
 #import <WebKit/WebFrame.h>
 #import <objc/runtime.h>
 @end
 
 @interface NSString (JSStringRefAdditions)
-- (JSStringRef)createJSStringRef;
+- (JSRetainPtr<JSStringRef>)createJSStringRef;
 @end
 
 @implementation NSString (JSStringRefAdditions)
 
-- (JSStringRef)createJSStringRef
+- (JSRetainPtr<JSStringRef>)createJSStringRef
 {
-    return JSStringCreateWithCFString((__bridge CFStringRef)self);
+    return adopt(JSStringCreateWithCFString((__bridge CFStringRef)self));
 }
 
 @end
@@ -118,7 +117,7 @@ static Class webAccessibilityObjectWrapperClass()
 static JSValueRef makeValueRefForValue(JSContextRef context, id value)
 {
     if ([value isKindOfClass:[NSString class]])
-        return JSValueMakeString(context, adopt([value createJSStringRef]).get());
+        return JSValueMakeString(context, [value createJSStringRef].get());
     if ([value isKindOfClass:[NSNumber class]]) {
         if (!strcmp([value objCType], @encode(BOOL)))
             return JSValueMakeBoolean(context, [value boolValue]);
@@ -151,7 +150,7 @@ static JSValueRef makeObjectRefForDictionary(JSContextRef context, NSDictionary
     [dictionary enumerateKeysAndObjectsUsingBlock:^(NSString *key, id obj, BOOL *stop)
     {
         if (JSValueRef propertyValue = makeValueRefForValue(context, obj))
-            JSObjectSetProperty(context, object, adopt([key createJSStringRef]).get(), propertyValue, kJSPropertyAttributeNone, nullptr);
+            JSObjectSetProperty(context, object, [key createJSStringRef].get(), propertyValue, kJSPropertyAttributeNone, nullptr);
     }];
 
     return object;
@@ -166,7 +165,7 @@ static JSValueRef makeObjectRefForDictionary(JSContextRef context, NSDictionary
         return;
 
     NSDictionary *userInfo = [[notification userInfo] objectForKey:@"userInfo"];
-    JSValueRef notificationNameArgument = JSValueMakeString([mainFrame globalContext], adopt([notificationName createJSStringRef]).get());
+    JSValueRef notificationNameArgument = JSValueMakeString([mainFrame globalContext], [notificationName createJSStringRef].get());
     JSValueRef userInfoArgument = makeObjectRefForDictionary([mainFrame globalContext], userInfo);
     if (m_platformElement) {
         // Listener for one element gets the notification name and userInfo.
index ba9b550..b242a96 100644 (file)
@@ -30,8 +30,6 @@
 #import "AccessibilityUIElement.h"
 
 #import <Foundation/Foundation.h>
-#import <JavaScriptCore/JSRetainPtr.h>
-#import <JavaScriptCore/JSStringRef.h>
 #import <JavaScriptCore/JSStringRefCF.h>
 #import <WebKit/WebFrame.h>
 #import <WebKit/WebHTMLView.h>
@@ -81,6 +79,11 @@ typedef void (*AXPostedNotificationCallback)(id element, NSString* notification,
 - (void)_accessibilitySetValue:(id)value forAttribute:(NSString*)attributeName;
 @end
 
+static JSRetainPtr<JSStringRef> createEmptyJSString()
+{
+    return adopt(JSStringCreateWithCharacters(nullptr, 0));
+}
+
 AccessibilityUIElement::AccessibilityUIElement(PlatformUIElement element)
     : m_element(element)
     , m_notificationHandler(0)
@@ -174,7 +177,7 @@ static NSString* attributesOfElement(id accessibilityObject)
     return attributesString;
 }
 
-static JSStringRef concatenateAttributeAndValue(NSString* attribute, NSString* value)
+static JSRetainPtr<JSStringRef> concatenateAttributeAndValue(NSString *attribute, NSString *value)
 {
     Vector<UniChar> buffer([attribute length]);
     [attribute getCharacters:buffer.data()];
@@ -185,7 +188,7 @@ static JSStringRef concatenateAttributeAndValue(NSString* attribute, NSString* v
     [value getCharacters:valueBuffer.data()];
     buffer.appendVector(valueBuffer);
 
-    return JSStringCreateWithCharacters(buffer.data(), buffer.size());
+    return adopt(JSStringCreateWithCharacters(buffer.data(), buffer.size()));
 }
 
 static void convertNSArrayToVector(NSArray* array, Vector<AccessibilityUIElement>& elementVector)
@@ -195,7 +198,7 @@ static void convertNSArrayToVector(NSArray* array, Vector<AccessibilityUIElement
         elementVector.append(AccessibilityUIElement([array objectAtIndex:i]));
 }
 
-static JSStringRef descriptionOfElements(Vector<AccessibilityUIElement>& elementVector)
+static JSRetainPtr<JSStringRef> descriptionOfElements(Vector<AccessibilityUIElement>& elementVector)
 {
     NSMutableString* allElementString = [NSMutableString string];
     size_t size = elementVector.size();
@@ -217,7 +220,7 @@ static NSDictionary *selectTextParameterizedAttributeForCriteria(JSContextRef co
     if (searchStrings) {
         NSMutableArray *searchStringsParameter = [NSMutableArray array];
         if (JSValueIsString(context, searchStrings)) {
-            JSRetainPtr<JSStringRef> searchStringsString(Adopt, JSValueToStringCopy(context, searchStrings, nullptr));
+            auto searchStringsString = adopt(JSValueToStringCopy(context, searchStrings, nullptr));
             if (searchStringsString)
                 [searchStringsParameter addObject:[NSString stringWithJSStringRef:searchStringsString.get()]];
         }
@@ -225,13 +228,13 @@ static NSDictionary *selectTextParameterizedAttributeForCriteria(JSContextRef co
             JSObjectRef searchStringsArray = JSValueToObject(context, searchStrings, nullptr);
             unsigned searchStringsArrayLength = 0;
             
-            JSRetainPtr<JSStringRef> lengthPropertyString(Adopt, JSStringCreateWithUTF8CString("length"));
+            auto lengthPropertyString = adopt(JSStringCreateWithUTF8CString("length"));
             JSValueRef searchStringsArrayLengthValue = JSObjectGetProperty(context, searchStringsArray, lengthPropertyString.get(), nullptr);
             if (searchStringsArrayLengthValue && JSValueIsNumber(context, searchStringsArrayLengthValue))
                 searchStringsArrayLength = static_cast<unsigned>(JSValueToNumber(context, searchStringsArrayLengthValue, nullptr));
             
             for (unsigned i = 0; i < searchStringsArrayLength; ++i) {
-                JSRetainPtr<JSStringRef> searchStringsString(Adopt, JSValueToStringCopy(context, JSObjectGetPropertyAtIndex(context, searchStringsArray, i, nullptr), nullptr));
+                auto searchStringsString = adopt(JSValueToStringCopy(context, JSObjectGetPropertyAtIndex(context, searchStringsArray, i, nullptr), nullptr));
                 if (searchStringsString)
                     [searchStringsParameter addObject:[NSString stringWithJSStringRef:searchStringsString.get()]];
             }
@@ -445,34 +448,34 @@ AccessibilityUIElement AccessibilityUIElement::disclosedByRow()
     return nullptr;
 }
 
-JSStringRef AccessibilityUIElement::attributesOfLinkedUIElements()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfLinkedUIElements()
 {
     Vector<AccessibilityUIElement> linkedElements;
     getLinkedUIElements(linkedElements);
     return descriptionOfElements(linkedElements);
 }
 
-JSStringRef AccessibilityUIElement::attributesOfDocumentLinks()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfDocumentLinks()
 {
     Vector<AccessibilityUIElement> linkElements;
     getDocumentLinks(linkElements);
     return descriptionOfElements(linkElements);
 }
 
-JSStringRef AccessibilityUIElement::attributesOfChildren()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfChildren()
 {
     Vector<AccessibilityUIElement> children;
     getChildren(children);
     return descriptionOfElements(children);
 }
 
-JSStringRef AccessibilityUIElement::allAttributes()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::allAttributes()
 {
     NSString* attributes = attributesOfElement(m_element);
     return [attributes createJSStringRef];
 }
 
-JSStringRef AccessibilityUIElement::stringAttributeValue(JSStringRef attribute)
+JSRetainPtr<JSStringRef> AccessibilityUIElement::stringAttributeValue(JSStringRef attribute)
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     id value = [m_element accessibilityAttributeValue:[NSString stringWithJSStringRef:attribute]];
@@ -568,7 +571,7 @@ bool AccessibilityUIElement::isAttributeSupported(JSStringRef attribute)
     return false;
 }
 
-JSStringRef AccessibilityUIElement::parameterizedAttributeNames()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::parameterizedAttributeNames()
 {
     NSArray* supportedParameterizedAttributes = [m_element accessibilityParameterizedAttributeNames];
     
@@ -580,7 +583,7 @@ JSStringRef AccessibilityUIElement::parameterizedAttributeNames()
     return [attributesString createJSStringRef];
 }
 
-JSStringRef AccessibilityUIElement::role()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::role()
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     NSString *role = descriptionOfValue([m_element accessibilityAttributeValue:NSAccessibilityRoleAttribute], m_element);
@@ -590,7 +593,7 @@ JSStringRef AccessibilityUIElement::role()
     return nullptr;
 }
 
-JSStringRef AccessibilityUIElement::subrole()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::subrole()
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     NSString* role = descriptionOfValue([m_element accessibilityAttributeValue:NSAccessibilitySubroleAttribute], m_element);
@@ -600,7 +603,7 @@ JSStringRef AccessibilityUIElement::subrole()
     return nullptr;
 }
 
-JSStringRef AccessibilityUIElement::roleDescription()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::roleDescription()
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     NSString* role = descriptionOfValue([m_element accessibilityAttributeValue:NSAccessibilityRoleDescriptionAttribute], m_element);
@@ -610,7 +613,7 @@ JSStringRef AccessibilityUIElement::roleDescription()
     return nullptr;
 }
 
-JSStringRef AccessibilityUIElement::computedRoleString()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::computedRoleString()
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     NSString *computedRoleString = descriptionOfValue([m_element accessibilityAttributeValue:@"AXARIARole"], m_element);
@@ -620,7 +623,7 @@ JSStringRef AccessibilityUIElement::computedRoleString()
     return nullptr;
 }
 
-JSStringRef AccessibilityUIElement::title()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::title()
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     NSString* title = descriptionOfValue([m_element accessibilityAttributeValue:NSAccessibilityTitleAttribute], m_element);
@@ -630,7 +633,7 @@ JSStringRef AccessibilityUIElement::title()
     return nullptr;
 }
 
-JSStringRef AccessibilityUIElement::description()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::description()
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     id description = descriptionOfValue([m_element accessibilityAttributeValue:NSAccessibilityDescriptionAttribute], m_element);
@@ -640,17 +643,17 @@ JSStringRef AccessibilityUIElement::description()
     return nullptr;
 }
 
-JSStringRef AccessibilityUIElement::orientation() const
+JSRetainPtr<JSStringRef> AccessibilityUIElement::orientation() const
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     id description = descriptionOfValue([m_element accessibilityAttributeValue:NSAccessibilityOrientationAttribute], m_element);
-    return concatenateAttributeAndValue(@"AXOrientation", description);    
+    return concatenateAttributeAndValue(@"AXOrientation", description);
     END_AX_OBJC_EXCEPTIONS
 
     return nullptr;
 }
 
-JSStringRef AccessibilityUIElement::stringValue()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::stringValue()
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     id description = descriptionOfValue([m_element accessibilityAttributeValue:NSAccessibilityValueAttribute], m_element);
@@ -661,7 +664,7 @@ JSStringRef AccessibilityUIElement::stringValue()
     return nullptr;
 }
 
-JSStringRef AccessibilityUIElement::language()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::language()
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     id description = descriptionOfValue([m_element accessibilityAttributeValue:@"AXLanguage"], m_element);
@@ -671,7 +674,7 @@ JSStringRef AccessibilityUIElement::language()
     return nullptr;
 }
 
-JSStringRef AccessibilityUIElement::helpText() const
+JSRetainPtr<JSStringRef> AccessibilityUIElement::helpText() const
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     id description = descriptionOfValue([m_element accessibilityAttributeValue:NSAccessibilityHelpAttribute], m_element);
@@ -774,7 +777,7 @@ double AccessibilityUIElement::maxValue()
     return 0.0;
 }
 
-JSStringRef AccessibilityUIElement::valueDescription()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::valueDescription()
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     NSString* valueDescription = [m_element accessibilityAttributeValue:NSAccessibilityValueDescriptionAttribute];
@@ -898,7 +901,7 @@ int AccessibilityUIElement::hierarchicalLevel() const
     return 0;
 }
 
-JSStringRef AccessibilityUIElement::speakAs()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::speakAs()
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     id value = [m_element accessibilityAttributeValue:@"AXDRTSpeechAttribute"];
@@ -909,7 +912,7 @@ JSStringRef AccessibilityUIElement::speakAs()
     return nullptr;
 }
 
-JSStringRef AccessibilityUIElement::classList() const
+JSRetainPtr<JSStringRef> AccessibilityUIElement::classList() const
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     id value = [m_element accessibilityAttributeValue:@"AXDOMClassList"];
@@ -941,7 +944,7 @@ bool AccessibilityUIElement::ariaIsGrabbed() const
     return false;
 }
 
-JSStringRef AccessibilityUIElement::ariaDropEffects() const
+JSRetainPtr<JSStringRef> AccessibilityUIElement::ariaDropEffects() const
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     id value = [m_element accessibilityAttributeValue:NSAccessibilityDropEffectsAttribute];
@@ -974,7 +977,7 @@ int AccessibilityUIElement::lineForIndex(int index)
     return -1;
 }
 
-JSStringRef AccessibilityUIElement::rangeForLine(int line)
+JSRetainPtr<JSStringRef> AccessibilityUIElement::rangeForLine(int line)
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     id value = [m_element accessibilityAttributeValue:NSAccessibilityRangeForLineParameterizedAttribute forParameter:[NSNumber numberWithInt:line]];
@@ -985,7 +988,7 @@ JSStringRef AccessibilityUIElement::rangeForLine(int line)
     return nullptr;
 }
 
-JSStringRef AccessibilityUIElement::rangeForPosition(int x, int y)
+JSRetainPtr<JSStringRef> AccessibilityUIElement::rangeForPosition(int x, int y)
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     id value = [m_element accessibilityAttributeValue:NSAccessibilityRangeForPositionParameterizedAttribute forParameter:[NSValue valueWithPoint:NSMakePoint(x, y)]];
@@ -997,7 +1000,7 @@ JSStringRef AccessibilityUIElement::rangeForPosition(int x, int y)
 }
 
 
-JSStringRef AccessibilityUIElement::boundsForRange(unsigned location, unsigned length)
+JSRetainPtr<JSStringRef> AccessibilityUIElement::boundsForRange(unsigned location, unsigned length)
 {
     NSRange range = NSMakeRange(location, length);
     BEGIN_AX_OBJC_EXCEPTIONS
@@ -1014,7 +1017,7 @@ JSStringRef AccessibilityUIElement::boundsForRange(unsigned location, unsigned l
     return nullptr;
 }
 
-JSStringRef AccessibilityUIElement::stringForRange(unsigned location, unsigned length)
+JSRetainPtr<JSStringRef> AccessibilityUIElement::stringForRange(unsigned location, unsigned length)
 {
     NSRange range = NSMakeRange(location, length);
     BEGIN_AX_OBJC_EXCEPTIONS
@@ -1028,7 +1031,7 @@ JSStringRef AccessibilityUIElement::stringForRange(unsigned location, unsigned l
     return nullptr;
 }
 
-JSStringRef AccessibilityUIElement::attributedStringForRange(unsigned location, unsigned length)
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForRange(unsigned location, unsigned length)
 {
     NSRange range = NSMakeRange(location, length);
     BEGIN_AX_OBJC_EXCEPTIONS
@@ -1087,7 +1090,7 @@ AccessibilityUIElement AccessibilityUIElement::uiElementForSearchPredicate(JSCon
     return nullptr;
 }
 
-JSStringRef AccessibilityUIElement::selectTextWithCriteria(JSContextRef context, JSStringRef ambiguityResolution, JSValueRef searchStrings, JSStringRef replacementString, JSStringRef activity)
+JSRetainPtr<JSStringRef> AccessibilityUIElement::selectTextWithCriteria(JSContextRef context, JSStringRef ambiguityResolution, JSValueRef searchStrings, JSStringRef replacementString, JSStringRef activity)
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     NSDictionary *parameterizedAttribute = selectTextParameterizedAttributeForCriteria(context, ambiguityResolution, searchStrings, replacementString, activity);
@@ -1099,7 +1102,7 @@ JSStringRef AccessibilityUIElement::selectTextWithCriteria(JSContextRef context,
     return nullptr;
 }
 
-JSStringRef AccessibilityUIElement::attributesOfColumnHeaders()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfColumnHeaders()
 {
     // not yet defined in AppKit... odd
     BEGIN_AX_OBJC_EXCEPTIONS
@@ -1112,7 +1115,7 @@ JSStringRef AccessibilityUIElement::attributesOfColumnHeaders()
     return nullptr;
 }
 
-JSStringRef AccessibilityUIElement::attributesOfRowHeaders()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfRowHeaders()
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     NSArray* rowHeadersArray = [m_element accessibilityAttributeValue:@"AXRowHeaderUIElements"];
@@ -1124,7 +1127,7 @@ JSStringRef AccessibilityUIElement::attributesOfRowHeaders()
     return nullptr;
 }
 
-JSStringRef AccessibilityUIElement::attributesOfColumns()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfColumns()
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     NSArray* columnsArray = [m_element accessibilityAttributeValue:NSAccessibilityColumnsAttribute];
@@ -1136,7 +1139,7 @@ JSStringRef AccessibilityUIElement::attributesOfColumns()
     return nullptr;
 }
 
-JSStringRef AccessibilityUIElement::attributesOfRows()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfRows()
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     NSArray* rowsArray = [m_element accessibilityAttributeValue:NSAccessibilityRowsAttribute];
@@ -1148,7 +1151,7 @@ JSStringRef AccessibilityUIElement::attributesOfRows()
     return nullptr;
 }
 
-JSStringRef AccessibilityUIElement::attributesOfVisibleCells()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfVisibleCells()
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     NSArray* cellsArray = [m_element accessibilityAttributeValue:@"AXVisibleCells"];
@@ -1160,7 +1163,7 @@ JSStringRef AccessibilityUIElement::attributesOfVisibleCells()
     return nullptr;
 }
 
-JSStringRef AccessibilityUIElement::attributesOfHeader()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfHeader()
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     id headerObject = [m_element accessibilityAttributeValue:NSAccessibilityHeaderAttribute];
@@ -1204,7 +1207,7 @@ int AccessibilityUIElement::indexInTable()
     return -1;
 }
 
-JSStringRef AccessibilityUIElement::rowIndexRange()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::rowIndexRange()
 {
     NSRange range = NSMakeRange(0, 0);
     BEGIN_AX_OBJC_EXCEPTIONS
@@ -1218,7 +1221,7 @@ JSStringRef AccessibilityUIElement::rowIndexRange()
     return nullptr;
 }
 
-JSStringRef AccessibilityUIElement::columnIndexRange()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::columnIndexRange()
 {
     NSRange range = NSMakeRange(0, 0);
     BEGIN_AX_OBJC_EXCEPTIONS
@@ -1226,7 +1229,7 @@ JSStringRef AccessibilityUIElement::columnIndexRange()
     if (indexRange)
         range = [indexRange rangeValue];
     NSMutableString* rangeDescription = [NSMutableString stringWithFormat:@"{%lu, %lu}",static_cast<unsigned long>(range.location), static_cast<unsigned long>(range.length)];
-    return [rangeDescription createJSStringRef];    
+    return [rangeDescription createJSStringRef];
     END_AX_OBJC_EXCEPTIONS
     
     return nullptr;
@@ -1266,7 +1269,7 @@ AccessibilityUIElement AccessibilityUIElement::verticalScrollbar() const
     return nullptr;
 }
 
-JSStringRef AccessibilityUIElement::pathDescription() const
+JSRetainPtr<JSStringRef> AccessibilityUIElement::pathDescription() const
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     NSMutableString *result = [NSMutableString stringWithString:@"\nStart Path\n"];
@@ -1299,7 +1302,7 @@ JSStringRef AccessibilityUIElement::pathDescription() const
     return nullptr;
 }
 
-JSStringRef AccessibilityUIElement::selectedTextRange()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::selectedTextRange()
 {
     NSRange range = NSMakeRange(NSNotFound, 0);
     BEGIN_AX_OBJC_EXCEPTIONS
@@ -1307,7 +1310,7 @@ JSStringRef AccessibilityUIElement::selectedTextRange()
     if (indexRange)
         range = [indexRange rangeValue];
     NSMutableString *rangeDescription = [NSMutableString stringWithFormat:@"{%lu, %lu}", static_cast<unsigned long>(range.location), static_cast<unsigned long>(range.length)];
-    return [rangeDescription createJSStringRef];    
+    return [rangeDescription createJSStringRef];
     END_AX_OBJC_EXCEPTIONS
     
     return nullptr;
@@ -1397,13 +1400,13 @@ void AccessibilityUIElement::clearSelectedChildren() const
     // FIXME: implement
 }
 
-JSStringRef AccessibilityUIElement::accessibilityValue() const
+JSRetainPtr<JSStringRef> AccessibilityUIElement::accessibilityValue() const
 {
     // FIXME: implement
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::documentEncoding()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::documentEncoding()
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     id value = [m_element accessibilityAttributeValue:@"AXDocumentEncoding"];
@@ -1411,10 +1414,10 @@ JSStringRef AccessibilityUIElement::documentEncoding()
         return [value createJSStringRef];
     END_AX_OBJC_EXCEPTIONS
     
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::documentURI()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::documentURI()
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     id value = [m_element accessibilityAttributeValue:@"AXDocumentURI"];
@@ -1422,14 +1425,14 @@ JSStringRef AccessibilityUIElement::documentURI()
         return [value createJSStringRef];
     END_AX_OBJC_EXCEPTIONS
     
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::url()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::url()
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     NSURL *url = [m_element accessibilityAttributeValue:NSAccessibilityURLAttribute];
-    return [[url absoluteString] createJSStringRef];    
+    return [[url absoluteString] createJSStringRef];
     END_AX_OBJC_EXCEPTIONS
     
     return nullptr;
@@ -1705,7 +1708,7 @@ AccessibilityTextMarker AccessibilityUIElement::nextTextMarker(AccessibilityText
     return nullptr;
 }
 
-JSStringRef AccessibilityUIElement::stringForTextMarkerRange(AccessibilityTextMarkerRange* markerRange)
+JSRetainPtr<JSStringRef> AccessibilityUIElement::stringForTextMarkerRange(AccessibilityTextMarkerRange* markerRange)
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     id textString = [m_element accessibilityAttributeValue:@"AXStringForTextMarkerRange" forParameter:(__bridge id)markerRange->platformTextMarkerRange()];
@@ -1715,7 +1718,7 @@ JSStringRef AccessibilityUIElement::stringForTextMarkerRange(AccessibilityTextMa
     return nullptr;
 }
 
-static JSStringRef createJSStringRef(id string)
+static JSRetainPtr<JSStringRef> createJSStringRef(id string)
 {
     if (!string)
         return nullptr;
@@ -1736,13 +1739,13 @@ static JSStringRef createJSStringRef(id string)
     return [mutableString createJSStringRef];
 }
 
-JSStringRef AccessibilityUIElement::attributedStringForTextMarkerRange(AccessibilityTextMarkerRange* markerRange)
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForTextMarkerRange(AccessibilityTextMarkerRange* markerRange)
 {
     id string = [m_element accessibilityAttributeValue:@"AXAttributedStringForTextMarkerRange" forParameter:(__bridge id)markerRange->platformTextMarkerRange()];
     return createJSStringRef(string);
 }
 
-JSStringRef AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions(AccessibilityTextMarkerRange* markerRange, bool includeSpellCheck)
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions(AccessibilityTextMarkerRange* markerRange, bool includeSpellCheck)
 {
     id parameter = nil;
     if (includeSpellCheck)
@@ -1955,7 +1958,7 @@ AccessibilityTextMarker AccessibilityUIElement::nextSentenceEndTextMarkerForText
 
 #endif // SUPPORTS_AX_TEXTMARKERS && PLATFORM(MAC)
 
-JSStringRef AccessibilityUIElement::supportedActions()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::supportedActions()
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     NSArray *names = [m_element accessibilityActionNames];
@@ -1976,7 +1979,7 @@ static NSString *convertMathMultiscriptPairsToString(NSArray *pairs)
     return result;
 }
 
-JSStringRef AccessibilityUIElement::mathPostscriptsDescription() const
+JSRetainPtr<JSStringRef> AccessibilityUIElement::mathPostscriptsDescription() const
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     NSArray *pairs = [m_element accessibilityAttributeValue:@"AXMathPostscripts"];
@@ -1986,7 +1989,7 @@ JSStringRef AccessibilityUIElement::mathPostscriptsDescription() const
     return nullptr;
 }
 
-JSStringRef AccessibilityUIElement::mathPrescriptsDescription() const
+JSRetainPtr<JSStringRef> AccessibilityUIElement::mathPrescriptsDescription() const
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     NSArray *pairs = [m_element accessibilityAttributeValue:@"AXMathPrescripts"];
index 331e1d8..05b0392 100644 (file)
     if (!globalObject)
         return;
 
-    JSObjectSetProperty(ctx, globalObject, JSRetainPtr<JSStringRef>(Adopt, JSStringCreateWithUTF8CString("__worldID")).get(), JSValueMakeNumber(ctx, worldIDForWorld(world)), kJSPropertyAttributeReadOnly, 0);
+    JSObjectSetProperty(ctx, globalObject, adopt(JSStringCreateWithUTF8CString("__worldID")).get(), JSValueMakeNumber(ctx, worldIDForWorld(world)), kJSPropertyAttributeReadOnly, 0);
 }
 
 - (void)webView:(WebView *)sender didClearWindowObjectForFrame:(WebFrame *)frame inScriptWorld:(WebScriptWorld *)world
index 0f90274..b523165 100644 (file)
@@ -40,8 +40,6 @@
 #import "WorkQueue.h"
 #import "WorkQueueItem.h"
 #import <Foundation/Foundation.h>
-#import <JavaScriptCore/JSRetainPtr.h>
-#import <JavaScriptCore/JSStringRef.h>
 #import <JavaScriptCore/JSStringRefCF.h>
 #import <WebCore/GeolocationPosition.h>
 #import <WebKit/DOMDocument.h>
@@ -187,7 +185,7 @@ JSValueRef originsArrayToJS(JSContextRef context, NSArray *origins)
     JSObjectRef arrayObj = JSValueToObject(context, arrayResult, 0);
     for (NSUInteger i = 0; i < count; i++) {
         NSString *origin = [[origins objectAtIndex:i] databaseIdentifier];
-        JSRetainPtr<JSStringRef> originJS(Adopt, JSStringCreateWithCFString((__bridge CFStringRef)origin));
+        auto originJS = adopt(JSStringCreateWithCFString((__bridge CFStringRef)origin));
         JSObjectSetPropertyAtIndex(context, arrayObj, i, JSValueMakeString(context, originJS.get()), 0);
     }
 
@@ -249,18 +247,18 @@ void TestRunner::clearBackForwardList()
     [item release];
 }
 
-JSStringRef TestRunner::copyDecodedHostName(JSStringRef name)
+JSRetainPtr<JSStringRef> TestRunner::copyDecodedHostName(JSStringRef name)
 {
-    RetainPtr<CFStringRef> nameCF = adoptCF(JSStringCopyCFString(kCFAllocatorDefault, name));
+    auto nameCF = adoptCF(JSStringCopyCFString(kCFAllocatorDefault, name));
     NSString *nameNS = (__bridge NSString *)nameCF.get();
-    return JSStringCreateWithCFString((__bridge CFStringRef)[nameNS _web_decodeHostName]);
+    return adopt(JSStringCreateWithCFString((__bridge CFStringRef)[nameNS _web_decodeHostName]));
 }
 
-JSStringRef TestRunner::copyEncodedHostName(JSStringRef name)
+JSRetainPtr<JSStringRef> TestRunner::copyEncodedHostName(JSStringRef name)
 {
-    RetainPtr<CFStringRef> nameCF = adoptCF(JSStringCopyCFString(kCFAllocatorDefault, name));
+    auto nameCF = adoptCF(JSStringCopyCFString(kCFAllocatorDefault, name));
     NSString *nameNS = (__bridge NSString *)nameCF.get();
-    return JSStringCreateWithCFString((__bridge CFStringRef)[nameNS _web_encodeHostName]);
+    return adopt(JSStringCreateWithCFString((__bridge CFStringRef)[nameNS _web_encodeHostName]));
 }
 
 void TestRunner::display()
@@ -344,7 +342,7 @@ static inline std::string resourceRootAbsolutePath(const std::string& testURL, c
     return testURL.substr(0, indexOfSeparatorAfterDirectoryName(expectedRootName, testURL));
 }
 
-JSStringRef TestRunner::pathToLocalResource(JSContextRef context, JSStringRef localResourceJSString)
+JSRetainPtr<JSStringRef> TestRunner::pathToLocalResource(JSContextRef context, JSStringRef localResourceJSString)
 {
     // The passed in path will be an absolute path to the resource starting
     // with "/tmp" or "/tmp/LayoutTests", optionally starting with the explicit file:// protocol.
@@ -372,7 +370,7 @@ JSStringRef TestRunner::pathToLocalResource(JSContextRef context, JSStringRef lo
         ASSERT(absolutePathToLocalResource[0] == '/');
         absolutePathToLocalResource = std::string("file://") + absolutePathToLocalResource;
     }
-    return JSStringCreateWithUTF8CString(absolutePathToLocalResource.c_str());
+    return adopt(JSStringCreateWithUTF8CString(absolutePathToLocalResource.c_str()));
 }
 
 void TestRunner::queueLoad(JSStringRef url, JSStringRef target)
@@ -383,7 +381,7 @@ void TestRunner::queueLoad(JSStringRef url, JSStringRef target)
     NSURL *nsurl = [NSURL URLWithString:urlNS relativeToURL:[[[mainFrame dataSource] response] URL]];
     NSString *nsurlString = [nsurl absoluteString];
 
-    JSRetainPtr<JSStringRef> absoluteURL(Adopt, JSStringCreateWithUTF8CString([nsurlString UTF8String]));
+    auto absoluteURL = adopt(JSStringCreateWithUTF8CString([nsurlString UTF8String]));
     WorkQueue::singleton().queue(new LoadItem(absoluteURL.get(), target));
 }
 
@@ -681,7 +679,7 @@ bool TestRunner::findString(JSContextRef context, JSStringRef target, JSObjectRe
 {
     WebFindOptions options = 0;
 
-    JSRetainPtr<JSStringRef> lengthPropertyName(Adopt, JSStringCreateWithUTF8CString("length"));
+    auto lengthPropertyName = adopt(JSStringCreateWithUTF8CString("length"));
     JSValueRef lengthValue = JSObjectGetProperty(context, optionsArray, lengthPropertyName.get(), 0);
     if (!JSValueIsNumber(context, lengthValue))
         return false;
@@ -694,7 +692,7 @@ bool TestRunner::findString(JSContextRef context, JSStringRef target, JSObjectRe
         if (!JSValueIsString(context, value))
             continue;
 
-        JSRetainPtr<JSStringRef> optionName(Adopt, JSValueToStringCopy(context, value, 0));
+        auto optionName = adopt(JSValueToStringCopy(context, value, nullptr));
 
         if (JSStringIsEqualToUTF8CString(optionName.get(), "CaseInsensitive"))
             options |= WebFindOptionsCaseInsensitive;
@@ -816,7 +814,7 @@ void TestRunner::evaluateInWebInspector(JSStringRef script)
     [[[mainFrame webView] inspector] evaluateInFrontend:nil script:scriptNS];
 }
 
-JSStringRef TestRunner::inspectorTestStubURL()
+JSRetainPtr<JSStringRef> TestRunner::inspectorTestStubURL()
 {
 #if PLATFORM(IOS)
     return nullptr;
@@ -833,7 +831,7 @@ JSStringRef TestRunner::inspectorTestStubURL()
         return nullptr;
 
     CFStringRef urlString = CFURLGetString(url.get());
-    return JSStringCreateWithCFString(urlString);
+    return adopt(JSStringCreateWithCFString(urlString));
 #endif
 }
 
index b985df6..f416482 100644 (file)
@@ -363,7 +363,7 @@ void AccessibilityController::winNotificationReceived(PlatformUIElement element,
         if (!isSame)
             continue;
 
-        JSRetainPtr<JSStringRef> jsNotification(Adopt, JSStringCreateWithUTF8CString(eventName.c_str()));
+        auto jsNotification = adopt(JSStringCreateWithUTF8CString(eventName.c_str()));
         JSValueRef argument = JSValueMakeString(frame->globalContext(), jsNotification.get());
         JSObjectCallAsFunction(frame->globalContext(), slot.value, 0, 1, &argument, 0);
     }
@@ -391,6 +391,5 @@ bool AccessibilityController::enhancedAccessibilityEnabled()
 
 JSRetainPtr<JSStringRef> AccessibilityController::platformName() const
 {
-    JSRetainPtr<JSStringRef> platformName(Adopt, JSStringCreateWithUTF8CString("win"));
-    return platformName;
+    return adopt(JSStringCreateWithUTF8CString("win"));
 }
index a559542..e1b16ff 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008, 2013, 2014-2015 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008-2018 Apple Inc. All Rights Reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 
 using std::wstring;
 
+static JSRetainPtr<JSStringRef> createEmptyJSString()
+{
+    return adopt(JSStringCreateWithCharacters(nullptr, 0));
+}
+
 static COMPtr<IAccessibleComparable> comparableObject(IAccessible* accessible)
 {
     COMPtr<IServiceProvider> serviceProvider(Query, accessible);
@@ -163,19 +168,19 @@ unsigned AccessibilityUIElement::indexOfChild(AccessibilityUIElement* element)
     return 0;
 }
 
-JSStringRef AccessibilityUIElement::allAttributes()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::allAttributes()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::attributesOfLinkedUIElements()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfLinkedUIElements()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::attributesOfDocumentLinks()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfDocumentLinks()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 AccessibilityUIElement AccessibilityUIElement::titleUIElement()
@@ -216,14 +221,14 @@ AccessibilityUIElement AccessibilityUIElement::parentElement()
     return parentAccessible;
 }
 
-JSStringRef AccessibilityUIElement::attributesOfChildren()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfChildren()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::parameterizedAttributeNames()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::parameterizedAttributeNames()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 static VARIANT& self()
@@ -286,14 +291,14 @@ static _bstr_t convertToDRTLabel(const _bstr_t roleName)
     return roleName;
 }
 
-JSStringRef AccessibilityUIElement::role()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::role()
 {
     if (!m_element)
-        return JSStringCreateWithBSTR(_bstr_t(L"AXRole: "));
+        return adopt(JSStringCreateWithUTF8CString("AXRole: "));
 
     _variant_t vRole;
     if (FAILED(m_element->get_accRole(self(), &vRole.GetVARIANT())))
-        return JSStringCreateWithBSTR(_bstr_t(L"AXRole: "));
+        return adopt(JSStringCreateWithUTF8CString("AXRole: "));
 
     ASSERT(V_VT(&vRole) == VT_I4 || V_VT(&vRole) == VT_BSTR);
 
@@ -309,95 +314,95 @@ JSStringRef AccessibilityUIElement::role()
     } else if (V_VT(&vRole) == VT_BSTR)
         result = V_BSTR(&vRole);
 
-    return JSStringCreateWithBSTR(_bstr_t(L"AXRole: ") + convertToDRTLabel(result));
+    return adopt(JSStringCreateWithBSTR(_bstr_t(L"AXRole: ") + convertToDRTLabel(result)));
 }
 
-JSStringRef AccessibilityUIElement::subrole()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::subrole()
 {
     return 0;
 }
 
-JSStringRef AccessibilityUIElement::roleDescription()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::roleDescription()
 {
     return 0;
 }
 
-JSStringRef AccessibilityUIElement::computedRoleString()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::computedRoleString()
 {
     return 0;
 }
 
-JSStringRef AccessibilityUIElement::title()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::title()
 {
     if (!m_element)
-        return JSStringCreateWithBSTR(_bstr_t(L"AXTitle: "));
+        return adopt(JSStringCreateWithUTF8CString("AXTitle: "));
 
     _bstr_t titleBSTR;
     if (FAILED(m_element->get_accName(self(), &titleBSTR.GetBSTR())))
-        return JSStringCreateWithBSTR(_bstr_t(L"AXTitle: "));
+        return adopt(JSStringCreateWithUTF8CString("AXTitle: "));
 
-    return JSStringCreateWithBSTR(_bstr_t(L"AXTitle: ") + titleBSTR);
+    return adopt(JSStringCreateWithBSTR(_bstr_t(L"AXTitle: ") + titleBSTR));
 }
 
-JSStringRef AccessibilityUIElement::description()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::description()
 {
     if (!m_element)
-        return JSStringCreateWithBSTR(_bstr_t(L"AXDescription: "));
+        return adopt(JSStringCreateWithUTF8CString("AXDescription: "));
 
     _bstr_t descriptionBSTR;
     if (FAILED(m_element->get_accDescription(self(), &descriptionBSTR.GetBSTR())))
-        return JSStringCreateWithBSTR(_bstr_t(L"AXDescription: "));
+        return adopt(JSStringCreateWithUTF8CString("AXDescription: "));
 
     if (!descriptionBSTR.length())
-        return JSStringCreateWithBSTR(_bstr_t(L"AXDescription: "));
+        return adopt(JSStringCreateWithUTF8CString("AXDescription: "));
 
     if (wcsstr(static_cast<wchar_t*>(descriptionBSTR), L"Description: ") == static_cast<wchar_t*>(descriptionBSTR)) {
         // The Mozilla MSAA implementation requires that the string returned to us be prefixed with "Description: "
         // To match the Mac test results, we will just prefix with AX -> AXDescription:
-        return JSStringCreateWithBSTR(_bstr_t(L"AX") + descriptionBSTR);
+        return adopt(JSStringCreateWithBSTR(_bstr_t(L"AX") + descriptionBSTR));
     }
 
-    return JSStringCreateWithBSTR(descriptionBSTR);
+    return adopt(JSStringCreateWithBSTR(descriptionBSTR));
 }
 
-JSStringRef AccessibilityUIElement::stringValue()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::stringValue()
 {
     if (!m_element)
-        return JSStringCreateWithBSTR(_bstr_t(L"AXValue: "));
+        return adopt(JSStringCreateWithUTF8CString("AXValue: "));
 
     _bstr_t valueBSTR;
     if (FAILED(m_element->get_accValue(self(), &valueBSTR.GetBSTR())))
-        return JSStringCreateWithBSTR(_bstr_t(L"AXValue: "));
+        return adopt(JSStringCreateWithUTF8CString("AXValue: "));
 
-    return JSStringCreateWithBSTR(_bstr_t(L"AXValue: ") + valueBSTR);
+    return adopt(JSStringCreateWithBSTR(_bstr_t(L"AXValue: ") + valueBSTR));
 }
 
-JSStringRef AccessibilityUIElement::language()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::language()
 {
     if (!m_element)
-        return JSStringCreateWithBSTR(_bstr_t(L"AXLanguage: "));
+        return adopt(JSStringCreateWithUTF8CString("AXLanguage: "));
 
     COMPtr<IAccessibleComparable> accessible2Element = comparableObject(m_element.get());
     if (!accessible2Element)
-        return JSStringCreateWithBSTR(_bstr_t(L"AXLanguage: "));
+        return adopt(JSStringCreateWithUTF8CString("AXLanguage: "));
 
     IA2Locale locale;
     if (FAILED(accessible2Element->get_locale(&locale)))
-        return JSStringCreateWithBSTR(_bstr_t(L"AXLanguage: "));
+        return adopt(JSStringCreateWithUTF8CString("AXLanguage: "));
 
-    return JSStringCreateWithBSTR(_bstr_t(L"AXLanguage: ") + _bstr_t(locale.language, false));
+    return adopt(JSStringCreateWithBSTR(_bstr_t(L"AXLanguage: ") + _bstr_t(locale.language, false)));
 }
 
-JSStringRef AccessibilityUIElement::helpText() const
+JSRetainPtr<JSStringRef> AccessibilityUIElement::helpText() const
 {
     if (!m_element)
-        return JSStringCreateWithBSTR(_bstr_t(L"AXHelp: "));
+        return adopt(JSStringCreateWithUTF8CString("AXHelp: "));
 
     _bstr_t helpTextBSTR;
     if (FAILED(m_element->get_accHelp(self(), &helpTextBSTR.GetBSTR())))
-        return JSStringCreateWithBSTR(_bstr_t(L"AXHelp: "));
+        return adopt(JSStringCreateWithUTF8CString("AXHelp: "));
 
-    return JSStringCreateWithBSTR(_bstr_t(L"AXHelp: ") + helpTextBSTR);
+    return adopt(JSStringCreateWithBSTR(_bstr_t(L"AXHelp: ") + helpTextBSTR));
 }
 
 double AccessibilityUIElement::x()
@@ -454,7 +459,7 @@ double AccessibilityUIElement::clickPointY()
     return 0;
 }
 
-JSStringRef AccessibilityUIElement::valueDescription()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::valueDescription()
 {
     return nullptr;
 }
@@ -494,7 +499,7 @@ bool AccessibilityUIElement::ariaIsGrabbed() const
     return false;
 }
  
-JSStringRef AccessibilityUIElement::ariaDropEffects() const
+JSRetainPtr<JSStringRef> AccessibilityUIElement::ariaDropEffects() const
 {
     return 0;
 }
@@ -522,7 +527,7 @@ bool AccessibilityUIElement::isIndeterminate() const
     return false;
 }
 
-JSStringRef AccessibilityUIElement::orientation() const
+JSRetainPtr<JSStringRef> AccessibilityUIElement::orientation() const
 {
     return 0;
 }
@@ -592,34 +597,34 @@ int AccessibilityUIElement::insertionPointLineNumber()
     return 0;
 }
 
-JSStringRef AccessibilityUIElement::attributesOfColumnHeaders()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfColumnHeaders()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::attributesOfRowHeaders()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfRowHeaders()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::attributesOfColumns()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfColumns()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::attributesOfRows()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfRows()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::attributesOfVisibleCells()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfVisibleCells()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::attributesOfHeader()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfHeader()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 int AccessibilityUIElement::indexInTable()
@@ -627,14 +632,14 @@ int AccessibilityUIElement::indexInTable()
     return 0;
 }
 
-JSStringRef AccessibilityUIElement::rowIndexRange()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::rowIndexRange()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::columnIndexRange()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::columnIndexRange()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 int AccessibilityUIElement::lineForIndex(int)
@@ -642,19 +647,19 @@ int AccessibilityUIElement::lineForIndex(int)
     return 0;
 }
 
-JSStringRef AccessibilityUIElement::boundsForRange(unsigned location, unsigned length)
+JSRetainPtr<JSStringRef> AccessibilityUIElement::boundsForRange(unsigned location, unsigned length)
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::stringForRange(unsigned, unsigned)
+JSRetainPtr<JSStringRef> AccessibilityUIElement::stringForRange(unsigned, unsigned)
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::attributedStringForRange(unsigned, unsigned)
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForRange(unsigned, unsigned)
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 bool AccessibilityUIElement::attributedStringRangeIsMisspelled(unsigned, unsigned)
@@ -672,7 +677,7 @@ AccessibilityUIElement AccessibilityUIElement::uiElementForSearchPredicate(JSCon
     return { nullptr };
 }
 
-JSStringRef AccessibilityUIElement::selectTextWithCriteria(JSContextRef context, JSStringRef ambiguityResolution, JSValueRef searchStrings, JSStringRef replacementString, JSStringRef activity)
+JSRetainPtr<JSStringRef> AccessibilityUIElement::selectTextWithCriteria(JSContextRef context, JSStringRef ambiguityResolution, JSValueRef searchStrings, JSStringRef replacementString, JSStringRef activity)
 {
     return 0;
 }
@@ -682,28 +687,28 @@ AccessibilityUIElement AccessibilityUIElement::cellForColumnAndRow(unsigned colu
     return { nullptr };
 }
 
-JSStringRef AccessibilityUIElement::selectedTextRange()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::selectedTextRange()
 {
     COMPtr<IAccessibleComparable> comparable = comparableObject(platformUIElement().get());
     if (!comparable)
-        return JSStringCreateWithCharacters(0, 0);
+        return createEmptyJSString();
 
     _variant_t value;
     if (FAILED(comparable->get_attribute(_bstr_t(L"AXSelectedTextRangeAttribute"), &value.GetVARIANT())))
-        return JSStringCreateWithCharacters(0, 0);    
+        return createEmptyJSString();
 
     ASSERT(V_VT(&value) == VT_BSTR);
-    return JSStringCreateWithBSTR(value.bstrVal);
+    return adopt(JSStringCreateWithBSTR(value.bstrVal));
 }
 
 void AccessibilityUIElement::setSelectedTextRange(unsigned location, unsigned length)
 {
 }
 
-JSStringRef AccessibilityUIElement::stringAttributeValue(JSStringRef attribute)
+JSRetainPtr<JSStringRef> AccessibilityUIElement::stringAttributeValue(JSStringRef attribute)
 {
     // FIXME: implement
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 double AccessibilityUIElement::numberAttributeValue(JSStringRef attribute)
@@ -788,16 +793,16 @@ AccessibilityUIElement AccessibilityUIElement::disclosedByRow()
     return { nullptr };
 }
 
-JSStringRef AccessibilityUIElement::accessibilityValue() const
+JSRetainPtr<JSStringRef> AccessibilityUIElement::accessibilityValue() const
 {
     if (!m_element)
-        return JSStringCreateWithCharacters(0, 0);
+        return createEmptyJSString();
 
     _bstr_t valueBSTR;
     if (FAILED(m_element->get_accValue(self(), &valueBSTR.GetBSTR())) || !valueBSTR.length())
-        return JSStringCreateWithCharacters(0, 0);
+        return createEmptyJSString();
 
-    return JSStringCreateWithBSTR(valueBSTR);
+    return adopt(JSStringCreateWithBSTR(valueBSTR));
 }
 
 void AccessibilityUIElement::clearSelectedChildren() const
@@ -805,20 +810,20 @@ void AccessibilityUIElement::clearSelectedChildren() const
     // FIXME: implement
 }
 
-JSStringRef AccessibilityUIElement::documentEncoding()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::documentEncoding()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::documentURI()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::documentURI()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
-JSStringRef AccessibilityUIElement::url()
+JSRetainPtr<JSStringRef> AccessibilityUIElement::url()
 {
     // FIXME: implement
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 bool AccessibilityUIElement::addNotificationListener(JSObjectRef functionCallback)
@@ -949,7 +954,7 @@ void AccessibilityUIElement::scrollToGlobalPoint(int x, int y)
     // FIXME: implement
 }
 
-JSStringRef AccessibilityUIElement::classList() const
+JSRetainPtr<JSStringRef> AccessibilityUIElement::classList() const
 {
     // FIXME: implement
     return 0;
index c1da919..b0fbe3c 100644 (file)
@@ -210,14 +210,14 @@ void TestRunner::clearBackForwardList()
     backForwardList->goToItem(item.get());
 }
 
-JSStringRef TestRunner::copyDecodedHostName(JSStringRef name)
+JSRetainPtr<JSStringRef> TestRunner::copyDecodedHostName(JSStringRef name)
 {
     // FIXME: Implement!
     fprintf(testResult, "ERROR: TestRunner::copyDecodedHostName(JSStringRef) not implemented\n");
     return 0;
 }
 
-JSStringRef TestRunner::copyEncodedHostName(JSStringRef name)
+JSRetainPtr<JSStringRef> TestRunner::copyEncodedHostName(JSStringRef name)
 {
     // FIXME: Implement!
     fprintf(testResult, "ERROR: TestRunner::copyEncodedHostName(JSStringRef) not implemented\n");
@@ -311,7 +311,7 @@ static wstring jsStringRefToWString(JSStringRef jsStr)
     return buffer.data();
 }
 
-JSStringRef TestRunner::pathToLocalResource(JSContextRef context, JSStringRef url)
+JSRetainPtr<JSStringRef> TestRunner::pathToLocalResource(JSContextRef context, JSStringRef url)
 {
     wstring input(JSStringGetCharactersPtr(url), JSStringGetLength(url));
 
@@ -321,7 +321,7 @@ JSStringRef TestRunner::pathToLocalResource(JSContextRef context, JSStringRef ur
         return nullptr;
     }
 
-    return JSStringCreateWithCharacters(localPath.c_str(), localPath.length());
+    return adopt(JSStringCreateWithCharacters(localPath.c_str(), localPath.length()));
 }
 
 void TestRunner::queueLoad(JSStringRef url, JSStringRef target)
@@ -346,7 +346,7 @@ void TestRunner::queueLoad(JSStringRef url, JSStringRef target)
 
     wstring wURL = jsStringRefToWString(url);
     wstring wAbsoluteURL = responseURL + TEXT("/") + wURL;
-    JSRetainPtr<JSStringRef> jsAbsoluteURL(Adopt, JSStringCreateWithCharacters(wAbsoluteURL.data(), wAbsoluteURL.length()));
+    auto jsAbsoluteURL = adopt(JSStringCreateWithCharacters(wAbsoluteURL.data(), wAbsoluteURL.length()));
 
     WorkQueue::singleton().queue(new LoadItem(jsAbsoluteURL.get(), target));
 }
@@ -991,7 +991,7 @@ bool TestRunner::findString(JSContextRef context, JSStringRef target, JSObjectRe
 
     unsigned char options = 0;
 
-    JSRetainPtr<JSStringRef> lengthPropertyName(Adopt, JSStringCreateWithUTF8CString("length"));
+    auto lengthPropertyName = adopt(JSStringCreateWithUTF8CString("length"));
     JSValueRef lengthValue = JSObjectGetProperty(context, optionsArray, lengthPropertyName.get(), nullptr);
     if (!JSValueIsNumber(context, lengthValue))
         return false;
@@ -1004,7 +1004,7 @@ bool TestRunner::findString(JSContextRef context, JSStringRef target, JSObjectRe
         if (!JSValueIsString(context, value))
             continue;
 
-        JSRetainPtr<JSStringRef> optionName(Adopt, JSValueToStringCopy(context, value, nullptr));
+        auto optionName = adopt(JSValueToStringCopy(context, value, nullptr));
 
         if (JSStringIsEqualToUTF8CString(optionName.get(), "CaseInsensitive"))
             options |= WebFindOptionsCaseInsensitive;
@@ -1185,7 +1185,7 @@ void TestRunner::evaluateInWebInspector(JSStringRef script)
     inspectorPrivate->evaluateInFrontend(bstrT(script).GetBSTR());
 }
 
-JSStringRef TestRunner::inspectorTestStubURL()
+JSRetainPtr<JSStringRef> TestRunner::inspectorTestStubURL()
 {
     CFBundleRef webkitBundle = webKitBundle();
     if (!webkitBundle)
@@ -1195,7 +1195,7 @@ JSStringRef TestRunner::inspectorTestStubURL()
     if (!url)
         return nullptr;
 
-    return JSStringCreateWithCFString(CFURLGetString(url.get()));
+    return adopt(JSStringCreateWithCFString(CFURLGetString(url.get())));
 }
 
 typedef HashMap<unsigned, COMPtr<IWebScriptWorld> > WorldMap;
index 081adbf..778a30e 100644 (file)
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef JSWrapper_h
-#define JSWrapper_h
+#pragma once
 
 #include "JSWrappable.h"
 #include <JavaScriptCore/JSRetainPtr.h>
@@ -48,10 +47,8 @@ inline JSValueRef toJS(JSContextRef context, JSWrappable* impl)
 
 inline void setProperty(JSContextRef context, JSObjectRef object, const char* propertyName, JSWrappable* value, JSPropertyAttributes attributes, JSValueRef* exception)
 {
-    JSRetainPtr<JSStringRef> propertyNameString(Adopt, JSStringCreateWithUTF8CString(propertyName));
+    auto propertyNameString = adopt(JSStringCreateWithUTF8CString(propertyName));
     JSObjectSetProperty(context, object, propertyNameString.get(), JSWrapper::wrap(context, value), attributes, exception);
 }
 
 } // namespace WTR
-
-#endif // JSWrapper_h
index 44c558e..5a84da8 100644 (file)
@@ -39,7 +39,7 @@ static inline bool isPersistentCallbackID(unsigned callbackID)
 }
 
 UIScriptContext::UIScriptContext(UIScriptContextDelegate& delegate)
-    : m_context(Adopt, JSGlobalContextCreate(nullptr))
+    : m_context(adopt(JSGlobalContextCreate(nullptr)))
     , m_delegate(delegate)
 {
     m_controller = UIScriptController::create(*this);
@@ -60,14 +60,14 @@ void UIScriptContext::runUIScript(const String& script, unsigned scriptCallbackI
 {
     m_currentScriptCallbackID = scriptCallbackID;
 
-    JSRetainPtr<JSStringRef> stringRef(Adopt, JSStringCreateWithUTF8CString(script.utf8().data()));
+    auto stringRef = adopt(JSStringCreateWithUTF8CString(script.utf8().data()));
 
     JSValueRef exception = nullptr;
     JSValueRef result = JSEvaluateScript(m_context.get(), stringRef.get(), 0, 0, 1, &exception);
     
     if (!hasOutstandingAsyncTasks()) {
         JSValueRef stringifyException = nullptr;
-        JSRetainPtr<JSStringRef> stringified(Adopt, JSValueToStringCopy(m_context.get(), result, &stringifyException));
+        auto stringified = adopt(JSValueToStringCopy(m_context.get(), result, &stringifyException));
         requestUIScriptCompletion(stringified.get());
         tryToCompleteUIScriptForCurrentParentCallback();
     }
index b7c16f5..ae99048 100644 (file)
@@ -42,7 +42,7 @@ DeviceOrientation* toDeviceOrientation(JSContextRef context, JSValueRef value)
         DeviceOrientation::LandscapeRight
     };
 
-    JSRetainPtr<JSStringRef> option(Adopt, JSValueToStringCopy(context, value, nullptr));
+    auto option = adopt(JSValueToStringCopy(context, value, nullptr));
     if (option.get()->string() == "portrait")
         return &values[0];
         
index 231ab55..8d83d8c 100644 (file)
@@ -68,9 +68,9 @@ static const char *stringForCorrectionResponse(NSCorrectionResponse correctionRe
     return "invalid";
 }
 
-static NSTextCheckingType nsTextCheckingType(JSRetainPtr<JSStringRef>&& jsType)
+static NSTextCheckingType nsTextCheckingType(JSStringRef jsType)
 {
-    auto cfType = adoptCF(JSStringCopyCFString(kCFAllocatorDefault, jsType.get()));
+    auto cfType = adoptCF(JSStringCopyCFString(kCFAllocatorDefault, jsType));
     if (CFStringCompare(cfType.get(), CFSTR("orthography"), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
         return NSTextCheckingTypeOrthography;
 
@@ -251,7 +251,7 @@ static NSTextCheckingType nsTextCheckingType(JSRetainPtr<JSStringRef>&& jsType)
                 }
                 JSPropertyNameArrayRelease(detailsObjectProperties);
             }
-            [resultsForWord addObject:[[[LayoutTestTextCheckingResult alloc] initWithType:nsTextCheckingType(WTFMove(typeValue)) range:NSMakeRange(fromValue, toValue - fromValue) replacement:(__bridge NSString *)replacementText.get() details:details.get()] autorelease]];
+            [resultsForWord addObject:[[[LayoutTestTextCheckingResult alloc] initWithType:nsTextCheckingType(typeValue.get()) range:NSMakeRange(fromValue, toValue - fromValue) replacement:(__bridge NSString *)replacementText.get() details:details.get()] autorelease]];
         }
         auto cfTextToCheck = adoptCF(JSStringCopyCFString(kCFAllocatorDefault, textToCheck));
         [results setObject:resultsForWord.get() forKey:(__bridge NSString *)cfTextToCheck.get()];
index 133d99e..2136e98 100644 (file)
@@ -58,7 +58,7 @@ static void javaScriptCallback(WKSerializedScriptValueRef resultSerializedScript
     JSValueRef scriptValue = WKSerializedScriptValueDeserialize(resultSerializedScriptValue, scriptContext, 0);
     ASSERT_NOT_NULL(scriptValue);
 
-    context->actualString.adopt(JSValueToStringCopy(scriptContext, scriptValue, 0));
+    context->actualString = adopt(JSValueToStringCopy(scriptContext, scriptValue, 0));
     ASSERT_NOT_NULL(context->actualString.get());
 
     context->didFinish = true;
index c4eb1e9..7010f38 100644 (file)
@@ -30,7 +30,6 @@
 #include "PlatformUtilities.h"
 #include "PlatformWebView.h"
 #include "Test.h"
-#include <JavaScriptCore/JSRetainPtr.h>
 #include <JavaScriptCore/JavaScriptCore.h>
 #include <WebKit/WKSerializedScriptValue.h>
 #include <WebKit/WKPagePrivate.h>
index 8b345d7..00e1a8c 100644 (file)
@@ -31,7 +31,6 @@
 #import "PlatformWebView.h"
 #import "Test.h"
 #import "TestWKWebView.h"
-#import <JavaScriptCore/JSRetainPtr.h>
 #import <JavaScriptCore/JavaScriptCore.h>
 #import <WebKit/WKPagePrivateMac.h>
 #import <WebKit/WKPreferencesPrivate.h>
index f5c83df..2b119b8 100644 (file)
@@ -42,7 +42,7 @@ TEST(WebKitLegacy, DOMNodeFromJSObject)
     WebScriptWorld *isolatedWorld = [WebScriptWorld world];
     JSGlobalContextRef context = [[webView mainFrame] _globalContextForScriptWorld:isolatedWorld];
 
-    JSRetainPtr<JSStringRef> script(Adopt, JSStringCreateWithUTF8CString("document.body"));
+    auto script = adopt(JSStringCreateWithUTF8CString("document.body"));
 
     JSValueRef value = JSEvaluateScript(context, script.get(), 0, 0, 0, 0);
     JSObjectRef jsBody = JSValueToObject(context, value, 0);
index 69fb592..ef4a63e 100644 (file)
@@ -80,13 +80,15 @@ TEST(WebKitLegacy, JSWrapperForNode)
     ASSERT_TRUE(JSValueIsObject(normalCtx, normalNodeJSValue));
     JSObjectRef normalNodeJSObject = JSValueToObject(normalCtx, normalNodeJSValue, 0);
 
-    JSRetainPtr<JSStringRef> isolatedPropertyJSString = JSStringCreateWithUTF8CString("isolatedProperty");
+    auto isolatedPropertyJSString = adopt(JSStringCreateWithUTF8CString("isolatedProperty"));
+
     // Test for successful retrieval of the first property in the isolated script world
     EXPECT_TRUE(JSValueIsBoolean(isolatedCtx, JSObjectGetProperty(isolatedCtx, isolatedNodeJSObject, isolatedPropertyJSString.get(), 0)));
     // Test for failed retrieval of the first property in the standard script world
     EXPECT_TRUE(JSValueIsUndefined(normalCtx, JSObjectGetProperty(normalCtx, normalNodeJSObject, isolatedPropertyJSString.get(), 0)));
 
-    JSRetainPtr<JSStringRef> normalPropertyJSString = JSStringCreateWithUTF8CString("normalProperty");
+    auto normalPropertyJSString = adopt(JSStringCreateWithUTF8CString("normalProperty"));
+
     // Test for successful retrieval of the second property in the standard script world
     EXPECT_TRUE(JSValueIsBoolean(normalCtx, JSObjectGetProperty(normalCtx, normalNodeJSObject, normalPropertyJSString.get(), 0)));
     // Test for failed retrieval of the second property in the isolated script world
index d07904b..7b81676 100644 (file)
@@ -31,7 +31,6 @@
 #include "InjectedBundlePage.h"
 #include "JSAccessibilityController.h"
 
-#include <JavaScriptCore/JSRetainPtr.h>
 #include <WebKit/WKBundle.h>
 #include <WebKit/WKBundlePage.h>
 #include <WebKit/WKBundlePagePrivate.h>
index 7e99fbb..6533604 100644 (file)
@@ -29,8 +29,6 @@
 #include "AccessibilityUIElement.h"
 #include "JSAccessibilityTextMarker.h"
 
-#include <JavaScriptCore/JSRetainPtr.h>
-
 namespace WTR {
     
 Ref<AccessibilityTextMarker> AccessibilityTextMarker::create(PlatformTextMarker marker)
index 7444f35..2b21e8a 100644 (file)
@@ -29,8 +29,6 @@
 #include "AccessibilityUIElement.h"
 #include "JSAccessibilityTextMarkerRange.h"
 
-#include <JavaScriptCore/JSRetainPtr.h>
-
 namespace WTR {
     
 Ref<AccessibilityTextMarkerRange> AccessibilityTextMarkerRange::create(PlatformTextMarkerRange markerRange)
index e619555..499cbe9 100644 (file)
@@ -27,7 +27,6 @@
 #include "AccessibilityUIElement.h"
 
 #include "JSAccessibilityUIElement.h"
-#include <JavaScriptCore/JSRetainPtr.h>
 
 namespace WTR {
 
index 8591954..d6a638e 100644 (file)
@@ -448,8 +448,8 @@ sub _platformTypeConstructor
     return "JSValueToNullableBoolean(context, $argumentName)" if $type->name eq "boolean" && $type->isNullable;
     return "JSValueToBoolean(context, $argumentName)" if $type->name eq "boolean";
     return "$argumentName" if $type->name eq "object";
-    return "JSRetainPtr<JSStringRef>(Adopt, JSValueToStringCopy(context, $argumentName, 0))" if $$self{codeGenerator}->IsStringType($type);
-    return "JSValueToNumber(context, $argumentName, 0)" if $$self{codeGenerator}->IsPrimitiveType($type);
+    return "adopt(JSValueToStringCopy(context, $argumentName, nullptr))" if $$self{codeGenerator}->IsStringType($type);
+    return "JSValueToNumber(context, $argumentName, nullptr)" if $$self{codeGenerator}->IsPrimitiveType($type);
     return "to" . _implementationClassName($type) . "(context, $argumentName)";
 }
 
index 76384d5..25cfcbb 100644 (file)
@@ -130,7 +130,7 @@ static WKEventModifiers parseModifier(JSStringRef modifier)
 
 static unsigned arrayLength(JSContextRef context, JSObjectRef array)
 {
-    JSRetainPtr<JSStringRef> lengthString(Adopt, JSStringCreateWithUTF8CString("length"));
+    auto lengthString = adopt(JSStringCreateWithUTF8CString("length"));
     JSValueRef lengthValue = JSObjectGetProperty(context, array, lengthString.get(), 0);
     if (!lengthValue)
         return 0;
@@ -144,7 +144,7 @@ static WKEventModifiers parseModifierArray(JSContextRef context, JSValueRef arra
 
     // The value may either be a string with a single modifier or an array of modifiers.
     if (JSValueIsString(context, arrayValue)) {
-        JSRetainPtr<JSStringRef> string(Adopt, JSValueToStringCopy(context, arrayValue, 0));
+        auto string = adopt(JSValueToStringCopy(context, arrayValue, 0));
         return parseModifier(string.get());
     }
 
@@ -158,7 +158,7 @@ static WKEventModifiers parseModifierArray(JSContextRef context, JSValueRef arra
         JSValueRef value = JSObjectGetPropertyAtIndex(context, array, i, &exception);
         if (exception)
             continue;
-        JSRetainPtr<JSStringRef> string(Adopt, JSValueToStringCopy(context, value, &exception));
+        auto string = adopt(JSValueToStringCopy(context, value, &exception));
         if (exception)
             continue;
         modifiers |= parseModifier(string.get());
index 26efa88..5576a98 100644 (file)
@@ -67,7 +67,7 @@ static JSValueRef propertyValue(JSContextRef context, JSObjectRef object, const
 {
     if (!object)
         return 0;
-    JSRetainPtr<JSStringRef> propertyNameString(Adopt, JSStringCreateWithUTF8CString(propertyName));
+    auto propertyNameString = adopt(JSStringCreateWithUTF8CString(propertyName));
     return JSObjectGetProperty(context, object, propertyNameString.get(), 0);
 }
 
@@ -93,7 +93,7 @@ static double numericWindowPropertyValue(WKBundleFrameRef frame, const char* pro
 static WTF::String dumpPath(JSGlobalContextRef context, JSObjectRef nodeValue)
 {
     JSValueRef nodeNameValue = propertyValue(context, nodeValue, "nodeName");
-    JSRetainPtr<JSStringRef> jsStringNodeName(Adopt, JSValueToStringCopy(context, nodeNameValue, 0));
+    auto jsStringNodeName = adopt(JSValueToStringCopy(context, nodeNameValue, 0));
     WKRetainPtr<WKStringRef> nodeName = toWK(jsStringNodeName);
 
     JSValueRef parentNode = propertyValue(context, nodeValue, "parentNode");
@@ -818,7 +818,7 @@ void InjectedBundlePage::dumpAllFrameScrollPositions(StringBuilder& stringBuilde
 
 static JSRetainPtr<JSStringRef> toJS(const char* string)
 {
-    return JSRetainPtr<JSStringRef>(Adopt, JSStringCreateWithUTF8CString(string));
+    return adopt(JSStringCreateWithUTF8CString(string));
 }
 
 static bool hasDocumentElement(WKBundleFrameRef frame)
index a3ed22b..f70ee13 100644 (file)
@@ -306,7 +306,7 @@ bool TestRunner::findString(JSStringRef target, JSValueRef optionsArrayAsValue)
     auto& injectedBundle = InjectedBundle::singleton();
     WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(injectedBundle.page()->page());
     JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame);
-    JSRetainPtr<JSStringRef> lengthPropertyName(Adopt, JSStringCreateWithUTF8CString("length"));
+    auto lengthPropertyName = adopt(JSStringCreateWithUTF8CString("length"));
     JSObjectRef optionsArray = JSValueToObject(context, optionsArrayAsValue, 0);
     JSValueRef lengthValue = JSObjectGetProperty(context, optionsArray, lengthPropertyName.get(), 0);
     if (!JSValueIsNumber(context, lengthValue))
@@ -318,7 +318,7 @@ bool TestRunner::findString(JSStringRef target, JSValueRef optionsArrayAsValue)
         if (!JSValueIsString(context, value))
             continue;
 
-        JSRetainPtr<JSStringRef> optionName(Adopt, JSValueToStringCopy(context, value, 0));
+        auto optionName = adopt(JSValueToStringCopy(context, value, 0));
 
         if (JSStringIsEqualToUTF8CString(optionName.get(), "CaseInsensitive"))
             options |= kWKFindOptionsCaseInsensitive;
@@ -1836,8 +1836,8 @@ void TestRunner::statisticsDidRunTelemetryCallback(unsigned totalPrevalentResour
     stringBuilder.appendNumber(top3SubframeUnderTopFrameOrigins);
     stringBuilder.appendLiteral(" }");
     
-    JSValueRef result = JSValueMakeFromJSONString(context, JSStringCreateWithUTF8CString(stringBuilder.toString().utf8().data()));
-    
+    JSValueRef result = JSValueMakeFromJSONString(context, adopt(JSStringCreateWithUTF8CString(stringBuilder.toString().utf8().data())).get());
+
     callTestRunnerCallback(StatisticsDidRunTelemetryCallbackID, 1, &result);
 }
 
@@ -2029,7 +2029,7 @@ void TestRunner::callDidReceiveAllStorageAccessEntriesCallback(Vector<String>& d
     }
     stringBuilder.appendLiteral("]");
     
-    JSValueRef result = JSValueMakeFromJSONString(context, JSStringCreateWithUTF8CString(stringBuilder.toString().utf8().data()));
+    JSValueRef result = JSValueMakeFromJSONString(context, adopt(JSStringCreateWithUTF8CString(stringBuilder.toString().utf8().data())).get());
 
     callTestRunnerCallback(AllStorageAccessEntriesCallbackID, 1, &result);
 }
@@ -2239,7 +2239,7 @@ void TestRunner::setOpenPanelFiles(JSValueRef filesValue)
         return;
 
     JSObjectRef files = JSValueToObject(context, filesValue, nullptr);
-    static auto lengthProperty = JSRetainPtr<JSStringRef>(Adopt, JSStringCreateWithUTF8CString("length"));
+    static auto lengthProperty = adopt(JSStringCreateWithUTF8CString("length"));
     JSValueRef filesLengthValue = JSObjectGetProperty(context, files, lengthProperty.get(), nullptr);
     if (!JSValueIsNumber(context, filesLengthValue))
         return;
@@ -2251,7 +2251,7 @@ void TestRunner::setOpenPanelFiles(JSValueRef filesValue)
         if (!JSValueIsString(context, fileValue))
             continue;
 
-        auto file = JSRetainPtr<JSStringRef>(Adopt, JSValueToStringCopy(context, fileValue, nullptr));
+        auto file = adopt(JSValueToStringCopy(context, fileValue, nullptr));
         size_t fileBufferSize = JSStringGetMaximumUTF8CStringSize(file.get()) + 1;
         auto fileBuffer = std::make_unique<char[]>(fileBufferSize);
         JSStringGetUTF8CString(file.get(), fileBuffer.get(), fileBufferSize);
index 09fa2bc..87ccd21 100644 (file)
@@ -30,8 +30,6 @@
 #import "InjectedBundle.h"
 #import "InjectedBundlePage.h"
 
-#import <JavaScriptCore/JSRetainPtr.h>
-#import <JavaScriptCore/JSStringRef.h>
 #import <JavaScriptCore/JSStringRefCF.h>
 #import <UIKit/UIAccessibility.h>
 #import <WebKit/WKBundle.h>
@@ -64,8 +62,7 @@ bool AccessibilityController::removeNotificationListener()
 
 JSRetainPtr<JSStringRef> AccessibilityController::platformName()
 {
-    JSRetainPtr<JSStringRef> platformName(Adopt, JSStringCreateWithUTF8CString("ios"));
-    return platformName;
+    return adopt(JSStringCreateWithUTF8CString("ios"));
 }
 
 void AccessibilityController::resetToConsistentState()
index c5e5e6c..a6e1f86 100644 (file)
@@ -30,8 +30,6 @@
 #import "InjectedBundle.h"
 #import "InjectedBundlePage.h"
 #import <Foundation/Foundation.h>
-#import <JavaScriptCore/JSRetainPtr.h>
-#import <JavaScriptCore/JSStringRef.h>
 #import <JavaScriptCore/JSStringRefCF.h>
 #import <UIKit/UIKit.h>
 #import <WebCore/TextGranularity.h>
@@ -112,15 +110,20 @@ typedef void (*AXPostedNotificationCallback)(id element, NSString* notification,
     return CFBridgingRelease(JSStringCopyCFString(kCFAllocatorDefault, jsStringRef));
 }
 
-- (JSStringRef)createJSStringRef
+- (JSRetainPtr<JSStringRef>)createJSStringRef
 {
-    return JSStringCreateWithCFString((__bridge CFStringRef)self);
+    return adopt(JSStringCreateWithCFString((__bridge CFStringRef)self));
 }
 
 @end
 
 namespace WTR {
 
+static JSRetainPtr<JSStringRef> createEmptyJSString()
+{
+    return adopt(JSStringCreateWithCharacters(nullptr, 0));
+}
+
 static void convertNSArrayToVector(NSArray* array, Vector<RefPtr<AccessibilityUIElement> >& elementVector)
 {
     NSUInteger count = [array count];
@@ -128,18 +131,18 @@ static void convertNSArrayToVector(NSArray* array, Vector<RefPtr<AccessibilityUI
         elementVector.append(AccessibilityUIElement::create([array objectAtIndex:i]));
 }    
 
-static JSStringRef concatenateAttributeAndValue(NSString* attribute, NSString* value)
+static JSRetainPtr<JSStringRef> concatenateAttributeAndValue(NSString *attribute, NSString *value)
 {
     Vector<UniChar> buffer([attribute length]);
     [attribute getCharacters:buffer.data()];
     buffer.append(':');
     buffer.append(' ');
-    
+
     Vector<UniChar> valueBuffer([value length]);
     [value getCharacters:valueBuffer.data()];
     buffer.appendVector(valueBuffer);
-    
-    return JSStringCreateWithCharacters(buffer.data(), buffer.size());
+
+    return adopt(JSStringCreateWithCharacters(buffer.data(), buffer.size()));
 }
     
 AccessibilityUIElement::AccessibilityUIElement(PlatformUIElement element)
@@ -326,22 +329,22 @@ RefPtr<AccessibilityUIElement> AccessibilityUIElement::disclosedByRow()
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfLinkedUIElements()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfDocumentLinks()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfChildren()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::allAttributes()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::stringAttributeValue(JSStringRef attribute)
@@ -364,7 +367,7 @@ JSRetainPtr<JSStringRef> AccessibilityUIElement::stringAttributeValue(JSStringRe
         return [rectStr createJSStringRef];
     }
 
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 double AccessibilityUIElement::numberAttributeValue(JSStringRef attribute)
@@ -425,33 +428,33 @@ bool AccessibilityUIElement::isAttributeSupported(JSStringRef attribute)
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::parameterizedAttributeNames()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::role()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::subrole()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::roleDescription()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::computedRoleString()
 {
     // FIXME: implement
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::title()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::description()
@@ -461,7 +464,7 @@ JSRetainPtr<JSStringRef> AccessibilityUIElement::description()
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::orientation() const
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::stringValue()
@@ -471,7 +474,7 @@ JSRetainPtr<JSStringRef> AccessibilityUIElement::stringValue()
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::language()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::helpText() const
@@ -531,7 +534,7 @@ double AccessibilityUIElement::maxValue()
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::valueDescription()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 int AccessibilityUIElement::insertionPointLineNumber()
@@ -620,7 +623,7 @@ bool AccessibilityUIElement::ariaIsGrabbed() const
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::ariaDropEffects() const
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 // parameterized attributes
@@ -641,24 +644,18 @@ JSRetainPtr<JSStringRef> AccessibilityUIElement::rangeForPosition(int x, int y)
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::boundsForRange(unsigned location, unsigned length)
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::stringForRange(unsigned location, unsigned length)
 {
     NSString *stringForRange = [m_element stringForRange:NSMakeRange(location, length)];
-    if (!stringForRange)
-        return nullptr;
-    
     return [stringForRange createJSStringRef];
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForRange(unsigned location, unsigned length)
 {
     NSAttributedString *stringForRange = [m_element attributedStringForRange:NSMakeRange(location, length)];
-    if (!stringForRange)
-        return nullptr;
-    
     return [[stringForRange description] createJSStringRef];
 }
 
@@ -701,32 +698,32 @@ JSRetainPtr<JSStringRef> AccessibilityUIElement::selectTextWithCriteria(JSContex
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfColumnHeaders()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfRowHeaders()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfColumns()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfRows()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfVisibleCells()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfHeader()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::traits()
@@ -822,7 +819,7 @@ void AccessibilityUIElement::scrollToMakeVisibleWithSubFocus(int x, int y, int w
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::selectedTextRange()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 bool AccessibilityUIElement::setSelectedVisibleTextRange(AccessibilityTextMarkerRange*)
@@ -879,17 +876,17 @@ void AccessibilityUIElement::clearSelectedChildren() const
 JSRetainPtr<JSStringRef> AccessibilityUIElement::accessibilityValue() const
 {
     // FIXME: implement
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::documentEncoding()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::documentURI()
 {
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 void AccessibilityUIElement::assistiveTechnologySimulatedFocus()
@@ -929,9 +926,6 @@ void AccessibilityUIElement::decreaseTextSelection()
 JSRetainPtr<JSStringRef> AccessibilityUIElement::stringForSelection()
 {
     NSString *stringForRange = [m_element selectionRangeString];
-    if (!stringForRange)
-        return nullptr;
-    
     return [stringForRange createJSStringRef];
 }
     
@@ -1099,7 +1093,7 @@ JSRetainPtr<JSStringRef> AccessibilityUIElement::stringForTextMarkerRange(Access
 {
     id textMarkers = (id)markerRange->platformTextMarkerRange();
     if (!textMarkers || ![textMarkers isKindOfClass:[NSArray class]])
-        return JSStringCreateWithCharacters(0, 0);
+        return createEmptyJSString();
     return [[m_element stringForTextMarkers:textMarkers] createJSStringRef];
 }
 
index 16ca3dd..f2f05fb 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef AccessibilityCommonMac_h
-#define AccessibilityCommonMac_h
+#pragma once
 
 #import "AccessibilityUIElement.h"
-
-#import <JavaScriptCore/JSStringRef.h>
+#import <JavaScriptCore/JSRetainPtr.h>
 
 // If an unsupported attribute is passed in, it will raise an accessibility exception. These are usually caught by the Accessibility Runtime to inform
 // the AX client app of the error. However, DRT is the AX client app, so it must catch these exceptions.
 #define BEGIN_AX_OBJC_EXCEPTIONS @try {
 #define END_AX_OBJC_EXCEPTIONS } @catch(NSException *e) { if (![[e name] isEqualToString:NSAccessibilityException]) @throw; }
 
-
 @interface NSString (JSStringRefAdditions)
 + (NSString *)stringWithJSStringRef:(JSStringRef)jsStringRef;
-- (JSStringRef)createJSStringRef;
+- (JSRetainPtr<JSStringRef>)createJSStringRef;
 @end
 
 namespace WTR {
@@ -51,5 +48,3 @@ namespace WTR {
 extern NSDictionary *searchPredicateParameterizedAttributeForSearchCriteria(JSContextRef, AccessibilityUIElement *startElement, bool isDirectionNext, unsigned resultsLimit, JSValueRef searchKey, JSStringRef searchText, bool visibleOnly, bool immediateDescendantsOnly);
 
 };
-
-#endif // AccessibilityCommonMac_h
index 9ea6432..cf778c6 100644 (file)
@@ -31,8 +31,6 @@
 #import "config.h"
 #import "AccessibilityCommonMac.h"
 
-#import <JavaScriptCore/JSRetainPtr.h>
-#import <JavaScriptCore/JSStringRef.h>
 #import <JavaScriptCore/JSStringRefCF.h>
 
 @implementation NSString (JSStringRefAdditions)
@@ -45,9 +43,9 @@
     return CFBridgingRelease(JSStringCopyCFString(kCFAllocatorDefault, jsStringRef));
 }
 
-- (JSStringRef)createJSStringRef
+- (JSRetainPtr<JSStringRef>)createJSStringRef
 {
-    return JSStringCreateWithCFString((__bridge CFStringRef)self);
+    return adopt(JSStringCreateWithCFString((__bridge CFStringRef)self));
 }
 
 namespace WTR {
@@ -66,14 +64,14 @@ NSDictionary *searchPredicateParameterizedAttributeForSearchCriteria(JSContextRe
     if (searchKey) {
         id searchKeyParameter = nil;
         if (JSValueIsString(context, searchKey)) {
-            JSRetainPtr<JSStringRef> searchKeyString(Adopt, JSValueToStringCopy(context, searchKey, nullptr));
+            auto searchKeyString = adopt(JSValueToStringCopy(context, searchKey, nullptr));
             if (searchKeyString)
                 searchKeyParameter = [NSString stringWithJSStringRef:searchKeyString.get()];
         } else if (JSValueIsObject(context, searchKey)) {
             JSObjectRef searchKeyArray = JSValueToObject(context, searchKey, nullptr);
             unsigned searchKeyArrayLength = 0;
             
-            JSRetainPtr<JSStringRef> lengthPropertyString(Adopt, JSStringCreateWithUTF8CString("length"));
+            auto lengthPropertyString = adopt(JSStringCreateWithUTF8CString("length"));
             JSValueRef searchKeyArrayLengthValue = JSObjectGetProperty(context, searchKeyArray, lengthPropertyString.get(), nullptr);
             if (searchKeyArrayLengthValue && JSValueIsNumber(context, searchKeyArrayLengthValue))
                 searchKeyArrayLength = static_cast<unsigned>(JSValueToNumber(context, searchKeyArrayLengthValue, nullptr));
index a38c768..90e8eef 100644 (file)
@@ -35,8 +35,6 @@
 #import "AccessibilityNotificationHandler.h"
 #import "InjectedBundle.h"
 #import "InjectedBundlePage.h"
-#import <JavaScriptCore/JSRetainPtr.h>
-#import <JavaScriptCore/JSStringRef.h>
 #import <JavaScriptCore/JSStringRefCF.h>
 #import <WebKit/WKBundle.h>
 #import <WebKit/WKBundlePage.h>
@@ -108,8 +106,7 @@ RefPtr<AccessibilityUIElement> AccessibilityController::accessibleElementById(JS
 
 JSRetainPtr<JSStringRef> AccessibilityController::platformName()
 {
-    JSRetainPtr<JSStringRef> platformName(Adopt, JSStringCreateWithUTF8CString("mac"));
-    return platformName;
+    return adopt(JSStringCreateWithUTF8CString("mac"));
 }
 
 } // namespace WTR
index f3ecb3b..5c51d48 100644 (file)
 @end
 
 @interface NSString (JSStringRefAdditions)
-- (JSStringRef)createJSStringRef;
+- (JSRetainPtr<JSStringRef>)createJSStringRef;
 @end
 
 @implementation NSString (JSStringRefAdditions)
 
-- (JSStringRef)createJSStringRef
+- (JSRetainPtr<JSStringRef>)createJSStringRef
 {
-    return JSStringCreateWithCFString((__bridge CFStringRef)self);
+    return adopt(JSStringCreateWithCFString((__bridge CFStringRef)self));
 }
 
 @end
@@ -126,7 +126,7 @@ static Class webAccessibilityObjectWrapperClass()
 static JSValueRef makeValueRefForValue(JSContextRef context, id value)
 {
     if ([value isKindOfClass:[NSString class]])
-        return JSValueMakeString(context, adopt([value createJSStringRef]).get());
+        return JSValueMakeString(context, [value createJSStringRef].get());
     if ([value isKindOfClass:[NSNumber class]]) {
         if (!strcmp([value objCType], @encode(BOOL)))
             return JSValueMakeBoolean(context, [value boolValue]);
@@ -159,7 +159,7 @@ static JSValueRef makeObjectRefForDictionary(JSContextRef context, NSDictionary
     [dictionary enumerateKeysAndObjectsUsingBlock:^(NSString *key, id obj, BOOL *stop)
     {
         if (JSValueRef propertyValue = makeValueRefForValue(context, obj))
-            JSObjectSetProperty(context, object, adopt([key createJSStringRef]).get(), propertyValue, kJSPropertyAttributeNone, nullptr);
+            JSObjectSetProperty(context, object, [key createJSStringRef].get(), propertyValue, kJSPropertyAttributeNone, nullptr);
     }];
 
     return object;
@@ -178,7 +178,7 @@ static JSValueRef makeObjectRefForDictionary(JSContextRef context, NSDictionary
     WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(WTR::InjectedBundle::singleton().page()->page());
     JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame);
 
-    JSValueRef notificationNameArgument = JSValueMakeString(context, adopt([notificationName createJSStringRef]).get());
+    JSValueRef notificationNameArgument = JSValueMakeString(context, [notificationName createJSStringRef].get());
     JSValueRef userInfoArgument = makeObjectRefForDictionary(context, userInfo);
     if (m_platformElement) {
         // Listener for one element gets the notification name and userInfo.
index 77dffb3..669d6ee 100644 (file)
@@ -35,8 +35,6 @@
 
 #import <AppKit/NSAccessibility.h>
 #import <Foundation/Foundation.h>
-#import <JavaScriptCore/JSRetainPtr.h>
-#import <JavaScriptCore/JSStringRef.h>
 #import <JavaScriptCore/JSStringRefCF.h>
 #import <JavaScriptCore/JSObjectRef.h>
 #import <WebKit/WKBundleFrame.h>
@@ -87,6 +85,11 @@ typedef void (*AXPostedNotificationCallback)(id element, NSString* notification,
 
 namespace WTR {
 
+static JSRetainPtr<JSStringRef> createEmptyJSString()
+{
+    return adopt(JSStringCreateWithCharacters(nullptr, 0));
+}
+
 AccessibilityUIElement::AccessibilityUIElement(PlatformUIElement element)
     : m_element(element)
     , m_notificationHandler(0)
@@ -199,7 +202,7 @@ static JSValueRef convertElementsToObjectArray(JSContextRef context, Vector<RefP
     return arrayResult;
 }
 
-static JSStringRef concatenateAttributeAndValue(NSString* attribute, NSString* value)
+static JSRetainPtr<JSStringRef> concatenateAttributeAndValue(NSString* attribute, NSString* value)
 {
     Vector<UniChar> buffer([attribute length]);
     [attribute getCharacters:buffer.data()];
@@ -210,7 +213,7 @@ static JSStringRef concatenateAttributeAndValue(NSString* attribute, NSString* v
     [value getCharacters:valueBuffer.data()];
     buffer.appendVector(valueBuffer);
 
-    return JSStringCreateWithCharacters(buffer.data(), buffer.size());
+    return adopt(JSStringCreateWithCharacters(buffer.data(), buffer.size()));
 }
 
 static void convertNSArrayToVector(NSArray* array, Vector<RefPtr<AccessibilityUIElement> >& elementVector)
@@ -220,7 +223,7 @@ static void convertNSArrayToVector(NSArray* array, Vector<RefPtr<AccessibilityUI
         elementVector.append(AccessibilityUIElement::create([array objectAtIndex:i]));
 }
 
-static JSStringRef descriptionOfElements(Vector<RefPtr<AccessibilityUIElement> >& elementVector)
+static JSRetainPtr<JSStringRef> descriptionOfElements(Vector<RefPtr<AccessibilityUIElement> >& elementVector)
 {
     NSMutableString* allElementString = [NSMutableString string];
     size_t size = elementVector.size();
@@ -243,7 +246,7 @@ static NSDictionary *selectTextParameterizedAttributeForCriteria(JSContextRef co
     if (searchStrings) {
         NSMutableArray *searchStringsParameter = [NSMutableArray array];
         if (JSValueIsString(context, searchStrings)) {
-            JSRetainPtr<JSStringRef> searchStringsString(Adopt, JSValueToStringCopy(context, searchStrings, nullptr));
+            auto searchStringsString = adopt(JSValueToStringCopy(context, searchStrings, nullptr));
             if (searchStringsString)
                 [searchStringsParameter addObject:[NSString stringWithJSStringRef:searchStringsString.get()]];
         }
@@ -251,13 +254,13 @@ static NSDictionary *selectTextParameterizedAttributeForCriteria(JSContextRef co
             JSObjectRef searchStringsArray = JSValueToObject(context, searchStrings, nullptr);
             unsigned searchStringsArrayLength = 0;
             
-            JSRetainPtr<JSStringRef> lengthPropertyString(Adopt, JSStringCreateWithUTF8CString("length"));
+            auto lengthPropertyString = adopt(JSStringCreateWithUTF8CString("length"));
             JSValueRef searchStringsArrayLengthValue = JSObjectGetProperty(context, searchStringsArray, lengthPropertyString.get(), nullptr);
             if (searchStringsArrayLengthValue && JSValueIsNumber(context, searchStringsArrayLengthValue))
                 searchStringsArrayLength = static_cast<unsigned>(JSValueToNumber(context, searchStringsArrayLengthValue, nullptr));
             
             for (unsigned i = 0; i < searchStringsArrayLength; ++i) {
-                JSRetainPtr<JSStringRef> searchStringsString(Adopt, JSValueToStringCopy(context, JSObjectGetPropertyAtIndex(context, searchStringsArray, i, nullptr), nullptr));
+                auto searchStringsString = adopt(JSValueToStringCopy(context, JSObjectGetPropertyAtIndex(context, searchStringsArray, i, nullptr), nullptr));
                 if (searchStringsString)
                     [searchStringsParameter addObject:[NSString stringWithJSStringRef:searchStringsString.get()]];
             }
@@ -1500,7 +1503,7 @@ void AccessibilityUIElement::clearSelectedChildren() const
 JSRetainPtr<JSStringRef> AccessibilityUIElement::accessibilityValue() const
 {
     // FIXME: implement
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::documentEncoding()
@@ -1511,7 +1514,7 @@ JSRetainPtr<JSStringRef> AccessibilityUIElement::documentEncoding()
         return [value createJSStringRef];
     END_AX_OBJC_EXCEPTIONS
     
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::documentURI()
@@ -1522,7 +1525,7 @@ JSRetainPtr<JSStringRef> AccessibilityUIElement::documentURI()
         return [value createJSStringRef];
     END_AX_OBJC_EXCEPTIONS
     
-    return JSStringCreateWithCharacters(0, 0);
+    return createEmptyJSString();
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::url()
@@ -1825,7 +1828,7 @@ RefPtr<AccessibilityUIElement> AccessibilityUIElement::accessibilityElementForTe
     return nullptr;
 }
 
-static JSStringRef createJSStringRef(id string)
+static JSRetainPtr<JSStringRef> createJSStringRef(id string)
 {
     id mutableString = [[[NSMutableString alloc] init] autorelease];
     id attributes = [string attributesAtIndex:0 effectiveRange:nil];
index 752731c..daf14ca 100644 (file)
@@ -50,7 +50,7 @@ inline WKRetainPtr<WKStringRef> toWK(JSStringRef string)
     return adoptWK(WKStringCreateWithJSString(string));
 }
 
-inline WKRetainPtr<WKStringRef> toWK(JSRetainPtr<JSStringRef> string)
+inline WKRetainPtr<WKStringRef> toWK(const JSRetainPtr<JSStringRef>& string)
 {
     return toWK(string.get());
 }
@@ -62,7 +62,7 @@ inline WKRetainPtr<WKStringRef> toWK(const WTF::String& string)
 
 inline JSRetainPtr<JSStringRef> toJS(WKStringRef string)
 {
-    return JSRetainPtr<JSStringRef>(Adopt, WKStringCopyJSString(string));
+    return adopt(WKStringCopyJSString(string));
 }
 
 inline JSRetainPtr<JSStringRef> toJS(const WKRetainPtr<WKStringRef>& string)