Changeset 142794 in webkit


Ignore:
Timestamp:
Feb 13, 2013 1:56:00 PM (11 years ago)
Author:
Christophe Dumez
Message:

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

Location:
trunk/Source/WebKit2
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r142792 r142794  
     12013-02-13  Christophe Dumez  <ch.dumez@sisa.samsung.com>
     2
     3        [EFL][WK2] Stop using WebString in ewk_cookie_manager, ewk_form_submission_request and ewk_text_checker
     4        https://bugs.webkit.org/show_bug.cgi?id=108794
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        Stop using WebString in ewk_cookie_manager, ewk_form_submission_request
     9        and ewk_text_checker as it is internal C++ API. WKString and
     10        WKEinaSharedString are used instead.
     11
     12        * UIProcess/API/cpp/efl/WKEinaSharedString.cpp:
     13        (WKEinaSharedString::leakString): Add leakString() method to
     14        WKEinaSharedString so that we can conveniently convert a WKString to a
     15        Eina shared string and take ownership of it.
     16        * UIProcess/API/cpp/efl/WKEinaSharedString.h:
     17        * UIProcess/API/efl/ewk_cookie_manager.cpp:
     18        (getHostnamesWithCookiesCallback):
     19        * UIProcess/API/efl/ewk_form_submission_request.cpp:
     20        (EwkFormSubmissionRequest::copyFieldValue):
     21        (ewk_form_submission_request_field_names_get):
     22        (ewk_form_submission_request_field_value_get):
     23        * UIProcess/API/efl/ewk_form_submission_request_private.h:
     24        (EwkFormSubmissionRequest):
     25        * UIProcess/API/efl/ewk_text_checker.cpp:
     26        (checkSpellingOfString):
     27        (guessesForWord):
     28        (learnWord):
     29        (ignoreWord):
     30        * UIProcess/API/efl/tests/test_ewk2_eina_shared_string.cpp:
     31        (TEST_F): Add API test for new WKEinaSharedString::leakString() method.
     32
    1332013-02-13  Anders Carlsson  <andersca@apple.com>
    234
  • trunk/Source/WebKit2/UIProcess/API/cpp/efl/WKEinaSharedString.cpp

    r129319 r142794  
    113113    return sharedString;
    114114}
     115
     116Eina_Stringshare* WKEinaSharedString::leakString()
     117{
     118    Eina_Stringshare* sharedString = m_string;
     119    m_string = 0;
     120
     121    return sharedString;
     122}
  • trunk/Source/WebKit2/UIProcess/API/cpp/efl/WKEinaSharedString.h

    r128160 r142794  
    4747    ~WKEinaSharedString();
    4848
     49    Eina_Stringshare* leakString();
     50
    4951    WKEinaSharedString& operator=(const WKEinaSharedString& other);
    5052    WKEinaSharedString& operator=(const char* str);
  • trunk/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.cpp

    r140542 r142794  
    3535#include "ewk_private.h"
    3636#include <wtf/OwnPtr.h>
    37 #include <wtf/text/CString.h>
    38 #include <wtf/text/WTFString.h>
    3937
    4038using namespace WebKit;
     
    195193    for (size_t i = 0; i < hostnameCount; ++i) {
    196194        WKStringRef wkHostname = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkHostnames, i));
    197         String hostname = toImpl(wkHostname)->string();
    198         if (hostname.isEmpty())
     195        if (WKStringIsEmpty(wkHostname))
    199196            continue;
    200         hostnames = eina_list_append(hostnames, eina_stringshare_add(hostname.utf8().data()));
     197        hostnames = eina_list_append(hostnames, WKEinaSharedString(wkHostname).leakString());
    201198    }
    202199
  • trunk/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request.cpp

    r133744 r142794  
    3232#include "WKString.h"
    3333#include "ewk_form_submission_request_private.h"
    34 #include <wtf/text/CString.h>
    3534
    3635using namespace WebKit;
     
    4948}
    5049
    51 String EwkFormSubmissionRequest::fieldValue(const String& fieldName) const
     50Eina_Stringshare* EwkFormSubmissionRequest::copyFieldValue(const char* fieldName) const
    5251{
    5352    ASSERT(fieldName);
    54     WKRetainPtr<WKStringRef> wkFieldName = adoptWK(toCopiedAPI(fieldName));
     53    WKRetainPtr<WKStringRef> wkFieldName = adoptWK(WKStringCreateWithUTF8CString(fieldName));
    5554    WKStringRef wkValue = static_cast<WKStringRef>(WKDictionaryGetItemForKey(m_wkValues.get(), wkFieldName.get()));
    5655
    57     return wkValue ? toImpl(wkValue)->string() : String();
     56    return WKEinaSharedString(wkValue).leakString();
    5857}
    5958
     
    7372    EWK_OBJ_GET_IMPL_OR_RETURN(EwkFormSubmissionRequest, request, impl, 0);
    7473
    75     Eina_List* names = 0;
     74    Eina_List* fieldNames = 0;
    7675
    77     WKRetainPtr<WKArrayRef> wkKeys = impl->fieldNames();
    78     const size_t numKeys = WKArrayGetSize(wkKeys.get());
     76    WKRetainPtr<WKArrayRef> wkFieldNames = impl->fieldNames();
     77    const size_t numKeys = WKArrayGetSize(wkFieldNames.get());
    7978    for (size_t i = 0; i < numKeys; ++i) {
    80         WKStringRef wkKey = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkKeys.get(), i));
    81         names = eina_list_append(names, eina_stringshare_add(toImpl(wkKey)->string().utf8().data()));
     79        WKStringRef wkFieldName = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkFieldNames.get(), i));
     80        fieldNames = eina_list_append(fieldNames, WKEinaSharedString(wkFieldName).leakString());
    8281    }
    8382
    84     return names;
     83    return fieldNames;
    8584}
    8685
     
    9089    EINA_SAFETY_ON_NULL_RETURN_VAL(name, 0);
    9190
    92     String value = impl->fieldValue(String::fromUTF8(name));
    93 
    94     return value.isNull() ?  0 : eina_stringshare_add(value.utf8().data());
     91    return impl->copyFieldValue(name);
    9592}
    9693
  • trunk/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request_private.h

    r135117 r142794  
    2828
    2929#include "WKDictionary.h"
     30#include "WKEinaSharedString.h"
    3031#include "WKFormSubmissionListener.h"
    3132#include "WKRetainPtr.h"
    3233#include "ewk_object_private.h"
    3334#include <wtf/PassRefPtr.h>
    34 #include <wtf/text/WTFString.h>
    3535
    3636class EwkFormSubmissionRequest : public EwkObject {
     
    4646
    4747    WKRetainPtr<WKArrayRef> fieldNames() const;
    48     String fieldValue(const String& fieldName) const;
     48    Eina_Stringshare* copyFieldValue(const char* fieldName) const;
    4949
    5050    void submit();
  • trunk/Source/WebKit2/UIProcess/API/efl/ewk_text_checker.cpp

    r134021 r142794  
    3232#include "TextCheckerEnchant.h"
    3333#include "WKAPICast.h"
     34#include "WKEinaSharedString.h"
    3435#include "WKMutableArray.h"
    3536#include "WKRetainPtr.h"
     
    3738#include "WKTextChecker.h"
    3839#include "WebPageProxy.h"
    39 #include "WebString.h"
    4040#include "ewk_settings.h"
    4141#include "ewk_text_checker_private.h"
    4242#include <Eina.h>
    4343#include <wtf/OwnPtr.h>
    44 #include <wtf/text/CString.h>
    4544
    4645using namespace WebCore;
     
    10099{
    101100    if (clientCallbacks().string_spelling_check)
    102         clientCallbacks().string_spelling_check(tag, toImpl(text)->string().utf8().data(), misspellingLocation, misspellingLength);
     101        clientCallbacks().string_spelling_check(tag, WKEinaSharedString(text), misspellingLocation, misspellingLength);
    103102    else
    104         textCheckerEnchant()->checkSpellingOfString(toImpl(text)->string(), *misspellingLocation, *misspellingLength);
     103        textCheckerEnchant()->checkSpellingOfString(toWTFString(text), *misspellingLocation, *misspellingLength);
    105104}
    106105
     
    110109
    111110    if (clientCallbacks().word_guesses_get) {
    112         Eina_List* list = clientCallbacks().word_guesses_get(tag, toImpl(word)->string().utf8().data());
     111        Eina_List* list = clientCallbacks().word_guesses_get(tag, WKEinaSharedString(word));
    113112        void* item;
    114113
     
    119118        }
    120119    } else {
    121         const Vector<String>& guesses = textCheckerEnchant()->getGuessesForWord(toImpl(word)->string());
     120        const Vector<String>& guesses = textCheckerEnchant()->getGuessesForWord(toWTFString(word));
    122121        size_t numberOfGuesses = guesses.size();
    123122        for (size_t i = 0; i < numberOfGuesses; ++i) {
     
    133132{
    134133    if (clientCallbacks().word_learn)
    135         clientCallbacks().word_learn(tag, toImpl(word)->string().utf8().data());
     134        clientCallbacks().word_learn(tag, WKEinaSharedString(word));
    136135    else
    137         textCheckerEnchant()->learnWord(toImpl(word)->string());
     136        textCheckerEnchant()->learnWord(toWTFString(word));
    138137}
    139138
     
    141140{
    142141    if (clientCallbacks().word_ignore)
    143         clientCallbacks().word_ignore(tag, toImpl(word)->string().utf8().data());
     142        clientCallbacks().word_ignore(tag, WKEinaSharedString(word));
    144143    else
    145         textCheckerEnchant()->ignoreWord(toImpl(word)->string());
     144        textCheckerEnchant()->ignoreWord(toWTFString(word));
    146145}
    147146
  • trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_eina_shared_string.cpp

    r135349 r142794  
    125125    checkString(string, anotherTestString);
    126126}
     127
     128TEST_F(EWK2UnitTestBase, leakString)
     129{
     130    WKEinaSharedString string;
     131
     132    string = testString;
     133    checkString(string, testString);
     134
     135    Eina_Stringshare* leakedString = string.leakString();
     136    checkString(string, 0);
     137    ASSERT_STREQ(leakedString, testString);
     138
     139    eina_stringshare_del(leakedString);
     140}
Note: See TracChangeset for help on using the changeset viewer.