| Differences between
and this patch
- a/Source/WTF/ChangeLog +15 lines
Lines 1-3 a/Source/WTF/ChangeLog_sec1
1
2014-03-18  Darin Adler  <darin@apple.com>
2
3
        Reduce use of deprecatedCharacters in WebCore
4
        https://bugs.webkit.org/show_bug.cgi?id=130318
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * wtf/text/WTFString.h: Export another overload of charactersToFloat since it's used
9
        in WebCore now.
10
11
        * wtf/text/cf/StringViewCF.cpp: Change so this can build on Windows.
12
13
        * WTF.vcxproj/WTF.vcxproj: Added StringViewCF.cpp.
14
        * WTF.vcxproj/WTF.vcxproj.filters: Added StringViewCF.cpp.
15
1
2014-03-17  Darin Adler  <darin@apple.com>
16
2014-03-17  Darin Adler  <darin@apple.com>
2
17
3
        Remove most uses of deprecatedCharacter in WTF
18
        Remove most uses of deprecatedCharacter in WTF
- a/Source/WebCore/ChangeLog +253 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2014-03-18  Darin Adler  <darin@apple.com>
2
3
        Reduce use of deprecatedCharacters in WebCore
4
        https://bugs.webkit.org/show_bug.cgi?id=130318
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * Modules/indexeddb/IDBKeyPath.cpp:
9
        (WebCore::IDBKeyPathLexer::IDBKeyPathLexer): Use StringView for parsing.
10
        (WebCore::IDBKeyPathLexer::lex): Ditto.
11
        (WebCore::IDBKeyPathLexer::lexIdentifier): Ditto.
12
13
        * Modules/indexeddb/leveldb/IDBLevelDBCoding.cpp:
14
        (WebCore::IDBLevelDBCoding::encodeString): Index directly into string instead of
15
        using deprecatedCharacters.
16
17
        * Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp:
18
        (WebCore::ThreadableWebSocketChannelClientWrapper::setSubprotocol): Use
19
        StringView::getCharactersWithUpconvert.
20
        (WebCore::ThreadableWebSocketChannelClientWrapper::setExtensions): Ditto.
21
22
        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
23
        (-[WebAccessibilityObjectWrapper arrayOfTextForTextMarkers:attributed:]):
24
        Use operator NSString * instead of explicitly creating an NSString.
25
26
        * bindings/js/SerializedScriptValue.cpp:
27
        (WebCore::writeLittleEndianUInt16): Added.
28
        (WebCore::CloneSerializer::serialize): Added a separate code path for 8-bit strings.
29
        (WebCore::CloneSerializer::write): Ditto.
30
31
        * bindings/objc/WebScriptObject.mm:
32
        (+[WebScriptObject _convertValueToObjcValue:JSC::originRootObject:rootObject:]):
33
        Use operator NSString * instead of explicitly creating an NSString.
34
35
        * dom/Document.cpp:
36
        (WebCore::Document::parseQualifiedName): Index directly into string instead of
37
        using deprecatedCharacters.
38
        * editing/CompositeEditCommand.cpp:
39
        (WebCore::containsOnlyWhitespace): Ditto.
40
        * editing/SmartReplace.cpp:
41
        (WebCore::addAllCodePoints): Ditto.
42
        (WebCore::getSmartSet): Use StringView::upconvertedCharacters.
43
44
        * editing/TextIterator.cpp:
45
        (WebCore::foldQuoteMarksAndSoftHyphens): Changed to return a value so it can be
46
        used in initialization rather than assignment.
47
        (WebCore::SearchBuffer::SearchBuffer): Use StringView::upconvertedCharacters.
48
49
        * editing/TypingCommand.cpp:
50
        (WebCore::TypingCommand::insertText): Index directly into string instead of using
51
        deprecatedCharacters.
52
        * editing/VisiblePosition.cpp:
53
        (WebCore::VisiblePosition::characterAfter): Ditto.
54
        * editing/VisibleUnits.cpp:
55
        (WebCore::startOfParagraph): Ditto.
56
        (WebCore::endOfParagraph): Ditto.
57
58
        * fileapi/WebKitBlobBuilder.cpp:
59
        (WebCore::BlobBuilder::append): Pass a StringView to TextEncoding::encode.
60
61
        * html/BaseDateAndTimeInputType.cpp:
62
        (WebCore::BaseDateAndTimeInputType::parseToDateComponents): Use
63
        StringView::upconvertedCharacters.
64
65
        * html/FormDataList.cpp:
66
        (WebCore::FormDataList::appendString): Pass a StringView to TextEncoding::encode.
67
68
        * html/canvas/CanvasRenderingContext2D.cpp:
69
        (WebCore::normalizeSpaces): Use StringView::getCharactersWithUpconvert.
70
71
        * html/parser/HTMLParserIdioms.cpp:
72
        (WebCore::stripLeadingAndTrailingHTMLSpaces): Use characters16 for a code path
73
        that already handled 8-bit characters separately.
74
        (WebCore::parseHTMLNonNegativeInteger): Ditto.
75
        (WebCore::parseDescriptors): Added an 8-bit code path.
76
77
        * inspector/InspectorStyleSheet.cpp:
78
        (WebCore::InspectorStyle::newLineAndWhitespaceDelimiters): Index directly into
79
        string instead of using deprecatedCharacters.
80
        * inspector/InspectorStyleTextEditor.cpp:
81
        (WebCore::InspectorStyleTextEditor::insertProperty): Ditto.
82
        (WebCore::InspectorStyleTextEditor::internalReplaceProperty): Ditto.
83
84
        * page/ContentSecurityPolicy.cpp:
85
        (WebCore::isSourceListNone): Use StringView::upconvertedCharacters.
86
        (WebCore::CSPSourceList::parse): Ditto.
87
        (WebCore::NonceDirective::parse): Ditto.
88
        (WebCore::MediaListDirective::parse): Ditto.
89
        (WebCore::CSPDirectiveList::parse): Ditto.
90
        (WebCore::CSPDirectiveList::parseReportURI): Ditto.
91
        (WebCore::CSPDirectiveList::parseReflectedXSS): Ditto.
92
        (WebCore::ContentSecurityPolicy::didReceiveHeader): Ditto.
93
94
        * page/PageSerializer.cpp:
95
        (WebCore::PageSerializer::serializeFrame): Pass a StringView into
96
        TextEncoding::encode.
97
        (WebCore::PageSerializer::serializeCSSStyleSheet): Ditto.
98
99
        * platform/Length.cpp:
100
        (WebCore::countCharacter): Index directly into string instead of using
101
        deprecatedCharacters. Also changed to take a StringImpl&.
102
        (WebCore::newCoordsArray): Ditto. Call countCharacter the new way, and
103
        use StringView::upconvertedCharacters.
104
        (WebCore::newLengthArray): Ditto.
105
106
        * platform/LinkHash.cpp:
107
        (WebCore::visitedLinkHash): Use characters16 for the 16-bit path.
108
        Also removed unused visitedURL function.
109
        * platform/LinkHash.h: Removed unused visitedURL function.
110
111
        * platform/SharedBuffer.cpp:
112
        (WebCore::utf8Buffer): Added an 8-bit code path.
113
        * platform/URL.cpp:
114
        (WebCore::URL::port): Ditto.
115
        (WebCore::encodeRelativeString): Use StringView to call TextEncoding::encode.
116
117
        * platform/graphics/Color.cpp:
118
        (WebCore::Color::parseHexColor): Use characters16 in the 16-bit path.
119
        (WebCore::Color::Color): Ditto.
120
121
        * platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp:
122
        (WebCore::harfBuzzGetGlyph): Use StringView to call TextEncoding::encode.
123
124
        * platform/graphics/StringTruncator.cpp:
125
        (WebCore::centerTruncateToBuffer): Use StringView::getCharactersWithUpconvert.
126
        (WebCore::rightTruncateToBuffer): Ditto.
127
        (WebCore::rightClipToCharacterBuffer): Ditto.
128
        (WebCore::rightClipToWordBuffer): Ditto.
129
        (WebCore::leftTruncateToBuffer): Ditto.
130
        (WebCore::truncateString): Ditto.
131
132
        * platform/graphics/TextRun.h:
133
        (WebCore::TextRun::TextRun): Use characters16 in the 16-bit code path.
134
135
        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
136
        (WebCore::MediaPlayerPrivateAVFoundationObjC::shouldWaitForLoadingOfResource):
137
        Use StringView::upconvertedCharacters.
138
139
        * platform/network/DataURL.cpp:
140
        (WebCore::handleDataURL): Use StringView to call TextEncoding::encode.
141
        * platform/network/FormDataBuilder.cpp:
142
        (WebCore::FormDataBuilder::addFilenameToMultiPartHeader): Ditto.
143
144
        * platform/sql/SQLiteStatement.cpp:
145
        (WebCore::SQLiteStatement::bindBlob): Use StringView::upconvertedCharacters.
146
        (WebCore::SQLiteStatement::bindText): Ditto.
147
148
        * platform/text/DecodeEscapeSequences.h:
149
        (WebCore::Unicode16BitEscapeSequence::decodeRun): Changed to take a StringView.
150
        (WebCore::URLEscapeSequence::decodeRun): Ditto.
151
        (WebCore::decodeEscapeSequences): Pass StringView to decodeRun.
152
153
        * platform/text/Hyphenation.cpp:
154
        (WebCore::lastHyphenLocation): Take a StringView.
155
        * platform/text/Hyphenation.h: Make lastHyphenLocation take a StringView.
156
157
        * platform/text/TextBreakIterator.cpp:
158
        (WebCore::initializeIteratorWithRules): Use StringView::upconvertedCharacters.
159
160
        * platform/text/TextEncoding.cpp:
161
        (WebCore::TextEncoding::encode): Use StringView::upconvertedCharacters.
162
        Change argument type to StringView.
163
        * platform/text/TextEncoding.h: Ditto.
164
165
        * platform/text/TextEncodingRegistry.cpp:
166
        (WebCore::atomicCanonicalTextEncodingName): Use characters16 for the 16-bit path.
167
168
        * platform/text/cf/HyphenationCF.cpp:
169
        (WebCore::lastHyphenLocation): Use StringView::text.createCFStringWithoutCopying.
170
        Change argument type to StringView.
171
172
        * rendering/RenderBlock.cpp:
173
        (WebCore::RenderBlock::constructTextRun): Use characters16 for the 16-bit path.
174
175
        * rendering/RenderCombineText.cpp:
176
        (WebCore::RenderCombineText::width): Removed check for null characters pointer,
177
        since the pointer will never be null, and even if it was there would be no need
178
        for an early exit.
179
180
        * rendering/RenderText.cpp:
181
        (WebCore::maxWordFragmentWidth): Take a StringView.
182
        (WebCore::RenderText::computePreferredLogicalWidths): Pass in a StringView.
183
        * rendering/line/BreakingContextInlineHeaders.h:
184
        (WebCore::tryHyphenating): Ditto.
185
186
        * rendering/svg/SVGTextLayoutEngine.cpp:
187
        (WebCore::SVGTextLayoutEngine::layoutTextOnLineOrPath): Use
188
        StringView::upconvertedCharacters.
189
190
        * rendering/svg/SVGTextMetrics.cpp:
191
        (WebCore::SVGTextMetrics::SVGTextMetrics): Use String::substring.
192
193
        * svg/SVGAngle.cpp:
194
        (WebCore::SVGAngle::setValueAsString): Use StringView::upconvertedCharacters.
195
        * svg/SVGAnimateMotionElement.cpp:
196
        (WebCore::parsePoint): Ditto.
197
        * svg/SVGAnimationElement.cpp:
198
        (WebCore::parseKeySplines): Ditto.
199
        * svg/SVGFitToViewBox.cpp:
200
        (WebCore::SVGFitToViewBox::parseViewBox): Ditto.
201
202
        * svg/SVGFontData.cpp:
203
        (WebCore::SVGFontData::applySVGGlyphSelection): Pass StringView to
204
        createStringWIthMirroredCharacters.
205
        (WebCore::createStringWithMirroredCharacters): Changed to use StringView and
206
        use indexing into that instead of a characters pointer.
207
208
        * svg/SVGFontData.h: Removed createStringWithMirroredCharacters member function,
209
        since it has nothing to do with the SVGFontData object. Now it's just a private
210
        helper function in the SVGFontData.cpp source file.
211
212
        * svg/SVGFontElement.cpp:
213
        (WebCore::SVGFontElement::registerLigaturesInGlyphCache): Index into the string
214
        instead of using deprecatedCharacters.
215
216
        * svg/SVGGlyphMap.h:
217
        (WebCore::SVGGlyphMap::addGlyph): Use StringView::upconvertedCharacters.
218
        (WebCore::SVGGlyphMap::collectGlyphsForString): Ditto.
219
        * svg/SVGGlyphRefElement.cpp:
220
        (WebCore::SVGGlyphRefElement::parseAttribute): Ditto.
221
        * svg/SVGLength.cpp:
222
        (WebCore::SVGLength::setValueAsString): Ditto.
223
        * svg/SVGLengthList.cpp:
224
        (WebCore::SVGLengthList::parse): Ditto.
225
        * svg/SVGNumberList.cpp:
226
        (WebCore::SVGNumberList::parse): Ditto.
227
        * svg/SVGParserUtilities.cpp:
228
        (WebCore::parseNumberFromString): Ditto.
229
        (WebCore::parseNumberOptionalNumber): Ditto.
230
        (WebCore::parseRect): Ditto.
231
        (WebCore::pointsListFromSVGData): Ditto.
232
        (WebCore::parseGlyphName): Ditto.
233
        (WebCore::parseKerningUnicodeString): Ditto.
234
        (WebCore::parseDelimitedString): Ditto.
235
        * svg/SVGPreserveAspectRatio.cpp:
236
        (WebCore::SVGPreserveAspectRatio::parse): Ditto.
237
        * svg/SVGStringList.cpp:
238
        (WebCore::SVGStringList::parse): Ditto.
239
        * svg/SVGTransformList.cpp:
240
        (WebCore::SVGTransformList::parse): Ditto.
241
        * svg/SVGTransformable.cpp:
242
        (WebCore::SVGTransformable::parseTransformType): Ditto.
243
        * svg/SVGViewSpec.cpp:
244
        (WebCore::SVGViewSpec::parseViewSpec): Ditto.
245
        * svg/SVGZoomAndPan.h:
246
        (WebCore::SVGZoomAndPan::parseAttribute): Ditto.
247
248
        * xml/XMLHttpRequest.cpp:
249
        (WebCore::XMLHttpRequest::send): Pass a StringView to TextEncoding::encode.
250
251
        * xml/XSLStyleSheetLibxslt.cpp:
252
        (WebCore::XSLStyleSheet::parseString): Use StringView::upconvertedCharacters.
253
1
2014-03-18  Philippe Normand  <pnormand@igalia.com>
254
2014-03-18  Philippe Normand  <pnormand@igalia.com>
2
255
3
        [GTK] ResourceLoaderSoup.cpp was added by mistake
256
        [GTK] ResourceLoaderSoup.cpp was added by mistake
- a/Source/WTF/WTF.vcxproj/WTF.vcxproj +1 lines
Lines 129-134 a/Source/WTF/WTF.vcxproj/WTF.vcxproj_sec1
129
    <ClCompile Include="..\wtf\text\cf\AtomicStringCF.cpp" />
129
    <ClCompile Include="..\wtf\text\cf\AtomicStringCF.cpp" />
130
    <ClCompile Include="..\wtf\text\cf\StringCF.cpp" />
130
    <ClCompile Include="..\wtf\text\cf\StringCF.cpp" />
131
    <ClCompile Include="..\wtf\text\cf\StringImplCF.cpp" />
131
    <ClCompile Include="..\wtf\text\cf\StringImplCF.cpp" />
132
    <ClCompile Include="..\wtf\text\cf\StringViewCF.cpp" />
132
    <ClCompile Include="..\wtf\Threading.cpp" />
133
    <ClCompile Include="..\wtf\Threading.cpp" />
133
    <ClCompile Include="..\wtf\ThreadingWin.cpp" />
134
    <ClCompile Include="..\wtf\ThreadingWin.cpp" />
134
    <ClCompile Include="..\wtf\threadspecificWin.cpp" />
135
    <ClCompile Include="..\wtf\threadspecificWin.cpp" />
- a/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters -3 / +6 lines
Lines 84-89 a/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters_sec1
84
    <ClCompile Include="..\wtf\text\cf\StringCF.cpp">
84
    <ClCompile Include="..\wtf\text\cf\StringCF.cpp">
85
      <Filter>text</Filter>
85
      <Filter>text</Filter>
86
    </ClCompile>
86
    </ClCompile>
87
    <ClCompile Include="..\wtf\text\cf\StringImplCF.cpp">
88
      <Filter>text</Filter>
89
    </ClCompile>
90
    <ClCompile Include="..\wtf\text\cf\StringViewCF.cpp">
91
      <Filter>text</Filter>
92
    </ClCompile>
87
    <ClCompile Include="..\wtf\win\MainThreadWin.cpp">
93
    <ClCompile Include="..\wtf\win\MainThreadWin.cpp">
88
      <Filter>win</Filter>
94
      <Filter>win</Filter>
89
    </ClCompile>
95
    </ClCompile>
Lines 237-245 a/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters_sec2
237
    <ClCompile Include="..\wtf\win\RunLoopWin.cpp">
243
    <ClCompile Include="..\wtf\win\RunLoopWin.cpp">
238
      <Filter>win</Filter>
244
      <Filter>win</Filter>
239
    </ClCompile>
245
    </ClCompile>
240
    <ClCompile Include="..\wtf\text\cf\StringImplCF.cpp">
241
      <Filter>text</Filter>
242
    </ClCompile>
243
    <ClCompile Include="..\wtf\FastBitVector.cpp" />
246
    <ClCompile Include="..\wtf\FastBitVector.cpp" />
244
  </ItemGroup>
247
  </ItemGroup>
245
  <ItemGroup>
248
  <ItemGroup>
- a/Source/WTF/wtf/text/WTFString.h -1 / +1 lines
Lines 66-72 intptr_t charactersToIntPtr(const UChar*, size_t, bool* ok = 0); // ignores trai a/Source/WTF/wtf/text/WTFString.h_sec1
66
// It would be better if these were more consistent with the above functions instead.
66
// It would be better if these were more consistent with the above functions instead.
67
WTF_EXPORT_STRING_API double charactersToDouble(const LChar*, size_t, bool* ok = 0);
67
WTF_EXPORT_STRING_API double charactersToDouble(const LChar*, size_t, bool* ok = 0);
68
WTF_EXPORT_STRING_API double charactersToDouble(const UChar*, size_t, bool* ok = 0);
68
WTF_EXPORT_STRING_API double charactersToDouble(const UChar*, size_t, bool* ok = 0);
69
float charactersToFloat(const LChar*, size_t, bool* ok = 0);
69
WTF_EXPORT_STRING_API float charactersToFloat(const LChar*, size_t, bool* ok = 0);
70
WTF_EXPORT_STRING_API float charactersToFloat(const UChar*, size_t, bool* ok = 0);
70
WTF_EXPORT_STRING_API float charactersToFloat(const UChar*, size_t, bool* ok = 0);
71
WTF_EXPORT_STRING_API float charactersToFloat(const LChar*, size_t, size_t& parsedLength);
71
WTF_EXPORT_STRING_API float charactersToFloat(const LChar*, size_t, size_t& parsedLength);
72
WTF_EXPORT_STRING_API float charactersToFloat(const UChar*, size_t, size_t& parsedLength);
72
WTF_EXPORT_STRING_API float charactersToFloat(const UChar*, size_t, size_t& parsedLength);
- a/Source/WTF/wtf/text/cf/StringViewCF.cpp -4 / +9 lines
Lines 23-32 a/Source/WTF/wtf/text/cf/StringViewCF.cpp_sec1
23
 * THE POSSIBILITY OF SUCH DAMAGE.
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
24
 */
25
25
26
#import "config.h"
26
#include "config.h"
27
#import "StringView.h"
27
#include <wtf/text/StringView.h>
28
28
29
#import "RetainPtr.h"
29
#if USE(CF)
30
31
#include <CoreFoundation/CoreFoundation.h>
32
#include <wtf/RetainPtr.h>
30
33
31
namespace WTF {
34
namespace WTF {
32
35
Lines 35-41 RetainPtr<CFStringRef> StringView::createCFStringWithoutCopying() const a/Source/WTF/wtf/text/cf/StringViewCF.cpp_sec2
35
    if (is8Bit())
38
    if (is8Bit())
36
        return adoptCF(CFStringCreateWithBytesNoCopy(kCFAllocatorDefault, characters8(), length(), kCFStringEncodingISOLatin1, false, kCFAllocatorNull));
39
        return adoptCF(CFStringCreateWithBytesNoCopy(kCFAllocatorDefault, characters8(), length(), kCFStringEncodingISOLatin1, false, kCFAllocatorNull));
37
40
38
    return adoptCF(CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, characters16(), length(), kCFAllocatorNull));
41
    return adoptCF(CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, reinterpret_cast<const UniChar*>(characters16()), length(), kCFAllocatorNull));
39
}
42
}
40
43
41
}
44
}
45
46
#endif // USE(CF)
- a/Source/WebCore/Modules/indexeddb/IDBKeyPath.cpp -15 / +14 lines
Lines 45-52 public: a/Source/WebCore/Modules/indexeddb/IDBKeyPath.cpp_sec1
45
45
46
    explicit IDBKeyPathLexer(const String& s)
46
    explicit IDBKeyPathLexer(const String& s)
47
        : m_string(s)
47
        : m_string(s)
48
        , m_ptr(s.deprecatedCharacters())
48
        , m_remainingText(s)
49
        , m_end(s.deprecatedCharacters() + s.length())
50
        , m_currentTokenType(TokenError)
49
        , m_currentTokenType(TokenError)
51
    {
50
    {
52
    }
51
    }
Lines 64-86 public: a/Source/WebCore/Modules/indexeddb/IDBKeyPath.cpp_sec2
64
private:
63
private:
65
    TokenType lex(String&);
64
    TokenType lex(String&);
66
    TokenType lexIdentifier(String&);
65
    TokenType lexIdentifier(String&);
66
67
    String m_currentElement;
67
    String m_currentElement;
68
    String m_string;
68
    const String m_string;
69
    const UChar* m_ptr;
69
    StringView m_remainingText;
70
    const UChar* m_end;
71
    TokenType m_currentTokenType;
70
    TokenType m_currentTokenType;
72
};
71
};
73
72
74
IDBKeyPathLexer::TokenType IDBKeyPathLexer::lex(String& element)
73
IDBKeyPathLexer::TokenType IDBKeyPathLexer::lex(String& element)
75
{
74
{
76
    if (m_ptr >= m_end)
75
    if (m_remainingText.isEmpty())
77
        return TokenEnd;
76
        return TokenEnd;
78
    ASSERT_WITH_SECURITY_IMPLICATION(m_ptr < m_end);
79
77
80
    if (*m_ptr == '.') {
78
    if (m_remainingText[0] == '.') {
81
        ++m_ptr;
79
        m_remainingText = m_remainingText.substring(1);
82
        return TokenDot;
80
        return TokenDot;
83
    }
81
    }
82
84
    return lexIdentifier(element);
83
    return lexIdentifier(element);
85
}
84
}
86
85
Lines 108-123 static inline bool isIdentifierCharacter(UChar c) a/Source/WebCore/Modules/indexeddb/IDBKeyPath.cpp_sec3
108
107
109
IDBKeyPathLexer::TokenType IDBKeyPathLexer::lexIdentifier(String& element)
108
IDBKeyPathLexer::TokenType IDBKeyPathLexer::lexIdentifier(String& element)
110
{
109
{
111
    const UChar* start = m_ptr;
110
    StringView start = m_remainingText;
112
    if (m_ptr < m_end && isIdentifierStartCharacter(*m_ptr))
111
    if (!m_remainingText.isEmpty() && isIdentifierStartCharacter(m_remainingText[0]))
113
        ++m_ptr;
112
        m_remainingText = m_remainingText.substring(1);
114
    else
113
    else
115
        return TokenError;
114
        return TokenError;
116
115
117
    while (m_ptr < m_end && isIdentifierCharacter(*m_ptr))
116
    while (!m_remainingText.isEmpty() && isIdentifierCharacter(m_remainingText[0]))
118
        ++m_ptr;
117
        m_remainingText = m_remainingText.substring(1);
119
118
120
    element = String(start, m_ptr - start);
119
    element = start.substring(0, start.length() - m_remainingText.length()).toString();
121
    return TokenIdentifier;
120
    return TokenIdentifier;
122
}
121
}
123
122
- a/Source/WebCore/Modules/indexeddb/leveldb/IDBLevelDBCoding.cpp -2 / +1 lines
Lines 297-306 Vector<char> encodeString(const String& s) a/Source/WebCore/Modules/indexeddb/leveldb/IDBLevelDBCoding.cpp_sec1
297
    size_t length = s.length();
297
    size_t length = s.length();
298
    Vector<char> ret(length * sizeof(UChar));
298
    Vector<char> ret(length * sizeof(UChar));
299
299
300
    const UChar* src = s.deprecatedCharacters();
301
    UChar* dst = reinterpret_cast<UChar*>(ret.data());
300
    UChar* dst = reinterpret_cast<UChar*>(ret.data());
302
    for (unsigned i = 0; i < length; ++i)
301
    for (unsigned i = 0; i < length; ++i)
303
        *dst++ = htons(*src++);
302
        *dst++ = htons(s[i]);
304
303
305
    return ret;
304
    return ret;
306
}
305
}
- a/Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp -4 / +3 lines
Lines 38-43 a/Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp_sec1
38
#include "WebSocketChannelClient.h"
38
#include "WebSocketChannelClient.h"
39
#include <wtf/PassRefPtr.h>
39
#include <wtf/PassRefPtr.h>
40
#include <wtf/RefPtr.h>
40
#include <wtf/RefPtr.h>
41
#include <wtf/text/StringView.h>
41
42
42
namespace WebCore {
43
namespace WebCore {
43
44
Lines 110-117 void ThreadableWebSocketChannelClientWrapper::setSubprotocol(const String& subpr a/Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp_sec2
110
{
111
{
111
    unsigned length = subprotocol.length();
112
    unsigned length = subprotocol.length();
112
    m_subprotocol.resize(length);
113
    m_subprotocol.resize(length);
113
    if (length)
114
    StringView(subprotocol).getCharactersWithUpconvert(m_subprotocol.data());
114
        memcpy(m_subprotocol.data(), subprotocol.deprecatedCharacters(), sizeof(UChar) * length);
115
}
115
}
116
116
117
String ThreadableWebSocketChannelClientWrapper::extensions() const
117
String ThreadableWebSocketChannelClientWrapper::extensions() const
Lines 125-132 void ThreadableWebSocketChannelClientWrapper::setExtensions(const String& extens a/Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp_sec3
125
{
125
{
126
    unsigned length = extensions.length();
126
    unsigned length = extensions.length();
127
    m_extensions.resize(length);
127
    m_extensions.resize(length);
128
    if (length)
128
    StringView(extensions).getCharactersWithUpconvert(m_extensions.data());
129
        memcpy(m_extensions.data(), extensions.deprecatedCharacters(), sizeof(UChar) * length);
130
}
129
}
131
130
132
ThreadableWebSocketChannel::SendResult ThreadableWebSocketChannelClientWrapper::sendRequestResult() const
131
ThreadableWebSocketChannel::SendResult ThreadableWebSocketChannelClientWrapper::sendRequestResult() const
- a/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm -1 / +1 lines
Lines 1660-1666 - (NSArray *)arrayOfTextForTextMarkers:(NSArray *)markers attributed:(BOOL)attri a/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm_sec1
1660
                String listMarkerText = m_object->listMarkerTextForNodeAndPosition(node, VisiblePosition(it.range()->startPosition())); 
1660
                String listMarkerText = m_object->listMarkerTextForNodeAndPosition(node, VisiblePosition(it.range()->startPosition())); 
1661
                
1661
                
1662
                if (!listMarkerText.isEmpty()) 
1662
                if (!listMarkerText.isEmpty()) 
1663
                    [array addObject:[NSString stringWithCharacters:listMarkerText.deprecatedCharacters() length:listMarkerText.length()]];
1663
                    [array addObject:listMarkerText];
1664
                // There was not an element representation, so just return the text.
1664
                // There was not an element representation, so just return the text.
1665
                [array addObject:it.text().createNSString().get()];
1665
                [array addObject:it.text().createNSString().get()];
1666
            }
1666
            }
- a/Source/WebCore/bindings/js/SerializedScriptValue.cpp -5 / +27 lines
Lines 447-452 template <typename T> static bool writeLittleEndian(Vector<uint8_t>& buffer, con a/Source/WebCore/bindings/js/SerializedScriptValue.cpp_sec1
447
    return true;
447
    return true;
448
}
448
}
449
449
450
static bool writeLittleEndianUInt16(Vector<uint8_t>& buffer, const LChar* values, uint32_t length)
451
{
452
    if (length > std::numeric_limits<uint32_t>::max() / 2)
453
        return false;
454
455
    for (unsigned i = 0; i < length; ++i) {
456
        buffer.append(values[i]);
457
        buffer.append(0);
458
    }
459
460
    return true;
461
}
462
450
template <> bool writeLittleEndian<uint8_t>(Vector<uint8_t>& buffer, const uint8_t* values, uint32_t length)
463
template <> bool writeLittleEndian<uint8_t>(Vector<uint8_t>& buffer, const uint8_t* values, uint32_t length)
451
{
464
{
452
    buffer.append(values, length);
465
    buffer.append(values, length);
Lines 472-478 public: a/Source/WebCore/bindings/js/SerializedScriptValue.cpp_sec2
472
        }
485
        }
473
        writeLittleEndian<uint8_t>(out, StringTag);
486
        writeLittleEndian<uint8_t>(out, StringTag);
474
        writeLittleEndian(out, s.length());
487
        writeLittleEndian(out, s.length());
475
        return writeLittleEndian(out, s.impl()->deprecatedCharacters(), s.length());
488
        if (s.is8Bit())
489
            return writeLittleEndianUInt16(out, s.characters8(), s.length());
490
        return writeLittleEndian(out, s.characters16(), s.length());
476
    }
491
    }
477
492
478
    static void serializeUndefined(Vector<uint8_t>& out)
493
    static void serializeUndefined(Vector<uint8_t>& out)
Lines 969-989 private: a/Source/WebCore/bindings/js/SerializedScriptValue.cpp_sec3
969
            return;
984
            return;
970
        }
985
        }
971
986
987
        unsigned length = str.length();
988
972
        // This condition is unlikely to happen as they would imply an ~8gb
989
        // This condition is unlikely to happen as they would imply an ~8gb
973
        // string but we should guard against it anyway
990
        // string but we should guard against it anyway
974
        if (str.length() >= StringPoolTag) {
991
        if (length >= StringPoolTag) {
975
            fail();
992
            fail();
976
            return;
993
            return;
977
        }
994
        }
978
995
979
        // Guard against overflow
996
        // Guard against overflow
980
        if (str.length() > (std::numeric_limits<uint32_t>::max() - sizeof(uint32_t)) / sizeof(UChar)) {
997
        if (length > (std::numeric_limits<uint32_t>::max() - sizeof(uint32_t)) / sizeof(UChar)) {
981
            fail();
998
            fail();
982
            return;
999
            return;
983
        }
1000
        }
984
1001
985
        writeLittleEndian<uint32_t>(m_buffer, str.length());
1002
        writeLittleEndian<uint32_t>(m_buffer, length);
986
        if (!writeLittleEndian<uint16_t>(m_buffer, reinterpret_cast<const uint16_t*>(str.deprecatedCharacters()), str.length()))
1003
        if (!length || str.is8Bit()) {
1004
            if (!writeLittleEndianUInt16(m_buffer, str.characters8(), length))
1005
                fail();
1006
            return;
1007
        }
1008
        if (!writeLittleEndian(m_buffer, str.characters16(), length))
987
            fail();
1009
            fail();
988
    }
1010
    }
989
1011
- a/Source/WebCore/bindings/objc/WebScriptObject.mm -5 / +2 lines
Lines 546-556 + (id)_convertValueToObjcValue:(JSC::JSValue)value originRootObject:(RootObject* a/Source/WebCore/bindings/objc/WebScriptObject.mm_sec1
546
        return [WebScriptObject scriptObjectForJSObject:toRef(object) originRootObject:originRootObject rootObject:rootObject];
546
        return [WebScriptObject scriptObjectForJSObject:toRef(object) originRootObject:originRootObject rootObject:rootObject];
547
    }
547
    }
548
548
549
    if (value.isString()) {
549
    if (value.isString())
550
        ExecState* exec = rootObject->globalObject()->globalExec();
550
        return asString(value)->value(rootObject->globalObject()->globalExec());
551
        const String& u = asString(value)->value(exec);
552
        return [NSString stringWithCharacters:u.deprecatedCharacters() length:u.length()];
553
    }
554
551
555
    if (value.isNumber())
552
    if (value.isNumber())
556
        return [NSNumber numberWithDouble:value.asNumber()];
553
        return [NSNumber numberWithDouble:value.asNumber()];
- a/Source/WebCore/dom/Document.cpp -2 / +1 lines
Lines 3972-3981 bool Document::parseQualifiedName(const String& qualifiedName, String& prefix, S a/Source/WebCore/dom/Document.cpp_sec1
3972
    bool sawColon = false;
3972
    bool sawColon = false;
3973
    int colonPos = 0;
3973
    int colonPos = 0;
3974
3974
3975
    const UChar* s = qualifiedName.deprecatedCharacters();
3976
    for (unsigned i = 0; i < length;) {
3975
    for (unsigned i = 0; i < length;) {
3977
        UChar32 c;
3976
        UChar32 c;
3978
        U16_NEXT(s, i, length, c)
3977
        U16_NEXT(qualifiedName, i, length, c)
3979
        if (c == ':') {
3978
        if (c == ':') {
3980
            if (sawColon) {
3979
            if (sawColon) {
3981
                ec = NAMESPACE_ERR;
3980
                ec = NAMESPACE_ERR;
- a/Source/WebCore/editing/CompositeEditCommand.cpp -1 / +1 lines
Lines 667-673 void CompositeEditCommand::setNodeAttribute(PassRefPtr<Element> element, const Q a/Source/WebCore/editing/CompositeEditCommand.cpp_sec1
667
static inline bool containsOnlyWhitespace(const String& text)
667
static inline bool containsOnlyWhitespace(const String& text)
668
{
668
{
669
    for (unsigned i = 0; i < text.length(); ++i) {
669
    for (unsigned i = 0; i < text.length(); ++i) {
670
        if (!isWhitespace(text.deprecatedCharacters()[i]))
670
        if (!isWhitespace(text[i]))
671
            return false;
671
            return false;
672
    }
672
    }
673
    
673
    
- a/Source/WebCore/editing/SmartReplace.cpp -5 / +4 lines
Lines 34-48 a/Source/WebCore/editing/SmartReplace.cpp_sec1
34
34
35
#include <unicode/uset.h>
35
#include <unicode/uset.h>
36
#include <wtf/Assertions.h>
36
#include <wtf/Assertions.h>
37
#include <wtf/text/WTFString.h>
37
#include <wtf/text/StringView.h>
38
38
39
namespace WebCore {
39
namespace WebCore {
40
40
41
static void addAllCodePoints(USet* smartSet, const String& string)
41
static void addAllCodePoints(USet* smartSet, const String& string)
42
{
42
{
43
    const UChar* characters = string.deprecatedCharacters();
44
    for (size_t i = 0; i < string.length(); i++)
43
    for (size_t i = 0; i < string.length(); i++)
45
        uset_add(smartSet, characters[i]);
44
        uset_add(smartSet, string[i]);
46
}
45
}
47
46
48
// This is mostly a port of the code in WebCore/editing/SmartReplaceCF.cpp
47
// This is mostly a port of the code in WebCore/editing/SmartReplaceCF.cpp
Lines 56-62 static USet* getSmartSet(bool isPreviousCharacter) a/Source/WebCore/editing/SmartReplace.cpp_sec2
56
        // Whitespace and newline (kCFCharacterSetWhitespaceAndNewline)
55
        // Whitespace and newline (kCFCharacterSetWhitespaceAndNewline)
57
        UErrorCode ec = U_ZERO_ERROR;
56
        UErrorCode ec = U_ZERO_ERROR;
58
        String whitespaceAndNewline = ASCIILiteral("[[:WSpace:] [\\u000A\\u000B\\u000C\\u000D\\u0085]]");
57
        String whitespaceAndNewline = ASCIILiteral("[[:WSpace:] [\\u000A\\u000B\\u000C\\u000D\\u0085]]");
59
        smartSet = uset_openPattern(whitespaceAndNewline.deprecatedCharacters(), whitespaceAndNewline.length(), &ec);
58
        smartSet = uset_openPattern(StringView(whitespaceAndNewline).upconvertedCharacters(), whitespaceAndNewline.length(), &ec);
60
        ASSERT(U_SUCCESS(ec));
59
        ASSERT(U_SUCCESS(ec));
61
60
62
        // CJK ranges
61
        // CJK ranges
Lines 83-89 static USet* getSmartSet(bool isPreviousCharacter) a/Source/WebCore/editing/SmartReplace.cpp_sec3
83
            // Punctuation (kCFCharacterSetPunctuation)
82
            // Punctuation (kCFCharacterSetPunctuation)
84
            UErrorCode ec = U_ZERO_ERROR;
83
            UErrorCode ec = U_ZERO_ERROR;
85
            String punctuationClass = ASCIILiteral("[:P:]");
84
            String punctuationClass = ASCIILiteral("[:P:]");
86
            USet* icuPunct = uset_openPattern(punctuationClass.deprecatedCharacters(), punctuationClass.length(), &ec);
85
            USet* icuPunct = uset_openPattern(StringView(punctuationClass).upconvertedCharacters(), punctuationClass.length(), &ec);
87
            ASSERT(U_SUCCESS(ec));
86
            ASSERT(U_SUCCESS(ec));
88
            uset_addAll(smartSet, icuPunct);
87
            uset_addAll(smartSet, icuPunct);
89
            uset_close(icuPunct);
88
            uset_close(icuPunct);
- a/Source/WebCore/editing/TextIterator.cpp -20 / +22 lines
Lines 92-98 private: a/Source/WebCore/editing/TextIterator.cpp_sec1
92
    bool isBadMatch(const UChar*, size_t length) const;
92
    bool isBadMatch(const UChar*, size_t length) const;
93
    bool isWordStartMatch(size_t start, size_t length) const;
93
    bool isWordStartMatch(size_t start, size_t length) const;
94
94
95
    String m_target;
95
    const String m_target;
96
    const StringView::UpconvertedCharacters m_targetCharacters;
96
    FindOptions m_options;
97
    FindOptions m_options;
97
98
98
    Vector<UChar> m_buffer;
99
    Vector<UChar> m_buffer;
Lines 101-107 private: a/Source/WebCore/editing/TextIterator.cpp_sec2
101
    bool m_atBreak;
102
    bool m_atBreak;
102
    bool m_needsMoreContext;
103
    bool m_needsMoreContext;
103
104
104
    bool m_targetRequiresKanaWorkaround;
105
    const bool m_targetRequiresKanaWorkaround;
105
    Vector<UChar> m_normalizedTarget;
106
    Vector<UChar> m_normalizedTarget;
106
    mutable Vector<UChar> m_normalizedMatch;
107
    mutable Vector<UChar> m_normalizedMatch;
107
108
Lines 1649-1665 static inline UChar foldQuoteMarkOrSoftHyphen(UChar c) a/Source/WebCore/editing/TextIterator.cpp_sec3
1649
    }
1650
    }
1650
}
1651
}
1651
1652
1652
static inline void foldQuoteMarksAndSoftHyphens(String& s)
1653
// FIXME: We'd like to tailor the searcher to fold quote marks for us instead
1654
// of doing it in a separate replacement pass here, but ICU doesn't offer a way
1655
// to add tailoring on top of the locale-specific tailoring as of this writing.
1656
static inline String foldQuoteMarksAndSoftHyphens(String string)
1653
{
1657
{
1654
    s.replace(hebrewPunctuationGeresh, '\'');
1658
    string.replace(hebrewPunctuationGeresh, '\'');
1655
    s.replace(hebrewPunctuationGershayim, '"');
1659
    string.replace(hebrewPunctuationGershayim, '"');
1656
    s.replace(leftDoubleQuotationMark, '"');
1660
    string.replace(leftDoubleQuotationMark, '"');
1657
    s.replace(leftSingleQuotationMark, '\'');
1661
    string.replace(leftSingleQuotationMark, '\'');
1658
    s.replace(rightDoubleQuotationMark, '"');
1662
    string.replace(rightDoubleQuotationMark, '"');
1659
    s.replace(rightSingleQuotationMark, '\'');
1663
    string.replace(rightSingleQuotationMark, '\'');
1660
    // Replace soft hyphen with an ignorable character so that their presence or absence will
1664
1661
    // not affect string comparison.
1665
    // Replace soft hyphens with an ignorable character so that presence or absence will not affect string comparison.
1662
    s.replace(softHyphen, 0);
1666
    string.replace(softHyphen, 0);
1667
1668
    return string;
1663
}
1669
}
1664
1670
1665
#if !UCONFIG_NO_COLLATION
1671
#if !UCONFIG_NO_COLLATION
Lines 1943-1949 static inline bool isSeparator(UChar32 character) a/Source/WebCore/editing/TextIterator.cpp_sec4
1943
}
1949
}
1944
1950
1945
inline SearchBuffer::SearchBuffer(const String& target, FindOptions options)
1951
inline SearchBuffer::SearchBuffer(const String& target, FindOptions options)
1946
    : m_target(target)
1952
    : m_target(foldQuoteMarksAndSoftHyphens(target))
1953
    , m_targetCharacters(StringView(m_target).upconvertedCharacters())
1947
    , m_options(options)
1954
    , m_options(options)
1948
    , m_prefixLength(0)
1955
    , m_prefixLength(0)
1949
    , m_atBreak(true)
1956
    , m_atBreak(true)
Lines 1952-1962 inline SearchBuffer::SearchBuffer(const String& target, FindOptions options) a/Source/WebCore/editing/TextIterator.cpp_sec5
1952
{
1959
{
1953
    ASSERT(!m_target.isEmpty());
1960
    ASSERT(!m_target.isEmpty());
1954
1961
1955
    // FIXME: We'd like to tailor the searcher to fold quote marks for us instead
1956
    // of doing it in a separate replacement pass here, but ICU doesn't offer a way
1957
    // to add tailoring on top of the locale-specific tailoring as of this writing.
1958
    foldQuoteMarksAndSoftHyphens(m_target);
1959
1960
    size_t targetLength = m_target.length();
1962
    size_t targetLength = m_target.length();
1961
    m_buffer.reserveInitialCapacity(std::max(targetLength * 8, minimumSearchBufferSize));
1963
    m_buffer.reserveInitialCapacity(std::max(targetLength * 8, minimumSearchBufferSize));
1962
    m_overlap = m_buffer.capacity() / 4;
1964
    m_overlap = m_buffer.capacity() / 4;
Lines 2000-2011 inline SearchBuffer::SearchBuffer(const String& target, FindOptions options) a/Source/WebCore/editing/TextIterator.cpp_sec6
2000
    usearch_setAttribute(searcher, USEARCH_ELEMENT_COMPARISON, comparator, &status);
2002
    usearch_setAttribute(searcher, USEARCH_ELEMENT_COMPARISON, comparator, &status);
2001
    ASSERT(status == U_ZERO_ERROR);
2003
    ASSERT(status == U_ZERO_ERROR);
2002
2004
2003
    usearch_setPattern(searcher, m_target.deprecatedCharacters(), targetLength, &status);
2005
    usearch_setPattern(searcher, m_targetCharacters, targetLength, &status);
2004
    ASSERT(status == U_ZERO_ERROR);
2006
    ASSERT(status == U_ZERO_ERROR);
2005
2007
2006
    // The kana workaround requires a normalized copy of the target string.
2008
    // The kana workaround requires a normalized copy of the target string.
2007
    if (m_targetRequiresKanaWorkaround)
2009
    if (m_targetRequiresKanaWorkaround)
2008
        normalizeCharacters(m_target.deprecatedCharacters(), m_target.length(), m_normalizedTarget);
2010
        normalizeCharacters(m_targetCharacters, targetLength, m_normalizedTarget);
2009
}
2011
}
2010
2012
2011
inline SearchBuffer::~SearchBuffer()
2013
inline SearchBuffer::~SearchBuffer()
- a/Source/WebCore/editing/TypingCommand.cpp -1 / +1 lines
Lines 155-161 void TypingCommand::insertText(Document& document, const String& text, Options o a/Source/WebCore/editing/TypingCommand.cpp_sec1
155
    ASSERT(frame);
155
    ASSERT(frame);
156
156
157
    if (!text.isEmpty())
157
    if (!text.isEmpty())
158
        frame->editor().updateMarkersForWordsAffectedByEditing(isSpaceOrNewline(text.deprecatedCharacters()[0]));
158
        frame->editor().updateMarkersForWordsAffectedByEditing(isSpaceOrNewline(text[0]));
159
    
159
    
160
    insertText(document, text, frame->selection().selection(), options, composition);
160
    insertText(document, text, frame->selection().selection(), options, composition);
161
}
161
}
- a/Source/WebCore/editing/VisiblePosition.cpp -2 / +1 lines
Lines 590-597 UChar32 VisiblePosition::characterAfter() const a/Source/WebCore/editing/VisiblePosition.cpp_sec1
590
        return 0;
590
        return 0;
591
591
592
    UChar32 ch;
592
    UChar32 ch;
593
    const UChar* characters = textNode->data().deprecatedCharacters();
593
    U16_NEXT(textNode->data(), offset, length, ch);
594
    U16_NEXT(characters, offset, length, ch);
595
    return ch;
594
    return ch;
596
}
595
}
597
596
- a/Source/WebCore/editing/VisibleUnits.cpp -6 / +6 lines
Lines 1155-1167 VisiblePosition startOfParagraph(const VisiblePosition& c, EditingBoundaryCrossi a/Source/WebCore/editing/VisibleUnits.cpp_sec1
1155
            ASSERT_WITH_SECURITY_IMPLICATION(n->isTextNode());
1155
            ASSERT_WITH_SECURITY_IMPLICATION(n->isTextNode());
1156
            type = Position::PositionIsOffsetInAnchor;
1156
            type = Position::PositionIsOffsetInAnchor;
1157
            if (style.preserveNewline()) {
1157
            if (style.preserveNewline()) {
1158
                const UChar* chars = toRenderText(r)->deprecatedCharacters();
1158
                StringImpl& text = *toRenderText(r)->text();
1159
                int i = toRenderText(r)->textLength();
1159
                int i = text.length();
1160
                int o = offset;
1160
                int o = offset;
1161
                if (n == startNode && o < i)
1161
                if (n == startNode && o < i)
1162
                    i = std::max(0, o);
1162
                    i = std::max(0, o);
1163
                while (--i >= 0) {
1163
                while (--i >= 0) {
1164
                    if (chars[i] == '\n')
1164
                    if (text[i] == '\n')
1165
                        return VisiblePosition(Position(toText(n), i + 1), DOWNSTREAM);
1165
                        return VisiblePosition(Position(toText(n), i + 1), DOWNSTREAM);
1166
                }
1166
                }
1167
            }
1167
            }
Lines 1236-1248 VisiblePosition endOfParagraph(const VisiblePosition& c, EditingBoundaryCrossing a/Source/WebCore/editing/VisibleUnits.cpp_sec2
1236
        // FIXME: We avoid returning a position where the renderer can't accept the caret.
1236
        // FIXME: We avoid returning a position where the renderer can't accept the caret.
1237
        if (r->isText() && toRenderText(r)->hasRenderedText()) {
1237
        if (r->isText() && toRenderText(r)->hasRenderedText()) {
1238
            ASSERT_WITH_SECURITY_IMPLICATION(n->isTextNode());
1238
            ASSERT_WITH_SECURITY_IMPLICATION(n->isTextNode());
1239
            int length = toRenderText(r)->textLength();
1240
            type = Position::PositionIsOffsetInAnchor;
1239
            type = Position::PositionIsOffsetInAnchor;
1241
            if (style.preserveNewline()) {
1240
            if (style.preserveNewline()) {
1242
                const UChar* chars = toRenderText(r)->deprecatedCharacters();
1241
                StringImpl& text = *toRenderText(r)->text();
1243
                int o = n == startNode ? offset : 0;
1242
                int o = n == startNode ? offset : 0;
1243
                int length = text.length();
1244
                for (int i = o; i < length; ++i) {
1244
                for (int i = o; i < length; ++i) {
1245
                    if (chars[i] == '\n')
1245
                    if (text[i] == '\n')
1246
                        return VisiblePosition(Position(toText(n), i), DOWNSTREAM);
1246
                        return VisiblePosition(Position(toText(n), i), DOWNSTREAM);
1247
                }
1247
                }
1248
            }
1248
            }
- a/Source/WebCore/fileapi/WebKitBlobBuilder.cpp -1 / +2 lines
Lines 44-49 a/Source/WebCore/fileapi/WebKitBlobBuilder.cpp_sec1
44
#include <wtf/Vector.h>
44
#include <wtf/Vector.h>
45
#include <wtf/text/AtomicString.h>
45
#include <wtf/text/AtomicString.h>
46
#include <wtf/text/CString.h>
46
#include <wtf/text/CString.h>
47
#include <wtf/text/StringView.h>
47
48
48
namespace WebCore {
49
namespace WebCore {
49
50
Lines 71-77 Vector<char>& BlobBuilder::getBuffer() a/Source/WebCore/fileapi/WebKitBlobBuilder.cpp_sec2
71
72
72
void BlobBuilder::append(const String& text, const String& endingType)
73
void BlobBuilder::append(const String& text, const String& endingType)
73
{
74
{
74
    CString utf8Text = UTF8Encoding().encode(text.deprecatedCharacters(), text.length(), EntitiesForUnencodables);
75
    CString utf8Text = UTF8Encoding().encode(text, EntitiesForUnencodables);
75
76
76
    Vector<char>& buffer = getBuffer();
77
    Vector<char>& buffer = getBuffer();
77
    size_t oldSize = buffer.size();
78
    size_t oldSize = buffer.size();
- a/Source/WebCore/html/BaseDateAndTimeInputType.cpp -1 / +1 lines
Lines 108-114 bool BaseDateAndTimeInputType::parseToDateComponents(const String& source, DateC a/Source/WebCore/html/BaseDateAndTimeInputType.cpp_sec1
108
    DateComponents ignoredResult;
108
    DateComponents ignoredResult;
109
    if (!out)
109
    if (!out)
110
        out = &ignoredResult;
110
        out = &ignoredResult;
111
    return parseToDateComponentsInternal(source.deprecatedCharacters(), source.length(), out);
111
    return parseToDateComponentsInternal(source.upconvertedCharacters(), source.length(), out);
112
}
112
}
113
113
114
String BaseDateAndTimeInputType::serialize(const Decimal& value) const
114
String BaseDateAndTimeInputType::serialize(const Decimal& value) const
- a/Source/WebCore/html/FormDataList.cpp -1 / +2 lines
Lines 22-27 a/Source/WebCore/html/FormDataList.cpp_sec1
22
#include "FormDataList.h"
22
#include "FormDataList.h"
23
23
24
#include "LineEnding.h"
24
#include "LineEnding.h"
25
#include <wtf/text/StringView.h>
25
26
26
namespace WebCore {
27
namespace WebCore {
27
28
Lines 32-38 FormDataList::FormDataList(const TextEncoding& c) a/Source/WebCore/html/FormDataList.cpp_sec2
32
33
33
void FormDataList::appendString(const String& s)
34
void FormDataList::appendString(const String& s)
34
{
35
{
35
    CString cstr = m_encoding.encode(s.deprecatedCharacters(), s.length(), EntitiesForUnencodables);
36
    CString cstr = m_encoding.encode(s, EntitiesForUnencodables);
36
    m_items.append(normalizeLineEndingsToCRLF(cstr));
37
    m_items.append(normalizeLineEndingsToCRLF(cstr));
37
}
38
}
38
39
- a/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp -1 / +1 lines
Lines 2167-2173 static void normalizeSpaces(String& text) a/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp_sec1
2167
2167
2168
    unsigned textLength = text.length();
2168
    unsigned textLength = text.length();
2169
    Vector<UChar> charVector(textLength);
2169
    Vector<UChar> charVector(textLength);
2170
    memcpy(charVector.data(), text.deprecatedCharacters(), textLength * sizeof(UChar));
2170
    StringView(text).getCharactersWithUpconvert(charVector.data());
2171
2171
2172
    charVector[i++] = ' ';
2172
    charVector[i++] = ' ';
2173
2173
- a/Source/WebCore/html/parser/HTMLParserIdioms.cpp -4 / +7 lines
Lines 71-77 String stripLeadingAndTrailingHTMLSpaces(const String& string) a/Source/WebCore/html/parser/HTMLParserIdioms.cpp_sec1
71
    if (string.is8Bit())
71
    if (string.is8Bit())
72
        return stripLeadingAndTrailingHTMLSpaces(string, string.characters8(), length);
72
        return stripLeadingAndTrailingHTMLSpaces(string, string.characters8(), length);
73
73
74
    return stripLeadingAndTrailingHTMLSpaces(string, string.deprecatedCharacters(), length);
74
    return stripLeadingAndTrailingHTMLSpaces(string, string.characters16(), length);
75
}
75
}
76
76
77
String serializeForNumberType(const Decimal& number)
77
String serializeForNumberType(const Decimal& number)
Lines 267-278 bool parseHTMLNonNegativeInteger(const String& input, unsigned& value) a/Source/WebCore/html/parser/HTMLParserIdioms.cpp_sec2
267
    // Step 1
267
    // Step 1
268
    // Step 2
268
    // Step 2
269
    unsigned length = input.length();
269
    unsigned length = input.length();
270
    if (length && input.is8Bit()) {
270
    if (!length || input.is8Bit()) {
271
        const LChar* start = input.characters8();
271
        const LChar* start = input.characters8();
272
        return parseHTMLNonNegativeIntegerInternal(start, start + length, value);
272
        return parseHTMLNonNegativeIntegerInternal(start, start + length, value);
273
    }
273
    }
274
    
274
    
275
    const UChar* start = input.deprecatedCharacters();
275
    const UChar* start = input.characters16();
276
    return parseHTMLNonNegativeIntegerInternal(start, start + length, value);
276
    return parseHTMLNonNegativeIntegerInternal(start, start + length, value);
277
}
277
}
278
278
Lines 326-332 static bool parseDescriptors(const String& attribute, size_t start, size_t end, a/Source/WebCore/html/parser/HTMLParserIdioms.cpp_sec3
326
        if (isFoundScaleFactor)
326
        if (isFoundScaleFactor)
327
            return false;
327
            return false;
328
328
329
        imageScaleFactor = charactersToFloat(attribute.deprecatedCharacters() + descriptorStart, descriptorEnd - descriptorStart, &isValid);
329
        if (attribute.is8Bit())
330
            imageScaleFactor = charactersToFloat(attribute.characters8() + descriptorStart, descriptorEnd - descriptorStart, &isValid);
331
        else
332
            imageScaleFactor = charactersToFloat(attribute.characters16() + descriptorStart, descriptorEnd - descriptorStart, &isValid);
330
        isFoundScaleFactor = true;
333
        isFoundScaleFactor = true;
331
    }
334
    }
332
335
- a/Source/WebCore/inspector/InspectorStyleSheet.cpp -2 / +1 lines
Lines 712-725 NewLineAndWhitespace& InspectorStyle::newLineAndWhitespaceDelimiters() const a/Source/WebCore/inspector/InspectorStyleSheet.cpp_sec1
712
    int propertyIndex = 0;
712
    int propertyIndex = 0;
713
    bool isFullPrefixScanned = false;
713
    bool isFullPrefixScanned = false;
714
    bool lineFeedTerminated = false;
714
    bool lineFeedTerminated = false;
715
    const UChar* characters = text.deprecatedCharacters();
716
    while (propertyIndex < propertyCount) {
715
    while (propertyIndex < propertyCount) {
717
        const WebCore::CSSPropertySourceData& currentProperty = sourcePropertyData->at(propertyIndex++);
716
        const WebCore::CSSPropertySourceData& currentProperty = sourcePropertyData->at(propertyIndex++);
718
717
719
        bool processNextProperty = false;
718
        bool processNextProperty = false;
720
        int scanEnd = currentProperty.range.start;
719
        int scanEnd = currentProperty.range.start;
721
        for (int i = scanStart; i < scanEnd; ++i) {
720
        for (int i = scanStart; i < scanEnd; ++i) {
722
            UChar ch = characters[i];
721
            UChar ch = text[i];
723
            bool isLineFeed = isHTMLLineBreak(ch);
722
            bool isLineFeed = isHTMLLineBreak(ch);
724
            if (isLineFeed) {
723
            if (isLineFeed) {
725
                if (!lineFeedTerminated)
724
                if (!lineFeedTerminated)
- a/Source/WebCore/inspector/InspectorStyleTextEditor.cpp -8 / +5 lines
Lines 82-93 void InspectorStyleTextEditor::insertProperty(unsigned index, const String& prop a/Source/WebCore/inspector/InspectorStyleTextEditor.cpp_sec1
82
    if (insertLast && !insertFirstInSource) {
82
    if (insertLast && !insertFirstInSource) {
83
        propertyStart = styleBodyLength;
83
        propertyStart = styleBodyLength;
84
        if (propertyStart && textToSet.length()) {
84
        if (propertyStart && textToSet.length()) {
85
            const UChar* characters = m_styleText.deprecatedCharacters();
86
87
            long curPos = propertyStart - 1; // The last position of style declaration, since propertyStart points past one.
85
            long curPos = propertyStart - 1; // The last position of style declaration, since propertyStart points past one.
88
            while (curPos && isHTMLSpace(characters[curPos]))
86
            while (curPos && isHTMLSpace(m_styleText[curPos]))
89
                --curPos;
87
                --curPos;
90
            if (curPos && characters[curPos] != ';') {
88
            if (curPos && m_styleText[curPos] != ';') {
91
                // Prepend a ";" to the property text if appending to a style declaration where
89
                // Prepend a ";" to the property text if appending to a style declaration where
92
                // the last property has no trailing ";".
90
                // the last property has no trailing ";".
93
                textToSet.insert(";", 0);
91
                textToSet.insert(";", 0);
Lines 230-236 void InspectorStyleTextEditor::internalReplaceProperty(const InspectorStylePrope a/Source/WebCore/inspector/InspectorStyleTextEditor.cpp_sec2
230
    const SourceRange& range = property.sourceData.range;
228
    const SourceRange& range = property.sourceData.range;
231
    long replaceRangeStart = range.start;
229
    long replaceRangeStart = range.start;
232
    long replaceRangeEnd = range.end;
230
    long replaceRangeEnd = range.end;
233
    const UChar* characters = m_styleText.deprecatedCharacters();
234
    long newTextLength = newText.length();
231
    long newTextLength = newText.length();
235
    String finalNewText = newText;
232
    String finalNewText = newText;
236
233
Lines 241-254 void InspectorStyleTextEditor::internalReplaceProperty(const InspectorStylePrope a/Source/WebCore/inspector/InspectorStyleTextEditor.cpp_sec3
241
        if (replaceRangeStart >= fullPrefixLength && m_styleText.substring(replaceRangeStart - fullPrefixLength, fullPrefixLength) == fullPrefix)
238
        if (replaceRangeStart >= fullPrefixLength && m_styleText.substring(replaceRangeStart - fullPrefixLength, fullPrefixLength) == fullPrefix)
242
            replaceRangeStart -= fullPrefixLength;
239
            replaceRangeStart -= fullPrefixLength;
243
    } else if (newTextLength) {
240
    } else if (newTextLength) {
244
        if (isHTMLLineBreak(newText.deprecatedCharacters()[newTextLength - 1])) {
241
        if (isHTMLLineBreak(newText[newTextLength - 1])) {
245
            // Coalesce newlines of the original and new property values (to avoid a lot of blank lines while incrementally applying property values).
242
            // Coalesce newlines of the original and new property values (to avoid a lot of blank lines while incrementally applying property values).
246
            bool foundNewline = false;
243
            bool foundNewline = false;
247
            bool isLastNewline = false;
244
            bool isLastNewline = false;
248
            int i;
245
            int i;
249
            int textLength = m_styleText.length();
246
            int textLength = m_styleText.length();
250
            for (i = replaceRangeEnd; i < textLength && isSpaceOrNewline(characters[i]); ++i) {
247
            for (i = replaceRangeEnd; i < textLength && isSpaceOrNewline(m_styleText[i]); ++i) {
251
                isLastNewline = isHTMLLineBreak(characters[i]);
248
                isLastNewline = isHTMLLineBreak(m_styleText[i]);
252
                if (isLastNewline)
249
                if (isLastNewline)
253
                    foundNewline = true;
250
                    foundNewline = true;
254
                else if (foundNewline && !isLastNewline) {
251
                else if (foundNewline && !isLastNewline) {
- a/Source/WebCore/page/ContentSecurityPolicy.cpp -10 / +18 lines
Lines 47-53 a/Source/WebCore/page/ContentSecurityPolicy.cpp_sec1
47
#include <inspector/ScriptCallStackFactory.h>
47
#include <inspector/ScriptCallStackFactory.h>
48
#include <wtf/HashSet.h>
48
#include <wtf/HashSet.h>
49
#include <wtf/text/TextPosition.h>
49
#include <wtf/text/TextPosition.h>
50
#include <wtf/text/WTFString.h>
51
50
52
using namespace Inspector;
51
using namespace Inspector;
53
52
Lines 189-196 static void skipWhile(const UChar*& position, const UChar* end) a/Source/WebCore/page/ContentSecurityPolicy.cpp_sec2
189
188
190
static bool isSourceListNone(const String& value)
189
static bool isSourceListNone(const String& value)
191
{
190
{
192
    const UChar* begin = value.deprecatedCharacters();
191
    auto characters = StringView(value).upconvertedCharacters();
193
    const UChar* end = value.deprecatedCharacters() + value.length();
192
    const UChar* begin = characters;
193
    const UChar* end = characters + value.length();
194
    skipWhile<isASCIISpace>(begin, end);
194
    skipWhile<isASCIISpace>(begin, end);
195
195
196
    const UChar* position = begin;
196
    const UChar* position = begin;
Lines 339-345 void CSPSourceList::parse(const String& value) a/Source/WebCore/page/ContentSecurityPolicy.cpp_sec3
339
    // We represent 'none' as an empty m_list.
339
    // We represent 'none' as an empty m_list.
340
    if (isSourceListNone(value))
340
    if (isSourceListNone(value))
341
        return;
341
        return;
342
    parse(value.deprecatedCharacters(), value.deprecatedCharacters() + value.length());
342
    auto characters = StringView(value).upconvertedCharacters();
343
    parse(characters, characters + value.length());
343
}
344
}
344
345
345
bool CSPSourceList::matches(const URL& url)
346
bool CSPSourceList::matches(const URL& url)
Lines 680-686 private: a/Source/WebCore/page/ContentSecurityPolicy.cpp_sec4
680
    void parse(const String& value)
681
    void parse(const String& value)
681
    {
682
    {
682
        String nonce;
683
        String nonce;
683
        const UChar* position = value.deprecatedCharacters();
684
        auto characters = StringView(value).upconvertedCharacters();
685
        const UChar* position = characters;
684
        const UChar* end = position + value.length();
686
        const UChar* end = position + value.length();
685
687
686
        skipWhile<isASCIISpace>(position, end);
688
        skipWhile<isASCIISpace>(position, end);
Lines 723-729 public: a/Source/WebCore/page/ContentSecurityPolicy.cpp_sec5
723
private:
725
private:
724
    void parse(const String& value)
726
    void parse(const String& value)
725
    {
727
    {
726
        const UChar* begin = value.deprecatedCharacters();
728
        auto characters = StringView(value).upconvertedCharacters();
729
        const UChar* begin = characters;
727
        const UChar* position = begin;
730
        const UChar* position = begin;
728
        const UChar* end = begin + value.length();
731
        const UChar* end = begin + value.length();
729
732
Lines 1211-1217 void CSPDirectiveList::parse(const String& policy) a/Source/WebCore/page/ContentSecurityPolicy.cpp_sec6
1211
    if (policy.isEmpty())
1214
    if (policy.isEmpty())
1212
        return;
1215
        return;
1213
1216
1214
    const UChar* position = policy.deprecatedCharacters();
1217
    auto characters = StringView(policy).upconvertedCharacters();
1218
    const UChar* position = characters;
1215
    const UChar* end = position + policy.length();
1219
    const UChar* end = position + policy.length();
1216
1220
1217
    while (position < end) {
1221
    while (position < end) {
Lines 1290-1296 void CSPDirectiveList::parseReportURI(const String& name, const String& value) a/Source/WebCore/page/ContentSecurityPolicy.cpp_sec7
1290
        m_policy->reportDuplicateDirective(name);
1294
        m_policy->reportDuplicateDirective(name);
1291
        return;
1295
        return;
1292
    }
1296
    }
1293
    const UChar* position = value.deprecatedCharacters();
1297
1298
    auto characters = StringView(value).upconvertedCharacters();
1299
    const UChar* position = characters;
1294
    const UChar* end = position + value.length();
1300
    const UChar* end = position + value.length();
1295
1301
1296
    while (position < end) {
1302
    while (position < end) {
Lines 1344-1350 void CSPDirectiveList::parseReflectedXSS(const String& name, const String& value a/Source/WebCore/page/ContentSecurityPolicy.cpp_sec8
1344
        return;
1350
        return;
1345
    }
1351
    }
1346
1352
1347
    const UChar* position = value.deprecatedCharacters();
1353
    auto characters = StringView(value).upconvertedCharacters();
1354
    const UChar* position = characters;
1348
    const UChar* end = position + value.length();
1355
    const UChar* end = position + value.length();
1349
1356
1350
    skipWhile<isASCIISpace>(position, end);
1357
    skipWhile<isASCIISpace>(position, end);
Lines 1443-1449 void ContentSecurityPolicy::didReceiveHeader(const String& header, HeaderType ty a/Source/WebCore/page/ContentSecurityPolicy.cpp_sec9
1443
    // RFC2616, section 4.2 specifies that headers appearing multiple times can
1450
    // RFC2616, section 4.2 specifies that headers appearing multiple times can
1444
    // be combined with a comma. Walk the header string, and parse each comma
1451
    // be combined with a comma. Walk the header string, and parse each comma
1445
    // separated chunk as a separate header.
1452
    // separated chunk as a separate header.
1446
    const UChar* begin = header.deprecatedCharacters();
1453
    auto characters = StringView(header).upconvertedCharacters();
1454
    const UChar* begin = characters;
1447
    const UChar* position = begin;
1455
    const UChar* position = begin;
1448
    const UChar* end = begin + header.length();
1456
    const UChar* end = begin + header.length();
1449
    while (position < end) {
1457
    while (position < end) {
- a/Source/WebCore/page/PageSerializer.cpp -2 / +2 lines
Lines 216-222 void PageSerializer::serializeFrame(Frame* frame) a/Source/WebCore/page/PageSerializer.cpp_sec1
216
        return;
216
        return;
217
    }
217
    }
218
    String text = accumulator.serializeNodes(*document->documentElement(), 0, IncludeNode);
218
    String text = accumulator.serializeNodes(*document->documentElement(), 0, IncludeNode);
219
    CString frameHTML = textEncoding.encode(text.deprecatedCharacters(), text.length(), EntitiesForUnencodables);
219
    CString frameHTML = textEncoding.encode(text, EntitiesForUnencodables);
220
    m_resources->append(Resource(url, document->suggestedMIMEType(), SharedBuffer::create(frameHTML.data(), frameHTML.length())));
220
    m_resources->append(Resource(url, document->suggestedMIMEType(), SharedBuffer::create(frameHTML.data(), frameHTML.length())));
221
    m_resourceURLs.add(url);
221
    m_resourceURLs.add(url);
222
222
Lines 283-289 void PageSerializer::serializeCSSStyleSheet(CSSStyleSheet* styleSheet, const URL a/Source/WebCore/page/PageSerializer.cpp_sec2
283
        TextEncoding textEncoding(styleSheet->contents().charset());
283
        TextEncoding textEncoding(styleSheet->contents().charset());
284
        ASSERT(textEncoding.isValid());
284
        ASSERT(textEncoding.isValid());
285
        String textString = cssText.toString();
285
        String textString = cssText.toString();
286
        CString text = textEncoding.encode(textString.deprecatedCharacters(), textString.length(), EntitiesForUnencodables);
286
        CString text = textEncoding.encode(textString, EntitiesForUnencodables);
287
        m_resources->append(Resource(url, String("text/css"), SharedBuffer::create(text.data(), text.length())));
287
        m_resources->append(Resource(url, String("text/css"), SharedBuffer::create(text.data(), text.length())));
288
        m_resourceURLs.add(url);
288
        m_resourceURLs.add(url);
289
    }
289
    }
- a/Source/WebCore/platform/Length.cpp -13 / +15 lines
Lines 30-36 a/Source/WebCore/platform/Length.cpp_sec1
30
#include <wtf/Assertions.h>
30
#include <wtf/Assertions.h>
31
#include <wtf/StdLibExtras.h>
31
#include <wtf/StdLibExtras.h>
32
#include <wtf/text/StringBuffer.h>
32
#include <wtf/text/StringBuffer.h>
33
#include <wtf/text/WTFString.h>
33
#include <wtf/text/StringView.h>
34
34
35
using namespace WTF;
35
using namespace WTF;
36
36
Lines 77-97 static Length parseLength(const UChar* data, unsigned length) a/Source/WebCore/platform/Length.cpp_sec2
77
    return Length(0, Relative);
77
    return Length(0, Relative);
78
}
78
}
79
79
80
static int countCharacter(const UChar* data, unsigned length, UChar character)
80
static unsigned countCharacter(StringImpl& string, UChar character)
81
{
81
{
82
    int count = 0;
82
    unsigned count = 0;
83
    for (int i = 0; i < static_cast<int>(length); ++i)
83
    unsigned length = string.length();
84
        count += data[i] == character;
84
    for (unsigned i = 0; i < length; ++i)
85
        count += string[i] == character;
85
    return count;
86
    return count;
86
}
87
}
87
88
88
std::unique_ptr<Length[]> newCoordsArray(const String& string, int& len)
89
std::unique_ptr<Length[]> newCoordsArray(const String& string, int& len)
89
{
90
{
90
    unsigned length = string.length();
91
    unsigned length = string.length();
91
    const UChar* data = string.deprecatedCharacters();
92
    StringBuffer<UChar> spacified(length);
92
    StringBuffer<UChar> spacified(length);
93
    for (unsigned i = 0; i < length; i++) {
93
    for (unsigned i = 0; i < length; i++) {
94
        UChar cc = data[i];
94
        UChar cc = string[i];
95
        if (cc > '9' || (cc < '0' && cc != '-' && cc != '*' && cc != '.'))
95
        if (cc > '9' || (cc < '0' && cc != '-' && cc != '*' && cc != '.'))
96
            spacified[i] = ' ';
96
            spacified[i] = ' ';
97
        else
97
        else
Lines 101-118 std::unique_ptr<Length[]> newCoordsArray(const String& string, int& len) a/Source/WebCore/platform/Length.cpp_sec3
101
101
102
    str = str->simplifyWhiteSpace();
102
    str = str->simplifyWhiteSpace();
103
103
104
    len = countCharacter(str->deprecatedCharacters(), str->length(), ' ') + 1;
104
    len = countCharacter(*str, ' ') + 1;
105
    auto r = std::make_unique<Length[]>(len);
105
    auto r = std::make_unique<Length[]>(len);
106
106
107
    int i = 0;
107
    int i = 0;
108
    unsigned pos = 0;
108
    unsigned pos = 0;
109
    size_t pos2;
109
    size_t pos2;
110
110
111
    auto upconvertedCharacters = StringView(str.get()).upconvertedCharacters();
111
    while ((pos2 = str->find(' ', pos)) != notFound) {
112
    while ((pos2 = str->find(' ', pos)) != notFound) {
112
        r[i++] = parseLength(str->deprecatedCharacters() + pos, pos2 - pos);
113
        r[i++] = parseLength(upconvertedCharacters + pos, pos2 - pos);
113
        pos = pos2+1;
114
        pos = pos2+1;
114
    }
115
    }
115
    r[i] = parseLength(str->deprecatedCharacters() + pos, str->length() - pos);
116
    r[i] = parseLength(upconvertedCharacters + pos, str->length() - pos);
116
117
117
    ASSERT(i == len - 1);
118
    ASSERT(i == len - 1);
118
119
Lines 127-141 std::unique_ptr<Length[]> newLengthArray(const String& string, int& len) a/Source/WebCore/platform/Length.cpp_sec4
127
        return nullptr;
128
        return nullptr;
128
    }
129
    }
129
130
130
    len = countCharacter(str->deprecatedCharacters(), str->length(), ',') + 1;
131
    len = countCharacter(*str, ',') + 1;
131
    auto r = std::make_unique<Length[]>(len);
132
    auto r = std::make_unique<Length[]>(len);
132
133
133
    int i = 0;
134
    int i = 0;
134
    unsigned pos = 0;
135
    unsigned pos = 0;
135
    size_t pos2;
136
    size_t pos2;
136
137
138
    auto upconvertedCharacters = StringView(str.get()).upconvertedCharacters();
137
    while ((pos2 = str->find(',', pos)) != notFound) {
139
    while ((pos2 = str->find(',', pos)) != notFound) {
138
        r[i++] = parseLength(str->deprecatedCharacters() + pos, pos2 - pos);
140
        r[i++] = parseLength(upconvertedCharacters + pos, pos2 - pos);
139
        pos = pos2+1;
141
        pos = pos2+1;
140
    }
142
    }
141
143
Lines 143-149 std::unique_ptr<Length[]> newLengthArray(const String& string, int& len) a/Source/WebCore/platform/Length.cpp_sec5
143
145
144
    // IE Quirk: If the last comma is the last char skip it and reduce len by one.
146
    // IE Quirk: If the last comma is the last char skip it and reduce len by one.
145
    if (str->length()-pos > 0)
147
    if (str->length()-pos > 0)
146
        r[i] = parseLength(str->deprecatedCharacters() + pos, str->length() - pos);
148
        r[i] = parseLength(upconvertedCharacters + pos, str->length() - pos);
147
    else
149
    else
148
        len--;
150
        len--;
149
151
- a/Source/WebCore/platform/LinkHash.cpp -8 / +2 lines
Lines 214-223 static ALWAYS_INLINE LinkHash visitedLinkHashInline(const CharacterType* url, un a/Source/WebCore/platform/LinkHash.cpp_sec1
214
LinkHash visitedLinkHash(const String& url)
214
LinkHash visitedLinkHash(const String& url)
215
{
215
{
216
    unsigned length = url.length();
216
    unsigned length = url.length();
217
217
    if (!length || url.is8Bit())
218
    if (length && url.is8Bit())
219
        return visitedLinkHashInline(url.characters8(), length);
218
        return visitedLinkHashInline(url.characters8(), length);
220
    return visitedLinkHashInline(url.deprecatedCharacters(), length);
219
    return visitedLinkHashInline(url.characters16(), length);
221
}
220
}
222
221
223
LinkHash visitedLinkHash(const UChar* url, unsigned length)
222
LinkHash visitedLinkHash(const UChar* url, unsigned length)
Lines 284-294 static ALWAYS_INLINE void visitedURLInline(const URL& base, const CharacterType* a/Source/WebCore/platform/LinkHash.cpp_sec2
284
    return;
283
    return;
285
}
284
}
286
285
287
void visitedURL(const URL& base, const AtomicString& attributeURL, Vector<UChar, 512>& buffer)
288
{
289
    return visitedURLInline(base, attributeURL.string().deprecatedCharacters(), attributeURL.length(), buffer);
290
}
291
292
LinkHash visitedLinkHash(const URL& base, const AtomicString& attributeURL)
286
LinkHash visitedLinkHash(const URL& base, const AtomicString& attributeURL)
293
{
287
{
294
    if (attributeURL.isEmpty())
288
    if (attributeURL.isEmpty())
- a/Source/WebCore/platform/LinkHash.h -6 lines
Lines 63-74 LinkHash visitedLinkHash(const UChar* url, unsigned length); a/Source/WebCore/platform/LinkHash.h_sec1
63
// look like a relative URL.
63
// look like a relative URL.
64
LinkHash visitedLinkHash(const URL& base, const AtomicString& attributeURL);
64
LinkHash visitedLinkHash(const URL& base, const AtomicString& attributeURL);
65
65
66
// Resolves the potentially relative URL "attributeURL" relative to the given
67
// base URL, and returns the hash of the string that will be used for visited.
68
// It will return an empty Vector in case of errors.
69
void visitedURL(const URL& base, const AtomicString& attributeURL, Vector<UChar, 512>&);
70
71
72
}  // namespace WebCore
66
}  // namespace WebCore
73
67
74
#endif  // LinkHash_h
68
#endif  // LinkHash_h
- a/Source/WebCore/platform/SharedBuffer.cpp -4 / +12 lines
Lines 522-531 PassRefPtr<SharedBuffer> utf8Buffer(const String& string) a/Source/WebCore/platform/SharedBuffer.cpp_sec1
522
522
523
    // Convert to runs of 8-bit characters.
523
    // Convert to runs of 8-bit characters.
524
    char* p = buffer.data();
524
    char* p = buffer.data();
525
    const UChar* d = string.deprecatedCharacters();
525
    WTF::Unicode::ConversionResult result;
526
    WTF::Unicode::ConversionResult result = WTF::Unicode::convertUTF16ToUTF8(&d, d + length, &p, p + buffer.size(), true);
526
    if (length) {
527
    if (result != WTF::Unicode::conversionOK)
527
        if (string.is8Bit()) {
528
        return 0;
528
            const LChar* d = string.characters8();
529
            result = WTF::Unicode::convertLatin1ToUTF8(&d, d + length, &p, p + buffer.size());
530
        } else {
531
            const UChar* d = string.characters16();
532
            result = WTF::Unicode::convertUTF16ToUTF8(&d, d + length, &p, p + buffer.size(), true);
533
        }
534
        if (result != WTF::Unicode::conversionOK)
535
            return nullptr;
536
    }
529
537
530
    buffer.shrink(p - buffer.data());
538
    buffer.shrink(p - buffer.data());
531
    return SharedBuffer::adoptVector(buffer);
539
    return SharedBuffer::adoptVector(buffer);
- a/Source/WebCore/platform/URL.cpp -4 / +8 lines
Lines 588-594 unsigned short URL::port() const a/Source/WebCore/platform/URL.cpp_sec1
588
        return 0;
588
        return 0;
589
589
590
    bool ok = false;
590
    bool ok = false;
591
    unsigned number = charactersToUIntStrict(m_string.deprecatedCharacters() + m_hostEnd + 1, m_portEnd - m_hostEnd - 1, &ok);
591
    unsigned number;
592
    if (m_string.is8Bit())
593
        number = charactersToUIntStrict(m_string.characters8() + m_hostEnd + 1, m_portEnd - m_hostEnd - 1, &ok);
594
    else
595
        number = charactersToUIntStrict(m_string.characters16() + m_hostEnd + 1, m_portEnd - m_hostEnd - 1, &ok);
592
    if (!ok || number > maximumValidPortNumber)
596
    if (!ok || number > maximumValidPortNumber)
593
        return invalidPortNumber;
597
        return invalidPortNumber;
594
    return number;
598
    return number;
Lines 1666-1679 static void encodeRelativeString(const String& rel, const TextEncoding& encoding a/Source/WebCore/platform/URL.cpp_sec2
1666
    }
1670
    }
1667
1671
1668
    if (pathEnd == -1) {
1672
    if (pathEnd == -1) {
1669
        CString decoded = pathEncoding.encode(s.data(), s.size(), URLEncodedEntitiesForUnencodables);
1673
        CString decoded = pathEncoding.encode(StringView(s.data(), s.size()), URLEncodedEntitiesForUnencodables);
1670
        output.resize(decoded.length());
1674
        output.resize(decoded.length());
1671
        memcpy(output.data(), decoded.data(), decoded.length());
1675
        memcpy(output.data(), decoded.data(), decoded.length());
1672
    } else {
1676
    } else {
1673
        CString pathDecoded = pathEncoding.encode(s.data(), pathEnd, URLEncodedEntitiesForUnencodables);
1677
        CString pathDecoded = pathEncoding.encode(StringView(s.data(), pathEnd), URLEncodedEntitiesForUnencodables);
1674
        // Unencodable characters in URLs are represented by converting
1678
        // Unencodable characters in URLs are represented by converting
1675
        // them to XML entities and escaping non-alphanumeric characters.
1679
        // them to XML entities and escaping non-alphanumeric characters.
1676
        CString otherDecoded = encoding.encode(s.data() + pathEnd, s.size() - pathEnd, URLEncodedEntitiesForUnencodables);
1680
        CString otherDecoded = encoding.encode(StringView(s.data() + pathEnd, s.size() - pathEnd), URLEncodedEntitiesForUnencodables);
1677
1681
1678
        output.resize(pathDecoded.length() + otherDecoded.length());
1682
        output.resize(pathDecoded.length() + otherDecoded.length());
1679
        memcpy(output.data(), pathDecoded.data(), pathDecoded.length());
1683
        memcpy(output.data(), pathDecoded.data(), pathDecoded.length());
- a/Source/WebCore/platform/graphics/Color.cpp -2 / +2 lines
Lines 165-171 bool Color::parseHexColor(const String& name, RGBA32& rgb) a/Source/WebCore/platform/graphics/Color.cpp_sec1
165
        return false;
165
        return false;
166
    if (name.is8Bit())
166
    if (name.is8Bit())
167
        return parseHexColor(name.characters8(), name.length(), rgb);
167
        return parseHexColor(name.characters8(), name.length(), rgb);
168
    return parseHexColor(name.deprecatedCharacters(), name.length(), rgb);
168
    return parseHexColor(name.characters16(), name.length(), rgb);
169
}
169
}
170
170
171
int differenceSquared(const Color& c1, const Color& c2)
171
int differenceSquared(const Color& c1, const Color& c2)
Lines 182-188 Color::Color(const String& name) a/Source/WebCore/platform/graphics/Color.cpp_sec2
182
        if (name.is8Bit())
182
        if (name.is8Bit())
183
            m_valid = parseHexColor(name.characters8() + 1, name.length() - 1, m_color);
183
            m_valid = parseHexColor(name.characters8() + 1, name.length() - 1, m_color);
184
        else
184
        else
185
            m_valid = parseHexColor(name.deprecatedCharacters() + 1, name.length() - 1, m_color);
185
            m_valid = parseHexColor(name.characters16() + 1, name.length() - 1, m_color);
186
    } else
186
    } else
187
        setNamedColor(name);
187
        setNamedColor(name);
188
}
188
}
- a/Source/WebCore/platform/graphics/StringTruncator.cpp -12 / +10 lines
Lines 89-100 static unsigned centerTruncateToBuffer(const String& string, unsigned length, un a/Source/WebCore/platform/graphics/StringTruncator.cpp_sec1
89
    unsigned truncatedLength = shouldInsertEllipsis ? omitStart + 1 + (length - omitEnd) : length - (omitEnd - omitStart);
89
    unsigned truncatedLength = shouldInsertEllipsis ? omitStart + 1 + (length - omitEnd) : length - (omitEnd - omitStart);
90
    ASSERT(truncatedLength <= length);
90
    ASSERT(truncatedLength <= length);
91
91
92
    memcpy(buffer, string.deprecatedCharacters(), sizeof(UChar) * omitStart);
92
    StringView(string).substring(0, omitStart).getCharactersWithUpconvert(buffer);
93
    if (shouldInsertEllipsis) {
93
    if (shouldInsertEllipsis)
94
        buffer[omitStart] = horizontalEllipsis;
94
        buffer[omitStart++] = horizontalEllipsis;
95
        memcpy(&buffer[omitStart + 1], &string.deprecatedCharacters()[omitEnd], sizeof(UChar) * (length - omitEnd));
95
    StringView(string).substring(omitEnd, length - omitEnd).getCharactersWithUpconvert(&buffer[omitStart + 1]);
96
    } else
97
        memcpy(&buffer[omitStart], &string.deprecatedCharacters()[omitEnd], sizeof(UChar) * (length - omitEnd));
98
    return truncatedLength;
96
    return truncatedLength;
99
}
97
}
100
98
Lines 119-125 static unsigned rightTruncateToBuffer(const String& string, unsigned length, uns a/Source/WebCore/platform/graphics/StringTruncator.cpp_sec2
119
    unsigned keepLength = textBreakAtOrPreceding(it, keepCount);
117
    unsigned keepLength = textBreakAtOrPreceding(it, keepCount);
120
    unsigned truncatedLength = shouldInsertEllipsis ? keepLength + 1 : keepLength;
118
    unsigned truncatedLength = shouldInsertEllipsis ? keepLength + 1 : keepLength;
121
119
122
    memcpy(buffer, string.deprecatedCharacters(), sizeof(UChar) * keepLength);
120
    StringView(string).substring(0, keepLength).getCharactersWithUpconvert(buffer);
123
    if (shouldInsertEllipsis)
121
    if (shouldInsertEllipsis)
124
        buffer[keepLength] = horizontalEllipsis;
122
        buffer[keepLength] = horizontalEllipsis;
125
123
Lines 133-139 static unsigned rightClipToCharacterBuffer(const String& string, unsigned length a/Source/WebCore/platform/graphics/StringTruncator.cpp_sec3
133
131
134
    NonSharedCharacterBreakIterator it(StringView(string).substring(0, length));
132
    NonSharedCharacterBreakIterator it(StringView(string).substring(0, length));
135
    unsigned keepLength = textBreakAtOrPreceding(it, keepCount);
133
    unsigned keepLength = textBreakAtOrPreceding(it, keepCount);
136
    memcpy(buffer, string.deprecatedCharacters(), sizeof(UChar) * keepLength);
134
    StringView(string).substring(0, keepLength).getCharactersWithUpconvert(buffer);
137
135
138
    return keepLength;
136
    return keepLength;
139
}
137
}
Lines 145-151 static unsigned rightClipToWordBuffer(const String& string, unsigned length, uns a/Source/WebCore/platform/graphics/StringTruncator.cpp_sec4
145
143
146
    TextBreakIterator* it = wordBreakIterator(StringView(string).substring(0, length));
144
    TextBreakIterator* it = wordBreakIterator(StringView(string).substring(0, length));
147
    unsigned keepLength = textBreakAtOrPreceding(it, keepCount);
145
    unsigned keepLength = textBreakAtOrPreceding(it, keepCount);
148
    memcpy(buffer, string.deprecatedCharacters(), sizeof(UChar) * keepLength);
146
    StringView(string).substring(0, keepLength).getCharactersWithUpconvert(buffer);
149
147
150
#if PLATFORM(IOS)
148
#if PLATFORM(IOS)
151
    // FIXME: We should guard this code behind an editing behavior. Then we can remove the PLATFORM(IOS)-guard.
149
    // FIXME: We should guard this code behind an editing behavior. Then we can remove the PLATFORM(IOS)-guard.
Lines 178-187 static unsigned leftTruncateToBuffer(const String& string, unsigned length, unsi a/Source/WebCore/platform/graphics/StringTruncator.cpp_sec5
178
176
179
    if (shouldInsertEllipsis) {
177
    if (shouldInsertEllipsis) {
180
        buffer[0] = horizontalEllipsis;
178
        buffer[0] = horizontalEllipsis;
181
        memcpy(&buffer[1], &string.deprecatedCharacters()[adjustedStartIndex], sizeof(UChar) * (length - adjustedStartIndex + 1));
179
        StringView(string).substring(adjustedStartIndex, length - adjustedStartIndex + 1).getCharactersWithUpconvert(&buffer[1]);
182
        return length - adjustedStartIndex + 1;
180
        return length - adjustedStartIndex + 1;
183
    }
181
    }
184
    memcpy(&buffer[0], &string.deprecatedCharacters()[adjustedStartIndex], sizeof(UChar) * (length - adjustedStartIndex + 1));
182
    StringView(string).substring(adjustedStartIndex, length - adjustedStartIndex + 1).getCharactersWithUpconvert(&buffer[0]);
185
    return length - adjustedStartIndex;
183
    return length - adjustedStartIndex;
186
}
184
}
187
185
Lines 218-224 static String truncateString(const String& string, float maxWidth, const Font& f a/Source/WebCore/platform/graphics/StringTruncator.cpp_sec6
218
        truncatedLength = centerTruncateToBuffer(string, length, keepCount, stringBuffer, shouldInsertEllipsis);
216
        truncatedLength = centerTruncateToBuffer(string, length, keepCount, stringBuffer, shouldInsertEllipsis);
219
    } else {
217
    } else {
220
        keepCount = length;
218
        keepCount = length;
221
        memcpy(stringBuffer, string.deprecatedCharacters(), sizeof(UChar) * length);
219
        StringView(string).getCharactersWithUpconvert(stringBuffer);
222
        truncatedLength = length;
220
        truncatedLength = length;
223
    }
221
    }
224
222
- a/Source/WebCore/platform/graphics/TextRun.h -2 / +2 lines
Lines 116-126 public: a/Source/WebCore/platform/graphics/TextRun.h_sec1
116
        , m_disableSpacing(false)
116
        , m_disableSpacing(false)
117
        , m_tabSize(0)
117
        , m_tabSize(0)
118
    {
118
    {
119
        if (m_charactersLength && s.is8Bit()) {
119
        if (!m_charactersLength || s.is8Bit()) {
120
            m_data.characters8 = s.characters8();
120
            m_data.characters8 = s.characters8();
121
            m_is8Bit = true;
121
            m_is8Bit = true;
122
        } else {
122
        } else {
123
            m_data.characters16 = s.deprecatedCharacters();
123
            m_data.characters16 = s.characters16();
124
            m_is8Bit = false;
124
            m_is8Bit = false;
125
        }
125
        }
126
    }
126
    }
- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm -1 / +1 lines
Lines 1246-1252 bool MediaPlayerPrivateAVFoundationObjC::shouldWaitForLoadingOfResource(AVAssetR a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm_sec1
1246
        initDataView->set<uint32_t>(0, keyURISize, true);
1246
        initDataView->set<uint32_t>(0, keyURISize, true);
1247
1247
1248
        RefPtr<Uint16Array> keyURIArray = Uint16Array::create(initDataBuffer, 4, keyURI.length());
1248
        RefPtr<Uint16Array> keyURIArray = Uint16Array::create(initDataBuffer, 4, keyURI.length());
1249
        keyURIArray->setRange(keyURI.deprecatedCharacters(), keyURI.length() / sizeof(unsigned char), 0);
1249
        keyURIArray->setRange(StringView(keyURI).upconvertedCharacters(), keyURI.length() / sizeof(unsigned char), 0);
1250
1250
1251
#if ENABLE(ENCRYPTED_MEDIA)
1251
#if ENABLE(ENCRYPTED_MEDIA)
1252
        if (!player()->keyNeeded("com.apple.lskd", emptyString(), static_cast<const unsigned char*>(initDataBuffer->data()), initDataBuffer->byteLength()))
1252
        if (!player()->keyNeeded("com.apple.lskd", emptyString(), static_cast<const unsigned char*>(initDataBuffer->data()), initDataBuffer->byteLength()))
- a/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp -1 / +2 lines
Lines 44-49 a/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp_sec1
44
#include FT_TRUETYPE_TABLES_H
44
#include FT_TRUETYPE_TABLES_H
45
#include <hb.h>
45
#include <hb.h>
46
#include <wtf/text/CString.h>
46
#include <wtf/text/CString.h>
47
#include <wtf/text/StringView.h>
47
48
48
namespace WebCore {
49
namespace WebCore {
49
50
Lines 112-118 static hb_bool_t harfBuzzGetGlyph(hb_font_t*, void* fontData, hb_codepoint_t uni a/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp_sec2
112
    if (result.isNewEntry) {
113
    if (result.isNewEntry) {
113
        cairo_glyph_t* glyphs = 0;
114
        cairo_glyph_t* glyphs = 0;
114
        int numGlyphs = 0;
115
        int numGlyphs = 0;
115
        CString utf8Codepoint = UTF8Encoding().encode(reinterpret_cast<UChar*>(&unicode), 1, QuestionMarksForUnencodables);
116
        CString utf8Codepoint = UTF8Encoding().encode(StringView(reinterpret_cast<UChar*>(&unicode), 1), QuestionMarksForUnencodables);
116
        if (cairo_scaled_font_text_to_glyphs(scaledFont, 0, 0, utf8Codepoint.data(), utf8Codepoint.length(), &glyphs, &numGlyphs, 0, 0, 0) != CAIRO_STATUS_SUCCESS)
117
        if (cairo_scaled_font_text_to_glyphs(scaledFont, 0, 0, utf8Codepoint.data(), utf8Codepoint.length(), &glyphs, &numGlyphs, 0, 0, 0) != CAIRO_STATUS_SUCCESS)
117
            return false;
118
            return false;
118
        if (!numGlyphs)
119
        if (!numGlyphs)
- a/Source/WebCore/platform/network/DataURL.cpp -1 / +2 lines
Lines 35-40 a/Source/WebCore/platform/network/DataURL.cpp_sec1
35
#include "TextEncoding.h"
35
#include "TextEncoding.h"
36
#include <wtf/text/Base64.h>
36
#include <wtf/text/Base64.h>
37
#include <wtf/text/CString.h>
37
#include <wtf/text/CString.h>
38
#include <wtf/text/StringView.h>
38
39
39
namespace WebCore {
40
namespace WebCore {
40
41
Lines 84-90 void handleDataURL(ResourceHandle* handle) a/Source/WebCore/platform/network/DataURL.cpp_sec2
84
        data = decodeURLEscapeSequences(data, encoding);
85
        data = decodeURLEscapeSequences(data, encoding);
85
        handle->client()->didReceiveResponse(handle, response);
86
        handle->client()->didReceiveResponse(handle, response);
86
87
87
        CString encodedData = encoding.encode(data.deprecatedCharacters(), data.length(), URLEncodedEntitiesForUnencodables);
88
        CString encodedData = encoding.encode(data, URLEncodedEntitiesForUnencodables);
88
        response.setExpectedContentLength(encodedData.length());
89
        response.setExpectedContentLength(encodedData.length());
89
        if (encodedData.length())
90
        if (encodedData.length())
90
            handle->client()->didReceiveData(handle, encodedData.data(), encodedData.length(), 0);
91
            handle->client()->didReceiveData(handle, encodedData.data(), encodedData.length(), 0);
- a/Source/WebCore/platform/network/FormDataBuilder.cpp -11 / +8 lines
Lines 28-39 a/Source/WebCore/platform/network/FormDataBuilder.cpp_sec1
28
#include "Blob.h"
28
#include "Blob.h"
29
#include "Document.h"
29
#include "Document.h"
30
#include "TextEncoding.h"
30
#include "TextEncoding.h"
31
32
#include <limits>
31
#include <limits>
33
#include <wtf/Assertions.h>
32
#include <wtf/Assertions.h>
34
#include <wtf/HexNumber.h>
33
#include <wtf/HexNumber.h>
35
#include <wtf/text/CString.h>
36
#include <wtf/RandomNumber.h>
34
#include <wtf/RandomNumber.h>
35
#include <wtf/text/CString.h>
36
#include <wtf/text/StringView.h>
37
37
38
namespace WebCore {
38
namespace WebCore {
39
39
Lines 61-72 static void appendQuotedString(Vector<char>& buffer, const CString& string) a/Source/WebCore/platform/network/FormDataBuilder.cpp_sec2
61
    size_t length = string.length();
61
    size_t length = string.length();
62
    for (size_t i = 0; i < length; ++i) {
62
    for (size_t i = 0; i < length; ++i) {
63
        char c = string.data()[i];
63
        char c = string.data()[i];
64
65
        switch (c) {
64
        switch (c) {
66
        case  0x0a:
65
        case 0xA:
67
            append(buffer, "%0A");
66
            append(buffer, "%0A");
68
            break;
67
            break;
69
        case 0x0d:
68
        case 0xD:
70
            append(buffer, "%0D");
69
            append(buffer, "%0D");
71
            break;
70
            break;
72
        case '"':
71
        case '"':
Lines 86-96 TextEncoding FormDataBuilder::encodingFromAcceptCharset(const String& acceptChar a/Source/WebCore/platform/network/FormDataBuilder.cpp_sec3
86
    Vector<String> charsets;
85
    Vector<String> charsets;
87
    normalizedAcceptCharset.split(' ', charsets);
86
    normalizedAcceptCharset.split(' ', charsets);
88
87
89
    TextEncoding encoding;
88
    for (auto& charset : charsets) {
90
89
        TextEncoding encoding(charset);
91
    Vector<String>::const_iterator end = charsets.end();
90
        if (encoding.isValid())
92
    for (Vector<String>::const_iterator it = charsets.begin(); it != end; ++it) {
93
        if ((encoding = TextEncoding(*it)).isValid())
94
            return encoding;
91
            return encoding;
95
    }
92
    }
96
93
Lines 165-171 void FormDataBuilder::addFilenameToMultiPartHeader(Vector<char>& buffer, const T a/Source/WebCore/platform/network/FormDataBuilder.cpp_sec4
165
    // FIXME: This loses data irreversibly if the filename includes characters you can't encode
162
    // FIXME: This loses data irreversibly if the filename includes characters you can't encode
166
    // in the website's character set.
163
    // in the website's character set.
167
    append(buffer, "; filename=\"");
164
    append(buffer, "; filename=\"");
168
    appendQuotedString(buffer, encoding.encode(filename.deprecatedCharacters(), filename.length(), QuestionMarksForUnencodables));
165
    appendQuotedString(buffer, encoding.encode(filename, QuestionMarksForUnencodables));
169
    append(buffer, '"');
166
    append(buffer, '"');
170
}
167
}
171
168
- a/Source/WebCore/platform/sql/SQLiteStatement.cpp -3 / +5 lines
Lines 30-36 a/Source/WebCore/platform/sql/SQLiteStatement.cpp_sec1
30
#include "SQLValue.h"
30
#include "SQLValue.h"
31
#include <sqlite3.h>
31
#include <sqlite3.h>
32
#include <wtf/Assertions.h>
32
#include <wtf/Assertions.h>
33
#include <wtf/text/StringImpl.h>
33
#include <wtf/text/StringView.h>
34
34
35
// SQLite 3.6.16 makes sqlite3_prepare_v2 automatically retry preparing the statement
35
// SQLite 3.6.16 makes sqlite3_prepare_v2 automatically retry preparing the statement
36
// once if the database scheme has changed. We rely on this behavior.
36
// once if the database scheme has changed. We rely on this behavior.
Lines 177-188 int SQLiteStatement::bindBlob(int index, const String& text) a/Source/WebCore/platform/sql/SQLiteStatement.cpp_sec2
177
{
177
{
178
    // String::characters() returns 0 for the empty string, which SQLite
178
    // String::characters() returns 0 for the empty string, which SQLite
179
    // treats as a null, so we supply a non-null pointer for that case.
179
    // treats as a null, so we supply a non-null pointer for that case.
180
    auto upconvertedCharacters = StringView(text).upconvertedCharacters();
180
    UChar anyCharacter = 0;
181
    UChar anyCharacter = 0;
181
    const UChar* characters;
182
    const UChar* characters;
182
    if (text.isEmpty() && !text.isNull())
183
    if (text.isEmpty() && !text.isNull())
183
        characters = &anyCharacter;
184
        characters = &anyCharacter;
184
    else
185
    else
185
        characters = text.deprecatedCharacters();
186
        characters = upconvertedCharacters;
186
187
187
    return bindBlob(index, characters, text.length() * sizeof(UChar));
188
    return bindBlob(index, characters, text.length() * sizeof(UChar));
188
}
189
}
Lines 195-206 int SQLiteStatement::bindText(int index, const String& text) a/Source/WebCore/platform/sql/SQLiteStatement.cpp_sec3
195
196
196
    // String::characters() returns 0 for the empty string, which SQLite
197
    // String::characters() returns 0 for the empty string, which SQLite
197
    // treats as a null, so we supply a non-null pointer for that case.
198
    // treats as a null, so we supply a non-null pointer for that case.
199
    auto upconvertedCharacters = StringView(text).upconvertedCharacters();
198
    UChar anyCharacter = 0;
200
    UChar anyCharacter = 0;
199
    const UChar* characters;
201
    const UChar* characters;
200
    if (text.isEmpty() && !text.isNull())
202
    if (text.isEmpty() && !text.isNull())
201
        characters = &anyCharacter;
203
        characters = &anyCharacter;
202
    else
204
    else
203
        characters = text.deprecatedCharacters();
205
        characters = upconvertedCharacters;
204
206
205
    return sqlite3_bind_text16(m_statement, index, characters, sizeof(UChar) * text.length(), SQLITE_TRANSIENT);
207
    return sqlite3_bind_text16(m_statement, index, characters, sizeof(UChar) * text.length(), SQLITE_TRANSIENT);
206
}
208
}
- a/Source/WebCore/platform/text/DecodeEscapeSequences.h -10 / +9 lines
Lines 51-69 struct Unicode16BitEscapeSequence { a/Source/WebCore/platform/text/DecodeEscapeSequences.h_sec1
51
        }
51
        }
52
        return runEnd;
52
        return runEnd;
53
    }
53
    }
54
    static String decodeRun(const UChar* run, size_t runLength, const TextEncoding&)
54
    static String decodeRun(StringView run, const TextEncoding&)
55
    {
55
    {
56
        // Each %u-escape sequence represents a UTF-16 code unit.
56
        // Each %u-escape sequence represents a UTF-16 code unit.
57
        // See <http://www.w3.org/International/iri-edit/draft-duerst-iri.html#anchor29>.
57
        // See <http://www.w3.org/International/iri-edit/draft-duerst-iri.html#anchor29>.
58
        // For 16-bit escape sequences, we know that findEndOfRun() has given us a contiguous run of sequences
58
        // For 16-bit escape sequences, we know that findEndOfRun() has given us a contiguous run of sequences
59
        // without any intervening characters, so decode the run without additional checks.
59
        // without any intervening characters, so decode the run without additional checks.
60
        size_t numberOfSequences = runLength / sequenceSize;
60
        auto numberOfSequences = run.length() / sequenceSize;
61
        StringBuilder builder;
61
        StringBuilder builder;
62
        builder.reserveCapacity(numberOfSequences);
62
        builder.reserveCapacity(numberOfSequences);
63
        while (numberOfSequences--) {
63
        while (numberOfSequences--) {
64
            UChar codeUnit = (toASCIIHexValue(run[2]) << 12) | (toASCIIHexValue(run[3]) << 8) | (toASCIIHexValue(run[4]) << 4) | toASCIIHexValue(run[5]);
64
            UChar codeUnit = (toASCIIHexValue(run[2]) << 12) | (toASCIIHexValue(run[3]) << 8) | (toASCIIHexValue(run[4]) << 4) | toASCIIHexValue(run[5]);
65
            builder.append(codeUnit);
65
            builder.append(codeUnit);
66
            run += sequenceSize;
66
            run = run.substring(sequenceSize);
67
        }
67
        }
68
        return builder.toString();
68
        return builder.toString();
69
    }
69
    }
Lines 96-116 struct URLEscapeSequence { a/Source/WebCore/platform/text/DecodeEscapeSequences.h_sec2
96
        }
96
        }
97
        return runEnd;
97
        return runEnd;
98
    }
98
    }
99
    static String decodeRun(const UChar* run, size_t runLength, const TextEncoding& encoding)
99
    static String decodeRun(StringView run, const TextEncoding& encoding)
100
    {
100
    {
101
        // For URL escape sequences, we know that findEndOfRun() has given us a run where every %-sign introduces
101
        // For URL escape sequences, we know that findEndOfRun() has given us a run where every %-sign introduces
102
        // a valid escape sequence, but there may be characters between the sequences.
102
        // a valid escape sequence, but there may be characters between the sequences.
103
        Vector<char, 512> buffer;
103
        Vector<char, 512> buffer;
104
        buffer.resize(runLength); // Unescaping hex sequences only makes the length smaller.
104
        buffer.resize(run.length()); // Unescaping hex sequences only makes the length smaller.
105
        char* p = buffer.data();
105
        char* p = buffer.data();
106
        const UChar* runEnd = run + runLength;
106
        while (!run.isEmpty()) {
107
        while (run < runEnd) {
108
            if (run[0] == '%') {
107
            if (run[0] == '%') {
109
                *p++ = (toASCIIHexValue(run[1]) << 4) | toASCIIHexValue(run[2]);
108
                *p++ = (toASCIIHexValue(run[1]) << 4) | toASCIIHexValue(run[2]);
110
                run += sequenceSize;
109
                run = run.substring(sequenceSize);
111
            } else {
110
            } else {
112
                *p++ = run[0];
111
                *p++ = run[0];
113
                run += 1;
112
                run = run.substring(1);
114
            }
113
            }
115
        }
114
        }
116
        ASSERT(buffer.size() >= static_cast<size_t>(p - buffer.data())); // Prove buffer not overrun.
115
        ASSERT(buffer.size() >= static_cast<size_t>(p - buffer.data())); // Prove buffer not overrun.
Lines 134-140 String decodeEscapeSequences(const String& string, const TextEncoding& encoding) a/Source/WebCore/platform/text/DecodeEscapeSequences.h_sec3
134
            continue;
133
            continue;
135
        }
134
        }
136
135
137
        String decoded = EscapeSequence::decodeRun(string.deprecatedCharacters() + encodedRunPosition, encodedRunEnd - encodedRunPosition, encoding);
136
        String decoded = EscapeSequence::decodeRun(StringView(string).substring(encodedRunPosition, encodedRunEnd - encodedRunPosition), encoding);
138
        if (decoded.isEmpty())
137
        if (decoded.isEmpty())
139
            continue;
138
            continue;
140
139
- a/Source/WebCore/platform/text/Hyphenation.cpp -1 / +2 lines
Lines 27-32 a/Source/WebCore/platform/text/Hyphenation.cpp_sec1
27
#include "Hyphenation.h"
27
#include "Hyphenation.h"
28
28
29
#include "NotImplemented.h"
29
#include "NotImplemented.h"
30
#include <wtf/text/StringView.h>
30
31
31
namespace WebCore {
32
namespace WebCore {
32
33
Lines 35-41 bool canHyphenate(const AtomicString& /* localeIdentifier */) a/Source/WebCore/platform/text/Hyphenation.cpp_sec2
35
    return false;
36
    return false;
36
}
37
}
37
38
38
size_t lastHyphenLocation(const UChar* /* characters */, size_t /* length */, size_t /* beforeIndex */, const AtomicString& /* localeIdentifier */)
39
size_t lastHyphenLocation(StringView, size_t /* beforeIndex */, const AtomicString& /* localeIdentifier */)
39
{
40
{
40
    ASSERT_NOT_REACHED();
41
    ASSERT_NOT_REACHED();
41
    return 0;
42
    return 0;
- a/Source/WebCore/platform/text/Hyphenation.h -1 / +1 lines
Lines 32-38 a/Source/WebCore/platform/text/Hyphenation.h_sec1
32
namespace WebCore {
32
namespace WebCore {
33
33
34
bool canHyphenate(const AtomicString& localeIdentifier);
34
bool canHyphenate(const AtomicString& localeIdentifier);
35
size_t lastHyphenLocation(const UChar*, size_t length, size_t beforeIndex, const AtomicString& localeIdentifier);
35
size_t lastHyphenLocation(StringView, size_t beforeIndex, const AtomicString& localeIdentifier);
36
36
37
} // namespace WebCore
37
} // namespace WebCore
38
38
- a/Source/WebCore/platform/text/TextBreakIterator.cpp -4 / +6 lines
Lines 28-34 a/Source/WebCore/platform/text/TextBreakIterator.cpp_sec1
28
#include <mutex>
28
#include <mutex>
29
#include <wtf/Atomics.h>
29
#include <wtf/Atomics.h>
30
#include <wtf/text/StringView.h>
30
#include <wtf/text/StringView.h>
31
#include <wtf/text/WTFString.h>
32
31
33
namespace WebCore {
32
namespace WebCore {
34
33
Lines 43-58 static TextBreakIterator* initializeIterator(UBreakIteratorType type, const char a/Source/WebCore/platform/text/TextBreakIterator.cpp_sec2
43
}
42
}
44
43
45
#if !PLATFORM(IOS)
44
#if !PLATFORM(IOS)
45
46
static TextBreakIterator* initializeIteratorWithRules(const char* breakRules)
46
static TextBreakIterator* initializeIteratorWithRules(const char* breakRules)
47
{
47
{
48
    UParseError parseStatus;
48
    UParseError parseStatus;
49
    UErrorCode openStatus = U_ZERO_ERROR;
49
    UErrorCode openStatus = U_ZERO_ERROR;
50
    String rules(breakRules);
50
    unsigned length = strlen(breakRules);
51
    TextBreakIterator* iterator = reinterpret_cast<TextBreakIterator*>(ubrk_openRules(rules.deprecatedCharacters(), rules.length(), 0, 0, &parseStatus, &openStatus));
51
    auto upconvertedCharacters = StringView(reinterpret_cast<const LChar*>(breakRules), length).upconvertedCharacters();
52
    TextBreakIterator* iterator = reinterpret_cast<TextBreakIterator*>(ubrk_openRules(upconvertedCharacters, length, 0, 0, &parseStatus, &openStatus));
52
    ASSERT_WITH_MESSAGE(U_SUCCESS(openStatus), "ICU could not open a break iterator: %s (%d)", u_errorName(openStatus), openStatus);
53
    ASSERT_WITH_MESSAGE(U_SUCCESS(openStatus), "ICU could not open a break iterator: %s (%d)", u_errorName(openStatus), openStatus);
53
    return iterator;
54
    return iterator;
54
}
55
}
55
#endif // !PLATFORM(IOS)
56
57
#endif
56
58
57
59
58
// Iterator text setting
60
// Iterator text setting
- a/Source/WebCore/platform/text/TextEncoding.cpp -7 / +10 lines
Lines 34-40 a/Source/WebCore/platform/text/TextEncoding.cpp_sec1
34
#include <wtf/OwnPtr.h>
34
#include <wtf/OwnPtr.h>
35
#include <wtf/StdLibExtras.h>
35
#include <wtf/StdLibExtras.h>
36
#include <wtf/text/CString.h>
36
#include <wtf/text/CString.h>
37
#include <wtf/text/WTFString.h>
37
#include <wtf/text/StringView.h>
38
38
39
namespace WebCore {
39
namespace WebCore {
40
40
Lines 64-83 String TextEncoding::decode(const char* data, size_t length, bool stopOnError, b a/Source/WebCore/platform/text/TextEncoding.cpp_sec2
64
    return newTextCodec(*this)->decode(data, length, true, stopOnError, sawError);
64
    return newTextCodec(*this)->decode(data, length, true, stopOnError, sawError);
65
}
65
}
66
66
67
CString TextEncoding::encode(const UChar* characters, size_t length, UnencodableHandling handling) const
67
CString TextEncoding::encode(StringView text, UnencodableHandling handling) const
68
{
68
{
69
    if (!m_name)
69
    if (!m_name)
70
        return CString();
70
        return CString();
71
71
72
    if (!length)
72
    if (text.isEmpty())
73
        return "";
73
        return "";
74
74
75
    // FIXME: What's the right place to do normalization?
75
    // FIXME: What's the right place to do normalization?
76
    // It's a little strange to do it inside the encode function.
76
    // It's a little strange to do it inside the encode function.
77
    // Perhaps normalization should be an explicit step done before calling encode.
77
    // Perhaps normalization should be an explicit step done before calling encode.
78
78
79
    const UChar* source = characters;
79
    auto upconvertedCharacters = text.upconvertedCharacters();
80
    size_t sourceLength = length;
80
81
    const UChar* source = upconvertedCharacters;
82
    size_t sourceLength = text.length();
81
83
82
    Vector<UChar> normalizedCharacters;
84
    Vector<UChar> normalizedCharacters;
83
85
Lines 85-101 CString TextEncoding::encode(const UChar* characters, size_t length, Unencodable a/Source/WebCore/platform/text/TextEncoding.cpp_sec3
85
    if (unorm_quickCheck(source, sourceLength, UNORM_NFC, &err) != UNORM_YES) {
87
    if (unorm_quickCheck(source, sourceLength, UNORM_NFC, &err) != UNORM_YES) {
86
        // First try using the length of the original string, since normalization to NFC rarely increases length.
88
        // First try using the length of the original string, since normalization to NFC rarely increases length.
87
        normalizedCharacters.grow(sourceLength);
89
        normalizedCharacters.grow(sourceLength);
88
        int32_t normalizedLength = unorm_normalize(source, length, UNORM_NFC, 0, normalizedCharacters.data(), length, &err);
90
        int32_t normalizedLength = unorm_normalize(source, sourceLength, UNORM_NFC, 0, normalizedCharacters.data(), sourceLength, &err);
89
        if (err == U_BUFFER_OVERFLOW_ERROR) {
91
        if (err == U_BUFFER_OVERFLOW_ERROR) {
90
            err = U_ZERO_ERROR;
92
            err = U_ZERO_ERROR;
91
            normalizedCharacters.resize(normalizedLength);
93
            normalizedCharacters.resize(normalizedLength);
92
            normalizedLength = unorm_normalize(source, length, UNORM_NFC, 0, normalizedCharacters.data(), normalizedLength, &err);
94
            normalizedLength = unorm_normalize(source, sourceLength, UNORM_NFC, 0, normalizedCharacters.data(), normalizedLength, &err);
93
        }
95
        }
94
        ASSERT(U_SUCCESS(err));
96
        ASSERT(U_SUCCESS(err));
95
97
96
        source = normalizedCharacters.data();
98
        source = normalizedCharacters.data();
97
        sourceLength = normalizedLength;
99
        sourceLength = normalizedLength;
98
    }
100
    }
101
99
    return newTextCodec(*this)->encode(source, sourceLength, handling);
102
    return newTextCodec(*this)->encode(source, sourceLength, handling);
100
}
103
}
101
104
- a/Source/WebCore/platform/text/TextEncoding.h -1 / +1 lines
Lines 69-75 namespace WebCore { a/Source/WebCore/platform/text/TextEncoding.h_sec1
69
            return decode(str, length, false, ignored);
69
            return decode(str, length, false, ignored);
70
        }
70
        }
71
        String decode(const char*, size_t length, bool stopOnError, bool& sawError) const;
71
        String decode(const char*, size_t length, bool stopOnError, bool& sawError) const;
72
        CString encode(const UChar*, size_t length, UnencodableHandling) const;
72
        CString encode(StringView, UnencodableHandling) const;
73
73
74
        UChar backslashAsCurrencySymbol() const;
74
        UChar backslashAsCurrencySymbol() const;
75
75
- a/Source/WebCore/platform/text/TextEncodingRegistry.cpp -3 / +3 lines
Lines 336-347 const char* atomicCanonicalTextEncodingName(const CharacterType* characters, siz a/Source/WebCore/platform/text/TextEncodingRegistry.cpp_sec1
336
const char* atomicCanonicalTextEncodingName(const String& alias)
336
const char* atomicCanonicalTextEncodingName(const String& alias)
337
{
337
{
338
    if (!alias.length())
338
    if (!alias.length())
339
        return 0;
339
        return nullptr;
340
340
341
    if (alias.is8Bit())
341
    if (alias.is8Bit())
342
        return atomicCanonicalTextEncodingName<LChar>(alias.characters8(), alias.length());
342
        return atomicCanonicalTextEncodingName(alias.characters8(), alias.length());
343
343
344
    return atomicCanonicalTextEncodingName<UChar>(alias.deprecatedCharacters(), alias.length());
344
    return atomicCanonicalTextEncodingName(alias.characters16(), alias.length());
345
}
345
}
346
346
347
bool noExtendedTextEncodingNameUsed()
347
bool noExtendedTextEncodingNameUsed()
- a/Source/WebCore/platform/text/cf/HyphenationCF.cpp -4 / +3 lines
Lines 31-36 a/Source/WebCore/platform/text/cf/HyphenationCF.cpp_sec1
31
#include "TextBreakIteratorInternalICU.h"
31
#include "TextBreakIteratorInternalICU.h"
32
#include <wtf/ListHashSet.h>
32
#include <wtf/ListHashSet.h>
33
#include <wtf/RetainPtr.h>
33
#include <wtf/RetainPtr.h>
34
#include <wtf/text/StringView.h>
34
35
35
namespace WebCore {
36
namespace WebCore {
36
37
Lines 73-87 bool canHyphenate(const AtomicString& localeIdentifier) a/Source/WebCore/platform/text/cf/HyphenationCF.cpp_sec2
73
#endif // PLATFORM(IOS)
74
#endif // PLATFORM(IOS)
74
}
75
}
75
76
76
size_t lastHyphenLocation(const UChar* characters, size_t length, size_t beforeIndex, const AtomicString& localeIdentifier)
77
size_t lastHyphenLocation(StringView text, size_t beforeIndex, const AtomicString& localeIdentifier)
77
{
78
{
78
    RetainPtr<CFStringRef> string = adoptCF(CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, reinterpret_cast<const UniChar*>(characters), length, kCFAllocatorNull));
79
80
    RetainPtr<CFLocaleRef> locale = cfLocaleCache().get(localeIdentifier);
79
    RetainPtr<CFLocaleRef> locale = cfLocaleCache().get(localeIdentifier);
81
    ASSERT(locale);
80
    ASSERT(locale);
82
81
83
    CFOptionFlags searchAcrossWordBoundaries = 1;
82
    CFOptionFlags searchAcrossWordBoundaries = 1;
84
    CFIndex result = CFStringGetHyphenationLocationBeforeIndex(string.get(), beforeIndex, CFRangeMake(0, length), searchAcrossWordBoundaries, locale.get(), 0);
83
    CFIndex result = CFStringGetHyphenationLocationBeforeIndex(text.createCFStringWithoutCopying().get(), beforeIndex, CFRangeMake(0, text.length()), searchAcrossWordBoundaries, locale.get(), 0);
85
    return result == kCFNotFound ? 0 : result;
84
    return result == kCFNotFound ? 0 : result;
86
}
85
}
87
86
- a/Source/WebCore/rendering/RenderBlock.cpp -2 / +2 lines
Lines 5277-5285 TextRun RenderBlock::constructTextRun(RenderObject* context, const Font& font, c a/Source/WebCore/rendering/RenderBlock.cpp_sec1
5277
{
5277
{
5278
    unsigned length = string.length();
5278
    unsigned length = string.length();
5279
5279
5280
    if (length && string.is8Bit())
5280
    if (!length || string.is8Bit())
5281
        return constructTextRunInternal(context, font, string.characters8(), length, style, expansion, flags);
5281
        return constructTextRunInternal(context, font, string.characters8(), length, style, expansion, flags);
5282
    return constructTextRunInternal(context, font, string.deprecatedCharacters(), length, style, expansion, flags);
5282
    return constructTextRunInternal(context, font, string.characters16(), length, style, expansion, flags);
5283
}
5283
}
5284
5284
5285
RenderBlock* RenderBlock::createAnonymousWithParentRendererAndDisplay(const RenderObject* parent, EDisplay display)
5285
RenderBlock* RenderBlock::createAnonymousWithParentRendererAndDisplay(const RenderObject* parent, EDisplay display)
- a/Source/WebCore/rendering/RenderCombineText.cpp -3 lines
Lines 60-68 void RenderCombineText::setTextInternal(const String& text) a/Source/WebCore/rendering/RenderCombineText.cpp_sec1
60
60
61
float RenderCombineText::width(unsigned from, unsigned length, const Font& font, float xPosition, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
61
float RenderCombineText::width(unsigned from, unsigned length, const Font& font, float xPosition, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
62
{
62
{
63
    if (!deprecatedCharacters())
64
        return 0;
65
66
    if (m_isCombined)
63
    if (m_isCombined)
67
        return font.size();
64
        return font.size();
68
65
- a/Source/WebCore/rendering/RenderText.cpp -6 / +6 lines
Lines 624-638 static inline float hyphenWidth(RenderText* renderer, const Font& font) a/Source/WebCore/rendering/RenderText.cpp_sec1
624
    return font.width(RenderBlock::constructTextRun(renderer, font, style.hyphenString().string(), style));
624
    return font.width(RenderBlock::constructTextRun(renderer, font, style.hyphenString().string(), style));
625
}
625
}
626
626
627
static float maxWordFragmentWidth(RenderText* renderer, const RenderStyle& style, const Font& font, const UChar* word, int wordLength, int minimumPrefixLength, int minimumSuffixLength, int& suffixStart, HashSet<const SimpleFontData*>& fallbackFonts, GlyphOverflow& glyphOverflow)
627
static float maxWordFragmentWidth(RenderText* renderer, const RenderStyle& style, const Font& font, StringView word, int minimumPrefixLength, unsigned minimumSuffixLength, int& suffixStart, HashSet<const SimpleFontData*>& fallbackFonts, GlyphOverflow& glyphOverflow)
628
{
628
{
629
    suffixStart = 0;
629
    suffixStart = 0;
630
    if (wordLength <= minimumSuffixLength)
630
    if (word.length() <= minimumSuffixLength)
631
        return 0;
631
        return 0;
632
632
633
    Vector<int, 8> hyphenLocations;
633
    Vector<int, 8> hyphenLocations;
634
    int hyphenLocation = wordLength - minimumSuffixLength;
634
    int hyphenLocation = word.length() - minimumSuffixLength;
635
    while ((hyphenLocation = lastHyphenLocation(word, wordLength, hyphenLocation, style.locale())) >= minimumPrefixLength)
635
    while ((hyphenLocation = lastHyphenLocation(word, hyphenLocation, style.locale())) >= minimumPrefixLength)
636
        hyphenLocations.append(hyphenLocation);
636
        hyphenLocations.append(hyphenLocation);
637
637
638
    if (hyphenLocations.isEmpty())
638
    if (hyphenLocations.isEmpty())
Lines 645-651 static float maxWordFragmentWidth(RenderText* renderer, const RenderStyle& style a/Source/WebCore/rendering/RenderText.cpp_sec2
645
    for (size_t k = 0; k < hyphenLocations.size(); ++k) {
645
    for (size_t k = 0; k < hyphenLocations.size(); ++k) {
646
        int fragmentLength = hyphenLocations[k] - suffixStart;
646
        int fragmentLength = hyphenLocations[k] - suffixStart;
647
        StringBuilder fragmentWithHyphen;
647
        StringBuilder fragmentWithHyphen;
648
        fragmentWithHyphen.append(word + suffixStart, fragmentLength);
648
        fragmentWithHyphen.append(word.substring(suffixStart, fragmentLength));
649
        fragmentWithHyphen.append(style.hyphenString());
649
        fragmentWithHyphen.append(style.hyphenString());
650
650
651
        TextRun run = RenderBlock::constructTextRun(renderer, font, fragmentWithHyphen.deprecatedCharacters(), fragmentWithHyphen.length(), style);
651
        TextRun run = RenderBlock::constructTextRun(renderer, font, fragmentWithHyphen.deprecatedCharacters(), fragmentWithHyphen.length(), style);
Lines 797-803 void RenderText::computePreferredLogicalWidths(float leadWidth, HashSet<const Si a/Source/WebCore/rendering/RenderText.cpp_sec3
797
797
798
            if (w > maxWordWidth) {
798
            if (w > maxWordWidth) {
799
                int suffixStart;
799
                int suffixStart;
800
                float maxFragmentWidth = maxWordFragmentWidth(this, style, font, deprecatedCharacters() + i, wordLen, minimumPrefixLength, minimumSuffixLength, suffixStart, fallbackFonts, glyphOverflow);
800
                float maxFragmentWidth = maxWordFragmentWidth(this, style, font, StringView(m_text).substring(i, wordLen), minimumPrefixLength, minimumSuffixLength, suffixStart, fallbackFonts, glyphOverflow);
801
801
802
                if (suffixStart) {
802
                if (suffixStart) {
803
                    float suffixWidth;
803
                    float suffixWidth;
- a/Source/WebCore/rendering/line/BreakingContextInlineHeaders.h -2 / +2 lines
Lines 597-607 inline void tryHyphenating(RenderText* text, const Font& font, const AtomicStrin a/Source/WebCore/rendering/line/BreakingContextInlineHeaders.h_sec1
597
    if (prefixLength < minimumPrefixLength)
597
    if (prefixLength < minimumPrefixLength)
598
        return;
598
        return;
599
599
600
    prefixLength = lastHyphenLocation(text->deprecatedCharacters() + lastSpace, pos - lastSpace, std::min(prefixLength, pos - lastSpace - minimumSuffixLength) + 1, localeIdentifier);
600
    prefixLength = lastHyphenLocation(StringView(text->text()).substring(lastSpace, pos - lastSpace), std::min(prefixLength, pos - lastSpace - minimumSuffixLength) + 1, localeIdentifier);
601
    if (!prefixLength || prefixLength < minimumPrefixLength)
601
    if (!prefixLength || prefixLength < minimumPrefixLength)
602
        return;
602
        return;
603
603
604
    // When lastSapce is a space, which it always is except sometimes at the beginning of a line or after collapsed
604
    // When lastSpace is a space, which it always is except sometimes at the beginning of a line or after collapsed
605
    // space, it should not count towards hyphenate-limit-before.
605
    // space, it should not count towards hyphenate-limit-before.
606
    if (prefixLength == minimumPrefixLength) {
606
    if (prefixLength == minimumPrefixLength) {
607
        UChar characterAtLastSpace = text->characterAt(lastSpace);
607
        UChar characterAtLastSpace = text->characterAt(lastSpace);
- a/Source/WebCore/rendering/svg/SVGTextLayoutEngine.cpp -1 / +2 lines
Lines 436-442 void SVGTextLayoutEngine::layoutTextOnLineOrPath(SVGInlineTextBox* textBox, Rend a/Source/WebCore/rendering/svg/SVGTextLayoutEngine.cpp_sec1
436
    Vector<SVGTextMetrics>& visualMetricsValues = text->layoutAttributes()->textMetricsValues();
436
    Vector<SVGTextMetrics>& visualMetricsValues = text->layoutAttributes()->textMetricsValues();
437
    ASSERT(!visualMetricsValues.isEmpty());
437
    ASSERT(!visualMetricsValues.isEmpty());
438
438
439
    const UChar* characters = text->deprecatedCharacters();
439
    auto upconvertedCharacters = StringView(text->text()).upconvertedCharacters();
440
    const UChar* characters = upconvertedCharacters;
440
    const Font& font = style->font();
441
    const Font& font = style->font();
441
442
442
    SVGTextLayoutEngineSpacing spacingLayout(font);
443
    SVGTextLayoutEngineSpacing spacingLayout(font);
- a/Source/WebCore/rendering/svg/SVGTextMetrics.cpp -1 / +1 lines
Lines 105-111 SVGTextMetrics::SVGTextMetrics(RenderSVGInlineText* text, unsigned position, uns a/Source/WebCore/rendering/svg/SVGTextMetrics.cpp_sec1
105
    m_height = text->scaledFont().fontMetrics().floatHeight() / scalingFactor;
105
    m_height = text->scaledFont().fontMetrics().floatHeight() / scalingFactor;
106
    if (needsContext) {
106
    if (needsContext) {
107
        m_glyph.isValid = true;
107
        m_glyph.isValid = true;
108
        m_glyph.unicodeString = String(text->deprecatedCharacters() + position, length);
108
        m_glyph.unicodeString = text->text()->substring(position, length);
109
        m_glyph.name = glyphName;
109
        m_glyph.name = glyphName;
110
    }
110
    }
111
111
- a/Source/WebCore/svg/SVGAngle.cpp -2 / +3 lines
Lines 25-31 a/Source/WebCore/svg/SVGAngle.cpp_sec1
25
#include "ExceptionCode.h"
25
#include "ExceptionCode.h"
26
#include "SVGParserUtilities.h"
26
#include "SVGParserUtilities.h"
27
#include <wtf/MathExtras.h>
27
#include <wtf/MathExtras.h>
28
#include <wtf/text/WTFString.h>
28
#include <wtf/text/StringView.h>
29
29
30
namespace WebCore {
30
namespace WebCore {
31
31
Lines 140-146 void SVGAngle::setValueAsString(const String& value, ExceptionCode& ec) a/Source/WebCore/svg/SVGAngle.cpp_sec2
140
    }
140
    }
141
141
142
    float valueInSpecifiedUnits = 0;
142
    float valueInSpecifiedUnits = 0;
143
    const UChar* ptr = value.deprecatedCharacters();
143
    auto upconvertedCharacters = StringView(value).upconvertedCharacters();
144
    const UChar* ptr = upconvertedCharacters;
144
    const UChar* end = ptr + value.length();
145
    const UChar* end = ptr + value.length();
145
146
146
    if (!parseNumber(ptr, end, valueInSpecifiedUnits, false)) {
147
    if (!parseNumber(ptr, end, valueInSpecifiedUnits, false)) {
- a/Source/WebCore/svg/SVGAnimateMotionElement.cpp -1 / +3 lines
Lines 38-43 a/Source/WebCore/svg/SVGAnimateMotionElement.cpp_sec1
38
#include "SVGTransformList.h"
38
#include "SVGTransformList.h"
39
#include <wtf/MathExtras.h>
39
#include <wtf/MathExtras.h>
40
#include <wtf/StdLibExtras.h>
40
#include <wtf/StdLibExtras.h>
41
#include <wtf/text/StringView.h>
41
42
42
namespace WebCore {
43
namespace WebCore {
43
    
44
    
Lines 156-162 static bool parsePoint(const String& s, FloatPoint& point) a/Source/WebCore/svg/SVGAnimateMotionElement.cpp_sec2
156
{
157
{
157
    if (s.isEmpty())
158
    if (s.isEmpty())
158
        return false;
159
        return false;
159
    const UChar* cur = s.deprecatedCharacters();
160
    auto upconvertedCharacters = StringView(s).upconvertedCharacters();
161
    const UChar* cur = upconvertedCharacters;
160
    const UChar* end = cur + s.length();
162
    const UChar* end = cur + s.length();
161
    
163
    
162
    if (!skipOptionalSVGSpaces(cur, end))
164
    if (!skipOptionalSVGSpaces(cur, end))
- a/Source/WebCore/svg/SVGAnimationElement.cpp -1 / +4 lines
Lines 38-43 a/Source/WebCore/svg/SVGAnimationElement.cpp_sec1
38
#include "SVGNames.h"
38
#include "SVGNames.h"
39
#include "SVGParserUtilities.h"
39
#include "SVGParserUtilities.h"
40
#include <wtf/MathExtras.h>
40
#include <wtf/MathExtras.h>
41
#include <wtf/text/StringView.h>
41
42
42
namespace WebCore {
43
namespace WebCore {
43
44
Lines 92-98 static void parseKeySplines(const String& parse, Vector<UnitBezier>& result) a/Source/WebCore/svg/SVGAnimationElement.cpp_sec2
92
    result.clear();
93
    result.clear();
93
    if (parse.isEmpty())
94
    if (parse.isEmpty())
94
        return;
95
        return;
95
    const UChar* cur = parse.deprecatedCharacters();
96
97
    auto upconvertedCharacters = StringView(parse).upconvertedCharacters();
98
    const UChar* cur = upconvertedCharacters;
96
    const UChar* end = cur + parse.length();
99
    const UChar* end = cur + parse.length();
97
100
98
    skipOptionalSVGSpaces(cur, end);
101
    skipOptionalSVGSpaces(cur, end);
- a/Source/WebCore/svg/SVGFitToViewBox.cpp -4 / +4 lines
Lines 29-43 a/Source/WebCore/svg/SVGFitToViewBox.cpp_sec1
29
#include "SVGNames.h"
29
#include "SVGNames.h"
30
#include "SVGParserUtilities.h"
30
#include "SVGParserUtilities.h"
31
#include "SVGPreserveAspectRatio.h"
31
#include "SVGPreserveAspectRatio.h"
32
#include <wtf/text/StringImpl.h>
32
#include <wtf/text/StringView.h>
33
33
34
namespace WebCore {
34
namespace WebCore {
35
35
36
bool SVGFitToViewBox::parseViewBox(Document* doc, const String& s, FloatRect& viewBox)
36
bool SVGFitToViewBox::parseViewBox(Document* doc, const String& s, FloatRect& viewBox)
37
{
37
{
38
    const UChar* c = s.deprecatedCharacters();
38
    auto upconvertedCharacters = StringView(s).upconvertedCharacters();
39
    const UChar* end = c + s.length();
39
    const UChar* characters = upconvertedCharacters;
40
    return parseViewBox(doc, c, end, viewBox, true);
40
    return parseViewBox(doc, characters, characters + s.length(), viewBox, true);
41
}
41
}
42
42
43
bool SVGFitToViewBox::parseViewBox(Document* doc, const UChar*& c, const UChar* end, FloatRect& viewBox, bool validate)
43
bool SVGFitToViewBox::parseViewBox(Document* doc, const UChar*& c, const UChar* end, FloatRect& viewBox, bool validate)
- a/Source/WebCore/svg/SVGFontData.cpp -7 / +7 lines
Lines 41-46 using namespace Unicode; a/Source/WebCore/svg/SVGFontData.cpp_sec1
41
41
42
namespace WebCore {
42
namespace WebCore {
43
43
44
static String createStringWithMirroredCharacters(StringView);
45
44
SVGFontData::SVGFontData(SVGFontFaceElement* fontFaceElement)
46
SVGFontData::SVGFontData(SVGFontFaceElement* fontFaceElement)
45
    : m_svgFontFaceElement(fontFaceElement)
47
    : m_svgFontFaceElement(fontFaceElement)
46
    , m_horizontalOriginX(fontFaceElement->horizontalOriginX())
48
    , m_horizontalOriginX(fontFaceElement->horizontalOriginX())
Lines 146-152 bool SVGFontData::applySVGGlyphSelection(WidthIterator& iterator, GlyphData& gly a/Source/WebCore/svg/SVGFontData.cpp_sec2
146
    }
148
    }
147
149
148
    if (mirror)
150
    if (mirror)
149
        remainingTextInRun = createStringWithMirroredCharacters(remainingTextInRun.deprecatedCharacters(), remainingTextInRun.length());
151
        remainingTextInRun = createStringWithMirroredCharacters(remainingTextInRun);
150
    if (!currentCharacter && arabicForms.isEmpty())
152
    if (!currentCharacter && arabicForms.isEmpty())
151
        arabicForms = charactersWithArabicForm(remainingTextInRun, mirror);
153
        arabicForms = charactersWithArabicForm(remainingTextInRun, mirror);
152
154
Lines 287-304 bool SVGFontData::fillNonBMPGlyphs(SVGFontElement* fontElement, GlyphPage* pageT a/Source/WebCore/svg/SVGFontData.cpp_sec3
287
    return haveGlyphs;
289
    return haveGlyphs;
288
}
290
}
289
291
290
String SVGFontData::createStringWithMirroredCharacters(const UChar* characters, unsigned length) const
292
String createStringWithMirroredCharacters(StringView string)
291
{
293
{
294
    unsigned length = string.length();
292
    StringBuilder mirroredCharacters;
295
    StringBuilder mirroredCharacters;
293
    mirroredCharacters.reserveCapacity(length);
296
    mirroredCharacters.reserveCapacity(length);
294
297
    for (unsigned i = 0; i < length; ) {
295
    unsigned i = 0;
296
    while (i < length) {
297
        UChar32 character;
298
        UChar32 character;
298
        U16_NEXT(characters, i, length, character);
299
        U16_NEXT(string, i, length, character);
299
        mirroredCharacters.append(u_charMirror(character));
300
        mirroredCharacters.append(u_charMirror(character));
300
    }
301
    }
301
302
    return mirroredCharacters.toString();
302
    return mirroredCharacters.toString();
303
}
303
}
304
304
- a/Source/WebCore/svg/SVGFontData.h -2 lines
Lines 52-59 private: a/Source/WebCore/svg/SVGFontData.h_sec1
52
    bool fillBMPGlyphs(SVGFontElement*, GlyphPage* , unsigned offset, unsigned length, UChar* buffer, const SimpleFontData*) const;
52
    bool fillBMPGlyphs(SVGFontElement*, GlyphPage* , unsigned offset, unsigned length, UChar* buffer, const SimpleFontData*) const;
53
    bool fillNonBMPGlyphs(SVGFontElement*, GlyphPage* , unsigned offset, unsigned length, UChar* buffer, const SimpleFontData*) const;
53
    bool fillNonBMPGlyphs(SVGFontElement*, GlyphPage* , unsigned offset, unsigned length, UChar* buffer, const SimpleFontData*) const;
54
54
55
    String createStringWithMirroredCharacters(const UChar* characters, unsigned length) const;
56
57
    // Ths SVGFontFaceElement is kept alive --
55
    // Ths SVGFontFaceElement is kept alive --
58
    // 1) in the external font case: by the CSSFontFaceSource, which holds a reference to the external SVG document
56
    // 1) in the external font case: by the CSSFontFaceSource, which holds a reference to the external SVG document
59
    //    containing the element;
57
    //    containing the element;
- a/Source/WebCore/svg/SVGFontElement.cpp -2 / +2 lines
Lines 94-102 void SVGFontElement::registerLigaturesInGlyphCache(Vector<String>& ligatures) a/Source/WebCore/svg/SVGFontElement.cpp_sec1
94
        unsigned unicodeLength = unicode.length();
94
        unsigned unicodeLength = unicode.length();
95
        ASSERT(unicodeLength > 1);
95
        ASSERT(unicodeLength > 1);
96
96
97
        const UChar* characters = unicode.deprecatedCharacters();
98
        for (unsigned i = 0; i < unicodeLength; ++i) {
97
        for (unsigned i = 0; i < unicodeLength; ++i) {
99
            String lookupString(characters + i, 1);
98
            UChar character = unicode[i];
99
            String lookupString(&character, 1);
100
            m_glyphMap.collectGlyphsForString(lookupString, glyphs);
100
            m_glyphMap.collectGlyphsForString(lookupString, glyphs);
101
            if (!glyphs.isEmpty()) {
101
            if (!glyphs.isEmpty()) {
102
                glyphs.clear();
102
                glyphs.clear();
- a/Source/WebCore/svg/SVGGlyphMap.h -4 / +6 lines
Lines 21-31 a/Source/WebCore/svg/SVGGlyphMap.h_sec1
21
#define SVGGlyphMap_h
21
#define SVGGlyphMap_h
22
22
23
#if ENABLE(SVG_FONTS)
23
#if ENABLE(SVG_FONTS)
24
24
#include "SurrogatePairAwareTextIterator.h"
25
#include "SurrogatePairAwareTextIterator.h"
25
#include "SVGGlyph.h"
26
#include "SVGGlyph.h"
26
27
#include <wtf/HashMap.h>
27
#include <wtf/HashMap.h>
28
#include <wtf/Vector.h>
28
#include <wtf/Vector.h>
29
#include <wtf/text/StringView.h>
29
30
30
namespace WebCore {
31
namespace WebCore {
31
32
Lines 68-74 public: a/Source/WebCore/svg/SVGGlyphMap.h_sec2
68
69
69
        UChar32 character = 0;
70
        UChar32 character = 0;
70
        unsigned clusterLength = 0;
71
        unsigned clusterLength = 0;
71
        SurrogatePairAwareTextIterator textIterator(unicodeString.deprecatedCharacters(), 0, length, length);
72
        auto upconvertedCharacters = StringView(unicodeString).upconvertedCharacters();
73
        SurrogatePairAwareTextIterator textIterator(upconvertedCharacters, 0, length, length);
72
        while (textIterator.consume(character, clusterLength)) {
74
        while (textIterator.consume(character, clusterLength)) {
73
            node = currentLayer->get(character);
75
            node = currentLayer->get(character);
74
            if (!node) {
76
            if (!node) {
Lines 113-124 public: a/Source/WebCore/svg/SVGGlyphMap.h_sec3
113
    {
115
    {
114
        GlyphMapLayer* currentLayer = &m_rootLayer;
116
        GlyphMapLayer* currentLayer = &m_rootLayer;
115
117
116
        const UChar* characters = string.deprecatedCharacters();
118
        auto upconvertedCharacters = StringView(string).upconvertedCharacters();
117
        size_t length = string.length();
119
        size_t length = string.length();
118
120
119
        UChar32 character = 0;
121
        UChar32 character = 0;
120
        unsigned clusterLength = 0;
122
        unsigned clusterLength = 0;
121
        SurrogatePairAwareTextIterator textIterator(characters, 0, length, length);
123
        SurrogatePairAwareTextIterator textIterator(upconvertedCharacters, 0, length, length);
122
        while (textIterator.consume(character, clusterLength)) {
124
        while (textIterator.consume(character, clusterLength)) {
123
            RefPtr<GlyphMapNode> node = currentLayer->get(character);
125
            RefPtr<GlyphMapNode> node = currentLayer->get(character);
124
            if (!node)
126
            if (!node)
- a/Source/WebCore/svg/SVGGlyphRefElement.cpp -1 / +3 lines
Lines 27-32 a/Source/WebCore/svg/SVGGlyphRefElement.cpp_sec1
27
#include "SVGParserUtilities.h"
27
#include "SVGParserUtilities.h"
28
#include "XLinkNames.h"
28
#include "XLinkNames.h"
29
#include <wtf/text/AtomicString.h>
29
#include <wtf/text/AtomicString.h>
30
#include <wtf/text/StringView.h>
30
31
31
namespace WebCore {
32
namespace WebCore {
32
33
Lines 66-72 bool SVGGlyphRefElement::hasValidGlyphElement(String& glyphName) const a/Source/WebCore/svg/SVGGlyphRefElement.cpp_sec2
66
67
67
void SVGGlyphRefElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
68
void SVGGlyphRefElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
68
{
69
{
69
    const UChar* startPtr = value.string().deprecatedCharacters();
70
    auto upconvertedCharacters = StringView(value.string()).upconvertedCharacters();
71
    const UChar* startPtr = upconvertedCharacters;
70
    const UChar* endPtr = startPtr + value.length();
72
    const UChar* endPtr = startPtr + value.length();
71
73
72
    // FIXME: We need some error handling here.
74
    // FIXME: We need some error handling here.
- a/Source/WebCore/svg/SVGLength.cpp -3 / +3 lines
Lines 29-37 a/Source/WebCore/svg/SVGLength.cpp_sec1
29
#include "FloatConversion.h"
29
#include "FloatConversion.h"
30
#include "SVGNames.h"
30
#include "SVGNames.h"
31
#include "SVGParserUtilities.h"
31
#include "SVGParserUtilities.h"
32
33
#include <wtf/MathExtras.h>
32
#include <wtf/MathExtras.h>
34
#include <wtf/text/WTFString.h>
33
#include <wtf/text/StringView.h>
35
34
36
namespace WebCore {
35
namespace WebCore {
37
36
Lines 224-230 void SVGLength::setValueAsString(const String& string, ExceptionCode& ec) a/Source/WebCore/svg/SVGLength.cpp_sec2
224
        return;
223
        return;
225
224
226
    float convertedNumber = 0;
225
    float convertedNumber = 0;
227
    const UChar* ptr = string.deprecatedCharacters();
226
    auto upconvertedCharacters = StringView(string).upconvertedCharacters();
227
    const UChar* ptr = upconvertedCharacters;
228
    const UChar* end = ptr + string.length();
228
    const UChar* end = ptr + string.length();
229
229
230
    if (!parseNumber(ptr, end, convertedNumber, false)) {
230
    if (!parseNumber(ptr, end, convertedNumber, false)) {
- a/Source/WebCore/svg/SVGLengthList.cpp -1 / +2 lines
Lines 31-37 void SVGLengthList::parse(const String& value, SVGLengthMode mode) a/Source/WebCore/svg/SVGLengthList.cpp_sec1
31
    clear();
31
    clear();
32
    ExceptionCode ec = 0;
32
    ExceptionCode ec = 0;
33
33
34
    const UChar* ptr = value.deprecatedCharacters();
34
    auto upconvertedCharacters = StringView(value).upconvertedCharacters();
35
    const UChar* ptr = upconvertedCharacters;
35
    const UChar* end = ptr + value.length();
36
    const UChar* end = ptr + value.length();
36
    while (ptr < end) {
37
    while (ptr < end) {
37
        const UChar* start = ptr;
38
        const UChar* start = ptr;
- a/Source/WebCore/svg/SVGNumberList.cpp -1 / +2 lines
Lines 31-37 void SVGNumberList::parse(const String& value) a/Source/WebCore/svg/SVGNumberList.cpp_sec1
31
    clear();
31
    clear();
32
32
33
    float number = 0;
33
    float number = 0;
34
    const UChar* ptr = value.deprecatedCharacters();
34
    auto upconvertedCharacters = StringView(value).upconvertedCharacters();
35
    const UChar* ptr = upconvertedCharacters;
35
    const UChar* end = ptr + value.length();
36
    const UChar* end = ptr + value.length();
36
37
37
    // The spec strangely doesn't allow leading whitespace.  We might choose to violate that intentionally. (section 4.1)
38
    // The spec strangely doesn't allow leading whitespace.  We might choose to violate that intentionally. (section 4.1)
- a/Source/WebCore/svg/SVGParserUtilities.cpp -8 / +16 lines
Lines 26-34 a/Source/WebCore/svg/SVGParserUtilities.cpp_sec1
26
#include "Document.h"
26
#include "Document.h"
27
#include "FloatRect.h"
27
#include "FloatRect.h"
28
#include "SVGPointList.h"
28
#include "SVGPointList.h"
29
30
#include <limits>
29
#include <limits>
31
#include <wtf/ASCIICType.h>
30
#include <wtf/ASCIICType.h>
31
#include <wtf/text/StringView.h>
32
32
33
namespace WebCore {
33
namespace WebCore {
34
34
Lines 164-170 bool parseNumber(const UChar*& ptr, const UChar* end, float& number, bool skip) a/Source/WebCore/svg/SVGParserUtilities.cpp_sec2
164
164
165
bool parseNumberFromString(const String& string, float& number, bool skip)
165
bool parseNumberFromString(const String& string, float& number, bool skip)
166
{
166
{
167
    const UChar* ptr = string.deprecatedCharacters();
167
    auto upconvertedCharacters = StringView(string).upconvertedCharacters();
168
    const UChar* ptr = upconvertedCharacters;
168
    const UChar* end = ptr + string.length();
169
    const UChar* end = ptr + string.length();
169
    return genericParseNumber(ptr, end, number, skip) && ptr == end;
170
    return genericParseNumber(ptr, end, number, skip) && ptr == end;
170
}
171
}
Lines 203-209 bool parseNumberOptionalNumber(const String& s, float& x, float& y) a/Source/WebCore/svg/SVGParserUtilities.cpp_sec3
203
{
204
{
204
    if (s.isEmpty())
205
    if (s.isEmpty())
205
        return false;
206
        return false;
206
    const UChar* cur = s.deprecatedCharacters();
207
208
    auto upconvertedCharacters = StringView(s).upconvertedCharacters();
209
    const UChar* cur = upconvertedCharacters;
207
    const UChar* end = cur + s.length();
210
    const UChar* end = cur + s.length();
208
211
209
    if (!parseNumber(cur, end, x))
212
    if (!parseNumber(cur, end, x))
Lines 219-225 bool parseNumberOptionalNumber(const String& s, float& x, float& y) a/Source/WebCore/svg/SVGParserUtilities.cpp_sec4
219
222
220
bool parseRect(const String& string, FloatRect& rect)
223
bool parseRect(const String& string, FloatRect& rect)
221
{
224
{
222
    const UChar* ptr = string.deprecatedCharacters();
225
    auto upconvertedCharacters = StringView(string).upconvertedCharacters();
226
    const UChar* ptr = upconvertedCharacters;
223
    const UChar* end = ptr + string.length();
227
    const UChar* end = ptr + string.length();
224
    skipOptionalSVGSpaces(ptr, end);
228
    skipOptionalSVGSpaces(ptr, end);
225
    
229
    
Lines 236-242 bool pointsListFromSVGData(SVGPointList& pointsList, const String& points) a/Source/WebCore/svg/SVGParserUtilities.cpp_sec5
236
{
240
{
237
    if (points.isEmpty())
241
    if (points.isEmpty())
238
        return true;
242
        return true;
239
    const UChar* cur = points.deprecatedCharacters();
243
    auto upconvertedCharacters = StringView(points).upconvertedCharacters();
244
    const UChar* cur = upconvertedCharacters;
240
    const UChar* end = cur + points.length();
245
    const UChar* end = cur + points.length();
241
246
242
    skipOptionalSVGSpaces(cur, end);
247
    skipOptionalSVGSpaces(cur, end);
Lines 270-276 bool parseGlyphName(const String& input, HashSet<String>& values) a/Source/WebCore/svg/SVGParserUtilities.cpp_sec6
270
    // FIXME: Parsing error detection is missing.
275
    // FIXME: Parsing error detection is missing.
271
    values.clear();
276
    values.clear();
272
277
273
    const UChar* ptr = input.deprecatedCharacters();
278
    auto upconvertedCharacters = StringView(input).upconvertedCharacters();
279
    const UChar* ptr = upconvertedCharacters;
274
    const UChar* end = ptr + input.length();
280
    const UChar* end = ptr + input.length();
275
    skipOptionalSVGSpaces(ptr, end);
281
    skipOptionalSVGSpaces(ptr, end);
276
282
Lines 367-373 static bool parseUnicodeRange(const UChar* characters, unsigned length, UnicodeR a/Source/WebCore/svg/SVGParserUtilities.cpp_sec7
367
bool parseKerningUnicodeString(const String& input, UnicodeRanges& rangeList, HashSet<String>& stringList)
373
bool parseKerningUnicodeString(const String& input, UnicodeRanges& rangeList, HashSet<String>& stringList)
368
{
374
{
369
    // FIXME: Parsing error detection is missing.
375
    // FIXME: Parsing error detection is missing.
370
    const UChar* ptr = input.deprecatedCharacters();
376
    auto upconvertedCharacters = StringView(input).upconvertedCharacters();
377
    const UChar* ptr = upconvertedCharacters;
371
    const UChar* end = ptr + input.length();
378
    const UChar* end = ptr + input.length();
372
379
373
    while (ptr < end) {
380
    while (ptr < end) {
Lines 394-400 Vector<String> parseDelimitedString(const String& input, const char seperator) a/Source/WebCore/svg/SVGParserUtilities.cpp_sec8
394
{
401
{
395
    Vector<String> values;
402
    Vector<String> values;
396
403
397
    const UChar* ptr = input.deprecatedCharacters();
404
    auto upconvertedCharacters = StringView(input).upconvertedCharacters();
405
    const UChar* ptr = upconvertedCharacters;
398
    const UChar* end = ptr + input.length();
406
    const UChar* end = ptr + input.length();
399
    skipOptionalSVGSpaces(ptr, end);
407
    skipOptionalSVGSpaces(ptr, end);
400
408
- a/Source/WebCore/svg/SVGPreserveAspectRatio.cpp -2 / +3 lines
Lines 26-32 a/Source/WebCore/svg/SVGPreserveAspectRatio.cpp_sec1
26
#include "ExceptionCode.h"
26
#include "ExceptionCode.h"
27
#include "FloatRect.h"
27
#include "FloatRect.h"
28
#include "SVGParserUtilities.h"
28
#include "SVGParserUtilities.h"
29
#include <wtf/text/WTFString.h>
29
#include <wtf/text/StringView.h>
30
30
31
namespace WebCore {
31
namespace WebCore {
32
32
Lines 58-64 void SVGPreserveAspectRatio::setMeetOrSlice(unsigned short meetOrSlice, Exceptio a/Source/WebCore/svg/SVGPreserveAspectRatio.cpp_sec2
58
58
59
void SVGPreserveAspectRatio::parse(const String& value)
59
void SVGPreserveAspectRatio::parse(const String& value)
60
{
60
{
61
    const UChar* begin = value.deprecatedCharacters();
61
    auto upconvertedCharacters = StringView(value).upconvertedCharacters();
62
    const UChar* begin = upconvertedCharacters;
62
    parseInternal(begin, begin + value.length(), true);
63
    parseInternal(begin, begin + value.length(), true);
63
}
64
}
64
65
- a/Source/WebCore/svg/SVGStringList.cpp -1 / +2 lines
Lines 48-54 void SVGStringList::parse(const String& data, UChar delimiter) a/Source/WebCore/svg/SVGStringList.cpp_sec1
48
    // TODO : more error checking/reporting
48
    // TODO : more error checking/reporting
49
    clear();
49
    clear();
50
50
51
    const UChar* ptr = data.deprecatedCharacters();
51
    auto upconvertedCharacters = StringView(data).upconvertedCharacters();
52
    const UChar* ptr = upconvertedCharacters;
52
    const UChar* end = ptr + data.length();
53
    const UChar* end = ptr + data.length();
53
    while (ptr < end) {
54
    while (ptr < end) {
54
        const UChar* start = ptr;
55
        const UChar* start = ptr;
- a/Source/WebCore/svg/SVGTransformList.cpp -1 / +2 lines
Lines 74-80 String SVGTransformList::valueAsString() const a/Source/WebCore/svg/SVGTransformList.cpp_sec1
74
74
75
void SVGTransformList::parse(const String& transform)
75
void SVGTransformList::parse(const String& transform)
76
{
76
{
77
    const UChar* start = transform.deprecatedCharacters();
77
    auto upconvertedCharacters = StringView(transform).upconvertedCharacters();
78
    const UChar* start = upconvertedCharacters;
78
    if (!SVGTransformable::parseTransformAttribute(*this, start, start + transform.length()))
79
    if (!SVGTransformable::parseTransformAttribute(*this, start, start + transform.length()))
79
        clear();
80
        clear();
80
}
81
}
- a/Source/WebCore/svg/SVGTransformable.cpp -1 / +3 lines
Lines 28-33 a/Source/WebCore/svg/SVGTransformable.cpp_sec1
28
#include "SVGNames.h"
28
#include "SVGNames.h"
29
#include "SVGParserUtilities.h"
29
#include "SVGParserUtilities.h"
30
#include "SVGTransformList.h"
30
#include "SVGTransformList.h"
31
#include <wtf/text/StringView.h>
31
32
32
namespace WebCore {
33
namespace WebCore {
33
34
Lines 171-177 static inline bool parseAndSkipType(const UChar*& currTransform, const UChar* en a/Source/WebCore/svg/SVGTransformable.cpp_sec2
171
SVGTransform::SVGTransformType SVGTransformable::parseTransformType(const String& typeString)
172
SVGTransform::SVGTransformType SVGTransformable::parseTransformType(const String& typeString)
172
{
173
{
173
    unsigned short type = SVGTransform::SVG_TRANSFORM_UNKNOWN;
174
    unsigned short type = SVGTransform::SVG_TRANSFORM_UNKNOWN;
174
    const UChar* characters = typeString.deprecatedCharacters();
175
    auto upconvertedCharacters = StringView(typeString).upconvertedCharacters();
176
    const UChar* characters = upconvertedCharacters;
175
    parseAndSkipType(characters, characters + typeString.length(), type);
177
    parseAndSkipType(characters, characters + typeString.length(), type);
176
    return static_cast<SVGTransform::SVGTransformType>(type);
178
    return static_cast<SVGTransform::SVGTransformType>(type);
177
}
179
}
- a/Source/WebCore/svg/SVGViewSpec.cpp -1 / +2 lines
Lines 207-213 static const UChar viewTargetSpec[] = {'v', 'i', 'e', 'w', 'T', 'a', 'r', 'g', a/Source/WebCore/svg/SVGViewSpec.cpp_sec1
207
207
208
bool SVGViewSpec::parseViewSpec(const String& viewSpec)
208
bool SVGViewSpec::parseViewSpec(const String& viewSpec)
209
{
209
{
210
    const UChar* currViewSpec = viewSpec.deprecatedCharacters();
210
    auto upconvertedCharacters = StringView(viewSpec).upconvertedCharacters();
211
    const UChar* currViewSpec = upconvertedCharacters;
211
    const UChar* end = currViewSpec + viewSpec.length();
212
    const UChar* end = currViewSpec + viewSpec.length();
212
213
213
    if (currViewSpec >= end || !m_contextElement)
214
    if (currViewSpec >= end || !m_contextElement)
- a/Source/WebCore/svg/SVGZoomAndPan.h -1 / +3 lines
Lines 24-29 a/Source/WebCore/svg/SVGZoomAndPan.h_sec1
24
#include "QualifiedName.h"
24
#include "QualifiedName.h"
25
#include "SVGNames.h"
25
#include "SVGNames.h"
26
#include <wtf/HashSet.h>
26
#include <wtf/HashSet.h>
27
#include <wtf/text/StringView.h>
27
28
28
namespace WebCore {
29
namespace WebCore {
29
30
Lines 59-65 public: a/Source/WebCore/svg/SVGZoomAndPan.h_sec2
59
    {
60
    {
60
        ASSERT(target);
61
        ASSERT(target);
61
        if (name == SVGNames::zoomAndPanAttr) {
62
        if (name == SVGNames::zoomAndPanAttr) {
62
            const UChar* start = value.string().deprecatedCharacters();
63
            auto upconvertedCharacters = StringView(value.string()).upconvertedCharacters();
64
            const UChar* start = upconvertedCharacters;
63
            const UChar* end = start + value.length();
65
            const UChar* end = start + value.length();
64
            SVGZoomAndPanType zoomAndPan = SVGZoomAndPanUnknown;
66
            SVGZoomAndPanType zoomAndPan = SVGZoomAndPanUnknown;
65
            parseZoomAndPan(start, end, zoomAndPan);
67
            parseZoomAndPan(start, end, zoomAndPan);
- a/Source/WebCore/xml/XMLHttpRequest.cpp -2 / +2 lines
Lines 619-625 void XMLHttpRequest::send(Document* document, ExceptionCode& ec) a/Source/WebCore/xml/XMLHttpRequest.cpp_sec1
619
619
620
        // FIXME: this should use value of document.inputEncoding to determine the encoding to use.
620
        // FIXME: this should use value of document.inputEncoding to determine the encoding to use.
621
        TextEncoding encoding = UTF8Encoding();
621
        TextEncoding encoding = UTF8Encoding();
622
        m_requestEntityBody = FormData::create(encoding.encode(body.deprecatedCharacters(), body.length(), EntitiesForUnencodables));
622
        m_requestEntityBody = FormData::create(encoding.encode(body, EntitiesForUnencodables));
623
        if (m_upload)
623
        if (m_upload)
624
            m_requestEntityBody->setAlwaysStream(true);
624
            m_requestEntityBody->setAlwaysStream(true);
625
    }
625
    }
Lines 646-652 void XMLHttpRequest::send(const String& body, ExceptionCode& ec) a/Source/WebCore/xml/XMLHttpRequest.cpp_sec2
646
            m_requestHeaders.set("Content-Type", contentType);
646
            m_requestHeaders.set("Content-Type", contentType);
647
        }
647
        }
648
648
649
        m_requestEntityBody = FormData::create(UTF8Encoding().encode(body.deprecatedCharacters(), body.length(), EntitiesForUnencodables));
649
        m_requestEntityBody = FormData::create(UTF8Encoding().encode(body, EntitiesForUnencodables));
650
        if (m_upload)
650
        if (m_upload)
651
            m_requestEntityBody->setAlwaysStream(true);
651
            m_requestEntityBody->setAlwaysStream(true);
652
    }
652
    }
- a/Source/WebCore/xml/XSLStyleSheetLibxslt.cpp -2 / +2 lines
Lines 33-39 a/Source/WebCore/xml/XSLStyleSheetLibxslt.cpp_sec1
33
#include "XMLDocumentParserScope.h"
33
#include "XMLDocumentParserScope.h"
34
#include "XSLImportRule.h"
34
#include "XSLImportRule.h"
35
#include "XSLTProcessor.h"
35
#include "XSLTProcessor.h"
36
37
#include <libxml/uri.h>
36
#include <libxml/uri.h>
38
#include <libxslt/xsltutils.h>
37
#include <libxslt/xsltutils.h>
39
38
Lines 148-154 bool XSLStyleSheet::parseString(const String& string) a/Source/WebCore/xml/XSLStyleSheetLibxslt.cpp_sec2
148
147
149
    XMLDocumentParserScope scope(cachedResourceLoader(), XSLTProcessor::genericErrorFunc, XSLTProcessor::parseErrorFunc, console);
148
    XMLDocumentParserScope scope(cachedResourceLoader(), XSLTProcessor::genericErrorFunc, XSLTProcessor::parseErrorFunc, console);
150
149
151
    const char* buffer = reinterpret_cast<const char*>(string.deprecatedCharacters());
150
    auto upconvertedCharacters = StringView(string).upconvertedCharacters();
151
    const char* buffer = reinterpret_cast<const char*>(upconvertedCharacters.get());
152
    int size = string.length() * sizeof(UChar);
152
    int size = string.length() * sizeof(UChar);
153
153
154
    xmlParserCtxtPtr ctxt = xmlCreateMemoryParserCtxt(buffer, size);
154
    xmlParserCtxtPtr ctxt = xmlCreateMemoryParserCtxt(buffer, size);

Return to Bug 130318