Reduce WTF::String operations that do unnecessary Unicode operations instead of ASCII
https://bugs.webkit.org/show_bug.cgi?id=179907

Reviewed by Sam Weinig.

Source/JavaScriptCore:

* inspector/agents/InspectorDebuggerAgent.cpp:
(Inspector::matches): Removed explicit TextCaseSensitive because RegularExpression now
defaults to that.

* runtime/StringPrototype.cpp:
(JSC::stringIncludesImpl): Use String::find since there is no overload of
String::contains that takes a start offset now that we removed the one that took a
caseSensitive boolean. We can add one later if we like, but this should do for now.

* yarr/RegularExpression.h: Moved the TextCaseSensitivity enumeration here from
the StringImpl.h header because it is only used here.

Source/WebCore:

* Modules/plugins/YouTubePluginReplacement.cpp:
(WebCore::hasCaseInsensitivePrefix): Deleted.
(WebCore::processAndCreateYouTubeURL): Use startsWithLettersIgnoringASCIICase.

* Modules/websockets/WebSocketHandshake.cpp:
(WebCore::WebSocketHandshake::readHTTPHeaders): Use isAllASCII.

* accessibility/atk/AccessibilityObjectAtk.cpp:
(WebCore::AccessibilityObject::getLengthForTextRange const): Use text().length().

* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::traverseToOffsetInRange): Use isHTMLSpace instead of
isSpaceOrNewline since the code is trying to skip collapsible HTML spaces, not
arbitrary Unicode whitespace.
* accessibility/AccessibilityList.cpp:
(WebCore::AccessibilityList::childHasPseudoVisibleListItemMarkers): Use
isAllSpecialCharacters<isHTMLSpace> for the same reason as above.

* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::isSearchField const): Use containsIgnoringASCIICase.

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::accessibilityObjectContainsText const): Use
new findPlainText function exported from TextIterator so this can share the
same search matching logic used to find text in webpages.
(WebCore::AccessibilityObject::selectText): Use capitalize and its return value
rather than makeCapitalize modifying a string in place.

* accessibility/AccessibilityRenderObject.cpp:
(WebCore::objectInclusionFromAltText): Use isAllSpecialCharacters<isHTMLSpace>
for the same reason as above.
(WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored const): Ditto.

* bindings/js/JSDOMConvertStrings.cpp:
(WebCore::stringToByteString): Use isAllLatin1.

* contentextensions/ContentExtensionParser.cpp:
(WebCore::ContentExtensions::containsOnlyASCIIWithNoUppercase): Use
StringView::codeUnits instead of String::at.

* contentextensions/ContentExtensionsBackend.cpp:
(WebCore::ContentExtensions::ContentExtensionsBackend::actionsForResourceLoad const):
Use isAllASCII.
* contentextensions/URLFilterParser.cpp:
(WebCore::ContentExtensions::URLFilterParser::addPattern): Ditto.

* css/CSSFontFaceSrcValue.cpp:
(WebCore::CSSFontFaceSrcValue::isSupportedFormat const): Use protocolIs and
endsWithIgnoringASCIICase.

* css/DOMCSSNamespace.cpp:
(WebCore::valueWithoutImportant): Use endsWithIgnoringASCIICase.

* css/parser/CSSPropertyParser.cpp:
(WebCore::parseGridTemplateAreasRow): Use isAllSpecialCharacters<isCSSSpace>,
for the preflight, which matches what the actual parsing code uses.

* dom/CharacterData.cpp:
(WebCore::CharacterData::containsOnlyWhitespace const): Deleted. Callers can
efficiently get at the data and do this kind of check on the data directly.
* dom/CharacterData.h: Updated for the above.

* dom/DataTransfer.cpp:
(WebCore::normalizeType): Use startsWith since the string is already converted
to ASCII lowercase.

* dom/Position.cpp:
(WebCore::Position::leadingWhitespacePosition const): Use isHTMLSpace since
since the code is trying to check for collapsible HTML spaces, not general
Unicode spaces. Other call sites of isSpaceOrNewline need to be checked for
this, but I did not fix them all at this time.
(WebCore::Position::trailingWhitespacePosition const): Ditto.

* editing/Editor.cpp:
(WebCore::Editor::editorUIUpdateTimerFired): Use noBreakSpace.

* editing/FrameSelection.cpp:
(WebCore::FrameSelection::debugRenderer const): Use text().length() instead
of textLength.
(WebCore::FrameSelection::selectionAtWordStart const): Use noBreakSpace.
(WebCore::FrameSelection::wordSelectionContainingCaretSelection): Ditto.
(WebCore::FrameSelection::actualSelectionAtSentenceStart const): Ditto.

* editing/TextIterator.cpp:
(WebCore::textNodeOffsetInFlow): Use text().length().
(WebCore::TextIterator::handleTextNode): Ditto.
(WebCore::collapsedSpaceLength): Updated since RenderText::text now returns
a reference rather than a pointer.
(WebCore::findPlainText): Added. Uses SearchBuffer to search for one string
within another. Exported so accessibility code can do this operation.
* editing/TextIterator.h: Updated for the above.

* editing/TypingCommand.cpp:
(WebCore::TypingCommand::markMisspellingsAfterTyping): Use noBreakSpace.

* editing/VisibleUnits.cpp:
(WebCore::findStartOfParagraph): Updated since RenderText::text now returns
a reference.
(WebCore::findEndOfParagraph): Ditto.

* editing/cocoa/HTMLConverter.mm:
(HTMLConverter::_processText): Use String::characterAt instead of String::at.
Use capitalize instead of makeCapitalized.

* editing/cocoa/WebContentReaderCocoa.mm:
(WebCore::stripMicrosoftPrefix): Use findIgnoringASCIICase.

* html/Autofill.cpp:
(WebCore::AutofillData::createFromHTMLFormControlElement): Use
startsWithLettersIgnoringASCIICase.

* html/BaseTextInputType.cpp:
(WebCore::BaseTextInputType::patternMismatch const): Removed explicit
TextCaseSensitive since it now is the default, and needed to touch this anyway
because the enumeration is now in a different namespace.

* html/EmailInputType.cpp:
(WebCore::isValidEmailAddress): Updated to use JSC::Yarr::TextCaseInsensitive.

* html/HTMLObjectElement.cpp:
(WebCore::HTMLObjectElement::hasFallbackContent const): Use
isAllSpecialCharacters<isHTMLSpace>.
(WebCore::HTMLObjectElement::shouldAllowQuickTimeClassIdQuirk): Use
startsWithLettersIgnoringASCIICase.
(WebCore::HTMLObjectElement::hasValidClassId): Use protocolIs.
(WebCore::preventsParentObjectFromExposure): Use isAllSpecialCharacters<isHTMLSpace>.

* html/parser/HTMLConstructionSite.cpp:
(WebCore::HTMLConstructionSite::setCompatibilityModeFromDoctype):
Use startsWithLettersIgnoringASCIICase.

* html/parser/HTMLMetaCharsetParser.cpp:
(WebCore::extractCharset): Use findIgnoringASCIICase.

* html/parser/XSSAuditor.cpp:
(WebCore::XSSAuditor::isContainedInRequest): Use containsIgnoringASCIICase.

* html/track/WebVTTParser.cpp:
(WebCore::WebVTTParser::hasRequiredFileIdentifier): Don't pass the length to
the String::startsWith function. There has never been a version of that function
that takes the length, there is no need to pass the length since the function
handles null-terminated strings like the one here, and in the past the length
has been getting converted to a boolean making the comparison be case sensitive.
Removing the argument entirely leaves it case sensitive.

* inspector/InspectorNodeFinder.cpp:
(WebCore::InspectorNodeFinder::matchesElement): Use startsWithIgnoringASCIICase
and endsWithIgnoringASCIICase.

* inspector/InspectorStyleSheet.cpp:
(WebCore::selectorsFromSource): Use JSC::Yarr::TextCaseSensitive.

* inspector/agents/InspectorDOMAgent.cpp:
(WebCore::containsOnlyHTMLWhitespace): Made this a non-member function
and reimplemented using isAllSpecialCharacters<isHTMLSpace>().
(WebCore::InspectorDOMAgent::innerFirstChild): Use containsOnlyHTMLWhitespace.
(WebCore::InspectorDOMAgent::innerNextSibling): Ditto.
(WebCore::InspectorDOMAgent::innerPreviousSibling): Ditto.
(WebCore::InspectorDOMAgent::innerChildNodeCount): Ditto.
(WebCore::InspectorDOMAgent::didInsertDOMNode): Ditto.
(WebCore::InspectorDOMAgent::didRemoveDOMNode): Ditto.
* inspector/agents/InspectorDOMAgent.h: Updated for above change.

* loader/appcache/ApplicationCacheStorage.cpp:
(WebCore::ApplicationCacheStorage::shouldStoreResourceAsFlatFile):
Use startsWithLettersIgnoringASCIICase.

* page/Base64Utilities.cpp:
(WebCore::Base64Utilities::btoa): Use isAllLatin1.

* page/Frame.cpp:
(WebCore::createRegExpForLabels): Removed TextCaseSensitive argument since
that is now the default and also used JSC::Yarr::TextCaseInsensitive.
(WebCore::matchLabelsAgainstString): More of the same.

* page/FrameView.cpp:
(WebCore::countRenderedCharactersInRenderObjectWithThreshold): Use
text().length().

* page/SecurityOrigin.cpp:
(WebCore::isFeedWithNestedProtocolInHTTPFamily): Use
startsWithLettersIgnoringASCIICase.

* page/UserContentURLPattern.cpp:
(WebCore::UserContentURLPattern::matchesHost const):
Use endsWithIgnoringASCIICase.
* page/csp/ContentSecurityPolicySource.cpp:
(WebCore::ContentSecurityPolicySource::hostMatches const): Ditto.

* page/csp/ContentSecurityPolicySourceList.cpp:
(WebCore::ContentSecurityPolicySourceList::parseNonceSource):
Use startsWithIgnoringASCIICase.

* page/ios/FrameIOS.mm:
(WebCore::Frame::wordsInCurrentParagraph const): Use noBreakSpace.

* platform/ContentType.cpp:
(WebCore::ContentType::parameter const): Use findIgnoringASCIICase.

* platform/MIMETypeRegistry.cpp:
(WebCore::MIMETypeRegistry::isSupportedFontMIMEType): Use
startsWithLettersIgnoringASCIICase.
(WebCore::MIMETypeRegistry::isSupportedJSONMIMEType): Use
mimeType.endsWithIgnoringASCIICase.
(WebCore::MIMETypeRegistry::isTextMIMEType): Use
startsWithLettersIgnoringASCIICase.
(WebCore::MIMETypeRegistry::isXMLMIMEType): Use endsWithIgnoringASCIICase.
(WebCore::MIMETypeRegistry::isJavaAppletMIMEType): Use
startsWithLettersIgnoringASCIICase.
(WebCore::MIMETypeRegistry::canShowMIMEType): Ditto.

* platform/URL.cpp:
(WebCore::isAllASCII): Renamed from containsOnlyASCII.
(WebCore::appendEncodedHostname): Use isAllASCII.

* platform/URLParser.cpp:
(WebCore::containsOnlyASCII): Deleted.
(WebCore::URLParser::domainToASCII): Use StringImpl::isAllASCII. Changed
to take StringImpl& to guarantee we won't keep doing null checks since
the caller already checks for null.
(WebCore::URLParser::parseHostAndPort): Pass StringImpl&.
* platform/URLParser.h: Updated for above.

* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::supportsType): Use endsWithIgnoringASCIICase
and startsWithLettersIgnoringASCIICase.

* platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm:
(WebCore::validKeySystemRE): Use JSC::Yarr::TextCaseInsensitive.

* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::FontCache::similarFont): Use containsIgnoringASCIICase for
the Geeza font special cases.

* platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
(WebCore::shouldRejectMIMEType): Use startsWithLettersIgnoringASCIICase.

* platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
(WebCore::GraphicsContext3D::getUnmangledInfoLog): Removed
TextCaseSensitive since it now is the default.

* platform/mac/PublicSuffixMac.mm:
(WebCore::topPrivatelyControlledDomain): Use isAllASCII.

* platform/mac/SSLKeyGeneratorMac.mm:
(WebCore::signedPublicKeyAndChallengeString): Use isAllASCII.

* platform/mac/StringUtilities.mm:
(WebCore::stringMatchesWildcardString): Use JSC::Yarr::TextCaseInsensitive.

* platform/mediastream/RealtimeMediaSourceCenter.cpp:
(WebCore::addStringToSHA1): Use isAllASCII.

* platform/network/CacheValidation.cpp:
(WebCore::parseCacheControlDirectives): Use containsIgnoringASCIICase.

* platform/network/HTTPParsers.cpp:
(WebCore::parseHTTPRefresh): Use findIgnoringASCIICase.
(WebCore::findCharsetInMediaType): Ditto.
(WebCore::parseRange): Use startsWithLettersIgnoringASCIICase.

* platform/network/curl/AuthenticationChallengeCurl.cpp:
(WebCore::AuthenticationChallenge::protectionSpaceFromHandle):
Use findIgnoringASCIICase.
* platform/network/curl/MultipartHandle.cpp:
(WebCore::MultipartHandle::extractBoundary): Ditto.
* platform/network/curl/ResourceHandleCurlDelegate.cpp:
(WebCore::ResourceHandleCurlDelegate::handleDataURL): Use
endsWithIgnoringASCIICase.
* platform/network/curl/ResourceResponseCurl.cpp:
(WebCore::ResourceResponse::isAppendableHeader): Use
startsWithLettersIgnoringASCIICase.
(WebCore::ResourceResponse::appendHTTPHeaderField): Ditto.

* platform/win/ClipboardUtilitiesWin.cpp:
(WebCore::extractMarkupFromCFHTML): Use findIgnoringASCIICase.
(WebCore::fragmentFromCFHTML): Ditto.

* rendering/BidiRun.cpp:
(WebCore::BidiRun::BidiRun): Use text().length().
* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::absolutePDFURL const): Use
endsWithIgnoringASCIICase.
* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::placeBoxRangeInInlineDirection): Use text().length().
* rendering/InlineIterator.h:
(WebCore::InlineIterator::fastIncrementInTextNode): Ditto.
(WebCore::InlineIterator::increment): Dtto.
* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::isLineBreak const): Updated since RenderText::text
now returns a StringImpl&.
(WebCore::InlineTextBox::selectionStartEnd const): Use text().length().
(WebCore::InlineTextBox::text const): Updated since RenderText::text
now returns a StringImpl&.
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::constructTextRun): Use text().length().
* rendering/RenderBlockFlow.cpp:
(WebCore::isVisibleRenderText): Use isAllSpecialCharacters<isHTMLSpace>().
(WebCore::RenderBlockFlow::computeInlinePreferredLogicalWidths const):
Use the new trimmedPreferredWidths that returns a structure instead of the
old one with lots of arguments. Also use text().length().
* rendering/RenderBlockLineLayout.cpp:
(WebCore::endsWithHTMLSpaces): Renamed and changed to use isHTMLSpace
instead of isASCIISpace.
(WebCore::reachedEndOfTextRenderer): Use endsWithHTMLSpaces.
(WebCore::RenderBlockFlow::computeInlineDirectionPositionsForSegment):
Updated for hcanges to RenderText.
(WebCore::RenderBlockFlow::handleTrailingSpaces): Ditto.
(WebCore::RenderBlockFlow::determineStartPosition): Ditto.

* rendering/RenderCombineText.cpp:
(WebCore::RenderCombineText::combineTextIfNeeded): Use
isAllSpecialCharacters<isHTMLSpace>.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::calculateClipRects const): Ditto.

* rendering/RenderListBox.cpp:
(WebCore::bolder): Added. Helper function.
(WebCore::RenderListBox::updateFromElement): Rewrote to
only compute the bolder font once rather than for every item.
(WebCore::RenderListBox::paintItemForeground): Updated for
change to applyTextTransform.

* rendering/RenderMenuList.cpp:
(WebCore::RenderMenuList::adjustInnerStyle): Updated for change
to RenderText::text.
(RenderMenuList::updateOptionsWidth): Updated for change to
applyTextTransform.
(RenderMenuList::itemText const): Ditto.

* rendering/RenderText.cpp:
(WebCore::capitalize): Renamed from makeCapitalized. Changed to
take and return a String instead of taking a String*.
(WebCore::RenderText::RenderText): Use isAllASCII. Also moved
initialization of most non-bitfield members to the class definition.
(WebCore::RenderText::positionForPoint): Use text().
(WebCore::RenderText::widthFromCache const): Ditto.
(WebCore::RenderText::hangablePunctuationStartWidth const): Ditto.
(WebCore::RenderText::hangablePunctuationEndWidth const): Ditto.
(WebCore::RenderText::isHangableStopOrComma): Ditto.
(WebCore::RenderText::firstCharacterIndexStrippingSpaces const): Ditto.
(WebCore::RenderText::lastCharacterIndexStrippingSpaces const): Ditto.
(WebCore::RenderText::trimmedPreferredWidths): Changed to return values
in a structure instead of taking lots of arguments.
(WebCore::RenderText::computePreferredLogicalWidths): Updated to use
the text() function.
(WebCore::isAllCollapsibleWhitespace): Added.
(WebCore::RenderText::isAllCollapsibleWhitespace const): Updated to
use a tighter loop.
(WebCore::isAllPossiblyCollapsibleWhitespace): Added.
(WebCore::RenderText::containsOnlyHTMLWhitespace const): Updated to
use a tighter loop. Renamed from containsOnlyWhitespace.
(WebCore::RenderText::setTextWithOffset): Updated to  use text().
(WebCore::isInlineFlowOrEmptyText): Rewrote to be easier to read.
(WebCore::RenderText::previousCharacter const): Got rid of unneeded
null check and simplified.
(WebCore::applyTextTransform): Changed to return a String rather
than modifying one that is passed in.
(WebCore::RenderText::setRenderedText): Updated use of applyTextTransform.
(WebCore::RenderText::secureText): More of the same.
(WebCore::RenderText::computeCanUseSimplifiedTextMeasuring const): Ditto.
(WebCore::RenderText::textWithoutConvertingBackslashToYenSymbol const): Ditto.
(WebCore::RenderText::width const): Ditto.
(WebCore::RenderText::collectSelectionRectsForLineBoxes): Ditto.
(WebCore::RenderText::previousOffset const): Ditto.
(WebCore::RenderText::previousOffsetForBackwardDeletion const): Ditto.
(WebCore::RenderText::nextOffset const): Ditto.
(WebCore::RenderText::computeCanUseSimpleFontCodePath const): Ditto.
(WebCore::RenderText::stringView const): Ditto.

* rendering/RenderText.h: Made some more members private and final.
Updated for above, including adding the Widths structure. Got rid of the
textLength function, which existed as a workaround before we could mark
a function like length final. Made the text function return a StringImpl&,
which is good since the m_text string is never null, and so callers end
up using StringImpl directly and saving null checks. Removed functions
that are not needed, including is8Bit, characters8, characters16,
uncheckedCharacterAt, operator[], and isAllASCII.

* rendering/RenderTextFragment.cpp:
(WebCore::RenderTextFragment::setText): Use text().length().
* rendering/RenderTextLineBoxes.cpp:
(WebCore::RenderTextLineBoxes::caretMaxOffset const): Ditto.
(WebCore::RenderTextLineBoxes::positionForPoint const): Ditto.
(WebCore::RenderTextLineBoxes::setSelectionState): Ditto.
(WebCore::RenderTextLineBoxes::absoluteQuads const): Ditto.
* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::canUseForFontAndText): Ditto.
* rendering/SimpleLineLayoutCoverage.cpp:
(WebCore::SimpleLineLayout::textLengthForSubtree): Ditto.
(WebCore::SimpleLineLayout::collectNonEmptyLeafRenderBlockFlows): Ditto.
* rendering/SimpleLineLayoutFlowContents.cpp:
(WebCore::SimpleLineLayout::initializeSegments): Ditto.
* rendering/SimpleLineLayoutFunctions.cpp:
(WebCore::SimpleLineLayout::textOffsetForPoint): Ditto.
* rendering/SimpleLineLayoutFunctions.h:
(WebCore::SimpleLineLayout::findCaretMaximumOffset): Ditto.
* rendering/line/BreakingContext.h:
(WebCore::shouldAddBorderPaddingMargin): Ditto.
(WebCore::shouldSkipWhitespaceAfterStartObject): Ditto.
(WebCore::iteratorIsBeyondEndOfRenderCombineText): Ditto.
(WebCore::textWidth): Ditto.
(WebCore::BreakingContext::handleText): Ditto.
(WebCore::BreakingContext::optimalLineBreakLocationForTrailingWord): Ditto.
* rendering/line/TrailingObjects.cpp:
(WebCore::TrailingObjects::updateWhitespaceCollapsingTransitionsForTrailingBoxes): Ditto.

* rendering/mathml/RenderMathMLFenced.cpp:
(WebCore::RenderMathMLFenced::updateFromElement): Removed stray use of "unsigned int".

* rendering/svg/RenderSVGInlineText.cpp:
(WebCore::RenderSVGInlineText::characterStartsNewTextChunk const): Use text().length().
(WebCore::RenderSVGInlineText::positionForPoint): Ditto.
* rendering/svg/SVGTextLayoutAttributesBuilder.cpp:
(WebCore::processRenderSVGInlineText): Ditto.
* rendering/svg/SVGTextLayoutEngine.cpp:
(WebCore::SVGTextLayoutEngine::currentLogicalCharacterAttributes): Ditto.
* rendering/svg/SVGTextQuery.cpp:
(WebCore::SVGTextQuery::modifyStartEndPositionsRespectingLigatures const): Ditto.

* style/RenderTreeUpdater.cpp:
(WebCore::RenderTreeUpdater::updateRenderTree): Use isAllSpecialCharacters<isHTMLSpace>.
(WebCore::RenderTreeUpdater::textRendererIsNeeded): Ditto.

* svg/SVGTests.cpp:
(WebCore::SVGTests::hasFeatureForLegacyBindings): Use startsWithLettersIgnoringASCIICase.
* xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::shouldAllowExternalLoad): Ditto.

Source/WebKit:

* NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::isMediaMIMEType): Use startsWithLettersIgnoringASCIICase.
* NetworkProcess/cache/NetworkCacheKey.cpp:
(WebKit::NetworkCache::hashString): Use isAllASCII..
* UIProcess/API/C/WKWebsitePolicies.cpp:
(WKWebsitePoliciesSetCustomHeaderFields): Use startsWithLettersIgnoringASCIICase..
* UIProcess/API/Cocoa/_WKWebsitePolicies.mm:
(-[_WKWebsitePolicies setCustomHeaderFields:]): Ditto.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::savePDFToFileInDownloadsFolder): Use endsWithIgnoringASCIICase.
* UIProcess/WebPreferences.cpp:
(WebKit::WebPreferences::WebPreferences): Initialize m_identifier explicitly. Somehow
changing the String default constructor to be "= default" led to a warning that we
otherwise did not get about not initializing m_identifier. Arguably a compiler bug,
but legitimately strange that the copy constructor does not copy m_identifier and so
nice to be explicit about it, I guess.
* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::savePDFToTemporaryFolderAndOpenWithNativeApplicationRaw): Use
endsWithIgnoringASCIICase.
(WebKit::WebPageProxy::openPDFFromTemporaryFolderWithNativeApplication): Ditto.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::createPlugin): Ditto.
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::platformEditorState const): Use isAllSpecialCharacters<isHTMLSpace>.

Source/WebKitLegacy/mac:

* History/BinaryPropertyList.cpp:
(BinaryPropertyListPlan::writeStringObject): Use isAllASCII.
(BinaryPropertyListSerializer::appendStringObject): Ditto.
* WebView/WebHTMLRepresentation.mm:
(regExpForLabels): Removed TextCaseSensitive since it is now the default.
(matchLabelsAgainstString): Use JSC::Yarr::TextCaseInsensitive.

Source/WebKitLegacy/win:

* Plugins/PluginDatabaseWin.cpp:
(WebCore::PluginDatabase::getPluginPathsInDirectories const): Use
startsWithLettersIgnoringASCIICase and endsWithIgnoringASCIICase.
* WebDownloadCFNet.cpp:
(WebDownload::initToResumeWithBundle): Use endsWithIgnoringASCIICase.

* WebView.cpp:
(WebView::markAllMatchesForText): Fix old code that was passing TextCaseSensitivity
to a function that actually takes FindOptions. By luck, TextCaseSensitive happens to
be 0, which is correct FindOptions for case sensitive matching, and TextCaseInsensitive
happens to be 1, which is correct FindOptions for case insensitive matching, so fixing
the code does not cause any change in behavior.

Source/WTF:

* wtf/text/ASCIIFastPath.h: Moved the using for charactersAreAllASCII here since
the function is defined here.

* wtf/text/AtomicString.h: Removed overloads of contains, find, startsWith, and
endsWith that take a boolean indicating whether they should be "case sensitive".
When false, this was doing Unicode case folding, and no callers needed that.
Also tweaked formatting and argument names.

* wtf/text/IntegerToStringConversion.h: Added an include of LChar.h since this file
uses that. Also tweaked formatting a bit.

* wtf/text/StringImpl.cpp:
(WTF::StringImpl::containsOnlyWhitespace): Deleted. Despite its name sounding like
it used the full Unicode whitespace definition, this actually checked isASCIISpace.
Callers now all use isAllSpecialCharacters instead with the whitespace definition
that is appropriate to each call site.
(WTF::latin1CaseFoldTable): Deleted.
(WTF::equalCompatibilityCaseless): Deleted.
(WTF::StringImpl::findIgnoringCase): Deleted.
(WTF::findIgnoringCaseInner): Deleted.
(WTF::reverseFindIgnoringCaseInner): Deleted.
(WTF::StringImpl::reverseFindIgnoringCase): Deleted.
(WTF::equalInner): Removed boolean caseSensitive argument.
(WTF::StringImpl::startsWith): Ditto.
(WTF::StringImpl::endsWith): Ditto.

* wtf/text/StringImpl.h: Moved TextCaseSensitivity out into a different header.
Moved ASCIIFastPath.h include here from WTFString.h. Moved isAllSpecialCharacters
free function here from WTFString.h. Moved lots of function bodies out of class
definitions to make the class definitions easier to read. Sorted things a bit.
Tweaked formatting. Marked constructor that takes one argument explicit. Added
an isEmpty function like the one in String. Renamed copyChars to copyCharacters.
Added isAllASCII, isAllLatin1 and isAllSpecialCharacters functions. Removed
boolean caseSensitive arguments from various functions. Removed findIgnoringCase
and reverseFindIgnoringCase. Added a FIXME to codePointCompare about the way it
treats null and empty strings as equal. Changed length argument in remove to
unsigned to match other lengths.

* wtf/text/WTFString.cpp:
(WTF::String::removeInternal): Changed length argument to be unsigned.
(WTF::createWithFormatAndArguments): Use emptyString.
(WTF::String::isSafeToSendToAnotherThread const): Rewrote to be easier to read.

* wtf/text/WTFString.h: Moved ASCIIFastPath.h to StringImpl.h. Moved lots of
function bodies out of class definitions to make the class definitions easier
to read, made others one-liners. Removed the String::at function but kept the
String::characterAt function; the two were identical. Removed boolean
caseSensitive arguments from various functions. Removed findIgnoringCase and
reverseFindIgnoringCase. Renamed containsOnlyASCII to isAllASCII and
containsOnlyLatin1 to isAllLatin1 to match the naming of isAllSpecialCharacters.
Moved the inline implementations of functions that are defined above further
down, after things like the ASCIILiteral class and various functions.

* wtf/text/icu/UTextProviderLatin1.cpp: Updated name of copyChars.

Tools:

* DumpRenderTree/mac/DumpRenderTree.mm:
(changeWindowScaleIfNeeded): Use containsIgnoringASCIICase.
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::urlContains const): Ditto.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@225117 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/rendering/RenderBlockFlow.cpp b/Source/WebCore/rendering/RenderBlockFlow.cpp
index 79757e7..b26d672 100644
--- a/Source/WebCore/rendering/RenderBlockFlow.cpp
+++ b/Source/WebCore/rendering/RenderBlockFlow.cpp
@@ -30,6 +30,7 @@
 #include "FrameSelection.h"
 #include "HTMLElement.h"
 #include "HTMLInputElement.h"
+#include "HTMLParserIdioms.h"
 #include "HTMLTextAreaElement.h"
 #include "HitTestLocation.h"
 #include "InlineTextBox.h"
@@ -3671,13 +3672,14 @@
 }
 
 #if ENABLE(TEXT_AUTOSIZING)
+
 static inline bool isVisibleRenderText(const RenderObject& renderer)
 {
     if (!is<RenderText>(renderer))
         return false;
 
     auto& renderText = downcast<RenderText>(renderer);
-    return !renderText.linesBoundingBox().isEmpty() && !renderText.text()->containsOnlyWhitespace();
+    return !renderText.linesBoundingBox().isEmpty() && !renderText.text().isAllSpecialCharacters<isHTMLSpace>();
 }
 
 static inline bool resizeTextPermitted(const RenderObject& renderer)
@@ -3787,6 +3789,7 @@
         descendant = RenderObjectTraversal::nextSkippingChildren(text, this);
     }
 }
+
 #endif // ENABLE(TEXT_AUTOSIZING)
 
 void RenderBlockFlow::layoutExcludedChildren(bool relayoutChildren)
@@ -4264,18 +4267,15 @@
                 // of the string. If those are going to be stripped out,
                 // then they shouldn't be considered in the breakable char
                 // check.
-                bool hasBreakableChar, hasBreak;
-                float beginMin, endMin;
-                bool beginWS, endWS;
-                float beginMax, endMax;
                 bool strippingBeginWS = stripFrontSpaces;
-                renderText.trimmedPrefWidths(inlineMax, beginMin, beginWS, endMin, endWS,
-                                     hasBreakableChar, hasBreak, beginMax, endMax,
-                                     childMin, childMax, stripFrontSpaces);
+                auto widths = renderText.trimmedPreferredWidths(inlineMax, stripFrontSpaces);
+
+                childMin = widths.min;
+                childMax = widths.max;
 
                 // This text object will not be rendered, but it may still provide a breaking opportunity.
-                if (!hasBreak && !childMax) {
-                    if (autoWrap && (beginWS || endWS)) {
+                if (!widths.hasBreak && !childMax) {
+                    if (autoWrap && (widths.beginWS || widths.endWS)) {
                         minLogicalWidth = preferredWidth(minLogicalWidth, inlineMin);
                         inlineMin = 0;
                     }
@@ -4294,14 +4294,14 @@
                 if (!addedTextIndent || hasRemainingNegativeTextIndent) {
                     ti = textIndent.ceilToFloat();
                     childMin += ti;
-                    beginMin += ti;
+                    widths.beginMin += ti;
 
                     // It the text indent negative and larger than the child minimum, we re-use the remainder
                     // in future minimum calculations, but using the negative value again on the maximum
                     // will lead to under-counting the max pref width.
                     if (!addedTextIndent) {
                         childMax += ti;
-                        beginMax += ti;
+                        widths.beginMax += ti;
                         addedTextIndent = true;
                     }
 
@@ -4316,48 +4316,48 @@
                     unsigned startIndex = strippingBeginWS ? renderText.firstCharacterIndexStrippingSpaces() : 0;
                     float hangStartWidth = renderText.hangablePunctuationStartWidth(startIndex);
                     childMin -= hangStartWidth;
-                    beginMin -= hangStartWidth;
+                    widths.beginMin -= hangStartWidth;
                     childMax -= hangStartWidth;
-                    beginMax -= hangStartWidth;
+                    widths.beginMax -= hangStartWidth;
                     addedStartPunctuationHang = true;
                 }
                 
                 // If we have no breakable characters at all,
                 // then this is the easy case. We add ourselves to the current
                 // min and max and continue.
-                if (!hasBreakableChar)
+                if (!widths.hasBreakableChar)
                     inlineMin += childMin;
                 else {
                     // We have a breakable character. Now we need to know if
                     // we start and end with whitespace.
-                    if (beginWS) {
+                    if (widths.beginWS) {
                         // End the current line.
                         minLogicalWidth = preferredWidth(minLogicalWidth, inlineMin);
                     } else {
-                        inlineMin += beginMin;
+                        inlineMin += widths.beginMin;
                         minLogicalWidth = preferredWidth(minLogicalWidth, inlineMin);
                         childMin -= ti;
                     }
 
                     inlineMin = childMin;
 
-                    if (endWS) {
+                    if (widths.endWS) {
                         // We end in whitespace, which means we can end our current line.
                         minLogicalWidth = preferredWidth(minLogicalWidth, inlineMin);
                         inlineMin = 0;
                         shouldBreakLineAfterText = false;
                     } else {
                         minLogicalWidth = preferredWidth(minLogicalWidth, inlineMin);
-                        inlineMin = endMin;
+                        inlineMin = widths.endMin;
                         shouldBreakLineAfterText = true;
                     }
                 }
 
-                if (hasBreak) {
-                    inlineMax += beginMax;
+                if (widths.hasBreak) {
+                    inlineMax += widths.beginMax;
                     maxLogicalWidth = preferredWidth(maxLogicalWidth, inlineMax);
                     maxLogicalWidth = preferredWidth(maxLogicalWidth, childMax);
-                    inlineMax = endMax;
+                    inlineMax = widths.endMax;
                     addedTextIndent = true;
                     addedStartPunctuationHang = true;
                 } else
@@ -4388,8 +4388,8 @@
     if (styleToUse.collapseWhiteSpace())
         stripTrailingSpace(inlineMax, inlineMin, trailingSpaceChild);
     
-    if (canHangPunctuationAtEnd && lastText && lastText->textLength() > 0) {
-        unsigned endIndex = trailingSpaceChild == lastText ? lastText->lastCharacterIndexStrippingSpaces() : lastText->textLength() - 1;
+    if (canHangPunctuationAtEnd && lastText && lastText->text().length() > 0) {
+        unsigned endIndex = trailingSpaceChild == lastText ? lastText->lastCharacterIndexStrippingSpaces() : lastText->text().length() - 1;
         float endHangWidth = lastText->hangablePunctuationEndWidth(endIndex);
         inlineMin -= endHangWidth;
         inlineMax -= endHangWidth;