Changeset 161840 in webkit
- Timestamp:
- Jan 12, 2014 3:23:44 PM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/JSValueRef.cpp
r157688 r161840 324 324 String str = string->string(); 325 325 unsigned length = str.length(); 326 if ( length &&str.is8Bit()) {326 if (str.is8Bit()) { 327 327 LiteralParser<LChar> parser(exec, str.characters8(), length, StrictJSON); 328 328 return toRef(exec, parser.tryLiteralParse()); 329 329 } 330 LiteralParser<UChar> parser(exec, str.characters (), length, StrictJSON);330 LiteralParser<UChar> parser(exec, str.characters16(), length, StrictJSON); 331 331 return toRef(exec, parser.tryLiteralParse()); 332 332 } -
trunk/Source/JavaScriptCore/ChangeLog
r161820 r161840 1 2014-01-12 Darin Adler <darin@apple.com> 2 3 Reduce use of String::characters 4 https://bugs.webkit.org/show_bug.cgi?id=126854 5 6 Reviewed by Sam Weinig. 7 8 * API/JSValueRef.cpp: 9 (JSValueMakeFromJSONString): Use characters16 instead of characters for 16-bit case. 10 Had to remove length check because an empty string could be either 8 bit or 16 bit. 11 Don't need a null string check before calling is8Bit because JSStringRef can't hold 12 a null string. 13 14 * bindings/ScriptValue.cpp: 15 (Deprecated::jsToInspectorValue): Use the existing string here instead of creating 16 a new one by calling characters and length on the old string. I think this may be 17 left over from when string types were not the same in JavaScriptCore and WebCore. 18 Also rewrite the property names loop to use modern for syntax and fewer locals. 19 20 * inspector/InspectorValues.cpp: 21 (Inspector::escapeChar): Changed to use appendLiteral instead of hard-coding string 22 lengths. Moved handling of "<" and ">" in here instead of at the call site. 23 (Inspector::doubleQuoteString): Simplify the code so there is no use of characters 24 and length. This is still an inefficient way of doing this job and could use a rethink. 25 26 * runtime/DatePrototype.cpp: 27 (JSC::formatLocaleDate): Use RetainPtr, createCFString, and the conversion from 28 CFStringRef to WTF::String to remove a lot of unneeded code. 29 30 * runtime/Identifier.h: Removed unneeded Identifier::characters function. 31 32 * runtime/JSStringBuilder.h: 33 (JSC::JSStringBuilder::append): Use characters16 instead of characters function here, 34 since we have already checked is8Bit above. 35 1 36 2014-01-12 Andy Estes <aestes@apple.com> 2 37 -
trunk/Source/JavaScriptCore/bindings/ScriptValue.cpp
r160457 r161840 116 116 if (value.isNumber()) 117 117 return InspectorBasicValue::create(value.asNumber()); 118 if (value.isString()) { 119 String s = value.getString(scriptState); 120 return InspectorString::create(String(s.characters(), s.length())); 121 } 118 if (value.isString()) 119 return InspectorString::create(value.getString(scriptState)); 122 120 123 121 if (value.isObject()) { … … 139 137 PropertyNameArray propertyNames(scriptState); 140 138 object->methodTable()->getOwnPropertyNames(object, scriptState, propertyNames, ExcludeDontEnumProperties); 141 for (size_t i = 0; i < propertyNames.size(); i++) { 142 const Identifier& name = propertyNames[i]; 143 JSValue propertyValue = object->get(scriptState, name); 144 RefPtr<InspectorValue> inspectorValue = jsToInspectorValue(scriptState, propertyValue, maxDepth); 139 for (auto& name : propertyNames) { 140 RefPtr<InspectorValue> inspectorValue = jsToInspectorValue(scriptState, object->get(scriptState, name), maxDepth); 145 141 if (!inspectorValue) 146 142 return nullptr; 147 inspectorObject->setValue( String(name.characters(), name.length()), inspectorValue);143 inspectorObject->setValue(name.string(), inspectorValue); 148 144 } 149 145 return inspectorObject; -
trunk/Source/JavaScriptCore/inspector/InspectorValues.cpp
r160457 r161840 447 447 inline bool escapeChar(UChar c, StringBuilder* dst) 448 448 { 449 // Must escape < and > to prevent script execution. 449 450 switch (c) { 450 case '\b': dst->append("\\b", 2); break; 451 case '\f': dst->append("\\f", 2); break; 452 case '\n': dst->append("\\n", 2); break; 453 case '\r': dst->append("\\r", 2); break; 454 case '\t': dst->append("\\t", 2); break; 455 case '\\': dst->append("\\\\", 2); break; 456 case '"': dst->append("\\\"", 2); break; 451 case '\b': dst->appendLiteral("\\b"); break; 452 case '\f': dst->appendLiteral("\\f"); break; 453 case '\n': dst->appendLiteral("\\n"); break; 454 case '\r': dst->appendLiteral("\\r"); break; 455 case '\t': dst->appendLiteral("\\t"); break; 456 case '\\': dst->appendLiteral("\\\\"); break; 457 case '"': dst->appendLiteral("\\\""); break; 458 case '<': dst->appendLiteral("\\u003C"); break; 459 case '>': dst->appendLiteral("\\u003E"); break; 457 460 default: 458 461 return false; … … 467 470 UChar c = str[i]; 468 471 if (!escapeChar(c, dst)) { 469 if (c < 32 || c > 126 || c == '<' || c == '>') { 470 // 1. Escaping <, > to prevent script execution. 471 // 2. Technically, we could also pass through c > 126 as UTF8, but this 472 // is also optional. It would also be a pain to implement here. 473 unsigned int symbol = static_cast<unsigned int>(c); 474 String symbolCode = String::format("\\u%04X", symbol); 475 dst->append(symbolCode.characters(), symbolCode.length()); 476 } else 472 // We could format c > 126 as UTF-8 instead of escaping them. 473 if (c >= 32 || c <= 126) 477 474 dst->append(c); 475 else { 476 // FIXME: Way too slow to do this by creating and destroying a string each time. 477 dst->append(String::format("\\u%04X", static_cast<unsigned>(c))); 478 } 478 479 } 479 480 } -
trunk/Source/JavaScriptCore/runtime/DatePrototype.cpp
r156620 r161840 163 163 timeStyle = styleFromArgString(arg0String, timeStyle); 164 164 165 CFLocaleRef locale = CFLocaleCopyCurrent(); 166 CFDateFormatterRef formatter = CFDateFormatterCreate(0, locale, dateStyle, timeStyle); 167 CFRelease(locale); 168 169 if (useCustomFormat) { 170 CFStringRef customFormatCFString = CFStringCreateWithCharacters(0, customFormatString.characters(), customFormatString.length()); 171 CFDateFormatterSetFormat(formatter, customFormatCFString); 172 CFRelease(customFormatCFString); 173 } 174 175 CFStringRef string = CFDateFormatterCreateStringWithAbsoluteTime(0, formatter, floor(timeInMilliseconds / msPerSecond) - kCFAbsoluteTimeIntervalSince1970); 176 177 CFRelease(formatter); 178 179 // We truncate the string returned from CFDateFormatter if it's absurdly long (> 200 characters). 180 // That's not great error handling, but it just won't happen so it doesn't matter. 181 UChar buffer[200]; 182 const size_t bufferLength = WTF_ARRAY_LENGTH(buffer); 183 size_t length = CFStringGetLength(string); 184 ASSERT(length <= bufferLength); 185 if (length > bufferLength) 186 length = bufferLength; 187 CFStringGetCharacters(string, CFRangeMake(0, length), buffer); 188 189 CFRelease(string); 190 191 return jsNontrivialString(exec, String(buffer, length)); 165 RetainPtr<CFDateFormatterRef> formatter = adoptCF(CFDateFormatterCreate(kCFAllocatorDefault, adoptCF(CFLocaleCopyCurrent()).get(), dateStyle, timeStyle)); 166 167 if (useCustomFormat) 168 CFDateFormatterSetFormat(formatter.get(), customFormatString.createCFString().get()); 169 170 RetainPtr<CFStringRef> string = adoptCF(CFDateFormatterCreateStringWithAbsoluteTime(kCFAllocatorDefault, formatter.get(), floor(timeInMilliseconds / msPerSecond) - kCFAbsoluteTimeIntervalSince1970)); 171 172 return jsNontrivialString(exec, string.get()); 192 173 } 193 174 -
trunk/Source/JavaScriptCore/runtime/Identifier.h
r158498 r161840 56 56 StringImpl* impl() const { return m_string.impl(); } 57 57 58 const UChar* characters() const { return m_string.characters(); }59 58 int length() const { return m_string.length(); } 60 59 -
trunk/Source/JavaScriptCore/runtime/JSStringBuilder.h
r147892 r161840 106 106 upConvert(); 107 107 } 108 m_okay &= buffer16.tryAppend(str.characters (), length);108 m_okay &= buffer16.tryAppend(str.characters16(), length); 109 109 } 110 110 -
trunk/Source/WTF/ChangeLog
r161818 r161840 1 2014-01-12 Darin Adler <darin@apple.com> 2 3 Reduce use of String::characters 4 https://bugs.webkit.org/show_bug.cgi?id=126854 5 6 Reviewed by Sam Weinig. 7 8 * wtf/text/StringImpl.cpp: 9 (WTF::StringImpl::replace): Use characters16 here since is8Bit was already checked. 10 * wtf/text/WTFString.h: 11 (WTF::String::isAllSpecialCharacters): Use characters16 here since is8Bit was 12 already checked. Also renamed "len" to "length". 13 1 14 2014-01-12 Anders Carlsson <andersca@apple.com> 2 15 -
trunk/Source/WTF/wtf/text/StringImpl.cpp
r161362 r161840 1490 1490 data[i + position + lengthToInsert] = m_data8[i + position + lengthToReplace]; 1491 1491 } else { 1492 memcpy(data + position + lengthToInsert, characters () + position + lengthToReplace,1492 memcpy(data + position + lengthToInsert, characters16() + position + lengthToReplace, 1493 1493 (length() - position - lengthToReplace) * sizeof(UChar)); 1494 1494 } -
trunk/Source/WTF/wtf/text/WTFString.h
r161601 r161840 625 625 inline bool String::isAllSpecialCharacters() const 626 626 { 627 size_t len =length();628 629 if (!len )627 size_t length = this->length(); 628 629 if (!length) 630 630 return true; 631 631 632 632 if (is8Bit()) 633 return WTF::isAllSpecialCharacters<isSpecialCharacter , LChar>(characters8(), len);634 return WTF::isAllSpecialCharacters<isSpecialCharacter , UChar>(characters(), len);633 return WTF::isAllSpecialCharacters<isSpecialCharacter>(characters8(), length); 634 return WTF::isAllSpecialCharacters<isSpecialCharacter>(characters16(), length); 635 635 } 636 636 -
trunk/Source/WebCore/ChangeLog
r161839 r161840 1 2014-01-12 Darin Adler <darin@apple.com> 2 3 Reduce use of String::characters 4 https://bugs.webkit.org/show_bug.cgi?id=126854 5 6 Reviewed by Sam Weinig. 7 8 * bindings/objc/WebScriptObject.mm: 9 (+[WebScriptObject _convertValueToObjcValue:JSC::originRootObject:rootObject:]): 10 Get rid of unneeded code to turn a WTF::String into an NSString, since that's 11 built into the WTF::String class. 12 13 * editing/CompositeEditCommand.cpp: 14 (WebCore::containsOnlyWhitespace): Use WTF::String's [] operator instead of 15 an explicit call to the characters function. Small performance cost. 16 * editing/TypingCommand.cpp: 17 (WebCore::TypingCommand::insertText): Ditto. 18 19 * editing/VisibleUnits.cpp: 20 (WebCore::startOfParagraph): Use reverseFind instead of writing our own loop. 21 (WebCore::endOfParagraph): Use find instead of writing our own loop. 22 23 * html/parser/HTMLParserIdioms.cpp: 24 (WebCore::stripLeadingAndTrailingHTMLSpaces): Use characters16 instead of 25 characters since we have already checked is8Bit. 26 (WebCore::parseHTMLNonNegativeInteger): Ditto. Replace the length check with 27 a check of isNull since a zero length string could be 8 bit, but it's not 28 safe to call is8Bit on a null WTF::String. (That should probably be fixed.) 29 30 * inspector/ContentSearchUtils.cpp: 31 (WebCore::ContentSearchUtils::createSearchRegexSource): Use StringBuilder 32 instead of String in code that builds up a string one character at a time. 33 The old way was ridiculously slow because it allocated a new string for every 34 character; the new way still isn't all that efficient, but it's better. Also 35 changed to use strchr instead of WTF::String::find for special characters. 36 37 * inspector/InspectorStyleSheet.cpp: 38 (WebCore::InspectorStyle::newLineAndWhitespaceDelimiters): Use WTF::String's 39 [] operator instead of an explicit call to the characters function. 40 * inspector/InspectorStyleTextEditor.cpp: 41 (WebCore::InspectorStyleTextEditor::insertProperty): Ditto. 42 (WebCore::InspectorStyleTextEditor::internalReplaceProperty): Ditto. 43 * platform/Length.cpp: 44 (WebCore::newCoordsArray): Ditto. 45 46 * platform/LinkHash.cpp: 47 (WebCore::visitedLinkHash): Use characters16 instead of characters since 48 we have already checked is8Bit. Replace the length check with a check of 49 isNull (as above in parseHTMLNonNegativeInteger). 50 51 * platform/graphics/Color.cpp: 52 (WebCore::Color::parseHexColor): Use characters16 since we already checked is8Bit. 53 (WebCore::Color::Color): Ditto. 54 55 * platform/graphics/TextRun.h: 56 (WebCore::TextRun::TextRun): Use characters16 instead of characters since 57 we have already checked is8Bit. Replace the length check with a check of 58 isNull (as above in parseHTMLNonNegativeInteger). 59 60 * platform/text/TextEncodingRegistry.cpp: 61 (WebCore::atomicCanonicalTextEncodingName): Use characters16 instead of 62 characters since we already checked is8Bit. Also use isEmpty instead of !length. 63 64 * rendering/RenderBlock.cpp: 65 (WebCore::RenderBlock::constructTextRun): Use characters16 instead of characters 66 since we have already checked is8Bit. Replace the length check with a check of 67 isNull (as above in parseHTMLNonNegativeInteger). 68 69 * rendering/RenderCombineText.cpp: 70 (WebCore::RenderCombineText::width): Check for zero length instead of checking 71 for null characters. 72 73 * svg/SVGFontElement.cpp: 74 (WebCore::SVGFontElement::registerLigaturesInGlyphCache): Rewrite ligatures 75 for loop and give local variables a better name. Construct the substring with 76 the substring function. Still a really inefficient approach -- allocating a new 77 string for every character is absurdly expensive. 78 79 * xml/XPathFunctions.cpp: 80 (WebCore::XPath::FunId::evaluate): Use String instead of StringBuilder. Still 81 not all that efficient, but better than before. Use substring to construct the 82 substring. 83 84 * xml/XPathNodeSet.h: Added begin and end functions so we can use a C++11 for 85 loop with this class. 86 1 87 2014-01-12 Benjamin Poulain <benjamin@webkit.org> 2 88 -
trunk/Source/WebCore/bindings/objc/WebScriptObject.mm
r161220 r161840 549 549 } 550 550 551 if (value.isString()) { 552 ExecState* exec = rootObject->globalObject()->globalExec(); 553 const String& u = asString(value)->value(exec); 554 return [NSString stringWithCharacters:u.characters() length:u.length()]; 555 } 551 if (value.isString()) 552 return asString(value)->value(rootObject->globalObject()->globalExec()); 556 553 557 554 if (value.isNumber()) -
trunk/Source/WebCore/editing/CompositeEditCommand.cpp
r161638 r161840 668 668 { 669 669 for (unsigned i = 0; i < text.length(); ++i) { 670 if (!isWhitespace(text .characters()[i]))670 if (!isWhitespace(text[i])) 671 671 return false; 672 672 } 673 674 673 return true; 675 674 } -
trunk/Source/WebCore/editing/TypingCommand.cpp
r161638 r161840 153 153 154 154 if (!text.isEmpty()) 155 frame->editor().updateMarkersForWordsAffectedByEditing(isSpaceOrNewline(text .characters()[0]));155 frame->editor().updateMarkersForWordsAffectedByEditing(isSpaceOrNewline(text[0])); 156 156 157 157 insertText(document, text, frame->selection().selection(), options, composition); -
trunk/Source/WebCore/editing/VisibleUnits.cpp
r161795 r161840 1147 1147 type = Position::PositionIsOffsetInAnchor; 1148 1148 if (style.preserveNewline()) { 1149 const UChar* chars = toRenderText(r)->characters(); 1150 int i = toRenderText(r)->textLength(); 1151 int o = offset; 1152 if (n == startNode && o < i) 1153 i = std::max(0, o); 1154 while (--i >= 0) { 1155 if (chars[i] == '\n') 1156 return VisiblePosition(Position(toText(n), i + 1), DOWNSTREAM); 1157 } 1149 unsigned startOffset = n == startNode ? std::max(0, offset) : std::numeric_limits<unsigned>::max(); 1150 size_t newlineOffset = toRenderText(r)->text()->reverseFind('\n', startOffset); 1151 if (newlineOffset != notFound) 1152 return VisiblePosition(Position(toText(n), newlineOffset + 1), DOWNSTREAM); 1158 1153 } 1159 1154 node = n; … … 1227 1222 if (r->isText() && toRenderText(r)->hasRenderedText()) { 1228 1223 ASSERT_WITH_SECURITY_IMPLICATION(n->isTextNode()); 1229 int length = toRenderText(r)->textLength();1230 1224 type = Position::PositionIsOffsetInAnchor; 1231 1225 if (style.preserveNewline()) { 1232 const UChar* chars = toRenderText(r)->characters(); 1233 int o = n == startNode ? offset : 0; 1234 for (int i = o; i < length; ++i) { 1235 if (chars[i] == '\n') 1236 return VisiblePosition(Position(toText(n), i), DOWNSTREAM); 1237 } 1226 size_t newlineOffset = toRenderText(r)->text()->find('\n', n == startNode ? offset : 0); 1227 if (newlineOffset != notFound) 1228 return VisiblePosition(Position(toText(n), newlineOffset), DOWNSTREAM); 1238 1229 } 1239 1230 node = n; -
trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp
r158650 r161840 72 72 return stripLeadingAndTrailingHTMLSpaces(string, string.characters8(), length); 73 73 74 return stripLeadingAndTrailingHTMLSpaces(string, string.characters (), length);74 return stripLeadingAndTrailingHTMLSpaces(string, string.characters16(), length); 75 75 } 76 76 … … 268 268 // Step 2 269 269 unsigned length = input.length(); 270 if ( length &&input.is8Bit()) {270 if (input.isNull() || input.is8Bit()) { 271 271 const LChar* start = input.characters8(); 272 272 return parseHTMLNonNegativeIntegerInternal(start, start + length, value); 273 273 } 274 274 275 const UChar* start = input.characters ();275 const UChar* start = input.characters16(); 276 276 return parseHTMLNonNegativeIntegerInternal(start, start + length, value); 277 277 } -
trunk/Source/WebCore/inspector/ContentSearchUtils.cpp
r161309 r161840 37 37 #include <wtf/BumpPointerAllocator.h> 38 38 #include <wtf/StdLibExtras.h> 39 #include <wtf/text/StringBuilder.h> 39 40 #include <yarr/Yarr.h> 40 41 … … 51 52 static String createSearchRegexSource(const String& text) 52 53 { 53 String result; 54 const UChar* characters = text.characters(); 55 String specials(regexSpecialCharacters); 56 54 StringBuilder result; 57 55 for (unsigned i = 0; i < text.length(); i++) { 58 if (specials.find(characters[i]) != notFound) 59 result.append("\\"); 60 result.append(characters[i]); 61 } 62 63 return result; 56 if (isASCII(text[i]) && strchr(regexSpecialCharacters, text[i])) 57 result.append('\\'); 58 result.append(text[i]); 59 } 60 return result.toString(); 64 61 } 65 62 -
trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp
r160457 r161840 724 724 bool isFullPrefixScanned = false; 725 725 bool lineFeedTerminated = false; 726 const UChar* characters = text.characters();727 726 while (propertyIndex < propertyCount) { 728 727 const WebCore::CSSPropertySourceData& currentProperty = sourcePropertyData->at(propertyIndex++); … … 731 730 int scanEnd = currentProperty.range.start; 732 731 for (int i = scanStart; i < scanEnd; ++i) { 733 UChar ch = characters[i];732 UChar ch = text[i]; 734 733 bool isLineFeed = isHTMLLineBreak(ch); 735 734 if (isLineFeed) { -
trunk/Source/WebCore/inspector/InspectorStyleTextEditor.cpp
r160457 r161840 83 83 propertyStart = styleBodyLength; 84 84 if (propertyStart && textToSet.length()) { 85 const UChar* characters = m_styleText.characters();86 87 85 long curPos = propertyStart - 1; // The last position of style declaration, since propertyStart points past one. 88 while (curPos && isHTMLSpace( characters[curPos]))86 while (curPos && isHTMLSpace(m_styleText[curPos])) 89 87 --curPos; 90 if (curPos && characters[curPos] != ';') {88 if (curPos && m_styleText[curPos] != ';') { 91 89 // Prepend a ";" to the property text if appending to a style declaration where 92 90 // the last property has no trailing ";". … … 231 229 long replaceRangeStart = range.start; 232 230 long replaceRangeEnd = range.end; 233 const UChar* characters = m_styleText.characters();234 231 long newTextLength = newText.length(); 235 232 String finalNewText = newText; … … 242 239 replaceRangeStart -= fullPrefixLength; 243 240 } else if (newTextLength) { 244 if (isHTMLLineBreak(newText .characters()[newTextLength - 1])) {241 if (isHTMLLineBreak(newText[newTextLength - 1])) { 245 242 // Coalesce newlines of the original and new property values (to avoid a lot of blank lines while incrementally applying property values). 246 243 bool foundNewline = false; … … 248 245 int i; 249 246 int textLength = m_styleText.length(); 250 for (i = replaceRangeEnd; i < textLength && isSpaceOrNewline( characters[i]); ++i) {251 isLastNewline = isHTMLLineBreak( characters[i]);247 for (i = replaceRangeEnd; i < textLength && isSpaceOrNewline(m_styleText[i]); ++i) { 248 isLastNewline = isHTMLLineBreak(m_styleText[i]); 252 249 if (isLastNewline) 253 250 foundNewline = true; -
trunk/Source/WebCore/platform/Length.cpp
r156132 r161840 89 89 { 90 90 unsigned length = string.length(); 91 const UChar* data = string.characters();92 91 StringBuffer<UChar> spacified(length); 93 92 for (unsigned i = 0; i < length; i++) { 94 UChar cc = data[i];93 UChar cc = string[i]; 95 94 if (cc > '9' || (cc < '0' && cc != '-' && cc != '*' && cc != '.')) 96 95 spacified[i] = ' '; -
trunk/Source/WebCore/platform/LinkHash.cpp
r156550 r161840 215 215 { 216 216 unsigned length = url.length(); 217 218 if (length && url.is8Bit()) 217 if (url.isNull() || url.is8Bit()) 219 218 return visitedLinkHashInline(url.characters8(), length); 220 return visitedLinkHashInline(url.characters (), length);219 return visitedLinkHashInline(url.characters16(), length); 221 220 } 222 221 -
trunk/Source/WebCore/platform/graphics/Color.cpp
r161589 r161840 166 166 if (name.is8Bit()) 167 167 return parseHexColor(name.characters8(), name.length(), rgb); 168 return parseHexColor(name.characters (), name.length(), rgb);168 return parseHexColor(name.characters16(), name.length(), rgb); 169 169 } 170 170 … … 183 183 m_valid = parseHexColor(name.characters8() + 1, name.length() - 1, m_color); 184 184 else 185 m_valid = parseHexColor(name.characters () + 1, name.length() - 1, m_color);185 m_valid = parseHexColor(name.characters16() + 1, name.length() - 1, m_color); 186 186 } else 187 187 setNamedColor(name); -
trunk/Source/WebCore/platform/graphics/TextRun.h
r157960 r161840 125 125 { 126 126 #if ENABLE(8BIT_TEXTRUN) 127 if ( m_charactersLength &&s.is8Bit()) {127 if (s.isNull() || s.is8Bit()) { 128 128 m_data.characters8 = s.characters8(); 129 129 m_is8Bit = true; 130 130 } else { 131 m_data.characters16 = s.characters ();131 m_data.characters16 = s.characters16(); 132 132 m_is8Bit = false; 133 133 } -
trunk/Source/WebCore/platform/text/TextEncodingRegistry.cpp
r161589 r161840 344 344 const char* atomicCanonicalTextEncodingName(const String& alias) 345 345 { 346 if ( !alias.length())347 return 0;346 if (alias.isEmpty()) 347 return nullptr; 348 348 349 349 if (alias.is8Bit()) 350 350 return atomicCanonicalTextEncodingName<LChar>(alias.characters8(), alias.length()); 351 351 352 return atomicCanonicalTextEncodingName<UChar>(alias.characters (), alias.length());352 return atomicCanonicalTextEncodingName<UChar>(alias.characters16(), alias.length()); 353 353 } 354 354 -
trunk/Source/WebCore/rendering/RenderBlock.cpp
r161790 r161840 5480 5480 { 5481 5481 unsigned length = string.length(); 5482 5483 5482 #if ENABLE(8BIT_TEXTRUN) 5484 if ( length &&string.is8Bit())5483 if (string.isNull() || string.is8Bit()) 5485 5484 return constructTextRunInternal(context, font, string.characters8(), length, style, expansion, flags); 5486 return constructTextRunInternal(context, font, string.characters (), length, style, expansion, flags);5485 return constructTextRunInternal(context, font, string.characters16(), length, style, expansion, flags); 5487 5486 #else 5488 5487 return constructTextRunInternal(context, font, string.characters(), length, style, expansion, flags); -
trunk/Source/WebCore/rendering/RenderCombineText.cpp
r158163 r161840 61 61 float RenderCombineText::width(unsigned from, unsigned length, const Font& font, float xPosition, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const 62 62 { 63 if (! characters())63 if (!textLength()) 64 64 return 0; 65 65 -
trunk/Source/WebCore/svg/SVGFontElement.cpp
r160598 r161840 88 88 // character substitution properly through glyphDataForCharacter(). 89 89 Vector<SVGGlyph> glyphs; 90 size_t ligaturesSize = ligatures.size(); 91 for (size_t i = 0; i < ligaturesSize; ++i) { 92 const String& unicode = ligatures[i]; 93 94 unsigned unicodeLength = unicode.length(); 95 ASSERT(unicodeLength > 1); 96 97 const UChar* characters = unicode.characters(); 98 for (unsigned i = 0; i < unicodeLength; ++i) { 99 String lookupString(characters + i, 1); 90 for (auto& ligature : ligatures) { 91 unsigned ligatureLength = ligature.length(); 92 ASSERT(ligatureLength > 1); 93 94 for (unsigned i = 0; i < ligatureLength; ++i) { 95 // FIXME: Is there a faster way to do this without allocating/deallocating a string for every character in every ligature? 96 String lookupString(ligature.substring(i, 1)); 100 97 m_glyphMap.collectGlyphsForString(lookupString, glyphs); 101 98 if (!glyphs.isEmpty()) { -
trunk/Source/WebCore/xml/XPathFunctions.cpp
r161425 r161840 308 308 { 309 309 Value a = argument(0).evaluate(); 310 StringBuilder idList; // A whitespace-separated list of IDs 311 310 311 String idList; // A whitespace-separated list of IDs 312 312 if (a.isNodeSet()) { 313 const NodeSet& nodes = a.toNodeSet(); 314 for (size_t i = 0; i < nodes.size(); ++i) { 315 String str = stringValue(nodes[i]); 316 idList.append(str); 317 idList.append(' '); 313 StringBuilder spaceSeparatedList; 314 for (auto& node : a.toNodeSet()) { 315 spaceSeparatedList.append(stringValue(node.get())); 316 spaceSeparatedList.append(' '); 318 317 } 318 idList = spaceSeparatedList.toString(); 319 319 } else { 320 String str = a.toString(); 321 idList.append(str); 320 idList = a.toString(); 322 321 } 323 322 … … 341 340 // If there are several nodes with the same id, id() should return the first one. 342 341 // In WebKit, getElementById behaves so, too, although its behavior in this case is formally undefined. 343 Node* node = contextScope.getElementById( String(idList.characters() +startPos, endPos - startPos));342 Node* node = contextScope.getElementById(idList.substring(startPos, endPos - startPos)); 344 343 if (node && resultSet.add(node).isNewEntry) 345 344 result.append(node); -
trunk/Source/WebCore/xml/XPathNodeSet.h
r157205 r161840 45 45 void clear() { m_nodes.clear(); } 46 46 47 Vector<RefPtr<Node>>::const_iterator begin() const { return m_nodes.begin(); } 48 Vector<RefPtr<Node>>::const_iterator end() const { return m_nodes.end(); } 49 47 50 // NodeSet itself does not verify that nodes in it are unique. 48 51 void append(PassRefPtr<Node> node) { m_nodes.append(node); }
Note: See TracChangeset
for help on using the changeset viewer.