Changeset 242189 in webkit
- Timestamp:
- Feb 27, 2019 8:35:25 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r242137 r242189 1 2019-02-27 Simon Fraser <simon.fraser@apple.com> 2 3 Roll out r242014; it caused crashes in compositing logging (webkit.org/b/195141) 4 5 * bytecode/CodeBlock.cpp: 6 (JSC::CodeBlock::nameForRegister): 7 1 8 2019-02-27 Antoine Quint <graouts@apple.com> 2 9 -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
r242014 r242189 93 93 #include <wtf/SimpleStats.h> 94 94 #include <wtf/StringPrintStream.h> 95 #include <wtf/text/StringConcatenateNumbers.h>96 95 #include <wtf/text/UniquedStringImpl.h> 97 96 … … 2890 2889 return "this"_s; 2891 2890 if (virtualRegister.isArgument()) 2892 return makeString("arguments[", pad(' ', 3, virtualRegister.toArgument()), ']');2893 2894 return emptyString();2891 return String::format("arguments[%3d]", virtualRegister.toArgument()); 2892 2893 return ""; 2895 2894 } 2896 2895 -
trunk/Source/WTF/ChangeLog
r242127 r242189 1 2019-02-27 Simon Fraser <simon.fraser@apple.com> 2 3 Roll out r242014; it caused crashes in compositing logging (webkit.org/b/195141) 4 5 * wtf/Assertions.cpp: 6 (WTF::createWithFormatAndArguments): Deleted. 7 * wtf/HexNumber.h: 8 (WTF::StringTypeAdapter<HexNumberBuffer>::toString const): 9 * wtf/text/StringConcatenate.h: 10 (WTF::makeString): 11 (WTF::pad): Deleted. 12 (WTF::StringTypeAdapter<PaddingSpecification<UnderlyingAdapterType>>::StringTypeAdapter): Deleted. 13 (WTF::StringTypeAdapter<PaddingSpecification<UnderlyingAdapterType>>::length const): Deleted. 14 (WTF::StringTypeAdapter<PaddingSpecification<UnderlyingAdapterType>>::is8Bit const): Deleted. 15 (WTF::StringTypeAdapter<PaddingSpecification<UnderlyingAdapterType>>::writeTo const): Deleted. 16 * wtf/text/StringConcatenateNumbers.h: 17 (WTF::FormattedNumber::fixedPrecision): 18 (WTF::FormattedNumber::fixedWidth): 19 (WTF::StringTypeAdapter<FormattedNumber>::toString const): 20 * wtf/text/StringOperators.h: 21 (WTF::StringAppend::StringAppend): 22 * wtf/text/StringView.h: 23 (WTF::StringView::invalidate): 24 * wtf/text/WTFString.cpp: 25 (WTF::createWithFormatAndArguments): 26 (WTF::String::format): 27 * wtf/text/WTFString.h: 28 1 29 2019-02-26 Mark Lam <mark.lam@apple.com> 2 30 -
trunk/Source/WTF/wtf/Assertions.cpp
r242075 r242189 75 75 #endif 76 76 77 namespace WTF {78 79 WTF_ATTRIBUTE_PRINTF(1, 0) static String createWithFormatAndArguments(const char* format, va_list args)80 {81 va_list argsCopy;82 va_copy(argsCopy, args);83 84 ALLOW_NONLITERAL_FORMAT_BEGIN85 86 #if USE(CF) && !OS(WINDOWS)87 if (strstr(format, "%@")) {88 auto cfFormat = adoptCF(CFStringCreateWithCString(kCFAllocatorDefault, format, kCFStringEncodingUTF8));89 auto result = adoptCF(CFStringCreateWithFormatAndArguments(kCFAllocatorDefault, nullptr, cfFormat.get(), args));90 va_end(argsCopy);91 return result.get();92 }93 #endif94 95 // Do the format once to get the length.96 #if COMPILER(MSVC)97 int result = _vscprintf(format, args);98 #else99 char ch;100 int result = vsnprintf(&ch, 1, format, args);101 #endif102 103 if (!result) {104 va_end(argsCopy);105 return emptyString();106 }107 if (result < 0) {108 va_end(argsCopy);109 return { };110 }111 112 Vector<char, 256> buffer;113 unsigned length = result;114 buffer.grow(length + 1);115 116 // Now do the formatting again, guaranteed to fit.117 vsnprintf(buffer.data(), buffer.size(), format, argsCopy);118 va_end(argsCopy);119 120 ALLOW_NONLITERAL_FORMAT_END121 122 return StringImpl::create(reinterpret_cast<const LChar*>(buffer.data()), length);123 }124 125 }126 127 77 extern "C" { 128 78 … … 444 394 445 395 ALLOW_NONLITERAL_FORMAT_BEGIN 446 String loggingString = WTF::createWithFormatAndArguments(format, args);396 String loggingString = String::format(format, args); 447 397 ALLOW_NONLITERAL_FORMAT_END 448 398 -
trunk/Source/WTF/wtf/HexNumber.h
r242014 r242189 103 103 bool is8Bit() const { return true; } 104 104 template<typename CharacterType> void writeTo(CharacterType* destination) const { StringImpl::copyCharacters(destination, characters(), length()); } 105 String toString() const { return { characters(), length() }; } 105 106 106 107 private: -
trunk/Source/WTF/wtf/text/StringConcatenate.h
r242014 r242189 26 26 #pragma once 27 27 28 #include < cstring>28 #include <string.h> 29 29 #include <wtf/CheckedArithmetic.h> 30 30 #include <wtf/text/AtomicString.h> … … 39 39 namespace WTF { 40 40 41 template<> class StringTypeAdapter<char, void> { 41 template<typename StringType, typename> 42 class StringTypeAdapter; 43 44 template<> 45 class StringTypeAdapter<char, void> { 42 46 public: 43 47 StringTypeAdapter(char character) 44 : m_character { character }48 : m_character(character) 45 49 { 46 50 } … … 48 52 unsigned length() { return 1; } 49 53 bool is8Bit() { return true; } 50 template<typename CharacterType> void writeTo(CharacterType* destination) const { *destination = m_character; } 54 55 void writeTo(LChar* destination) const 56 { 57 *destination = m_character; 58 } 59 60 void writeTo(UChar* destination) const 61 { 62 *destination = m_character; 63 } 64 65 String toString() const { return String(&m_character, 1); } 51 66 52 67 private: … … 54 69 }; 55 70 56 template<> class StringTypeAdapter<UChar, void> { 71 template<> 72 class StringTypeAdapter<UChar, void> { 57 73 public: 58 74 StringTypeAdapter(UChar character) 59 : m_character { character }75 : m_character(character) 60 76 { 61 77 } 62 78 63 79 unsigned length() const { return 1; } 64 bool is8Bit() const { return isLatin1(m_character); }80 bool is8Bit() const { return m_character <= 0xff; } 65 81 66 82 void writeTo(LChar* destination) const 67 83 { 68 84 ASSERT(is8Bit()); 85 *destination = static_cast<LChar>(m_character); 86 } 87 88 void writeTo(UChar* destination) const 89 { 69 90 *destination = m_character; 70 91 } 71 92 72 void writeTo(UChar* destination) const { *destination = m_character; }93 String toString() const { return String(&m_character, 1); } 73 94 74 95 private: … … 76 97 }; 77 98 78 template<> class StringTypeAdapter<const LChar*, void> { 99 template<> 100 class StringTypeAdapter<const LChar*, void> { 79 101 public: 80 102 StringTypeAdapter(const LChar* characters) 81 : m_characters { characters } 82 , m_length { computeLength(characters) } 83 { 103 : m_characters(characters) 104 { 105 size_t length = strlen(reinterpret_cast<const char*>(characters)); 106 RELEASE_ASSERT(length <= String::MaxLength); 107 m_length = static_cast<unsigned>(length); 84 108 } 85 109 86 110 unsigned length() const { return m_length; } 87 111 bool is8Bit() const { return true; } 88 template<typename CharacterType> void writeTo(CharacterType* destination) const { StringImpl::copyCharacters(destination, m_characters, m_length); } 89 90 private: 91 static unsigned computeLength(const LChar* characters) 92 { 93 size_t length = std::strlen(reinterpret_cast<const char*>(characters)); 94 RELEASE_ASSERT(length <= String::MaxLength); 95 return static_cast<unsigned>(length); 96 } 97 112 113 void writeTo(LChar* destination) const 114 { 115 StringView(m_characters, m_length).getCharactersWithUpconvert(destination); 116 } 117 118 void writeTo(UChar* destination) const 119 { 120 StringView(m_characters, m_length).getCharactersWithUpconvert(destination); 121 } 122 123 String toString() const { return String(m_characters, m_length); } 124 125 private: 98 126 const LChar* m_characters; 99 127 unsigned m_length; 100 128 }; 101 129 102 template<> class StringTypeAdapter<const UChar*, void> { 130 template<> 131 class StringTypeAdapter<const UChar*, void> { 103 132 public: 104 133 StringTypeAdapter(const UChar* characters) 105 : m_characters { characters } 106 , m_length { computeLength(characters) } 107 { 108 } 109 110 unsigned length() const { return m_length; } 111 bool is8Bit() const { return !m_length; } 112 void writeTo(LChar*) const { ASSERT(!m_length); } 113 void writeTo(UChar* destination) const { StringImpl::copyCharacters(destination, m_characters, m_length); } 114 115 private: 116 static unsigned computeLength(const UChar* characters) 134 : m_characters(characters) 117 135 { 118 136 size_t length = 0; 119 while ( characters[length])137 while (m_characters[length]) 120 138 ++length; 121 139 RELEASE_ASSERT(length <= String::MaxLength); 122 return static_cast<unsigned>(length); 123 } 124 140 m_length = static_cast<unsigned>(length); 141 } 142 143 unsigned length() const { return m_length; } 144 bool is8Bit() const { return false; } 145 146 NO_RETURN_DUE_TO_CRASH void writeTo(LChar*) const 147 { 148 CRASH(); // FIXME make this a compile-time failure https://bugs.webkit.org/show_bug.cgi?id=165791 149 } 150 151 void writeTo(UChar* destination) const 152 { 153 memcpy(destination, m_characters, m_length * sizeof(UChar)); 154 } 155 156 String toString() const { return String(m_characters, m_length); } 157 158 private: 125 159 const UChar* m_characters; 126 160 unsigned m_length; 127 161 }; 128 162 129 template<> class StringTypeAdapter<const char*, void> : public StringTypeAdapter<const LChar*, void> { 163 template<> 164 class StringTypeAdapter<const char*, void> : public StringTypeAdapter<const LChar*, void> { 130 165 public: 131 166 StringTypeAdapter(const char* characters) 132 : StringTypeAdapter<const LChar*, void> { reinterpret_cast<const LChar*>(characters) } 133 { 134 } 135 }; 136 137 template<> class StringTypeAdapter<char*, void> : public StringTypeAdapter<const char*, void> { 167 : StringTypeAdapter<const LChar*, void>(reinterpret_cast<const LChar*>(characters)) 168 { 169 } 170 }; 171 172 template<> 173 class StringTypeAdapter<char*, void> : public StringTypeAdapter<const char*, void> { 138 174 public: 139 175 StringTypeAdapter(const char* characters) 140 : StringTypeAdapter<const char*, void> { characters } 141 { 142 } 143 }; 144 145 template<> class StringTypeAdapter<ASCIILiteral, void> : public StringTypeAdapter<const char*, void> { 176 : StringTypeAdapter<const char*, void>(characters) 177 { 178 } 179 }; 180 181 template<> 182 class StringTypeAdapter<ASCIILiteral, void> : public StringTypeAdapter<const char*, void> { 146 183 public: 147 184 StringTypeAdapter(ASCIILiteral characters) 148 : StringTypeAdapter<const char*, void> { characters } 149 { 150 } 151 }; 152 153 template<> class StringTypeAdapter<Vector<char>, void> { 185 : StringTypeAdapter<const char*, void>(characters) 186 { 187 } 188 }; 189 190 template<> 191 class StringTypeAdapter<Vector<char>, void> { 154 192 public: 155 193 StringTypeAdapter(const Vector<char>& vector) 156 : m_vector { vector }194 : m_vector(vector) 157 195 { 158 196 } … … 160 198 size_t length() const { return m_vector.size(); } 161 199 bool is8Bit() const { return true; } 162 template<typename CharacterType> void writeTo(CharacterType* destination) const { StringImpl::copyCharacters(destination, characters(), length()); } 163 164 private: 165 const LChar* characters() const 166 { 167 return reinterpret_cast<const LChar*>(m_vector.data()); 168 } 169 200 201 void writeTo(LChar* destination) const 202 { 203 StringView(reinterpret_cast<const LChar*>(m_vector.data()), m_vector.size()).getCharactersWithUpconvert(destination); 204 } 205 206 void writeTo(UChar* destination) const 207 { 208 StringView(reinterpret_cast<const LChar*>(m_vector.data()), m_vector.size()).getCharactersWithUpconvert(destination); 209 } 210 211 String toString() const { return String(m_vector.data(), m_vector.size()); } 212 213 private: 170 214 const Vector<char>& m_vector; 171 215 }; 172 216 173 template<> class StringTypeAdapter<String, void> { 217 template<> 218 class StringTypeAdapter<String, void> { 174 219 public: 175 220 StringTypeAdapter(const String& string) 176 : m_string { string }221 : m_string(string) 177 222 { 178 223 } … … 180 225 unsigned length() const { return m_string.length(); } 181 226 bool is8Bit() const { return m_string.isNull() || m_string.is8Bit(); } 182 template<typename CharacterType> void writeTo(CharacterType* destination) const 183 { 184 StringView { m_string }.getCharactersWithUpconvert(destination); 227 228 void writeTo(LChar* destination) const 229 { 230 StringView(m_string).getCharactersWithUpconvert(destination); 185 231 WTF_STRINGTYPEADAPTER_COPIED_WTF_STRING(); 186 232 } 187 233 234 void writeTo(UChar* destination) const 235 { 236 StringView(m_string).getCharactersWithUpconvert(destination); 237 WTF_STRINGTYPEADAPTER_COPIED_WTF_STRING(); 238 } 239 240 String toString() const { return m_string; } 241 188 242 private: 189 243 const String& m_string; 190 244 }; 191 245 192 template<> class StringTypeAdapter<AtomicString, void> : public StringTypeAdapter<String, void> { 246 template<> 247 class StringTypeAdapter<AtomicString, void> : public StringTypeAdapter<String, void> { 193 248 public: 194 249 StringTypeAdapter(const AtomicString& string) 195 : StringTypeAdapter<String, void> { string.string() } 196 { 197 } 198 }; 199 200 template<typename UnderlyingAdapterType> struct PaddingSpecification { 201 LChar character; 202 unsigned length; 203 UnderlyingAdapterType underlyingAdapter; 204 }; 205 206 template<typename StringType> PaddingSpecification<StringTypeAdapter<StringType>> pad(char character, unsigned length, StringType adapter) 207 { 208 return { static_cast<LChar>(character), length, StringTypeAdapter<StringType> { adapter } }; 209 } 210 211 template<typename UnderlyingAdapterType> class StringTypeAdapter<PaddingSpecification<UnderlyingAdapterType>> { 212 public: 213 StringTypeAdapter(const PaddingSpecification<UnderlyingAdapterType>& padding) 214 : m_padding { padding } 215 { 216 } 217 218 unsigned length() const { return std::max(m_padding.length, m_padding.underlyingAdapter.length()); } 219 bool is8Bit() const { return m_padding.underlyingAdapter.is8Bit(); } 220 template<typename CharacterType> void writeTo(CharacterType* destination) const 221 { 222 unsigned underlyingLength = m_padding.underlyingAdapter.length(); 223 unsigned count = 0; 224 if (underlyingLength < m_padding.length) { 225 count = m_padding.length - underlyingLength; 226 for (unsigned i = 0; i < count; ++i) 227 destination[i] = m_padding.character; 228 } 229 m_padding.underlyingAdapter.writeTo(destination + count); 230 } 231 232 private: 233 const PaddingSpecification<UnderlyingAdapterType>& m_padding; 250 : StringTypeAdapter<String, void>(string.string()) 251 { 252 } 234 253 }; 235 254 … … 296 315 } 297 316 317 // Convenience only. 318 template<typename StringType> 319 String makeString(StringType string) 320 { 321 return String(string); 322 } 323 298 324 template<typename... StringTypes> 299 325 String makeString(StringTypes... strings) … … 308 334 309 335 using WTF::makeString; 310 using WTF::pad;311 336 using WTF::tryMakeString; 312 337 -
trunk/Source/WTF/wtf/text/StringConcatenateNumbers.h
r242014 r242189 43 43 bool is8Bit() const { return true; } 44 44 template<typename CharacterType> void writeTo(CharacterType* destination) const { writeNumberToBufferSigned(m_number, destination); } 45 String toString() const { return String::number(m_number); } 45 46 46 47 private: … … 59 60 bool is8Bit() const { return true; } 60 61 template<typename CharacterType> void writeTo(CharacterType* destination) const { writeNumberToBufferUnsigned(m_number, destination); } 62 String toString() const { return String::number(m_number); } 61 63 62 64 private: … … 70 72 { 71 73 numberToString(number, m_buffer); 72 m_length = st d::strlen(m_buffer);74 m_length = strlen(m_buffer); 73 75 } 74 76 … … 76 78 bool is8Bit() const { return true; } 77 79 template<typename CharacterType> void writeTo(CharacterType* destination) const { StringImpl::copyCharacters(destination, buffer(), m_length); } 80 String toString() const { return { buffer(), m_length }; } 78 81 79 82 private: … … 90 93 FormattedNumber numberFormatter; 91 94 numberToFixedPrecisionString(number, significantFigures, numberFormatter.m_buffer, trailingZerosTruncatingPolicy == TruncateTrailingZeros); 92 numberFormatter.m_length = st d::strlen(numberFormatter.m_buffer);95 numberFormatter.m_length = strlen(numberFormatter.m_buffer); 93 96 return numberFormatter; 94 97 } … … 98 101 FormattedNumber numberFormatter; 99 102 numberToFixedWidthString(number, decimalPlaces, numberFormatter.m_buffer); 100 numberFormatter.m_length = st d::strlen(numberFormatter.m_buffer);103 numberFormatter.m_length = strlen(numberFormatter.m_buffer); 101 104 return numberFormatter; 102 105 } … … 110 113 }; 111 114 112 template<> class StringTypeAdapter<FormattedNumber> { 115 template<> 116 class StringTypeAdapter<FormattedNumber> { 113 117 public: 114 118 StringTypeAdapter(const FormattedNumber& number) … … 120 124 bool is8Bit() const { return true; } 121 125 template<typename CharacterType> void writeTo(CharacterType* destination) const { StringImpl::copyCharacters(destination, m_number.buffer(), m_number.length()); } 126 String toString() const { return { m_number.buffer(), m_number.length() }; } 122 127 123 128 private: -
trunk/Source/WTF/wtf/text/StringOperators.h
r242014 r242189 24 24 namespace WTF { 25 25 26 template<typename StringType1, typename StringType2> class StringAppend { 26 template<typename StringType1, typename StringType2> 27 class StringAppend { 27 28 public: 28 29 StringAppend(StringType1 string1, StringType2 string2) 29 : m_string1 { string1 }30 , m_string2 { string2 }30 : m_string1(string1) 31 , m_string2(string2) 31 32 { 32 33 } … … 85 86 public: 86 87 StringTypeAdapter<StringAppend<StringType1, StringType2>>(StringAppend<StringType1, StringType2>& buffer) 87 : m_buffer { buffer }88 : m_buffer(buffer) 88 89 { 89 90 } 90 91 91 unsigned length() const { return m_buffer.length(); } 92 bool is8Bit() const { return m_buffer.is8Bit(); } 93 template<typename CharacterType> void writeTo(CharacterType* destination) const { m_buffer.writeTo(destination); } 92 unsigned length() { return m_buffer.length(); } 93 94 bool is8Bit() { return m_buffer.is8Bit(); } 95 96 void writeTo(LChar* destination) { m_buffer.writeTo(destination); } 97 void writeTo(UChar* destination) { m_buffer.writeTo(destination); } 98 99 String toString() const { return m_buffer; } 94 100 95 101 private: -
trunk/Source/WTF/wtf/text/StringView.h
r242014 r242189 566 566 567 567 #if !CHECK_STRINGVIEW_LIFETIME 568 569 568 inline void StringView::invalidate(const StringImpl&) 570 569 { 571 570 } 572 573 571 #endif 572 573 template<typename StringType, typename> class StringTypeAdapter; 574 574 575 575 template<> class StringTypeAdapter<StringView, void> { 576 576 public: 577 577 StringTypeAdapter(StringView string) 578 : m_string { string }578 : m_string(string) 579 579 { 580 580 } … … 582 582 unsigned length() { return m_string.length(); } 583 583 bool is8Bit() { return m_string.is8Bit(); } 584 template<typename CharacterType> void writeTo(CharacterType* destination) { m_string.getCharactersWithUpconvert(destination); } 584 void writeTo(LChar* destination) { m_string.getCharactersWithUpconvert(destination); } 585 void writeTo(UChar* destination) { m_string.getCharactersWithUpconvert(destination); } 586 587 String toString() const { return m_string.toString(); } 585 588 586 589 private: -
trunk/Source/WTF/wtf/text/WTFString.cpp
r242014 r242189 450 450 } 451 451 452 WTF_ATTRIBUTE_PRINTF(1, 0) static String createWithFormatAndArguments(const char *format, va_list args) 453 { 454 va_list argsCopy; 455 va_copy(argsCopy, args); 456 457 ALLOW_NONLITERAL_FORMAT_BEGIN 458 459 #if USE(CF) && !OS(WINDOWS) 460 if (strstr(format, "%@")) { 461 auto cfFormat = adoptCF(CFStringCreateWithCString(kCFAllocatorDefault, format, kCFStringEncodingUTF8)); 462 auto result = adoptCF(CFStringCreateWithFormatAndArguments(kCFAllocatorDefault, nullptr, cfFormat.get(), args)); 463 va_end(argsCopy); 464 return result.get(); 465 } 466 #endif 467 468 // Do the format once to get the length. 469 #if COMPILER(MSVC) 470 int result = _vscprintf(format, args); 471 #else 472 char ch; 473 int result = vsnprintf(&ch, 1, format, args); 474 #endif 475 476 if (!result) { 477 va_end(argsCopy); 478 return emptyString(); 479 } 480 if (result < 0) { 481 va_end(argsCopy); 482 return String(); 483 } 484 485 Vector<char, 256> buffer; 486 unsigned len = result; 487 buffer.grow(len + 1); 488 489 // Now do the formatting again, guaranteed to fit. 490 vsnprintf(buffer.data(), buffer.size(), format, argsCopy); 491 va_end(argsCopy); 492 493 ALLOW_NONLITERAL_FORMAT_END 494 495 return StringImpl::create(reinterpret_cast<const LChar*>(buffer.data()), len); 496 } 497 498 String String::format(const char *format, ...) 499 { 500 va_list args; 501 va_start(args, format); 502 String result = createWithFormatAndArguments(format, args); 503 va_end(args); 504 return result; 505 } 506 452 507 String String::number(int number) 453 508 { -
trunk/Source/WTF/wtf/text/WTFString.h
r242014 r242189 261 261 // Use convertToASCIILowercase instead if ASCII case insensitive comparison is desired. 262 262 WTF_EXPORT_PRIVATE String foldCase() const; 263 264 WTF_EXPORT_PRIVATE static String format(const char *, ...) WTF_ATTRIBUTE_PRINTF(1, 2); 263 265 264 266 // Returns an uninitialized string. The characters needs to be written -
trunk/Source/WebCore/ChangeLog
r242184 r242189 1 2019-02-27 Simon Fraser <simon.fraser@apple.com> 2 3 Roll out r242014; it caused crashes in compositing logging (webkit.org/b/195141) 4 5 * dom/Document.cpp: 6 (WebCore::Document::lastModified const): 7 * html/FTPDirectoryDocument.cpp: 8 (WebCore::processFileDateString): 9 * mathml/MathMLElement.cpp: 10 (WebCore::convertToPercentageIfNeeded): 11 (WebCore::MathMLElement::collectStyleForPresentationAttribute): 12 * page/cocoa/ResourceUsageOverlayCocoa.mm: 13 (WebCore::ResourceUsageOverlay::platformDraw): 14 * page/linux/ResourceUsageOverlayLinux.cpp: 15 (WebCore::cpuUsageString): 16 (WebCore::gcTimerString): 17 * platform/DateComponents.cpp: 18 (WebCore::DateComponents::toStringForTime const): 19 (WebCore::DateComponents::toString const): 20 * platform/LocalizedStrings.cpp: 21 (WebCore::localizedString): 22 * platform/audio/HRTFElevation.cpp: 23 (WebCore::HRTFElevation::calculateKernelsForAzimuthElevation): 24 * platform/mock/MockRealtimeVideoSource.cpp: 25 (WebCore::MockRealtimeVideoSource::drawText): 26 * rendering/RenderLayerCompositor.cpp: 27 (WebCore::RenderLayerCompositor::logLayerInfo): 28 * rendering/RenderTheme.cpp: 29 (WebCore::RenderTheme::formatMediaControlsTime const): 30 1 31 2019-02-27 Zalan Bujtas <zalan@apple.com> 2 32 -
trunk/Source/WebCore/dom/Document.cpp
r242137 r242189 4997 4997 dateTime = loader()->response().lastModified(); 4998 4998 4999 // FIXME: If this document came from the file system, the HTML specification tells 5000 // us to read the last modification date from the file system. 4999 // FIXME: If this document came from the file system, the HTML5 5000 // specification tells us to read the last modification date from the file 5001 // system. 5001 5002 if (!dateTime) 5002 5003 dateTime = WallTime::now(); … … 5004 5005 auto ctime = dateTime.value().secondsSinceEpoch().secondsAs<time_t>(); 5005 5006 auto localDateTime = std::localtime(&ctime); 5006 return makeString(pad('0', 2, localDateTime->tm_mon + 1), '/', 5007 pad('0', 2, localDateTime->tm_mday), '/', 5008 pad('0', 4, 1900 + localDateTime->tm_year), ' ', 5009 pad('0', 2, localDateTime->tm_hour), ':', 5010 pad('0', 2, localDateTime->tm_min), ':', 5011 pad('0', 2, localDateTime->tm_sec)); 5007 return String::format("%02d/%02d/%04d %02d:%02d:%02d", localDateTime->tm_mon + 1, localDateTime->tm_mday, 1900 + localDateTime->tm_year, localDateTime->tm_hour, localDateTime->tm_min, localDateTime->tm_sec); 5012 5008 } 5013 5009 -
trunk/Source/WebCore/html/FTPDirectoryDocument.cpp
r242014 r242189 211 211 if (hour == 0) 212 212 hour = 12; 213 timeOfDay = makeString(", ", hour, ':', pad('0', 2, fileTime.tm_min), " AM");213 timeOfDay = String::format(", %i:%02i AM", hour, fileTime.tm_min); 214 214 } else { 215 215 hour = hour - 12; 216 216 if (hour == 0) 217 217 hour = 12; 218 timeOfDay = makeString(", ", hour, ':', pad('0', 2, fileTime.tm_min), " PM");218 timeOfDay = String::format(", %i:%02i PM", hour, fileTime.tm_min); 219 219 } 220 220 } -
trunk/Source/WebCore/mathml/MathMLElement.cpp
r242014 r242189 40 40 #include "RenderTableCell.h" 41 41 #include <wtf/IsoMallocInlines.h> 42 #include <wtf/text/StringConcatenateNumbers.h>43 42 44 43 namespace WebCore { … … 101 100 static String convertToPercentageIfNeeded(const AtomicString& value) 102 101 { 103 // FIXME: Might be better to use double than float.104 // FIXME: Might be better to use "shortest" numeric formatting instead of fixed width.105 102 bool ok = false; 106 103 float unitlessValue = value.toFloat(&ok); 107 if ( !ok)108 return value;109 return makeString(FormattedNumber::fixedWidth(unitlessValue * 100, 3), '%');104 if (ok) 105 return String::format("%.3f%%", unitlessValue * 100.0); 106 return value; 110 107 } 111 108 … … 120 117 } else if (name == mathcolorAttr) 121 118 addPropertyToPresentationAttributeStyle(style, CSSPropertyColor, value); 122 // FIXME: The following are deprecated attributes that should lose if there is a conflict with a non-deprecated attribute.119 // FIXME: deprecated attributes that should loose in a conflict with a non deprecated attribute 123 120 else if (name == fontsizeAttr) 124 121 addPropertyToPresentationAttributeStyle(style, CSSPropertyFontSize, value); … … 138 135 } else { 139 136 ASSERT(!isPresentationAttribute(name)); 140 StyledElement::collectStyleForPresentationAttribute(name, value, style); 137 StyledElement::collectStyleForPresentationAttribute(name, value 138 , style); 141 139 } 142 140 } -
trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm
r242014 r242189 469 469 size_t external = category.externalSize.last(); 470 470 471 String label = makeString(pad(' ', 11, category.name), ": ", formatByteNumber(dirty));471 String label = String::format("% 11s: %s", category.name.ascii().data(), formatByteNumber(dirty).ascii().data()); 472 472 if (external) 473 473 label = label + makeString(" + ", formatByteNumber(external)); -
trunk/Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp
r242014 r242189 47 47 if (cpuUsage < 0) 48 48 return "<unknown>"_s; 49 return makeString(FormattedNumber::fixedWidth(cpuUsage, 1), '%');49 return String::format("%.1f%%", cpuUsage); 50 50 } 51 51 … … 65 65 if (std::isnan(timerFireDate)) 66 66 return "[not scheduled]"_s; 67 return String:: number((timerFireDate - now).seconds());67 return String::format("%g", (timerFireDate - now).seconds()); 68 68 } 69 69 -
trunk/Source/WebCore/platform/DateComponents.cpp
r242014 r242189 36 36 #include <wtf/DateMath.h> 37 37 #include <wtf/MathExtras.h> 38 #include <wtf/text/ StringConcatenateNumbers.h>38 #include <wtf/text/WTFString.h> 39 39 40 40 namespace WebCore { … … 694 694 #endif 695 695 case None: 696 return makeString(pad('0', 2, m_hour), ':', pad('0', 2, m_minute));696 return String::format("%02d:%02d", m_hour, m_minute); 697 697 case Second: 698 return makeString(pad('0', 2, m_hour), ':', pad('0', 2, m_minute), ':', pad('0', 2, m_second));698 return String::format("%02d:%02d:%02d", m_hour, m_minute, m_second); 699 699 case Millisecond: 700 return makeString(pad('0', 2, m_hour), ':', pad('0', 2, m_minute), ':', pad('0', 2, m_second), '.', pad('0', 3, m_millisecond));700 return String::format("%02d:%02d:%02d.%03d", m_hour, m_minute, m_second, m_millisecond); 701 701 } 702 702 } … … 706 706 switch (m_type) { 707 707 case Date: 708 return makeString(pad('0', 4, m_year), '-', pad('0', 2, m_month + 1), '-', pad('0', 2, m_monthDay));708 return String::format("%04d-%02d-%02d", m_year, m_month + 1, m_monthDay); 709 709 case DateTime: 710 return makeString(pad('0', 4, m_year), '-', pad('0', 2, m_month + 1), '-', pad('0', 2, m_monthDay), 'T', toStringForTime(format), 'Z'); 710 return String::format("%04d-%02d-%02dT", m_year, m_month + 1, m_monthDay) 711 + toStringForTime(format) + "Z"_str; 711 712 case DateTimeLocal: 712 return makeString(pad('0', 4, m_year), '-', pad('0', 2, m_month + 1), '-', pad('0', 2, m_monthDay), 'T', toStringForTime(format)); 713 return String::format("%04d-%02d-%02dT", m_year, m_month + 1, m_monthDay) 714 + toStringForTime(format); 713 715 case Month: 714 return makeString(pad('0', 4, m_year), '-', pad('0', 2, m_month + 1));716 return String::format("%04d-%02d", m_year, m_month + 1); 715 717 case Time: 716 718 return toStringForTime(format); 717 719 case Week: 718 return makeString(pad('0', 4, m_year), "-W", pad('0', 2, m_week));720 return String::format("%04d-W%02d", m_year, m_week); 719 721 case Invalid: 720 722 break; -
trunk/Source/WebCore/platform/LocalizedStrings.cpp
r242014 r242189 44 44 namespace WebCore { 45 45 46 // Because |format| is used as the second parameter to va_start, it cannot be a reference 46 // We can't use String::format for two reasons: 47 // 1) It doesn't handle non-ASCII characters in the format string. 48 // 2) It doesn't handle the %2$d syntax. 49 // Note that because |format| is used as the second parameter to va_start, it cannot be a reference 47 50 // type according to section 18.7/3 of the C++ N1905 standard. 48 51 String formatLocalizedString(String format, ...) … … 71 74 72 75 #if !USE(CF) 73 74 76 String localizedString(const char* key) 75 77 { 76 78 return String::fromUTF8(key, strlen(key)); 77 79 } 78 79 80 #endif 80 81 -
trunk/Source/WebCore/platform/audio/HRTFElevation.cpp
r242014 r242189 177 177 AudioChannel* rightEarImpulseResponse = response->channel(AudioBus::ChannelRight); 178 178 #else 179 String resourceName = makeString("IRC_", subjectName, "_C_R0195_T", pad('0', 3, azimuth), "_P", pad('0', 3, positiveElevation));179 String resourceName = String::format("IRC_%s_C_R0195_T%03d_P%03d", subjectName.utf8().data(), azimuth, positiveElevation); 180 180 181 181 RefPtr<AudioBus> impulseResponse(AudioBus::loadPlatformResource(resourceName.utf8().data(), sampleRate)); -
trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp
r242014 r242189 351 351 context.setFillColor(Color::white); 352 352 context.setTextDrawingMode(TextModeFill); 353 String string = makeString(pad('0', 2, hours), ':', pad('0', 2, minutes), ':', pad('0', 2, seconds), '.', pad('0', 3, milliseconds % 1000));353 String string = String::format("%02u:%02u:%02u.%03u", hours, minutes, seconds, milliseconds % 1000); 354 354 context.drawText(timeFont, TextRun((StringView(string))), timeLocation); 355 355 356 string = makeString(pad('0', 6, m_frameNumber++));356 string = String::format("%06u", m_frameNumber++); 357 357 timeLocation.move(0, m_baseFontSize); 358 358 context.drawText(timeFont, TextRun((StringView(string))), timeLocation); -
trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp
r242014 r242189 61 61 #include "TiledBacking.h" 62 62 #include "TransformState.h" 63 #include <wtf/HexNumber.h>64 63 #include <wtf/MemoryPressureHandler.h> 65 64 #include <wtf/SetForScope.h> … … 1325 1324 1326 1325 StringBuilder logString; 1327 logString.append(makeString(pad(' ', 12 + depth * 2, hex(reinterpret_cast<uintptr_t>(&layer))), " id ", backing->graphicsLayer()->primaryLayerID(), " (", FormattedNumber::fixedWidth(absoluteBounds.x().toFloat(), 3), ',', FormattedNumber::fixedWidth(absoluteBounds.y().toFloat(), 3), '-', FormattedNumber::fixedWidth(absoluteBounds.maxX().toFloat(), 3), ',', FormattedNumber::fixedWidth(absoluteBounds.maxY().toFloat(), 3), ") ", FormattedNumber::fixedWidth(backing->backingStoreMemoryEstimate() / 1024, 2), "KB")); 1328 1326 logString.append(String::format("%*p id %" PRIu64 " (%.3f,%.3f-%.3f,%.3f) %.2fKB", 12 + depth * 2, &layer, backing->graphicsLayer()->primaryLayerID(), 1327 absoluteBounds.x().toFloat(), absoluteBounds.y().toFloat(), absoluteBounds.maxX().toFloat(), absoluteBounds.maxY().toFloat(), 1328 backing->backingStoreMemoryEstimate() / 1024)); 1329 1329 1330 if (!layer.renderer().style().hasAutoZIndex()) 1330 1331 logString.append(makeString(" z-index: ", layer.renderer().style().zIndex())); -
trunk/Source/WebCore/rendering/RenderTheme.cpp
r242014 r242189 47 47 #include <wtf/FileSystem.h> 48 48 #include <wtf/NeverDestroyed.h> 49 #include <wtf/text/StringConcatenateNumbers.h>50 49 51 50 #if ENABLE(METER_ELEMENT) … … 570 569 if (!std::isfinite(time)) 571 570 time = 0; 572 // FIXME: Seems like it would be better to use std::lround here. 573 int seconds = static_cast<int>(std::abs(time)); 571 int seconds = (int)fabsf(time); 574 572 int hours = seconds / (60 * 60); 575 573 int minutes = (seconds / 60) % 60; 576 574 seconds %= 60; 577 if (hours) 578 return makeString((time < 0 ? "-" : ""), hours, ':', pad('0', 2, minutes), ':', pad('0', 2, seconds)); 579 return makeString((time < 0 ? "-" : ""), pad('0', 2, minutes), ':', pad('0', 2, seconds)); 575 if (hours) { 576 if (hours > 9) 577 return String::format("%s%02d:%02d:%02d", (time < 0 ? "-" : ""), hours, minutes, seconds); 578 579 return String::format("%s%01d:%02d:%02d", (time < 0 ? "-" : ""), hours, minutes, seconds); 580 } 581 582 return String::format("%s%02d:%02d", (time < 0 ? "-" : ""), minutes, seconds); 580 583 } 581 584 -
trunk/Source/WebKit/ChangeLog
r242187 r242189 1 2019-02-27 Simon Fraser <simon.fraser@apple.com> 2 3 Roll out r242014; it caused crashes in compositing logging (webkit.org/b/195141) 4 5 * UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm: 6 (WebKit::LocalAuthenticator::getAssertion): 7 1 8 2019-02-27 Michael Catanzaro <mcatanzaro@igalia.com> 2 9 -
trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm
r242014 r242189 401 401 weakThis->continueGetAssertionAfterUserConsented(consent, context, credentialId, userhandle); 402 402 }; 403 NSData *idData = selectedCredentialAttributes[(id)kSecAttrApplicationTag];404 StringView idStringView { static_cast<const LChar*>([idData bytes]), static_cast<unsigned>([idData length]) };405 403 m_connection->getUserConsent( 406 makeString("Log into ", requestData().requestOptions.rpId, " with ", idStringView, '.'),404 String::format("Log into %s with %s.", requestData().requestOptions.rpId.utf8().data(), selectedCredentialAttributes[(id)kSecAttrApplicationTag]), 407 405 (__bridge SecAccessControlRef)selectedCredentialAttributes[(id)kSecAttrAccessControl], 408 406 WTFMove(callback)); -
trunk/Source/WebKitLegacy/win/ChangeLog
r242082 r242189 1 2019-02-27 Simon Fraser <simon.fraser@apple.com> 2 3 Roll out r242014; it caused crashes in compositing logging (webkit.org/b/195141) 4 5 * FullscreenVideoController.cpp: 6 (timeToString): 7 1 8 2019-02-26 Philippe Normand <pnormand@igalia.com> 2 9 -
trunk/Source/WebKitLegacy/win/FullscreenVideoController.cpp
r242014 r242189 42 42 #include <windowsx.h> 43 43 #include <wtf/StdLibExtras.h> 44 #include <wtf/text/StringConcatenateNumbers.h>45 44 46 45 #if USE(CA) … … 472 471 int minutes = (seconds / 60) % 60; 473 472 seconds %= 60; 474 if (hours) 475 return makeString((time < 0 ? "-" : ""), hours, ':', pad('0', 2, minutes), ':', pad('0', 2, seconds)); 476 return makeString((time < 0 ? "-" : ""), pad('0', 2, minutes), ':', pad('0', 2, seconds)); 473 474 if (hours) { 475 if (hours > 9) 476 return String::format("%s%02d:%02d:%02d", (time < 0 ? "-" : ""), hours, minutes, seconds); 477 return String::format("%s%01d:%02d:%02d", (time < 0 ? "-" : ""), hours, minutes, seconds); 478 } 479 480 return String::format("%s%02d:%02d", (time < 0 ? "-" : ""), minutes, seconds); 477 481 } 478 482
Note: See TracChangeset
for help on using the changeset viewer.