Changeset 163848 in webkit


Ignore:
Timestamp:
Feb 10, 2014 6:12:42 PM (10 years ago)
Author:
andersca@apple.com
Message:

Remove a couple of deprecatedCharacters() from WebKit2
https://bugs.webkit.org/show_bug.cgi?id=128569

Reviewed by Andreas Kling.

  • Shared/APIString.h:
  • UIProcess/TextChecker.h:
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::checkTextOfParagraph):
(WebKit::WebPageProxy::checkSpellingOfString):
(WebKit::WebPageProxy::checkGrammarOfString):

  • UIProcess/mac/TextCheckerMac.mm:

(WebKit::TextChecker::checkTextOfParagraph):
(WebKit::TextChecker::checkSpellingOfString):
(WebKit::TextChecker::checkGrammarOfString):

Location:
trunk/Source/WebKit2
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r163844 r163848  
     12014-02-10  Anders Carlsson  <andersca@apple.com>
     2
     3        Remove a couple of deprecatedCharacters() from WebKit2
     4        https://bugs.webkit.org/show_bug.cgi?id=128569
     5
     6        Reviewed by Andreas Kling.
     7
     8        * Shared/APIString.h:
     9        * UIProcess/TextChecker.h:
     10        * UIProcess/WebPageProxy.cpp:
     11        (WebKit::WebPageProxy::checkTextOfParagraph):
     12        (WebKit::WebPageProxy::checkSpellingOfString):
     13        (WebKit::WebPageProxy::checkGrammarOfString):
     14        * UIProcess/mac/TextCheckerMac.mm:
     15        (WebKit::TextChecker::checkTextOfParagraph):
     16        (WebKit::TextChecker::checkSpellingOfString):
     17        (WebKit::TextChecker::checkGrammarOfString):
     18
    1192014-02-10  Filip Pizlo  <fpizlo@apple.com>
    220
  • trunk/Source/WebKit2/Shared/APIString.h

    r162158 r163848  
    7979    size_t getUTF8CString(char* buffer, size_t bufferSize)
    8080    {
    81         if (!bufferSize)
     81        if (!bufferSize || m_string.isEmpty())
    8282            return 0;
    83         char* p = buffer;
    84         const UChar* d = m_string.deprecatedCharacters();
    85         WTF::Unicode::ConversionResult result = WTF::Unicode::convertUTF16ToUTF8(&d, d + m_string.length(), &p, p + bufferSize - 1, /* strict */ true);
    86         *p++ = '\0';
     83        char* destination = buffer;
     84
     85        WTF::Unicode::ConversionResult result;
     86        if (m_string.is8Bit()) {
     87            const LChar* source = m_string.characters8();
     88            result = WTF::Unicode::convertLatin1ToUTF8(&source, source + m_string.length(), &destination, destination + bufferSize - 1);
     89        } else {
     90            const UChar* source = m_string.characters16();
     91            result = WTF::Unicode::convertUTF16ToUTF8(&source, source + m_string.length(), &destination, destination + bufferSize - 1, /* strict */ true);
     92        }
     93
     94        *destination++ = '\0';
    8795        if (result != WTF::Unicode::conversionOK && result != WTF::Unicode::targetExhausted)
    8896            return 0;
    89         return p - buffer;
     97        return destination - buffer;
    9098    }
    9199
  • trunk/Source/WebKit2/UIProcess/TextChecker.h

    r149476 r163848  
    6868    static void closeSpellDocumentWithTag(int64_t);
    6969#if USE(UNIFIED_TEXT_CHECKING)
    70     static Vector<WebCore::TextCheckingResult> checkTextOfParagraph(int64_t spellDocumentTag, const UChar* text, int length, uint64_t checkingTypes);
     70    static Vector<WebCore::TextCheckingResult> checkTextOfParagraph(int64_t spellDocumentTag, StringView, uint64_t checkingTypes);
    7171#endif
    72     static void checkSpellingOfString(int64_t spellDocumentTag, const UChar* text, uint32_t length, int32_t& misspellingLocation, int32_t& misspellingLength);
    73     static void checkGrammarOfString(int64_t spellDocumentTag, const UChar* text, uint32_t length, Vector<WebCore::GrammarDetail>&, int32_t& badGrammarLocation, int32_t& badGrammarLength);
     72    static void checkSpellingOfString(int64_t spellDocumentTag, StringView, int32_t& misspellingLocation, int32_t& misspellingLength);
     73    static void checkGrammarOfString(int64_t spellDocumentTag, StringView, Vector<WebCore::GrammarDetail>&, int32_t& badGrammarLocation, int32_t& badGrammarLength);
    7474    static bool spellingUIIsShowing();
    7575    static void toggleSpellingUIIsShowing();
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r163836 r163848  
    34343434void WebPageProxy::checkTextOfParagraph(const String& text, uint64_t checkingTypes, Vector<TextCheckingResult>& results)
    34353435{
    3436     results = TextChecker::checkTextOfParagraph(spellDocumentTag(), text.deprecatedCharacters(), text.length(), checkingTypes);
     3436    results = TextChecker::checkTextOfParagraph(spellDocumentTag(), text, checkingTypes);
    34373437}
    34383438#endif
     
    34403440void WebPageProxy::checkSpellingOfString(const String& text, int32_t& misspellingLocation, int32_t& misspellingLength)
    34413441{
    3442     TextChecker::checkSpellingOfString(spellDocumentTag(), text.deprecatedCharacters(), text.length(), misspellingLocation, misspellingLength);
     3442    TextChecker::checkSpellingOfString(spellDocumentTag(), text, misspellingLocation, misspellingLength);
    34433443}
    34443444
    34453445void WebPageProxy::checkGrammarOfString(const String& text, Vector<GrammarDetail>& grammarDetails, int32_t& badGrammarLocation, int32_t& badGrammarLength)
    34463446{
    3447     TextChecker::checkGrammarOfString(spellDocumentTag(), text.deprecatedCharacters(), text.length(), grammarDetails, badGrammarLocation, badGrammarLength);
     3447    TextChecker::checkGrammarOfString(spellDocumentTag(), text, grammarDetails, badGrammarLocation, badGrammarLength);
    34483448}
    34493449
  • trunk/Source/WebKit2/UIProcess/mac/TextCheckerMac.mm

    r162505 r163848  
    2929#import "TextCheckerState.h"
    3030#import <WebCore/NotImplemented.h>
     31#import <wtf/text/StringView.h>
    3132#import <wtf/RetainPtr.h>
    3233
     
    294295#if USE(UNIFIED_TEXT_CHECKING)
    295296
    296 Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, const UChar* text, int length, uint64_t checkingTypes)
     297Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, StringView stringView, uint64_t checkingTypes)
    297298{
    298299    Vector<TextCheckingResult> results;
    299300
    300     RetainPtr<NSString> textString = adoptNS([[NSString alloc] initWithCharactersNoCopy:const_cast<UChar*>(text) length:length freeWhenDone:NO]);
    301     NSArray *incomingResults = [[NSSpellChecker sharedSpellChecker] checkString:textString .get()
    302                                                                           range:NSMakeRange(0, length)
     301    auto textString = stringView.createNSStringWithoutCopying();
     302    NSArray *incomingResults = [[NSSpellChecker sharedSpellChecker] checkString:textString.get()
     303                                                                          range:NSMakeRange(0, stringView.length())
    303304                                                                          types:checkingTypes | NSTextCheckingTypeOrthography
    304305                                                                        options:nil
     
    383384#endif
    384385
    385 void TextChecker::checkSpellingOfString(int64_t, const UChar*, uint32_t, int32_t&, int32_t&)
     386void TextChecker::checkSpellingOfString(int64_t, StringView, int32_t&, int32_t&)
    386387{
    387388    // Mac uses checkTextOfParagraph instead.
     
    389390}
    390391
    391 void TextChecker::checkGrammarOfString(int64_t, const UChar*, uint32_t, Vector<WebCore::GrammarDetail>&, int32_t&, int32_t&)
     392void TextChecker::checkGrammarOfString(int64_t, StringView, Vector<WebCore::GrammarDetail>&, int32_t&, int32_t&)
    392393{
    393394    // Mac uses checkTextOfParagraph instead.
Note: See TracChangeset for help on using the changeset viewer.