Changeset 18712 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Jan 9, 2007, 6:54:26 AM (18 years ago)
Author:
darin
Message:

JavaScriptCore:

Reviewed by Maciej.

  • wtf/unicode/icu/UnicodeIcu.h: Change parameter and return types to UChar32 and UChar. Removed unneeded type casts and added some const to functions that lacked it. Removed WTF::Unicode::memcmp. (WTF::Unicode::umemcasecmp): Renamed from strcasecmp since this doesn't work on 0-terminated strings as the str functions do.
  • wtf/unicode/qt4/UnicodeQt4.h: Ditto.
  • got rid of namespace prefixes from most uses of WTF::Unicode
  • kjs/function.cpp: (KJS::isStrWhiteSpace): (KJS::escapeStringForPrettyPrinting):
  • kjs/lexer.cpp: (KJS::Lexer::isWhiteSpace): (KJS::Lexer::isIdentStart): (KJS::Lexer::isIdentPart):
  • kjs/string_object.cpp: (KJS::StringProtoFunc::callAsFunction):

WebCore:

Reviewed by Maciej.

  • got rid of namespace prefixes from most uses of WTF::Unicode
  • updated for removal of WTF::Unicode::memcmp
  • updated for renaming of WTF::Unicode::strcasecmp to umemcasecmp.
  • unified constants for special Unicode characters in a new CharacterNames.h header
  • WebCore.xcodeproj/project.pbxproj:
  • css/cssparser.cpp: (WebCore::ParseString::lower):
  • dom/Document.cpp: (WebCore::isValidNameStart): (WebCore::isValidNamePart):
  • dom/Position.cpp: (WebCore::Position::leadingWhitespacePosition): (WebCore::Position::trailingWhitespacePosition):
  • editing/CompositeEditCommand.cpp: (WebCore::isWhitespace):
  • editing/HTMLInterchange.cpp:
  • editing/TextIterator.cpp: (WebCore::CircularSearchBuffer::CircularSearchBuffer): (WebCore::CircularSearchBuffer::append):
  • editing/htmlediting.cpp: (WebCore::stringWithRebalancedWhitespace): (WebCore::nonBreakingSpaceString):
  • editing/htmlediting.h:
  • html/HTMLFontElement.cpp: (WebCore::parseFontSizeNumber):
  • html/HTMLParser.cpp: (WebCore::HTMLParser::handleError):
  • html/HTMLSelectElement.cpp: (WebCore::stripLeadingWhiteSpace):
  • platform/Font.cpp: (WebCore::WidthIterator::advance): (WebCore::WidthIterator::normalizeVoicingMarks):
  • platform/GlyphMap.cpp: (WebCore::GlyphMap::locatePage):
  • platform/MimeTypeRegistry.h:
  • platform/StringHash.h:
  • platform/StringImpl.cpp: (WebCore::isSpace): (WebCore::StringImpl::append): (WebCore::StringImpl::insert): (WebCore::StringImpl::truncate): (WebCore::StringImpl::remove): (WebCore::parseLength): (WebCore::StringImpl::isLower): (WebCore::StringImpl::lower): (WebCore::StringImpl::upper): (WebCore::StringImpl::secure): (WebCore::StringImpl::foldCase): (WebCore::StringImpl::capitalize):t (WebCore::StringImpl::toInt): (WebCore::equalIgnoringCase): (WebCore::StringImpl::find):
  • platform/TextBoundaries.h:
  • platform/TextCodec.h:
  • platform/TextCodecLatin1.cpp:
  • platform/TextEncoding.h:
  • platform/TextEncodingRegistry.h:
  • platform/mac/PasteboardMac.mm: (WebCore::Pasteboard::writeSelection):
  • platform/mac/TextCodecMac.cpp: (WebCore::TextCodecMac::decode):
  • rendering/RenderBlock.cpp: (WebCore::RenderBlock::updateFirstLetter):
  • rendering/RenderListMarker.cpp: (WebCore::listMarkerText): (WebCore::RenderListMarker::paint):
  • rendering/RenderText.cpp: (WebCore::RenderText::widthFromCache): (WebCore::isSpaceAccordingToStyle): (WebCore::RenderText::setInternalString):
  • rendering/RenderTreeAsText.cpp: (WebCore::quoteAndEscapeNonPrintables): (WebCore::operator<<):
  • rendering/bidi.cpp: (WebCore::BidiState::BidiState): (WebCore::BidiContext::BidiContext): (WebCore::bidiNext): (WebCore::bidiFirst): (WebCore::BidiIterator::direction): (WebCore::appendRun): (WebCore::embed): (WebCore::RenderBlock::bidiReorderLine): (WebCore::RenderBlock::layoutInlineChildren): (WebCore::skipNonBreakingSpace): (WebCore::RenderBlock::findNextLineBreak):
  • rendering/break_lines.cpp: (WebCore::nextBreakablePosition):
  • rendering/break_lines.h:
  • xml/XPathParser.cpp: (WebCore::XPath::charCat):
Location:
trunk/JavaScriptCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r18658 r18712  
     12007-01-09  Darin Adler  <[email protected]>
     2
     3        Reviewed by Maciej.
     4
     5        - fix http://bugs.webkit.org/show_bug.cgi?id=12174
     6          improve Unicode use (less WTF::Unicode:: prefix, centralized character names)
     7
     8        * wtf/unicode/icu/UnicodeIcu.h: Change parameter and return types
     9        to UChar32 and UChar. Removed unneeded type casts and added some
     10        const to functions that lacked it. Removed WTF::Unicode::memcmp.
     11        (WTF::Unicode::umemcasecmp): Renamed from strcasecmp since this
     12        doesn't work on 0-terminated strings as the str functions do.
     13        * wtf/unicode/qt4/UnicodeQt4.h: Ditto.
     14
     15        - got rid of namespace prefixes from most uses of WTF::Unicode
     16
     17        * kjs/function.cpp:
     18        (KJS::isStrWhiteSpace):
     19        (KJS::escapeStringForPrettyPrinting):
     20        * kjs/lexer.cpp:
     21        (KJS::Lexer::isWhiteSpace):
     22        (KJS::Lexer::isIdentStart):
     23        (KJS::Lexer::isIdentPart):
     24        * kjs/string_object.cpp:
     25        (KJS::StringProtoFunc::callAsFunction):
     26
    1272007-01-07  David Kilzer  <[email protected]>
    228
  • trunk/JavaScriptCore/kjs/function.cpp

    r17507 r18712  
    4242
    4343#include <wtf/unicode/Unicode.h>
     44
     45using namespace WTF;
     46using namespace Unicode;
    4447
    4548namespace KJS {
     
    691694            return true;
    692695        default:
    693             return WTF::Unicode::isSeparatorSpace(c);
     696            return isSeparatorSpace(c);
    694697    }
    695698}
     
    966969            break;
    967970        default:
    968             if (c < 128 && WTF::Unicode::isPrintableChar(c))
     971            if (c < 128 && isPrintableChar(c))
    969972                escapedString.append(c);
    970973            else {
  • trunk/JavaScriptCore/kjs/lexer.cpp

    r17862 r18712  
    3232#include <wtf/unicode/Unicode.h>
    3333
    34 static bool isDecimalDigit(int);
     34using namespace WTF;
     35using namespace Unicode;
    3536
    3637// we can't specify the namespace in yacc's C output, so do it here
    3738using namespace KJS;
    38 
    39 static Lexer *currLexer = 0;
    4039
    4140#ifndef KDE_USE_FINAL
     
    5352  return Lexer::curr()->lex();
    5453}
     54
     55namespace KJS {
     56
     57static Lexer* currLexer = 0;
     58
     59static bool isDecimalDigit(int);
    5560
    5661Lexer::Lexer()
     
    566571bool Lexer::isWhiteSpace() const
    567572{
    568   return current == '\t' || current == 0x0b || current == 0x0c || WTF::Unicode::isSeparatorSpace(current);
     573  return current == '\t' || current == 0x0b || current == 0x0c || isSeparatorSpace(current);
    569574}
    570575
     
    582587bool Lexer::isIdentStart(int c)
    583588{
    584   return (WTF::Unicode::category(c) & (WTF::Unicode::Letter_Uppercase
    585         | WTF::Unicode::Letter_Lowercase
    586         | WTF::Unicode::Letter_Titlecase
    587         | WTF::Unicode::Letter_Modifier
    588         | WTF::Unicode::Letter_Other))
     589  return (category(c) & (Letter_Uppercase | Letter_Lowercase | Letter_Titlecase | Letter_Modifier | Letter_Other))
    589590    || c == '$' || c == '_';
    590591}
     
    592593bool Lexer::isIdentPart(int c)
    593594{
    594   return (WTF::Unicode::category(c) & (WTF::Unicode::Letter_Uppercase
    595         | WTF::Unicode::Letter_Lowercase
    596         | WTF::Unicode::Letter_Titlecase
    597         | WTF::Unicode::Letter_Modifier
    598         | WTF::Unicode::Letter_Other
    599         | WTF::Unicode::Mark_NonSpacing
    600         | WTF::Unicode::Mark_SpacingCombining
    601         | WTF::Unicode::Number_DecimalDigit
    602         | WTF::Unicode::Punctuation_Connector))
     595  return (category(c) & (Letter_Uppercase | Letter_Lowercase | Letter_Titlecase | Letter_Modifier | Letter_Other
     596        | Mark_NonSpacing | Mark_SpacingCombining | Number_DecimalDigit | Punctuation_Connector))
    603597    || c == '$' || c == '_';
    604598}
     
    912906  return string;
    913907}
     908
     909}
  • trunk/JavaScriptCore/kjs/string_object.cpp

    r18356 r18712  
    3838#endif
    3939
    40 using namespace KJS;
     40using namespace WTF;
     41
     42namespace KJS {
    4143
    4244// ------------------------------ StringInstance ----------------------------
     
    684686    uint16_t* destIfNeeded;
    685687
    686     int len = WTF::Unicode::toLower(dataPtr, u.size(), destIfNeeded);
     688    int len = Unicode::toLower(dataPtr, u.size(), destIfNeeded);
    687689    if (len >= 0)
    688690        result = jsString(UString(reinterpret_cast<UChar *>(destIfNeeded ? destIfNeeded : dataPtr), len));
     
    700702    uint16_t* destIfNeeded;
    701703
    702     int len = WTF::Unicode::toUpper(dataPtr, u.size(), destIfNeeded);
     704    int len = Unicode::toUpper(dataPtr, u.size(), destIfNeeded);
    703705    if (len >= 0)
    704706        result = jsString(UString(reinterpret_cast<UChar *>(destIfNeeded ? destIfNeeded : dataPtr), len));
     
    826828  return jsString(s);
    827829}
     830
     831}
  • trunk/JavaScriptCore/wtf/unicode/icu/UnicodeIcu.h

    r18247 r18712  
    44 *  Copyright (C) 2006 George Staikos <[email protected]>
    55 *  Copyright (C) 2006 Alexey Proskuryakov <[email protected]>
     6 *  Copyright (C) 2007 Apple Computer, Inc. All rights reserved.
    67 *
    78 *  This library is free software; you can redistribute it and/or
     
    118119    };
    119120
    120     inline uint32_t foldCase(uint32_t c)
     121    inline UChar32 foldCase(UChar32 c)
    121122    {
    122123      return u_foldCase(c, U_FOLD_CASE_DEFAULT);
    123124    }
    124125
    125     inline int foldCase(UChar* result, int resultLength, UChar* src, int srcLength, bool* error)
     126    inline int foldCase(UChar* result, int resultLength, const UChar* src, int srcLength, bool* error)
    126127    {
    127128      UErrorCode status = U_ZERO_ERROR;
    128       int32_t realLength = u_strFoldCase(result, resultLength, src, srcLength, U_FOLD_CASE_DEFAULT, &status);
     129      int realLength = u_strFoldCase(result, resultLength, src, srcLength, U_FOLD_CASE_DEFAULT, &status);
    129130      *error = !U_SUCCESS(status);
    130131      return realLength;
    131132    }
    132133
    133     inline int toLower(uint16_t* str, int strLength, uint16_t*& destIfNeeded)
     134    inline int toLower(UChar* str, int strLength, UChar*& destIfNeeded)
    134135    {
    135136      UErrorCode err = U_ZERO_ERROR;
     
    137138      destIfNeeded = 0;
    138139
    139       resultLength = u_strToLower(0, 0, reinterpret_cast< ::UChar*>(str), strLength, "", &err);
     140      resultLength = u_strToLower(0, 0, str, strLength, "", &err);
    140141
    141142      if (resultLength <= strLength) {
    142143        err = U_ZERO_ERROR;
    143         u_strToLower(reinterpret_cast< ::UChar*>(str), resultLength, reinterpret_cast< ::UChar*>(str), strLength, "", &err);
     144        u_strToLower(str, resultLength, str, strLength, "", &err);
    144145      } else {
    145146        err = U_ZERO_ERROR;
    146         destIfNeeded = (uint16_t*)malloc(resultLength * sizeof(uint16_t));
    147         u_strToLower(reinterpret_cast< ::UChar*>(destIfNeeded), resultLength, reinterpret_cast< ::UChar*>(str), strLength, "", &err);
     147        destIfNeeded = static_cast<UChar*>(malloc(resultLength * sizeof(UChar)));
     148        u_strToLower(destIfNeeded, resultLength, str, strLength, "", &err);
    148149      }
    149150
     
    151152    }
    152153
    153     inline int toLower(UChar* result, int resultLength, UChar* src, int srcLength, bool* error)
     154    inline int toLower(UChar* result, int resultLength, const UChar* src, int srcLength, bool* error)
    154155    {
    155156      UErrorCode status = U_ZERO_ERROR;
    156       int32_t realLength = u_strToLower(result, resultLength, src, srcLength, "", &status);
     157      int realLength = u_strToLower(result, resultLength, src, srcLength, "", &status);
    157158      *error = !!U_FAILURE(status);
    158159      return realLength;
    159160    }
    160161
    161     inline int32_t toLower(int32_t c)
     162    inline UChar32 toLower(UChar32 c)
    162163    {
    163164      return u_tolower(c);
    164165    }
    165166
    166     inline int32_t toUpper(int32_t c)
     167    inline UChar32 toUpper(UChar32 c)
    167168    {
    168169      return u_toupper(c);
    169170    }
    170171
    171     inline int toUpper(uint16_t* str, int strLength, uint16_t*& destIfNeeded)
     172    inline int toUpper(UChar* str, int strLength, UChar*& destIfNeeded)
    172173    {
    173174      UErrorCode err = U_ZERO_ERROR;
     
    175176      destIfNeeded = 0;
    176177
    177       resultLength = u_strToUpper(0, 0, reinterpret_cast< ::UChar*>(str), strLength, "", &err);
     178      resultLength = u_strToUpper(0, 0, str, strLength, "", &err);
    178179
    179180      if (resultLength <= strLength) {
    180181        err = U_ZERO_ERROR;
    181         u_strToUpper(reinterpret_cast< ::UChar*>(str), resultLength, reinterpret_cast< ::UChar*>(str), strLength, "", &err);
     182        u_strToUpper(str, resultLength, str, strLength, "", &err);
    182183      } else {
    183184        err = U_ZERO_ERROR;
    184         destIfNeeded = (uint16_t*)malloc(resultLength * sizeof(uint16_t));
    185         u_strToUpper(reinterpret_cast< ::UChar*>(destIfNeeded), resultLength, reinterpret_cast< ::UChar*>(str), strLength, "", &err);
     185        destIfNeeded = (UChar*)malloc(resultLength * sizeof(UChar));
     186        u_strToUpper(destIfNeeded, resultLength, str, strLength, "", &err);
    186187      }
    187188
     
    189190    }
    190191
    191     inline int toUpper(UChar* result, int resultLength, UChar* src, int srcLength, bool* error)
     192    inline int toUpper(UChar* result, int resultLength, const UChar* src, int srcLength, bool* error)
    192193    {
    193194      UErrorCode status = U_ZERO_ERROR;
    194       int32_t realLength = u_strToUpper(result, resultLength, src, srcLength, "", &status);
     195      int realLength = u_strToUpper(result, resultLength, src, srcLength, "", &status);
    195196      *error = !!U_FAILURE(status);
    196197      return realLength;
    197198    }
    198199
    199     inline int toTitleCase (uint32_t c)
     200    inline UChar32 toTitleCase(UChar32 c)
    200201    {
    201202      return u_totitle(c);
    202203    }
    203204
    204     inline bool isFormatChar(int32_t c)
     205    inline bool isFormatChar(UChar32 c)
    205206    {
    206207      return u_charType(c) == U_FORMAT_CHAR;
    207208    }
    208209
    209     inline bool isSeparatorSpace(int32_t c)
     210    inline bool isSeparatorSpace(UChar32 c)
    210211    {
    211212      return u_charType(c) == U_SPACE_SEPARATOR;
    212213    }
    213214
    214     inline bool isPrintableChar(int32_t c)
     215    inline bool isPrintableChar(UChar32 c)
    215216    {
    216217      return !!u_isprint(c);
    217218    }
    218219   
    219     inline bool isDigit(int32_t c)
     220    inline bool isDigit(UChar32 c)
    220221    {
    221222      return !!u_isdigit(c);
    222223    }
    223224
    224     inline bool isPunct(int32_t c)
     225    inline bool isPunct(UChar32 c)
    225226    {
    226227      return !!u_ispunct(c);
    227228    }
    228229
    229     inline int32_t mirroredChar(int32_t c)
     230    inline UChar32 mirroredChar(UChar32 c)
    230231    {
    231232      return u_charMirror(c);
    232233    }
    233234
    234     inline CharCategory category(int32_t c)
     235    inline CharCategory category(UChar32 c)
    235236    {
    236237      return static_cast<CharCategory>(U_GET_GC_MASK(c));
    237238    }
    238239
    239     inline Direction direction(int c) {
    240       return (Direction)u_charDirection(c);
    241     }
    242 
    243     inline bool isLower(int32_t c)
     240    inline Direction direction(UChar32 c)
     241    {
     242      return static_cast<Direction>(u_charDirection(c));
     243    }
     244
     245    inline bool isLower(UChar32 c)
    244246    {
    245247      return !!u_islower(c);
    246248    }
    247249
    248     inline bool isUpper(int32_t c)
     250    inline bool isUpper(UChar32 c)
    249251    {
    250252      return !!u_isUUppercase(c);
    251253      }
    252254
    253     inline int digitValue(int32_t c)
     255    inline int digitValue(UChar32 c)
    254256    {
    255257      return u_charDigitValue(c);
     
    266268    }
    267269
    268     inline int strcasecmp(const UChar *a, const UChar *b, int len)
     270    inline int umemcasecmp(const UChar* a, const UChar* b, int len)
    269271    {
    270272      return u_memcasecmp(a, b, len, U_FOLD_CASE_DEFAULT);
    271273    }
    272274
    273     inline void memset(UChar* dest, UChar ch, int32_t count)
    274     {
    275       u_memset(dest, ch, count);
    276     }
    277275  }
    278276}
  • trunk/JavaScriptCore/wtf/unicode/qt4/UnicodeQt4.h

    r18161 r18712  
    143143    };
    144144
    145     inline int toLower(uint16_t* str, int strLength, uint16_t*& destIfNeeded)
     145    inline int toLower(UChar* str, int strLength, UChar*& destIfNeeded)
    146146    {
    147147      destIfNeeded = 0;
     
    153153    }
    154154
    155     inline uint16_t toLower(uint16_t ch)
    156     {
    157       return QChar(ch).toLower().unicode();
    158     }
    159 
    160     inline int toLower(UChar* result, int resultLength, UChar* src, int srcLength,  bool* error)
     155    inline UChar32 toLower(UChar32 ch)
     156    {
     157      if (ch > 0xffff)
     158        return ch;
     159      return QChar((unsigned short)ch).toLower().unicode();
     160    }
     161
     162    inline int toLower(UChar* result, int resultLength, const UChar* src, int srcLength,  bool* error)
    161163    {
    162164      *error = false;
     
    169171    }
    170172
    171     inline int toUpper(uint16_t* str, int strLength, uint16_t*& destIfNeeded)
     173    inline int toUpper(UChar* str, int strLength, UChar*& destIfNeeded)
    172174    {
    173175      destIfNeeded = 0;
     
    179181    }
    180182
    181     inline uint16_t toUpper(uint16_t ch)
    182     {
    183       return QChar(ch).toUpper().unicode();
     183    inline UChar32 toUpper(UChar32 ch)
     184    {
     185      if (ch > 0xffff)
     186        return ch;
     187      return QChar((unsigned short)ch).toUpper().unicode();
    184188    }
    185189
     
    195199    }
    196200
    197     inline int toTitleCase (uint32_t c)
     201    inline int toTitleCase(UChar32 c)
    198202    {
    199203      if (c > 0xffff)
    200204        return c;
    201       return QChar(c).toUpper().unicode();
    202     }
    203 
    204     inline uint32_t foldCase(uint32_t c)
     205      return QChar((unsigned short)c).toUpper().unicode();
     206    }
     207
     208    inline UChar32 foldCase(UChar32 c)
    205209    {
    206210      if (c > 0xffff)
    207211        return c;
    208       return QChar(c).toLower().unicode();
     212      return QChar((unsigned short)c).toLower().unicode();
    209213    }
    210214
     
    214218    }
    215219
    216     inline bool isFormatChar(int32_t c)
     220    inline bool isFormatChar(UChar32 c)
    217221    {
    218222      return (c & 0xffff0000) == 0 && QChar((unsigned short)c).category() == QChar::Other_Format;
    219223    }
    220224
    221     inline bool isPrintableChar(int32_t c)
     225    inline bool isPrintableChar(UChar32 c)
    222226    {
    223227      return (c & 0xffff0000) == 0 && QChar((unsigned short)c).isPrint();
    224228    }
    225229
    226     inline bool isSeparatorSpace(int32_t c)
     230    inline bool isSeparatorSpace(UChar32 c)
    227231    {
    228232      return (c & 0xffff0000) == 0 && QChar((unsigned short)c).category() == QChar::Separator_Space;
    229233    }
    230234
    231     inline bool isPunct(int32_t c)
     235    inline bool isPunct(UChar32 c)
    232236    {
    233237      return (c & 0xffff0000) == 0 && QChar((unsigned short)c).isPunct();
    234238    }
    235239
    236     inline bool isDigit(int32_t c)
     240    inline bool isDigit(UChar32 c)
    237241    {
    238242      return (c & 0xffff0000) == 0 && QChar((unsigned short)c).isDigit();
    239243    }
    240244
    241     inline bool isLower(int32_t c)
     245    inline bool isLower(UChar32 c)
    242246    {
    243247      return (c & 0xffff0000) == 0 && QChar((unsigned short)c).category() == QChar::Letter_Lowercase;
    244248    }
    245249
    246     inline bool isUpper(int32_t c)
     250    inline bool isUpper(UChar32 c)
    247251    {
    248252      return (c & 0xffff0000) == 0 && QChar((unsigned short)c).category() == QChar::Letter_Uppercase;
    249253    }
    250254
    251     inline int digitValue(int32_t c)
     255    inline int digitValue(UChar32 c)
    252256    {
    253257      if (c > 0xffff)
     
    256260    }
    257261
    258     inline uint16_t mirroredChar(uint16_t c)
    259     {
     262    inline UChar32 mirroredChar(UChar32 c)
     263    {
     264      if (c > 0xffff)
     265        return c;
    260266      return QChar(c).mirroredChar().unicode();
    261267    }
     
    275281    }
    276282
    277 
    278     inline int strcasecmp(const UChar *a, const UChar *b, int len)
     283    inline int umemcasecmp(const UChar* a, const UChar* b, int len)
    279284    {
    280285      for (int i = 0; i < len; ++i) {
     
    287292    }
    288293
    289     inline void memset(UChar* dest, UChar ch, int32_t count)
    290     {
    291       UChar *end = dest + count;
    292       while (dest < end)
    293         *dest++ = ch;
    294     }
    295 
    296     inline Direction direction(int c) {
     294    inline Direction direction(UChar32 c) {
    297295      if (c > 0xffff)
    298296        return LeftToRight;
     
    300298    }
    301299
    302     inline CharCategory category(int c) {
     300    inline CharCategory category(UChar32 c) {
    303301      if (c > 0xffff)
    304302        return (CharCategory) U_MASK(QChar::Letter_Other);
    305303      return (CharCategory) U_MASK(QChar(c).category());
    306304    }
     305
    307306  }
    308307}
Note: See TracChangeset for help on using the changeset viewer.