WebKit Bugzilla
Attachment 349873 Details for
Bug 189652
: Use OpaqueJSString rather than JSRetainPtr inside WebKit
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-189652-20180916123210.patch (text/plain), 33.13 KB, created by
Darin Adler
on 2018-09-16 12:32:11 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Darin Adler
Created:
2018-09-16 12:32:11 PDT
Size:
33.13 KB
patch
obsolete
>Subversion Revision: 236032 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index bafeb6e997670e8817a680d6ca98e96f7133869e..0af7622b22ca2d227dfaa49caef570075d54cedf 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,37 @@ >+2018-09-16 Darin Adler <darin@apple.com> >+ >+ Use OpaqueJSString rather than JSRetainPtr inside WebKit >+ https://bugs.webkit.org/show_bug.cgi?id=189652 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * API/JSCallbackObjectFunctions.h: Removed an uneeded include of >+ JSStringRef.h. >+ >+ * API/JSContext.mm: >+ (-[JSContext evaluateScript:withSourceURL:]): Use OpaqueJSString::create rather >+ than JSStringCreateWithCFString, simplifying the code and also obviating the >+ need for explicit JSStringRelease. >+ (-[JSContext setName:]): Ditto. >+ >+ * API/JSStringRef.cpp: >+ (JSStringIsEqualToUTF8CString): Use adoptRef rather than explicit JSStringRelease. >+ It seems that additional optimization is possible, obviating the need to allocate >+ an OpaqueJSString, but that's true almost everywhere else in this patch, too. >+ >+ * API/JSValue.mm: >+ (+[JSValue valueWithNewRegularExpressionFromPattern:flags:inContext:]): Use >+ OpaqueJSString::create and adoptRef as appropriate. >+ (+[JSValue valueWithNewErrorFromMessage:inContext:]): Ditto. >+ (+[JSValue valueWithNewSymbolFromDescription:inContext:]): Ditto. >+ (performPropertyOperation): Ditto. >+ (-[JSValue invokeMethod:withArguments:]): Ditto. >+ (valueToObjectWithoutCopy): Ditto. >+ (containerValueToObject): Ditto. >+ (valueToString): Ditto. >+ (objectToValueWithoutCopy): Ditto. >+ (objectToValue): Ditto. >+ > 2018-09-08 Darin Adler <darin@apple.com> > > Streamline JSRetainPtr, fix leaks of JSString and JSGlobalContext >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 82ada9d39001111836889c5c258e47d82a20a87b..eda1c0fd83cfb05655b68ab9ac16fb442dffac7b 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,17 @@ >+2018-09-16 Darin Adler <darin@apple.com> >+ >+ Use OpaqueJSString rather than JSRetainPtr inside WebKit >+ https://bugs.webkit.org/show_bug.cgi?id=189652 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Modules/plugins/QuickTimePluginReplacement.mm: >+ (WebCore::jsValueWithDictionaryInContext): Use OpaqueJSString::create. >+ (WebCore::jsValueWithAVMetadataItemInContext): Use adoptCF. >+ >+ * platform/mac/SerializedPlatformRepresentationMac.mm: >+ (WebCore::jsValueWithDictionaryInContext): Use OpaqueJSString::create. >+ > 2018-09-08 Darin Adler <darin@apple.com> > > Streamline JSRetainPtr, fix leaks of JSString and JSGlobalContext >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index ad6ed539f7fc1145430aebe4d742be32aaefbbfa..9f7e0dcb959f620f6da7540bd7bdba2d30e716e0 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,27 @@ >+2018-09-16 Darin Adler <darin@apple.com> >+ >+ Use OpaqueJSString rather than JSRetainPtr inside WebKit >+ https://bugs.webkit.org/show_bug.cgi?id=189652 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Shared/API/c/WKString.cpp: Removed unneeded include of JSStringRef.h. >+ >+ * WebProcess/Automation/WebAutomationSessionProxy.cpp: Removed unneeded >+ include of JSRetainPtr. >+ (WebKit::toJSString): Deleted. >+ (WebKit::toJSValue): Use OpaqueJSString::create. >+ (WebKit::callPropertyFunction): Ditto. >+ (WebKit::evaluate): Use adoptRef. >+ (WebKit::evaluateJavaScriptCallback): Ditto. >+ (WebKit::WebAutomationSessionProxy::scriptObjectForFrame): >+ Use OpaqueJSString::create. >+ (WebKit::WebAutomationSessionProxy::evaluateJavaScriptFunction): Use >+ String rather than JSStringRef. >+ >+ * WebProcess/Plugins/PDF/PDFPlugin.mm: Removed unneeded includes. >+ (WebKit::PDFPlugin::runScriptsInPDFDocument): Use OpaqueJSString::create. >+ > 2018-09-08 Darin Adler <darin@apple.com> > > Streamline JSRetainPtr, fix leaks of JSString and JSGlobalContext >diff --git a/Source/WebKitLegacy/ios/ChangeLog b/Source/WebKitLegacy/ios/ChangeLog >index cbce570eb369352fdc478feb7f9f2099b7251b61..0532670b4943827245c8a22b8e01dfd8ac01b26f 100644 >--- a/Source/WebKitLegacy/ios/ChangeLog >+++ b/Source/WebKitLegacy/ios/ChangeLog >@@ -1,3 +1,15 @@ >+2018-09-16 Darin Adler <darin@apple.com> >+ >+ Use OpaqueJSString rather than JSRetainPtr inside WebKit >+ https://bugs.webkit.org/show_bug.cgi?id=189652 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * WebView/WebPDFViewIOS.mm: >+ (-[WebPDFView finishedLoadingWithDataSource:]): Use OpaqueJSString::create. >+ * WebView/WebPDFViewPlaceholder.mm: >+ (-[WebPDFViewPlaceholder _evaluateJSForDocument:]): Ditto. >+ > 2018-08-29 Olivia Barnett <obarnett@apple.com> > > Implement the Web Share API >diff --git a/Source/WebKitLegacy/mac/ChangeLog b/Source/WebKitLegacy/mac/ChangeLog >index 7c9642460c02830da154889e52a8d7f8fd2c0c13..c95e4c365fe12097316794ec3a0e99a7375c4916 100644 >--- a/Source/WebKitLegacy/mac/ChangeLog >+++ b/Source/WebKitLegacy/mac/ChangeLog >@@ -1,3 +1,13 @@ >+2018-09-16 Darin Adler <darin@apple.com> >+ >+ Use OpaqueJSString rather than JSRetainPtr inside WebKit >+ https://bugs.webkit.org/show_bug.cgi?id=189652 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * WebView/WebPDFRepresentation.mm: >+ (-[WebPDFRepresentation finishedLoadingWithDataSource:]): Use OpaqueJSString::create. >+ > 2018-09-14 Jer Noble <jer.noble@apple.com> > > Turn SourceBufferChangeTypeEnabled on by default >diff --git a/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h b/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h >index 0b2f04ef6f81037514329eef80b0c6ac9e9e4f86..15b860866dea92284b78a0d707d80166598771d1 100644 >--- a/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h >+++ b/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h >@@ -34,7 +34,6 @@ > #include "JSLock.h" > #include "JSObjectRef.h" > #include "JSString.h" >-#include "JSStringRef.h" > #include "OpaqueJSString.h" > #include "PropertyNameArray.h" > #include <wtf/Vector.h> >diff --git a/Source/JavaScriptCore/API/JSContext.mm b/Source/JavaScriptCore/API/JSContext.mm >index f4e88c144eaa169190b6ca337d54ba0db5d61b35..b88ceaa851242adfa04ace2b280c9bdab4ed5a29 100644 >--- a/Source/JavaScriptCore/API/JSContext.mm >+++ b/Source/JavaScriptCore/API/JSContext.mm >@@ -100,12 +100,9 @@ - (JSValue *)evaluateScript:(NSString *)script > - (JSValue *)evaluateScript:(NSString *)script withSourceURL:(NSURL *)sourceURL > { > JSValueRef exceptionValue = nullptr; >- JSStringRef scriptJS = JSStringCreateWithCFString((__bridge CFStringRef)script); >- JSStringRef sourceURLJS = sourceURL ? JSStringCreateWithCFString((__bridge CFStringRef)[sourceURL absoluteString]) : nullptr; >- JSValueRef result = JSEvaluateScript(m_context, scriptJS, nullptr, sourceURLJS, 0, &exceptionValue); >- if (sourceURLJS) >- JSStringRelease(sourceURLJS); >- JSStringRelease(scriptJS); >+ auto scriptJS = OpaqueJSString::create(script); >+ auto sourceURLJS = OpaqueJSString::create([sourceURL absoluteString]); >+ JSValueRef result = JSEvaluateScript(m_context, scriptJS.get(), nullptr, sourceURLJS.get(), 0, &exceptionValue); > > if (exceptionValue) > return [self valueFromNotifyException:exceptionValue]; >@@ -202,10 +199,7 @@ - (NSString *)name > > - (void)setName:(NSString *)name > { >- JSStringRef nameJS = name ? JSStringCreateWithCFString((__bridge CFStringRef)name) : nullptr; >- JSGlobalContextSetName(m_context, nameJS); >- if (nameJS) >- JSStringRelease(nameJS); >+ JSGlobalContextSetName(m_context, OpaqueJSString::create(name).get()); > } > > - (BOOL)_remoteInspectionEnabled >diff --git a/Source/JavaScriptCore/API/JSStringRef.cpp b/Source/JavaScriptCore/API/JSStringRef.cpp >index 909540481da914d8ea19c649bcbe178a269af0b0..1683aae59529390245aafac0ba31bb87200b9f36 100644 >--- a/Source/JavaScriptCore/API/JSStringRef.cpp >+++ b/Source/JavaScriptCore/API/JSStringRef.cpp >@@ -125,9 +125,5 @@ bool JSStringIsEqual(JSStringRef a, JSStringRef b) > > bool JSStringIsEqualToUTF8CString(JSStringRef a, const char* b) > { >- JSStringRef bBuf = JSStringCreateWithUTF8CString(b); >- bool result = JSStringIsEqual(a, bBuf); >- JSStringRelease(bBuf); >- >- return result; >+ return JSStringIsEqual(a, adoptRef(JSStringCreateWithUTF8CString(b)).get()); > } >diff --git a/Source/JavaScriptCore/API/JSValue.mm b/Source/JavaScriptCore/API/JSValue.mm >index 9e49ae2472368de99cb44af7896da79902db29de..dc112396d3891cb96fa72dfb4605c5c02879b210 100644 >--- a/Source/JavaScriptCore/API/JSValue.mm >+++ b/Source/JavaScriptCore/API/JSValue.mm >@@ -124,21 +124,16 @@ + (JSValue *)valueWithNewArrayInContext:(JSContext *)context > > + (JSValue *)valueWithNewRegularExpressionFromPattern:(NSString *)pattern flags:(NSString *)flags inContext:(JSContext *)context > { >- JSStringRef patternString = JSStringCreateWithCFString((__bridge CFStringRef)pattern); >- JSStringRef flagsString = JSStringCreateWithCFString((__bridge CFStringRef)flags); >- JSValueRef arguments[2] = { JSValueMakeString([context JSGlobalContextRef], patternString), JSValueMakeString([context JSGlobalContextRef], flagsString) }; >- JSStringRelease(patternString); >- JSStringRelease(flagsString); >- >+ auto patternString = OpaqueJSString::create(pattern); >+ auto flagsString = OpaqueJSString::create(flags); >+ JSValueRef arguments[2] = { JSValueMakeString([context JSGlobalContextRef], patternString.get()), JSValueMakeString([context JSGlobalContextRef], flagsString.get()) }; > return [JSValue valueWithJSValueRef:JSObjectMakeRegExp([context JSGlobalContextRef], 2, arguments, 0) inContext:context]; > } > > + (JSValue *)valueWithNewErrorFromMessage:(NSString *)message inContext:(JSContext *)context > { >- JSStringRef string = JSStringCreateWithCFString((__bridge CFStringRef)message); >- JSValueRef argument = JSValueMakeString([context JSGlobalContextRef], string); >- JSStringRelease(string); >- >+ auto string = OpaqueJSString::create(message); >+ JSValueRef argument = JSValueMakeString([context JSGlobalContextRef], string.get()); > return [JSValue valueWithJSValueRef:JSObjectMakeError([context JSGlobalContextRef], 1, &argument, 0) inContext:context]; > } > >@@ -154,13 +149,10 @@ + (JSValue *)valueWithUndefinedInContext:(JSContext *)context > > + (JSValue *)valueWithNewSymbolFromDescription:(NSString *)description inContext:(JSContext *)context > { >- JSStringRef string = JSStringCreateWithCFString((__bridge CFStringRef)description); >- auto value = [JSValue valueWithJSValueRef:JSValueMakeSymbol([context JSGlobalContextRef], string) inContext:context]; >- JSStringRelease(string); >- return value; >+ auto string = OpaqueJSString::create(description); >+ return [JSValue valueWithJSValueRef:JSValueMakeSymbol([context JSGlobalContextRef], string.get()) inContext:context]; > } > >- > - (id)toObject > { > return valueToObject(_context, m_value); >@@ -256,9 +248,8 @@ inline Expected<Result, JSValueRef> performPropertyOperation(NSStringFunction st > Result result; > // If it's a NSString already, reduce indirection and just pass the NSString. > if ([propertyKey isKindOfClass:[NSString class]]) { >- JSStringRef name = JSStringCreateWithCFString((__bridge CFStringRef)propertyKey); >- result = stringFunction([context JSGlobalContextRef], object, name, arguments..., &exception); >- JSStringRelease(name); >+ auto name = OpaqueJSString::create((NSString *)propertyKey); >+ result = stringFunction([context JSGlobalContextRef], object, name.get(), arguments..., &exception); > } else > result = jsFunction([context JSGlobalContextRef], object, [[JSValue valueWithObject:propertyKey inContext:context] JSValueRef], arguments..., &exception); > return Expected<Result, JSValueRef>(result); >@@ -485,9 +476,8 @@ - (JSValue *)invokeMethod:(NSString *)method withArguments:(NSArray *)arguments > if (exception) > return [_context valueFromNotifyException:exception]; > >- JSStringRef name = JSStringCreateWithCFString((__bridge CFStringRef)method); >- JSValueRef function = JSObjectGetProperty([_context JSGlobalContextRef], thisObject, name, &exception); >- JSStringRelease(name); >+ auto name = OpaqueJSString::create(method); >+ JSValueRef function = JSObjectGetProperty([_context JSGlobalContextRef], thisObject, name.get(), &exception); > if (exception) > return [_context valueFromNotifyException:exception]; > >@@ -698,9 +688,8 @@ static JSContainerConvertor::Task valueToObjectWithoutCopy(JSGlobalContextRef co > primitive = [NSNumber numberWithDouble:JSValueToNumber(context, value, 0)]; > } else if (JSValueIsString(context, value)) { > // Would be nice to unique strings, too. >- JSStringRef jsstring = JSValueToStringCopy(context, value, 0); >- primitive = CFBridgingRelease(JSStringCopyCFString(kCFAllocatorDefault, jsstring)); >- JSStringRelease(jsstring); >+ auto jsstring = adoptRef(JSValueToStringCopy(context, value, 0)); >+ primitive = CFBridgingRelease(JSStringCopyCFString(kCFAllocatorDefault, jsstring.get())); > } else if (JSValueIsNull(context, value)) > primitive = [NSNull null]; > else { >@@ -741,9 +730,8 @@ static id containerValueToObject(JSGlobalContextRef context, JSContainerConverto > ASSERT([current.objc isKindOfClass:[NSMutableArray class]]); > NSMutableArray *array = (NSMutableArray *)current.objc; > >- JSStringRef lengthString = JSStringCreateWithUTF8CString("length"); >- unsigned length = JSC::toUInt32(JSValueToNumber(context, JSObjectGetProperty(context, js, lengthString, 0), 0)); >- JSStringRelease(lengthString); >+ auto lengthString = OpaqueJSString::create("length"_s); >+ unsigned length = JSC::toUInt32(JSValueToNumber(context, JSObjectGetProperty(context, js, lengthString.get(), 0), 0)); > > for (unsigned i = 0; i < length; ++i) { > id objc = convertor.convert(JSObjectGetPropertyAtIndex(context, js, i, 0)); >@@ -803,15 +791,13 @@ id valueToString(JSGlobalContextRef context, JSValueRef value, JSValueRef* excep > return wrapped; > } > >- JSStringRef jsstring = JSValueToStringCopy(context, value, exception); >+ auto jsstring = adoptRef(JSValueToStringCopy(context, value, exception)); > if (*exception) { > ASSERT(!jsstring); > return nil; > } > >- NSString *string = CFBridgingRelease(JSStringCopyCFString(kCFAllocatorDefault, jsstring)); >- JSStringRelease(jsstring); >- return string; >+ return CFBridgingRelease(JSStringCopyCFString(kCFAllocatorDefault, jsstring.get())); > } > > id valueToDate(JSGlobalContextRef context, JSValueRef value, JSValueRef* exception) >@@ -954,10 +940,8 @@ static ObjcContainerConvertor::Task objectToValueWithoutCopy(JSContext *context, > return { object, ((JSValue *)object)->m_value, ContainerNone }; > > if ([object isKindOfClass:[NSString class]]) { >- JSStringRef string = JSStringCreateWithCFString((__bridge CFStringRef)object); >- JSValueRef js = JSValueMakeString(contextRef, string); >- JSStringRelease(string); >- return { object, js, ContainerNone }; >+ auto string = OpaqueJSString::create((NSString *)object); >+ return { object, JSValueMakeString(contextRef, string.get()), ContainerNone }; > } > > if ([object isKindOfClass:[NSNumber class]]) { >@@ -1013,13 +997,11 @@ JSValueRef objectToValue(JSContext *context, id object) > NSDictionary *dictionary = (NSDictionary *)current.objc; > for (id key in [dictionary keyEnumerator]) { > if ([key isKindOfClass:[NSString class]]) { >- JSStringRef propertyName = JSStringCreateWithCFString((__bridge CFStringRef)key); >- JSObjectSetProperty(contextRef, js, propertyName, convertor.convert([dictionary objectForKey:key]), 0, 0); >- JSStringRelease(propertyName); >+ auto propertyName = OpaqueJSString::create((NSString *)key); >+ JSObjectSetProperty(contextRef, js, propertyName.get(), convertor.convert([dictionary objectForKey:key]), 0, 0); > } > } > } >- > } while (!convertor.isWorkListEmpty()); > > return task.js; >diff --git a/Source/WebCore/Modules/plugins/QuickTimePluginReplacement.mm b/Source/WebCore/Modules/plugins/QuickTimePluginReplacement.mm >index ca34d8172e25314ab8a37bf49e85085c6f8fb9f5..79ec891d813cd91b708719f742d969a7ff21f709 100644 >--- a/Source/WebCore/Modules/plugins/QuickTimePluginReplacement.mm >+++ b/Source/WebCore/Modules/plugins/QuickTimePluginReplacement.mm >@@ -255,6 +255,7 @@ void QuickTimePluginReplacement::postEvent(const String& eventName) > } > > #if PLATFORM(IOS) >+ > static JSValue *jsValueWithDataInContext(NSData *data, const String& mimeType, JSContext *context) > { > Vector<char> base64Data; >@@ -291,7 +292,6 @@ static JSValue *jsValueWithArrayInContext(NSArray *array, JSContext *context) > return result; > } > >- > static JSValue *jsValueWithDictionaryInContext(NSDictionary *dictionary, JSContext *context) > { > JSValueRef exception = 0; >@@ -308,9 +308,8 @@ static JSValue *jsValueWithDictionaryInContext(NSDictionary *dictionary, JSConte > if (!value) > continue; > >- JSStringRef name = JSStringCreateWithCFString((__bridge CFStringRef)key); >- JSObjectSetProperty([context JSGlobalContextRef], resultObject, name, [value JSValueRef], 0, &exception); >- JSStringRelease(name); >+ auto name = OpaqueJSString::create(key); >+ JSObjectSetProperty([context JSGlobalContextRef], resultObject, name.get(), [value JSValueRef], 0, &exception); > if (exception) > continue; > } >@@ -350,12 +349,8 @@ static JSValue *jsValueWithAVMetadataItemInContext(AVMetadataItemType *item, JSC > [dictionary setObject:item.locale forKey:@"locale"]; > > if (CMTIME_IS_VALID(item.time)) { >- CFDictionaryRef timeDict = PAL::CMTimeCopyAsDictionary(item.time, kCFAllocatorDefault); >- >- if (timeDict) { >- [dictionary setObject:(id)timeDict forKey:@"timestamp"]; >- CFRelease(timeDict); >- } >+ if (auto timeDictionary = adoptCF(PAL::CMTimeCopyAsDictionary(item.time, kCFAllocatorDefault))) >+ [dictionary setObject:(__bridge NSDictionary *)timeDictionary.get() forKey:@"timestamp"]; > } > > if (item.value) { >@@ -365,13 +360,14 @@ static JSValue *jsValueWithAVMetadataItemInContext(AVMetadataItemType *item, JSC > Vector<char> base64Data; > base64Encode([value bytes], [value length], base64Data); > String data64 = "data:" + String(mimeType) + ";base64," + base64Data; >- [dictionary setObject:(id)data64.createCFString().get() forKey:@"value"]; >+ [dictionary setObject:(__bridge NSString *)data64.createCFString().get() forKey:@"value"]; > } else > [dictionary setObject:value forKey:@"value"]; > } > > return jsValueWithDictionaryInContext(dictionary, context); > } >+ > #endif > > JSC::JSValue JSQuickTimePluginReplacement::timedMetaData(JSC::ExecState& state) const >@@ -391,7 +387,7 @@ JSC::JSValue JSQuickTimePluginReplacement::timedMetaData(JSC::ExecState& state) > > JSContext *jsContext = frame->script().javaScriptContext(); > JSValue *metaDataValue = jsValueWithValueInContext(metaData, jsContext); >- >+ > return toJS(&state, [metaDataValue JSValueRef]); > #else > UNUSED_PARAM(state); >diff --git a/Source/WebCore/platform/mac/SerializedPlatformRepresentationMac.mm b/Source/WebCore/platform/mac/SerializedPlatformRepresentationMac.mm >index ded7ec0c7989c024b50e7ef941a95cab34b4b61b..dc0d41c01f0c81330c8b5ce0b1addf8a4d5e579e 100644 >--- a/Source/WebCore/platform/mac/SerializedPlatformRepresentationMac.mm >+++ b/Source/WebCore/platform/mac/SerializedPlatformRepresentationMac.mm >@@ -190,9 +190,8 @@ static JSValue *jsValueWithDictionaryInContext(NSDictionary *dictionary, JSConte > if (!value) > continue; > >- JSStringRef name = JSStringCreateWithCFString((__bridge CFStringRef)key); >- JSObjectSetProperty([context JSGlobalContextRef], resultObject, name, [value JSValueRef], 0, &exception); >- JSStringRelease(name); >+ auto name = OpaqueJSString::create(key); >+ JSObjectSetProperty([context JSGlobalContextRef], resultObject, name.get(), [value JSValueRef], 0, &exception); > if (exception) > continue; > } >diff --git a/Source/WebKit/Shared/API/c/WKString.cpp b/Source/WebKit/Shared/API/c/WKString.cpp >index 650367045aee6dad6440603050b7b62cfd42049a..78de61e98a7792782c502a40478cb3add215b105 100644 >--- a/Source/WebKit/Shared/API/c/WKString.cpp >+++ b/Source/WebKit/Shared/API/c/WKString.cpp >@@ -29,7 +29,6 @@ > > #include "WKAPICast.h" > #include <JavaScriptCore/InitializeThreading.h> >-#include <JavaScriptCore/JSStringRef.h> > #include <JavaScriptCore/OpaqueJSString.h> > > using namespace WebKit; >diff --git a/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp b/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp >index fa6df2abe9ffca3fe50a89b81cacb0995dca3ad7..29fb01e20c40084f39a93976197eda85543c9fc1 100644 >--- a/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp >+++ b/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp >@@ -38,7 +38,6 @@ > #include "WebProcess.h" > #include <JavaScriptCore/APICast.h> > #include <JavaScriptCore/JSObject.h> >-#include <JavaScriptCore/JSRetainPtr.h> > #include <JavaScriptCore/JSStringRefPrivate.h> > #include <JavaScriptCore/OpaqueJSString.h> > #include <WebCore/CookieJar.h> >@@ -87,14 +86,9 @@ static JSObjectRef toJSArray(JSContextRef context, const Vector<T>& data, JSValu > return array; > } > >-static inline JSRetainPtr<JSStringRef> toJSString(const String& string) >-{ >- return adopt(OpaqueJSString::create(string).leakRef()); >-} >- > static inline JSValueRef toJSValue(JSContextRef context, const String& string) > { >- return JSValueMakeString(context, toJSString(string).get()); >+ return JSValueMakeString(context, OpaqueJSString::create(string).get()); > } > > static inline JSValueRef callPropertyFunction(JSContextRef context, JSObjectRef object, const String& propertyName, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) >@@ -102,7 +96,7 @@ static inline JSValueRef callPropertyFunction(JSContextRef context, JSObjectRef > ASSERT_ARG(object, object); > ASSERT_ARG(object, JSValueIsObject(context, object)); > >- JSObjectRef function = const_cast<JSObjectRef>(JSObjectGetProperty(context, object, toJSString(propertyName).get(), exception)); >+ JSObjectRef function = const_cast<JSObjectRef>(JSObjectGetProperty(context, object, OpaqueJSString::create(propertyName).get(), exception)); > ASSERT(JSObjectIsFunction(context, function)); > > return JSObjectCallAsFunction(context, function, object, argumentCount, arguments, exception); >@@ -127,7 +121,7 @@ static JSValueRef evaluate(JSContextRef context, JSObjectRef function, JSObjectR > if (argumentCount != 1) > return JSValueMakeUndefined(context); > >- auto script = adopt(JSValueToStringCopy(context, arguments[0], exception)); >+ auto script = adoptRef(JSValueToStringCopy(context, arguments[0], exception)); > return JSEvaluateScript(context, script.get(), nullptr, nullptr, 0, exception); > } > >@@ -150,7 +144,7 @@ static JSValueRef evaluateJavaScriptCallback(JSContextRef context, JSObjectRef f > > uint64_t frameID = JSValueToNumber(context, arguments[0], exception); > uint64_t callbackID = JSValueToNumber(context, arguments[1], exception); >- auto result = adopt(JSValueToStringCopy(context, arguments[2], exception)); >+ auto result = adoptRef(JSValueToStringCopy(context, arguments[2], exception)); > > bool resultIsErrorName = JSValueToBoolean(context, arguments[3]); > >@@ -183,7 +177,7 @@ JSObjectRef WebAutomationSessionProxy::scriptObjectForFrame(WebFrame& frame) > > String script = StringImpl::createWithoutCopying(WebAutomationSessionProxyScriptSource, sizeof(WebAutomationSessionProxyScriptSource)); > >- JSObjectRef scriptObjectFunction = const_cast<JSObjectRef>(JSEvaluateScript(context, toJSString(script).get(), nullptr, nullptr, 0, &exception)); >+ JSObjectRef scriptObjectFunction = const_cast<JSObjectRef>(JSEvaluateScript(context, OpaqueJSString::create(script).get(), nullptr, nullptr, 0, &exception)); > ASSERT(JSValueIsObject(context, scriptObjectFunction)); > > JSValueRef arguments[] = { sessionIdentifier, evaluateFunction, createUUIDFunction }; >@@ -284,25 +278,25 @@ void WebAutomationSessionProxy::evaluateJavaScriptFunction(uint64_t pageID, uint > > String errorType = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::JavaScriptError); > >- JSRetainPtr<JSStringRef> exceptionMessage; >+ String exceptionMessage; > if (JSValueIsObject(context, exception)) { >- JSValueRef nameValue = JSObjectGetProperty(context, const_cast<JSObjectRef>(exception), toJSString("name"_s).get(), nullptr); >- auto exceptionName = adopt(JSValueToStringCopy(context, nameValue, nullptr)); >- if (exceptionName->string() == "NodeNotFound") >+ JSValueRef nameValue = JSObjectGetProperty(context, const_cast<JSObjectRef>(exception), OpaqueJSString::create("name"_s).get(), nullptr); >+ auto exceptionName = adoptRef(JSValueToStringCopy(context, nameValue, nullptr))->string(); >+ if (exceptionName == "NodeNotFound") > errorType = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::NodeNotFound); >- else if (exceptionName->string() == "InvalidElementState") >+ else if (exceptionName == "InvalidElementState") > errorType = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::InvalidElementState); >- else if (exceptionName->string() == "InvalidParameter") >+ else if (exceptionName == "InvalidParameter") > errorType = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::InvalidParameter); >- else if (exceptionName->string() == "InvalidSelector") >+ else if (exceptionName == "InvalidSelector") > 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)); >+ JSValueRef messageValue = JSObjectGetProperty(context, const_cast<JSObjectRef>(exception), OpaqueJSString::create("message"_s).get(), nullptr); >+ exceptionMessage = adoptRef(JSValueToStringCopy(context, messageValue, nullptr))->string(); > } else >- exceptionMessage = adopt(JSValueToStringCopy(context, exception, nullptr)); >+ exceptionMessage = adoptRef(JSValueToStringCopy(context, exception, nullptr))->string(); > >- didEvaluateJavaScriptFunction(frameID, callbackID, exceptionMessage->string(), errorType); >+ didEvaluateJavaScriptFunction(frameID, callbackID, exceptionMessage, errorType); > } > > void WebAutomationSessionProxy::didEvaluateJavaScriptFunction(uint64_t frameID, uint64_t callbackID, const String& result, const String& errorType) >diff --git a/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm b/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm >index da041072a3d60ccb61aa80a1c4c32b24d8962950..71b8cf83343c6cf852a0d0972838dffad2706c8a 100644 >--- a/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm >+++ b/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm >@@ -48,8 +48,6 @@ > #import "WebProcess.h" > #import <JavaScriptCore/JSContextRef.h> > #import <JavaScriptCore/JSObjectRef.h> >-#import <JavaScriptCore/JSStringRef.h> >-#import <JavaScriptCore/JSStringRefCF.h> > #import <PDFKit/PDFKit.h> > #import <QuartzCore/QuartzCore.h> > #import <WebCore/AXObjectCache.h> >@@ -1096,19 +1094,13 @@ void PDFPlugin::runScriptsInPDFDocument() > Vector<RetainPtr<CFStringRef>> scripts; > getAllScriptsInPDFDocument([m_pdfDocument documentRef], scripts); > >- size_t scriptCount = scripts.size(); >- if (!scriptCount) >+ if (scripts.isEmpty()) > return; > > JSGlobalContextRef ctx = JSGlobalContextCreate(0); > JSObjectRef jsPDFDoc = makeJSPDFDoc(ctx); >- >- for (size_t i = 0; i < scriptCount; ++i) { >- JSStringRef script = JSStringCreateWithCFString(scripts[i].get()); >- JSEvaluateScript(ctx, script, jsPDFDoc, 0, 0, 0); >- JSStringRelease(script); >- } >- >+ for (auto& script : scripts) >+ JSEvaluateScript(ctx, OpaqueJSString::create(script.get()).get(), jsPDFDoc, nullptr, 0, nullptr); > JSGlobalContextRelease(ctx); > } > >diff --git a/Source/WebKitLegacy/ios/WebView/WebPDFViewIOS.mm b/Source/WebKitLegacy/ios/WebView/WebPDFViewIOS.mm >index ec1a8ec65679b8bfc626064fa2f1bbff085533e2..1841b985c850caf04374aa813a2050bdf00457a7 100644 >--- a/Source/WebKitLegacy/ios/WebView/WebPDFViewIOS.mm >+++ b/Source/WebKitLegacy/ios/WebView/WebPDFViewIOS.mm >@@ -34,8 +34,7 @@ > #import "WebPDFDocumentExtras.h" > #import "WebPDFViewPlaceholder.h" > #import <JavaScriptCore/JSContextRef.h> >-#import <JavaScriptCore/JSStringRef.h> >-#import <JavaScriptCore/JSStringRefCF.h> >+#import <JavaScriptCore/OpaqueJSString.h> > #import <WebCore/Color.h> > #import <WebCore/Frame.h> > #import <WebCore/FrameLoader.h> >@@ -321,19 +320,13 @@ - (void)finishedLoadingWithDataSource:(WebDataSource *)dataSource > > NSArray *scripts = allScriptsInPDFDocument(_PDFDocument); > >- NSUInteger scriptCount = [scripts count]; >- if (!scriptCount) >+ if (![scripts count]) > return; > > JSGlobalContextRef ctx = JSGlobalContextCreate(0); > JSObjectRef jsPDFDoc = makeJSPDFDoc(ctx, dataSource); >- >- for (NSUInteger i = 0; i < scriptCount; ++i) { >- JSStringRef script = JSStringCreateWithCFString((CFStringRef)[scripts objectAtIndex:i]); >- JSEvaluateScript(ctx, script, jsPDFDoc, 0, 0, 0); >- JSStringRelease(script); >- } >- >+ for (NSString *script in scripts) >+ JSEvaluateScript(ctx, OpaqueJSString::create(script).get(), jsPDFDoc, nullptr, 0, nullptr); > JSGlobalContextRelease(ctx); > > [self setNeedsDisplay:YES]; >diff --git a/Source/WebKitLegacy/ios/WebView/WebPDFViewPlaceholder.mm b/Source/WebKitLegacy/ios/WebView/WebPDFViewPlaceholder.mm >index bf68f3a504bc5065c3a498da340ab666f03e300c..93b1566aa2eccfd0450be4098631269d382fe5d4 100644 >--- a/Source/WebKitLegacy/ios/WebView/WebPDFViewPlaceholder.mm >+++ b/Source/WebKitLegacy/ios/WebView/WebPDFViewPlaceholder.mm >@@ -30,8 +30,6 @@ > #import "WebFrameInternal.h" > #import "WebPDFViewIOS.h" > #import <JavaScriptCore/JSContextRef.h> >-#import <JavaScriptCore/JSStringRef.h> >-#import <JavaScriptCore/JSStringRefCF.h> > #import <WebCore/DataTransfer.h> > #import <WebCore/EventHandler.h> > #import <WebCore/EventNames.h> >@@ -309,18 +307,11 @@ - (void)_evaluateJSForDocument:(CGPDFDocumentRef)pdfDocument > > NSArray *scripts = allScriptsInPDFDocument(pdfDocument); > >- NSUInteger scriptCount = [scripts count]; >- if (scriptCount) { >- >+ if ([scripts count]) { > JSGlobalContextRef ctx = JSGlobalContextCreate(0); > JSObjectRef jsPDFDoc = makeJSPDFDoc(ctx, _dataSource); >- >- for (NSUInteger i = 0; i < scriptCount; ++i) { >- JSStringRef script = JSStringCreateWithCFString((CFStringRef)[scripts objectAtIndex:i]); >- JSEvaluateScript(ctx, script, jsPDFDoc, 0, 0, 0); >- JSStringRelease(script); >- } >- >+ for (NSString *script in scripts) >+ JSEvaluateScript(ctx, OpaqueJSString::create(script).get(), jsPDFDoc, nullptr, 0, nullptr); > JSGlobalContextRelease(ctx); > } > } >diff --git a/Source/WebKitLegacy/mac/WebView/WebPDFRepresentation.mm b/Source/WebKitLegacy/mac/WebView/WebPDFRepresentation.mm >index 79db38a6660bad06b8825bb53cb04d2df6f56408..aadfed218fcef4b12fb89aa777a194f5fd27a045 100644 >--- a/Source/WebKitLegacy/mac/WebView/WebPDFRepresentation.mm >+++ b/Source/WebKitLegacy/mac/WebView/WebPDFRepresentation.mm >@@ -37,8 +37,7 @@ > #import "WebPDFView.h" > #import "WebTypesInternal.h" > #import <JavaScriptCore/JSContextRef.h> >-#import <JavaScriptCore/JSStringRef.h> >-#import <JavaScriptCore/JSStringRefCF.h> >+#import <JavaScriptCore/OpaqueJSString.h> > #import <wtf/Assertions.h> > #import <wtf/ObjcRuntimeExtras.h> > #import <wtf/RetainPtr.h> >@@ -129,19 +128,13 @@ - (void)finishedLoadingWithDataSource:(WebDataSource *)dataSource > [doc release]; > doc = nil; > >- NSUInteger scriptCount = [scripts count]; >- if (!scriptCount) >+ if (![scripts count]) > return; > > JSGlobalContextRef ctx = JSGlobalContextCreate(0); > JSObjectRef jsPDFDoc = makeJSPDFDoc(ctx, dataSource); >- >- for (NSUInteger i = 0; i < scriptCount; ++i) { >- JSStringRef script = JSStringCreateWithCFString((CFStringRef)[scripts objectAtIndex:i]); >- JSEvaluateScript(ctx, script, jsPDFDoc, 0, 0, 0); >- JSStringRelease(script); >- } >- >+ for (NSString *script in scripts) >+ JSEvaluateScript(ctx, OpaqueJSString::create(script).get(), jsPDFDoc, nullptr, 0, nullptr); > JSGlobalContextRelease(ctx); > } >
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 189652
: 349873