Changeset 156948 in webkit
- Timestamp:
- Oct 4, 2013 11:38:33 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r156947 r156948 1 2013-10-04 Darin Adler <darin@apple.com> 2 3 text-transform: lowercase is not lang-dependent (Turkish languages : tr,az) 4 https://bugs.webkit.org/show_bug.cgi?id=21312 5 6 Reviewed by Ryosuke Niwa. 7 8 * fast/text/text-transform-turkish-and-azeri-expected.html: Added. 9 * fast/text/text-transform-turkish-and-azeri.html: Added. 10 1 11 2013-10-04 Alexey Proskuryakov <ap@apple.com> 2 12 -
trunk/Source/WTF/ChangeLog
r156935 r156948 1 2013-10-04 Darin Adler <darin@apple.com> 2 3 text-transform: lowercase is not lang-dependent (Turkish languages : tr,az) 4 https://bugs.webkit.org/show_bug.cgi?id=21312 5 6 Reviewed by Ryosuke Niwa. 7 8 * wtf/text/StringImpl.cpp: 9 (WTF::StringImpl::upper): Removed an extra call that would unnecessarily reallocate 10 a StringImpl in the general non-ASCII case. Added an overload that takes a locale identifier. 11 (WTF::StringImpl::lower): Ditto. 12 * wtf/text/StringImpl.h: Ditto. 13 * wtf/text/WTFString.cpp: 14 (WTF::String::lower): Ditto. 15 (WTF::String::upper): Ditto. 16 * wtf/text/WTFString.h: Ditto. Also deleted the makeLower and makeUpper functions since they 17 offer no advantages over the lower and upper functions. Also added a constructor that takes 18 a RefPtr<StringImpl> with move construction to help. 19 1 20 2013-10-04 Brent Fulgham <bfulgham@apple.com> 2 21 -
trunk/Source/WTF/wtf/text/StringImpl.cpp
r156775 r156948 553 553 // Do a slower implementation for cases that include non-ASCII characters. 554 554 bool error; 555 newImpl = createUninitialized(m_length, data16);556 555 int32_t realLength = Unicode::toUpper(data16, length, source16, m_length, &error); 557 556 if (!error && realLength == length) … … 564 563 } 565 564 565 static inline bool needsTurkishCasingRules(const AtomicString& localeIdentifier) 566 { 567 // Either "tr" or "az" locale, with case sensitive comparison and allowing for an ignored subtag. 568 UChar first = localeIdentifier[0]; 569 UChar second = localeIdentifier[1]; 570 return ((isASCIIAlphaCaselessEqual(first, 't') && isASCIIAlphaCaselessEqual(second, 'r')) 571 || (isASCIIAlphaCaselessEqual(first, 'a') && isASCIIAlphaCaselessEqual(second, 'z'))) 572 && (localeIdentifier.length() == 2 || localeIdentifier[2] == '-'); 573 } 574 575 RefPtr<StringImpl> StringImpl::lower(const AtomicString& localeIdentifier) 576 { 577 #if !USE(ICU_UNICODE) 578 UNUSED_PARAM(localeIdentifier); 579 return lower(); 580 #else 581 // Use the more-optimized code path most of the time. 582 // Assuming here that the only locale-specific lowercasing is the Turkish casing rules. 583 // FIXME: Could possibly optimize further by looking for the specific sequences 584 // that have locale-specific lowercasing. There are only three of them. 585 if (!needsTurkishCasingRules(localeIdentifier)) 586 return lower(); 587 588 // FIXME: Could share more code with the main StringImpl::lower by factoring out 589 // this last part into a shared function that takes a locale string, since this is 590 // just like the end of that function. 591 592 if (m_length > static_cast<unsigned>(numeric_limits<int32_t>::max())) 593 CRASH(); 594 int length = m_length; 595 596 // Below, we pass in the hardcoded locale "tr". Passing that is more efficient than 597 // allocating memory just to turn localeIdentifier into a C string, and we assume 598 // there is no difference between the uppercasing for "tr" and "az" locales. 599 const UChar* source16 = characters(); 600 UChar* data16; 601 RefPtr<StringImpl> newString = createUninitialized(length, data16); 602 UErrorCode status = U_ZERO_ERROR; 603 int realLength = u_strToLower(data16, length, source16, length, "tr", &status); 604 if (U_SUCCESS(status) && realLength == length) 605 return newString; 606 status = U_ZERO_ERROR; 607 newString = createUninitialized(realLength, data16); 608 u_strToLower(data16, realLength, source16, length, "tr", &status); 609 if (U_FAILURE(status)) 610 return this; 611 return newString.release(); 612 #endif 613 } 614 615 RefPtr<StringImpl> StringImpl::upper(const AtomicString& localeIdentifier) 616 { 617 #if !USE(ICU_UNICODE) 618 UNUSED_PARAM(localeIdentifier); 619 return upper(); 620 #else 621 // Use the more-optimized code path most of the time. 622 // Assuming here that the only locale-specific lowercasing is the Turkish casing rules, 623 // and that the only affected character is lowercase "i". 624 if (!needsTurkishCasingRules(localeIdentifier) || find('i') == notFound) 625 return upper(); 626 627 if (m_length > static_cast<unsigned>(numeric_limits<int32_t>::max())) 628 CRASH(); 629 int length = m_length; 630 631 // Below, we pass in the hardcoded locale "tr". Passing that is more efficient than 632 // allocating memory just to turn localeIdentifier into a C string, and we assume 633 // there is no difference between the uppercasing for "tr" and "az" locales. 634 const UChar* source16 = characters(); 635 UChar* data16; 636 RefPtr<StringImpl> newString = createUninitialized(length, data16); 637 UErrorCode status = U_ZERO_ERROR; 638 int realLength = u_strToUpper(data16, length, source16, length, "tr", &status); 639 if (U_SUCCESS(status) && realLength == length) 640 return newString; 641 newString = createUninitialized(realLength, data16); 642 status = U_ZERO_ERROR; 643 u_strToUpper(data16, realLength, source16, length, "tr", &status); 644 if (U_FAILURE(status)) 645 return this; 646 return newString.release(); 647 #endif 648 } 649 566 650 PassRefPtr<StringImpl> StringImpl::fill(UChar character) 567 651 { 568 if (!m_length)569 return this;570 571 652 if (!(character & ~0x7F)) { 572 653 LChar* data; -
trunk/Source/WTF/wtf/text/StringImpl.h
r156910 r156948 691 691 WTF_EXPORT_STRING_API PassRefPtr<StringImpl> lower(); 692 692 WTF_EXPORT_STRING_API PassRefPtr<StringImpl> upper(); 693 WTF_EXPORT_STRING_API RefPtr<StringImpl> lower(const AtomicString& localeIdentifier); 694 WTF_EXPORT_STRING_API RefPtr<StringImpl> upper(const AtomicString& localeIdentifier); 693 695 694 696 WTF_EXPORT_STRING_API PassRefPtr<StringImpl> fill(UChar); -
trunk/Source/WTF/wtf/text/WTFString.cpp
r156775 r156948 334 334 } 335 335 336 String String::lower(const AtomicString& localeIdentifier) const 337 { 338 if (!m_impl) 339 return String(); 340 return m_impl->lower(localeIdentifier); 341 } 342 343 String String::upper(const AtomicString& localeIdentifier) const 344 { 345 if (!m_impl) 346 return String(); 347 return m_impl->upper(localeIdentifier); 348 } 349 336 350 String String::stripWhiteSpace() const 337 351 { -
trunk/Source/WTF/wtf/text/WTFString.h
r156775 r156948 123 123 String(StringImpl* impl) : m_impl(impl) { } 124 124 String(PassRefPtr<StringImpl> impl) : m_impl(impl) { } 125 String(RefPtr<StringImpl>&& impl) : m_impl(impl) { } 125 126 126 127 // Construct a string from a constant string literal. … … 319 320 } 320 321 321 void makeLower() { if (m_impl) m_impl = m_impl->lower(); }322 void makeUpper() { if (m_impl) m_impl = m_impl->upper(); }323 322 void fill(UChar c) { if (m_impl) m_impl = m_impl->fill(c); } 324 323 … … 334 333 WTF_EXPORT_STRING_API String lower() const; 335 334 WTF_EXPORT_STRING_API String upper() const; 335 336 WTF_EXPORT_STRING_API String lower(const AtomicString& localeIdentifier) const; 337 WTF_EXPORT_STRING_API String upper(const AtomicString& localeIdentifier) const; 336 338 337 339 WTF_EXPORT_STRING_API String stripWhiteSpace() const; -
trunk/Source/WebCore/ChangeLog
r156947 r156948 1 2013-10-04 Darin Adler <darin@apple.com> 2 3 text-transform: lowercase is not lang-dependent (Turkish languages : tr,az) 4 https://bugs.webkit.org/show_bug.cgi?id=21312 5 6 Reviewed by Ryosuke Niwa. 7 8 Test: fast/text/text-transform-turkish-and-azeri.html 9 10 This patch covers text-transform: uppercase and text-transform: lowercase. 11 More changes will be needed to cover text-transform: capitalize. 12 13 * inspector/DOMPatchSupport.cpp: 14 (WebCore::DOMPatchSupport::patchNode): Use String::upper instead of String::makeUpper. 15 * page/EventHandler.cpp: 16 (WebCore::findDropZone): Use String::lower instead of String::makeLower. 17 * platform/graphics/harfbuzz/HarfBuzzShaper.cpp: 18 (WebCore::HarfBuzzShaper::shapeHarfBuzzRuns): Use String::upper instead of String::makeUpper. 19 * platform/network/blackberry/rss/RSS10Parser.cpp: [Seriously, how is an RSS parser 20 part of WebKit's networking layer? Where are the tests that cover this? Seems wrong 21 to have this code in the project.] 22 (WebCore::RSS10Parser::parseXmlDoc): Use lower instead of makeLower. 23 (WebCore::RSS10Parser::parseItem): Ditto. 24 (WebCore::RSS10Parser::parseFeed): Ditto. 25 * platform/network/blackberry/rss/RSS20Parser.cpp: 26 (WebCore::RSS20Parser::parseXmlDoc): Ditto. 27 (WebCore::RSS20Parser::parseItem): Ditto. 28 (WebCore::RSS20Parser::parseFeed): Ditto. 29 (WebCore::RSS20Parser::parseEnclosure): Ditto. 30 * platform/network/blackberry/rss/RSSAtomParser.cpp: 31 (WebCore::RSSAtomParser::parseXmlDoc): Ditto. 32 (WebCore::RSSAtomParser::parseItem): Ditto. 33 (WebCore::RSSAtomParser::parseFeed): Ditto. 34 (WebCore::RSSAtomParser::parseLink): Ditto. 35 (WebCore::RSSAtomParser::parseContent): Ditto. 36 (WebCore::RSSAtomParser::parseAuthor): Ditto. 37 (WebCore::RSSAtomParser::parseCategory): Ditto. 38 * platform/text/win/LocaleWin.cpp: 39 (WebCore::convertLocaleNameToLCID): Use String::lower instead of String::makeLower. 40 * rendering/RenderText.cpp: 41 (WebCore::applyTextTransform): Use String::upper and String::lower instead of 42 String::makeUpper and String::makeLower, and also pass in the locale to each. 43 * xml/XMLHttpRequest.cpp: 44 (WebCore::XMLHttpRequest::uppercaseKnownHTTPMethod): Changed this so it doesn't call 45 upper just to return an already known string constant. 46 1 47 2013-10-04 Alexey Proskuryakov <ap@apple.com> 2 48 -
trunk/Source/WebCore/inspector/DOMPatchSupport.cpp
r156550 r156948 143 143 144 144 // Compose the new list. 145 String markupCopy = markup; 146 markupCopy.makeLower(); 145 String markupCopy = markup.lower(); 147 146 Vector<OwnPtr<Digest> > newList; 148 147 for (Node* child = parentNode->firstChild(); child != node; child = child->nextSibling()) -
trunk/Source/WebCore/page/EventHandler.cpp
r156815 r156948 2062 2062 continue; 2063 2063 2064 dropZoneStr .makeLower();2064 dropZoneStr = dropZoneStr.lower(); 2065 2065 2066 2066 SpaceSplitString keywords(dropZoneStr, false); -
trunk/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.cpp
r156015 r156948 495 495 496 496 if (m_font->isSmallCaps() && u_islower(m_normalizedBuffer[currentRun->startIndex()])) { 497 String upperText = String(m_normalizedBuffer.get() + currentRun->startIndex(), currentRun->numCharacters()); 498 upperText.makeUpper(); 497 String upperText = String(m_normalizedBuffer.get() + currentRun->startIndex(), currentRun->numCharacters()).upper(); 499 498 currentFontData = m_font->glyphDataForCharacter(upperText[0], false, SmallCapsVariant).fontData; 500 499 hb_buffer_add_utf16(harfBuzzBuffer.get(), reinterpret_cast<const uint16_t*>(upperText.characters()), currentRun->numCharacters(), 0, currentRun->numCharacters()); -
trunk/Source/WebCore/platform/network/blackberry/rss/RSS10Parser.cpp
r126230 r156948 54 54 if (childnode->type == XML_ELEMENT_NODE) { 55 55 name = String(reinterpret_cast<const char*>(childnode->name)); 56 name .makeLower();56 name = name.lower(); 57 57 if (name == "channel") { 58 58 BLACKBERRY_ASSERT(!m_root); … … 99 99 for (; node; node = node->next) { 100 100 String name(reinterpret_cast<const char*>(node->name)); 101 name .makeLower();101 name = name.lower(); 102 102 103 103 parseItemBaseAttribute(item, name, node); … … 115 115 for (; node; node = node->next) { 116 116 String name(reinterpret_cast<const char*>(node->name)); 117 name .makeLower();117 name = name.lower(); 118 118 119 119 parseItemBaseAttribute(feed, name, node); -
trunk/Source/WebCore/platform/network/blackberry/rss/RSS20Parser.cpp
r126230 r156948 48 48 for (; node; node = node->next) { 49 49 String name(reinterpret_cast<const char*>(node->name)); 50 name .makeLower();50 name = name.lower(); 51 51 52 52 if (name == "rss") { … … 54 54 if (channel->type == XML_ELEMENT_NODE) { 55 55 name = reinterpret_cast<const char*>(channel->name); 56 name .makeLower();56 name = name.lower(); 57 57 if (name == "channel") 58 58 m_root = parseFeed(channel->children); … … 91 91 for (; node; node = node->next) { 92 92 String name(reinterpret_cast<const char*>(node->name)); 93 name .makeLower();93 name = name.lower(); 94 94 95 95 if (parseItemBaseAttribute(item, name, node)) … … 125 125 for (; node; node = node->next) { 126 126 String name(reinterpret_cast<const char*>(node->name)); 127 name .makeLower();127 name = name.lower(); 128 128 129 129 if (parseItemBaseAttribute(feed, name, node)) … … 149 149 for (xmlAttr* attr = node->properties; attr; attr = attr->next) { 150 150 String name(reinterpret_cast<const char*>(attr->name)); 151 name .makeLower();151 name = name.lower(); 152 152 153 153 if (name == "url") -
trunk/Source/WebCore/platform/network/blackberry/rss/RSSAtomParser.cpp
r156550 r156948 81 81 for (; node; node = node->next) { 82 82 String name(reinterpret_cast<const char*>(node->name)); 83 name .makeLower();83 name = name.lower(); 84 84 85 85 if (name == "feed") { … … 122 122 for (xmlAttr* attr = node->properties; attr; attr = attr->next) { 123 123 String name(reinterpret_cast<const char*>(attr->name)); 124 name .makeLower();124 name = name.lower(); 125 125 if (name == "base") 126 126 base = textFromXMLAttr(attr); … … 130 130 for (; node; node = node->next) { 131 131 String name(reinterpret_cast<const char*>(node->name)); 132 name .makeLower();132 name = name.lower(); 133 133 134 134 if (parseItemBaseAttribute(item, name, node, base)) … … 168 168 for (; node; node = node->next) { 169 169 String name(reinterpret_cast<const char*>(node->name)); 170 name .makeLower();170 name = name.lower(); 171 171 172 172 if (parseItemBaseAttribute(feed, name, node, emptyString())) … … 194 194 for (xmlAttr* attr = node->properties; attr; attr = attr->next) { 195 195 String name(reinterpret_cast<const char*>(attr->name)); 196 name .makeLower();196 name = name.lower(); 197 197 198 198 if (name == "href") … … 239 239 for (xmlAttr* attr = node->properties; attr; attr = attr->next) { 240 240 String name(reinterpret_cast<const char*>(attr->name)); 241 name .makeLower();241 name = name.lower(); 242 242 243 243 if (name == "type") … … 296 296 for (node = node->children; node; node = node->next) { 297 297 String name(reinterpret_cast<const char*>(node->name)); 298 name .makeLower();298 name = name.lower(); 299 299 300 300 if (name == "name") … … 321 321 for (xmlAttr* attr = node->properties; attr; attr = attr->next) { 322 322 String name(reinterpret_cast<const char*>(attr->name)); 323 name .makeLower();323 name = name.lower(); 324 324 325 325 // If there's a label, we use it, if not, use term attribute, as label is -
trunk/Source/WebCore/platform/text/win/LocaleWin.cpp
r152142 r156948 110 110 DEFINE_STATIC_LOCAL(NameToLCIDMap, map, ()); 111 111 ensureNameToLCIDMap(map); 112 String localeName = String(name).replace('_', '-'); 113 localeName.makeLower(); 112 String localeName = String(name).replace('_', '-').lower(); 114 113 do { 115 114 NameToLCIDMap::const_iterator iterator = map.find(localeName); -
trunk/Source/WebCore/rendering/RenderText.cpp
r156888 r156948 1332 1332 break; 1333 1333 case UPPERCASE: 1334 text .makeUpper();1334 text = text.upper(style->locale()); 1335 1335 break; 1336 1336 case LOWERCASE: 1337 text .makeLower();1337 text = text.lower(style->locale()); 1338 1338 break; 1339 1339 } -
trunk/Source/WebCore/xml/XMLHttpRequest.cpp
r156688 r156948 453 453 String XMLHttpRequest::uppercaseKnownHTTPMethod(const String& method) 454 454 { 455 if (equalIgnoringCase(method, "COPY") || equalIgnoringCase(method, "DELETE") || equalIgnoringCase(method, "GET") 456 || equalIgnoringCase(method, "HEAD") || equalIgnoringCase(method, "INDEX") || equalIgnoringCase(method, "LOCK") 457 || equalIgnoringCase(method, "M-POST") || equalIgnoringCase(method, "MKCOL") || equalIgnoringCase(method, "MOVE") 458 || equalIgnoringCase(method, "OPTIONS") || equalIgnoringCase(method, "POST") || equalIgnoringCase(method, "PROPFIND") 459 || equalIgnoringCase(method, "PROPPATCH") || equalIgnoringCase(method, "PUT") || equalIgnoringCase(method, "UNLOCK")) { 460 return method.upper(); 455 const char* const methods[] = { "COPY", "DELETE", "GET", "HEAD", "INDEX", "LOCK", "M-POST", "MKCOL", "MOVE", "OPTIONS", "POST", "PROPFIND", "PROPPATCH", "PUT", "UNLOCK" }; 456 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(methods); ++i) { 457 if (equalIgnoringCase(method, methods[i])) { 458 // Don't bother allocating a new string if it's already all uppercase. 459 if (method == methods[i]) 460 break; 461 return ASCIILiteral(methods[i]); 462 } 461 463 } 462 464 return method; -
trunk/Source/WebKit/gtk/ChangeLog
r156946 r156948 1 2013-10-04 Darin Adler <darin@apple.com> 2 3 text-transform: lowercase is not lang-dependent (Turkish languages : tr,az) 4 https://bugs.webkit.org/show_bug.cgi?id=21312 5 6 Reviewed by Ryosuke Niwa. 7 8 * WebCoreSupport/DumpRenderTreeSupportGtk.cpp: 9 (DumpRenderTreeSupportGtk::doCommand): Use StringImpl::upper instead of 10 StringImpl::makeUpper. 11 1 12 2013-10-04 Anders Carlsson <andersca@apple.com> 2 13 -
trunk/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp
r156683 r156948 359 359 String firstChar = commandString.left(1); 360 360 commandString = commandString.right(commandString.length() - 1); 361 firstChar.makeUpper(); 362 commandString.insert(firstChar, 0); 361 commandString.insert(firstChar.upper(), 0); 363 362 364 363 editor.command(commandString).execute();
Note: See TracChangeset
for help on using the changeset viewer.