Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (242188 => 242189)
--- trunk/Source/_javascript_Core/ChangeLog 2019-02-28 03:42:46 UTC (rev 242188)
+++ trunk/Source/_javascript_Core/ChangeLog 2019-02-28 04:35:25 UTC (rev 242189)
@@ -1,3 +1,10 @@
+2019-02-27 Simon Fraser <[email protected]>
+
+ Roll out r242014; it caused crashes in compositing logging (webkit.org/b/195141)
+
+ * bytecode/CodeBlock.cpp:
+ (JSC::CodeBlock::nameForRegister):
+
2019-02-27 Antoine Quint <[email protected]>
Support Pointer Events on macOS
Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp (242188 => 242189)
--- trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp 2019-02-28 03:42:46 UTC (rev 242188)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp 2019-02-28 04:35:25 UTC (rev 242189)
@@ -92,7 +92,6 @@
#include <wtf/Forward.h>
#include <wtf/SimpleStats.h>
#include <wtf/StringPrintStream.h>
-#include <wtf/text/StringConcatenateNumbers.h>
#include <wtf/text/UniquedStringImpl.h>
#if ENABLE(ASSEMBLER)
@@ -2889,9 +2888,9 @@
if (virtualRegister == thisRegister())
return "this"_s;
if (virtualRegister.isArgument())
- return makeString("arguments[", pad(' ', 3, virtualRegister.toArgument()), ']');
+ return String::format("arguments[%3d]", virtualRegister.toArgument());
- return emptyString();
+ return "";
}
ValueProfile* CodeBlock::tryGetValueProfileForBytecodeOffset(int bytecodeOffset)
Modified: trunk/Source/WTF/ChangeLog (242188 => 242189)
--- trunk/Source/WTF/ChangeLog 2019-02-28 03:42:46 UTC (rev 242188)
+++ trunk/Source/WTF/ChangeLog 2019-02-28 04:35:25 UTC (rev 242189)
@@ -1,3 +1,31 @@
+2019-02-27 Simon Fraser <[email protected]>
+
+ Roll out r242014; it caused crashes in compositing logging (webkit.org/b/195141)
+
+ * wtf/Assertions.cpp:
+ (WTF::createWithFormatAndArguments): Deleted.
+ * wtf/HexNumber.h:
+ (WTF::StringTypeAdapter<HexNumberBuffer>::toString const):
+ * wtf/text/StringConcatenate.h:
+ (WTF::makeString):
+ (WTF::pad): Deleted.
+ (WTF::StringTypeAdapter<PaddingSpecification<UnderlyingAdapterType>>::StringTypeAdapter): Deleted.
+ (WTF::StringTypeAdapter<PaddingSpecification<UnderlyingAdapterType>>::length const): Deleted.
+ (WTF::StringTypeAdapter<PaddingSpecification<UnderlyingAdapterType>>::is8Bit const): Deleted.
+ (WTF::StringTypeAdapter<PaddingSpecification<UnderlyingAdapterType>>::writeTo const): Deleted.
+ * wtf/text/StringConcatenateNumbers.h:
+ (WTF::FormattedNumber::fixedPrecision):
+ (WTF::FormattedNumber::fixedWidth):
+ (WTF::StringTypeAdapter<FormattedNumber>::toString const):
+ * wtf/text/StringOperators.h:
+ (WTF::StringAppend::StringAppend):
+ * wtf/text/StringView.h:
+ (WTF::StringView::invalidate):
+ * wtf/text/WTFString.cpp:
+ (WTF::createWithFormatAndArguments):
+ (WTF::String::format):
+ * wtf/text/WTFString.h:
+
2019-02-26 Mark Lam <[email protected]>
Remove remaining poisoning code.
Modified: trunk/Source/WTF/wtf/Assertions.cpp (242188 => 242189)
--- trunk/Source/WTF/wtf/Assertions.cpp 2019-02-28 03:42:46 UTC (rev 242188)
+++ trunk/Source/WTF/wtf/Assertions.cpp 2019-02-28 04:35:25 UTC (rev 242189)
@@ -74,56 +74,6 @@
#include <unistd.h>
#endif
-namespace WTF {
-
-WTF_ATTRIBUTE_PRINTF(1, 0) static String createWithFormatAndArguments(const char* format, va_list args)
-{
- va_list argsCopy;
- va_copy(argsCopy, args);
-
- ALLOW_NONLITERAL_FORMAT_BEGIN
-
-#if USE(CF) && !OS(WINDOWS)
- if (strstr(format, "%@")) {
- auto cfFormat = adoptCF(CFStringCreateWithCString(kCFAllocatorDefault, format, kCFStringEncodingUTF8));
- auto result = adoptCF(CFStringCreateWithFormatAndArguments(kCFAllocatorDefault, nullptr, cfFormat.get(), args));
- va_end(argsCopy);
- return result.get();
- }
-#endif
-
- // Do the format once to get the length.
-#if COMPILER(MSVC)
- int result = _vscprintf(format, args);
-#else
- char ch;
- int result = vsnprintf(&ch, 1, format, args);
-#endif
-
- if (!result) {
- va_end(argsCopy);
- return emptyString();
- }
- if (result < 0) {
- va_end(argsCopy);
- return { };
- }
-
- Vector<char, 256> buffer;
- unsigned length = result;
- buffer.grow(length + 1);
-
- // Now do the formatting again, guaranteed to fit.
- vsnprintf(buffer.data(), buffer.size(), format, argsCopy);
- va_end(argsCopy);
-
- ALLOW_NONLITERAL_FORMAT_END
-
- return StringImpl::create(reinterpret_cast<const LChar*>(buffer.data()), length);
-}
-
-}
-
extern "C" {
static void logToStderr(const char* buffer)
@@ -443,7 +393,7 @@
ASSERT(channel->state == WTFLogChannelOnWithAccumulation);
ALLOW_NONLITERAL_FORMAT_BEGIN
- String loggingString = WTF::createWithFormatAndArguments(format, args);
+ String loggingString = String::format(format, args);
ALLOW_NONLITERAL_FORMAT_END
if (!loggingString.endsWith('\n'))
Modified: trunk/Source/WTF/wtf/HexNumber.h (242188 => 242189)
--- trunk/Source/WTF/wtf/HexNumber.h 2019-02-28 03:42:46 UTC (rev 242188)
+++ trunk/Source/WTF/wtf/HexNumber.h 2019-02-28 04:35:25 UTC (rev 242189)
@@ -102,6 +102,7 @@
unsigned length() const { return m_buffer.length; }
bool is8Bit() const { return true; }
template<typename CharacterType> void writeTo(CharacterType* destination) const { StringImpl::copyCharacters(destination, characters(), length()); }
+ String toString() const { return { characters(), length() }; }
private:
const LChar* characters() const { return &*(m_buffer.characters.end() - length()); }
Modified: trunk/Source/WTF/wtf/text/StringConcatenate.h (242188 => 242189)
--- trunk/Source/WTF/wtf/text/StringConcatenate.h 2019-02-28 03:42:46 UTC (rev 242188)
+++ trunk/Source/WTF/wtf/text/StringConcatenate.h 2019-02-28 04:35:25 UTC (rev 242189)
@@ -25,7 +25,7 @@
#pragma once
-#include <cstring>
+#include <string.h>
#include <wtf/CheckedArithmetic.h>
#include <wtf/text/AtomicString.h>
#include <wtf/text/StringView.h>
@@ -38,201 +38,220 @@
namespace WTF {
-template<> class StringTypeAdapter<char, void> {
+template<typename StringType, typename>
+class StringTypeAdapter;
+
+template<>
+class StringTypeAdapter<char, void> {
public:
StringTypeAdapter(char character)
- : m_character { character }
+ : m_character(character)
{
}
unsigned length() { return 1; }
bool is8Bit() { return true; }
- template<typename CharacterType> void writeTo(CharacterType* destination) const { *destination = m_character; }
+ void writeTo(LChar* destination) const
+ {
+ *destination = m_character;
+ }
+
+ void writeTo(UChar* destination) const
+ {
+ *destination = m_character;
+ }
+
+ String toString() const { return String(&m_character, 1); }
+
private:
char m_character;
};
-template<> class StringTypeAdapter<UChar, void> {
+template<>
+class StringTypeAdapter<UChar, void> {
public:
StringTypeAdapter(UChar character)
- : m_character { character }
+ : m_character(character)
{
}
unsigned length() const { return 1; }
- bool is8Bit() const { return isLatin1(m_character); }
+ bool is8Bit() const { return m_character <= 0xff; }
void writeTo(LChar* destination) const
{
ASSERT(is8Bit());
+ *destination = static_cast<LChar>(m_character);
+ }
+
+ void writeTo(UChar* destination) const
+ {
*destination = m_character;
}
- void writeTo(UChar* destination) const { *destination = m_character; }
+ String toString() const { return String(&m_character, 1); }
private:
UChar m_character;
};
-template<> class StringTypeAdapter<const LChar*, void> {
+template<>
+class StringTypeAdapter<const LChar*, void> {
public:
StringTypeAdapter(const LChar* characters)
- : m_characters { characters }
- , m_length { computeLength(characters) }
+ : m_characters(characters)
{
+ size_t length = strlen(reinterpret_cast<const char*>(characters));
+ RELEASE_ASSERT(length <= String::MaxLength);
+ m_length = static_cast<unsigned>(length);
}
unsigned length() const { return m_length; }
bool is8Bit() const { return true; }
- template<typename CharacterType> void writeTo(CharacterType* destination) const { StringImpl::copyCharacters(destination, m_characters, m_length); }
-private:
- static unsigned computeLength(const LChar* characters)
+ void writeTo(LChar* destination) const
{
- size_t length = std::strlen(reinterpret_cast<const char*>(characters));
- RELEASE_ASSERT(length <= String::MaxLength);
- return static_cast<unsigned>(length);
+ StringView(m_characters, m_length).getCharactersWithUpconvert(destination);
}
+ void writeTo(UChar* destination) const
+ {
+ StringView(m_characters, m_length).getCharactersWithUpconvert(destination);
+ }
+
+ String toString() const { return String(m_characters, m_length); }
+
+private:
const LChar* m_characters;
unsigned m_length;
};
-template<> class StringTypeAdapter<const UChar*, void> {
+template<>
+class StringTypeAdapter<const UChar*, void> {
public:
StringTypeAdapter(const UChar* characters)
- : m_characters { characters }
- , m_length { computeLength(characters) }
+ : m_characters(characters)
{
+ size_t length = 0;
+ while (m_characters[length])
+ ++length;
+ RELEASE_ASSERT(length <= String::MaxLength);
+ m_length = static_cast<unsigned>(length);
}
unsigned length() const { return m_length; }
- bool is8Bit() const { return !m_length; }
- void writeTo(LChar*) const { ASSERT(!m_length); }
- void writeTo(UChar* destination) const { StringImpl::copyCharacters(destination, m_characters, m_length); }
+ bool is8Bit() const { return false; }
-private:
- static unsigned computeLength(const UChar* characters)
+ NO_RETURN_DUE_TO_CRASH void writeTo(LChar*) const
{
- size_t length = 0;
- while (characters[length])
- ++length;
- RELEASE_ASSERT(length <= String::MaxLength);
- return static_cast<unsigned>(length);
+ CRASH(); // FIXME make this a compile-time failure https://bugs.webkit.org/show_bug.cgi?id=165791
}
+ void writeTo(UChar* destination) const
+ {
+ memcpy(destination, m_characters, m_length * sizeof(UChar));
+ }
+
+ String toString() const { return String(m_characters, m_length); }
+
+private:
const UChar* m_characters;
unsigned m_length;
};
-template<> class StringTypeAdapter<const char*, void> : public StringTypeAdapter<const LChar*, void> {
+template<>
+class StringTypeAdapter<const char*, void> : public StringTypeAdapter<const LChar*, void> {
public:
StringTypeAdapter(const char* characters)
- : StringTypeAdapter<const LChar*, void> { reinterpret_cast<const LChar*>(characters) }
+ : StringTypeAdapter<const LChar*, void>(reinterpret_cast<const LChar*>(characters))
{
}
};
-template<> class StringTypeAdapter<char*, void> : public StringTypeAdapter<const char*, void> {
+template<>
+class StringTypeAdapter<char*, void> : public StringTypeAdapter<const char*, void> {
public:
StringTypeAdapter(const char* characters)
- : StringTypeAdapter<const char*, void> { characters }
+ : StringTypeAdapter<const char*, void>(characters)
{
}
};
-template<> class StringTypeAdapter<ASCIILiteral, void> : public StringTypeAdapter<const char*, void> {
+template<>
+class StringTypeAdapter<ASCIILiteral, void> : public StringTypeAdapter<const char*, void> {
public:
StringTypeAdapter(ASCIILiteral characters)
- : StringTypeAdapter<const char*, void> { characters }
+ : StringTypeAdapter<const char*, void>(characters)
{
}
};
-template<> class StringTypeAdapter<Vector<char>, void> {
+template<>
+class StringTypeAdapter<Vector<char>, void> {
public:
StringTypeAdapter(const Vector<char>& vector)
- : m_vector { vector }
+ : m_vector(vector)
{
}
size_t length() const { return m_vector.size(); }
bool is8Bit() const { return true; }
- template<typename CharacterType> void writeTo(CharacterType* destination) const { StringImpl::copyCharacters(destination, characters(), length()); }
-private:
- const LChar* characters() const
+ void writeTo(LChar* destination) const
{
- return reinterpret_cast<const LChar*>(m_vector.data());
+ StringView(reinterpret_cast<const LChar*>(m_vector.data()), m_vector.size()).getCharactersWithUpconvert(destination);
}
+ void writeTo(UChar* destination) const
+ {
+ StringView(reinterpret_cast<const LChar*>(m_vector.data()), m_vector.size()).getCharactersWithUpconvert(destination);
+ }
+
+ String toString() const { return String(m_vector.data(), m_vector.size()); }
+
+private:
const Vector<char>& m_vector;
};
-template<> class StringTypeAdapter<String, void> {
+template<>
+class StringTypeAdapter<String, void> {
public:
StringTypeAdapter(const String& string)
- : m_string { string }
+ : m_string(string)
{
}
unsigned length() const { return m_string.length(); }
bool is8Bit() const { return m_string.isNull() || m_string.is8Bit(); }
- template<typename CharacterType> void writeTo(CharacterType* destination) const
+
+ void writeTo(LChar* destination) const
{
- StringView { m_string }.getCharactersWithUpconvert(destination);
+ StringView(m_string).getCharactersWithUpconvert(destination);
WTF_STRINGTYPEADAPTER_COPIED_WTF_STRING();
}
+ void writeTo(UChar* destination) const
+ {
+ StringView(m_string).getCharactersWithUpconvert(destination);
+ WTF_STRINGTYPEADAPTER_COPIED_WTF_STRING();
+ }
+
+ String toString() const { return m_string; }
+
private:
const String& m_string;
};
-template<> class StringTypeAdapter<AtomicString, void> : public StringTypeAdapter<String, void> {
+template<>
+class StringTypeAdapter<AtomicString, void> : public StringTypeAdapter<String, void> {
public:
StringTypeAdapter(const AtomicString& string)
- : StringTypeAdapter<String, void> { string.string() }
+ : StringTypeAdapter<String, void>(string.string())
{
}
};
-template<typename UnderlyingAdapterType> struct PaddingSpecification {
- LChar character;
- unsigned length;
- UnderlyingAdapterType underlyingAdapter;
-};
-
-template<typename StringType> PaddingSpecification<StringTypeAdapter<StringType>> pad(char character, unsigned length, StringType adapter)
-{
- return { static_cast<LChar>(character), length, StringTypeAdapter<StringType> { adapter } };
-}
-
-template<typename UnderlyingAdapterType> class StringTypeAdapter<PaddingSpecification<UnderlyingAdapterType>> {
-public:
- StringTypeAdapter(const PaddingSpecification<UnderlyingAdapterType>& padding)
- : m_padding { padding }
- {
- }
-
- unsigned length() const { return std::max(m_padding.length, m_padding.underlyingAdapter.length()); }
- bool is8Bit() const { return m_padding.underlyingAdapter.is8Bit(); }
- template<typename CharacterType> void writeTo(CharacterType* destination) const
- {
- unsigned underlyingLength = m_padding.underlyingAdapter.length();
- unsigned count = 0;
- if (underlyingLength < m_padding.length) {
- count = m_padding.length - underlyingLength;
- for (unsigned i = 0; i < count; ++i)
- destination[i] = m_padding.character;
- }
- m_padding.underlyingAdapter.writeTo(destination + count);
- }
-
-private:
- const PaddingSpecification<UnderlyingAdapterType>& m_padding;
-};
-
template<typename Adapter>
inline bool are8Bit(Adapter adapter)
{
@@ -295,6 +314,13 @@
return tryMakeStringFromAdapters(StringTypeAdapter<StringTypes>(strings)...);
}
+// Convenience only.
+template<typename StringType>
+String makeString(StringType string)
+{
+ return String(string);
+}
+
template<typename... StringTypes>
String makeString(StringTypes... strings)
{
@@ -307,7 +333,6 @@
} // namespace WTF
using WTF::makeString;
-using WTF::pad;
using WTF::tryMakeString;
#include <wtf/text/StringOperators.h>
Modified: trunk/Source/WTF/wtf/text/StringConcatenateNumbers.h (242188 => 242189)
--- trunk/Source/WTF/wtf/text/StringConcatenateNumbers.h 2019-02-28 03:42:46 UTC (rev 242188)
+++ trunk/Source/WTF/wtf/text/StringConcatenateNumbers.h 2019-02-28 04:35:25 UTC (rev 242189)
@@ -42,6 +42,7 @@
unsigned length() const { return lengthOfNumberAsStringSigned(m_number); }
bool is8Bit() const { return true; }
template<typename CharacterType> void writeTo(CharacterType* destination) const { writeNumberToBufferSigned(m_number, destination); }
+ String toString() const { return String::number(m_number); }
private:
SignedInt m_number;
@@ -58,6 +59,7 @@
unsigned length() const { return lengthOfNumberAsStringUnsigned(m_number); }
bool is8Bit() const { return true; }
template<typename CharacterType> void writeTo(CharacterType* destination) const { writeNumberToBufferUnsigned(m_number, destination); }
+ String toString() const { return String::number(m_number); }
private:
UnsignedInt m_number;
@@ -69,12 +71,13 @@
StringTypeAdapter(FloatingPoint number)
{
numberToString(number, m_buffer);
- m_length = std::strlen(m_buffer);
+ m_length = strlen(m_buffer);
}
unsigned length() const { return m_length; }
bool is8Bit() const { return true; }
template<typename CharacterType> void writeTo(CharacterType* destination) const { StringImpl::copyCharacters(destination, buffer(), m_length); }
+ String toString() const { return { buffer(), m_length }; }
private:
const LChar* buffer() const { return reinterpret_cast<const LChar*>(m_buffer); }
@@ -89,7 +92,7 @@
{
FormattedNumber numberFormatter;
numberToFixedPrecisionString(number, significantFigures, numberFormatter.m_buffer, trailingZerosTruncatingPolicy == TruncateTrailingZeros);
- numberFormatter.m_length = std::strlen(numberFormatter.m_buffer);
+ numberFormatter.m_length = strlen(numberFormatter.m_buffer);
return numberFormatter;
}
@@ -97,7 +100,7 @@
{
FormattedNumber numberFormatter;
numberToFixedWidthString(number, decimalPlaces, numberFormatter.m_buffer);
- numberFormatter.m_length = std::strlen(numberFormatter.m_buffer);
+ numberFormatter.m_length = strlen(numberFormatter.m_buffer);
return numberFormatter;
}
@@ -109,7 +112,8 @@
unsigned m_length;
};
-template<> class StringTypeAdapter<FormattedNumber> {
+template<>
+class StringTypeAdapter<FormattedNumber> {
public:
StringTypeAdapter(const FormattedNumber& number)
: m_number { number }
@@ -119,6 +123,7 @@
unsigned length() const { return m_number.length(); }
bool is8Bit() const { return true; }
template<typename CharacterType> void writeTo(CharacterType* destination) const { StringImpl::copyCharacters(destination, m_number.buffer(), m_number.length()); }
+ String toString() const { return { m_number.buffer(), m_number.length() }; }
private:
const FormattedNumber& m_number;
Modified: trunk/Source/WTF/wtf/text/StringOperators.h (242188 => 242189)
--- trunk/Source/WTF/wtf/text/StringOperators.h 2019-02-28 03:42:46 UTC (rev 242188)
+++ trunk/Source/WTF/wtf/text/StringOperators.h 2019-02-28 04:35:25 UTC (rev 242189)
@@ -23,11 +23,12 @@
namespace WTF {
-template<typename StringType1, typename StringType2> class StringAppend {
+template<typename StringType1, typename StringType2>
+class StringAppend {
public:
StringAppend(StringType1 string1, StringType2 string2)
- : m_string1 { string1 }
- , m_string2 { string2 }
+ : m_string1(string1)
+ , m_string2(string2)
{
}
@@ -84,14 +85,19 @@
class StringTypeAdapter<StringAppend<StringType1, StringType2>> {
public:
StringTypeAdapter<StringAppend<StringType1, StringType2>>(StringAppend<StringType1, StringType2>& buffer)
- : m_buffer { buffer }
+ : m_buffer(buffer)
{
}
- unsigned length() const { return m_buffer.length(); }
- bool is8Bit() const { return m_buffer.is8Bit(); }
- template<typename CharacterType> void writeTo(CharacterType* destination) const { m_buffer.writeTo(destination); }
+ unsigned length() { return m_buffer.length(); }
+ bool is8Bit() { return m_buffer.is8Bit(); }
+
+ void writeTo(LChar* destination) { m_buffer.writeTo(destination); }
+ void writeTo(UChar* destination) { m_buffer.writeTo(destination); }
+
+ String toString() const { return m_buffer; }
+
private:
StringAppend<StringType1, StringType2>& m_buffer;
};
Modified: trunk/Source/WTF/wtf/text/StringView.h (242188 => 242189)
--- trunk/Source/WTF/wtf/text/StringView.h 2019-02-28 03:42:46 UTC (rev 242188)
+++ trunk/Source/WTF/wtf/text/StringView.h 2019-02-28 04:35:25 UTC (rev 242189)
@@ -565,24 +565,27 @@
}
#if !CHECK_STRINGVIEW_LIFETIME
-
inline void StringView::invalidate(const StringImpl&)
{
}
-
#endif
+template<typename StringType, typename> class StringTypeAdapter;
+
template<> class StringTypeAdapter<StringView, void> {
public:
StringTypeAdapter(StringView string)
- : m_string { string }
+ : m_string(string)
{
}
unsigned length() { return m_string.length(); }
bool is8Bit() { return m_string.is8Bit(); }
- template<typename CharacterType> void writeTo(CharacterType* destination) { m_string.getCharactersWithUpconvert(destination); }
+ void writeTo(LChar* destination) { m_string.getCharactersWithUpconvert(destination); }
+ void writeTo(UChar* destination) { m_string.getCharactersWithUpconvert(destination); }
+ String toString() const { return m_string.toString(); }
+
private:
StringView m_string;
};
Modified: trunk/Source/WTF/wtf/text/WTFString.cpp (242188 => 242189)
--- trunk/Source/WTF/wtf/text/WTFString.cpp 2019-02-28 03:42:46 UTC (rev 242188)
+++ trunk/Source/WTF/wtf/text/WTFString.cpp 2019-02-28 04:35:25 UTC (rev 242189)
@@ -449,6 +449,61 @@
return result;
}
+WTF_ATTRIBUTE_PRINTF(1, 0) static String createWithFormatAndArguments(const char *format, va_list args)
+{
+ va_list argsCopy;
+ va_copy(argsCopy, args);
+
+ ALLOW_NONLITERAL_FORMAT_BEGIN
+
+#if USE(CF) && !OS(WINDOWS)
+ if (strstr(format, "%@")) {
+ auto cfFormat = adoptCF(CFStringCreateWithCString(kCFAllocatorDefault, format, kCFStringEncodingUTF8));
+ auto result = adoptCF(CFStringCreateWithFormatAndArguments(kCFAllocatorDefault, nullptr, cfFormat.get(), args));
+ va_end(argsCopy);
+ return result.get();
+ }
+#endif
+
+ // Do the format once to get the length.
+#if COMPILER(MSVC)
+ int result = _vscprintf(format, args);
+#else
+ char ch;
+ int result = vsnprintf(&ch, 1, format, args);
+#endif
+
+ if (!result) {
+ va_end(argsCopy);
+ return emptyString();
+ }
+ if (result < 0) {
+ va_end(argsCopy);
+ return String();
+ }
+
+ Vector<char, 256> buffer;
+ unsigned len = result;
+ buffer.grow(len + 1);
+
+ // Now do the formatting again, guaranteed to fit.
+ vsnprintf(buffer.data(), buffer.size(), format, argsCopy);
+ va_end(argsCopy);
+
+ ALLOW_NONLITERAL_FORMAT_END
+
+ return StringImpl::create(reinterpret_cast<const LChar*>(buffer.data()), len);
+}
+
+String String::format(const char *format, ...)
+{
+ va_list args;
+ va_start(args, format);
+ String result = createWithFormatAndArguments(format, args);
+ va_end(args);
+ return result;
+}
+
String String::number(int number)
{
return numberToStringSigned<String>(number);
Modified: trunk/Source/WTF/wtf/text/WTFString.h (242188 => 242189)
--- trunk/Source/WTF/wtf/text/WTFString.h 2019-02-28 03:42:46 UTC (rev 242188)
+++ trunk/Source/WTF/wtf/text/WTFString.h 2019-02-28 04:35:25 UTC (rev 242189)
@@ -261,6 +261,8 @@
// Use convertToASCIILowercase instead if ASCII case insensitive comparison is desired.
WTF_EXPORT_PRIVATE String foldCase() const;
+ WTF_EXPORT_PRIVATE static String format(const char *, ...) WTF_ATTRIBUTE_PRINTF(1, 2);
+
// Returns an uninitialized string. The characters needs to be written
// into the buffer returned in data before the returned string is used.
static String createUninitialized(unsigned length, UChar*& data) { return StringImpl::createUninitialized(length, data); }
Modified: trunk/Source/WebCore/ChangeLog (242188 => 242189)
--- trunk/Source/WebCore/ChangeLog 2019-02-28 03:42:46 UTC (rev 242188)
+++ trunk/Source/WebCore/ChangeLog 2019-02-28 04:35:25 UTC (rev 242189)
@@ -1,3 +1,33 @@
+2019-02-27 Simon Fraser <[email protected]>
+
+ Roll out r242014; it caused crashes in compositing logging (webkit.org/b/195141)
+
+ * dom/Document.cpp:
+ (WebCore::Document::lastModified const):
+ * html/FTPDirectoryDocument.cpp:
+ (WebCore::processFileDateString):
+ * mathml/MathMLElement.cpp:
+ (WebCore::convertToPercentageIfNeeded):
+ (WebCore::MathMLElement::collectStyleForPresentationAttribute):
+ * page/cocoa/ResourceUsageOverlayCocoa.mm:
+ (WebCore::ResourceUsageOverlay::platformDraw):
+ * page/linux/ResourceUsageOverlayLinux.cpp:
+ (WebCore::cpuUsageString):
+ (WebCore::gcTimerString):
+ * platform/DateComponents.cpp:
+ (WebCore::DateComponents::toStringForTime const):
+ (WebCore::DateComponents::toString const):
+ * platform/LocalizedStrings.cpp:
+ (WebCore::localizedString):
+ * platform/audio/HRTFElevation.cpp:
+ (WebCore::HRTFElevation::calculateKernelsForAzimuthElevation):
+ * platform/mock/MockRealtimeVideoSource.cpp:
+ (WebCore::MockRealtimeVideoSource::drawText):
+ * rendering/RenderLayerCompositor.cpp:
+ (WebCore::RenderLayerCompositor::logLayerInfo):
+ * rendering/RenderTheme.cpp:
+ (WebCore::RenderTheme::formatMediaControlsTime const):
+
2019-02-27 Zalan Bujtas <[email protected]>
[ContentChangeObserver] Move _WKObservingContentChanges from global to ContentChangeObserver class
Modified: trunk/Source/WebCore/dom/Document.cpp (242188 => 242189)
--- trunk/Source/WebCore/dom/Document.cpp 2019-02-28 03:42:46 UTC (rev 242188)
+++ trunk/Source/WebCore/dom/Document.cpp 2019-02-28 04:35:25 UTC (rev 242189)
@@ -4996,19 +4996,15 @@
else if (loader())
dateTime = loader()->response().lastModified();
- // FIXME: If this document came from the file system, the HTML specification tells
- // us to read the last modification date from the file system.
+ // FIXME: If this document came from the file system, the HTML5
+ // specification tells us to read the last modification date from the file
+ // system.
if (!dateTime)
dateTime = WallTime::now();
auto ctime = dateTime.value().secondsSinceEpoch().secondsAs<time_t>();
auto localDateTime = std::localtime(&ctime);
- return makeString(pad('0', 2, localDateTime->tm_mon + 1), '/',
- pad('0', 2, localDateTime->tm_mday), '/',
- pad('0', 4, 1900 + localDateTime->tm_year), ' ',
- pad('0', 2, localDateTime->tm_hour), ':',
- pad('0', 2, localDateTime->tm_min), ':',
- pad('0', 2, localDateTime->tm_sec));
+ 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);
}
void Document::setCookieURL(const URL& url)
Modified: trunk/Source/WebCore/html/FTPDirectoryDocument.cpp (242188 => 242189)
--- trunk/Source/WebCore/html/FTPDirectoryDocument.cpp 2019-02-28 03:42:46 UTC (rev 242188)
+++ trunk/Source/WebCore/html/FTPDirectoryDocument.cpp 2019-02-28 04:35:25 UTC (rev 242189)
@@ -210,12 +210,12 @@
if (hour < 12) {
if (hour == 0)
hour = 12;
- timeOfDay = makeString(", ", hour, ':', pad('0', 2, fileTime.tm_min), " AM");
+ timeOfDay = String::format(", %i:%02i AM", hour, fileTime.tm_min);
} else {
hour = hour - 12;
if (hour == 0)
hour = 12;
- timeOfDay = makeString(", ", hour, ':', pad('0', 2, fileTime.tm_min), " PM");
+ timeOfDay = String::format(", %i:%02i PM", hour, fileTime.tm_min);
}
}
Modified: trunk/Source/WebCore/mathml/MathMLElement.cpp (242188 => 242189)
--- trunk/Source/WebCore/mathml/MathMLElement.cpp 2019-02-28 03:42:46 UTC (rev 242188)
+++ trunk/Source/WebCore/mathml/MathMLElement.cpp 2019-02-28 04:35:25 UTC (rev 242189)
@@ -39,7 +39,6 @@
#include "MouseEvent.h"
#include "RenderTableCell.h"
#include <wtf/IsoMallocInlines.h>
-#include <wtf/text/StringConcatenateNumbers.h>
namespace WebCore {
@@ -100,13 +99,11 @@
static String convertToPercentageIfNeeded(const AtomicString& value)
{
- // FIXME: Might be better to use double than float.
- // FIXME: Might be better to use "shortest" numeric formatting instead of fixed width.
bool ok = false;
float unitlessValue = value.toFloat(&ok);
- if (!ok)
- return value;
- return makeString(FormattedNumber::fixedWidth(unitlessValue * 100, 3), '%');
+ if (ok)
+ return String::format("%.3f%%", unitlessValue * 100.0);
+ return value;
}
void MathMLElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStyleProperties& style)
@@ -119,7 +116,7 @@
addPropertyToPresentationAttributeStyle(style, CSSPropertyFontSize, convertToPercentageIfNeeded(value));
} else if (name == mathcolorAttr)
addPropertyToPresentationAttributeStyle(style, CSSPropertyColor, value);
- // FIXME: The following are deprecated attributes that should lose if there is a conflict with a non-deprecated attribute.
+ // FIXME: deprecated attributes that should loose in a conflict with a non deprecated attribute
else if (name == fontsizeAttr)
addPropertyToPresentationAttributeStyle(style, CSSPropertyFontSize, value);
else if (name == backgroundAttr)
@@ -137,7 +134,8 @@
addPropertyToPresentationAttributeStyle(style, CSSPropertyDirection, value);
} else {
ASSERT(!isPresentationAttribute(name));
- StyledElement::collectStyleForPresentationAttribute(name, value, style);
+ StyledElement::collectStyleForPresentationAttribute(name, value
+ , style);
}
}
Modified: trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm (242188 => 242189)
--- trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm 2019-02-28 03:42:46 UTC (rev 242188)
+++ trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm 2019-02-28 04:35:25 UTC (rev 242189)
@@ -468,7 +468,7 @@
size_t reclaimable = category.reclaimableSize.last();
size_t external = category.externalSize.last();
- String label = makeString(pad(' ', 11, category.name), ": ", formatByteNumber(dirty));
+ String label = String::format("% 11s: %s", category.name.ascii().data(), formatByteNumber(dirty).ascii().data());
if (external)
label = label + makeString(" + ", formatByteNumber(external));
if (reclaimable)
Modified: trunk/Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp (242188 => 242189)
--- trunk/Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp 2019-02-28 03:42:46 UTC (rev 242188)
+++ trunk/Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp 2019-02-28 04:35:25 UTC (rev 242189)
@@ -46,7 +46,7 @@
{
if (cpuUsage < 0)
return "<unknown>"_s;
- return makeString(FormattedNumber::fixedWidth(cpuUsage, 1), '%');
+ return String::format("%.1f%%", cpuUsage);
}
static String formatByteNumber(size_t number)
@@ -64,7 +64,7 @@
{
if (std::isnan(timerFireDate))
return "[not scheduled]"_s;
- return String::number((timerFireDate - now).seconds());
+ return String::format("%g", (timerFireDate - now).seconds());
}
static const float gFontSize = 14;
Modified: trunk/Source/WebCore/platform/DateComponents.cpp (242188 => 242189)
--- trunk/Source/WebCore/platform/DateComponents.cpp 2019-02-28 03:42:46 UTC (rev 242188)
+++ trunk/Source/WebCore/platform/DateComponents.cpp 2019-02-28 04:35:25 UTC (rev 242189)
@@ -35,7 +35,7 @@
#include <wtf/ASCIICType.h>
#include <wtf/DateMath.h>
#include <wtf/MathExtras.h>
-#include <wtf/text/StringConcatenateNumbers.h>
+#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -693,11 +693,11 @@
FALLTHROUGH; // To None.
#endif
case None:
- return makeString(pad('0', 2, m_hour), ':', pad('0', 2, m_minute));
+ return String::format("%02d:%02d", m_hour, m_minute);
case Second:
- return makeString(pad('0', 2, m_hour), ':', pad('0', 2, m_minute), ':', pad('0', 2, m_second));
+ return String::format("%02d:%02d:%02d", m_hour, m_minute, m_second);
case Millisecond:
- return makeString(pad('0', 2, m_hour), ':', pad('0', 2, m_minute), ':', pad('0', 2, m_second), '.', pad('0', 3, m_millisecond));
+ return String::format("%02d:%02d:%02d.%03d", m_hour, m_minute, m_second, m_millisecond);
}
}
@@ -705,17 +705,19 @@
{
switch (m_type) {
case Date:
- return makeString(pad('0', 4, m_year), '-', pad('0', 2, m_month + 1), '-', pad('0', 2, m_monthDay));
+ return String::format("%04d-%02d-%02d", m_year, m_month + 1, m_monthDay);
case DateTime:
- return makeString(pad('0', 4, m_year), '-', pad('0', 2, m_month + 1), '-', pad('0', 2, m_monthDay), 'T', toStringForTime(format), 'Z');
+ return String::format("%04d-%02d-%02dT", m_year, m_month + 1, m_monthDay)
+ + toStringForTime(format) + "Z"_str;
case DateTimeLocal:
- return makeString(pad('0', 4, m_year), '-', pad('0', 2, m_month + 1), '-', pad('0', 2, m_monthDay), 'T', toStringForTime(format));
+ return String::format("%04d-%02d-%02dT", m_year, m_month + 1, m_monthDay)
+ + toStringForTime(format);
case Month:
- return makeString(pad('0', 4, m_year), '-', pad('0', 2, m_month + 1));
+ return String::format("%04d-%02d", m_year, m_month + 1);
case Time:
return toStringForTime(format);
case Week:
- return makeString(pad('0', 4, m_year), "-W", pad('0', 2, m_week));
+ return String::format("%04d-W%02d", m_year, m_week);
case Invalid:
break;
}
Modified: trunk/Source/WebCore/platform/LocalizedStrings.cpp (242188 => 242189)
--- trunk/Source/WebCore/platform/LocalizedStrings.cpp 2019-02-28 03:42:46 UTC (rev 242188)
+++ trunk/Source/WebCore/platform/LocalizedStrings.cpp 2019-02-28 04:35:25 UTC (rev 242189)
@@ -43,7 +43,10 @@
namespace WebCore {
-// Because |format| is used as the second parameter to va_start, it cannot be a reference
+// We can't use String::format for two reasons:
+// 1) It doesn't handle non-ASCII characters in the format string.
+// 2) It doesn't handle the %2$d syntax.
+// Note that because |format| is used as the second parameter to va_start, it cannot be a reference
// type according to section 18.7/3 of the C++ N1905 standard.
String formatLocalizedString(String format, ...)
{
@@ -70,12 +73,10 @@
}
#if !USE(CF)
-
String localizedString(const char* key)
{
return String::fromUTF8(key, strlen(key));
}
-
#endif
#if ENABLE(CONTEXT_MENUS)
Modified: trunk/Source/WebCore/platform/audio/HRTFElevation.cpp (242188 => 242189)
--- trunk/Source/WebCore/platform/audio/HRTFElevation.cpp 2019-02-28 03:42:46 UTC (rev 242188)
+++ trunk/Source/WebCore/platform/audio/HRTFElevation.cpp 2019-02-28 04:35:25 UTC (rev 242189)
@@ -176,7 +176,7 @@
AudioChannel* leftEarImpulseResponse = response->channel(AudioBus::ChannelLeft);
AudioChannel* rightEarImpulseResponse = response->channel(AudioBus::ChannelRight);
#else
- String resourceName = makeString("IRC_", subjectName, "_C_R0195_T", pad('0', 3, azimuth), "_P", pad('0', 3, positiveElevation));
+ String resourceName = String::format("IRC_%s_C_R0195_T%03d_P%03d", subjectName.utf8().data(), azimuth, positiveElevation);
RefPtr<AudioBus> impulseResponse(AudioBus::loadPlatformResource(resourceName.utf8().data(), sampleRate));
Modified: trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp (242188 => 242189)
--- trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp 2019-02-28 03:42:46 UTC (rev 242188)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp 2019-02-28 04:35:25 UTC (rev 242189)
@@ -350,10 +350,10 @@
FloatPoint timeLocation(captureSize.width() * .05, captureSize.height() * .15);
context.setFillColor(Color::white);
context.setTextDrawingMode(TextModeFill);
- String string = makeString(pad('0', 2, hours), ':', pad('0', 2, minutes), ':', pad('0', 2, seconds), '.', pad('0', 3, milliseconds % 1000));
+ String string = String::format("%02u:%02u:%02u.%03u", hours, minutes, seconds, milliseconds % 1000);
context.drawText(timeFont, TextRun((StringView(string))), timeLocation);
- string = makeString(pad('0', 6, m_frameNumber++));
+ string = String::format("%06u", m_frameNumber++);
timeLocation.move(0, m_baseFontSize);
context.drawText(timeFont, TextRun((StringView(string))), timeLocation);
Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (242188 => 242189)
--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2019-02-28 03:42:46 UTC (rev 242188)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2019-02-28 04:35:25 UTC (rev 242189)
@@ -60,7 +60,6 @@
#include "Settings.h"
#include "TiledBacking.h"
#include "TransformState.h"
-#include <wtf/HexNumber.h>
#include <wtf/MemoryPressureHandler.h>
#include <wtf/SetForScope.h>
#include <wtf/text/CString.h>
@@ -1324,8 +1323,10 @@
absoluteBounds.move(layer.offsetFromAncestor(m_renderView.layer()));
StringBuilder logString;
- 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"));
-
+ logString.append(String::format("%*p id %" PRIu64 " (%.3f,%.3f-%.3f,%.3f) %.2fKB", 12 + depth * 2, &layer, backing->graphicsLayer()->primaryLayerID(),
+ absoluteBounds.x().toFloat(), absoluteBounds.y().toFloat(), absoluteBounds.maxX().toFloat(), absoluteBounds.maxY().toFloat(),
+ backing->backingStoreMemoryEstimate() / 1024));
+
if (!layer.renderer().style().hasAutoZIndex())
logString.append(makeString(" z-index: ", layer.renderer().style().zIndex()));
Modified: trunk/Source/WebCore/rendering/RenderTheme.cpp (242188 => 242189)
--- trunk/Source/WebCore/rendering/RenderTheme.cpp 2019-02-28 03:42:46 UTC (rev 242188)
+++ trunk/Source/WebCore/rendering/RenderTheme.cpp 2019-02-28 04:35:25 UTC (rev 242189)
@@ -46,7 +46,6 @@
#include "TextControlInnerElements.h"
#include <wtf/FileSystem.h>
#include <wtf/NeverDestroyed.h>
-#include <wtf/text/StringConcatenateNumbers.h>
#if ENABLE(METER_ELEMENT)
#include "HTMLMeterElement.h"
@@ -569,14 +568,18 @@
{
if (!std::isfinite(time))
time = 0;
- // FIXME: Seems like it would be better to use std::lround here.
- int seconds = static_cast<int>(std::abs(time));
+ int seconds = (int)fabsf(time);
int hours = seconds / (60 * 60);
int minutes = (seconds / 60) % 60;
seconds %= 60;
- if (hours)
- return makeString((time < 0 ? "-" : ""), hours, ':', pad('0', 2, minutes), ':', pad('0', 2, seconds));
- return makeString((time < 0 ? "-" : ""), pad('0', 2, minutes), ':', pad('0', 2, seconds));
+ if (hours) {
+ if (hours > 9)
+ return String::format("%s%02d:%02d:%02d", (time < 0 ? "-" : ""), hours, minutes, seconds);
+
+ return String::format("%s%01d:%02d:%02d", (time < 0 ? "-" : ""), hours, minutes, seconds);
+ }
+
+ return String::format("%s%02d:%02d", (time < 0 ? "-" : ""), minutes, seconds);
}
String RenderTheme::formatMediaControlsCurrentTime(float currentTime, float /*duration*/) const
Modified: trunk/Source/WebKit/ChangeLog (242188 => 242189)
--- trunk/Source/WebKit/ChangeLog 2019-02-28 03:42:46 UTC (rev 242188)
+++ trunk/Source/WebKit/ChangeLog 2019-02-28 04:35:25 UTC (rev 242189)
@@ -1,3 +1,10 @@
+2019-02-27 Simon Fraser <[email protected]>
+
+ Roll out r242014; it caused crashes in compositing logging (webkit.org/b/195141)
+
+ * UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm:
+ (WebKit::LocalAuthenticator::getAssertion):
+
2019-02-27 Michael Catanzaro <[email protected]>
Unreviewed, fix -Wformat warning
Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm (242188 => 242189)
--- trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm 2019-02-28 03:42:46 UTC (rev 242188)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm 2019-02-28 04:35:25 UTC (rev 242189)
@@ -400,10 +400,8 @@
weakThis->continueGetAssertionAfterUserConsented(consent, context, credentialId, userhandle);
};
- NSData *idData = selectedCredentialAttributes[(id)kSecAttrApplicationTag];
- StringView idStringView { static_cast<const LChar*>([idData bytes]), static_cast<unsigned>([idData length]) };
m_connection->getUserConsent(
- makeString("Log into ", requestData().requestOptions.rpId, " with ", idStringView, '.'),
+ String::format("Log into %s with %s.", requestData().requestOptions.rpId.utf8().data(), selectedCredentialAttributes[(id)kSecAttrApplicationTag]),
(__bridge SecAccessControlRef)selectedCredentialAttributes[(id)kSecAttrAccessControl],
WTFMove(callback));
#endif // PLATFORM(IOS_FAMILY)
Modified: trunk/Source/WebKitLegacy/win/ChangeLog (242188 => 242189)
--- trunk/Source/WebKitLegacy/win/ChangeLog 2019-02-28 03:42:46 UTC (rev 242188)
+++ trunk/Source/WebKitLegacy/win/ChangeLog 2019-02-28 04:35:25 UTC (rev 242189)
@@ -1,3 +1,10 @@
+2019-02-27 Simon Fraser <[email protected]>
+
+ Roll out r242014; it caused crashes in compositing logging (webkit.org/b/195141)
+
+ * FullscreenVideoController.cpp:
+ (timeToString):
+
2019-02-26 Philippe Normand <[email protected]>
[WPE] Add API for webview background color configuration
Modified: trunk/Source/WebKitLegacy/win/FullscreenVideoController.cpp (242188 => 242189)
--- trunk/Source/WebKitLegacy/win/FullscreenVideoController.cpp 2019-02-28 03:42:46 UTC (rev 242188)
+++ trunk/Source/WebKitLegacy/win/FullscreenVideoController.cpp 2019-02-28 04:35:25 UTC (rev 242189)
@@ -41,7 +41,6 @@
#include <WebCore/TextRun.h>
#include <windowsx.h>
#include <wtf/StdLibExtras.h>
-#include <wtf/text/StringConcatenateNumbers.h>
#if USE(CA)
#include <WebCore/PlatformCALayerClient.h>
@@ -471,9 +470,14 @@
int hours = seconds / (60 * 60);
int minutes = (seconds / 60) % 60;
seconds %= 60;
- if (hours)
- return makeString((time < 0 ? "-" : ""), hours, ':', pad('0', 2, minutes), ':', pad('0', 2, seconds));
- return makeString((time < 0 ? "-" : ""), pad('0', 2, minutes), ':', pad('0', 2, seconds));
+
+ if (hours) {
+ if (hours > 9)
+ return String::format("%s%02d:%02d:%02d", (time < 0 ? "-" : ""), hours, minutes, seconds);
+ return String::format("%s%01d:%02d:%02d", (time < 0 ? "-" : ""), hours, minutes, seconds);
+ }
+
+ return String::format("%s%02d:%02d", (time < 0 ? "-" : ""), minutes, seconds);
}
void FullscreenVideoController::draw()