Changeset 165692 in webkit


Ignore:
Timestamp:
Mar 15, 2014 11:22:02 PM (10 years ago)
Author:
Darin Adler
Message:

Remove all uses of deprecatedCharacters from WebKit2
https://bugs.webkit.org/show_bug.cgi?id=130197

Reviewed by Andreas Kling.

Source/WebKit2:

  • Shared/APIString.h: Rewrote getCharacters to use StringView,

substring, and getCharactersWithUpconvert. Added an 8-bit case
to getUTF8CString.

  • Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp:

(WebKit::writeByte): Added.
(WebKit::writeCharacter): Added.
(WebKit::writeLine): Added. Uses operator[] instead of characters16 to get
the UTF-16 characters out of the string.
(WebKit::NetscapePluginModule::scanPlugin): Replaced code that writes out
text to stdout with much simpler version using the functions above.

  • UIProcess/TextChecker.h: Changed text arguments to use StringView instead

of UChar/int pairs.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::internalShowContextMenu): Updated to pass StringView.

  • UIProcess/efl/TextCheckerEfl.cpp:

(WebKit::nextWordOffset): Changed function to use StringView and unsigned.
(WebKit::TextChecker::checkTextOfParagraph): Changed to use StringView and
substring.
(WebKit::TextChecker::checkSpellingOfString): Ditto.
(WebKit::TextChecker::checkGrammarOfString): Ditto.
(WebKit::TextChecker::requestCheckingOfString): Pass in a StringView, so no
need to call deprecatedCharacters.

  • UIProcess/ios/TextCheckerIOS.mm:

(WebKit::TextChecker::checkTextOfParagraph): Changed to take StringView.
(WebKit::TextChecker::checkSpellingOfString): Ditto.
(WebKit::TextChecker::checkGrammarOfString): Ditto.

  • UIProcess/mac/TextCheckerMac.mm:

(WebKit::TextChecker::checkTextOfParagraph): Changed to take StringView and
use StringView::createNSStringWithoutCopying.
(WebKit::TextChecker::checkSpellingOfString): CHanged to take StringView.
(WebKit::TextChecker::checkGrammarOfString): Ditto.

  • WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:

(WebKit::convertStringToKeyCodes): Changed to take StringView and use
upconvertedCharacters instead of deprecatedCharacters. Also use move instead
of swap.
(WebKit::NetscapePlugin::sendComplexTextInput): Updated to new style for loop.

  • WebProcess/WebPage/EncoderAdapter.cpp:

(WebKit::EncoderAdapter::encodeString): Use StringView::upconvertedCharacters
instead of String::deprecatedCharacters.

Source/WTF:

  • wtf/text/StringView.h: Added new getCharactersWithUpconvert and upconvertedCharacters

functions. These are useful for callers that need UTF-16.

Location:
trunk/Source
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r165691 r165692  
     12014-03-15  Darin Adler  <darin@apple.com>
     2
     3        Remove all uses of deprecatedCharacters from WebKit2
     4        https://bugs.webkit.org/show_bug.cgi?id=130197
     5
     6        Reviewed by Andreas Kling.
     7
     8        * wtf/text/StringView.h: Added new getCharactersWithUpconvert and upconvertedCharacters
     9        functions. These are useful for callers that need UTF-16.
     10
    1112014-03-15  Darin Adler  <darin@apple.com>
    212
  • trunk/Source/WTF/wtf/text/StringView.h

    r163727 r165692  
    8686    }
    8787
     88    void getCharactersWithUpconvert(LChar*) const;
     89    void getCharactersWithUpconvert(UChar*) const;
     90
     91    class UpconvertedCharacters {
     92    public:
     93        explicit UpconvertedCharacters(const StringView&);
     94        operator const UChar*() const { return m_characters; }
     95        const UChar* get() const { return m_characters; }
     96    private:
     97        Vector<UChar, 32> m_upconvertedCharacters;
     98        const UChar* m_characters;
     99    };
     100    UpconvertedCharacters upconvertedCharacters() const { return UpconvertedCharacters(*this); }
     101
    88102    bool isNull() const { return !m_characters; }
    89103    bool isEmpty() const { return !length(); }
     
    177191};
    178192
     193inline void StringView::getCharactersWithUpconvert(LChar* destination) const
     194{
     195    ASSERT(is8Bit());
     196    memcpy(destination, characters8(), length());
     197}
     198
     199inline void StringView::getCharactersWithUpconvert(UChar* destination) const
     200{
     201    if (is8Bit()) {
     202        const LChar* characters8 = this->characters8();
     203        unsigned length = this->length();
     204        for (unsigned i = 0; i < length; ++i)
     205            destination[i] = characters8[i];
     206        return;
     207    }
     208    memcpy(destination, characters16(), length() * sizeof(UChar));
     209}
     210
     211inline StringView::UpconvertedCharacters::UpconvertedCharacters(const StringView& string)
     212{
     213    if (!string.is8Bit()) {
     214        m_characters = string.characters16();
     215        return;
     216    }
     217    const LChar* characters8 = string.characters8();
     218    unsigned length = string.length();
     219    m_upconvertedCharacters.reserveInitialCapacity(length);
     220    for (unsigned i = 0; i < length; ++i)
     221        m_upconvertedCharacters.uncheckedAppend(characters8[i]);
     222    m_characters = m_upconvertedCharacters.data();
     223}
     224
    179225} // namespace WTF
    180226
  • trunk/Source/WebKit2/ChangeLog

    r165685 r165692  
     12014-03-15  Darin Adler  <darin@apple.com>
     2
     3        Remove all uses of deprecatedCharacters from WebKit2
     4        https://bugs.webkit.org/show_bug.cgi?id=130197
     5
     6        Reviewed by Andreas Kling.
     7
     8        * Shared/APIString.h: Rewrote getCharacters to use StringView,
     9        substring, and getCharactersWithUpconvert. Added an 8-bit case
     10        to getUTF8CString.
     11
     12        * Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp:
     13        (WebKit::writeByte): Added.
     14        (WebKit::writeCharacter): Added.
     15        (WebKit::writeLine): Added. Uses operator[] instead of characters16 to get
     16        the UTF-16 characters out of the string.
     17        (WebKit::NetscapePluginModule::scanPlugin): Replaced code that writes out
     18        text to stdout with much simpler version using the functions above.
     19
     20        * UIProcess/TextChecker.h: Changed text arguments to use StringView instead
     21        of UChar/int pairs.
     22
     23        * UIProcess/WebPageProxy.cpp:
     24        (WebKit::WebPageProxy::internalShowContextMenu): Updated to pass StringView.
     25
     26        * UIProcess/efl/TextCheckerEfl.cpp:
     27        (WebKit::nextWordOffset): Changed function to use StringView and unsigned.
     28        (WebKit::TextChecker::checkTextOfParagraph): Changed to use StringView and
     29        substring.
     30        (WebKit::TextChecker::checkSpellingOfString): Ditto.
     31        (WebKit::TextChecker::checkGrammarOfString): Ditto.
     32        (WebKit::TextChecker::requestCheckingOfString): Pass in a StringView, so no
     33        need to call deprecatedCharacters.
     34
     35        * UIProcess/ios/TextCheckerIOS.mm:
     36        (WebKit::TextChecker::checkTextOfParagraph): Changed to take StringView.
     37        (WebKit::TextChecker::checkSpellingOfString): Ditto.
     38        (WebKit::TextChecker::checkGrammarOfString): Ditto.
     39
     40        * UIProcess/mac/TextCheckerMac.mm:
     41        (WebKit::TextChecker::checkTextOfParagraph): Changed to take StringView and
     42        use StringView::createNSStringWithoutCopying.
     43        (WebKit::TextChecker::checkSpellingOfString): CHanged to take StringView.
     44        (WebKit::TextChecker::checkGrammarOfString): Ditto.
     45
     46        * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
     47        (WebKit::convertStringToKeyCodes): Changed to take StringView and use
     48        upconvertedCharacters instead of deprecatedCharacters. Also use move instead
     49        of swap.
     50        (WebKit::NetscapePlugin::sendComplexTextInput): Updated to new style for loop.
     51
     52        * WebProcess/WebPage/EncoderAdapter.cpp:
     53        (WebKit::EncoderAdapter::encodeString): Use StringView::upconvertedCharacters
     54        instead of String::deprecatedCharacters.
     55
    1562014-03-15  David Kilzer  <ddkilzer@apple.com>
    257
  • trunk/Source/WebKit2/Shared/APIString.h

    r163860 r165692  
    3232#include <JavaScriptCore/OpaqueJSString.h>
    3333#include <wtf/PassRefPtr.h>
     34#include <wtf/text/StringView.h>
    3435#include <wtf/text/WTFString.h>
    3536#include <wtf/unicode/UTF8.h>
     
    6970    size_t getCharacters(UChar* buffer, size_t bufferLength) const
    7071    {
    71         if (!bufferLength)
    72             return 0;
    73         bufferLength = std::min(bufferLength, static_cast<size_t>(m_string.length()));
    74         memcpy(buffer, m_string.deprecatedCharacters(), bufferLength * sizeof(UChar));
    75         return bufferLength;
     72        unsigned unsignedBufferLength = std::min<size_t>(bufferLength, std::numeric_limits<unsigned>::max());
     73        StringView substring = StringView(m_string).substring(0, unsignedBufferLength);
     74        substring.getCharactersWithUpconvert(buffer);
     75        return substring.length();
    7676    }
    7777
     
    8282            return 0;
    8383        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';
     84        WTF::Unicode::ConversionResult result;
     85        if (m_string.is8Bit()) {
     86            const LChar* characters = m_string.characters8();
     87            result = WTF::Unicode::convertLatin1ToUTF8(&characters, characters + m_string.length(), &p, p + bufferSize - 1);
     88        } else {
     89            const UChar* characters = m_string.characters16();
     90            result = WTF::Unicode::convertUTF16ToUTF8(&characters, characters + m_string.length(), &p, p + bufferSize - 1, /* strict */ true);
     91        }
    8792        if (result != WTF::Unicode::conversionOK && result != WTF::Unicode::targetExhausted)
    8893            return 0;
     94        *p++ = '\0';
    8995        return p - buffer;
    9096    }
  • trunk/Source/WebKit2/Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp

    r164808 r165692  
    186186}
    187187
    188 static String truncateToSingleLine(const String& string)
    189 {
    190     unsigned oldLength = string.length();
    191     UChar* buffer;
    192     String stringBuffer(StringImpl::createUninitialized(oldLength + 1, buffer));
    193 
    194     unsigned newLength = 0;
    195     const UChar* start = string.deprecatedCharacters();
    196     for (const UChar* c = start; c < start + oldLength; ++c) {
    197         if (*c != UChar('\n'))
    198             buffer[newLength++] = *c;
    199     }
    200     buffer[newLength++] = UChar('\n');
    201 
    202     String result = (newLength == oldLength + 1) ? stringBuffer : String(stringBuffer.characters16(), newLength);
    203     ASSERT(result.endsWith(UChar('\n')));
    204     return result;
     188static void writeByte(char byte)
     189{
     190    int result;
     191    while ((result = fputc(byte, stdout)) == EOF && errno == EINTR) { }
     192    ASSERT(result != EOF);
     193}
     194
     195static void writeCharacter(UChar character)
     196{
     197    writeByte(reinterpret_cast<const char*>(&character)[0]);
     198    writeByte(reinterpret_cast<const char*>(&character)[1]);
     199}
     200
     201static void writeLine(const String& line)
     202{
     203    unsigned length = line.length();
     204    for (unsigned i = 0; i < length; ++i) {
     205        UChar character = line[i];
     206        if (character != '\n')
     207            writeCharacter(character);
     208    }
     209    writeCharacter('\n');
    205210}
    206211
     
    228233
    229234    // Write data to standard output for the UI process.
    230     String output[3] = {
    231         truncateToSingleLine(metaData.name),
    232         truncateToSingleLine(metaData.description),
    233         truncateToSingleLine(metaData.mimeDescription)
    234     };
    235     for (unsigned i = 0; i < 3; ++i) {
    236         const String& line = output[i];
    237         const char* current = reinterpret_cast<const char*>(line.characters16());
    238         const char* end = reinterpret_cast<const char*>(line.characters16()) + (line.length() * sizeof(UChar));
    239         while (current < end) {
    240             int result;
    241             while ((result = fputc(*current, stdout)) == EOF && errno == EINTR) { }
    242             ASSERT(result != EOF);
    243             ++current;
    244         }
    245     }
     235    writeLine(metaData.name);
     236    writeLine(metaData.description);
     237    writeLine(metaData.mimeDescription);
    246238
    247239    fflush(stdout);
  • trunk/Source/WebKit2/UIProcess/TextChecker.h

    r164172 r165692  
    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 text, 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 text, int32_t& misspellingLocation, int32_t& misspellingLength);
     73    static void checkGrammarOfString(int64_t spellDocumentTag, StringView text, Vector<WebCore::GrammarDetail>&, int32_t& badGrammarLocation, int32_t& badGrammarLength);
    7474    static bool spellingUIIsShowing();
    7575    static void toggleSpellingUIIsShowing();
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r165577 r165692  
    34703470void WebPageProxy::checkTextOfParagraph(const String& text, uint64_t checkingTypes, Vector<TextCheckingResult>& results)
    34713471{
    3472     results = TextChecker::checkTextOfParagraph(spellDocumentTag(), text.deprecatedCharacters(), text.length(), checkingTypes);
     3472    results = TextChecker::checkTextOfParagraph(spellDocumentTag(), text, checkingTypes);
    34733473}
    34743474#endif
     
    34763476void WebPageProxy::checkSpellingOfString(const String& text, int32_t& misspellingLocation, int32_t& misspellingLength)
    34773477{
    3478     TextChecker::checkSpellingOfString(spellDocumentTag(), text.deprecatedCharacters(), text.length(), misspellingLocation, misspellingLength);
     3478    TextChecker::checkSpellingOfString(spellDocumentTag(), text, misspellingLocation, misspellingLength);
    34793479}
    34803480
    34813481void WebPageProxy::checkGrammarOfString(const String& text, Vector<GrammarDetail>& grammarDetails, int32_t& badGrammarLocation, int32_t& badGrammarLength)
    34823482{
    3483     TextChecker::checkGrammarOfString(spellDocumentTag(), text.deprecatedCharacters(), text.length(), grammarDetails, badGrammarLocation, badGrammarLength);
     3483    TextChecker::checkGrammarOfString(spellDocumentTag(), text, grammarDetails, badGrammarLocation, badGrammarLength);
    34843484}
    34853485
  • trunk/Source/WebKit2/UIProcess/efl/TextCheckerEfl.cpp

    r163298 r165692  
    121121
    122122#if ENABLE(SPELLCHECK)
    123 static int nextWordOffset(const UChar* text, int length, int currentOffset)
     123static unsigned nextWordOffset(StringView text, unsigned currentOffset)
    124124{
    125125    // FIXME: avoid creating textIterator object here, it could be passed as a parameter.
     
    128128    //        For many word separators, the method doesn't properly determine the boundaries
    129129    //        without resetting the iterator.
    130     TextBreakIterator* textIterator = wordBreakIterator(StringView(text, length));
     130    TextBreakIterator* textIterator = wordBreakIterator(text);
    131131    if (!textIterator)
    132132        return currentOffset;
    133133
    134     int wordOffset = currentOffset;
    135     while (wordOffset < length && isTextBreak(textIterator, wordOffset))
     134    unsigned wordOffset = currentOffset;
     135    while (wordOffset < text.length() && isTextBreak(textIterator, wordOffset))
    136136        ++wordOffset;
    137137
     
    149149
    150150#if USE(UNIFIED_TEXT_CHECKING)
    151 Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, const UChar* text, int length, uint64_t checkingTypes)
     151Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, StringView text, uint64_t checkingTypes)
    152152{
    153153    Vector<TextCheckingResult> paragraphCheckingResult;
    154154#if ENABLE(SPELLCHECK)
    155155    if (checkingTypes & TextCheckingTypeSpelling) {
    156         TextBreakIterator* textIterator = wordBreakIterator(StringView(text, length));
     156        TextBreakIterator* textIterator = wordBreakIterator(text);
    157157        if (!textIterator)
    158158            return paragraphCheckingResult;
     
    160160        // Omit the word separators at the beginning/end of the text to don't unnecessarily
    161161        // involve the client to check spelling for them.
    162         int offset = nextWordOffset(text, length, 0);
    163         int lengthStrip = length;
     162        unsigned offset = nextWordOffset(text, 0);
     163        unsigned lengthStrip = text.length();
    164164        while (lengthStrip > 0 && isTextBreak(textIterator, lengthStrip - 1))
    165165            --lengthStrip;
    166166
    167         while (offset >= 0 && offset < lengthStrip) {
     167        while (offset < lengthStrip) {
    168168            int32_t misspellingLocation = -1;
    169169            int32_t misspellingLength = 0;
    170             checkSpellingOfString(spellDocumentTag, text + offset, lengthStrip - offset, misspellingLocation, misspellingLength);
     170            checkSpellingOfString(spellDocumentTag, text.substring(offset, lengthStrip - offset), misspellingLocation, misspellingLength);
    171171            if (!misspellingLength)
    172172                break;
     
    179179            offset += misspellingLocation + misspellingLength;
    180180            // Generally, we end up checking at the word separator, move to the adjacent word.
    181             offset = nextWordOffset(text, lengthStrip, offset);
     181            offset = nextWordOffset(text.substring(0, lengthStrip), offset);
    182182        }
    183183    }
     
    192192#endif
    193193
    194 void TextChecker::checkSpellingOfString(int64_t spellDocumentTag, const UChar* text, uint32_t length, int32_t& misspellingLocation, int32_t& misspellingLength)
    195 {
    196 #if ENABLE(SPELLCHECK)
    197     WebTextChecker::shared()->client().checkSpellingOfString(spellDocumentTag, String(text, length), misspellingLocation, misspellingLength);
     194void TextChecker::checkSpellingOfString(int64_t spellDocumentTag, StringView text, int32_t& misspellingLocation, int32_t& misspellingLength)
     195{
     196#if ENABLE(SPELLCHECK)
     197    WebTextChecker::shared()->client().checkSpellingOfString(spellDocumentTag, text.toStringWithoutCopying(), misspellingLocation, misspellingLength);
    198198#else
    199199    UNUSED_PARAM(spellDocumentTag);
     
    205205}
    206206
    207 void TextChecker::checkGrammarOfString(int64_t, const UChar*, uint32_t, Vector<GrammarDetail>&, int32_t&, int32_t&)
     207void TextChecker::checkGrammarOfString(int64_t, StringView, Vector<GrammarDetail>&, int32_t&, int32_t&)
    208208{
    209209    notImplemented();
     
    272272    ASSERT(request.mask() != TextCheckingTypeNone);
    273273
    274     String text = request.text();
    275     Vector<TextCheckingResult> result = checkTextOfParagraph(completion->spellDocumentTag(), text.deprecatedCharacters(), text.length(), request.mask());
    276 
    277     completion->didFinishCheckingText(result);
     274    completion->didFinishCheckingText(checkTextOfParagraph(completion->spellDocumentTag(), request.text(), request.mask()));
    278275#else
    279276    UNUSED_PARAM(completion);
  • trunk/Source/WebKit2/UIProcess/ios/TextCheckerIOS.mm

    r164776 r165692  
    3131#import "TextCheckerState.h"
    3232#import <WebCore/NotImplemented.h>
     33#import <wtf/text/StringView.h>
    3334
    3435using namespace WebCore;
     
    132133#if USE(UNIFIED_TEXT_CHECKING)
    133134
    134 Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t, const UChar*, int, uint64_t)
     135Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t, StringView, uint64_t)
    135136{
    136137    notImplemented();
     
    140141#endif
    141142
    142 void TextChecker::checkSpellingOfString(int64_t, const UChar*, uint32_t, int32_t&, int32_t&)
     143void TextChecker::checkSpellingOfString(int64_t, StringView, int32_t&, int32_t&)
    143144{
    144     // Mac uses checkTextOfParagraph instead.
    145145    notImplemented();
    146146}
    147147
    148 void TextChecker::checkGrammarOfString(int64_t, const UChar*, uint32_t, Vector<WebCore::GrammarDetail>&, int32_t&, int32_t&)
     148void TextChecker::checkGrammarOfString(int64_t, StringView, Vector<WebCore::GrammarDetail>&, int32_t&, int32_t&)
    149149{
    150     // Mac uses checkTextOfParagraph instead.
    151150    notImplemented();
    152151}
  • trunk/Source/WebKit2/UIProcess/mac/TextCheckerMac.mm

    r164776 r165692  
    3232#import <WebCore/NotImplemented.h>
    3333#import <wtf/RetainPtr.h>
     34#import <wtf/text/StringView.h>
    3435
    3536@interface NSSpellChecker (WebNSSpellCheckerDetails)
     
    296297#if USE(UNIFIED_TEXT_CHECKING)
    297298
    298 Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, const UChar* text, int length, uint64_t checkingTypes)
     299Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, StringView text, uint64_t checkingTypes)
    299300{
    300301    Vector<TextCheckingResult> results;
    301302
    302     RetainPtr<NSString> textString = adoptNS([[NSString alloc] initWithCharactersNoCopy:const_cast<UChar*>(text) length:length freeWhenDone:NO]);
    303     NSArray *incomingResults = [[NSSpellChecker sharedSpellChecker] checkString:textString .get()
    304                                                                           range:NSMakeRange(0, length)
     303    RetainPtr<NSString> textString = text.createNSStringWithoutCopying();
     304    NSArray *incomingResults = [[NSSpellChecker sharedSpellChecker] checkString:textString.get()
     305                                                                          range:NSMakeRange(0, text.length())
    305306                                                                          types:checkingTypes | NSTextCheckingTypeOrthography
    306307                                                                        options:nil
     
    385386#endif
    386387
    387 void TextChecker::checkSpellingOfString(int64_t, const UChar*, uint32_t, int32_t&, int32_t&)
     388void TextChecker::checkSpellingOfString(int64_t, StringView, int32_t&, int32_t&)
    388389{
    389390    // Mac uses checkTextOfParagraph instead.
     
    391392}
    392393
    393 void TextChecker::checkGrammarOfString(int64_t, const UChar*, uint32_t, Vector<WebCore::GrammarDetail>&, int32_t&, int32_t&)
     394void TextChecker::checkGrammarOfString(int64_t, StringView, Vector<WebCore::GrammarDetail>&, int32_t&, int32_t&)
    394395{
    395396    // Mac uses checkTextOfParagraph instead.
  • trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm

    r163297 r165692  
    964964
    965965#ifndef NP_NO_CARBON
    966 static bool convertStringToKeyCodes(const String& string, ScriptCode scriptCode, Vector<UInt8>& keyCodes)
     966static bool convertStringToKeyCodes(StringView string, ScriptCode scriptCode, Vector<UInt8>& keyCodes)
    967967{
    968968    // Create the mapping.
     
    974974    mapping.unicodeEncoding = CreateTextEncoding(kTextEncodingUnicodeDefault, kTextEncodingDefaultVariant, kTextEncodingDefaultFormat);
    975975    mapping.mappingVersion = kUnicodeUseLatestMapping;
    976    
     976
    977977    // Create the converter
    978978    UnicodeToTextInfo textInfo;
    979    
     979
    980980    if (CreateUnicodeToTextInfo(&mapping, &textInfo) != noErr)
    981981        return false;
    982    
     982
    983983    ByteCount inputLength = string.length() * sizeof(UniChar);
    984984    ByteCount inputRead;
     
    987987
    988988    Vector<UInt8> outputData(maxOutputLength);
    989     OSStatus status = ConvertFromUnicodeToText(textInfo, inputLength, string.deprecatedCharacters(), kNilOptions, 0, 0, 0, 0, maxOutputLength, &inputRead, &outputLength, outputData.data());
     989    OSStatus status = ConvertFromUnicodeToText(textInfo, inputLength, string.upconvertedCharacters(), kNilOptions, 0, 0, 0, 0, maxOutputLength, &inputRead, &outputLength, outputData.data());
    990990   
    991991    DisposeUnicodeToTextInfo(&textInfo);
     
    994994        return false;
    995995
    996     outputData.swap(keyCodes);
     996    keyCodes = std::move(outputData);
    997997    return true;
    998998}
     
    10351035        event.modifiers = 0;
    10361036
    1037         for (size_t i = 0; i < keyCodes.size(); i++) {
    1038             event.message = keyCodes[i];
     1037        for (auto& keyCode : keyCodes) {
     1038            event.message = keyCode;
    10391039            NPP_HandleEvent(&event);
    10401040        }
  • trunk/Source/WebKit2/WebProcess/WebPage/EncoderAdapter.cpp

    r161851 r165692  
    2929#include "DataReference.h"
    3030#include "WebCoreArgumentCoders.h"
    31 #include <wtf/text/WTFString.h>
     31#include <wtf/text/StringView.h>
    3232
    3333namespace WebKit {
     
    109109    uint64_t lengthInBytes = length * sizeof(UChar);
    110110    m_encoder << lengthInBytes;
    111     m_encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(value.deprecatedCharacters()), length * sizeof(UChar), alignof(UChar));
     111    m_encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(StringView(value).upconvertedCharacters().get()), length * sizeof(UChar), alignof(UChar));
    112112}
    113113
Note: See TracChangeset for help on using the changeset viewer.