Remove String::deprecatedCharacters
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 22 Mar 2014 18:52:22 +0000 (18:52 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 22 Mar 2014 18:52:22 +0000 (18:52 +0000)
commit1081156d844f9db88af52b1311464c3e3ce43153
tree3d54a33edc6e788b7d94fb667259e71997052a72
parentf6a998d15ca144f92519c7dac2d8026d3b54e789
Remove String::deprecatedCharacters
https://bugs.webkit.org/show_bug.cgi?id=126854

Reviewed by Sam Weinig.

Source/WebCore:

* bindings/scripts/StaticString.pm:
(GenerateStrings): Remove the code to generate the null m_copyData16 pointer.

* editing/TextIterator.cpp:
(WebCore::SearchBuffer::prependContext): Changed to use the new append function in
StringView.h and removed the one defined locally here.

* editing/VisibleUnits.cpp:
(WebCore::wordBreakIteratorForMinOffsetBoundary): Use the new append function
in StringView.h instead of using deprecatedCharacters.
(WebCore::wordBreakIteratorForMaxOffsetBoundary): Ditto.
Removed an append function defined locally here and use the one in StringView.h.

* editing/htmlediting.cpp:
(WebCore::stringWithRebalancedWhitespace): Use StringView::getCharactersWithUpconvert.

* html/parser/HTMLToken.h:
(WebCore::HTMLToken::appendToAttributeValue): Changed to take a StringView instead
of a const String&.

* loader/appcache/ManifestParser.cpp:
(WebCore::parseManifest): Use StringView and StringView::upconvertedCharacters.

* page/EventSource.cpp:
(WebCore::EventSource::didReceiveData): Use the new append overload from StringView.h.
Also added a comment about incorrect use of the decode function.

* page/ios/FrameIOS.mm:
(WebCore::Frame::interpretationsForCurrentRoot): Use the new StringView append function.
Also use simpler new-style for loops.

* platform/LinkHash.cpp:
(WebCore::visitedURLInline): Use the new append function and StringView::substring.
(WebCore::visitedLinkHash): Use upconvertedCharacters for the non-8-bit case.

* platform/URL.cpp:
(WebCore::findFirstOf): Chagned to take a StringView.
(WebCore::containsOnlyASCII): Added. Works on StringView. Could move to a WTF header in
the future if it's needed elsewhere.
(WebCore::protocolIs): Added. Works on StringView. Could put in URL.h if needed elsewhere,
or consider replacing the one that takes const String& with just this one.
(WebCore::appendEncodedHostname): Changed to take a StringView and use
StringView::upconvertedCharacters.
(WebCore::findHostnamesInMailToURL): Changed to take a StringView.
(WebCore::findHostnameInHierarchicalURL): Ditto.
(WebCore::encodeHostnames): Ditto.
(WebCore::encodeRelativeString): Ditto.

* platform/graphics/StringTruncator.cpp:
(WebCore::StringTruncator::width): Use StringView::upconvertedCharacters.

* platform/graphics/harfbuzz/HarfBuzzShaper.cpp:
(WebCore::HarfBuzzShaper::setFontFeatures): Use indexing directly on the string instead
of on a UChar*.
(WebCore::HarfBuzzShaper::shapeHarfBuzzRuns): Use StringView::upconvertedCharacters.

* platform/text/TextCodecICU.cpp:
(WebCore::TextCodecICU::encode): Use a Vector<UChar> rather than a String to copy and
replace the backslashes with yen signs. Also optimize case where there are no backslashes.

* rendering/RenderListMarker.cpp:
(WebCore::RenderListMarker::paint): Use TextRun::setText(StringView).

* rendering/RenderText.cpp:
(WebCore::maxWordFragmentWidth): Pass a String to RenderBlock::constructTextRun instead of
calling StringBuilder::deprecatedCharacters.

* rendering/RenderText.h: Removed deprecatedCharacters function.

* rendering/line/BreakingContextInlineHeaders.h: Added now-needed header include.

* rendering/svg/SVGInlineTextBox.cpp:
(WebCore::SVGInlineTextBox::constructTextRun): Use StringView version of TextRun constructor.

* rendering/svg/SVGTextMetrics.cpp:
(WebCore::SVGTextMetrics::SVGTextMetrics): Take references instead of pointers.
(WebCore::SVGTextMetrics::constructTextRun): Take references instead of pointers, and don't
take a character pointer any more. Instead, extract the text and use the StringView version of
the TextRun constructor.
(WebCore::SVGTextMetrics::measureCharacterRange): Take references instead of pointers and
update for above changes.
* rendering/svg/SVGTextMetrics.h: Updated for changes above. Also tweaked style a bit.

* rendering/svg/SVGTextMetricsBuilder.cpp:
(WebCore::SVGTextMetricsBuilder::advanceSimpleText): Updated for SVGTextMetrics changes.
(WebCore::SVGTextMetricsBuilder::advanceComplexText): Ditto.
(WebCore::SVGTextMetricsBuilder::initializeMeasurementWithTextRenderer): Ditto.
(WebCore::SVGTextMetricsBuilder::measureTextRenderer): Change code to store a character
for lastCharacter rather than storing a pointer to a character. Stop using TextRun::data16.

* rendering/svg/SVGTextQuery.cpp:
(WebCore::SVGTextQuery::subStringLengthCallback): Updated for SVGTextMetrics changes.
(WebCore::SVGTextQuery::startPositionOfCharacterCallback): Ditto.
(WebCore::SVGTextQuery::endPositionOfCharacterCallback): Ditto.
(WebCore::calculateGlyphBoundaries): Ditto.

* xml/XPathFunctions.cpp:
(WebCore::XPath::atomicSubstring): Added.
(WebCore::XPath::FunId::evaluate): Tweaked a bit to use a new style for loop.
Use the atomicSubstring function to avoid making a temporary String just to make an AtomicString.
That function also uses characters8/16 rather than depreccatedCharacters.

* xml/XPathNodeSet.h: Added begin and end so this collection can be iterated with new style for loop.

* xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::XMLDocumentParser::doWrite): Use StringView::upconvertedCharacters.
(WebCore::parseAttributes): Ditto.

Source/WebKit:

* WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in:
Removed getData16SlowCase.

Source/WebKit/ios:

* Misc/WebNSStringDrawing.h: Added a FIXME about deleting this file; we can probably do it soon.
* Misc/WebNSStringDrawing.mm:
(+[NSString _web_setWordRoundingEnabled:]):
(+[NSString _web_wordRoundingEnabled]):
(+[NSString _web_setWordRoundingAllowed:]):
(+[NSString _web_wordRoundingAllowed]):
(+[NSString _web_setAscentRoundingEnabled:]):
(+[NSString _web_ascentRoundingEnabled]):
(-[NSString _web_drawAtPoint:withFont:]):
(-[NSString _web_sizeWithFont:]):
(-[NSString _web_sizeWithFont:forWidth:ellipsis:]):
(-[NSString _web_sizeWithFont:forWidth:ellipsis:letterSpacing:]):
(-[NSString _web_sizeWithFont:forWidth:ellipsis:letterSpacing:resultRange:]):
(-[NSString _web_drawAtPoint:forWidth:withFont:ellipsis:]):
(-[NSString _web_drawAtPoint:forWidth:withFont:ellipsis:letterSpacing:]):
(-[NSString _web_drawAtPoint:forWidth:withFont:ellipsis:letterSpacing:includeEmoji:]):
(-[NSString _web_drawInRect:withFont:ellipsis:alignment:lineSpacing:includeEmoji:truncationRect:measureOnly:]):
(-[NSString _web_drawInRect:withFont:ellipsis:alignment:lineSpacing:includeEmoji:truncationRect:]):
(-[NSString _web_drawInRect:withFont:ellipsis:alignment:lineSpacing:]):
(-[NSString _web_drawInRect:withFont:ellipsis:alignment:]):
(-[NSString _web_sizeInRect:withFont:ellipsis:lineSpacing:]):
(-[NSString _web_sizeInRect:withFont:ellipsis:]):
(-[NSString _web_stringForWidth:withFont:ellipsis:letterSpacing:includeEmoji:]):
(-[NSString _web_sizeForWidth:withAttributes:]):
(-[NSString _web_drawAtPoint:forWidth:withAttributes:]):
(-[NSString _web_sizeInRect:withAttributes:]):
(-[NSString _web_drawInRect:withAttributes:]):
Emptied out all these functions since callers aren't really using them any more.

Source/WebKit/win:

* WebKitStatistics.cpp:
(WebKitStatistics::comClassNameCounts): Update to not use Vector::append(String).

Source/WTF:

* wtf/text/StringBuilder.cpp:
(WTF::StringBuilder::reifyString): Removed code to update 16-bit shadow.

* wtf/text/StringBuilder.h: Removed deprecatedCharacters.
(WTF::StringBuilder::StringBuilder): Removed m_valid16BitShadowLength.
(WTF::StringBuilder::clear): Removed code to clear m_valid16BitShadowLength.
(WTF::StringBuilder::swap): Removed code to swap m_valid16BitShadowLength.

* wtf/text/StringImpl.cpp:
(WTF::StringImpl::~StringImpl): Removed code to free m_copyData16.
(WTF::StringImpl::upper): Use StringView::upconvertedCharacters for slow case.
(WTF::StringImpl::lower): Ditto.
(WTF::StringImpl::find): Use characters8/16 rather than deprecatedCharacters.
Added an 8-bit code path to one of the overloads. Might want to revisit later
to decide whether to use templates instead of copy/paste, or even use StringView
to cut down on duplicate code paths.
(WTF::StringImpl::findIgnoringCase): Ditto.
(WTF::StringImpl::sizeInBytes): Remove code to handle has16BitShadow case.
(WTF::equalIgnoringNullity): Added. To be called by the Vector template in the header.

* wtf/text/StringImpl.h: Removed deprecatedCharacters, has16BitShadow,
upconvertCharacters, getData16SlowCase, s_hashFlagHas16BitShadow, and m_copyData16.
(WTF::equalIgnoringNullity): Changed the template function into an inline that calls
a non-inline helper function. The non-inline function handles both 8-bit and 16-bit
strings.

* wtf/text/StringView.h:
(WTF::StringView::StringView): Added an overload so we can make one of these directly
from a StringImpl without first wrapping it in a string. Added an adapter so we can
use StringView as part of string concatenation. Added an append function so we can
append to a Vector<UChar>.

* wtf/text/WTFString.cpp:
(WTF::String::append): Use StringView::getCharactersWithUpconvert. Also changed
single-character append so it won't always turn an 8-bit string into a 16-bit one.
(WTF::String::insert): Removed one insert overload and changed the other to use
StringView::getCharactersWithUpconvert.
(WTF::String::truncate): Changed to use StringImpl::substring.
(WTF::String::percentage): Added characters8/16 paths instead of using
deprecatedCharacters.

* wtf/text/WTFString.h: Removed deprecatedCharacters, getCharactersWithUpconvert,
insert(UChar*, unsigned, unsigned), and the append overload for Vector<UChar>.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166120 268f45cc-cd09-0410-ab3c-d52691b4dbfc
41 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/text/StringBuilder.cpp
Source/WTF/wtf/text/StringBuilder.h
Source/WTF/wtf/text/StringImpl.cpp
Source/WTF/wtf/text/StringImpl.h
Source/WTF/wtf/text/StringView.h
Source/WTF/wtf/text/WTFString.cpp
Source/WTF/wtf/text/WTFString.h
Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/StaticString.pm
Source/WebCore/editing/TextIterator.cpp
Source/WebCore/editing/VisibleUnits.cpp
Source/WebCore/editing/htmlediting.cpp
Source/WebCore/html/parser/HTMLToken.h
Source/WebCore/loader/appcache/ManifestParser.cpp
Source/WebCore/page/EventSource.cpp
Source/WebCore/page/ios/FrameIOS.mm
Source/WebCore/platform/LinkHash.cpp
Source/WebCore/platform/URL.cpp
Source/WebCore/platform/graphics/StringTruncator.cpp
Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.cpp
Source/WebCore/platform/text/TextCodecICU.cpp
Source/WebCore/rendering/RenderListMarker.cpp
Source/WebCore/rendering/RenderText.cpp
Source/WebCore/rendering/RenderText.h
Source/WebCore/rendering/line/BreakingContextInlineHeaders.h
Source/WebCore/rendering/svg/SVGInlineTextBox.cpp
Source/WebCore/rendering/svg/SVGTextMetrics.cpp
Source/WebCore/rendering/svg/SVGTextMetrics.h
Source/WebCore/rendering/svg/SVGTextMetricsBuilder.cpp
Source/WebCore/rendering/svg/SVGTextQuery.cpp
Source/WebCore/xml/XPathFunctions.cpp
Source/WebCore/xml/XPathNodeSet.h
Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp
Source/WebKit/ChangeLog
Source/WebKit/WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in
Source/WebKit/ios/ChangeLog
Source/WebKit/ios/Misc/WebNSStringDrawing.h
Source/WebKit/ios/Misc/WebNSStringDrawing.mm
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebKitStatistics.cpp