Title: [129743] trunk/Source/WebKit2
Revision
129743
Author
[email protected]
Date
2012-09-27 02:32:32 -0700 (Thu, 27 Sep 2012)

Log Message

[WK2] Injected bundle API implementation should use toWTFString()
https://bugs.webkit.org/show_bug.cgi?id=97766

Patch by Mikhail Pozdnyakov <[email protected]> on 2012-09-27
Reviewed by Kenneth Rohde Christiansen.

Injected bundle API implementation should call toWTFString() rather than convert
WKStringRef and WKURLRef to their impls and then call string() method directly.
The rational for that are both safety (toWTFString checks the given pointer) and
code readability.

* WebProcess/InjectedBundle/API/c/WKBundle.cpp:
(WKBundlePostMessage):
(WKBundlePostSynchronousMessage):
(WKBundleOverrideBoolPreferenceForTestRunner):
(WKBundleAddOriginAccessWhitelistEntry):
(WKBundleRemoveOriginAccessWhitelistEntry):
(WKBundleClearApplicationCacheForOrigin):
(WKBundleGetAppCacheUsageForOrigin):
(WKBundleSetApplicationCacheOriginQuota):
(WKBundleResetApplicationCacheOriginQuota):
(WKBundlePageNumberForElementById):
(WKBundleSetUserStyleSheetLocation):
(WKBundleSetWebNotificationPermission):
* WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp:
(WKBundleFramePauseAnimationOnElementWithId):
(WKBundleFramePauseTransitionOnElementWithId):
(WKBundleFrameAllowsFollowingLink):
(WKBundleFrameCopySuggestedFilenameForResourceWithURL):
(WKBundleFrameCopyMIMETypeForResourceWithURL):
(WKBundleFrameSetTextDirection):
* WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp:
(WKBundleInspectorEvaluateScriptForTest):
* WebProcess/InjectedBundle/API/c/WKBundleIntent.cpp:
(WKBundleIntentCreate):
* WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
(WKBundlePageExecuteEditingCommand):
(WKBundlePageIsEditingCommandEnabled):
(WKBundlePageHasLocalDataForURL):
(WKBundlePageFindString):
(WKBundlePageSetComposition):
(WKBundlePageConfirmCompositionWithText):
(WKBundlePageCanShowMIMEType):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (129742 => 129743)


--- trunk/Source/WebKit2/ChangeLog	2012-09-27 09:24:59 UTC (rev 129742)
+++ trunk/Source/WebKit2/ChangeLog	2012-09-27 09:32:32 UTC (rev 129743)
@@ -1,3 +1,48 @@
+2012-09-27  Mikhail Pozdnyakov  <[email protected]>
+
+        [WK2] Injected bundle API implementation should use toWTFString()
+        https://bugs.webkit.org/show_bug.cgi?id=97766
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Injected bundle API implementation should call toWTFString() rather than convert
+        WKStringRef and WKURLRef to their impls and then call string() method directly.
+        The rational for that are both safety (toWTFString checks the given pointer) and
+        code readability.
+
+        * WebProcess/InjectedBundle/API/c/WKBundle.cpp:
+        (WKBundlePostMessage):
+        (WKBundlePostSynchronousMessage):
+        (WKBundleOverrideBoolPreferenceForTestRunner):
+        (WKBundleAddOriginAccessWhitelistEntry):
+        (WKBundleRemoveOriginAccessWhitelistEntry):
+        (WKBundleClearApplicationCacheForOrigin):
+        (WKBundleGetAppCacheUsageForOrigin):
+        (WKBundleSetApplicationCacheOriginQuota):
+        (WKBundleResetApplicationCacheOriginQuota):
+        (WKBundlePageNumberForElementById):
+        (WKBundleSetUserStyleSheetLocation):
+        (WKBundleSetWebNotificationPermission):
+        * WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp:
+        (WKBundleFramePauseAnimationOnElementWithId):
+        (WKBundleFramePauseTransitionOnElementWithId):
+        (WKBundleFrameAllowsFollowingLink):
+        (WKBundleFrameCopySuggestedFilenameForResourceWithURL):
+        (WKBundleFrameCopyMIMETypeForResourceWithURL):
+        (WKBundleFrameSetTextDirection):
+        * WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp:
+        (WKBundleInspectorEvaluateScriptForTest):
+        * WebProcess/InjectedBundle/API/c/WKBundleIntent.cpp:
+        (WKBundleIntentCreate):
+        * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
+        (WKBundlePageExecuteEditingCommand):
+        (WKBundlePageIsEditingCommandEnabled):
+        (WKBundlePageHasLocalDataForURL):
+        (WKBundlePageFindString):
+        (WKBundlePageSetComposition):
+        (WKBundlePageConfirmCompositionWithText):
+        (WKBundlePageCanShowMIMEType):
+
 2012-09-27  Mario Sanchez Prada  <[email protected]>
 
         [WK2] IconDatabase: Add a way to notify when icon data is available

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp (129742 => 129743)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp	2012-09-27 09:24:59 UTC (rev 129742)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp	2012-09-27 09:32:32 UTC (rev 129743)
@@ -46,13 +46,13 @@
 
 void WKBundlePostMessage(WKBundleRef bundleRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef)
 {
-    toImpl(bundleRef)->postMessage(toImpl(messageNameRef)->string(), toImpl(messageBodyRef));
+    toImpl(bundleRef)->postMessage(toWTFString(messageNameRef), toImpl(messageBodyRef));
 }
 
 void WKBundlePostSynchronousMessage(WKBundleRef bundleRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef, WKTypeRef* returnDataRef)
 {
     RefPtr<APIObject> returnData;
-    toImpl(bundleRef)->postSynchronousMessage(toImpl(messageNameRef)->string(), toImpl(messageBodyRef), returnData);
+    toImpl(bundleRef)->postSynchronousMessage(toWTFString(messageNameRef), toImpl(messageBodyRef), returnData);
     if (returnDataRef)
         *returnDataRef = toAPI(returnData.release().leakRef());
 }
@@ -134,7 +134,7 @@
 
 void WKBundleOverrideBoolPreferenceForTestRunner(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, WKStringRef preference, bool enabled)
 {
-    toImpl(bundleRef)->overrideBoolPreferenceForTestRunner(toImpl(pageGroupRef), toImpl(preference)->string(), enabled);
+    toImpl(bundleRef)->overrideBoolPreferenceForTestRunner(toImpl(pageGroupRef), toWTFString(preference), enabled);
 }
 
 void WKBundleSetAllowUniversalAccessFromFileURLs(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, bool enabled)
@@ -194,12 +194,12 @@
 
 void WKBundleAddOriginAccessWhitelistEntry(WKBundleRef bundleRef, WKStringRef sourceOrigin, WKStringRef destinationProtocol, WKStringRef destinationHost, bool allowDestinationSubdomains)
 {
-    toImpl(bundleRef)->addOriginAccessWhitelistEntry(toImpl(sourceOrigin)->string(), toImpl(destinationProtocol)->string(), toImpl(destinationHost)->string(), allowDestinationSubdomains);
+    toImpl(bundleRef)->addOriginAccessWhitelistEntry(toWTFString(sourceOrigin), toWTFString(destinationProtocol), toWTFString(destinationHost), allowDestinationSubdomains);
 }
 
 void WKBundleRemoveOriginAccessWhitelistEntry(WKBundleRef bundleRef, WKStringRef sourceOrigin, WKStringRef destinationProtocol, WKStringRef destinationHost, bool allowDestinationSubdomains)
 {
-    toImpl(bundleRef)->removeOriginAccessWhitelistEntry(toImpl(sourceOrigin)->string(), toImpl(destinationProtocol)->string(), toImpl(destinationHost)->string(), allowDestinationSubdomains);
+    toImpl(bundleRef)->removeOriginAccessWhitelistEntry(toWTFString(sourceOrigin), toWTFString(destinationProtocol), toWTFString(destinationHost), allowDestinationSubdomains);
 }
 
 void WKBundleResetOriginAccessWhitelists(WKBundleRef bundleRef)
@@ -229,7 +229,7 @@
 
 void WKBundleClearApplicationCacheForOrigin(WKBundleRef bundleRef, WKStringRef origin)
 {
-    toImpl(bundleRef)->clearApplicationCacheForOrigin(toImpl(origin)->string());
+    toImpl(bundleRef)->clearApplicationCacheForOrigin(toWTFString(origin));
 }
 
 void WKBundleSetAppCacheMaximumSize(WKBundleRef bundleRef, uint64_t size)
@@ -239,17 +239,17 @@
 
 uint64_t WKBundleGetAppCacheUsageForOrigin(WKBundleRef bundleRef, WKStringRef origin)
 {
-    return toImpl(bundleRef)->appCacheUsageForOrigin(toImpl(origin)->string());
+    return toImpl(bundleRef)->appCacheUsageForOrigin(toWTFString(origin));
 }
 
 void WKBundleSetApplicationCacheOriginQuota(WKBundleRef bundleRef, WKStringRef origin, uint64_t bytes)
 {
-    toImpl(bundleRef)->setApplicationCacheOriginQuota(toImpl(origin)->string(), bytes);
+    toImpl(bundleRef)->setApplicationCacheOriginQuota(toWTFString(origin), bytes);
 }
 
 void WKBundleResetApplicationCacheOriginQuota(WKBundleRef bundleRef, WKStringRef origin)
 {
-    toImpl(bundleRef)->resetApplicationCacheOriginQuota(toImpl(origin)->string());
+    toImpl(bundleRef)->resetApplicationCacheOriginQuota(toWTFString(origin));
 }
 
 WKArrayRef WKBundleCopyOriginsWithApplicationCache(WKBundleRef bundleRef)
@@ -270,7 +270,7 @@
 
 int WKBundlePageNumberForElementById(WKBundleRef bundleRef, WKBundleFrameRef frameRef, WKStringRef idRef, double pageWidthInPixels, double pageHeightInPixels)
 {
-    return toImpl(bundleRef)->pageNumberForElementById(toImpl(frameRef), toImpl(idRef)->string(), pageWidthInPixels, pageHeightInPixels);
+    return toImpl(bundleRef)->pageNumberForElementById(toImpl(frameRef), toWTFString(idRef), pageWidthInPixels, pageHeightInPixels);
 }
 
 WKStringRef WKBundlePageSizeAndMarginsInPixels(WKBundleRef bundleRef, WKBundleFrameRef frameRef, int pageIndex, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft)
@@ -301,12 +301,12 @@
 
 void WKBundleSetUserStyleSheetLocation(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, WKStringRef location)
 {
-    toImpl(bundleRef)->setUserStyleSheetLocation(toImpl(pageGroupRef), toImpl(location)->string());
+    toImpl(bundleRef)->setUserStyleSheetLocation(toImpl(pageGroupRef), toWTFString(location));
 }
 
 void WKBundleSetWebNotificationPermission(WKBundleRef bundleRef, WKBundlePageRef pageRef, WKStringRef originStringRef, bool allowed)
 {
-    toImpl(bundleRef)->setWebNotificationPermission(toImpl(pageRef), toImpl(originStringRef)->string(), allowed);
+    toImpl(bundleRef)->setWebNotificationPermission(toImpl(pageRef), toWTFString(originStringRef), allowed);
 }
 
 void WKBundleRemoveAllWebNotificationPermissions(WKBundleRef bundleRef, WKBundlePageRef pageRef)

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp (129742 => 129743)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp	2012-09-27 09:24:59 UTC (rev 129742)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp	2012-09-27 09:32:32 UTC (rev 129743)
@@ -97,12 +97,12 @@
 
 bool WKBundleFramePauseAnimationOnElementWithId(WKBundleFrameRef frameRef, WKStringRef animationName, WKStringRef elementID, double time)
 {
-    return toImpl(frameRef)->pauseAnimationOnElementWithId(toImpl(animationName)->string(), toImpl(elementID)->string(), time);
+    return toImpl(frameRef)->pauseAnimationOnElementWithId(toWTFString(animationName), toWTFString(elementID), time);
 }
 
 bool WKBundleFramePauseTransitionOnElementWithId(WKBundleFrameRef frameRef, WKStringRef propertyName, WKStringRef elementID, double time)
 {
-    return toImpl(frameRef)->pauseTransitionOnElementWithId(toImpl(propertyName)->string(), toImpl(elementID)->string(), time);
+    return toImpl(frameRef)->pauseTransitionOnElementWithId(toWTFString(propertyName), toWTFString(elementID), time);
 }
 
 void WKBundleFrameSuspendAnimations(WKBundleFrameRef frameRef)
@@ -194,7 +194,7 @@
 
 bool WKBundleFrameAllowsFollowingLink(WKBundleFrameRef frameRef, WKURLRef urlRef)
 {
-    return toImpl(frameRef)->allowsFollowingLink(WebCore::KURL(WebCore::KURL(), toImpl(urlRef)->string()));
+    return toImpl(frameRef)->allowsFollowingLink(WebCore::KURL(WebCore::KURL(), toWTFString(urlRef)));
 }
 
 WKRect WKBundleFrameGetContentBounds(WKBundleFrameRef frameRef)
@@ -234,12 +234,12 @@
 
 WKStringRef WKBundleFrameCopySuggestedFilenameForResourceWithURL(WKBundleFrameRef frameRef, WKURLRef urlRef)
 {
-    return toCopiedAPI(toImpl(frameRef)->suggestedFilenameForResourceWithURL(WebCore::KURL(WebCore::KURL(), toImpl(urlRef)->string())));
+    return toCopiedAPI(toImpl(frameRef)->suggestedFilenameForResourceWithURL(WebCore::KURL(WebCore::KURL(), toWTFString(urlRef))));
 }
 
 WKStringRef WKBundleFrameCopyMIMETypeForResourceWithURL(WKBundleFrameRef frameRef, WKURLRef urlRef)
 {
-    return toCopiedAPI(toImpl(frameRef)->mimeTypeForResourceWithURL(WebCore::KURL(WebCore::KURL(), toImpl(urlRef)->string())));
+    return toCopiedAPI(toImpl(frameRef)->mimeTypeForResourceWithURL(WebCore::KURL(WebCore::KURL(), toWTFString(urlRef))));
 }
 
 bool WKBundleFrameContainsAnyFormElements(WKBundleFrameRef frameRef)
@@ -249,7 +249,7 @@
 
 void WKBundleFrameSetTextDirection(WKBundleFrameRef frameRef, WKStringRef directionRef)
 {
-    toImpl(frameRef)->setTextDirection(toImpl(directionRef)->string());
+    toImpl(frameRef)->setTextDirection(toWTFString(directionRef));
 }
 
 WKDataRef WKBundleFrameCopyWebArchive(WKBundleFrameRef frameRef)

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp (129742 => 129743)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp	2012-09-27 09:24:59 UTC (rev 129742)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp	2012-09-27 09:32:32 UTC (rev 129743)
@@ -52,7 +52,7 @@
 
 void WKBundleInspectorEvaluateScriptForTest(WKBundleInspectorRef inspectorRef, long callID, WKStringRef script)
 {
-    return toImpl(inspectorRef)->evaluateScriptForTest(callID, toImpl(script)->string());
+    return toImpl(inspectorRef)->evaluateScriptForTest(callID, toWTFString(script));
 }
 
 void WKBundleInspectorSetPageProfilingEnabled(WKBundleInspectorRef inspectorRef, bool enabled)

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntent.cpp (129742 => 129743)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntent.cpp	2012-09-27 09:24:59 UTC (rev 129742)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntent.cpp	2012-09-27 09:32:32 UTC (rev 129743)
@@ -64,7 +64,7 @@
     MessagePortArray dummyPorts;
     ExceptionCode ec;
 
-    RefPtr<Intent> coreIntent = Intent::create(toImpl(action)->string(), toImpl(type)->string(), data ? static_cast<SerializedScriptValue*>(toImpl(data)->internalRepresentation()) : 0, dummyPorts, ec);
+    RefPtr<Intent> coreIntent = Intent::create(toWTFString(action), toWTFString(type), data ? static_cast<SerializedScriptValue*>(toImpl(data)->internalRepresentation()) : 0, dummyPorts, ec);
 
     return toAPI(InjectedBundleIntent::create(coreIntent.get()).leakRef());
 #else

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp (129742 => 129743)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp	2012-09-27 09:24:59 UTC (rev 129742)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp	2012-09-27 09:32:32 UTC (rev 129743)
@@ -212,12 +212,12 @@
 
 void WKBundlePageExecuteEditingCommand(WKBundlePageRef pageRef, WKStringRef name, WKStringRef argument)
 {
-    toImpl(pageRef)->executeEditingCommand(toImpl(name)->string(), toImpl(argument)->string());
+    toImpl(pageRef)->executeEditingCommand(toWTFString(name), toWTFString(argument));
 }
 
 bool WKBundlePageIsEditingCommandEnabled(WKBundlePageRef pageRef, WKStringRef name)
 {
-    return toImpl(pageRef)->isEditingCommandEnabled(toImpl(name)->string());
+    return toImpl(pageRef)->isEditingCommandEnabled(toWTFString(name));
 }
 
 void WKBundlePageClearMainFrameName(WKBundlePageRef pageRef)
@@ -277,7 +277,7 @@
 
 bool WKBundlePageHasLocalDataForURL(WKBundlePageRef pageRef, WKURLRef urlRef)
 {
-    return toImpl(pageRef)->hasLocalDataForURL(WebCore::KURL(WebCore::KURL(), toImpl(urlRef)->string()));
+    return toImpl(pageRef)->hasLocalDataForURL(WebCore::KURL(WebCore::KURL(), toWTFString(urlRef)));
 }
 
 bool WKBundlePageCanHandleRequest(WKURLRequestRef requestRef)
@@ -287,7 +287,7 @@
 
 bool WKBundlePageFindString(WKBundlePageRef pageRef, WKStringRef target, WKFindOptions findOptions)
 {
-    return toImpl(pageRef)->findStringFromInjectedBundle(toImpl(target)->string(), toFindOptions(findOptions));
+    return toImpl(pageRef)->findStringFromInjectedBundle(toWTFString(target), toFindOptions(findOptions));
 }
 
 WKImageRef WKBundlePageCreateSnapshotWithOptions(WKBundlePageRef pageRef, WKRect rect, WKSnapshotOptions options)
@@ -403,7 +403,7 @@
 
 void WKBundlePageSetComposition(WKBundlePageRef pageRef, WKStringRef text, int from, int length)
 {
-    toImpl(pageRef)->setCompositionForTesting(toImpl(text)->string(), from, length);
+    toImpl(pageRef)->setCompositionForTesting(toWTFString(text), from, length);
 }
 
 bool WKBundlePageHasComposition(WKBundlePageRef pageRef)
@@ -418,14 +418,14 @@
 
 void WKBundlePageConfirmCompositionWithText(WKBundlePageRef pageRef, WKStringRef text)
 {
-    toImpl(pageRef)->confirmCompositionForTesting(toImpl(text)->string());
+    toImpl(pageRef)->confirmCompositionForTesting(toWTFString(text));
 }
 
 bool WKBundlePageCanShowMIMEType(WKBundlePageRef, WKStringRef mimeTypeRef)
 {
     using WebCore::MIMETypeRegistry;
 
-    const WTF::String mimeType = toImpl(mimeTypeRef)->string();
+    const String mimeType = toWTFString(mimeTypeRef);
 
     if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType))
         return true;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to