Use OpaqueJSString rather than JSRetainPtr inside WebKit
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Sep 2018 16:54:55 +0000 (16:54 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Sep 2018 16:54:55 +0000 (16:54 +0000)
commit082d43c4fce4a99dc35f3153e2ebd406acada4cd
tree74515775eb8eb848b3b084da4dd27393c0238d51
parente019732154aac9a1b9c8d57e116ea1a629d4fc35
Use OpaqueJSString rather than JSRetainPtr inside WebKit
https://bugs.webkit.org/show_bug.cgi?id=189652

Reviewed by Saam Barati.

Source/JavaScriptCore:

* 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.

Source/WebCore:

* Modules/plugins/QuickTimePluginReplacement.mm:
(WebCore::jsValueWithDictionaryInContext): Use OpaqueJSString::create.
(WebCore::jsValueWithAVMetadataItemInContext): Use adoptCF.

* platform/mac/SerializedPlatformRepresentationMac.mm:
(WebCore::jsValueWithDictionaryInContext): Use OpaqueJSString::create.

Source/WebKit:

* 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.

Source/WebKitLegacy/ios:

* WebView/WebPDFViewIOS.mm:
(-[WebPDFView finishedLoadingWithDataSource:]): Use OpaqueJSString::create.
* WebView/WebPDFViewPlaceholder.mm:
(-[WebPDFViewPlaceholder _evaluateJSForDocument:]): Ditto.

Source/WebKitLegacy/mac:

* WebView/WebPDFRepresentation.mm:
(-[WebPDFRepresentation finishedLoadingWithDataSource:]): Use OpaqueJSString::create.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236066 268f45cc-cd09-0410-ab3c-d52691b4dbfc
17 files changed:
Source/JavaScriptCore/API/JSCallbackObjectFunctions.h
Source/JavaScriptCore/API/JSContext.mm
Source/JavaScriptCore/API/JSStringRef.cpp
Source/JavaScriptCore/API/JSValue.mm
Source/JavaScriptCore/ChangeLog
Source/WebCore/ChangeLog
Source/WebCore/Modules/plugins/QuickTimePluginReplacement.mm
Source/WebCore/platform/mac/SerializedPlatformRepresentationMac.mm
Source/WebKit/ChangeLog
Source/WebKit/Shared/API/c/WKString.cpp
Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp
Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm
Source/WebKitLegacy/ios/ChangeLog
Source/WebKitLegacy/ios/WebView/WebPDFViewIOS.mm
Source/WebKitLegacy/ios/WebView/WebPDFViewPlaceholder.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebView/WebPDFRepresentation.mm