Reduce use of deprecatedCharacters in WebCore
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Mar 2014 21:57:44 +0000 (21:57 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Mar 2014 21:57:44 +0000 (21:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=130318

Reviewed by Andreas Kling.

Source/WebCore:

* Modules/indexeddb/IDBKeyPath.cpp:
(WebCore::IDBKeyPathLexer::IDBKeyPathLexer): Use StringView for parsing.
(WebCore::IDBKeyPathLexer::lex): Ditto.
(WebCore::IDBKeyPathLexer::lexIdentifier): Ditto.

* Modules/indexeddb/leveldb/IDBLevelDBCoding.cpp:
(WebCore::IDBLevelDBCoding::encodeString): Index directly into string instead of
using deprecatedCharacters.

* Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp:
(WebCore::ThreadableWebSocketChannelClientWrapper::setSubprotocol): Use
StringView::getCharactersWithUpconvert.
(WebCore::ThreadableWebSocketChannelClientWrapper::setExtensions): Ditto.

* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(-[WebAccessibilityObjectWrapper arrayOfTextForTextMarkers:attributed:]):
Use operator NSString * instead of explicitly creating an NSString.

* bindings/js/SerializedScriptValue.cpp:
(WebCore::writeLittleEndianUInt16): Added.
(WebCore::CloneSerializer::serialize): Added a separate code path for 8-bit strings.
(WebCore::CloneSerializer::write): Ditto.

* bindings/objc/WebScriptObject.mm:
(+[WebScriptObject _convertValueToObjcValue:JSC::originRootObject:rootObject:]):
Use operator NSString * instead of explicitly creating an NSString.

* dom/Document.cpp:
(WebCore::Document::parseQualifiedName): Index directly into string instead of
using deprecatedCharacters.
* editing/CompositeEditCommand.cpp:
(WebCore::containsOnlyWhitespace): Ditto.
* editing/SmartReplace.cpp:
(WebCore::addAllCodePoints): Ditto.
(WebCore::getSmartSet): Use StringView::upconvertedCharacters.

* editing/TextIterator.cpp:
(WebCore::foldQuoteMarksAndSoftHyphens): Changed to return a value so it can be
used in initialization rather than assignment.
(WebCore::SearchBuffer::SearchBuffer): Use StringView::upconvertedCharacters.

* editing/TypingCommand.cpp:
(WebCore::TypingCommand::insertText): Index directly into string instead of using
deprecatedCharacters.
* editing/VisiblePosition.cpp:
(WebCore::VisiblePosition::characterAfter): Ditto.
* editing/VisibleUnits.cpp:
(WebCore::startOfParagraph): Ditto.
(WebCore::endOfParagraph): Ditto.

* fileapi/WebKitBlobBuilder.cpp:
(WebCore::BlobBuilder::append): Pass a StringView to TextEncoding::encode.

* html/BaseDateAndTimeInputType.cpp:
(WebCore::BaseDateAndTimeInputType::parseToDateComponents): Use
StringView::upconvertedCharacters.

* html/FormDataList.cpp:
(WebCore::FormDataList::appendString): Pass a StringView to TextEncoding::encode.

* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::normalizeSpaces): Use StringView::getCharactersWithUpconvert.

* html/parser/HTMLParserIdioms.cpp:
(WebCore::stripLeadingAndTrailingHTMLSpaces): Use characters16 for a code path
that already handled 8-bit characters separately.
(WebCore::parseHTMLNonNegativeInteger): Ditto.
(WebCore::parseDescriptors): Added an 8-bit code path.

* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyle::newLineAndWhitespaceDelimiters): Index directly into
string instead of using deprecatedCharacters.
* inspector/InspectorStyleTextEditor.cpp:
(WebCore::InspectorStyleTextEditor::insertProperty): Ditto.
(WebCore::InspectorStyleTextEditor::internalReplaceProperty): Ditto.

* page/ContentSecurityPolicy.cpp:
(WebCore::isSourceListNone): Use StringView::upconvertedCharacters.
(WebCore::CSPSourceList::parse): Ditto.
(WebCore::NonceDirective::parse): Ditto.
(WebCore::MediaListDirective::parse): Ditto.
(WebCore::CSPDirectiveList::parse): Ditto.
(WebCore::CSPDirectiveList::parseReportURI): Ditto.
(WebCore::CSPDirectiveList::parseReflectedXSS): Ditto.
(WebCore::ContentSecurityPolicy::didReceiveHeader): Ditto.

* page/PageSerializer.cpp:
(WebCore::PageSerializer::serializeFrame): Pass a StringView into
TextEncoding::encode.
(WebCore::PageSerializer::serializeCSSStyleSheet): Ditto.

* platform/Length.cpp:
(WebCore::countCharacter): Index directly into string instead of using
deprecatedCharacters. Also changed to take a StringImpl&.
(WebCore::newCoordsArray): Ditto. Call countCharacter the new way, and
use StringView::upconvertedCharacters.
(WebCore::newLengthArray): Ditto.

* platform/LinkHash.cpp:
(WebCore::visitedLinkHash): Use characters16 for the 16-bit path.
Also removed unused visitedURL function.
* platform/LinkHash.h: Removed unused visitedURL function.

* platform/SharedBuffer.cpp:
(WebCore::utf8Buffer): Added an 8-bit code path.
* platform/URL.cpp:
(WebCore::URL::port): Ditto.
(WebCore::encodeRelativeString): Use StringView to call TextEncoding::encode.

* platform/graphics/Color.cpp:
(WebCore::Color::parseHexColor): Use characters16 in the 16-bit path.
(WebCore::Color::Color): Ditto.

* platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp:
(WebCore::harfBuzzGetGlyph): Use StringView to call TextEncoding::encode.

* platform/graphics/StringTruncator.cpp:
(WebCore::centerTruncateToBuffer): Use StringView::getCharactersWithUpconvert.
(WebCore::rightTruncateToBuffer): Ditto.
(WebCore::rightClipToCharacterBuffer): Ditto.
(WebCore::rightClipToWordBuffer): Ditto.
(WebCore::leftTruncateToBuffer): Ditto.
(WebCore::truncateString): Ditto.

* platform/graphics/TextRun.h:
(WebCore::TextRun::TextRun): Use characters16 in the 16-bit code path.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::shouldWaitForLoadingOfResource):
Use StringView::upconvertedCharacters.

* platform/network/DataURL.cpp:
(WebCore::handleDataURL): Use StringView to call TextEncoding::encode.
* platform/network/FormDataBuilder.cpp:
(WebCore::FormDataBuilder::addFilenameToMultiPartHeader): Ditto.

* platform/sql/SQLiteStatement.cpp:
(WebCore::SQLiteStatement::bindBlob): Use StringView::upconvertedCharacters.
(WebCore::SQLiteStatement::bindText): Ditto.

* platform/text/DecodeEscapeSequences.h:
(WebCore::Unicode16BitEscapeSequence::decodeRun): Changed to take a StringView.
(WebCore::URLEscapeSequence::decodeRun): Ditto.
(WebCore::decodeEscapeSequences): Pass StringView to decodeRun.

* platform/text/Hyphenation.cpp:
(WebCore::lastHyphenLocation): Take a StringView.
* platform/text/Hyphenation.h: Make lastHyphenLocation take a StringView.

* platform/text/TextBreakIterator.cpp:
(WebCore::initializeIteratorWithRules): Use StringView::upconvertedCharacters.

* platform/text/TextEncoding.cpp:
(WebCore::TextEncoding::encode): Use StringView::upconvertedCharacters.
Change argument type to StringView.
* platform/text/TextEncoding.h: Ditto.

* platform/text/TextEncodingRegistry.cpp:
(WebCore::atomicCanonicalTextEncodingName): Use characters16 for the 16-bit path.

* platform/text/cf/HyphenationCF.cpp:
(WebCore::lastHyphenLocation): Use StringView::text.createCFStringWithoutCopying.
Change argument type to StringView.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::constructTextRun): Use characters16 for the 16-bit path.

* rendering/RenderCombineText.cpp:
(WebCore::RenderCombineText::width): Removed check for null characters pointer,
since the pointer will never be null, and even if it was there would be no need
for an early exit.

* rendering/RenderText.cpp:
(WebCore::maxWordFragmentWidth): Take a StringView.
(WebCore::RenderText::computePreferredLogicalWidths): Pass in a StringView.
* rendering/line/BreakingContextInlineHeaders.h:
(WebCore::tryHyphenating): Ditto.

* rendering/svg/SVGTextLayoutEngine.cpp:
(WebCore::SVGTextLayoutEngine::layoutTextOnLineOrPath): Use
StringView::upconvertedCharacters.

* rendering/svg/SVGTextMetrics.cpp:
(WebCore::SVGTextMetrics::SVGTextMetrics): Use String::substring.

* svg/SVGAngle.cpp:
(WebCore::SVGAngle::setValueAsString): Use StringView::upconvertedCharacters.
* svg/SVGAnimateMotionElement.cpp:
(WebCore::parsePoint): Ditto.
* svg/SVGAnimationElement.cpp:
(WebCore::parseKeySplines): Ditto.
* svg/SVGFitToViewBox.cpp:
(WebCore::SVGFitToViewBox::parseViewBox): Ditto.

* svg/SVGFontData.cpp:
(WebCore::SVGFontData::applySVGGlyphSelection): Pass StringView to
createStringWIthMirroredCharacters.
(WebCore::createStringWithMirroredCharacters): Changed to use StringView and
use indexing into that instead of a characters pointer.

* svg/SVGFontData.h: Removed createStringWithMirroredCharacters member function,
since it has nothing to do with the SVGFontData object. Now it's just a private
helper function in the SVGFontData.cpp source file.

* svg/SVGFontElement.cpp:
(WebCore::SVGFontElement::registerLigaturesInGlyphCache): Index into the string
instead of using deprecatedCharacters.

* svg/SVGGlyphMap.h:
(WebCore::SVGGlyphMap::addGlyph): Use StringView::upconvertedCharacters.
(WebCore::SVGGlyphMap::collectGlyphsForString): Ditto.
* svg/SVGGlyphRefElement.cpp:
(WebCore::SVGGlyphRefElement::parseAttribute): Ditto.
* svg/SVGLength.cpp:
(WebCore::SVGLength::setValueAsString): Ditto.
* svg/SVGLengthList.cpp:
(WebCore::SVGLengthList::parse): Ditto.
* svg/SVGNumberList.cpp:
(WebCore::SVGNumberList::parse): Ditto.
* svg/SVGParserUtilities.cpp:
(WebCore::parseNumberFromString): Ditto.
(WebCore::parseNumberOptionalNumber): Ditto.
(WebCore::parseRect): Ditto.
(WebCore::pointsListFromSVGData): Ditto.
(WebCore::parseGlyphName): Ditto.
(WebCore::parseKerningUnicodeString): Ditto.
(WebCore::parseDelimitedString): Ditto.
* svg/SVGPreserveAspectRatio.cpp:
(WebCore::SVGPreserveAspectRatio::parse): Ditto.
* svg/SVGStringList.cpp:
(WebCore::SVGStringList::parse): Ditto.
* svg/SVGTransformList.cpp:
(WebCore::SVGTransformList::parse): Ditto.
* svg/SVGTransformable.cpp:
(WebCore::SVGTransformable::parseTransformType): Ditto.
* svg/SVGViewSpec.cpp:
(WebCore::SVGViewSpec::parseViewSpec): Ditto.
* svg/SVGZoomAndPan.h:
(WebCore::SVGZoomAndPan::parseAttribute): Ditto.

* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::send): Pass a StringView to TextEncoding::encode.

* xml/XSLStyleSheetLibxslt.cpp:
(WebCore::XSLStyleSheet::parseString): Use StringView::upconvertedCharacters.

Source/WTF:

* wtf/text/WTFString.h: Export another overload of charactersToFloat since it's used
in WebCore now.

* wtf/text/cf/StringViewCF.cpp: Change so this can build on Windows.

* WTF.vcxproj/WTF.vcxproj: Added StringViewCF.cpp.
* WTF.vcxproj/WTF.vcxproj.filters: Added StringViewCF.cpp.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@165848 268f45cc-cd09-0410-ab3c-d52691b4dbfc

76 files changed:
Source/WTF/ChangeLog
Source/WTF/WTF.vcxproj/WTF.vcxproj
Source/WTF/WTF.vcxproj/WTF.vcxproj.filters
Source/WTF/wtf/text/WTFString.h
Source/WTF/wtf/text/cf/StringViewCF.cpp
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBKeyPath.cpp
Source/WebCore/Modules/indexeddb/leveldb/IDBLevelDBCoding.cpp
Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp
Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm
Source/WebCore/bindings/js/SerializedScriptValue.cpp
Source/WebCore/bindings/objc/WebScriptObject.mm
Source/WebCore/dom/Document.cpp
Source/WebCore/editing/CompositeEditCommand.cpp
Source/WebCore/editing/SmartReplace.cpp
Source/WebCore/editing/TextIterator.cpp
Source/WebCore/editing/TypingCommand.cpp
Source/WebCore/editing/VisiblePosition.cpp
Source/WebCore/editing/VisibleUnits.cpp
Source/WebCore/fileapi/WebKitBlobBuilder.cpp
Source/WebCore/html/BaseDateAndTimeInputType.cpp
Source/WebCore/html/FormDataList.cpp
Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
Source/WebCore/html/parser/HTMLParserIdioms.cpp
Source/WebCore/inspector/InspectorStyleSheet.cpp
Source/WebCore/inspector/InspectorStyleTextEditor.cpp
Source/WebCore/page/ContentSecurityPolicy.cpp
Source/WebCore/page/PageSerializer.cpp
Source/WebCore/platform/Length.cpp
Source/WebCore/platform/LinkHash.cpp
Source/WebCore/platform/LinkHash.h
Source/WebCore/platform/SharedBuffer.cpp
Source/WebCore/platform/URL.cpp
Source/WebCore/platform/graphics/Color.cpp
Source/WebCore/platform/graphics/StringTruncator.cpp
Source/WebCore/platform/graphics/TextRun.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
Source/WebCore/platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp
Source/WebCore/platform/network/DataURL.cpp
Source/WebCore/platform/network/FormDataBuilder.cpp
Source/WebCore/platform/sql/SQLiteStatement.cpp
Source/WebCore/platform/text/DecodeEscapeSequences.h
Source/WebCore/platform/text/Hyphenation.cpp
Source/WebCore/platform/text/Hyphenation.h
Source/WebCore/platform/text/TextBreakIterator.cpp
Source/WebCore/platform/text/TextEncoding.cpp
Source/WebCore/platform/text/TextEncoding.h
Source/WebCore/platform/text/TextEncodingRegistry.cpp
Source/WebCore/platform/text/cf/HyphenationCF.cpp
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderCombineText.cpp
Source/WebCore/rendering/RenderText.cpp
Source/WebCore/rendering/line/BreakingContextInlineHeaders.h
Source/WebCore/rendering/svg/SVGTextLayoutEngine.cpp
Source/WebCore/rendering/svg/SVGTextMetrics.cpp
Source/WebCore/svg/SVGAngle.cpp
Source/WebCore/svg/SVGAnimateMotionElement.cpp
Source/WebCore/svg/SVGAnimationElement.cpp
Source/WebCore/svg/SVGFitToViewBox.cpp
Source/WebCore/svg/SVGFontData.cpp
Source/WebCore/svg/SVGFontData.h
Source/WebCore/svg/SVGFontElement.cpp
Source/WebCore/svg/SVGGlyphMap.h
Source/WebCore/svg/SVGGlyphRefElement.cpp
Source/WebCore/svg/SVGLength.cpp
Source/WebCore/svg/SVGLengthList.cpp
Source/WebCore/svg/SVGNumberList.cpp
Source/WebCore/svg/SVGParserUtilities.cpp
Source/WebCore/svg/SVGPreserveAspectRatio.cpp
Source/WebCore/svg/SVGStringList.cpp
Source/WebCore/svg/SVGTransformList.cpp
Source/WebCore/svg/SVGTransformable.cpp
Source/WebCore/svg/SVGViewSpec.cpp
Source/WebCore/svg/SVGZoomAndPan.h
Source/WebCore/xml/XMLHttpRequest.cpp
Source/WebCore/xml/XSLStyleSheetLibxslt.cpp

index b50bda5..f5e94ee 100644 (file)
@@ -1,3 +1,18 @@
+2014-03-18  Darin Adler  <darin@apple.com>
+
+        Reduce use of deprecatedCharacters in WebCore
+        https://bugs.webkit.org/show_bug.cgi?id=130318
+
+        Reviewed by Andreas Kling.
+
+        * wtf/text/WTFString.h: Export another overload of charactersToFloat since it's used
+        in WebCore now.
+
+        * wtf/text/cf/StringViewCF.cpp: Change so this can build on Windows.
+
+        * WTF.vcxproj/WTF.vcxproj: Added StringViewCF.cpp.
+        * WTF.vcxproj/WTF.vcxproj.filters: Added StringViewCF.cpp.
+
 2014-03-18  Filip Pizlo  <fpizlo@apple.com>
 
         More FTL enabling.
index c43fb47..b1da05a 100644 (file)
     <ClCompile Include="..\wtf\text\cf\AtomicStringCF.cpp" />
     <ClCompile Include="..\wtf\text\cf\StringCF.cpp" />
     <ClCompile Include="..\wtf\text\cf\StringImplCF.cpp" />
+    <ClCompile Include="..\wtf\text\cf\StringViewCF.cpp" />
     <ClCompile Include="..\wtf\Threading.cpp" />
     <ClCompile Include="..\wtf\ThreadingWin.cpp" />
     <ClCompile Include="..\wtf\threadspecificWin.cpp" />
index 49c3618..28a2f98 100644 (file)
     <ClCompile Include="..\wtf\text\cf\StringCF.cpp">
       <Filter>text</Filter>
     </ClCompile>
+    <ClCompile Include="..\wtf\text\cf\StringImplCF.cpp">
+      <Filter>text</Filter>
+    </ClCompile>
+    <ClCompile Include="..\wtf\text\cf\StringViewCF.cpp">
+      <Filter>text</Filter>
+    </ClCompile>
     <ClCompile Include="..\wtf\win\MainThreadWin.cpp">
       <Filter>win</Filter>
     </ClCompile>
     <ClCompile Include="..\wtf\win\RunLoopWin.cpp">
       <Filter>win</Filter>
     </ClCompile>
-    <ClCompile Include="..\wtf\text\cf\StringImplCF.cpp">
-      <Filter>text</Filter>
-    </ClCompile>
     <ClCompile Include="..\wtf\FastBitVector.cpp" />
   </ItemGroup>
   <ItemGroup>
index f329fe5..4441573 100644 (file)
@@ -66,7 +66,7 @@ intptr_t charactersToIntPtr(const UChar*, size_t, bool* ok = 0); // ignores trai
 // It would be better if these were more consistent with the above functions instead.
 WTF_EXPORT_STRING_API double charactersToDouble(const LChar*, size_t, bool* ok = 0);
 WTF_EXPORT_STRING_API double charactersToDouble(const UChar*, size_t, bool* ok = 0);
-float charactersToFloat(const LChar*, size_t, bool* ok = 0);
+WTF_EXPORT_STRING_API float charactersToFloat(const LChar*, size_t, bool* ok = 0);
 WTF_EXPORT_STRING_API float charactersToFloat(const UChar*, size_t, bool* ok = 0);
 WTF_EXPORT_STRING_API float charactersToFloat(const LChar*, size_t, size_t& parsedLength);
 WTF_EXPORT_STRING_API float charactersToFloat(const UChar*, size_t, size_t& parsedLength);
index 3a8f61a..a3736fd 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#import "config.h"
-#import "StringView.h"
+#include "config.h"
+#include <wtf/text/StringView.h>
 
-#import "RetainPtr.h"
+#if USE(CF)
+
+#include <CoreFoundation/CoreFoundation.h>
+#include <wtf/RetainPtr.h>
 
 namespace WTF {
 
@@ -35,7 +38,9 @@ RetainPtr<CFStringRef> StringView::createCFStringWithoutCopying() const
     if (is8Bit())
         return adoptCF(CFStringCreateWithBytesNoCopy(kCFAllocatorDefault, characters8(), length(), kCFStringEncodingISOLatin1, false, kCFAllocatorNull));
 
-    return adoptCF(CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, characters16(), length(), kCFAllocatorNull));
+    return adoptCF(CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, reinterpret_cast<const UniChar*>(characters16()), length(), kCFAllocatorNull));
 }
 
 }
+
+#endif // USE(CF)
index 5dd4105..22d87e8 100644 (file)
@@ -1,3 +1,256 @@
+2014-03-18  Darin Adler  <darin@apple.com>
+
+        Reduce use of deprecatedCharacters in WebCore
+        https://bugs.webkit.org/show_bug.cgi?id=130318
+
+        Reviewed by Andreas Kling.
+
+        * Modules/indexeddb/IDBKeyPath.cpp:
+        (WebCore::IDBKeyPathLexer::IDBKeyPathLexer): Use StringView for parsing.
+        (WebCore::IDBKeyPathLexer::lex): Ditto.
+        (WebCore::IDBKeyPathLexer::lexIdentifier): Ditto.
+
+        * Modules/indexeddb/leveldb/IDBLevelDBCoding.cpp:
+        (WebCore::IDBLevelDBCoding::encodeString): Index directly into string instead of
+        using deprecatedCharacters.
+
+        * Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp:
+        (WebCore::ThreadableWebSocketChannelClientWrapper::setSubprotocol): Use
+        StringView::getCharactersWithUpconvert.
+        (WebCore::ThreadableWebSocketChannelClientWrapper::setExtensions): Ditto.
+
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+        (-[WebAccessibilityObjectWrapper arrayOfTextForTextMarkers:attributed:]):
+        Use operator NSString * instead of explicitly creating an NSString.
+
+        * bindings/js/SerializedScriptValue.cpp:
+        (WebCore::writeLittleEndianUInt16): Added.
+        (WebCore::CloneSerializer::serialize): Added a separate code path for 8-bit strings.
+        (WebCore::CloneSerializer::write): Ditto.
+
+        * bindings/objc/WebScriptObject.mm:
+        (+[WebScriptObject _convertValueToObjcValue:JSC::originRootObject:rootObject:]):
+        Use operator NSString * instead of explicitly creating an NSString.
+
+        * dom/Document.cpp:
+        (WebCore::Document::parseQualifiedName): Index directly into string instead of
+        using deprecatedCharacters.
+        * editing/CompositeEditCommand.cpp:
+        (WebCore::containsOnlyWhitespace): Ditto.
+        * editing/SmartReplace.cpp:
+        (WebCore::addAllCodePoints): Ditto.
+        (WebCore::getSmartSet): Use StringView::upconvertedCharacters.
+
+        * editing/TextIterator.cpp:
+        (WebCore::foldQuoteMarksAndSoftHyphens): Changed to return a value so it can be
+        used in initialization rather than assignment.
+        (WebCore::SearchBuffer::SearchBuffer): Use StringView::upconvertedCharacters.
+
+        * editing/TypingCommand.cpp:
+        (WebCore::TypingCommand::insertText): Index directly into string instead of using
+        deprecatedCharacters.
+        * editing/VisiblePosition.cpp:
+        (WebCore::VisiblePosition::characterAfter): Ditto.
+        * editing/VisibleUnits.cpp:
+        (WebCore::startOfParagraph): Ditto.
+        (WebCore::endOfParagraph): Ditto.
+
+        * fileapi/WebKitBlobBuilder.cpp:
+        (WebCore::BlobBuilder::append): Pass a StringView to TextEncoding::encode.
+
+        * html/BaseDateAndTimeInputType.cpp:
+        (WebCore::BaseDateAndTimeInputType::parseToDateComponents): Use
+        StringView::upconvertedCharacters.
+
+        * html/FormDataList.cpp:
+        (WebCore::FormDataList::appendString): Pass a StringView to TextEncoding::encode.
+
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::normalizeSpaces): Use StringView::getCharactersWithUpconvert.
+
+        * html/parser/HTMLParserIdioms.cpp:
+        (WebCore::stripLeadingAndTrailingHTMLSpaces): Use characters16 for a code path
+        that already handled 8-bit characters separately.
+        (WebCore::parseHTMLNonNegativeInteger): Ditto.
+        (WebCore::parseDescriptors): Added an 8-bit code path.
+
+        * inspector/InspectorStyleSheet.cpp:
+        (WebCore::InspectorStyle::newLineAndWhitespaceDelimiters): Index directly into
+        string instead of using deprecatedCharacters.
+        * inspector/InspectorStyleTextEditor.cpp:
+        (WebCore::InspectorStyleTextEditor::insertProperty): Ditto.
+        (WebCore::InspectorStyleTextEditor::internalReplaceProperty): Ditto.
+
+        * page/ContentSecurityPolicy.cpp:
+        (WebCore::isSourceListNone): Use StringView::upconvertedCharacters.
+        (WebCore::CSPSourceList::parse): Ditto.
+        (WebCore::NonceDirective::parse): Ditto.
+        (WebCore::MediaListDirective::parse): Ditto.
+        (WebCore::CSPDirectiveList::parse): Ditto.
+        (WebCore::CSPDirectiveList::parseReportURI): Ditto.
+        (WebCore::CSPDirectiveList::parseReflectedXSS): Ditto.
+        (WebCore::ContentSecurityPolicy::didReceiveHeader): Ditto.
+
+        * page/PageSerializer.cpp:
+        (WebCore::PageSerializer::serializeFrame): Pass a StringView into
+        TextEncoding::encode.
+        (WebCore::PageSerializer::serializeCSSStyleSheet): Ditto.
+
+        * platform/Length.cpp:
+        (WebCore::countCharacter): Index directly into string instead of using
+        deprecatedCharacters. Also changed to take a StringImpl&.
+        (WebCore::newCoordsArray): Ditto. Call countCharacter the new way, and
+        use StringView::upconvertedCharacters.
+        (WebCore::newLengthArray): Ditto.
+
+        * platform/LinkHash.cpp:
+        (WebCore::visitedLinkHash): Use characters16 for the 16-bit path.
+        Also removed unused visitedURL function.
+        * platform/LinkHash.h: Removed unused visitedURL function.
+
+        * platform/SharedBuffer.cpp:
+        (WebCore::utf8Buffer): Added an 8-bit code path.
+        * platform/URL.cpp:
+        (WebCore::URL::port): Ditto.
+        (WebCore::encodeRelativeString): Use StringView to call TextEncoding::encode.
+
+        * platform/graphics/Color.cpp:
+        (WebCore::Color::parseHexColor): Use characters16 in the 16-bit path.
+        (WebCore::Color::Color): Ditto.
+
+        * platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp:
+        (WebCore::harfBuzzGetGlyph): Use StringView to call TextEncoding::encode.
+
+        * platform/graphics/StringTruncator.cpp:
+        (WebCore::centerTruncateToBuffer): Use StringView::getCharactersWithUpconvert.
+        (WebCore::rightTruncateToBuffer): Ditto.
+        (WebCore::rightClipToCharacterBuffer): Ditto.
+        (WebCore::rightClipToWordBuffer): Ditto.
+        (WebCore::leftTruncateToBuffer): Ditto.
+        (WebCore::truncateString): Ditto.
+
+        * platform/graphics/TextRun.h:
+        (WebCore::TextRun::TextRun): Use characters16 in the 16-bit code path.
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::shouldWaitForLoadingOfResource):
+        Use StringView::upconvertedCharacters.
+
+        * platform/network/DataURL.cpp:
+        (WebCore::handleDataURL): Use StringView to call TextEncoding::encode.
+        * platform/network/FormDataBuilder.cpp:
+        (WebCore::FormDataBuilder::addFilenameToMultiPartHeader): Ditto.
+
+        * platform/sql/SQLiteStatement.cpp:
+        (WebCore::SQLiteStatement::bindBlob): Use StringView::upconvertedCharacters.
+        (WebCore::SQLiteStatement::bindText): Ditto.
+
+        * platform/text/DecodeEscapeSequences.h:
+        (WebCore::Unicode16BitEscapeSequence::decodeRun): Changed to take a StringView.
+        (WebCore::URLEscapeSequence::decodeRun): Ditto.
+        (WebCore::decodeEscapeSequences): Pass StringView to decodeRun.
+
+        * platform/text/Hyphenation.cpp:
+        (WebCore::lastHyphenLocation): Take a StringView.
+        * platform/text/Hyphenation.h: Make lastHyphenLocation take a StringView.
+
+        * platform/text/TextBreakIterator.cpp:
+        (WebCore::initializeIteratorWithRules): Use StringView::upconvertedCharacters.
+
+        * platform/text/TextEncoding.cpp:
+        (WebCore::TextEncoding::encode): Use StringView::upconvertedCharacters.
+        Change argument type to StringView.
+        * platform/text/TextEncoding.h: Ditto.
+
+        * platform/text/TextEncodingRegistry.cpp:
+        (WebCore::atomicCanonicalTextEncodingName): Use characters16 for the 16-bit path.
+
+        * platform/text/cf/HyphenationCF.cpp:
+        (WebCore::lastHyphenLocation): Use StringView::text.createCFStringWithoutCopying.
+        Change argument type to StringView.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::constructTextRun): Use characters16 for the 16-bit path.
+
+        * rendering/RenderCombineText.cpp:
+        (WebCore::RenderCombineText::width): Removed check for null characters pointer,
+        since the pointer will never be null, and even if it was there would be no need
+        for an early exit.
+
+        * rendering/RenderText.cpp:
+        (WebCore::maxWordFragmentWidth): Take a StringView.
+        (WebCore::RenderText::computePreferredLogicalWidths): Pass in a StringView.
+        * rendering/line/BreakingContextInlineHeaders.h:
+        (WebCore::tryHyphenating): Ditto.
+
+        * rendering/svg/SVGTextLayoutEngine.cpp:
+        (WebCore::SVGTextLayoutEngine::layoutTextOnLineOrPath): Use
+        StringView::upconvertedCharacters.
+
+        * rendering/svg/SVGTextMetrics.cpp:
+        (WebCore::SVGTextMetrics::SVGTextMetrics): Use String::substring.
+
+        * svg/SVGAngle.cpp:
+        (WebCore::SVGAngle::setValueAsString): Use StringView::upconvertedCharacters.
+        * svg/SVGAnimateMotionElement.cpp:
+        (WebCore::parsePoint): Ditto.
+        * svg/SVGAnimationElement.cpp:
+        (WebCore::parseKeySplines): Ditto.
+        * svg/SVGFitToViewBox.cpp:
+        (WebCore::SVGFitToViewBox::parseViewBox): Ditto.
+
+        * svg/SVGFontData.cpp:
+        (WebCore::SVGFontData::applySVGGlyphSelection): Pass StringView to
+        createStringWIthMirroredCharacters.
+        (WebCore::createStringWithMirroredCharacters): Changed to use StringView and
+        use indexing into that instead of a characters pointer.
+
+        * svg/SVGFontData.h: Removed createStringWithMirroredCharacters member function,
+        since it has nothing to do with the SVGFontData object. Now it's just a private
+        helper function in the SVGFontData.cpp source file.
+
+        * svg/SVGFontElement.cpp:
+        (WebCore::SVGFontElement::registerLigaturesInGlyphCache): Index into the string
+        instead of using deprecatedCharacters.
+
+        * svg/SVGGlyphMap.h:
+        (WebCore::SVGGlyphMap::addGlyph): Use StringView::upconvertedCharacters.
+        (WebCore::SVGGlyphMap::collectGlyphsForString): Ditto.
+        * svg/SVGGlyphRefElement.cpp:
+        (WebCore::SVGGlyphRefElement::parseAttribute): Ditto.
+        * svg/SVGLength.cpp:
+        (WebCore::SVGLength::setValueAsString): Ditto.
+        * svg/SVGLengthList.cpp:
+        (WebCore::SVGLengthList::parse): Ditto.
+        * svg/SVGNumberList.cpp:
+        (WebCore::SVGNumberList::parse): Ditto.
+        * svg/SVGParserUtilities.cpp:
+        (WebCore::parseNumberFromString): Ditto.
+        (WebCore::parseNumberOptionalNumber): Ditto.
+        (WebCore::parseRect): Ditto.
+        (WebCore::pointsListFromSVGData): Ditto.
+        (WebCore::parseGlyphName): Ditto.
+        (WebCore::parseKerningUnicodeString): Ditto.
+        (WebCore::parseDelimitedString): Ditto.
+        * svg/SVGPreserveAspectRatio.cpp:
+        (WebCore::SVGPreserveAspectRatio::parse): Ditto.
+        * svg/SVGStringList.cpp:
+        (WebCore::SVGStringList::parse): Ditto.
+        * svg/SVGTransformList.cpp:
+        (WebCore::SVGTransformList::parse): Ditto.
+        * svg/SVGTransformable.cpp:
+        (WebCore::SVGTransformable::parseTransformType): Ditto.
+        * svg/SVGViewSpec.cpp:
+        (WebCore::SVGViewSpec::parseViewSpec): Ditto.
+        * svg/SVGZoomAndPan.h:
+        (WebCore::SVGZoomAndPan::parseAttribute): Ditto.
+
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::send): Pass a StringView to TextEncoding::encode.
+
+        * xml/XSLStyleSheetLibxslt.cpp:
+        (WebCore::XSLStyleSheet::parseString): Use StringView::upconvertedCharacters.
+
 2014-03-18  Bem Jones-Bey  <bjonesbe@adobe.com>
 
         LayoutBox is a terrible name
index d93c0af..85ea976 100644 (file)
@@ -45,8 +45,7 @@ public:
 
     explicit IDBKeyPathLexer(const String& s)
         : m_string(s)
-        , m_ptr(s.deprecatedCharacters())
-        , m_end(s.deprecatedCharacters() + s.length())
+        , m_remainingText(s)
         , m_currentTokenType(TokenError)
     {
     }
@@ -64,23 +63,23 @@ public:
 private:
     TokenType lex(String&);
     TokenType lexIdentifier(String&);
+
     String m_currentElement;
-    String m_string;
-    const UChar* m_ptr;
-    const UChar* m_end;
+    const String m_string;
+    StringView m_remainingText;
     TokenType m_currentTokenType;
 };
 
 IDBKeyPathLexer::TokenType IDBKeyPathLexer::lex(String& element)
 {
-    if (m_ptr >= m_end)
+    if (m_remainingText.isEmpty())
         return TokenEnd;
-    ASSERT_WITH_SECURITY_IMPLICATION(m_ptr < m_end);
 
-    if (*m_ptr == '.') {
-        ++m_ptr;
+    if (m_remainingText[0] == '.') {
+        m_remainingText = m_remainingText.substring(1);
         return TokenDot;
     }
+
     return lexIdentifier(element);
 }
 
@@ -108,16 +107,16 @@ static inline bool isIdentifierCharacter(UChar c)
 
 IDBKeyPathLexer::TokenType IDBKeyPathLexer::lexIdentifier(String& element)
 {
-    const UChar* start = m_ptr;
-    if (m_ptr < m_end && isIdentifierStartCharacter(*m_ptr))
-        ++m_ptr;
+    StringView start = m_remainingText;
+    if (!m_remainingText.isEmpty() && isIdentifierStartCharacter(m_remainingText[0]))
+        m_remainingText = m_remainingText.substring(1);
     else
         return TokenError;
 
-    while (m_ptr < m_end && isIdentifierCharacter(*m_ptr))
-        ++m_ptr;
+    while (!m_remainingText.isEmpty() && isIdentifierCharacter(m_remainingText[0]))
+        m_remainingText = m_remainingText.substring(1);
 
-    element = String(start, m_ptr - start);
+    element = start.substring(0, start.length() - m_remainingText.length()).toString();
     return TokenIdentifier;
 }
 
index 86e9fae..33606d0 100644 (file)
@@ -297,10 +297,9 @@ Vector<char> encodeString(const String& s)
     size_t length = s.length();
     Vector<char> ret(length * sizeof(UChar));
 
-    const UChar* src = s.deprecatedCharacters();
     UChar* dst = reinterpret_cast<UChar*>(ret.data());
     for (unsigned i = 0; i < length; ++i)
-        *dst++ = htons(*src++);
+        *dst++ = htons(s[i]);
 
     return ret;
 }
index 0ab3c5e..52e1d6f 100644 (file)
@@ -38,6 +38,7 @@
 #include "WebSocketChannelClient.h"
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
+#include <wtf/text/StringView.h>
 
 namespace WebCore {
 
@@ -110,8 +111,7 @@ void ThreadableWebSocketChannelClientWrapper::setSubprotocol(const String& subpr
 {
     unsigned length = subprotocol.length();
     m_subprotocol.resize(length);
-    if (length)
-        memcpy(m_subprotocol.data(), subprotocol.deprecatedCharacters(), sizeof(UChar) * length);
+    StringView(subprotocol).getCharactersWithUpconvert(m_subprotocol.data());
 }
 
 String ThreadableWebSocketChannelClientWrapper::extensions() const
@@ -125,8 +125,7 @@ void ThreadableWebSocketChannelClientWrapper::setExtensions(const String& extens
 {
     unsigned length = extensions.length();
     m_extensions.resize(length);
-    if (length)
-        memcpy(m_extensions.data(), extensions.deprecatedCharacters(), sizeof(UChar) * length);
+    StringView(extensions).getCharactersWithUpconvert(m_extensions.data());
 }
 
 ThreadableWebSocketChannel::SendResult ThreadableWebSocketChannelClientWrapper::sendRequestResult() const
index 8bfd197..7ffbb44 100644 (file)
@@ -1660,7 +1660,7 @@ static void AXAttributedStringAppendText(NSMutableAttributedString* attrString,
                 String listMarkerText = m_object->listMarkerTextForNodeAndPosition(node, VisiblePosition(it.range()->startPosition())); 
                 
                 if (!listMarkerText.isEmpty()) 
-                    [array addObject:[NSString stringWithCharacters:listMarkerText.deprecatedCharacters() length:listMarkerText.length()]];
+                    [array addObject:listMarkerText];
                 // There was not an element representation, so just return the text.
                 [array addObject:it.text().createNSString().get()];
             }
index 7de2c52..2d18b80 100644 (file)
@@ -447,6 +447,19 @@ template <typename T> static bool writeLittleEndian(Vector<uint8_t>& buffer, con
     return true;
 }
 
+static bool writeLittleEndianUInt16(Vector<uint8_t>& buffer, const LChar* values, uint32_t length)
+{
+    if (length > std::numeric_limits<uint32_t>::max() / 2)
+        return false;
+
+    for (unsigned i = 0; i < length; ++i) {
+        buffer.append(values[i]);
+        buffer.append(0);
+    }
+
+    return true;
+}
+
 template <> bool writeLittleEndian<uint8_t>(Vector<uint8_t>& buffer, const uint8_t* values, uint32_t length)
 {
     buffer.append(values, length);
@@ -472,7 +485,9 @@ public:
         }
         writeLittleEndian<uint8_t>(out, StringTag);
         writeLittleEndian(out, s.length());
-        return writeLittleEndian(out, s.impl()->deprecatedCharacters(), s.length());
+        if (s.is8Bit())
+            return writeLittleEndianUInt16(out, s.characters8(), s.length());
+        return writeLittleEndian(out, s.characters16(), s.length());
     }
 
     static void serializeUndefined(Vector<uint8_t>& out)
@@ -969,21 +984,28 @@ private:
             return;
         }
 
+        unsigned length = str.length();
+
         // This condition is unlikely to happen as they would imply an ~8gb
         // string but we should guard against it anyway
-        if (str.length() >= StringPoolTag) {
+        if (length >= StringPoolTag) {
             fail();
             return;
         }
 
         // Guard against overflow
-        if (str.length() > (std::numeric_limits<uint32_t>::max() - sizeof(uint32_t)) / sizeof(UChar)) {
+        if (length > (std::numeric_limits<uint32_t>::max() - sizeof(uint32_t)) / sizeof(UChar)) {
             fail();
             return;
         }
 
-        writeLittleEndian<uint32_t>(m_buffer, str.length());
-        if (!writeLittleEndian<uint16_t>(m_buffer, reinterpret_cast<const uint16_t*>(str.deprecatedCharacters()), str.length()))
+        writeLittleEndian<uint32_t>(m_buffer, length);
+        if (!length || str.is8Bit()) {
+            if (!writeLittleEndianUInt16(m_buffer, str.characters8(), length))
+                fail();
+            return;
+        }
+        if (!writeLittleEndian(m_buffer, str.characters16(), length))
             fail();
     }
 
index 58c7ade..0427cb6 100644 (file)
@@ -546,11 +546,8 @@ static void getListFromNSArray(ExecState *exec, NSArray *array, RootObject* root
         return [WebScriptObject scriptObjectForJSObject:toRef(object) originRootObject:originRootObject rootObject:rootObject];
     }
 
-    if (value.isString()) {
-        ExecState* exec = rootObject->globalObject()->globalExec();
-        const String& u = asString(value)->value(exec);
-        return [NSString stringWithCharacters:u.deprecatedCharacters() length:u.length()];
-    }
+    if (value.isString())
+        return asString(value)->value(rootObject->globalObject()->globalExec());
 
     if (value.isNumber())
         return [NSNumber numberWithDouble:value.asNumber()];
index dde6c3b..9ecc32c 100644 (file)
@@ -3972,10 +3972,9 @@ bool Document::parseQualifiedName(const String& qualifiedName, String& prefix, S
     bool sawColon = false;
     int colonPos = 0;
 
-    const UChar* s = qualifiedName.deprecatedCharacters();
     for (unsigned i = 0; i < length;) {
         UChar32 c;
-        U16_NEXT(s, i, length, c)
+        U16_NEXT(qualifiedName, i, length, c)
         if (c == ':') {
             if (sawColon) {
                 ec = NAMESPACE_ERR;
index 5ce2fc0..304c22d 100644 (file)
@@ -667,7 +667,7 @@ void CompositeEditCommand::setNodeAttribute(PassRefPtr<Element> element, const Q
 static inline bool containsOnlyWhitespace(const String& text)
 {
     for (unsigned i = 0; i < text.length(); ++i) {
-        if (!isWhitespace(text.deprecatedCharacters()[i]))
+        if (!isWhitespace(text[i]))
             return false;
     }
     
index 2b044e3..0b4764c 100644 (file)
 
 #include <unicode/uset.h>
 #include <wtf/Assertions.h>
-#include <wtf/text/WTFString.h>
+#include <wtf/text/StringView.h>
 
 namespace WebCore {
 
 static void addAllCodePoints(USet* smartSet, const String& string)
 {
-    const UChar* characters = string.deprecatedCharacters();
     for (size_t i = 0; i < string.length(); i++)
-        uset_add(smartSet, characters[i]);
+        uset_add(smartSet, string[i]);
 }
 
 // This is mostly a port of the code in WebCore/editing/SmartReplaceCF.cpp
@@ -56,7 +55,7 @@ static USet* getSmartSet(bool isPreviousCharacter)
         // Whitespace and newline (kCFCharacterSetWhitespaceAndNewline)
         UErrorCode ec = U_ZERO_ERROR;
         String whitespaceAndNewline = ASCIILiteral("[[:WSpace:] [\\u000A\\u000B\\u000C\\u000D\\u0085]]");
-        smartSet = uset_openPattern(whitespaceAndNewline.deprecatedCharacters(), whitespaceAndNewline.length(), &ec);
+        smartSet = uset_openPattern(StringView(whitespaceAndNewline).upconvertedCharacters(), whitespaceAndNewline.length(), &ec);
         ASSERT(U_SUCCESS(ec));
 
         // CJK ranges
@@ -83,7 +82,7 @@ static USet* getSmartSet(bool isPreviousCharacter)
             // Punctuation (kCFCharacterSetPunctuation)
             UErrorCode ec = U_ZERO_ERROR;
             String punctuationClass = ASCIILiteral("[:P:]");
-            USet* icuPunct = uset_openPattern(punctuationClass.deprecatedCharacters(), punctuationClass.length(), &ec);
+            USet* icuPunct = uset_openPattern(StringView(punctuationClass).upconvertedCharacters(), punctuationClass.length(), &ec);
             ASSERT(U_SUCCESS(ec));
             uset_addAll(smartSet, icuPunct);
             uset_close(icuPunct);
index 4dd2e93..77ff794 100644 (file)
@@ -92,7 +92,8 @@ private:
     bool isBadMatch(const UChar*, size_t length) const;
     bool isWordStartMatch(size_t start, size_t length) const;
 
-    String m_target;
+    const String m_target;
+    const StringView::UpconvertedCharacters m_targetCharacters;
     FindOptions m_options;
 
     Vector<UChar> m_buffer;
@@ -101,7 +102,7 @@ private:
     bool m_atBreak;
     bool m_needsMoreContext;
 
-    bool m_targetRequiresKanaWorkaround;
+    const bool m_targetRequiresKanaWorkaround;
     Vector<UChar> m_normalizedTarget;
     mutable Vector<UChar> m_normalizedMatch;
 
@@ -1649,17 +1650,22 @@ static inline UChar foldQuoteMarkOrSoftHyphen(UChar c)
     }
 }
 
-static inline void foldQuoteMarksAndSoftHyphens(String& s)
+// FIXME: We'd like to tailor the searcher to fold quote marks for us instead
+// of doing it in a separate replacement pass here, but ICU doesn't offer a way
+// to add tailoring on top of the locale-specific tailoring as of this writing.
+static inline String foldQuoteMarksAndSoftHyphens(String string)
 {
-    s.replace(hebrewPunctuationGeresh, '\'');
-    s.replace(hebrewPunctuationGershayim, '"');
-    s.replace(leftDoubleQuotationMark, '"');
-    s.replace(leftSingleQuotationMark, '\'');
-    s.replace(rightDoubleQuotationMark, '"');
-    s.replace(rightSingleQuotationMark, '\'');
-    // Replace soft hyphen with an ignorable character so that their presence or absence will
-    // not affect string comparison.
-    s.replace(softHyphen, 0);
+    string.replace(hebrewPunctuationGeresh, '\'');
+    string.replace(hebrewPunctuationGershayim, '"');
+    string.replace(leftDoubleQuotationMark, '"');
+    string.replace(leftSingleQuotationMark, '\'');
+    string.replace(rightDoubleQuotationMark, '"');
+    string.replace(rightSingleQuotationMark, '\'');
+
+    // Replace soft hyphens with an ignorable character so that presence or absence will not affect string comparison.
+    string.replace(softHyphen, 0);
+
+    return string;
 }
 
 #if !UCONFIG_NO_COLLATION
@@ -1943,7 +1949,8 @@ static inline bool isSeparator(UChar32 character)
 }
 
 inline SearchBuffer::SearchBuffer(const String& target, FindOptions options)
-    : m_target(target)
+    : m_target(foldQuoteMarksAndSoftHyphens(target))
+    , m_targetCharacters(StringView(m_target).upconvertedCharacters())
     , m_options(options)
     , m_prefixLength(0)
     , m_atBreak(true)
@@ -1952,11 +1959,6 @@ inline SearchBuffer::SearchBuffer(const String& target, FindOptions options)
 {
     ASSERT(!m_target.isEmpty());
 
-    // FIXME: We'd like to tailor the searcher to fold quote marks for us instead
-    // of doing it in a separate replacement pass here, but ICU doesn't offer a way
-    // to add tailoring on top of the locale-specific tailoring as of this writing.
-    foldQuoteMarksAndSoftHyphens(m_target);
-
     size_t targetLength = m_target.length();
     m_buffer.reserveInitialCapacity(std::max(targetLength * 8, minimumSearchBufferSize));
     m_overlap = m_buffer.capacity() / 4;
@@ -2000,12 +2002,12 @@ inline SearchBuffer::SearchBuffer(const String& target, FindOptions options)
     usearch_setAttribute(searcher, USEARCH_ELEMENT_COMPARISON, comparator, &status);
     ASSERT(status == U_ZERO_ERROR);
 
-    usearch_setPattern(searcher, m_target.deprecatedCharacters(), targetLength, &status);
+    usearch_setPattern(searcher, m_targetCharacters, targetLength, &status);
     ASSERT(status == U_ZERO_ERROR);
 
     // The kana workaround requires a normalized copy of the target string.
     if (m_targetRequiresKanaWorkaround)
-        normalizeCharacters(m_target.deprecatedCharacters(), m_target.length(), m_normalizedTarget);
+        normalizeCharacters(m_targetCharacters, targetLength, m_normalizedTarget);
 }
 
 inline SearchBuffer::~SearchBuffer()
index 3a6dba3..9329cdf 100644 (file)
@@ -155,7 +155,7 @@ void TypingCommand::insertText(Document& document, const String& text, Options o
     ASSERT(frame);
 
     if (!text.isEmpty())
-        frame->editor().updateMarkersForWordsAffectedByEditing(isSpaceOrNewline(text.deprecatedCharacters()[0]));
+        frame->editor().updateMarkersForWordsAffectedByEditing(isSpaceOrNewline(text[0]));
     
     insertText(document, text, frame->selection().selection(), options, composition);
 }
index 10ca164..fd8cc4d 100644 (file)
@@ -590,8 +590,7 @@ UChar32 VisiblePosition::characterAfter() const
         return 0;
 
     UChar32 ch;
-    const UChar* characters = textNode->data().deprecatedCharacters();
-    U16_NEXT(characters, offset, length, ch);
+    U16_NEXT(textNode->data(), offset, length, ch);
     return ch;
 }
 
index f9a3068..6c0561b 100644 (file)
@@ -1155,13 +1155,13 @@ VisiblePosition startOfParagraph(const VisiblePosition& c, EditingBoundaryCrossi
             ASSERT_WITH_SECURITY_IMPLICATION(n->isTextNode());
             type = Position::PositionIsOffsetInAnchor;
             if (style.preserveNewline()) {
-                const UChar* chars = toRenderText(r)->deprecatedCharacters();
-                int i = toRenderText(r)->textLength();
+                StringImpl& text = *toRenderText(r)->text();
+                int i = text.length();
                 int o = offset;
                 if (n == startNode && o < i)
                     i = std::max(0, o);
                 while (--i >= 0) {
-                    if (chars[i] == '\n')
+                    if (text[i] == '\n')
                         return VisiblePosition(Position(toText(n), i + 1), DOWNSTREAM);
                 }
             }
@@ -1236,13 +1236,13 @@ VisiblePosition endOfParagraph(const VisiblePosition& c, EditingBoundaryCrossing
         // FIXME: We avoid returning a position where the renderer can't accept the caret.
         if (r->isText() && toRenderText(r)->hasRenderedText()) {
             ASSERT_WITH_SECURITY_IMPLICATION(n->isTextNode());
-            int length = toRenderText(r)->textLength();
             type = Position::PositionIsOffsetInAnchor;
             if (style.preserveNewline()) {
-                const UChar* chars = toRenderText(r)->deprecatedCharacters();
+                StringImpl& text = *toRenderText(r)->text();
                 int o = n == startNode ? offset : 0;
+                int length = text.length();
                 for (int i = o; i < length; ++i) {
-                    if (chars[i] == '\n')
+                    if (text[i] == '\n')
                         return VisiblePosition(Position(toText(n), i), DOWNSTREAM);
                 }
             }
index 8a45805..658b6a4 100644 (file)
@@ -44,6 +44,7 @@
 #include <wtf/Vector.h>
 #include <wtf/text/AtomicString.h>
 #include <wtf/text/CString.h>
+#include <wtf/text/StringView.h>
 
 namespace WebCore {
 
@@ -71,7 +72,7 @@ Vector<char>& BlobBuilder::getBuffer()
 
 void BlobBuilder::append(const String& text, const String& endingType)
 {
-    CString utf8Text = UTF8Encoding().encode(text.deprecatedCharacters(), text.length(), EntitiesForUnencodables);
+    CString utf8Text = UTF8Encoding().encode(text, EntitiesForUnencodables);
 
     Vector<char>& buffer = getBuffer();
     size_t oldSize = buffer.size();
index bdcde18..0ca7a34 100644 (file)
@@ -108,7 +108,7 @@ bool BaseDateAndTimeInputType::parseToDateComponents(const String& source, DateC
     DateComponents ignoredResult;
     if (!out)
         out = &ignoredResult;
-    return parseToDateComponentsInternal(source.deprecatedCharacters(), source.length(), out);
+    return parseToDateComponentsInternal(source.upconvertedCharacters(), source.length(), out);
 }
 
 String BaseDateAndTimeInputType::serialize(const Decimal& value) const
index 48fc629..136b6af 100644 (file)
@@ -22,6 +22,7 @@
 #include "FormDataList.h"
 
 #include "LineEnding.h"
+#include <wtf/text/StringView.h>
 
 namespace WebCore {
 
@@ -32,7 +33,7 @@ FormDataList::FormDataList(const TextEncoding& c)
 
 void FormDataList::appendString(const String& s)
 {
-    CString cstr = m_encoding.encode(s.deprecatedCharacters(), s.length(), EntitiesForUnencodables);
+    CString cstr = m_encoding.encode(s, EntitiesForUnencodables);
     m_items.append(normalizeLineEndingsToCRLF(cstr));
 }
 
index 9c11923..47b8730 100755 (executable)
@@ -2167,7 +2167,7 @@ static void normalizeSpaces(String& text)
 
     unsigned textLength = text.length();
     Vector<UChar> charVector(textLength);
-    memcpy(charVector.data(), text.deprecatedCharacters(), textLength * sizeof(UChar));
+    StringView(text).getCharactersWithUpconvert(charVector.data());
 
     charVector[i++] = ' ';
 
index 6c99b25..a2186b1 100644 (file)
@@ -71,7 +71,7 @@ String stripLeadingAndTrailingHTMLSpaces(const String& string)
     if (string.is8Bit())
         return stripLeadingAndTrailingHTMLSpaces(string, string.characters8(), length);
 
-    return stripLeadingAndTrailingHTMLSpaces(string, string.deprecatedCharacters(), length);
+    return stripLeadingAndTrailingHTMLSpaces(string, string.characters16(), length);
 }
 
 String serializeForNumberType(const Decimal& number)
@@ -267,12 +267,12 @@ bool parseHTMLNonNegativeInteger(const String& input, unsigned& value)
     // Step 1
     // Step 2
     unsigned length = input.length();
-    if (length && input.is8Bit()) {
+    if (!length || input.is8Bit()) {
         const LChar* start = input.characters8();
         return parseHTMLNonNegativeIntegerInternal(start, start + length, value);
     }
     
-    const UChar* start = input.deprecatedCharacters();
+    const UChar* start = input.characters16();
     return parseHTMLNonNegativeIntegerInternal(start, start + length, value);
 }
 
@@ -326,7 +326,10 @@ static bool parseDescriptors(const String& attribute, size_t start, size_t end,
         if (isFoundScaleFactor)
             return false;
 
-        imageScaleFactor = charactersToFloat(attribute.deprecatedCharacters() + descriptorStart, descriptorEnd - descriptorStart, &isValid);
+        if (attribute.is8Bit())
+            imageScaleFactor = charactersToFloat(attribute.characters8() + descriptorStart, descriptorEnd - descriptorStart, &isValid);
+        else
+            imageScaleFactor = charactersToFloat(attribute.characters16() + descriptorStart, descriptorEnd - descriptorStart, &isValid);
         isFoundScaleFactor = true;
     }
 
index c635c58..08776d7 100644 (file)
@@ -712,14 +712,13 @@ NewLineAndWhitespace& InspectorStyle::newLineAndWhitespaceDelimiters() const
     int propertyIndex = 0;
     bool isFullPrefixScanned = false;
     bool lineFeedTerminated = false;
-    const UChar* characters = text.deprecatedCharacters();
     while (propertyIndex < propertyCount) {
         const WebCore::CSSPropertySourceData& currentProperty = sourcePropertyData->at(propertyIndex++);
 
         bool processNextProperty = false;
         int scanEnd = currentProperty.range.start;
         for (int i = scanStart; i < scanEnd; ++i) {
-            UChar ch = characters[i];
+            UChar ch = text[i];
             bool isLineFeed = isHTMLLineBreak(ch);
             if (isLineFeed) {
                 if (!lineFeedTerminated)
index c17c3de..3ce5cb6 100644 (file)
@@ -82,12 +82,10 @@ void InspectorStyleTextEditor::insertProperty(unsigned index, const String& prop
     if (insertLast && !insertFirstInSource) {
         propertyStart = styleBodyLength;
         if (propertyStart && textToSet.length()) {
-            const UChar* characters = m_styleText.deprecatedCharacters();
-
             long curPos = propertyStart - 1; // The last position of style declaration, since propertyStart points past one.
-            while (curPos && isHTMLSpace(characters[curPos]))
+            while (curPos && isHTMLSpace(m_styleText[curPos]))
                 --curPos;
-            if (curPos && characters[curPos] != ';') {
+            if (curPos && m_styleText[curPos] != ';') {
                 // Prepend a ";" to the property text if appending to a style declaration where
                 // the last property has no trailing ";".
                 textToSet.insert(";", 0);
@@ -230,7 +228,6 @@ void InspectorStyleTextEditor::internalReplaceProperty(const InspectorStylePrope
     const SourceRange& range = property.sourceData.range;
     long replaceRangeStart = range.start;
     long replaceRangeEnd = range.end;
-    const UChar* characters = m_styleText.deprecatedCharacters();
     long newTextLength = newText.length();
     String finalNewText = newText;
 
@@ -241,14 +238,14 @@ void InspectorStyleTextEditor::internalReplaceProperty(const InspectorStylePrope
         if (replaceRangeStart >= fullPrefixLength && m_styleText.substring(replaceRangeStart - fullPrefixLength, fullPrefixLength) == fullPrefix)
             replaceRangeStart -= fullPrefixLength;
     } else if (newTextLength) {
-        if (isHTMLLineBreak(newText.deprecatedCharacters()[newTextLength - 1])) {
+        if (isHTMLLineBreak(newText[newTextLength - 1])) {
             // Coalesce newlines of the original and new property values (to avoid a lot of blank lines while incrementally applying property values).
             bool foundNewline = false;
             bool isLastNewline = false;
             int i;
             int textLength = m_styleText.length();
-            for (i = replaceRangeEnd; i < textLength && isSpaceOrNewline(characters[i]); ++i) {
-                isLastNewline = isHTMLLineBreak(characters[i]);
+            for (i = replaceRangeEnd; i < textLength && isSpaceOrNewline(m_styleText[i]); ++i) {
+                isLastNewline = isHTMLLineBreak(m_styleText[i]);
                 if (isLastNewline)
                     foundNewline = true;
                 else if (foundNewline && !isLastNewline) {
index 5a5a7f7..57488b1 100644 (file)
@@ -47,7 +47,6 @@
 #include <inspector/ScriptCallStackFactory.h>
 #include <wtf/HashSet.h>
 #include <wtf/text/TextPosition.h>
-#include <wtf/text/WTFString.h>
 
 using namespace Inspector;
 
@@ -189,8 +188,9 @@ static void skipWhile(const UChar*& position, const UChar* end)
 
 static bool isSourceListNone(const String& value)
 {
-    const UChar* begin = value.deprecatedCharacters();
-    const UChar* end = value.deprecatedCharacters() + value.length();
+    auto characters = StringView(value).upconvertedCharacters();
+    const UChar* begin = characters;
+    const UChar* end = characters + value.length();
     skipWhile<isASCIISpace>(begin, end);
 
     const UChar* position = begin;
@@ -339,7 +339,8 @@ void CSPSourceList::parse(const String& value)
     // We represent 'none' as an empty m_list.
     if (isSourceListNone(value))
         return;
-    parse(value.deprecatedCharacters(), value.deprecatedCharacters() + value.length());
+    auto characters = StringView(value).upconvertedCharacters();
+    parse(characters, characters + value.length());
 }
 
 bool CSPSourceList::matches(const URL& url)
@@ -680,7 +681,8 @@ private:
     void parse(const String& value)
     {
         String nonce;
-        const UChar* position = value.deprecatedCharacters();
+        auto characters = StringView(value).upconvertedCharacters();
+        const UChar* position = characters;
         const UChar* end = position + value.length();
 
         skipWhile<isASCIISpace>(position, end);
@@ -723,7 +725,8 @@ public:
 private:
     void parse(const String& value)
     {
-        const UChar* begin = value.deprecatedCharacters();
+        auto characters = StringView(value).upconvertedCharacters();
+        const UChar* begin = characters;
         const UChar* position = begin;
         const UChar* end = begin + value.length();
 
@@ -1211,7 +1214,8 @@ void CSPDirectiveList::parse(const String& policy)
     if (policy.isEmpty())
         return;
 
-    const UChar* position = policy.deprecatedCharacters();
+    auto characters = StringView(policy).upconvertedCharacters();
+    const UChar* position = characters;
     const UChar* end = position + policy.length();
 
     while (position < end) {
@@ -1290,7 +1294,9 @@ void CSPDirectiveList::parseReportURI(const String& name, const String& value)
         m_policy->reportDuplicateDirective(name);
         return;
     }
-    const UChar* position = value.deprecatedCharacters();
+
+    auto characters = StringView(value).upconvertedCharacters();
+    const UChar* position = characters;
     const UChar* end = position + value.length();
 
     while (position < end) {
@@ -1344,7 +1350,8 @@ void CSPDirectiveList::parseReflectedXSS(const String& name, const String& value
         return;
     }
 
-    const UChar* position = value.deprecatedCharacters();
+    auto characters = StringView(value).upconvertedCharacters();
+    const UChar* position = characters;
     const UChar* end = position + value.length();
 
     skipWhile<isASCIISpace>(position, end);
@@ -1443,7 +1450,8 @@ void ContentSecurityPolicy::didReceiveHeader(const String& header, HeaderType ty
     // RFC2616, section 4.2 specifies that headers appearing multiple times can
     // be combined with a comma. Walk the header string, and parse each comma
     // separated chunk as a separate header.
-    const UChar* begin = header.deprecatedCharacters();
+    auto characters = StringView(header).upconvertedCharacters();
+    const UChar* begin = characters;
     const UChar* position = begin;
     const UChar* end = begin + header.length();
     while (position < end) {
index b721a64..c80259c 100644 (file)
@@ -216,7 +216,7 @@ void PageSerializer::serializeFrame(Frame* frame)
         return;
     }
     String text = accumulator.serializeNodes(*document->documentElement(), 0, IncludeNode);
-    CString frameHTML = textEncoding.encode(text.deprecatedCharacters(), text.length(), EntitiesForUnencodables);
+    CString frameHTML = textEncoding.encode(text, EntitiesForUnencodables);
     m_resources->append(Resource(url, document->suggestedMIMEType(), SharedBuffer::create(frameHTML.data(), frameHTML.length())));
     m_resourceURLs.add(url);
 
@@ -283,7 +283,7 @@ void PageSerializer::serializeCSSStyleSheet(CSSStyleSheet* styleSheet, const URL
         TextEncoding textEncoding(styleSheet->contents().charset());
         ASSERT(textEncoding.isValid());
         String textString = cssText.toString();
-        CString text = textEncoding.encode(textString.deprecatedCharacters(), textString.length(), EntitiesForUnencodables);
+        CString text = textEncoding.encode(textString, EntitiesForUnencodables);
         m_resources->append(Resource(url, String("text/css"), SharedBuffer::create(text.data(), text.length())));
         m_resourceURLs.add(url);
     }
index dc0579f..f8404b0 100644 (file)
@@ -30,7 +30,7 @@
 #include <wtf/Assertions.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/text/StringBuffer.h>
-#include <wtf/text/WTFString.h>
+#include <wtf/text/StringView.h>
 
 using namespace WTF;
 
@@ -77,21 +77,21 @@ static Length parseLength(const UChar* data, unsigned length)
     return Length(0, Relative);
 }
 
-static int countCharacter(const UChar* data, unsigned length, UChar character)
+static unsigned countCharacter(StringImpl& string, UChar character)
 {
-    int count = 0;
-    for (int i = 0; i < static_cast<int>(length); ++i)
-        count += data[i] == character;
+    unsigned count = 0;
+    unsigned length = string.length();
+    for (unsigned i = 0; i < length; ++i)
+        count += string[i] == character;
     return count;
 }
 
 std::unique_ptr<Length[]> newCoordsArray(const String& string, int& len)
 {
     unsigned length = string.length();
-    const UChar* data = string.deprecatedCharacters();
     StringBuffer<UChar> spacified(length);
     for (unsigned i = 0; i < length; i++) {
-        UChar cc = data[i];
+        UChar cc = string[i];
         if (cc > '9' || (cc < '0' && cc != '-' && cc != '*' && cc != '.'))
             spacified[i] = ' ';
         else
@@ -101,18 +101,19 @@ std::unique_ptr<Length[]> newCoordsArray(const String& string, int& len)
 
     str = str->simplifyWhiteSpace();
 
-    len = countCharacter(str->deprecatedCharacters(), str->length(), ' ') + 1;
+    len = countCharacter(*str, ' ') + 1;
     auto r = std::make_unique<Length[]>(len);
 
     int i = 0;
     unsigned pos = 0;
     size_t pos2;
 
+    auto upconvertedCharacters = StringView(str.get()).upconvertedCharacters();
     while ((pos2 = str->find(' ', pos)) != notFound) {
-        r[i++] = parseLength(str->deprecatedCharacters() + pos, pos2 - pos);
+        r[i++] = parseLength(upconvertedCharacters + pos, pos2 - pos);
         pos = pos2+1;
     }
-    r[i] = parseLength(str->deprecatedCharacters() + pos, str->length() - pos);
+    r[i] = parseLength(upconvertedCharacters + pos, str->length() - pos);
 
     ASSERT(i == len - 1);
 
@@ -127,15 +128,16 @@ std::unique_ptr<Length[]> newLengthArray(const String& string, int& len)
         return nullptr;
     }
 
-    len = countCharacter(str->deprecatedCharacters(), str->length(), ',') + 1;
+    len = countCharacter(*str, ',') + 1;
     auto r = std::make_unique<Length[]>(len);
 
     int i = 0;
     unsigned pos = 0;
     size_t pos2;
 
+    auto upconvertedCharacters = StringView(str.get()).upconvertedCharacters();
     while ((pos2 = str->find(',', pos)) != notFound) {
-        r[i++] = parseLength(str->deprecatedCharacters() + pos, pos2 - pos);
+        r[i++] = parseLength(upconvertedCharacters + pos, pos2 - pos);
         pos = pos2+1;
     }
 
@@ -143,7 +145,7 @@ std::unique_ptr<Length[]> newLengthArray(const String& string, int& len)
 
     // IE Quirk: If the last comma is the last char skip it and reduce len by one.
     if (str->length()-pos > 0)
-        r[i] = parseLength(str->deprecatedCharacters() + pos, str->length() - pos);
+        r[i] = parseLength(upconvertedCharacters + pos, str->length() - pos);
     else
         len--;
 
index 5f24b20..ece933f 100644 (file)
@@ -214,10 +214,9 @@ static ALWAYS_INLINE LinkHash visitedLinkHashInline(const CharacterType* url, un
 LinkHash visitedLinkHash(const String& url)
 {
     unsigned length = url.length();
-
-    if (length && url.is8Bit())
+    if (!length || url.is8Bit())
         return visitedLinkHashInline(url.characters8(), length);
-    return visitedLinkHashInline(url.deprecatedCharacters(), length);
+    return visitedLinkHashInline(url.characters16(), length);
 }
 
 LinkHash visitedLinkHash(const UChar* url, unsigned length)
@@ -284,11 +283,6 @@ static ALWAYS_INLINE void visitedURLInline(const URL& base, const CharacterType*
     return;
 }
 
-void visitedURL(const URL& base, const AtomicString& attributeURL, Vector<UChar, 512>& buffer)
-{
-    return visitedURLInline(base, attributeURL.string().deprecatedCharacters(), attributeURL.length(), buffer);
-}
-
 LinkHash visitedLinkHash(const URL& base, const AtomicString& attributeURL)
 {
     if (attributeURL.isEmpty())
index 14fdbed..039942f 100644 (file)
@@ -63,12 +63,6 @@ LinkHash visitedLinkHash(const UChar* url, unsigned length);
 // look like a relative URL.
 LinkHash visitedLinkHash(const URL& base, const AtomicString& attributeURL);
 
-// Resolves the potentially relative URL "attributeURL" relative to the given
-// base URL, and returns the hash of the string that will be used for visited.
-// It will return an empty Vector in case of errors.
-void visitedURL(const URL& base, const AtomicString& attributeURL, Vector<UChar, 512>&);
-
-
 }  // namespace WebCore
 
 #endif  // LinkHash_h
index c70b4d2..c5ff23a 100644 (file)
@@ -522,10 +522,18 @@ PassRefPtr<SharedBuffer> utf8Buffer(const String& string)
 
     // Convert to runs of 8-bit characters.
     char* p = buffer.data();
-    const UChar* d = string.deprecatedCharacters();
-    WTF::Unicode::ConversionResult result = WTF::Unicode::convertUTF16ToUTF8(&d, d + length, &p, p + buffer.size(), true);
-    if (result != WTF::Unicode::conversionOK)
-        return 0;
+    WTF::Unicode::ConversionResult result;
+    if (length) {
+        if (string.is8Bit()) {
+            const LChar* d = string.characters8();
+            result = WTF::Unicode::convertLatin1ToUTF8(&d, d + length, &p, p + buffer.size());
+        } else {
+            const UChar* d = string.characters16();
+            result = WTF::Unicode::convertUTF16ToUTF8(&d, d + length, &p, p + buffer.size(), true);
+        }
+        if (result != WTF::Unicode::conversionOK)
+            return nullptr;
+    }
 
     buffer.shrink(p - buffer.data());
     return SharedBuffer::adoptVector(buffer);
index 9469f1a..94dddca 100644 (file)
@@ -588,7 +588,11 @@ unsigned short URL::port() const
         return 0;
 
     bool ok = false;
-    unsigned number = charactersToUIntStrict(m_string.deprecatedCharacters() + m_hostEnd + 1, m_portEnd - m_hostEnd - 1, &ok);
+    unsigned number;
+    if (m_string.is8Bit())
+        number = charactersToUIntStrict(m_string.characters8() + m_hostEnd + 1, m_portEnd - m_hostEnd - 1, &ok);
+    else
+        number = charactersToUIntStrict(m_string.characters16() + m_hostEnd + 1, m_portEnd - m_hostEnd - 1, &ok);
     if (!ok || number > maximumValidPortNumber)
         return invalidPortNumber;
     return number;
@@ -1666,14 +1670,14 @@ static void encodeRelativeString(const String& rel, const TextEncoding& encoding
     }
 
     if (pathEnd == -1) {
-        CString decoded = pathEncoding.encode(s.data(), s.size(), URLEncodedEntitiesForUnencodables);
+        CString decoded = pathEncoding.encode(StringView(s.data(), s.size()), URLEncodedEntitiesForUnencodables);
         output.resize(decoded.length());
         memcpy(output.data(), decoded.data(), decoded.length());
     } else {
-        CString pathDecoded = pathEncoding.encode(s.data(), pathEnd, URLEncodedEntitiesForUnencodables);
+        CString pathDecoded = pathEncoding.encode(StringView(s.data(), pathEnd), URLEncodedEntitiesForUnencodables);
         // Unencodable characters in URLs are represented by converting
         // them to XML entities and escaping non-alphanumeric characters.
-        CString otherDecoded = encoding.encode(s.data() + pathEnd, s.size() - pathEnd, URLEncodedEntitiesForUnencodables);
+        CString otherDecoded = encoding.encode(StringView(s.data() + pathEnd, s.size() - pathEnd), URLEncodedEntitiesForUnencodables);
 
         output.resize(pathDecoded.length() + otherDecoded.length());
         memcpy(output.data(), pathDecoded.data(), pathDecoded.length());
index db5eb8e..8bc7146 100644 (file)
@@ -165,7 +165,7 @@ bool Color::parseHexColor(const String& name, RGBA32& rgb)
         return false;
     if (name.is8Bit())
         return parseHexColor(name.characters8(), name.length(), rgb);
-    return parseHexColor(name.deprecatedCharacters(), name.length(), rgb);
+    return parseHexColor(name.characters16(), name.length(), rgb);
 }
 
 int differenceSquared(const Color& c1, const Color& c2)
@@ -182,7 +182,7 @@ Color::Color(const String& name)
         if (name.is8Bit())
             m_valid = parseHexColor(name.characters8() + 1, name.length() - 1, m_color);
         else
-            m_valid = parseHexColor(name.deprecatedCharacters() + 1, name.length() - 1, m_color);
+            m_valid = parseHexColor(name.characters16() + 1, name.length() - 1, m_color);
     } else
         setNamedColor(name);
 }
index edc5454..e6640bd 100644 (file)
@@ -89,12 +89,10 @@ static unsigned centerTruncateToBuffer(const String& string, unsigned length, un
     unsigned truncatedLength = shouldInsertEllipsis ? omitStart + 1 + (length - omitEnd) : length - (omitEnd - omitStart);
     ASSERT(truncatedLength <= length);
 
-    memcpy(buffer, string.deprecatedCharacters(), sizeof(UChar) * omitStart);
-    if (shouldInsertEllipsis) {
-        buffer[omitStart] = horizontalEllipsis;
-        memcpy(&buffer[omitStart + 1], &string.deprecatedCharacters()[omitEnd], sizeof(UChar) * (length - omitEnd));
-    } else
-        memcpy(&buffer[omitStart], &string.deprecatedCharacters()[omitEnd], sizeof(UChar) * (length - omitEnd));
+    StringView(string).substring(0, omitStart).getCharactersWithUpconvert(buffer);
+    if (shouldInsertEllipsis)
+        buffer[omitStart++] = horizontalEllipsis;
+    StringView(string).substring(omitEnd, length - omitEnd).getCharactersWithUpconvert(&buffer[omitStart + 1]);
     return truncatedLength;
 }
 
@@ -119,7 +117,7 @@ static unsigned rightTruncateToBuffer(const String& string, unsigned length, uns
     unsigned keepLength = textBreakAtOrPreceding(it, keepCount);
     unsigned truncatedLength = shouldInsertEllipsis ? keepLength + 1 : keepLength;
 
-    memcpy(buffer, string.deprecatedCharacters(), sizeof(UChar) * keepLength);
+    StringView(string).substring(0, keepLength).getCharactersWithUpconvert(buffer);
     if (shouldInsertEllipsis)
         buffer[keepLength] = horizontalEllipsis;
 
@@ -133,7 +131,7 @@ static unsigned rightClipToCharacterBuffer(const String& string, unsigned length
 
     NonSharedCharacterBreakIterator it(StringView(string).substring(0, length));
     unsigned keepLength = textBreakAtOrPreceding(it, keepCount);
-    memcpy(buffer, string.deprecatedCharacters(), sizeof(UChar) * keepLength);
+    StringView(string).substring(0, keepLength).getCharactersWithUpconvert(buffer);
 
     return keepLength;
 }
@@ -145,7 +143,7 @@ static unsigned rightClipToWordBuffer(const String& string, unsigned length, uns
 
     TextBreakIterator* it = wordBreakIterator(StringView(string).substring(0, length));
     unsigned keepLength = textBreakAtOrPreceding(it, keepCount);
-    memcpy(buffer, string.deprecatedCharacters(), sizeof(UChar) * keepLength);
+    StringView(string).substring(0, keepLength).getCharactersWithUpconvert(buffer);
 
 #if PLATFORM(IOS)
     // FIXME: We should guard this code behind an editing behavior. Then we can remove the PLATFORM(IOS)-guard.
@@ -178,10 +176,10 @@ static unsigned leftTruncateToBuffer(const String& string, unsigned length, unsi
 
     if (shouldInsertEllipsis) {
         buffer[0] = horizontalEllipsis;
-        memcpy(&buffer[1], &string.deprecatedCharacters()[adjustedStartIndex], sizeof(UChar) * (length - adjustedStartIndex + 1));
+        StringView(string).substring(adjustedStartIndex, length - adjustedStartIndex + 1).getCharactersWithUpconvert(&buffer[1]);
         return length - adjustedStartIndex + 1;
     }
-    memcpy(&buffer[0], &string.deprecatedCharacters()[adjustedStartIndex], sizeof(UChar) * (length - adjustedStartIndex + 1));
+    StringView(string).substring(adjustedStartIndex, length - adjustedStartIndex + 1).getCharactersWithUpconvert(&buffer[0]);
     return length - adjustedStartIndex;
 }
 
@@ -218,7 +216,7 @@ static String truncateString(const String& string, float maxWidth, const Font& f
         truncatedLength = centerTruncateToBuffer(string, length, keepCount, stringBuffer, shouldInsertEllipsis);
     } else {
         keepCount = length;
-        memcpy(stringBuffer, string.deprecatedCharacters(), sizeof(UChar) * length);
+        StringView(string).getCharactersWithUpconvert(stringBuffer);
         truncatedLength = length;
     }
 
index 698541e..0b34bed 100644 (file)
@@ -116,11 +116,11 @@ public:
         , m_disableSpacing(false)
         , m_tabSize(0)
     {
-        if (m_charactersLength && s.is8Bit()) {
+        if (!m_charactersLength || s.is8Bit()) {
             m_data.characters8 = s.characters8();
             m_is8Bit = true;
         } else {
-            m_data.characters16 = s.deprecatedCharacters();
+            m_data.characters16 = s.characters16();
             m_is8Bit = false;
         }
     }
index 156b24a..efefcbf 100644 (file)
@@ -1246,7 +1246,7 @@ bool MediaPlayerPrivateAVFoundationObjC::shouldWaitForLoadingOfResource(AVAssetR
         initDataView->set<uint32_t>(0, keyURISize, true);
 
         RefPtr<Uint16Array> keyURIArray = Uint16Array::create(initDataBuffer, 4, keyURI.length());
-        keyURIArray->setRange(keyURI.deprecatedCharacters(), keyURI.length() / sizeof(unsigned char), 0);
+        keyURIArray->setRange(StringView(keyURI).upconvertedCharacters(), keyURI.length() / sizeof(unsigned char), 0);
 
 #if ENABLE(ENCRYPTED_MEDIA)
         if (!player()->keyNeeded("com.apple.lskd", emptyString(), static_cast<const unsigned char*>(initDataBuffer->data()), initDataBuffer->byteLength()))
index 52b9240..a4ccc54 100644 (file)
@@ -44,6 +44,7 @@
 #include FT_TRUETYPE_TABLES_H
 #include <hb.h>
 #include <wtf/text/CString.h>
+#include <wtf/text/StringView.h>
 
 namespace WebCore {
 
@@ -112,7 +113,7 @@ static hb_bool_t harfBuzzGetGlyph(hb_font_t*, void* fontData, hb_codepoint_t uni
     if (result.isNewEntry) {
         cairo_glyph_t* glyphs = 0;
         int numGlyphs = 0;
-        CString utf8Codepoint = UTF8Encoding().encode(reinterpret_cast<UChar*>(&unicode), 1, QuestionMarksForUnencodables);
+        CString utf8Codepoint = UTF8Encoding().encode(StringView(reinterpret_cast<UChar*>(&unicode), 1), QuestionMarksForUnencodables);
         if (cairo_scaled_font_text_to_glyphs(scaledFont, 0, 0, utf8Codepoint.data(), utf8Codepoint.length(), &glyphs, &numGlyphs, 0, 0, 0) != CAIRO_STATUS_SUCCESS)
             return false;
         if (!numGlyphs)
index 89c708a..229600e 100644 (file)
@@ -35,6 +35,7 @@
 #include "TextEncoding.h"
 #include <wtf/text/Base64.h>
 #include <wtf/text/CString.h>
+#include <wtf/text/StringView.h>
 
 namespace WebCore {
 
@@ -84,7 +85,7 @@ void handleDataURL(ResourceHandle* handle)
         data = decodeURLEscapeSequences(data, encoding);
         handle->client()->didReceiveResponse(handle, response);
 
-        CString encodedData = encoding.encode(data.deprecatedCharacters(), data.length(), URLEncodedEntitiesForUnencodables);
+        CString encodedData = encoding.encode(data, URLEncodedEntitiesForUnencodables);
         response.setExpectedContentLength(encodedData.length());
         if (encodedData.length())
             handle->client()->didReceiveData(handle, encodedData.data(), encodedData.length(), 0);
index a76916e..acad8e0 100644 (file)
 #include "Blob.h"
 #include "Document.h"
 #include "TextEncoding.h"
-
 #include <limits>
 #include <wtf/Assertions.h>
 #include <wtf/HexNumber.h>
-#include <wtf/text/CString.h>
 #include <wtf/RandomNumber.h>
+#include <wtf/text/CString.h>
+#include <wtf/text/StringView.h>
 
 namespace WebCore {
 
@@ -61,12 +61,11 @@ static void appendQuotedString(Vector<char>& buffer, const CString& string)
     size_t length = string.length();
     for (size_t i = 0; i < length; ++i) {
         char c = string.data()[i];
-
         switch (c) {
-        case  0x0a:
+        case 0xA:
             append(buffer, "%0A");
             break;
-        case 0x0d:
+        case 0xD:
             append(buffer, "%0D");
             break;
         case '"':
@@ -86,11 +85,9 @@ TextEncoding FormDataBuilder::encodingFromAcceptCharset(const String& acceptChar
     Vector<String> charsets;
     normalizedAcceptCharset.split(' ', charsets);
 
-    TextEncoding encoding;
-
-    Vector<String>::const_iterator end = charsets.end();
-    for (Vector<String>::const_iterator it = charsets.begin(); it != end; ++it) {
-        if ((encoding = TextEncoding(*it)).isValid())
+    for (auto& charset : charsets) {
+        TextEncoding encoding(charset);
+        if (encoding.isValid())
             return encoding;
     }
 
@@ -165,7 +162,7 @@ void FormDataBuilder::addFilenameToMultiPartHeader(Vector<char>& buffer, const T
     // FIXME: This loses data irreversibly if the filename includes characters you can't encode
     // in the website's character set.
     append(buffer, "; filename=\"");
-    appendQuotedString(buffer, encoding.encode(filename.deprecatedCharacters(), filename.length(), QuestionMarksForUnencodables));
+    appendQuotedString(buffer, encoding.encode(filename, QuestionMarksForUnencodables));
     append(buffer, '"');
 }
 
index 4b2b771..ee1b88f 100644 (file)
@@ -30,7 +30,7 @@
 #include "SQLValue.h"
 #include <sqlite3.h>
 #include <wtf/Assertions.h>
-#include <wtf/text/StringImpl.h>
+#include <wtf/text/StringView.h>
 
 // SQLite 3.6.16 makes sqlite3_prepare_v2 automatically retry preparing the statement
 // once if the database scheme has changed. We rely on this behavior.
@@ -177,12 +177,13 @@ int SQLiteStatement::bindBlob(int index, const String& text)
 {
     // String::characters() returns 0 for the empty string, which SQLite
     // treats as a null, so we supply a non-null pointer for that case.
+    auto upconvertedCharacters = StringView(text).upconvertedCharacters();
     UChar anyCharacter = 0;
     const UChar* characters;
     if (text.isEmpty() && !text.isNull())
         characters = &anyCharacter;
     else
-        characters = text.deprecatedCharacters();
+        characters = upconvertedCharacters;
 
     return bindBlob(index, characters, text.length() * sizeof(UChar));
 }
@@ -195,12 +196,13 @@ int SQLiteStatement::bindText(int index, const String& text)
 
     // String::characters() returns 0 for the empty string, which SQLite
     // treats as a null, so we supply a non-null pointer for that case.
+    auto upconvertedCharacters = StringView(text).upconvertedCharacters();
     UChar anyCharacter = 0;
     const UChar* characters;
     if (text.isEmpty() && !text.isNull())
         characters = &anyCharacter;
     else
-        characters = text.deprecatedCharacters();
+        characters = upconvertedCharacters;
 
     return sqlite3_bind_text16(m_statement, index, characters, sizeof(UChar) * text.length(), SQLITE_TRANSIENT);
 }
index 2fa6e46..c8a2892 100644 (file)
@@ -51,19 +51,19 @@ struct Unicode16BitEscapeSequence {
         }
         return runEnd;
     }
-    static String decodeRun(const UChar* run, size_t runLength, const TextEncoding&)
+    static String decodeRun(StringView run, const TextEncoding&)
     {
         // Each %u-escape sequence represents a UTF-16 code unit.
         // See <http://www.w3.org/International/iri-edit/draft-duerst-iri.html#anchor29>.
         // For 16-bit escape sequences, we know that findEndOfRun() has given us a contiguous run of sequences
         // without any intervening characters, so decode the run without additional checks.
-        size_t numberOfSequences = runLength / sequenceSize;
+        auto numberOfSequences = run.length() / sequenceSize;
         StringBuilder builder;
         builder.reserveCapacity(numberOfSequences);
         while (numberOfSequences--) {
             UChar codeUnit = (toASCIIHexValue(run[2]) << 12) | (toASCIIHexValue(run[3]) << 8) | (toASCIIHexValue(run[4]) << 4) | toASCIIHexValue(run[5]);
             builder.append(codeUnit);
-            run += sequenceSize;
+            run = run.substring(sequenceSize);
         }
         return builder.toString();
     }
@@ -96,21 +96,20 @@ struct URLEscapeSequence {
         }
         return runEnd;
     }
-    static String decodeRun(const UChar* run, size_t runLength, const TextEncoding& encoding)
+    static String decodeRun(StringView run, const TextEncoding& encoding)
     {
         // For URL escape sequences, we know that findEndOfRun() has given us a run where every %-sign introduces
         // a valid escape sequence, but there may be characters between the sequences.
         Vector<char, 512> buffer;
-        buffer.resize(runLength); // Unescaping hex sequences only makes the length smaller.
+        buffer.resize(run.length()); // Unescaping hex sequences only makes the length smaller.
         char* p = buffer.data();
-        const UChar* runEnd = run + runLength;
-        while (run < runEnd) {
+        while (!run.isEmpty()) {
             if (run[0] == '%') {
                 *p++ = (toASCIIHexValue(run[1]) << 4) | toASCIIHexValue(run[2]);
-                run += sequenceSize;
+                run = run.substring(sequenceSize);
             } else {
                 *p++ = run[0];
-                run += 1;
+                run = run.substring(1);
             }
         }
         ASSERT(buffer.size() >= static_cast<size_t>(p - buffer.data())); // Prove buffer not overrun.
@@ -134,7 +133,7 @@ String decodeEscapeSequences(const String& string, const TextEncoding& encoding)
             continue;
         }
 
-        String decoded = EscapeSequence::decodeRun(string.deprecatedCharacters() + encodedRunPosition, encodedRunEnd - encodedRunPosition, encoding);
+        String decoded = EscapeSequence::decodeRun(StringView(string).substring(encodedRunPosition, encodedRunEnd - encodedRunPosition), encoding);
         if (decoded.isEmpty())
             continue;
 
index 89f6438..13dd37a 100644 (file)
@@ -27,6 +27,7 @@
 #include "Hyphenation.h"
 
 #include "NotImplemented.h"
+#include <wtf/text/StringView.h>
 
 namespace WebCore {
 
@@ -35,7 +36,7 @@ bool canHyphenate(const AtomicString& /* localeIdentifier */)
     return false;
 }
 
-size_t lastHyphenLocation(const UChar* /* characters */, size_t /* length */, size_t /* beforeIndex */, const AtomicString& /* localeIdentifier */)
+size_t lastHyphenLocation(StringView, size_t /* beforeIndex */, const AtomicString& /* localeIdentifier */)
 {
     ASSERT_NOT_REACHED();
     return 0;
index 20882dc..38f2af1 100644 (file)
@@ -32,7 +32,7 @@
 namespace WebCore {
 
 bool canHyphenate(const AtomicString& localeIdentifier);
-size_t lastHyphenLocation(const UChar*, size_t length, size_t beforeIndex, const AtomicString& localeIdentifier);
+size_t lastHyphenLocation(StringView, size_t beforeIndex, const AtomicString& localeIdentifier);
 
 } // namespace WebCore
 
index 108d3b6..4786083 100644 (file)
@@ -28,7 +28,6 @@
 #include <mutex>
 #include <wtf/Atomics.h>
 #include <wtf/text/StringView.h>
-#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
@@ -43,16 +42,19 @@ static TextBreakIterator* initializeIterator(UBreakIteratorType type, const char
 }
 
 #if !PLATFORM(IOS)
+
 static TextBreakIterator* initializeIteratorWithRules(const char* breakRules)
 {
     UParseError parseStatus;
     UErrorCode openStatus = U_ZERO_ERROR;
-    String rules(breakRules);
-    TextBreakIterator* iterator = reinterpret_cast<TextBreakIterator*>(ubrk_openRules(rules.deprecatedCharacters(), rules.length(), 0, 0, &parseStatus, &openStatus));
+    unsigned length = strlen(breakRules);
+    auto upconvertedCharacters = StringView(reinterpret_cast<const LChar*>(breakRules), length).upconvertedCharacters();
+    TextBreakIterator* iterator = reinterpret_cast<TextBreakIterator*>(ubrk_openRules(upconvertedCharacters, length, 0, 0, &parseStatus, &openStatus));
     ASSERT_WITH_MESSAGE(U_SUCCESS(openStatus), "ICU could not open a break iterator: %s (%d)", u_errorName(openStatus), openStatus);
     return iterator;
 }
-#endif // !PLATFORM(IOS)
+
+#endif
 
 
 // Iterator text setting
index 5666255..db82bd7 100644 (file)
@@ -34,7 +34,7 @@
 #include <wtf/OwnPtr.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/text/CString.h>
-#include <wtf/text/WTFString.h>
+#include <wtf/text/StringView.h>
 
 namespace WebCore {
 
@@ -64,20 +64,22 @@ String TextEncoding::decode(const char* data, size_t length, bool stopOnError, b
     return newTextCodec(*this)->decode(data, length, true, stopOnError, sawError);
 }
 
-CString TextEncoding::encode(const UChar* characters, size_t length, UnencodableHandling handling) const
+CString TextEncoding::encode(StringView text, UnencodableHandling handling) const
 {
     if (!m_name)
         return CString();
 
-    if (!length)
+    if (text.isEmpty())
         return "";
 
     // FIXME: What's the right place to do normalization?
     // It's a little strange to do it inside the encode function.
     // Perhaps normalization should be an explicit step done before calling encode.
 
-    const UChar* source = characters;
-    size_t sourceLength = length;
+    auto upconvertedCharacters = text.upconvertedCharacters();
+
+    const UChar* source = upconvertedCharacters;
+    size_t sourceLength = text.length();
 
     Vector<UChar> normalizedCharacters;
 
@@ -85,17 +87,18 @@ CString TextEncoding::encode(const UChar* characters, size_t length, Unencodable
     if (unorm_quickCheck(source, sourceLength, UNORM_NFC, &err) != UNORM_YES) {
         // First try using the length of the original string, since normalization to NFC rarely increases length.
         normalizedCharacters.grow(sourceLength);
-        int32_t normalizedLength = unorm_normalize(source, length, UNORM_NFC, 0, normalizedCharacters.data(), length, &err);
+        int32_t normalizedLength = unorm_normalize(source, sourceLength, UNORM_NFC, 0, normalizedCharacters.data(), sourceLength, &err);
         if (err == U_BUFFER_OVERFLOW_ERROR) {
             err = U_ZERO_ERROR;
             normalizedCharacters.resize(normalizedLength);
-            normalizedLength = unorm_normalize(source, length, UNORM_NFC, 0, normalizedCharacters.data(), normalizedLength, &err);
+            normalizedLength = unorm_normalize(source, sourceLength, UNORM_NFC, 0, normalizedCharacters.data(), normalizedLength, &err);
         }
         ASSERT(U_SUCCESS(err));
 
         source = normalizedCharacters.data();
         sourceLength = normalizedLength;
     }
+
     return newTextCodec(*this)->encode(source, sourceLength, handling);
 }
 
index 1a1fab4..c9cf6c2 100644 (file)
@@ -69,7 +69,7 @@ namespace WebCore {
             return decode(str, length, false, ignored);
         }
         String decode(const char*, size_t length, bool stopOnError, bool& sawError) const;
-        CString encode(const UChar*, size_t length, UnencodableHandling) const;
+        CString encode(StringView, UnencodableHandling) const;
 
         UChar backslashAsCurrencySymbol() const;
 
index f53671f..b8b2999 100644 (file)
@@ -336,12 +336,12 @@ const char* atomicCanonicalTextEncodingName(const CharacterType* characters, siz
 const char* atomicCanonicalTextEncodingName(const String& alias)
 {
     if (!alias.length())
-        return 0;
+        return nullptr;
 
     if (alias.is8Bit())
-        return atomicCanonicalTextEncodingName<LChar>(alias.characters8(), alias.length());
+        return atomicCanonicalTextEncodingName(alias.characters8(), alias.length());
 
-    return atomicCanonicalTextEncodingName<UChar>(alias.deprecatedCharacters(), alias.length());
+    return atomicCanonicalTextEncodingName(alias.characters16(), alias.length());
 }
 
 bool noExtendedTextEncodingNameUsed()
index c7802b9..a344bd8 100644 (file)
@@ -31,6 +31,7 @@
 #include "TextBreakIteratorInternalICU.h"
 #include <wtf/ListHashSet.h>
 #include <wtf/RetainPtr.h>
+#include <wtf/text/StringView.h>
 
 namespace WebCore {
 
@@ -73,15 +74,13 @@ bool canHyphenate(const AtomicString& localeIdentifier)
 #endif // PLATFORM(IOS)
 }
 
-size_t lastHyphenLocation(const UChar* characters, size_t length, size_t beforeIndex, const AtomicString& localeIdentifier)
+size_t lastHyphenLocation(StringView text, size_t beforeIndex, const AtomicString& localeIdentifier)
 {
-    RetainPtr<CFStringRef> string = adoptCF(CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, reinterpret_cast<const UniChar*>(characters), length, kCFAllocatorNull));
-
     RetainPtr<CFLocaleRef> locale = cfLocaleCache().get(localeIdentifier);
     ASSERT(locale);
 
     CFOptionFlags searchAcrossWordBoundaries = 1;
-    CFIndex result = CFStringGetHyphenationLocationBeforeIndex(string.get(), beforeIndex, CFRangeMake(0, length), searchAcrossWordBoundaries, locale.get(), 0);
+    CFIndex result = CFStringGetHyphenationLocationBeforeIndex(text.createCFStringWithoutCopying().get(), beforeIndex, CFRangeMake(0, text.length()), searchAcrossWordBoundaries, locale.get(), 0);
     return result == kCFNotFound ? 0 : result;
 }
 
index 3bcda72..8ddb655 100644 (file)
@@ -5277,9 +5277,9 @@ TextRun RenderBlock::constructTextRun(RenderObject* context, const Font& font, c
 {
     unsigned length = string.length();
 
-    if (length && string.is8Bit())
+    if (!length || string.is8Bit())
         return constructTextRunInternal(context, font, string.characters8(), length, style, expansion, flags);
-    return constructTextRunInternal(context, font, string.deprecatedCharacters(), length, style, expansion, flags);
+    return constructTextRunInternal(context, font, string.characters16(), length, style, expansion, flags);
 }
 
 RenderBlock* RenderBlock::createAnonymousWithParentRendererAndDisplay(const RenderObject* parent, EDisplay display)
index ffee00f..11f8b97 100644 (file)
@@ -60,9 +60,6 @@ void RenderCombineText::setTextInternal(const String& text)
 
 float RenderCombineText::width(unsigned from, unsigned length, const Font& font, float xPosition, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
 {
-    if (!deprecatedCharacters())
-        return 0;
-
     if (m_isCombined)
         return font.size();
 
index 9f2e937..cdea9ff 100644 (file)
@@ -624,15 +624,15 @@ static inline float hyphenWidth(RenderText* renderer, const Font& font)
     return font.width(RenderBlock::constructTextRun(renderer, font, style.hyphenString().string(), style));
 }
 
-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)
+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)
 {
     suffixStart = 0;
-    if (wordLength <= minimumSuffixLength)
+    if (word.length() <= minimumSuffixLength)
         return 0;
 
     Vector<int, 8> hyphenLocations;
-    int hyphenLocation = wordLength - minimumSuffixLength;
-    while ((hyphenLocation = lastHyphenLocation(word, wordLength, hyphenLocation, style.locale())) >= minimumPrefixLength)
+    int hyphenLocation = word.length() - minimumSuffixLength;
+    while ((hyphenLocation = lastHyphenLocation(word, hyphenLocation, style.locale())) >= minimumPrefixLength)
         hyphenLocations.append(hyphenLocation);
 
     if (hyphenLocations.isEmpty())
@@ -645,7 +645,7 @@ static float maxWordFragmentWidth(RenderText* renderer, const RenderStyle& style
     for (size_t k = 0; k < hyphenLocations.size(); ++k) {
         int fragmentLength = hyphenLocations[k] - suffixStart;
         StringBuilder fragmentWithHyphen;
-        fragmentWithHyphen.append(word + suffixStart, fragmentLength);
+        fragmentWithHyphen.append(word.substring(suffixStart, fragmentLength));
         fragmentWithHyphen.append(style.hyphenString());
 
         TextRun run = RenderBlock::constructTextRun(renderer, font, fragmentWithHyphen.deprecatedCharacters(), fragmentWithHyphen.length(), style);
@@ -797,7 +797,7 @@ void RenderText::computePreferredLogicalWidths(float leadWidth, HashSet<const Si
 
             if (w > maxWordWidth) {
                 int suffixStart;
-                float maxFragmentWidth = maxWordFragmentWidth(this, style, font, deprecatedCharacters() + i, wordLen, minimumPrefixLength, minimumSuffixLength, suffixStart, fallbackFonts, glyphOverflow);
+                float maxFragmentWidth = maxWordFragmentWidth(this, style, font, StringView(m_text).substring(i, wordLen), minimumPrefixLength, minimumSuffixLength, suffixStart, fallbackFonts, glyphOverflow);
 
                 if (suffixStart) {
                     float suffixWidth;
index 9e89cdf..24ae588 100644 (file)
@@ -597,11 +597,11 @@ inline void tryHyphenating(RenderText* text, const Font& font, const AtomicStrin
     if (prefixLength < minimumPrefixLength)
         return;
 
-    prefixLength = lastHyphenLocation(text->deprecatedCharacters() + lastSpace, pos - lastSpace, std::min(prefixLength, pos - lastSpace - minimumSuffixLength) + 1, localeIdentifier);
+    prefixLength = lastHyphenLocation(StringView(text->text()).substring(lastSpace, pos - lastSpace), std::min(prefixLength, pos - lastSpace - minimumSuffixLength) + 1, localeIdentifier);
     if (!prefixLength || prefixLength < minimumPrefixLength)
         return;
 
-    // When lastSapce is a space, which it always is except sometimes at the beginning of a line or after collapsed
+    // When lastSpace is a space, which it always is except sometimes at the beginning of a line or after collapsed
     // space, it should not count towards hyphenate-limit-before.
     if (prefixLength == minimumPrefixLength) {
         UChar characterAtLastSpace = text->characterAt(lastSpace);
index a90da0c..4df29c4 100644 (file)
@@ -436,7 +436,8 @@ void SVGTextLayoutEngine::layoutTextOnLineOrPath(SVGInlineTextBox* textBox, Rend
     Vector<SVGTextMetrics>& visualMetricsValues = text->layoutAttributes()->textMetricsValues();
     ASSERT(!visualMetricsValues.isEmpty());
 
-    const UChar* characters = text->deprecatedCharacters();
+    auto upconvertedCharacters = StringView(text->text()).upconvertedCharacters();
+    const UChar* characters = upconvertedCharacters;
     const Font& font = style->font();
 
     SVGTextLayoutEngineSpacing spacingLayout(font);
index 7b899e8..07573f3 100644 (file)
@@ -105,7 +105,7 @@ SVGTextMetrics::SVGTextMetrics(RenderSVGInlineText* text, unsigned position, uns
     m_height = text->scaledFont().fontMetrics().floatHeight() / scalingFactor;
     if (needsContext) {
         m_glyph.isValid = true;
-        m_glyph.unicodeString = String(text->deprecatedCharacters() + position, length);
+        m_glyph.unicodeString = text->text()->substring(position, length);
         m_glyph.name = glyphName;
     }
 
index 94e8fb2..588f277 100644 (file)
@@ -25,7 +25,7 @@
 #include "ExceptionCode.h"
 #include "SVGParserUtilities.h"
 #include <wtf/MathExtras.h>
-#include <wtf/text/WTFString.h>
+#include <wtf/text/StringView.h>
 
 namespace WebCore {
 
@@ -140,7 +140,8 @@ void SVGAngle::setValueAsString(const String& value, ExceptionCode& ec)
     }
 
     float valueInSpecifiedUnits = 0;
-    const UChar* ptr = value.deprecatedCharacters();
+    auto upconvertedCharacters = StringView(value).upconvertedCharacters();
+    const UChar* ptr = upconvertedCharacters;
     const UChar* end = ptr + value.length();
 
     if (!parseNumber(ptr, end, valueInSpecifiedUnits, false)) {
index b979a75..bf1c757 100644 (file)
@@ -38,6 +38,7 @@
 #include "SVGTransformList.h"
 #include <wtf/MathExtras.h>
 #include <wtf/StdLibExtras.h>
+#include <wtf/text/StringView.h>
 
 namespace WebCore {
     
@@ -156,7 +157,8 @@ static bool parsePoint(const String& s, FloatPoint& point)
 {
     if (s.isEmpty())
         return false;
-    const UChar* cur = s.deprecatedCharacters();
+    auto upconvertedCharacters = StringView(s).upconvertedCharacters();
+    const UChar* cur = upconvertedCharacters;
     const UChar* end = cur + s.length();
     
     if (!skipOptionalSVGSpaces(cur, end))
index ce91f1b..a52d2cc 100644 (file)
@@ -38,6 +38,7 @@
 #include "SVGNames.h"
 #include "SVGParserUtilities.h"
 #include <wtf/MathExtras.h>
+#include <wtf/text/StringView.h>
 
 namespace WebCore {
 
@@ -92,7 +93,9 @@ static void parseKeySplines(const String& parse, Vector<UnitBezier>& result)
     result.clear();
     if (parse.isEmpty())
         return;
-    const UChar* cur = parse.deprecatedCharacters();
+
+    auto upconvertedCharacters = StringView(parse).upconvertedCharacters();
+    const UChar* cur = upconvertedCharacters;
     const UChar* end = cur + parse.length();
 
     skipOptionalSVGSpaces(cur, end);
index a51aaf2..e30e270 100644 (file)
 #include "SVGNames.h"
 #include "SVGParserUtilities.h"
 #include "SVGPreserveAspectRatio.h"
-#include <wtf/text/StringImpl.h>
+#include <wtf/text/StringView.h>
 
 namespace WebCore {
 
 bool SVGFitToViewBox::parseViewBox(Document* doc, const String& s, FloatRect& viewBox)
 {
-    const UChar* c = s.deprecatedCharacters();
-    const UChar* end = c + s.length();
-    return parseViewBox(doc, c, end, viewBox, true);
+    auto upconvertedCharacters = StringView(s).upconvertedCharacters();
+    const UChar* characters = upconvertedCharacters;
+    return parseViewBox(doc, characters, characters + s.length(), viewBox, true);
 }
 
 bool SVGFitToViewBox::parseViewBox(Document* doc, const UChar*& c, const UChar* end, FloatRect& viewBox, bool validate)
index 191ff80..80710ce 100644 (file)
@@ -41,6 +41,8 @@ using namespace Unicode;
 
 namespace WebCore {
 
+static String createStringWithMirroredCharacters(StringView);
+
 SVGFontData::SVGFontData(SVGFontFaceElement* fontFaceElement)
     : m_svgFontFaceElement(fontFaceElement)
     , m_horizontalOriginX(fontFaceElement->horizontalOriginX())
@@ -146,7 +148,7 @@ bool SVGFontData::applySVGGlyphSelection(WidthIterator& iterator, GlyphData& gly
     }
 
     if (mirror)
-        remainingTextInRun = createStringWithMirroredCharacters(remainingTextInRun.deprecatedCharacters(), remainingTextInRun.length());
+        remainingTextInRun = createStringWithMirroredCharacters(remainingTextInRun);
     if (!currentCharacter && arabicForms.isEmpty())
         arabicForms = charactersWithArabicForm(remainingTextInRun, mirror);
 
@@ -287,18 +289,16 @@ bool SVGFontData::fillNonBMPGlyphs(SVGFontElement* fontElement, GlyphPage* pageT
     return haveGlyphs;
 }
 
-String SVGFontData::createStringWithMirroredCharacters(const UChar* characters, unsigned length) const
+String createStringWithMirroredCharacters(StringView string)
 {
+    unsigned length = string.length();
     StringBuilder mirroredCharacters;
     mirroredCharacters.reserveCapacity(length);
-
-    unsigned i = 0;
-    while (i < length) {
+    for (unsigned i = 0; i < length; ) {
         UChar32 character;
-        U16_NEXT(characters, i, length, character);
+        U16_NEXT(string, i, length, character);
         mirroredCharacters.append(u_charMirror(character));
     }
-
     return mirroredCharacters.toString();
 }
 
index 3fb967c..72728a1 100644 (file)
@@ -52,8 +52,6 @@ private:
     bool fillBMPGlyphs(SVGFontElement*, GlyphPage* , unsigned offset, unsigned length, UChar* buffer, const SimpleFontData*) const;
     bool fillNonBMPGlyphs(SVGFontElement*, GlyphPage* , unsigned offset, unsigned length, UChar* buffer, const SimpleFontData*) const;
 
-    String createStringWithMirroredCharacters(const UChar* characters, unsigned length) const;
-
     // Ths SVGFontFaceElement is kept alive --
     // 1) in the external font case: by the CSSFontFaceSource, which holds a reference to the external SVG document
     //    containing the element;
index c035523..a20a656 100644 (file)
@@ -94,9 +94,9 @@ void SVGFontElement::registerLigaturesInGlyphCache(Vector<String>& ligatures)
         unsigned unicodeLength = unicode.length();
         ASSERT(unicodeLength > 1);
 
-        const UChar* characters = unicode.deprecatedCharacters();
         for (unsigned i = 0; i < unicodeLength; ++i) {
-            String lookupString(characters + i, 1);
+            UChar character = unicode[i];
+            String lookupString(&character, 1);
             m_glyphMap.collectGlyphsForString(lookupString, glyphs);
             if (!glyphs.isEmpty()) {
                 glyphs.clear();
index 00f87a5..3518f88 100644 (file)
 #define SVGGlyphMap_h
 
 #if ENABLE(SVG_FONTS)
+
 #include "SurrogatePairAwareTextIterator.h"
 #include "SVGGlyph.h"
-
 #include <wtf/HashMap.h>
 #include <wtf/Vector.h>
+#include <wtf/text/StringView.h>
 
 namespace WebCore {
 
@@ -68,7 +69,8 @@ public:
 
         UChar32 character = 0;
         unsigned clusterLength = 0;
-        SurrogatePairAwareTextIterator textIterator(unicodeString.deprecatedCharacters(), 0, length, length);
+        auto upconvertedCharacters = StringView(unicodeString).upconvertedCharacters();
+        SurrogatePairAwareTextIterator textIterator(upconvertedCharacters, 0, length, length);
         while (textIterator.consume(character, clusterLength)) {
             node = currentLayer->get(character);
             if (!node) {
@@ -113,12 +115,12 @@ public:
     {
         GlyphMapLayer* currentLayer = &m_rootLayer;
 
-        const UChar* characters = string.deprecatedCharacters();
+        auto upconvertedCharacters = StringView(string).upconvertedCharacters();
         size_t length = string.length();
 
         UChar32 character = 0;
         unsigned clusterLength = 0;
-        SurrogatePairAwareTextIterator textIterator(characters, 0, length, length);
+        SurrogatePairAwareTextIterator textIterator(upconvertedCharacters, 0, length, length);
         while (textIterator.consume(character, clusterLength)) {
             RefPtr<GlyphMapNode> node = currentLayer->get(character);
             if (!node)
index 218dcd9..9caa1b8 100644 (file)
@@ -27,6 +27,7 @@
 #include "SVGParserUtilities.h"
 #include "XLinkNames.h"
 #include <wtf/text/AtomicString.h>
+#include <wtf/text/StringView.h>
 
 namespace WebCore {
 
@@ -66,7 +67,8 @@ bool SVGGlyphRefElement::hasValidGlyphElement(String& glyphName) const
 
 void SVGGlyphRefElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
 {
-    const UChar* startPtr = value.string().deprecatedCharacters();
+    auto upconvertedCharacters = StringView(value.string()).upconvertedCharacters();
+    const UChar* startPtr = upconvertedCharacters;
     const UChar* endPtr = startPtr + value.length();
 
     // FIXME: We need some error handling here.
index 3cf2d24..bafd276 100644 (file)
@@ -29,9 +29,8 @@
 #include "FloatConversion.h"
 #include "SVGNames.h"
 #include "SVGParserUtilities.h"
-
 #include <wtf/MathExtras.h>
-#include <wtf/text/WTFString.h>
+#include <wtf/text/StringView.h>
 
 namespace WebCore {
 
@@ -224,7 +223,8 @@ void SVGLength::setValueAsString(const String& string, ExceptionCode& ec)
         return;
 
     float convertedNumber = 0;
-    const UChar* ptr = string.deprecatedCharacters();
+    auto upconvertedCharacters = StringView(string).upconvertedCharacters();
+    const UChar* ptr = upconvertedCharacters;
     const UChar* end = ptr + string.length();
 
     if (!parseNumber(ptr, end, convertedNumber, false)) {
index 2ba0b55..9a00ebf 100644 (file)
@@ -31,7 +31,8 @@ void SVGLengthList::parse(const String& value, SVGLengthMode mode)
     clear();
     ExceptionCode ec = 0;
 
-    const UChar* ptr = value.deprecatedCharacters();
+    auto upconvertedCharacters = StringView(value).upconvertedCharacters();
+    const UChar* ptr = upconvertedCharacters;
     const UChar* end = ptr + value.length();
     while (ptr < end) {
         const UChar* start = ptr;
index fd6aebb..3c02c1e 100644 (file)
@@ -31,7 +31,8 @@ void SVGNumberList::parse(const String& value)
     clear();
 
     float number = 0;
-    const UChar* ptr = value.deprecatedCharacters();
+    auto upconvertedCharacters = StringView(value).upconvertedCharacters();
+    const UChar* ptr = upconvertedCharacters;
     const UChar* end = ptr + value.length();
 
     // The spec strangely doesn't allow leading whitespace.  We might choose to violate that intentionally. (section 4.1)
index aad3313..0b0d88b 100644 (file)
@@ -26,9 +26,9 @@
 #include "Document.h"
 #include "FloatRect.h"
 #include "SVGPointList.h"
-
 #include <limits>
 #include <wtf/ASCIICType.h>
+#include <wtf/text/StringView.h>
 
 namespace WebCore {
 
@@ -164,7 +164,8 @@ bool parseNumber(const UChar*& ptr, const UChar* end, float& number, bool skip)
 
 bool parseNumberFromString(const String& string, float& number, bool skip)
 {
-    const UChar* ptr = string.deprecatedCharacters();
+    auto upconvertedCharacters = StringView(string).upconvertedCharacters();
+    const UChar* ptr = upconvertedCharacters;
     const UChar* end = ptr + string.length();
     return genericParseNumber(ptr, end, number, skip) && ptr == end;
 }
@@ -203,7 +204,9 @@ bool parseNumberOptionalNumber(const String& s, float& x, float& y)
 {
     if (s.isEmpty())
         return false;
-    const UChar* cur = s.deprecatedCharacters();
+
+    auto upconvertedCharacters = StringView(s).upconvertedCharacters();
+    const UChar* cur = upconvertedCharacters;
     const UChar* end = cur + s.length();
 
     if (!parseNumber(cur, end, x))
@@ -219,7 +222,8 @@ bool parseNumberOptionalNumber(const String& s, float& x, float& y)
 
 bool parseRect(const String& string, FloatRect& rect)
 {
-    const UChar* ptr = string.deprecatedCharacters();
+    auto upconvertedCharacters = StringView(string).upconvertedCharacters();
+    const UChar* ptr = upconvertedCharacters;
     const UChar* end = ptr + string.length();
     skipOptionalSVGSpaces(ptr, end);
     
@@ -236,7 +240,8 @@ bool pointsListFromSVGData(SVGPointList& pointsList, const String& points)
 {
     if (points.isEmpty())
         return true;
-    const UChar* cur = points.deprecatedCharacters();
+    auto upconvertedCharacters = StringView(points).upconvertedCharacters();
+    const UChar* cur = upconvertedCharacters;
     const UChar* end = cur + points.length();
 
     skipOptionalSVGSpaces(cur, end);
@@ -270,7 +275,8 @@ bool parseGlyphName(const String& input, HashSet<String>& values)
     // FIXME: Parsing error detection is missing.
     values.clear();
 
-    const UChar* ptr = input.deprecatedCharacters();
+    auto upconvertedCharacters = StringView(input).upconvertedCharacters();
+    const UChar* ptr = upconvertedCharacters;
     const UChar* end = ptr + input.length();
     skipOptionalSVGSpaces(ptr, end);
 
@@ -367,7 +373,8 @@ static bool parseUnicodeRange(const UChar* characters, unsigned length, UnicodeR
 bool parseKerningUnicodeString(const String& input, UnicodeRanges& rangeList, HashSet<String>& stringList)
 {
     // FIXME: Parsing error detection is missing.
-    const UChar* ptr = input.deprecatedCharacters();
+    auto upconvertedCharacters = StringView(input).upconvertedCharacters();
+    const UChar* ptr = upconvertedCharacters;
     const UChar* end = ptr + input.length();
 
     while (ptr < end) {
@@ -394,7 +401,8 @@ Vector<String> parseDelimitedString(const String& input, const char seperator)
 {
     Vector<String> values;
 
-    const UChar* ptr = input.deprecatedCharacters();
+    auto upconvertedCharacters = StringView(input).upconvertedCharacters();
+    const UChar* ptr = upconvertedCharacters;
     const UChar* end = ptr + input.length();
     skipOptionalSVGSpaces(ptr, end);
 
index 66dd69c..15b97c2 100644 (file)
@@ -26,7 +26,7 @@
 #include "ExceptionCode.h"
 #include "FloatRect.h"
 #include "SVGParserUtilities.h"
-#include <wtf/text/WTFString.h>
+#include <wtf/text/StringView.h>
 
 namespace WebCore {
 
@@ -58,7 +58,8 @@ void SVGPreserveAspectRatio::setMeetOrSlice(unsigned short meetOrSlice, Exceptio
 
 void SVGPreserveAspectRatio::parse(const String& value)
 {
-    const UChar* begin = value.deprecatedCharacters();
+    auto upconvertedCharacters = StringView(value).upconvertedCharacters();
+    const UChar* begin = upconvertedCharacters;
     parseInternal(begin, begin + value.length(), true);
 }
 
index 694eb39..a118ae7 100644 (file)
@@ -48,7 +48,8 @@ void SVGStringList::parse(const String& data, UChar delimiter)
     // TODO : more error checking/reporting
     clear();
 
-    const UChar* ptr = data.deprecatedCharacters();
+    auto upconvertedCharacters = StringView(data).upconvertedCharacters();
+    const UChar* ptr = upconvertedCharacters;
     const UChar* end = ptr + data.length();
     while (ptr < end) {
         const UChar* start = ptr;
index e3ee718..11e624d 100644 (file)
@@ -74,7 +74,8 @@ String SVGTransformList::valueAsString() const
 
 void SVGTransformList::parse(const String& transform)
 {
-    const UChar* start = transform.deprecatedCharacters();
+    auto upconvertedCharacters = StringView(transform).upconvertedCharacters();
+    const UChar* start = upconvertedCharacters;
     if (!SVGTransformable::parseTransformAttribute(*this, start, start + transform.length()))
         clear();
 }
index a1129d5..4e156c6 100644 (file)
@@ -28,6 +28,7 @@
 #include "SVGNames.h"
 #include "SVGParserUtilities.h"
 #include "SVGTransformList.h"
+#include <wtf/text/StringView.h>
 
 namespace WebCore {
 
@@ -171,7 +172,8 @@ static inline bool parseAndSkipType(const UChar*& currTransform, const UChar* en
 SVGTransform::SVGTransformType SVGTransformable::parseTransformType(const String& typeString)
 {
     unsigned short type = SVGTransform::SVG_TRANSFORM_UNKNOWN;
-    const UChar* characters = typeString.deprecatedCharacters();
+    auto upconvertedCharacters = StringView(typeString).upconvertedCharacters();
+    const UChar* characters = upconvertedCharacters;
     parseAndSkipType(characters, characters + typeString.length(), type);
     return static_cast<SVGTransform::SVGTransformType>(type);
 }
index 2985ab1..9822bd1 100644 (file)
@@ -207,7 +207,8 @@ static const UChar viewTargetSpec[] =  {'v', 'i', 'e', 'w', 'T', 'a', 'r', 'g',
 
 bool SVGViewSpec::parseViewSpec(const String& viewSpec)
 {
-    const UChar* currViewSpec = viewSpec.deprecatedCharacters();
+    auto upconvertedCharacters = StringView(viewSpec).upconvertedCharacters();
+    const UChar* currViewSpec = upconvertedCharacters;
     const UChar* end = currViewSpec + viewSpec.length();
 
     if (currViewSpec >= end || !m_contextElement)
index 4429728..490ba9a 100644 (file)
@@ -24,6 +24,7 @@
 #include "QualifiedName.h"
 #include "SVGNames.h"
 #include <wtf/HashSet.h>
+#include <wtf/text/StringView.h>
 
 namespace WebCore {
 
@@ -59,7 +60,8 @@ public:
     {
         ASSERT(target);
         if (name == SVGNames::zoomAndPanAttr) {
-            const UChar* start = value.string().deprecatedCharacters();
+            auto upconvertedCharacters = StringView(value.string()).upconvertedCharacters();
+            const UChar* start = upconvertedCharacters;
             const UChar* end = start + value.length();
             SVGZoomAndPanType zoomAndPan = SVGZoomAndPanUnknown;
             parseZoomAndPan(start, end, zoomAndPan);
index e3de46d..b6eab75 100644 (file)
@@ -619,7 +619,7 @@ void XMLHttpRequest::send(Document* document, ExceptionCode& ec)
 
         // FIXME: this should use value of document.inputEncoding to determine the encoding to use.
         TextEncoding encoding = UTF8Encoding();
-        m_requestEntityBody = FormData::create(encoding.encode(body.deprecatedCharacters(), body.length(), EntitiesForUnencodables));
+        m_requestEntityBody = FormData::create(encoding.encode(body, EntitiesForUnencodables));
         if (m_upload)
             m_requestEntityBody->setAlwaysStream(true);
     }
@@ -646,7 +646,7 @@ void XMLHttpRequest::send(const String& body, ExceptionCode& ec)
             m_requestHeaders.set("Content-Type", contentType);
         }
 
-        m_requestEntityBody = FormData::create(UTF8Encoding().encode(body.deprecatedCharacters(), body.length(), EntitiesForUnencodables));
+        m_requestEntityBody = FormData::create(UTF8Encoding().encode(body, EntitiesForUnencodables));
         if (m_upload)
             m_requestEntityBody->setAlwaysStream(true);
     }
index 1192bf0..7a17fbd 100644 (file)
@@ -33,7 +33,6 @@
 #include "XMLDocumentParserScope.h"
 #include "XSLImportRule.h"
 #include "XSLTProcessor.h"
-
 #include <libxml/uri.h>
 #include <libxslt/xsltutils.h>
 
@@ -148,7 +147,8 @@ bool XSLStyleSheet::parseString(const String& string)
 
     XMLDocumentParserScope scope(cachedResourceLoader(), XSLTProcessor::genericErrorFunc, XSLTProcessor::parseErrorFunc, console);
 
-    const char* buffer = reinterpret_cast<const char*>(string.deprecatedCharacters());
+    auto upconvertedCharacters = StringView(string).upconvertedCharacters();
+    const char* buffer = reinterpret_cast<const char*>(upconvertedCharacters.get());
     int size = string.length() * sizeof(UChar);
 
     xmlParserCtxtPtr ctxt = xmlCreateMemoryParserCtxt(buffer, size);