Diff
Modified: trunk/Source/WebKit2/ChangeLog (142793 => 142794)
--- trunk/Source/WebKit2/ChangeLog 2013-02-13 21:55:24 UTC (rev 142793)
+++ trunk/Source/WebKit2/ChangeLog 2013-02-13 21:56:00 UTC (rev 142794)
@@ -1,3 +1,35 @@
+2013-02-13 Christophe Dumez <[email protected]>
+
+ [EFL][WK2] Stop using WebString in ewk_cookie_manager, ewk_form_submission_request and ewk_text_checker
+ https://bugs.webkit.org/show_bug.cgi?id=108794
+
+ Reviewed by Alexey Proskuryakov.
+
+ Stop using WebString in ewk_cookie_manager, ewk_form_submission_request
+ and ewk_text_checker as it is internal C++ API. WKString and
+ WKEinaSharedString are used instead.
+
+ * UIProcess/API/cpp/efl/WKEinaSharedString.cpp:
+ (WKEinaSharedString::leakString): Add leakString() method to
+ WKEinaSharedString so that we can conveniently convert a WKString to a
+ Eina shared string and take ownership of it.
+ * UIProcess/API/cpp/efl/WKEinaSharedString.h:
+ * UIProcess/API/efl/ewk_cookie_manager.cpp:
+ (getHostnamesWithCookiesCallback):
+ * UIProcess/API/efl/ewk_form_submission_request.cpp:
+ (EwkFormSubmissionRequest::copyFieldValue):
+ (ewk_form_submission_request_field_names_get):
+ (ewk_form_submission_request_field_value_get):
+ * UIProcess/API/efl/ewk_form_submission_request_private.h:
+ (EwkFormSubmissionRequest):
+ * UIProcess/API/efl/ewk_text_checker.cpp:
+ (checkSpellingOfString):
+ (guessesForWord):
+ (learnWord):
+ (ignoreWord):
+ * UIProcess/API/efl/tests/test_ewk2_eina_shared_string.cpp:
+ (TEST_F): Add API test for new WKEinaSharedString::leakString() method.
+
2013-02-13 Anders Carlsson <[email protected]>
Remove Connection::QueueClient
Modified: trunk/Source/WebKit2/UIProcess/API/cpp/efl/WKEinaSharedString.cpp (142793 => 142794)
--- trunk/Source/WebKit2/UIProcess/API/cpp/efl/WKEinaSharedString.cpp 2013-02-13 21:55:24 UTC (rev 142793)
+++ trunk/Source/WebKit2/UIProcess/API/cpp/efl/WKEinaSharedString.cpp 2013-02-13 21:56:00 UTC (rev 142794)
@@ -112,3 +112,11 @@
sharedString.m_string = static_cast<const char*>(string);
return sharedString;
}
+
+Eina_Stringshare* WKEinaSharedString::leakString()
+{
+ Eina_Stringshare* sharedString = m_string;
+ m_string = 0;
+
+ return sharedString;
+}
Modified: trunk/Source/WebKit2/UIProcess/API/cpp/efl/WKEinaSharedString.h (142793 => 142794)
--- trunk/Source/WebKit2/UIProcess/API/cpp/efl/WKEinaSharedString.h 2013-02-13 21:55:24 UTC (rev 142793)
+++ trunk/Source/WebKit2/UIProcess/API/cpp/efl/WKEinaSharedString.h 2013-02-13 21:56:00 UTC (rev 142794)
@@ -46,6 +46,8 @@
~WKEinaSharedString();
+ Eina_Stringshare* leakString();
+
WKEinaSharedString& operator=(const WKEinaSharedString& other);
WKEinaSharedString& operator=(const char* str);
Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.cpp (142793 => 142794)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.cpp 2013-02-13 21:55:24 UTC (rev 142793)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.cpp 2013-02-13 21:56:00 UTC (rev 142794)
@@ -34,8 +34,6 @@
#include "ewk_error_private.h"
#include "ewk_private.h"
#include <wtf/OwnPtr.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/WTFString.h>
using namespace WebKit;
@@ -194,10 +192,9 @@
const size_t hostnameCount = WKArrayGetSize(wkHostnames);
for (size_t i = 0; i < hostnameCount; ++i) {
WKStringRef wkHostname = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkHostnames, i));
- String hostname = toImpl(wkHostname)->string();
- if (hostname.isEmpty())
+ if (WKStringIsEmpty(wkHostname))
continue;
- hostnames = eina_list_append(hostnames, eina_stringshare_add(hostname.utf8().data()));
+ hostnames = eina_list_append(hostnames, WKEinaSharedString(wkHostname).leakString());
}
callbackData->callback(hostnames, ewkError.get(), callbackData->userData);
Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request.cpp (142793 => 142794)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request.cpp 2013-02-13 21:55:24 UTC (rev 142793)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request.cpp 2013-02-13 21:56:00 UTC (rev 142794)
@@ -31,7 +31,6 @@
#include "WKBase.h"
#include "WKString.h"
#include "ewk_form_submission_request_private.h"
-#include <wtf/text/CString.h>
using namespace WebKit;
@@ -48,13 +47,13 @@
WKFormSubmissionListenerContinue(m_wkListener.get());
}
-String EwkFormSubmissionRequest::fieldValue(const String& fieldName) const
+Eina_Stringshare* EwkFormSubmissionRequest::copyFieldValue(const char* fieldName) const
{
ASSERT(fieldName);
- WKRetainPtr<WKStringRef> wkFieldName = adoptWK(toCopiedAPI(fieldName));
+ WKRetainPtr<WKStringRef> wkFieldName = adoptWK(WKStringCreateWithUTF8CString(fieldName));
WKStringRef wkValue = static_cast<WKStringRef>(WKDictionaryGetItemForKey(m_wkValues.get(), wkFieldName.get()));
- return wkValue ? toImpl(wkValue)->string() : String();
+ return WKEinaSharedString(wkValue).leakString();
}
WKRetainPtr<WKArrayRef> EwkFormSubmissionRequest::fieldNames() const
@@ -72,16 +71,16 @@
{
EWK_OBJ_GET_IMPL_OR_RETURN(EwkFormSubmissionRequest, request, impl, 0);
- Eina_List* names = 0;
+ Eina_List* fieldNames = 0;
- WKRetainPtr<WKArrayRef> wkKeys = impl->fieldNames();
- const size_t numKeys = WKArrayGetSize(wkKeys.get());
+ WKRetainPtr<WKArrayRef> wkFieldNames = impl->fieldNames();
+ const size_t numKeys = WKArrayGetSize(wkFieldNames.get());
for (size_t i = 0; i < numKeys; ++i) {
- WKStringRef wkKey = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkKeys.get(), i));
- names = eina_list_append(names, eina_stringshare_add(toImpl(wkKey)->string().utf8().data()));
+ WKStringRef wkFieldName = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkFieldNames.get(), i));
+ fieldNames = eina_list_append(fieldNames, WKEinaSharedString(wkFieldName).leakString());
}
- return names;
+ return fieldNames;
}
const char* ewk_form_submission_request_field_value_get(Ewk_Form_Submission_Request* request, const char* name)
@@ -89,9 +88,7 @@
EWK_OBJ_GET_IMPL_OR_RETURN(EwkFormSubmissionRequest, request, impl, 0);
EINA_SAFETY_ON_NULL_RETURN_VAL(name, 0);
- String value = impl->fieldValue(String::fromUTF8(name));
-
- return value.isNull() ? 0 : eina_stringshare_add(value.utf8().data());
+ return impl->copyFieldValue(name);
}
Eina_Bool ewk_form_submission_request_submit(Ewk_Form_Submission_Request* request)
Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request_private.h (142793 => 142794)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request_private.h 2013-02-13 21:55:24 UTC (rev 142793)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request_private.h 2013-02-13 21:56:00 UTC (rev 142794)
@@ -27,11 +27,11 @@
#define ewk_form_submission_request_private_h
#include "WKDictionary.h"
+#include "WKEinaSharedString.h"
#include "WKFormSubmissionListener.h"
#include "WKRetainPtr.h"
#include "ewk_object_private.h"
#include <wtf/PassRefPtr.h>
-#include <wtf/text/WTFString.h>
class EwkFormSubmissionRequest : public EwkObject {
public:
@@ -45,7 +45,7 @@
}
WKRetainPtr<WKArrayRef> fieldNames() const;
- String fieldValue(const String& fieldName) const;
+ Eina_Stringshare* copyFieldValue(const char* fieldName) const;
void submit();
Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_text_checker.cpp (142793 => 142794)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_text_checker.cpp 2013-02-13 21:55:24 UTC (rev 142793)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_text_checker.cpp 2013-02-13 21:56:00 UTC (rev 142794)
@@ -31,17 +31,16 @@
#include "TextCheckerEnchant.h"
#include "WKAPICast.h"
+#include "WKEinaSharedString.h"
#include "WKMutableArray.h"
#include "WKRetainPtr.h"
#include "WKString.h"
#include "WKTextChecker.h"
#include "WebPageProxy.h"
-#include "WebString.h"
#include "ewk_settings.h"
#include "ewk_text_checker_private.h"
#include <Eina.h>
#include <wtf/OwnPtr.h>
-#include <wtf/text/CString.h>
using namespace WebCore;
using namespace WebKit;
@@ -99,9 +98,9 @@
static void checkSpellingOfString(uint64_t tag, WKStringRef text, int32_t* misspellingLocation, int32_t* misspellingLength, const void*)
{
if (clientCallbacks().string_spelling_check)
- clientCallbacks().string_spelling_check(tag, toImpl(text)->string().utf8().data(), misspellingLocation, misspellingLength);
+ clientCallbacks().string_spelling_check(tag, WKEinaSharedString(text), misspellingLocation, misspellingLength);
else
- textCheckerEnchant()->checkSpellingOfString(toImpl(text)->string(), *misspellingLocation, *misspellingLength);
+ textCheckerEnchant()->checkSpellingOfString(toWTFString(text), *misspellingLocation, *misspellingLength);
}
static WKArrayRef guessesForWord(uint64_t tag, WKStringRef word, const void*)
@@ -109,7 +108,7 @@
WKMutableArrayRef suggestionsForWord = WKMutableArrayCreate();
if (clientCallbacks().word_guesses_get) {
- Eina_List* list = clientCallbacks().word_guesses_get(tag, toImpl(word)->string().utf8().data());
+ Eina_List* list = clientCallbacks().word_guesses_get(tag, WKEinaSharedString(word));
void* item;
EINA_LIST_FREE(list, item) {
@@ -118,7 +117,7 @@
free(item);
}
} else {
- const Vector<String>& guesses = textCheckerEnchant()->getGuessesForWord(toImpl(word)->string());
+ const Vector<String>& guesses = textCheckerEnchant()->getGuessesForWord(toWTFString(word));
size_t numberOfGuesses = guesses.size();
for (size_t i = 0; i < numberOfGuesses; ++i) {
WKRetainPtr<WKStringRef> suggestion(AdoptWK, WKStringCreateWithUTF8CString(guesses[i].utf8().data()));
@@ -132,17 +131,17 @@
static void learnWord(uint64_t tag, WKStringRef word, const void*)
{
if (clientCallbacks().word_learn)
- clientCallbacks().word_learn(tag, toImpl(word)->string().utf8().data());
+ clientCallbacks().word_learn(tag, WKEinaSharedString(word));
else
- textCheckerEnchant()->learnWord(toImpl(word)->string());
+ textCheckerEnchant()->learnWord(toWTFString(word));
}
static void ignoreWord(uint64_t tag, WKStringRef word, const void*)
{
if (clientCallbacks().word_ignore)
- clientCallbacks().word_ignore(tag, toImpl(word)->string().utf8().data());
+ clientCallbacks().word_ignore(tag, WKEinaSharedString(word));
else
- textCheckerEnchant()->ignoreWord(toImpl(word)->string());
+ textCheckerEnchant()->ignoreWord(toWTFString(word));
}
namespace Ewk_Text_Checker {
Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_eina_shared_string.cpp (142793 => 142794)
--- trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_eina_shared_string.cpp 2013-02-13 21:55:24 UTC (rev 142793)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_eina_shared_string.cpp 2013-02-13 21:56:00 UTC (rev 142794)
@@ -124,3 +124,17 @@
string = string; // Check that self-assignment does not break WKEinaSharedString internal data.
checkString(string, anotherTestString);
}
+
+TEST_F(EWK2UnitTestBase, leakString)
+{
+ WKEinaSharedString string;
+
+ string = testString;
+ checkString(string, testString);
+
+ Eina_Stringshare* leakedString = string.leakString();
+ checkString(string, 0);
+ ASSERT_STREQ(leakedString, testString);
+
+ eina_stringshare_del(leakedString);
+}