Skip to content
  • darin@apple.com's avatar
    Change most call sites to call ICU directly instead of through WTF::Unicode · 2eb5f4de
    darin@apple.com authored
    https://bugs.webkit.org/show_bug.cgi?id=122635
    
    Reviewed by Alexey Proskuryakov.
    
    Source/JavaScriptCore:
    
    * parser/Lexer.cpp:
    (JSC::isNonLatin1IdentStart): Take a UChar since that's what the only caller wants to pass.
    Use U_GET_GC_MASK instead of WTF::Unicode::category.
    (JSC::isNonLatin1IdentPart): Ditto.
    
    * parser/Lexer.h:
    (JSC::Lexer::isWhiteSpace): Use u_charType instead of WTF::Unicode::isSeparatorSpace.
    
    * runtime/JSFunction.cpp: Removed "using namespace" for WTF::Unicode, this will no longer
    compile since this doesn't include anything that defines that namespace.
    
    * runtime/JSGlobalObjectFunctions.cpp:
    (JSC::isStrWhiteSpace): Use u_charType instead of WTF::Unicode::isSeparatorSpace.
    
    * yarr/YarrInterpreter.cpp:
    (JSC::Yarr::ByteCompiler::atomPatternCharacter): Use u_tolower and u_toupper instead of
    Unicode::toLower and Unicode::toUpper. Also added some assertions since this code assumes
    it can convert any UChar to lowercase or uppercase in another UChar, with no risk of needing
    a UChar32 for the result. I guess that's probably true, but it would be good to know in a
    debug build if not.
    
    Source/WebCore:
    
    * Modules/indexeddb/IDBKeyPath.cpp:
    (isIdentifierStartCharacter): Use U_GET_GC_MASK instead of WTF::Unicode::category.
    (isIdentifierCharacter): Ditto.
    
    * css/CSSParser.cpp:
    (WebCore::makeLower): Use u_tolower instead of WTF::Unicode::toLower.
    Also assert the character fits in a UChar.
    
    * dom/Document.cpp:
    (WebCore::isValidNameStart): Use U_GET_GC_MASK instead of WTF::Unicode::category,
    and u_getIntPropertyValue instead of WTF::Unicode::decompositionType.
    (WebCore::isValidNamePart): Ditto.
    (WebCore::canonicalizedTitle): Ditto.
    
    * editing/Editor.cpp:
    (WebCore::Editor::insertTextWithoutSendingTextEvent): Use u_isPunct instead of
    WTF::Unicode::isPunct.
    
    * editing/TextIterator.cpp:
    (WebCore::SearchBuffer::append): Use u_strFoldCase instead of WTF::Unicode::foldCase.
    
    * html/HTMLElement.cpp:
    (WebCore::HTMLElement::directionality): Use UCharDirection instead of
    WTF::Unicode::Direction.
    
    * html/HTMLSelectElement.cpp:
    (WebCore::HTMLSelectElement::defaultEventHandler): Use u_isprint instead of
    WTF::Unicode::isPrintableChar.
    
    * html/TypeAhead.cpp:
    (WebCore::stripLeadingWhiteSpace): Use u_charDirection instead of
    WTF::Unicode::direction.
    
    * html/track/TextTrackCue.cpp:
    (WebCore::isCueParagraphSeparator): Use u_charType instead of
    WTF::Unicode::category.
    (WebCore::TextTrackCue::determineTextDirection): Use u_charDirection instead of
    WTF::Unicode::direction.
    
    * page/ContextMenuController.cpp:
    (WebCore::selectionContainsPossibleWord): Use U_GET_GC_MASK instead of
    WTF::Unicode::category.
    * platform/graphics/Font.cpp:
    (WebCore::Font::canReceiveTextEmphasis): Ditto.
    
    * platform/graphics/FontGlyphs.cpp:
    (WebCore::FontGlyphs::glyphDataAndPageForCharacter): Use u_toupper instead of
    WTF::Unicode::toUpper. Use u_charMirror instead of WTF::Unicode::mirroredChar.
    
    * platform/graphics/GraphicsContext.cpp:
    (WebCore::TextRunIterator::direction): Use u_charDirection instead of
    WTF::Unicode::direction.
    
    * platform/graphics/SVGGlyph.cpp:
    (WebCore::charactersWithArabicForm): Use ublock_getCode instead of
    WTF::Unicode::isArabicChar.
    
    * platform/graphics/SurrogatePairAwareTextIterator.cpp:
    (WebCore::SurrogatePairAwareTextIterator::normalizeVoicingMarks): Use
    u_getCombiningClass instead of WTF::Unicode::combiningClass.
    
    * platform/graphics/WidthIterator.cpp:
    (WebCore::WidthIterator::advanceInternal): Use u_toupper instead of
    WTF::Unicode::toUpper.
    
    * platform/graphics/mac/ComplexTextController.cpp:
    (WebCore::ComplexTextController::collectComplexTextRuns): Added some
    assertions about the user of u_toupper and tweaked coding style a bit.
    
    * platform/text/BidiContext.cpp:
    (WebCore::BidiContext::createUncached): Use UCharDirection instead of
    WTF::Unicode::Direction.
    (WebCore::BidiContext::create): Ditto.
    (WebCore::copyContextAndRebaselineLevel): Ditto.
    * platform/text/BidiContext.h:
    (WebCore::BidiContext::dir): Ditto.
    (WebCore::BidiContext::BidiContext): Ditto.
    * platform/text/BidiResolver.h:
    (WebCore::BidiStatus::BidiStatus): Ditto.
    (WebCore::BidiEmbedding::BidiEmbedding): Ditto.
    (WebCore::BidiEmbedding::direction): Ditto.
    (WebCore::BidiCharacterRun::BidiCharacterRun): Ditto.
    (WebCore::BidiResolver::BidiResolver): Ditto.
    (WebCore::BidiResolver::setLastDir): Ditto.
    (WebCore::BidiResolver::setLastStrongDir): Ditto.
    (WebCore::BidiResolver::setEorDir): Ditto.
    (WebCore::BidiResolver::dir): Ditto.
    (WebCore::BidiResolver::setDir): Ditto.
    (WebCore::BidiResolver::appendRun): Ditto.
    (WebCore::BidiResolver::embed): Ditto.
    (WebCore::BidiResolver::checkDirectionInLowerRaiseEmbeddingLevel): Ditto.
    (WebCore::BidiResolver::lowerExplicitEmbeddingLevel): Ditto.
    (WebCore::BidiResolver::raiseExplicitEmbeddingLevel): Ditto.
    (WebCore::BidiResolver::commitExplicitEmbedding): Ditto.
    (WebCore::BidiResolver::updateStatusLastFromCurrentDirection): Ditto.
    (WebCore::BidiResolver::createBidiRunsForLine): Ditto.
    
    * platform/text/SegmentedString.h:
    (WebCore::SegmentedString::advanceAndASSERTIgnoringCase): Use u_foldCase
    instead of WTF::Unicode::foldCase.
    
    * platform/text/TextBoundaries.cpp:
    (WebCore::findNextWordFromIndex): Use u_isalnum instead of
    WTF::Unicode::isAlphanumeric.
    
    * platform/text/TextBoundaries.h:
    (WebCore::requiresContextForWordBoundary): Use u_getIntPropertyValue directly
    instead of WTF::Unicode::requiresComplexContextForWordBreaking.
    
    * platform/text/mac/TextBoundaries.mm: Removed explicit use of WTF::Unicode,
    which was unneeded and also will no longer compile.
    
    * rendering/BidiRun.h:
    (WebCore::BidiRun::BidiRun): Use UCharDirection instead of WTF::Unicode::Direction.
    * rendering/InlineFlowBox.h: Ditto.
    * rendering/InlineIterator.h:
    (WebCore::embedCharFromDirection): Ditto.
    (WebCore::notifyObserverWillExitObject): Ditto.
    (WebCore::InlineIterator::direction): Ditto.
    (WebCore::IsolateTracker::embed): Ditto.
    (WebCore::InlineBidiResolver::appendRun): Ditto.
    
    * rendering/RenderBlock.cpp:
    (WebCore::isPunctuationForFirstLetter): Use U_GET_GC_MASK instead of
    WTF::Unicode::category.
    
    * rendering/RenderBlockLineLayout.cpp:
    (WebCore::determineDirectionality): Use u_charDirection instead of
    WTF::Unicode::direction.
    (WebCore::RenderBlockFlow::handleTrailingSpaces): Ditto.
    (WebCore::statusWithDirection): Ditto.
    (WebCore::LineBreaker::nextSegmentBreak): Use U_GET_GC_MASK instead of
    WTF::Unicode::category.
    
    * rendering/RenderListMarker.cpp:
    (WebCore::RenderListMarker::paint): Use u_charDirection instead of
    WTF::Unicode::direction.
    
    * rendering/RenderMenuList.cpp:
    (WebCore::RenderMenuList::adjustInnerStyle): Use UCharDirection instead of
    WTF::Unicode::Direction.
    
    * rendering/RenderText.cpp:
    (WebCore::makeCapitalized): Use u_totile instead of WTF::Unicode::toTitleCase.
    Also added a comment about the fact that we need to use u_strToTitle instead.
    
    * rendering/RootInlineBox.cpp:
    (WebCore::RootInlineBox::lineBreakBidiStatus): Use UCharDirection instead of
    WTF::Unicode::Direction.
    
    * svg/SVGFontData.cpp:
    (WebCore::SVGFontData::createStringWithMirroredCharacters): Use u_charMirror
    instead of WTF::Unicode::mirroredChar.
    
    * xml/XPathParser.cpp:
    (WebCore::XPath::charCat): Use U_GET_GC_MASK instead of WTF::Unicode::category.
    
    * platform/graphics/win/UniscribeController.cpp:
    (WebCore::UniscribeController::advance):
    * platform/win/PopupMenuWin.cpp:
    (WebCore::PopupMenuWin::paint):
    * platform/win/WebCoreTextRenderer.cpp:
    (WebCore::isOneLeftToRightRun):
    More of the same for Windows.
    
    Source/WTF:
    
    * wtf/text/StringHash.h:
    (WTF::CaseFoldingHash::foldCase): Use u_foldCase instead of WTF::Unicode::foldCase.
    (WTF::CaseFoldingHash::hash): Added an overload for a StringImpl& because why not.
    
    * wtf/text/StringImpl.cpp:
    (WTF::StringImpl::lower): Use u_tolower rather than WTF::Unicode::toLower. Also added
    an assertion to check that the lowercase version is also part of Latin-1. If this
    is not guaranteed it would be good to know in a debug build at least. Use u_strToLower
    rather than WTF::Unicode::toLower. Also removed #if USE(ICU_UNICODE) around the
    locale-specific version.
    (WTF::StringImpl::upper): Use u_toupper and u_strToUpper, as above.
    (WTF::StringImpl::foldCase): Use u_tolower and u_strFoldCase, as above.
    (WTF::equalIgnoringCase): Use u_foldCase instead of WTF::Unicode::foldCase.
    (WTF::StringImpl::defaultWritingDirection): Use u_charDirection and UCharDirection
    instead of WTF::Unicode::direction and WTF::Unicode::Direction.
    
    * wtf/text/StringImpl.h:
    (WTF::equalIgnoringCase): Use u_memcasecmp instead of WTF::Unicode::umemcasecmp.
    (WTF::isSpaceOrNewline): Use u_charDirection instead of WTF::Unicode::direction.
    
    * wtf/text/WTFString.h:
    (WTF::String::defaultWritingDirection): Use UCharDirection instead of WTF::Unicode::Direction.
    
    * wtf/unicode/icu/UnicodeIcu.h: Removed almost everything.
    
    * wtf/unicode/wchar/UnicodeWchar.cpp: Tried to do the right thing in this file, but
    I did not actually compile it. Also, the implementations here aren't really sufficient
    to make WebKit work broadly. There are many things that just aren't working with this
    implementation, such as parsing that uses u_charType to figure out which characters are valid.
    (unorm_normalize): Added.
    (u_charDirection): Added.
    (u_charMirror): Added.
    (u_charType): Added.
    (u_getCombiningClass): Added.
    (u_getIntPropertyValue): Added.
    (u_memcasecmp): Added.
    (convertWithFunction): Changed to work with ICU-style status code instead of error bool.
    (u_strFoldCase): Added.
    (u_strToLower): Added.
    (u_strToUpper): Added.
    * wtf/unicode/wchar/UnicodeWchar.h: Ditto. Later this file should just be named like the
    real ICU headers so the code can include it the same way it would ICU. But that will be
    in a future patch.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@157330 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    2eb5f4de