WebKit Bugzilla
Attachment 349270 Details for
Bug 189455
: Streamline JSRetainPtr, fix leaks of JSString and JSGlobalContext
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-189455-20180908183136.patch (text/plain), 217.47 KB, created by
Darin Adler
on 2018-09-08 18:31:37 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Darin Adler
Created:
2018-09-08 18:31:37 PDT
Size:
217.47 KB
patch
obsolete
>Subversion Revision: 235832 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 1b1f86c790e96b9ff2d2dd81c6272deb4c7ab90b..e81c3a1f88b148dccd3a695535cd2515cdadb98d 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,68 @@ >+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 NOBODY (OOPS!). >+ >+ * API/JSObjectRef.cpp: >+ (JSObjectCopyPropertyNames): Use adopt function instead of constructor. >+ >+ * 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-08 Yusuke Suzuki <utatane.tea@gmail.com> > > [JSC] Remove loadModule function in jsc.cpp >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index c5a3807f212de07aa798ee53f13972d1117d6035..3d9dfa42164f418190c21fd9e454765b03eb4cce 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -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 NOBODY (OOPS!). >+ >+ * Modules/plugins/QuickTimePluginReplacement.mm: >+ (WebCore::jsValueWithDictionaryInContext): Adding a missing >+ JSStringRelease to fix a leak. >+ > 2018-09-08 Simon Fraser <simon.fraser@apple.com> > > Clean up code related to Document node removal >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 5e9e188983a7632bd156e87cab47c1d81ddcfb8b..09f3f8b7561336a5c4ed436f5dac39e39b2fb515 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -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 NOBODY (OOPS!). >+ >+ * 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-08 Tim Horton <timothy_horton@apple.com> > > Unify most of the WebKit Objective-C API sources >diff --git a/Source/JavaScriptCore/API/JSObjectRef.cpp b/Source/JavaScriptCore/API/JSObjectRef.cpp >index 694d185fd50850250c27b014742940875e4dd2f6..6553f325fa018aedbbe10b26d7de0f5fcca25a28 100644 >--- a/Source/JavaScriptCore/API/JSObjectRef.cpp >+++ b/Source/JavaScriptCore/API/JSObjectRef.cpp >@@ -793,7 +793,7 @@ 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(adopt(OpaqueJSString::create(array[i].string()).leakRef())); > > return JSPropertyNameArrayRetain(propertyNames); > } >diff --git a/Source/JavaScriptCore/API/JSRetainPtr.h b/Source/JavaScriptCore/API/JSRetainPtr.h >index e400840803c71087cc7d6d6ef48ce41076fb8260..a78b64dfbd273ef89f4a02035950ac64029b58eb 100644 >--- a/Source/JavaScriptCore/API/JSRetainPtr.h >+++ b/Source/JavaScriptCore/API/JSRetainPtr.h >@@ -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,29 @@ 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. >+ 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 +98,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 +111,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 +136,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 +180,3 @@ template<typename T, typename U> inline bool operator!=(T* a, const JSRetainPtr< > { > return a != b.get(); > } >- >- >-#endif // JSRetainPtr_h >diff --git a/Source/JavaScriptCore/API/JSValue.mm b/Source/JavaScriptCore/API/JSValue.mm >index df45fc0dc89ee9e576093e4506f57a94269651d6..9e49ae2472368de99cb44af7896da79902db29de 100644 >--- a/Source/JavaScriptCore/API/JSValue.mm >+++ b/Source/JavaScriptCore/API/JSValue.mm >@@ -154,8 +154,10 @@ + (JSValue *)valueWithUndefinedInContext:(JSContext *)context > > + (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; > } > > >diff --git a/Source/JavaScriptCore/API/tests/CustomGlobalObjectClassTest.c b/Source/JavaScriptCore/API/tests/CustomGlobalObjectClassTest.c >index 9ffe233f4b796f5a0b95b374a483b014ed5bdd97..82d2dc17d380dd2bd8ca7c903e47966eac70c411 100644 >--- a/Source/JavaScriptCore/API/tests/CustomGlobalObjectClassTest.c >+++ b/Source/JavaScriptCore/API/tests/CustomGlobalObjectClassTest.c >@@ -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); > } >diff --git a/Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp b/Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp >index 637b3049c3d7e06e3f645386e42835e1b596d046..ac8010a7fd34b3511f04787b8565db6174c71654 100644 >--- a/Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp >+++ b/Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp >@@ -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 > >diff --git a/Source/JavaScriptCore/API/tests/FunctionOverridesTest.cpp b/Source/JavaScriptCore/API/tests/FunctionOverridesTest.cpp >index cf0d6dc0419eba9e5afc50a9e65417911a450df8..83896150f03a36289753c3d1539c8ee70b1bf05d 100644 >--- a/Source/JavaScriptCore/API/tests/FunctionOverridesTest.cpp >+++ b/Source/JavaScriptCore/API/tests/FunctionOverridesTest.cpp >@@ -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; >diff --git a/Source/JavaScriptCore/API/tests/JSObjectGetProxyTargetTest.cpp b/Source/JavaScriptCore/API/tests/JSObjectGetProxyTargetTest.cpp >index 7f2c3fe036ec249e254219a0a38f446b144ca8c7..71821eaeb627f23330ae499bd30c40d3ec5e5b19 100644 >--- a/Source/JavaScriptCore/API/tests/JSObjectGetProxyTargetTest.cpp >+++ b/Source/JavaScriptCore/API/tests/JSObjectGetProxyTargetTest.cpp >@@ -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"); >diff --git a/Source/JavaScriptCore/API/tests/PingPongStackOverflowTest.cpp b/Source/JavaScriptCore/API/tests/PingPongStackOverflowTest.cpp >index 042bebf5d07744bc42a8c734f7901144d360dae8..fbe46872032b8610903345f647eadda34c0d8991 100644 >--- a/Source/JavaScriptCore/API/tests/PingPongStackOverflowTest.cpp >+++ b/Source/JavaScriptCore/API/tests/PingPongStackOverflowTest.cpp >@@ -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; >diff --git a/Source/JavaScriptCore/API/tests/testapi.c b/Source/JavaScriptCore/API/tests/testapi.c >index 3fc861219a30845aa8be86446058afb3f6207ad9..01b038ae00dc4c38901a48f80769f07dbe992614 100644 >--- a/Source/JavaScriptCore/API/tests/testapi.c >+++ b/Source/JavaScriptCore/API/tests/testapi.c >@@ -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,7 +344,7 @@ static bool MyObject_hasInstance(JSContextRef context, JSObjectRef constructor, > UNUSED_PARAM(context); > UNUSED_PARAM(constructor); > >- if (JSValueIsString(context, possibleValue) && JSStringIsEqualToUTF8CString(JSValueToStringCopy(context, possibleValue, 0), "throwOnHasInstance")) { >+ if (isValueEqualToString(context, possibleValue, "throwOnHasInstance")) { > JSEvaluateScript(context, JSStringCreateWithUTF8CString("throw 'an exception'"), constructor, JSStringCreateWithUTF8CString("test script"), 1, exception); > return false; > } >@@ -1137,6 +1159,8 @@ static bool globalContextNameTest() > JSStringRelease(fetchName1); > JSStringRelease(fetchName2); > >+ JSGlobalContextRelease(context); >+ > return result; > } > >@@ -1243,7 +1267,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"); >diff --git a/Source/WebCore/Modules/plugins/QuickTimePluginReplacement.mm b/Source/WebCore/Modules/plugins/QuickTimePluginReplacement.mm >index 3dfd97bf6d27088ec911ab34e1d1d388bd227504..ca34d8172e25314ab8a37bf49e85085c6f8fb9f5 100644 >--- a/Source/WebCore/Modules/plugins/QuickTimePluginReplacement.mm >+++ b/Source/WebCore/Modules/plugins/QuickTimePluginReplacement.mm >@@ -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; > } >diff --git a/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp b/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp >index dd978b07e79deb959e93304474aa0585c9592e8c..fa6df2abe9ffca3fe50a89b81cacb0995dca3ad7 100644 >--- a/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp >+++ b/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp >@@ -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); > } >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 6debc2979c6634b7661a4858c15a2b64753da7f8..089c6707cf9d5ef34affd9a11028d503f6ef464a 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,403 @@ >+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 NOBODY (OOPS!). >+ >+ There is a lot of copied and pasted code for WebKit vs. Legacy WebKit >+ testing and even for macOS vs. iOS platform-specific code. For now, >+ this patch just makes corresponding changes to the copied code. Later >+ we might get better results by merging 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. >+ * 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. >+ >+ * 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-02 Darin Adler <darin@apple.com> > > [Cocoa] Turn on ARC for WebKitTestRunner >diff --git a/Tools/DumpRenderTree/AccessibilityController.cpp b/Tools/DumpRenderTree/AccessibilityController.cpp >index d035dea997bf8f1b74408c458f6b9ec94360c8b1..1a0c16706b2ae4260e32d290449bf2d65cfa3dfa 100644 >--- a/Tools/DumpRenderTree/AccessibilityController.cpp >+++ b/Tools/DumpRenderTree/AccessibilityController.cpp >@@ -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); >diff --git a/Tools/DumpRenderTree/AccessibilityTextMarker.cpp b/Tools/DumpRenderTree/AccessibilityTextMarker.cpp >index 12504978b0804b4566575a5173f4b96ee0b16fe5..e117d66f195a725cbeaf4f6580853715f9517ee6 100644 >--- a/Tools/DumpRenderTree/AccessibilityTextMarker.cpp >+++ b/Tools/DumpRenderTree/AccessibilityTextMarker.cpp >@@ -27,7 +27,6 @@ > #include "AccessibilityTextMarker.h" > > #include "AccessibilityUIElement.h" >-#include <JavaScriptCore/JSRetainPtr.h> > > // MARK: AccessibilityTextMarker > >diff --git a/Tools/DumpRenderTree/AccessibilityUIElement.cpp b/Tools/DumpRenderTree/AccessibilityUIElement.cpp >index f66c133603af28ab9d21c1d1ba629f4f6ad30aa6..e18173d0a798fe251c35276677d2a7c4fd9b255e 100644 >--- a/Tools/DumpRenderTree/AccessibilityUIElement.cpp >+++ b/Tools/DumpRenderTree/AccessibilityUIElement.cpp >@@ -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; > } >diff --git a/Tools/DumpRenderTree/AccessibilityUIElement.h b/Tools/DumpRenderTree/AccessibilityUIElement.h >index 634ce8a8e411a0989f6820406f12f9659031bbef..3457811f56a513feef01d8280d76274a9b6544f1 100644 >--- a/Tools/DumpRenderTree/AccessibilityUIElement.h >+++ b/Tools/DumpRenderTree/AccessibilityUIElement.h >@@ -23,11 +23,11 @@ > * 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 >diff --git a/Tools/DumpRenderTree/Bindings/CodeGeneratorDumpRenderTree.pm b/Tools/DumpRenderTree/Bindings/CodeGeneratorDumpRenderTree.pm >index b2c786c67d9a1ef3bc22fa0d40907d8ba5095d5d..c3152db14e63d4f6a85ad51910999165c27a9f42 100644 >--- a/Tools/DumpRenderTree/Bindings/CodeGeneratorDumpRenderTree.pm >+++ b/Tools/DumpRenderTree/Bindings/CodeGeneratorDumpRenderTree.pm >@@ -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)"; > } > >diff --git a/Tools/DumpRenderTree/GCController.cpp b/Tools/DumpRenderTree/GCController.cpp >index 781a828ebd050bb0ae91f693166825eb9fef23f9..4a37bf3a13da4caeea40a0cf8a709fe58d34ea4c 100644 >--- a/Tools/DumpRenderTree/GCController.cpp >+++ b/Tools/DumpRenderTree/GCController.cpp >@@ -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); >diff --git a/Tools/DumpRenderTree/TestRunner.cpp b/Tools/DumpRenderTree/TestRunner.cpp >index a5c0d809dc30b611cb4332fb690e6ed3ea8c3ba9..24a0c66b96a3606a7d90eed5fb8549fbd9d47ab3 100644 >--- a/Tools/DumpRenderTree/TestRunner.cpp >+++ b/Tools/DumpRenderTree/TestRunner.cpp >@@ -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); >diff --git a/Tools/DumpRenderTree/TestRunner.h b/Tools/DumpRenderTree/TestRunner.h >index 4b50245c75a5c21209f120907cf04f0b899beedf..b5122832ebae3ec7d7a73bd84a4d3c4c2950d505 100644 >--- a/Tools/DumpRenderTree/TestRunner.h >+++ b/Tools/DumpRenderTree/TestRunner.h >@@ -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); >diff --git a/Tools/DumpRenderTree/ios/AccessibilityControllerIOS.mm b/Tools/DumpRenderTree/ios/AccessibilityControllerIOS.mm >index 54e4a708286813575c1f1e0a3ab66a4ae0a7cb38..61e01f5ed7675a830ba6f38f8ecf5840fbc839cb 100644 >--- a/Tools/DumpRenderTree/ios/AccessibilityControllerIOS.mm >+++ b/Tools/DumpRenderTree/ios/AccessibilityControllerIOS.mm >@@ -155,6 +155,5 @@ bool AccessibilityController::enhancedAccessibilityEnabled() > > JSRetainPtr<JSStringRef> AccessibilityController::platformName() const > { >- JSRetainPtr<JSStringRef> platformName(Adopt, JSStringCreateWithUTF8CString("ios")); >- return platformName; >+ return adopt(JSStringCreateWithUTF8CString("ios")); > } >diff --git a/Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm b/Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm >index bb6969e9e1afd72bfecefb29e57fe6e2c3e5e9c3..c94814b2f62441f6c4cee5d3db491c58685a08cf 100644 >--- a/Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm >+++ b/Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm >@@ -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 @@ @interface NSObject (WebAccessibilityObjectWrapperPrivate) > - (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; >diff --git a/Tools/DumpRenderTree/mac/AccessibilityCommonMac.h b/Tools/DumpRenderTree/mac/AccessibilityCommonMac.h >index a5321276ba75a8dfeeede4faee55a41688d8bebe..2f013a13b692ce69a3ab264cdf2619b3198fad34 100644 >--- a/Tools/DumpRenderTree/mac/AccessibilityCommonMac.h >+++ b/Tools/DumpRenderTree/mac/AccessibilityCommonMac.h >@@ -28,24 +28,19 @@ > * 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 >diff --git a/Tools/DumpRenderTree/mac/AccessibilityCommonMac.mm b/Tools/DumpRenderTree/mac/AccessibilityCommonMac.mm >index 6597cad1805a154a25a0b22979390e7e38f71afb..0b867adcb90c3122416dcc265f3853b61b6d4713 100644 >--- a/Tools/DumpRenderTree/mac/AccessibilityCommonMac.mm >+++ b/Tools/DumpRenderTree/mac/AccessibilityCommonMac.mm >@@ -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 @@ + (NSString *)stringWithJSStringRef:(JSStringRef)jsStringRef > 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)); >diff --git a/Tools/DumpRenderTree/mac/AccessibilityControllerMac.mm b/Tools/DumpRenderTree/mac/AccessibilityControllerMac.mm >index 6b544553ffa8866947ff6723b345e118e3ba7c19..a4a71b2a7c32efe1749f806dedf2998b013ab6ab 100644 >--- a/Tools/DumpRenderTree/mac/AccessibilityControllerMac.mm >+++ b/Tools/DumpRenderTree/mac/AccessibilityControllerMac.mm >@@ -158,6 +158,5 @@ bool AccessibilityController::enhancedAccessibilityEnabled() > > JSRetainPtr<JSStringRef> AccessibilityController::platformName() const > { >- JSRetainPtr<JSStringRef> platformName(Adopt, JSStringCreateWithUTF8CString("mac")); >- return platformName; >+ return adopt(JSStringCreateWithUTF8CString("ios")); > } >diff --git a/Tools/DumpRenderTree/mac/AccessibilityNotificationHandler.mm b/Tools/DumpRenderTree/mac/AccessibilityNotificationHandler.mm >index 03aa9c685a10e74614e9d26eb56c2526fc9b4139..9d7ff6e9be6444537a9ffa5ba863bec467aafba6 100644 >--- a/Tools/DumpRenderTree/mac/AccessibilityNotificationHandler.mm >+++ b/Tools/DumpRenderTree/mac/AccessibilityNotificationHandler.mm >@@ -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> >@@ -45,14 +44,14 @@ + (void)accessibilitySetShouldRepostNotifications:(BOOL)repost; > @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 @@ - (void)stopObserving > 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 @@ - (void)_notificationReceived:(NSNotification *)notification > 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. >diff --git a/Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm b/Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm >index ba9b550d7be8fc11369c3f125a48184c52bb41e7..b242a96f4b8047a2ad9297fad0751cf48832669c 100644 >--- a/Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm >+++ b/Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm >@@ -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 @@ - (void)_accessibilityScrollToGlobalPoint:(NSPoint)point; > - (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"]; >diff --git a/Tools/DumpRenderTree/mac/FrameLoadDelegate.mm b/Tools/DumpRenderTree/mac/FrameLoadDelegate.mm >index 331e1d8d215b3dfb4788fbdc70883c512bc962cd..05b0392de21dbf05235c979b98dfcbc38f7d7098 100644 >--- a/Tools/DumpRenderTree/mac/FrameLoadDelegate.mm >+++ b/Tools/DumpRenderTree/mac/FrameLoadDelegate.mm >@@ -347,7 +347,7 @@ - (void)didClearWindowObjectForFrame:(WebFrame *)frame inIsolatedWorld:(WebScrip > 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 >diff --git a/Tools/DumpRenderTree/mac/TestRunnerMac.mm b/Tools/DumpRenderTree/mac/TestRunnerMac.mm >index 0f90274a4a04758fd43b33f17cbc833d1c76914f..b5231655e8b6cae174fbf92300249df667c65e9f 100644 >--- a/Tools/DumpRenderTree/mac/TestRunnerMac.mm >+++ b/Tools/DumpRenderTree/mac/TestRunnerMac.mm >@@ -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 > } > >diff --git a/Tools/TestRunnerShared/Bindings/JSWrapper.h b/Tools/TestRunnerShared/Bindings/JSWrapper.h >index 081adbf6f9e2cd4d2d6a1939785165a3daae104a..778a30ec58fedb035ad60e7cf81efc0080d10cf5 100644 >--- a/Tools/TestRunnerShared/Bindings/JSWrapper.h >+++ b/Tools/TestRunnerShared/Bindings/JSWrapper.h >@@ -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 >diff --git a/Tools/TestRunnerShared/UIScriptContext/UIScriptContext.cpp b/Tools/TestRunnerShared/UIScriptContext/UIScriptContext.cpp >index 44c558e5769301aff6bb1b12ba5fcccc946a9b20..5a84da8387ae99b54e17b85883ab723b29cfd760 100644 >--- a/Tools/TestRunnerShared/UIScriptContext/UIScriptContext.cpp >+++ b/Tools/TestRunnerShared/UIScriptContext/UIScriptContext.cpp >@@ -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(); > } >diff --git a/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp b/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp >index b7c16f58117b00d00713a16001aa0bf01d908dd2..ae99048f91da45aad84183b20e6bc7dc93033d22 100644 >--- a/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp >+++ b/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp >@@ -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]; > >diff --git a/Tools/TestRunnerShared/cocoa/LayoutTestSpellChecker.mm b/Tools/TestRunnerShared/cocoa/LayoutTestSpellChecker.mm >index f9131af212898b538b17b9ffc0711a7d54ec8cca..11284b914ff88773ccd39408100101b60679a91d 100644 >--- a/Tools/TestRunnerShared/cocoa/LayoutTestSpellChecker.mm >+++ b/Tools/TestRunnerShared/cocoa/LayoutTestSpellChecker.mm >@@ -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 @@ - (void)setResultsFromJSObject:(JSObjectRef)resultsObject inContext:(JSContextRe > } > JSPropertyNameArrayRelease(detailsObjectProperties); > } >- [resultsForWord addObject:[[LayoutTestTextCheckingResult alloc] initWithType:nsTextCheckingType(WTFMove(typeValue)) range:NSMakeRange(fromValue, toValue - fromValue) replacement:(__bridge NSString *)replacementText.get() details:details.get()]]; >+ [resultsForWord addObject:[[LayoutTestTextCheckingResult alloc] initWithType:nsTextCheckingType(typeValue.get()) range:NSMakeRange(fromValue, toValue - fromValue) replacement:(__bridge NSString *)replacementText.get() details:details.get()]]; > } > auto cfTextToCheck = adoptCF(JSStringCopyCFString(kCFAllocatorDefault, textToCheck)); > [results setObject:resultsForWord.get() forKey:(__bridge NSString *)cfTextToCheck.get()]; >diff --git a/Tools/WebKitTestRunner/InjectedBundle/AccessibilityController.cpp b/Tools/WebKitTestRunner/InjectedBundle/AccessibilityController.cpp >index d07904b33f4811fbd1fad3b6c21391e40e6a7177..7b816764224d92f945404fda6ce71b00be039575 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/AccessibilityController.cpp >+++ b/Tools/WebKitTestRunner/InjectedBundle/AccessibilityController.cpp >@@ -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> >diff --git a/Tools/WebKitTestRunner/InjectedBundle/AccessibilityTextMarker.cpp b/Tools/WebKitTestRunner/InjectedBundle/AccessibilityTextMarker.cpp >index 7e99fbb127e8a7b59d04e791b4ab43f20404cd54..65336041dc07226fa50fdc83726df01552076de5 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/AccessibilityTextMarker.cpp >+++ b/Tools/WebKitTestRunner/InjectedBundle/AccessibilityTextMarker.cpp >@@ -29,8 +29,6 @@ > #include "AccessibilityUIElement.h" > #include "JSAccessibilityTextMarker.h" > >-#include <JavaScriptCore/JSRetainPtr.h> >- > namespace WTR { > > Ref<AccessibilityTextMarker> AccessibilityTextMarker::create(PlatformTextMarker marker) >diff --git a/Tools/WebKitTestRunner/InjectedBundle/AccessibilityTextMarkerRange.cpp b/Tools/WebKitTestRunner/InjectedBundle/AccessibilityTextMarkerRange.cpp >index 7444f35222ea1c587b428e83f830ae1eadc7af8b..2b21e8a8801868d99179a76d7381d711282fdf23 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/AccessibilityTextMarkerRange.cpp >+++ b/Tools/WebKitTestRunner/InjectedBundle/AccessibilityTextMarkerRange.cpp >@@ -29,8 +29,6 @@ > #include "AccessibilityUIElement.h" > #include "JSAccessibilityTextMarkerRange.h" > >-#include <JavaScriptCore/JSRetainPtr.h> >- > namespace WTR { > > Ref<AccessibilityTextMarkerRange> AccessibilityTextMarkerRange::create(PlatformTextMarkerRange markerRange) >diff --git a/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp b/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp >index e6195559a72ce1e23d67e2909475fff118f6d5c9..499cbe9c46f89f65693dfafc3836f66b10cf2b5b 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp >+++ b/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp >@@ -27,7 +27,6 @@ > #include "AccessibilityUIElement.h" > > #include "JSAccessibilityUIElement.h" >-#include <JavaScriptCore/JSRetainPtr.h> > > namespace WTR { > >diff --git a/Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm b/Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm >index 8591954b51a4ee13d2b3054b62f943aa3d3fb381..d6a638e18756db231f3e65691aa45fadd8df75e6 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm >+++ b/Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm >@@ -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)"; > } > >diff --git a/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp b/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp >index 76384d5e421def46670380811d5d91874ab5735e..25cfcbb0542b9eab9d93f1de11a6c6609a4b9594 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp >+++ b/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp >@@ -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()); >diff --git a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp >index 26efa88ed5f5bf5514d13b7bb26ef6097a000ea9..5576a98dc0b540ca99889ef53c1dcfba135ab956 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp >+++ b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp >@@ -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) >diff --git a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp >index a3ed22b869444214f98435027db8526fb0fc5f04..f70ee1311514194e65578da968d5d7c258cfd1aa 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp >+++ b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp >@@ -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); >diff --git a/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityControllerIOS.mm b/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityControllerIOS.mm >index f1796f2a50751c73453e15c799e1706ba9e28b62..dc3244bf50b801fd804d6cfd96250e5ea50d830f 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityControllerIOS.mm >+++ b/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityControllerIOS.mm >@@ -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() >diff --git a/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm b/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm >index b6afc854cdbf80ba6c2d1c77cbcbd1100421937d..19ef9b67694547b46e57a0ab05a7d57874617fc9 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm >+++ b/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm >@@ -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 @@ + (NSString *)stringWithJSStringRef:(JSStringRef)jsStringRef > 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) >@@ -322,22 +325,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) >@@ -360,7 +363,7 @@ JSRetainPtr<JSStringRef> AccessibilityUIElement::stringAttributeValue(JSStringRe > return [rectStr createJSStringRef]; > } > >- return JSStringCreateWithCharacters(0, 0); >+ return createEmptyJSString(); > } > > double AccessibilityUIElement::numberAttributeValue(JSStringRef attribute) >@@ -421,33 +424,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() >@@ -457,7 +460,7 @@ JSRetainPtr<JSStringRef> AccessibilityUIElement::description() > > JSRetainPtr<JSStringRef> AccessibilityUIElement::orientation() const > { >- return JSStringCreateWithCharacters(0, 0); >+ return createEmptyJSString(); > } > > JSRetainPtr<JSStringRef> AccessibilityUIElement::stringValue() >@@ -467,7 +470,7 @@ JSRetainPtr<JSStringRef> AccessibilityUIElement::stringValue() > > JSRetainPtr<JSStringRef> AccessibilityUIElement::language() > { >- return JSStringCreateWithCharacters(0, 0); >+ return createEmptyJSString(); > } > > JSRetainPtr<JSStringRef> AccessibilityUIElement::helpText() const >@@ -527,7 +530,7 @@ double AccessibilityUIElement::maxValue() > > JSRetainPtr<JSStringRef> AccessibilityUIElement::valueDescription() > { >- return JSStringCreateWithCharacters(0, 0); >+ return createEmptyJSString(); > } > > int AccessibilityUIElement::insertionPointLineNumber() >@@ -616,7 +619,7 @@ bool AccessibilityUIElement::ariaIsGrabbed() const > > JSRetainPtr<JSStringRef> AccessibilityUIElement::ariaDropEffects() const > { >- return JSStringCreateWithCharacters(0, 0); >+ return createEmptyJSString(); > } > > // parameterized attributes >@@ -637,24 +640,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]; > } > >@@ -697,32 +694,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() >@@ -818,7 +815,7 @@ void AccessibilityUIElement::scrollToMakeVisibleWithSubFocus(int x, int y, int w > > JSRetainPtr<JSStringRef> AccessibilityUIElement::selectedTextRange() > { >- return JSStringCreateWithCharacters(0, 0); >+ return createEmptyJSString(); > } > > bool AccessibilityUIElement::setSelectedVisibleTextRange(AccessibilityTextMarkerRange*) >@@ -875,17 +872,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() >@@ -925,9 +922,6 @@ void AccessibilityUIElement::decreaseTextSelection() > JSRetainPtr<JSStringRef> AccessibilityUIElement::stringForSelection() > { > NSString *stringForRange = [m_element selectionRangeString]; >- if (!stringForRange) >- return nullptr; >- > return [stringForRange createJSStringRef]; > } > >@@ -1094,7 +1088,7 @@ JSRetainPtr<JSStringRef> AccessibilityUIElement::stringForTextMarkerRange(Access > { > id textMarkers = (__bridge id)markerRange->platformTextMarkerRange(); > if (!textMarkers || ![textMarkers isKindOfClass:[NSArray class]]) >- return JSStringCreateWithCharacters(0, 0); >+ return createEmptyJSString(); > return [[m_element stringForTextMarkers:textMarkers] createJSStringRef]; > } > >diff --git a/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityCommonMac.h b/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityCommonMac.h >index 16ca3dd1d858877fb6aff3d60818262ca853ac17..f2f05fb8947819cb199e838930fea6a0b50f29cc 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityCommonMac.h >+++ b/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityCommonMac.h >@@ -28,22 +28,19 @@ > * 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 >diff --git a/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityCommonMac.mm b/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityCommonMac.mm >index 9ea64322d112206d2918ab447cb369ac2584ea2f..cf778c6e1d4aa0a8c53434c7882e69f8acb46ed1 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityCommonMac.mm >+++ b/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityCommonMac.mm >@@ -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 @@ + (NSString *)stringWithJSStringRef:(JSStringRef)jsStringRef > 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)); >diff --git a/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityControllerMac.mm b/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityControllerMac.mm >index 310fa4871542e7f8bdb911736385498a19e04e77..7069cafde294818f9dd6f8ef5f4038868ca32a6c 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityControllerMac.mm >+++ b/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityControllerMac.mm >@@ -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> >@@ -107,8 +105,7 @@ RefPtr<AccessibilityUIElement> AccessibilityController::accessibleElementById(JS > > JSRetainPtr<JSStringRef> AccessibilityController::platformName() > { >- JSRetainPtr<JSStringRef> platformName(Adopt, JSStringCreateWithUTF8CString("mac")); >- return platformName; >+ return adopt(JSStringCreateWithUTF8CString("mac")); > } > > } // namespace WTR >diff --git a/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityNotificationHandler.mm b/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityNotificationHandler.mm >index 5dd02f7f409bc8d2658904b8e8efc9ddfeab95b6..04dd333f1363587f258bed0c3dcae527a40a85ea 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityNotificationHandler.mm >+++ b/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityNotificationHandler.mm >@@ -47,14 +47,14 @@ + (void)accessibilitySetShouldRepostNotifications:(BOOL)repost; > @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 >@@ -124,7 +124,7 @@ - (void)stopObserving > 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]); >@@ -157,7 +157,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; >@@ -176,7 +176,7 @@ - (void)_notificationReceived:(NSNotification *)notification > 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. >diff --git a/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm b/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm >index 6cf4e9f8cd8a0b1226e96722b5a1587f5d5bbfa9..ae3912638a9a484bf59bf262b26cd1e22592dae7 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm >+++ b/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm >@@ -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 @@ @end > > namespace WTR { > >+static JSRetainPtr<JSStringRef> createEmptyJSString() >+{ >+ return adopt(JSStringCreateWithCharacters(nullptr, 0)); >+} >+ > AccessibilityUIElement::AccessibilityUIElement(PlatformUIElement element) > : m_element(element) > , m_notificationHandler(0) >@@ -195,7 +198,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()]; >@@ -206,7 +209,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) >@@ -216,7 +219,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(); >@@ -239,7 +242,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()]]; > } >@@ -247,13 +250,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()]]; > } >@@ -1496,7 +1499,7 @@ void AccessibilityUIElement::clearSelectedChildren() const > JSRetainPtr<JSStringRef> AccessibilityUIElement::accessibilityValue() const > { > // FIXME: implement >- return JSStringCreateWithCharacters(0, 0); >+ return createEmptyJSString(); > } > > JSRetainPtr<JSStringRef> AccessibilityUIElement::documentEncoding() >@@ -1507,7 +1510,7 @@ JSRetainPtr<JSStringRef> AccessibilityUIElement::documentEncoding() > return [value createJSStringRef]; > END_AX_OBJC_EXCEPTIONS > >- return JSStringCreateWithCharacters(0, 0); >+ return createEmptyJSString(); > } > > JSRetainPtr<JSStringRef> AccessibilityUIElement::documentURI() >@@ -1518,7 +1521,7 @@ JSRetainPtr<JSStringRef> AccessibilityUIElement::documentURI() > return [value createJSStringRef]; > END_AX_OBJC_EXCEPTIONS > >- return JSStringCreateWithCharacters(0, 0); >+ return createEmptyJSString(); > } > > JSRetainPtr<JSStringRef> AccessibilityUIElement::url() >@@ -1820,7 +1823,7 @@ RefPtr<AccessibilityUIElement> AccessibilityUIElement::accessibilityElementForTe > return nullptr; > } > >-static JSStringRef createJSStringRef(id string) >+static JSRetainPtr<JSStringRef> createJSStringRef(id string) > { > auto mutableString = [[NSMutableString alloc] init]; > auto attributes = [string attributesAtIndex:0 effectiveRange:nil]; >diff --git a/Tools/WebKitTestRunner/StringFunctions.h b/Tools/WebKitTestRunner/StringFunctions.h >index 752731cbf9ffe8b6e6b56fb32c815a0bf1598d1c..daf14ca705486bfc20643123de5091b79e5d0131 100644 >--- a/Tools/WebKitTestRunner/StringFunctions.h >+++ b/Tools/WebKitTestRunner/StringFunctions.h >@@ -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)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 189455
:
349270
|
349271
|
349273
|
349278
|
349279
|
349849
|
349853
|
349854