Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (241750 => 241751)
--- trunk/Source/_javascript_Core/ChangeLog 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/_javascript_Core/ChangeLog 2019-02-19 02:04:33 UTC (rev 241751)
@@ -1,3 +1,19 @@
+2019-02-16 Darin Adler <da...@apple.com>
+
+ Continue reducing use of String::format, now focusing on hex: "%p", "%x", etc.
+ https://bugs.webkit.org/show_bug.cgi?id=194752
+
+ Reviewed by Daniel Bates.
+
+ * heap/HeapSnapshotBuilder.cpp:
+ (JSC::HeapSnapshotBuilder::json): Added back the "0x" that was removed when changing
+ this file to use appendUnsignedAsHex instead of "%p". The intent at that time was to
+ keep behavior the same, so let's do that.
+
+ * parser/Lexer.cpp:
+ (JSC::Lexer<T>::invalidCharacterMessage const): Use makeString and hex instead of
+ String::format and "%04x".
+
2019-02-18 Yusuke Suzuki <ysuz...@apple.com>
[JSC] Add LazyClassStructure::getInitializedOnMainThread
Modified: trunk/Source/_javascript_Core/heap/HeapSnapshotBuilder.cpp (241750 => 241751)
--- trunk/Source/_javascript_Core/heap/HeapSnapshotBuilder.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/_javascript_Core/heap/HeapSnapshotBuilder.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -435,9 +435,9 @@
if (m_snapshotType == SnapshotType::GCDebuggingSnapshot) {
json.append(',');
json.appendNumber(labelIndex);
- json.appendLiteral(",\"");
+ json.appendLiteral(",\"0x");
appendUnsignedAsHex(reinterpret_cast<uintptr_t>(node.cell), json, Lowercase);
- json.appendLiteral("\",\"");
+ json.appendLiteral("\",\"0x");
appendUnsignedAsHex(reinterpret_cast<uintptr_t>(wrappedAddress), json, Lowercase);
json.append('"');
}
Modified: trunk/Source/_javascript_Core/parser/Lexer.cpp (241750 => 241751)
--- trunk/Source/_javascript_Core/parser/Lexer.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/_javascript_Core/parser/Lexer.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -38,6 +38,7 @@
#include <limits.h>
#include <string.h>
#include <wtf/Assertions.h>
+#include <wtf/HexNumber.h>
#include <wtf/Variant.h>
#include <wtf/dtoa.h>
@@ -530,7 +531,7 @@
case 96:
return "Invalid character: '`'"_s;
default:
- return String::format("Invalid character '\\u%04x'", static_cast<unsigned>(m_current));
+ return makeString("Invalid character '\\u", hex(m_current, 4, Lowercase), '\'');
}
}
Modified: trunk/Source/WTF/ChangeLog (241750 => 241751)
--- trunk/Source/WTF/ChangeLog 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WTF/ChangeLog 2019-02-19 02:04:33 UTC (rev 241751)
@@ -1,3 +1,39 @@
+2019-02-16 Darin Adler <da...@apple.com>
+
+ Continue reducing use of String::format, now focusing on hex: "%p", "%x", etc.
+ https://bugs.webkit.org/show_bug.cgi?id=194752
+
+ Reviewed by Daniel Bates.
+
+ * WTF.xcodeproj/project.pbxproj: Added HexNumber.cpp and Logger.cpp.
+ * wtf/CMakeLists.txt: Ditto.
+
+ * wtf/HexNumber.cpp: Added.
+ (WTF::Internal::appendHex): Non-inline, non-template hex formatting logic.
+
+ * wtf/HexNumber.h:
+ (WTF::Internal::appendHex): Refactored main logic of appendUnsignedAsHex and
+ appendUnsignedAsHexFixedSize so they can be reused in a function named hex for
+ use with StringTypeAdapter.
+ (WTF::appendUnsignedAsHex): Ditto.
+ (WTF::appendUnsignedAsHexFixedSize): Ditto.
+ (WTF::hex): Added.
+ (WTF::StringTypeAdapter<HexNumberBuffer>): Added.
+
+ * wtf/Logger.cpp: Added.
+ (WTF::Logger::LogSiteIdentifier::toString const): Made this a non-template
+ function and moved it here so that we don't need to include HexNumber.h
+ in Logger.h. Since HexNumber.h has substantial code in it, it's good if we
+ don't include it in any other headers.
+
+ * wtf/Logger.h:
+ (WTF::LogArgument<Logger::LogSiteIdentifier>::toString): Changed to call
+ a non-template function, LogSiteIdentifier::toString.
+
+ * wtf/text/StringConcatenateNumbers.h: Replaced overloaded writeTo functions
+ with function templates and used StringImpl::copyCharacters instead of
+ hand-written loops.
+
2019-02-18 Joseph Pecoraro <pecor...@apple.com>
Web Inspector: Better categorize CPU usage per-thread / worker
Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (241750 => 241751)
--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj 2019-02-19 02:04:33 UTC (rev 241751)
@@ -87,6 +87,8 @@
8348BA0E21FBC0D500FD3054 /* ObjectIdentifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8348BA0D21FBC0D400FD3054 /* ObjectIdentifier.cpp */; };
93934BD318A1E8C300D0D6A1 /* StringViewCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93934BD218A1E8C300D0D6A1 /* StringViewCocoa.mm */; };
93934BD518A1F16900D0D6A1 /* StringViewCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93934BD418A1F16900D0D6A1 /* StringViewCF.cpp */; };
+ 93B5B44E2213D616004B7AA7 /* HexNumber.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93B5B44D2213D616004B7AA7 /* HexNumber.cpp */; };
+ 93B5B45122171EEA004B7AA7 /* Logger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93B5B45022171EE9004B7AA7 /* Logger.cpp */; };
93F1993E19D7958D00C2390B /* StringView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F1993D19D7958D00C2390B /* StringView.cpp */; };
9BC70F05176C379D00101DEC /* AtomicStringTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BC70F04176C379D00101DEC /* AtomicStringTable.cpp */; };
A32D8FA521FFFAB400780662 /* ThreadingPOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A32D8FA421FFFAB400780662 /* ThreadingPOSIX.cpp */; };
@@ -429,6 +431,8 @@
93934BD218A1E8C300D0D6A1 /* StringViewCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StringViewCocoa.mm; sourceTree = "<group>"; };
93934BD418A1F16900D0D6A1 /* StringViewCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringViewCF.cpp; sourceTree = "<group>"; };
93AC91A718942FC400244939 /* LChar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LChar.h; sourceTree = "<group>"; };
+ 93B5B44D2213D616004B7AA7 /* HexNumber.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HexNumber.cpp; sourceTree = "<group>"; };
+ 93B5B45022171EE9004B7AA7 /* Logger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Logger.cpp; sourceTree = "<group>"; };
93D191CF20CAECE800C51B8E /* objcSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = objcSPI.h; sourceTree = "<group>"; };
93DDE9311CDC052D00FD3491 /* dyldSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dyldSPI.h; sourceTree = "<group>"; };
93F1993D19D7958D00C2390B /* StringView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringView.cpp; sourceTree = "<group>"; };
@@ -967,6 +971,7 @@
A8A472B8151A825A004123FF /* HashTable.cpp */,
A8A472B9151A825A004123FF /* HashTable.h */,
A8A472BA151A825A004123FF /* HashTraits.h */,
+ 93B5B44D2213D616004B7AA7 /* HexNumber.cpp */,
A8A472BB151A825A004123FF /* HexNumber.h */,
517A53571F5734B700DCDC0A /* Identified.h */,
FE8925AF1D00DAEC0046907E /* Indenter.h */,
@@ -1001,6 +1006,7 @@
0F60F32E1DFCBD1B00416D6C /* LockedPrintStream.h */,
A8A472C3151A825A004123FF /* Locker.h */,
5311BD551EA7E15A00525281 /* LocklessBag.h */,
+ 93B5B45022171EE9004B7AA7 /* Logger.cpp */,
077CD86A1FD9CFD200828587 /* Logger.h */,
077CD86B1FD9CFD300828587 /* LoggerHelper.h */,
513E170A1CD7D5BF00E3650B /* LoggingAccumulator.h */,
@@ -1536,6 +1542,7 @@
0F30BA901E78708E002CA847 /* GlobalVersion.cpp in Sources */,
2CCD892A15C0390200285083 /* GregorianDateTime.cpp in Sources */,
A8A473D8151A825B004123FF /* HashTable.cpp in Sources */,
+ 93B5B44E2213D616004B7AA7 /* HexNumber.cpp in Sources */,
7A05093F1FB9DCC500B33FB8 /* JSONValues.cpp in Sources */,
E3A32BC41FC830E2007D7E76 /* JSValueMalloc.cpp in Sources */,
C2BCFC401F61D13000C9222C /* Language.cpp in Sources */,
@@ -1543,6 +1550,7 @@
C2BCFC551F621F3F00C9222C /* LineEnding.cpp in Sources */,
0FE1646A1B6FFC9600400E7C /* Lock.cpp in Sources */,
0F60F32F1DFCBD1B00416D6C /* LockedPrintStream.cpp in Sources */,
+ 93B5B45122171EEA004B7AA7 /* Logger.cpp in Sources */,
53534F2A1EC0E10E00141B2F /* MachExceptions.defs in Sources */,
7A6EBA3420746C34004F9C44 /* MachSendRight.cpp in Sources */,
A8A473E5151A825B004123FF /* MainThread.cpp in Sources */,
Modified: trunk/Source/WTF/wtf/CMakeLists.txt (241750 => 241751)
--- trunk/Source/WTF/wtf/CMakeLists.txt 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WTF/wtf/CMakeLists.txt 2019-02-19 02:04:33 UTC (rev 241751)
@@ -363,11 +363,13 @@
GlobalVersion.cpp
GregorianDateTime.cpp
HashTable.cpp
+ HexNumber.cpp
JSONValues.cpp
JSValueMalloc.cpp
Language.cpp
Lock.cpp
LockedPrintStream.cpp
+ Logger.cpp
MD5.cpp
MainThread.cpp
MediaTime.cpp
Added: trunk/Source/WTF/wtf/HexNumber.cpp (0 => 241751)
--- trunk/Source/WTF/wtf/HexNumber.cpp (rev 0)
+++ trunk/Source/WTF/wtf/HexNumber.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "HexNumber.h"
+
+namespace WTF {
+
+namespace Internal {
+
+std::pair<LChar*, unsigned> appendHex(LChar* buffer, unsigned bufferSize, std::uintmax_t number, unsigned minimumDigits, HexConversionMode mode)
+{
+ auto end = buffer + bufferSize;
+ auto start = end;
+ auto hexDigits = hexDigitsForMode(mode);
+ do {
+ *--start = hexDigits[number & 0xF];
+ number >>= 4;
+ } while (number);
+ auto startWithLeadingZeros = end - std::min(minimumDigits, bufferSize);
+ if (start > startWithLeadingZeros) {
+ std::memset(startWithLeadingZeros, '0', start - startWithLeadingZeros);
+ start = startWithLeadingZeros;
+ }
+ return { start, end - start };
+}
+
+}
+
+} // namespace WTF
Property changes on: trunk/Source/WTF/wtf/HexNumber.cpp
___________________________________________________________________
Added: svn:eol-style
+native
\ No newline at end of property
Modified: trunk/Source/WTF/wtf/HexNumber.h (241750 => 241751)
--- trunk/Source/WTF/wtf/HexNumber.h 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WTF/wtf/HexNumber.h 2019-02-19 02:04:33 UTC (rev 241751)
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2011 Research In Motion Limited. All rights reserved.
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -36,6 +36,14 @@
return mode == Lowercase ? lowercaseHexDigits : uppercaseHexDigits;
}
+WTF_EXPORT std::pair<LChar*, unsigned> appendHex(LChar* buffer, unsigned bufferSize, std::uintmax_t number, unsigned minimumDigits, HexConversionMode);
+
+template<size_t arraySize, typename NumberType>
+inline std::pair<LChar*, unsigned> appendHex(std::array<LChar, arraySize>& buffer, NumberType number, unsigned minimumDigits, HexConversionMode mode)
+{
+ return appendHex(&buffer.front(), buffer.size(), static_cast<typename std::make_unsigned<NumberType>::type>(number), minimumDigits, mode);
+}
+
} // namespace Internal
template<typename T>
@@ -46,40 +54,66 @@
destination.append(hexDigits[byte & 0xF]);
}
+// FIXME: Consider renaming to appendHex.
template<typename NumberType, typename DestinationType>
inline void appendUnsignedAsHex(NumberType number, DestinationType& destination, HexConversionMode mode = Uppercase)
{
- // Each byte can generate up to two digits.
- std::array<LChar, sizeof(NumberType) * 2> buffer;
- auto start = buffer.end();
- auto unsignedNumber = static_cast<typename std::make_unsigned<NumberType>::type>(number);
- auto hexDigits = Internal::hexDigitsForMode(mode);
- do {
- ASSERT(start > buffer.begin());
- *--start = hexDigits[unsignedNumber & 0xF];
- unsignedNumber >>= 4;
- } while (unsignedNumber);
- destination.append(&*start, buffer.end() - start);
+ appendUnsignedAsHexFixedSize(number, destination, 0, mode);
}
+// FIXME: Consider renaming to appendHex.
// Same as appendUnsignedAsHex, but zero-padding to get at least the desired number of digits.
template<typename NumberType, typename DestinationType>
-inline void appendUnsignedAsHexFixedSize(NumberType number, DestinationType& destination, unsigned desiredDigits, HexConversionMode mode = Uppercase)
+inline void appendUnsignedAsHexFixedSize(NumberType number, DestinationType& destination, unsigned minimumDigits, HexConversionMode mode = Uppercase)
{
- unsigned digits = 0;
- auto unsignedNumber = static_cast<typename std::make_unsigned<NumberType>::type>(number);
- do {
- ++digits;
- unsignedNumber >>= 4;
- } while (unsignedNumber);
- for (; digits < desiredDigits; ++digits)
- destination.append('0');
- appendUnsignedAsHex(number, destination, mode);
+ // Each byte can generate up to two digits.
+ std::array<LChar, sizeof(NumberType) * 2> buffer;
+ auto result = Internal::appendHex(buffer, number, minimumDigits, mode);
+ destination.append(result.first, result.second);
}
+struct HexNumberBuffer {
+ std::array<LChar, 16> characters;
+ unsigned length;
+};
+
+template<typename NumberType> HexNumberBuffer hex(NumberType number, unsigned minimumDigits = 0, HexConversionMode mode = Uppercase)
+{
+ // Each byte can generate up to two digits.
+ HexNumberBuffer buffer;
+ static_assert(sizeof(buffer.characters) >= sizeof(NumberType) * 2, "number too large for hexNumber");
+ auto result = Internal::appendHex(buffer.characters, number, minimumDigits, mode);
+ buffer.length = result.second;
+ return buffer;
+}
+
+template<typename NumberType> HexNumberBuffer hex(NumberType number, HexConversionMode mode)
+{
+ return hex(number, 0, mode);
+}
+
+template<> class StringTypeAdapter<HexNumberBuffer> {
+public:
+ StringTypeAdapter(const HexNumberBuffer& buffer)
+ : m_buffer { buffer }
+ {
+ }
+
+ 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()); }
+
+ const HexNumberBuffer& m_buffer;
+};
+
} // namespace WTF
using WTF::appendByteAsHex;
using WTF::appendUnsignedAsHex;
using WTF::appendUnsignedAsHexFixedSize;
+using WTF::hex;
using WTF::Lowercase;
Copied: trunk/Source/WTF/wtf/Logger.cpp (from rev 241750, trunk/Source/WebCore/css/CSSUnicodeRangeValue.cpp) (0 => 241751)
--- trunk/Source/WTF/wtf/Logger.cpp (rev 0)
+++ trunk/Source/WTF/wtf/Logger.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "Logger.h"
+
+#include <wtf/HexNumber.h>
+
+namespace WTF {
+
+String Logger::LogSiteIdentifier::toString() const
+{
+ StringBuilder builder;
+
+ if (className) {
+ builder.append(className);
+ builder.appendLiteral("::");
+ }
+ builder.append(methodName);
+ builder.append('(');
+ appendUnsignedAsHex(objectPtr, builder);
+ builder.appendLiteral(") ");
+ return builder.toString();
+}
+
+} // namespace WTF
+
+using WTF::Logger;
+using WTF::JSONLogValue;
Modified: trunk/Source/WTF/wtf/Logger.h (241750 => 241751)
--- trunk/Source/WTF/wtf/Logger.h 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WTF/wtf/Logger.h 2019-02-19 02:04:33 UTC (rev 241751)
@@ -25,13 +25,7 @@
#pragma once
-#include <wtf/Assertions.h>
-#include <wtf/HexNumber.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
#include <wtf/text/StringBuilder.h>
-#include <wtf/text/WTFString.h>
namespace WTF {
@@ -210,6 +204,8 @@
{
}
+ WTF_EXPORT String toString() const;
+
const char* className { nullptr };
const char* methodName { nullptr };
const uintptr_t objectPtr { 0 };
@@ -260,22 +256,8 @@
bool m_enabled { true };
};
-template <>
-struct LogArgument<Logger::LogSiteIdentifier> {
- static String toString(const Logger::LogSiteIdentifier& value)
- {
- StringBuilder builder;
-
- if (value.className) {
- builder.append(value.className);
- builder.appendLiteral("::");
- }
- builder.append(value.methodName);
- builder.append('(');
- appendUnsignedAsHex(value.objectPtr, builder);
- builder.appendLiteral(") ");
- return builder.toString();
- }
+template<> struct LogArgument<Logger::LogSiteIdentifier> {
+ static String toString(const Logger::LogSiteIdentifier& value) { return value.toString(); }
};
} // namespace WTF
Modified: trunk/Source/WTF/wtf/text/StringConcatenateNumbers.h (241750 => 241751)
--- trunk/Source/WTF/wtf/text/StringConcatenateNumbers.h 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WTF/wtf/text/StringConcatenateNumbers.h 2019-02-19 02:04:33 UTC (rev 241751)
@@ -35,16 +35,13 @@
class StringTypeAdapter<SignedInt, typename std::enable_if_t<std::is_integral<SignedInt>::value && std::is_signed<SignedInt>::value>> {
public:
StringTypeAdapter(SignedInt number)
- : m_number(number)
+ : m_number { number }
{
}
unsigned length() const { return lengthOfNumberAsStringSigned(m_number); }
bool is8Bit() const { return true; }
-
- void writeTo(LChar* destination) const { writeNumberToBufferSigned(m_number, destination); }
- void writeTo(UChar* destination) const { writeNumberToBufferSigned(m_number, destination); }
-
+ template<typename CharacterType> void writeTo(CharacterType* destination) const { writeNumberToBufferSigned(m_number, destination); }
String toString() const { return String::number(m_number); }
private:
@@ -55,16 +52,13 @@
class StringTypeAdapter<UnsignedInt, typename std::enable_if_t<std::is_integral<UnsignedInt>::value && !std::is_signed<UnsignedInt>::value>> {
public:
StringTypeAdapter(UnsignedInt number)
- : m_number(number)
+ : m_number { number }
{
}
unsigned length() const { return lengthOfNumberAsStringUnsigned(m_number); }
bool is8Bit() const { return true; }
-
- void writeTo(LChar* destination) const { writeNumberToBufferUnsigned(m_number, destination); }
- void writeTo(UChar* destination) const { writeNumberToBufferUnsigned(m_number, destination); }
-
+ template<typename CharacterType> void writeTo(CharacterType* destination) const { writeNumberToBufferUnsigned(m_number, destination); }
String toString() const { return String::number(m_number); }
private:
@@ -82,22 +76,12 @@
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 }; }
- void writeTo(LChar* destination) const
- {
- for (unsigned i = 0; i < m_length; ++i)
- destination[i] = m_buffer[i];
- }
+private:
+ const LChar* buffer() const { return reinterpret_cast<const LChar*>(m_buffer); }
- void writeTo(UChar* destination) const
- {
- for (unsigned i = 0; i < m_length; ++i)
- destination[i] = m_buffer[i];
- }
-
- String toString() const { return { m_buffer, m_length }; }
-
-private:
NumberToStringBuffer m_buffer;
unsigned m_length;
};
@@ -131,34 +115,18 @@
template<>
class StringTypeAdapter<FormattedNumber> {
public:
- StringTypeAdapter(const FormattedNumber& numberFormatter)
- : m_numberFormatter(numberFormatter)
+ StringTypeAdapter(const FormattedNumber& number)
+ : m_number { number }
{
}
- unsigned length() const { return m_numberFormatter.length(); }
+ 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() }; }
- void writeTo(LChar* destination) const
- {
- auto buffer = m_numberFormatter.buffer();
- auto length = m_numberFormatter.length();
- for (unsigned i = 0; i < length; ++i)
- destination[i] = buffer[i];
- }
-
- void writeTo(UChar* destination) const
- {
- auto buffer = m_numberFormatter.buffer();
- auto length = m_numberFormatter.length();
- for (unsigned i = 0; i < length; ++i)
- destination[i] = buffer[i];
- }
-
- String toString() const { return { m_numberFormatter.buffer(), m_numberFormatter.length() }; }
-
private:
- const FormattedNumber& m_numberFormatter;
+ const FormattedNumber& m_number;
};
}
Modified: trunk/Source/WebCore/ChangeLog (241750 => 241751)
--- trunk/Source/WebCore/ChangeLog 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/ChangeLog 2019-02-19 02:04:33 UTC (rev 241751)
@@ -1,3 +1,96 @@
+2019-02-16 Darin Adler <da...@apple.com>
+
+ Continue reducing use of String::format, now focusing on hex: "%p", "%x", etc.
+ https://bugs.webkit.org/show_bug.cgi?id=194752
+
+ Reviewed by Daniel Bates.
+
+ * Modules/websockets/WebSocket.cpp: Added an include of HexNumber.h. This previously
+ got included because of Logger.h, but that no longer pulls in HexNumber.h.
+
+ * css/CSSMarkup.cpp: Removed unneeded include of StringBuffer.h.
+ * css/CSSPrimitiveValue.cpp: Ditto.
+
+ * css/CSSUnicodeRangeValue.cpp:
+ (WebCore::CSSUnicodeRangeValue::customCSSText const): Use makeString and hex instead
+ of String::format and "%x".
+
+ * html/HTMLMediaElement.h:
+ (WTF::ValueToString<WebCore::TextTrackCue::string): Use a non-template function,
+ TextTrackCure::debugString, so we don't need to use HextNumber.h in a header.
+
+ * html/canvas/WebGLRenderingContextBase.cpp:
+ (GetErrorString): Use makeString and hex instead of String::format and "%04x".
+
+ * html/track/TextTrackCue.cpp:
+ (WebCore::TextTrackCue::debugString const): Added. Moved string conversion here
+ from HTMLMediaElement.h and use makeString instead of String::format. Also use
+ the word "debug" to make it clear that it's not OK to use this string, with a
+ pointer value serialized into it, outside of debugging.
+ * html/track/TextTrackCue.h: Added TextTrackCue::debugString.
+
+ * page/linux/ResourceUsageOverlayLinux.cpp:
+ (WebCore::formatByteNumber): Use makeString and FormattedNumber::fixedWidth
+ instead of String::format and "%.1f" etc.
+
+ * platform/cocoa/KeyEventCocoa.mm:
+ (WebCore::keyIdentifierForCharCode): Use the new hex function here instead of
+ the old code that did each of the four characters explicitly.
+
+ * platform/gamepad/mac/HIDGamepad.cpp:
+ (WebCore::HIDGamepad::HIDGamepad): Use makeString instead of String::format.
+
+ * platform/graphics/Color.cpp:
+ (WebCore::Color::nameForRenderTreeAsText const): Use hex instead of doing each
+ digit separately.
+
+ * platform/graphics/FloatPolygon.cpp:
+ (WebCore::FloatPolygonEdge::debugString const): Added. Moved string conversion here
+ from the header and use makeString instead of String::format. Also use
+ the word "debug" to make it clear that it's not OK to use this string, with a
+ pointer value serialized into it, outside of debugging.
+ * platform/graphics/FloatPolygon.h: Updated for the above.
+
+ * platform/graphics/ca/GraphicsLayerCA.cpp:
+ (WebCore::GraphicsLayerCA::setName): Use makeString instead of String::format.
+ (WebCore::GraphicsLayerCA::recursiveCommitChanges): DItto.
+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+ (WebCore::MediaPlayerPrivateGStreamer::load): Ditto.
+ (WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin): Ditto.
+ * platform/gtk/PlatformKeyboardEventGtk.cpp:
+ (WebCore::PlatformKeyboardEvent::keyIdentifierForGdkKeyCode): Ditto.
+ * platform/libwpe/PlatformKeyboardEventLibWPE.cpp:
+ (WebCore::PlatformKeyboardEvent::keyIdentifierForWPEKeyCode): Ditto.
+ * platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp:
+ (WebCore::GStreamerVideoEncoder::makeElement): Ditto.
+ (WebCore::GStreamerVideoEncoder::InitEncode): Ditto.
+
+ * platform/text/TextCodecLatin1.cpp: Removed unneeded include of StringBuffer.h
+ and "using namespace WTF".
+
+ * platform/win/GDIObjectCounter.cpp:
+ (WebCore::GDIObjectCounter::GDIObjectCounter): Use makeString instead of String::format.
+ * platform/win/KeyEventWin.cpp:
+ (WebCore::keyIdentifierForWindowsKeyCode): Ditto.
+
+ * rendering/FloatingObjects.cpp:
+ (WebCore::FloatingObject::debugString const): Added. Moved string conversion here
+ from the header and use makeString instead of String::format. Also use
+ the word "debug" to make it clear that it's not OK to use this string, with a
+ pointer value serialized into it, outside of debugging.
+ * rendering/FloatingObjects.h: Updated for the above.
+
+ * rendering/RenderFragmentContainer.cpp:
+ (WebCore::RenderFragmentContainer::debugString const): Added. Moved string
+ conversion here from the header and use makeString instead of String::format.
+ Also use the word "debug" to make it clear that it's not OK to use this string,
+ with a pointer value serialized into it, outside of debugging.
+ * rendering/RenderFragmentContainer.h: Updated for the above.
+ * rendering/RenderFragmentedFlow.h: Ditto.
+
+ * testing/Internals.cpp:
+ (WebCore::Internals::address): Use makeString instead of String::format.
+
2019-02-18 Wenson Hsieh <wenson_hs...@apple.com>
[iOS] Support pasting item-provider-backed data on the pasteboard as attachment elements
Modified: trunk/Source/WebCore/Modules/websockets/WebSocket.cpp (241750 => 241751)
--- trunk/Source/WebCore/Modules/websockets/WebSocket.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/Modules/websockets/WebSocket.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -55,12 +55,12 @@
#include <_javascript_Core/ArrayBufferView.h>
#include <_javascript_Core/ScriptCallStack.h>
#include <wtf/HashSet.h>
+#include <wtf/HexNumber.h>
#include <wtf/NeverDestroyed.h>
#include <wtf/RunLoop.h>
#include <wtf/StdLibExtras.h>
#include <wtf/text/CString.h>
#include <wtf/text/StringBuilder.h>
-#include <wtf/text/WTFString.h>
#if USE(WEB_THREAD)
#include "WebCoreThreadRun.h"
Modified: trunk/Source/WebCore/PAL/ChangeLog (241750 => 241751)
--- trunk/Source/WebCore/PAL/ChangeLog 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/PAL/ChangeLog 2019-02-19 02:04:33 UTC (rev 241751)
@@ -1,3 +1,13 @@
+2019-02-16 Darin Adler <da...@apple.com>
+
+ Continue reducing use of String::format, now focusing on hex: "%p", "%x", etc.
+ https://bugs.webkit.org/show_bug.cgi?id=194752
+
+ Reviewed by Daniel Bates.
+
+ * pal/FileSizeFormatter.cpp:
+ (fileSizeDescription): Use makeString instead of String::format.
+
2019-02-18 Daniel Bates <daba...@apple.com>
[iOS] Keyups for non-modifier keys identified as "Dead" when not focused in a content-editable element
Modified: trunk/Source/WebCore/PAL/pal/FileSizeFormatter.cpp (241750 => 241751)
--- trunk/Source/WebCore/PAL/pal/FileSizeFormatter.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/PAL/pal/FileSizeFormatter.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -35,7 +35,7 @@
// FIXME: These strings should be localized, but that would require bringing LocalizedStrings into PAL.
// See <https://bugs.webkit.org/show_bug.cgi?id=179019> for more details.
if (size < 1000)
- return String::format("%tu bytes", size);
+ return makeString(size, " bytes");
if (size < 1000000)
return makeString(FormattedNumber::fixedWidth(size / 1000., 1), " KB");
if (size < 1000000000)
Modified: trunk/Source/WebCore/css/CSSMarkup.cpp (241750 => 241751)
--- trunk/Source/WebCore/css/CSSMarkup.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/css/CSSMarkup.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -29,7 +29,6 @@
#include "CSSParserIdioms.h"
#include <wtf/HexNumber.h>
-#include <wtf/text/StringBuffer.h>
#include <wtf/text/StringBuilder.h>
namespace WebCore {
Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.cpp (241750 => 241751)
--- trunk/Source/WebCore/css/CSSPrimitiveValue.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -43,7 +43,6 @@
#include <wtf/DecimalNumber.h>
#include <wtf/NeverDestroyed.h>
#include <wtf/StdLibExtras.h>
-#include <wtf/text/StringBuffer.h>
#include <wtf/text/StringBuilder.h>
#if ENABLE(DASHBOARD_SUPPORT)
Modified: trunk/Source/WebCore/css/CSSUnicodeRangeValue.cpp (241750 => 241751)
--- trunk/Source/WebCore/css/CSSUnicodeRangeValue.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/css/CSSUnicodeRangeValue.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -26,13 +26,13 @@
#include "config.h"
#include "CSSUnicodeRangeValue.h"
-#include <wtf/text/WTFString.h>
+#include <wtf/HexNumber.h>
namespace WebCore {
String CSSUnicodeRangeValue::customCSSText() const
{
- return String::format("U+%x-%x", m_from, m_to);
+ return makeString("U+", hex(m_from, Lowercase), '-', hex(m_to, Lowercase));
}
bool CSSUnicodeRangeValue::equals(const CSSUnicodeRangeValue& other) const
Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (241750 => 241751)
--- trunk/Source/WebCore/html/HTMLMediaElement.h 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h 2019-02-19 02:04:33 UTC (rev 241751)
@@ -1206,46 +1206,29 @@
namespace WTF {
-template <>
-struct LogArgument<WebCore::HTMLMediaElement::AutoplayEventPlaybackState> {
- static String toString(const WebCore::HTMLMediaElement::AutoplayEventPlaybackState reason)
- {
- return convertEnumerationToString(reason);
- }
+template<> struct LogArgument<WebCore::HTMLMediaElement::AutoplayEventPlaybackState> {
+ static String toString(WebCore::HTMLMediaElement::AutoplayEventPlaybackState reason) { return convertEnumerationToString(reason); }
};
-
-} // namespace WTF
#if ENABLE(VIDEO_TRACK) && !defined(NDEBUG)
-namespace WTF {
// Template specialization required by PodIntervalTree in debug mode.
-template <> struct ValueToString<WebCore::TextTrackCue*> {
- static String string(WebCore::TextTrackCue* const& cue)
- {
- String text;
- if (cue->isRenderable())
- text = WebCore::toVTTCue(cue)->text();
- return String::format("%p id=%s interval=%s-->%s cue=%s)", cue, cue->id().utf8().data(), toString(cue->startTime()).utf8().data(), toString(cue->endTime()).utf8().data(), text.utf8().data());
- }
+template<> struct ValueToString<WebCore::TextTrackCue*> {
+ static String string(const WebCore::TextTrackCue* cue) { return cue->debugString(); }
};
-} // namespace WTF
#endif
#ifndef NDEBUG
-namespace WTF {
template<> struct ValueToString<MediaTime> {
- static String string(const MediaTime& time)
- {
- return toString(time);
- }
+ static String string(const MediaTime& time) { return toString(time); }
};
-} // namespace WTF
#endif
+} // namespace WTF
+
SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::HTMLMediaElement)
static bool isType(const WebCore::Element& element) { return element.isMediaElement(); }
static bool isType(const WebCore::Node& node) { return is<WebCore::Element>(node) && isType(downcast<WebCore::Element>(node)); }
Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp (241750 => 241751)
--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -98,6 +98,7 @@
#include <_javascript_Core/TypedArrayInlines.h>
#include <_javascript_Core/Uint32Array.h>
#include <wtf/CheckedArithmetic.h>
+#include <wtf/HexNumber.h>
#include <wtf/StdLibExtras.h>
#include <wtf/UniqueArray.h>
#include <wtf/text/CString.h>
@@ -6289,7 +6290,7 @@
case GraphicsContext3D::CONTEXT_LOST_WEBGL:
return "CONTEXT_LOST_WEBGL"_s;
default:
- return String::format("WebGL ERROR(%04x)", error);
+ return makeString("WebGL ERROR(", hex(error, 4, Lowercase), ')');
}
}
Modified: trunk/Source/WebCore/html/track/TextTrackCue.cpp (241750 => 241751)
--- trunk/Source/WebCore/html/track/TextTrackCue.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/html/track/TextTrackCue.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -44,8 +44,10 @@
#include "TextTrackCueList.h"
#include "VTTCue.h"
#include "VTTRegionList.h"
+#include <wtf/HexNumber.h>
#include <wtf/MathExtras.h>
#include <wtf/NeverDestroyed.h>
+#include <wtf/text/StringConcatenateNumbers.h>
namespace WebCore {
@@ -245,6 +247,14 @@
return object->toJSONString();
}
+String TextTrackCue::debugString() const
+{
+ String text;
+ if (isRenderable())
+ text = toVTTCue(this)->text();
+ return makeString("0x", hex(reinterpret_cast<uintptr_t>(this)), " id=", id(), " interval=", startTime(), "-->", endTime(), " cue=", text, ')');
+}
+
} // namespace WebCore
#endif
Modified: trunk/Source/WebCore/html/track/TextTrackCue.h (241750 => 241751)
--- trunk/Source/WebCore/html/track/TextTrackCue.h 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/html/track/TextTrackCue.h 2019-02-19 02:04:33 UTC (rev 241751)
@@ -86,6 +86,7 @@
virtual void didChange();
String toJSONString() const;
+ String debugString() const;
using RefCounted::ref;
using RefCounted::deref;
@@ -126,15 +127,10 @@
namespace WTF {
-template<typename Type>
-struct LogArgument;
+template<typename> struct LogArgument;
-template <>
-struct LogArgument<WebCore::TextTrackCue> {
- static String toString(const WebCore::TextTrackCue& cue)
- {
- return cue.toJSONString();
- }
+template<> struct LogArgument<WebCore::TextTrackCue> {
+ static String toString(const WebCore::TextTrackCue& cue) { return cue.toJSONString(); }
};
}
Modified: trunk/Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp (241750 => 241751)
--- trunk/Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -36,6 +36,7 @@
#include "RenderTheme.h"
#include "ResourceUsageThread.h"
#include <_javascript_Core/VM.h>
+#include <wtf/text/StringConcatenateNumbers.h>
namespace WebCore {
@@ -51,11 +52,11 @@
static String formatByteNumber(size_t number)
{
if (number >= 1024 * 1048576)
- return String::format("%.3f GB", static_cast<double>(number) / (1024 * 1048576));
+ return makeString(FormattedNumber::fixedWidth(number / (1024. * 1048576), 3), " GB");
if (number >= 1048576)
- return String::format("%.2f MB", static_cast<double>(number) / 1048576);
+ return makeString(FormattedNumber::fixedWidth(number / 1048576., 2), " MB");
if (number >= 1024)
- return String::format("%.1f kB", static_cast<double>(number) / 1024);
+ return makeString(FormattedNumber::fixedWidth(number / 1024, 1), " kB");
return String::number(number);
}
Modified: trunk/Source/WebCore/platform/cocoa/KeyEventCocoa.mm (241750 => 241751)
--- trunk/Source/WebCore/platform/cocoa/KeyEventCocoa.mm 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/platform/cocoa/KeyEventCocoa.mm 2019-02-19 02:04:33 UTC (rev 241751)
@@ -30,8 +30,8 @@
#import "PlatformKeyboardEvent.h"
#import "WindowsKeyboardCodes.h"
#import <wtf/ASCIICType.h>
+#import <wtf/HexNumber.h>
#import <wtf/MainThread.h>
-#import <wtf/text/WTFString.h>
#if PLATFORM(IOS_FAMILY)
#import "KeyEventCodesIOS.h"
@@ -494,12 +494,7 @@
// FIXME: We should use something other than the vendor-area Unicode values for the above keys.
// For now, just fall through to the default.
default:
- UChar codeUnit = toASCIIUpper(charCode);
- return makeString("U+",
- upperNibbleToASCIIHexDigit(codeUnit >> 8),
- lowerNibbleToASCIIHexDigit(codeUnit >> 8),
- upperNibbleToASCIIHexDigit(codeUnit),
- lowerNibbleToASCIIHexDigit(codeUnit));
+ return makeString("U+", hex(toASCIIUpper(charCode), 4));
}
}
Modified: trunk/Source/WebCore/platform/gamepad/mac/HIDGamepad.cpp (241750 => 241751)
--- trunk/Source/WebCore/platform/gamepad/mac/HIDGamepad.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/platform/gamepad/mac/HIDGamepad.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -31,9 +31,9 @@
#include <IOKit/hid/IOHIDElement.h>
#include <IOKit/hid/IOHIDUsageTables.h>
#include <IOKit/hid/IOHIDValue.h>
+#include <wtf/HexNumber.h>
#include <wtf/cf/TypeCastsCF.h>
#include <wtf/text/CString.h>
-#include <wtf/text/WTFString.h>
WTF_DECLARE_CF_TYPE_TRAIT(IOHIDElement);
@@ -57,7 +57,7 @@
// Currently the spec has no formatting for the id string.
// This string formatting matches Firefox.
- m_id = String::format("%x-%x-%s", vendorID, productID, productName.utf8().data());
+ m_id = makeString(hex(vendorID, Lowercase), '-', hex(productID, Lowercase), '-', productName);
initElements();
}
Modified: trunk/Source/WebCore/platform/graphics/Color.cpp (241750 => 241751)
--- trunk/Source/WebCore/platform/graphics/Color.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/platform/graphics/Color.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -388,17 +388,9 @@
String Color::nameForRenderTreeAsText() const
{
// FIXME: Handle ExtendedColors.
- if (alpha() < 0xFF) {
- return makeString('#',
- upperNibbleToASCIIHexDigit(red()), lowerNibbleToASCIIHexDigit(red()),
- upperNibbleToASCIIHexDigit(green()), lowerNibbleToASCIIHexDigit(green()),
- upperNibbleToASCIIHexDigit(blue()), lowerNibbleToASCIIHexDigit(blue()),
- upperNibbleToASCIIHexDigit(alpha()), lowerNibbleToASCIIHexDigit(alpha()));
- }
- return makeString('#',
- upperNibbleToASCIIHexDigit(red()), lowerNibbleToASCIIHexDigit(red()),
- upperNibbleToASCIIHexDigit(green()), lowerNibbleToASCIIHexDigit(green()),
- upperNibbleToASCIIHexDigit(blue()), lowerNibbleToASCIIHexDigit(blue()));
+ if (alpha() < 0xFF)
+ return makeString('#', hex(red(), 2), hex(green(), 2), hex(blue(), 2), hex(alpha(), 2));
+ return makeString('#', hex(red(), 2), hex(green(), 2), hex(blue(), 2));
}
Color Color::light() const
Modified: trunk/Source/WebCore/platform/graphics/FloatPolygon.cpp (241750 => 241751)
--- trunk/Source/WebCore/platform/graphics/FloatPolygon.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/platform/graphics/FloatPolygon.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -30,7 +30,9 @@
#include "config.h"
#include "FloatPolygon.h"
+#include <wtf/HexNumber.h>
#include <wtf/MathExtras.h>
+#include <wtf/text/StringConcatenateNumbers.h>
namespace WebCore {
@@ -253,4 +255,13 @@
return true;
}
+#ifndef NDEBUG
+
+String FloatPolygonEdge::debugString() const
+{
+ return makeString("0x", hex(reinterpret_cast<uintptr_t>(this)), " (", FormattedNumber::fixedPrecision(vertex1().x()), ',', FormattedNumber::fixedPrecision(vertex1().y()), ' ', FormattedNumber::fixedPrecision(vertex2().x()), ',', FormattedNumber::fixedPrecision(vertex2().y()), ')');
+}
+
+#endif
+
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/FloatPolygon.h (241750 => 241751)
--- trunk/Source/WebCore/platform/graphics/FloatPolygon.h 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/platform/graphics/FloatPolygon.h 2019-02-19 02:04:33 UTC (rev 241751)
@@ -27,8 +27,7 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef FloatPolygon_h
-#define FloatPolygon_h
+#pragma once
#include "FloatPoint.h"
#include "FloatRect.h"
@@ -122,6 +121,8 @@
unsigned vertexIndex2() const { return m_vertexIndex2; }
unsigned edgeIndex() const { return m_edgeIndex; }
+ String debugString() const;
+
private:
// Edge vertex index1 is less than index2, except the last edge, where index2 is 0. When a polygon edge
// is defined by 3 or more colinear vertices, index2 can be the index of the last colinear vertex.
@@ -133,15 +134,15 @@
} // namespace WebCore
-// This structure is used by PODIntervalTree for debugging.
#ifndef NDEBUG
+
namespace WTF {
+// This structure is used by PODIntervalTree for debugging.
template<> struct ValueToString<WebCore::FloatPolygonEdge*> {
- static String string(const WebCore::FloatPolygonEdge* edge) { return String::format("%p (%f,%f %f,%f)", edge, edge->vertex1().x(), edge->vertex1().y(), edge->vertex2().x(), edge->vertex2().y()); }
+ static String string(const WebCore::FloatPolygonEdge* edge) { return edge->debugString(); }
};
}
+
#endif
-
-#endif // FloatPolygon_h
Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (241750 => 241751)
--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -48,6 +48,7 @@
#include <limits.h>
#include <pal/spi/cf/CFUtilitiesSPI.h>
#include <wtf/CheckedArithmetic.h>
+#include <wtf/HexNumber.h>
#include <wtf/MathExtras.h>
#include <wtf/NeverDestroyed.h>
#include <wtf/SetForScope.h>
@@ -477,11 +478,9 @@
{
#if ENABLE(TREE_DEBUGGING)
String caLayerDescription;
-
if (!m_layer->isPlatformCALayerRemote())
- caLayerDescription = String::format("CALayer(%p) ", m_layer->platformLayer());
-
- GraphicsLayer::setName(caLayerDescription + String::format("GraphicsLayer(%p, %llu) ", this, primaryLayerID()) + name);
+ caLayerDescription = makeString("CALayer(0x", hex(reinterpret_cast<uintptr_t>(m_layer->platformLayer()), Lowercase), ") ");
+ GraphicsLayer::setName(makeString(caLayerDescription, "GraphicsLayer(0x", hex(reinterpret_cast<uintptr_t>(this), Lowercase), ", ", primaryLayerID(), ") ", name));
#else
GraphicsLayer::setName(name);
#endif
@@ -1533,7 +1532,7 @@
static NeverDestroyed<Color> washBorderColor(255, 0, 0, 100);
m_visibleTileWashLayer = createPlatformCALayer(PlatformCALayer::LayerTypeLayer, this);
- String name = String::format("Visible Tile Wash Layer %p", m_visibleTileWashLayer->platformLayer());
+ String name = makeString("Visible Tile Wash Layer 0x", hex(reinterpret_cast<uintptr_t>(m_visibleTileWashLayer->platformLayer()), Lowercase));
m_visibleTileWashLayer->setName(name);
m_visibleTileWashLayer->setAnchorPoint(FloatPoint3D(0, 0, 0));
m_visibleTileWashLayer->setBorderColor(washBorderColor);
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (241750 => 241751)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -52,6 +52,7 @@
#include <wtf/glib/GUniquePtr.h>
#include <wtf/glib/RunLoopSourcePriority.h>
#include <wtf/text/CString.h>
+#include <wtf/text/StringConcatenateNumbers.h>
#if ENABLE(MEDIA_STREAM) && GST_CHECK_VERSION(1, 10, 0)
#include "GStreamerMediaStreamSource.h"
@@ -330,8 +331,9 @@
{
#if GST_CHECK_VERSION(1, 10, 0)
m_streamPrivate = &stream;
- auto pipelineName = String::format("mediastream_%s_%p",
- (stream.hasCaptureVideoSource() || stream.hasCaptureAudioSource()) ? "Local" : "Remote", this);
+ auto pipelineName = makeString("mediastream_",
+ (stream.hasCaptureVideoSource() || stream.hasCaptureAudioSource()) ? "Local" : "Remote",
+ "_0x", hex(reinterpret_cast<uintptr_t>(this), Lowercase));
loadFull(String("mediastream://") + stream.id(), "playbin3", pipelineName);
syncOnClock(false);
@@ -2431,7 +2433,7 @@
// gst_element_factory_make() returns a floating reference so
// we should not adopt.
setPipeline(gst_element_factory_make(playbinName,
- pipelineName.isEmpty() ? String::format("play_%p", this).utf8().data() : pipelineName.utf8().data()));
+ (pipelineName.isEmpty() ? makeString("play_0x", hex(reinterpret_cast<uintptr_t>(this), Lowercase)) : pipelineName).utf8().data()));
setStreamVolumeElement(GST_STREAM_VOLUME(m_pipeline.get()));
GST_INFO_OBJECT(pipeline(), "Using legacy playbin element: %s", boolForPrinting(m_isLegacyPlaybin));
Modified: trunk/Source/WebCore/platform/gtk/PlatformKeyboardEventGtk.cpp (241750 => 241751)
--- trunk/Source/WebCore/platform/gtk/PlatformKeyboardEventGtk.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/platform/gtk/PlatformKeyboardEventGtk.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -37,6 +37,7 @@
#include "WindowsKeyboardCodes.h"
#include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>
+#include <wtf/HexNumber.h>
#include <wtf/glib/GUniquePtr.h>
namespace WebCore {
@@ -874,7 +875,7 @@
case GDK_Tab:
return "U+0009";
default:
- return String::format("U+%04X", gdk_keyval_to_unicode(gdk_keyval_to_upper(keyCode)));
+ return makeString("U+", hex(gdk_keyval_to_unicode(gdk_keyval_to_upper(keyCode)), 4));
}
}
Modified: trunk/Source/WebCore/platform/libwpe/PlatformKeyboardEventLibWPE.cpp (241750 => 241751)
--- trunk/Source/WebCore/platform/libwpe/PlatformKeyboardEventLibWPE.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/platform/libwpe/PlatformKeyboardEventLibWPE.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -30,6 +30,7 @@
#include "WindowsKeyboardCodes.h"
#include <wpe/wpe.h>
+#include <wtf/HexNumber.h>
#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -871,7 +872,7 @@
break;
}
- return String::format("U+%04X", wpe_key_code_to_unicode(keyCode));
+ return makeString("U+", hex(wpe_key_code_to_unicode(keyCode), 4));
}
int PlatformKeyboardEvent::windowsKeyCodeForWPEKeyCode(unsigned keycode)
Modified: trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp (241750 => 241751)
--- trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -42,6 +42,7 @@
#include <gst/pbutils/encoding-profile.h>
#include <gst/video/video.h>
#include <wtf/HashMap.h>
+#include <wtf/HexNumber.h>
#include <wtf/Lock.h>
#include <wtf/StdMap.h>
@@ -100,7 +101,7 @@
GstElement* makeElement(const gchar* factoryName)
{
- auto name = String::format("%s_enc_%s_%p", Name(), factoryName, this);
+ auto name = makeString(Name(), "_enc_", factoryName, "_0x", hex(reinterpret_cast<uintptr_t>(this)));
auto elem = gst_element_factory_make(factoryName, name.utf8().data());
return elem;
@@ -142,7 +143,7 @@
gst_app_sink_set_emit_signals(GST_APP_SINK(sink), TRUE);
g_signal_connect(sink, "new-sample", G_CALLBACK(newSampleCallbackTramp), this);
- auto name = String::format("%s_enc_rawcapsfilter_%p", Name(), this);
+ auto name = makeString(Name(), "_enc_rawcapsfilter_0x", hex(reinterpret_cast<uintptr_t>(this)));
m_capsFilter = gst_element_factory_make("capsfilter", name.utf8().data());
if (m_restrictionCaps)
g_object_set(m_capsFilter, "caps", m_restrictionCaps.get(), nullptr);
Modified: trunk/Source/WebCore/platform/text/TextCodecLatin1.cpp (241750 => 241751)
--- trunk/Source/WebCore/platform/text/TextCodecLatin1.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/platform/text/TextCodecLatin1.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -29,12 +29,9 @@
#include "TextCodecASCIIFastPath.h"
#include <array>
#include <wtf/text/CString.h>
-#include <wtf/text/StringBuffer.h>
#include <wtf/text/WTFString.h>
-
namespace WebCore {
-using namespace WTF;
static const UChar latin1ConversionTable[256] = {
0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, // 00-07
@@ -109,22 +106,22 @@
const uint8_t* source = reinterpret_cast<const uint8_t*>(bytes);
const uint8_t* end = reinterpret_cast<const uint8_t*>(bytes + length);
- const uint8_t* alignedEnd = alignToMachineWord(end);
+ const uint8_t* alignedEnd = WTF::alignToMachineWord(end);
LChar* destination = characters;
while (source < end) {
if (isASCII(*source)) {
// Fast path for ASCII. Most Latin-1 text will be ASCII.
- if (isAlignedToMachineWord(source)) {
+ if (WTF::isAlignedToMachineWord(source)) {
while (source < alignedEnd) {
- MachineWord chunk = *reinterpret_cast_ptr<const MachineWord*>(source);
+ auto chunk = *reinterpret_cast_ptr<const WTF::MachineWord*>(source);
- if (!isAllASCII<LChar>(chunk))
+ if (!WTF::isAllASCII<LChar>(chunk))
goto useLookupTable;
copyASCIIMachineWord(destination, source);
- source += sizeof(MachineWord);
- destination += sizeof(MachineWord);
+ source += sizeof(WTF::MachineWord);
+ destination += sizeof(WTF::MachineWord);
}
if (source == end)
@@ -170,16 +167,16 @@
while (source < end) {
if (isASCII(*source)) {
// Fast path for ASCII. Most Latin-1 text will be ASCII.
- if (isAlignedToMachineWord(source)) {
+ if (WTF::isAlignedToMachineWord(source)) {
while (source < alignedEnd) {
- MachineWord chunk = *reinterpret_cast_ptr<const MachineWord*>(source);
+ auto chunk = *reinterpret_cast_ptr<const WTF::MachineWord*>(source);
- if (!isAllASCII<LChar>(chunk))
+ if (!WTF::isAllASCII<LChar>(chunk))
goto useLookupTable16;
copyASCIIMachineWord(destination16, source);
- source += sizeof(MachineWord);
- destination16 += sizeof(MachineWord);
+ source += sizeof(WTF::MachineWord);
+ destination16 += sizeof(WTF::MachineWord);
}
if (source == end)
Modified: trunk/Source/WebCore/platform/win/GDIObjectCounter.cpp (241750 => 241751)
--- trunk/Source/WebCore/platform/win/GDIObjectCounter.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/platform/win/GDIObjectCounter.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -33,6 +33,7 @@
#include "GDIObjectCounter.h"
#include "Logging.h"
+#include <wtf/HexNumber.h>
#include <wtf/text/CString.h>
#include <windows.h>
@@ -46,7 +47,7 @@
GDIObjectCounter::GDIObjectCounter(const String& className, void* instance)
{
- init(String::format("%s (%p)", className.latin1().data(), instance));
+ init(makeString(className, " (0x", hex(reinterpret_cast<uintptr_t>(instance)), ')'));
}
void GDIObjectCounter::init(const String& identifier)
Modified: trunk/Source/WebCore/platform/win/KeyEventWin.cpp (241750 => 241751)
--- trunk/Source/WebCore/platform/win/KeyEventWin.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/platform/win/KeyEventWin.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -28,6 +28,7 @@
#include <windows.h>
#include <wtf/ASCIICType.h>
+#include <wtf/HexNumber.h>
#ifndef MAPVK_VSC_TO_VK_EX
#define MAPVK_VSC_TO_VK_EX 3
@@ -140,7 +141,7 @@
case VK_DELETE:
return "U+007F";
default:
- return String::format("U+%04X", toASCIIUpper(keyCode));
+ return makeString("U+", hex(toASCIIUpper(keyCode), 4));
}
}
Modified: trunk/Source/WebCore/rendering/FloatingObjects.cpp (241750 => 241751)
--- trunk/Source/WebCore/rendering/FloatingObjects.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/rendering/FloatingObjects.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -2,7 +2,7 @@
* Copyright (C) 1999 Lars Knoll (kn...@kde.org)
* (C) 1999 Antti Koivisto (koivi...@kde.org)
* (C) 2007 David Smith (catfish....@gmail.com)
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2003-2019 Apple Inc. All rights reserved.
* Copyright (C) Research In Motion Limited 2010. All rights reserved.
*
* This library is free software; you can redistribute it and/or
@@ -27,6 +27,8 @@
#include "RenderBlockFlow.h"
#include "RenderBox.h"
#include "RenderView.h"
+#include <wtf/HexNumber.h>
+#include <wtf/text/StringConcatenateNumbers.h>
namespace WebCore {
@@ -97,6 +99,15 @@
return locationOffsetOfBorderBox() - renderer().locationOffset();
}
+#ifndef NDEBUG
+
+String FloatingObject::debugString() const
+{
+ return makeString("0x", hex(reinterpret_cast<uintptr_t>(this)), " (", frameRect().x().toInt(), 'x', frameRect().y().toInt(), ' ', frameRect().maxX().toInt(), 'x', frameRect().maxY().toInt(), ')');
+}
+
+#endif
+
inline static bool rangesIntersect(LayoutUnit floatTop, LayoutUnit floatBottom, LayoutUnit objectTop, LayoutUnit objectBottom)
{
if (objectTop >= floatBottom || objectBottom < floatTop)
Modified: trunk/Source/WebCore/rendering/FloatingObjects.h (241750 => 241751)
--- trunk/Source/WebCore/rendering/FloatingObjects.h 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/rendering/FloatingObjects.h 2019-02-19 02:04:33 UTC (rev 241751)
@@ -2,7 +2,7 @@
* Copyright (C) 1999 Lars Knoll (kn...@kde.org)
* (C) 1999 Antti Koivisto (koivi...@kde.org)
* (C) 2007 David Smith (catfish....@gmail.com)
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2003-2019 Apple Inc. All rights reserved.
* Copyright (C) Research In Motion Limited 2010. All rights reserved.
*
* This library is free software; you can redistribute it and/or
@@ -95,6 +95,8 @@
LayoutSize marginOffset() const { ASSERT(isPlaced()); return m_marginOffset; }
LayoutSize translationOffsetToAncestor() const;
+ String debugString() const;
+
private:
WeakPtr<RenderBox> m_renderer;
WeakPtr<RootInlineBox> m_originatingLine;
@@ -188,15 +190,14 @@
} // namespace WebCore
#ifndef NDEBUG
+
namespace WTF {
// This helper is used by PODIntervalTree for debugging purposes.
template<> struct ValueToString<WebCore::FloatingObject*> {
- static String string(const WebCore::FloatingObject* floatingObject)
- {
- return String::format("%p (%ix%i %ix%i)", floatingObject, floatingObject->frameRect().x().toInt(), floatingObject->frameRect().y().toInt(), floatingObject->frameRect().maxX().toInt(), floatingObject->frameRect().maxY().toInt());
- }
+ static String string(const WebCore::FloatingObject* floatingObject) { return floatingObject->debugString(); }
};
} // namespace WTF
+
#endif
Modified: trunk/Source/WebCore/rendering/RenderFragmentContainer.cpp (241750 => 241751)
--- trunk/Source/WebCore/rendering/RenderFragmentContainer.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/rendering/RenderFragmentContainer.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -42,6 +42,7 @@
#include "RenderLayer.h"
#include "RenderView.h"
#include "StyleResolver.h"
+#include <wtf/HexNumber.h>
#include <wtf/IsoMallocInlines.h>
namespace WebCore {
@@ -560,4 +561,13 @@
fragmentedFlow->setCurrentFragmentMaintainer(nullptr);
}
+#ifndef NDEBUG
+
+String RenderFragmentContainer::debugString() const
+{
+ return makeString("0x", hex(reinterpret_cast<uintptr_t>(this), Lowercase));
+}
+
+#endif
+
} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/RenderFragmentContainer.h (241750 => 241751)
--- trunk/Source/WebCore/rendering/RenderFragmentContainer.h 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/rendering/RenderFragmentContainer.h 2019-02-19 02:04:33 UTC (rev 241751)
@@ -121,6 +121,8 @@
virtual void absoluteQuadsForBoxInFragment(Vector<FloatQuad>&, bool*, const RenderBox*, float, float) { }
+ String debugString() const;
+
protected:
RenderFragmentContainer(Element&, RenderStyle&&, RenderFragmentedFlow*);
RenderFragmentContainer(Document&, RenderStyle&&, RenderFragmentedFlow*);
Modified: trunk/Source/WebCore/rendering/RenderFragmentedFlow.h (241750 => 241751)
--- trunk/Source/WebCore/rendering/RenderFragmentedFlow.h 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/rendering/RenderFragmentedFlow.h 2019-02-19 02:04:33 UTC (rev 241751)
@@ -275,19 +275,20 @@
} // namespace WebCore
-// This structure is used by PODIntervalTree for debugging.
#ifndef NDEBUG
+
namespace WTF {
+// This structure is used by PODIntervalTree for debugging.
template <> struct ValueToString<WebCore::RenderFragmentContainer*> {
- static String string(const WebCore::RenderFragmentContainer* value) { return String::format("%p", value); }
+ static String string(const WebCore::RenderFragmentContainer* value) { return value->debugString(); }
};
-
template <> struct ValueToString<WeakPtr<WebCore::RenderFragmentContainer>> {
- static String string(const WeakPtr<WebCore::RenderFragmentContainer> value) { return value.get() ? ValueToString<WebCore::RenderFragmentContainer*>::string(value.get()) : String(); }
+ static String string(const WeakPtr<WebCore::RenderFragmentContainer>& value) { return value ? value->debugString() : String { }; }
};
} // namespace WTF
+
#endif
SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderFragmentedFlow, isRenderFragmentedFlow())
Modified: trunk/Source/WebCore/testing/Internals.cpp (241750 => 241751)
--- trunk/Source/WebCore/testing/Internals.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebCore/testing/Internals.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -117,9 +117,6 @@
#include "MockPageOverlay.h"
#include "MockPageOverlayClient.h"
#include "NetworkLoadInformation.h"
-#if USE(CG)
-#include "PDFDocumentImage.h"
-#endif
#include "Page.h"
#include "PageCache.h"
#include "PageOverlay.h"
@@ -183,16 +180,19 @@
#include <_javascript_Core/InspectorFrontendChannel.h>
#include <_javascript_Core/JSCInlines.h>
#include <_javascript_Core/JSCJSValue.h>
+#include <wtf/HexNumber.h>
#include <wtf/JSONValues.h>
#include <wtf/Language.h>
#include <wtf/MemoryPressureHandler.h>
#include <wtf/MonotonicTime.h>
#include <wtf/URLHelpers.h>
-#include <wtf/text/StringBuffer.h>
#include <wtf/text/StringBuilder.h>
#include <wtf/text/StringConcatenateNumbers.h>
-#include <wtf/text/StringView.h>
+#if USE(CG)
+#include "PDFDocumentImage.h"
+#endif
+
#if ENABLE(INPUT_TYPE_COLOR)
#include "ColorChooser.h"
#endif
@@ -621,7 +621,7 @@
String Internals::address(Node& node)
{
- return String::format("%p", &node);
+ return makeString("0x", hex(reinterpret_cast<uintptr_t>(&node)));
}
bool Internals::nodeNeedsStyleRecalc(Node& node)
Modified: trunk/Source/WebKit/ChangeLog (241750 => 241751)
--- trunk/Source/WebKit/ChangeLog 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebKit/ChangeLog 2019-02-19 02:04:33 UTC (rev 241751)
@@ -1,3 +1,30 @@
+2019-02-16 Darin Adler <da...@apple.com>
+
+ Continue reducing use of String::format, now focusing on hex: "%p", "%x", etc.
+ https://bugs.webkit.org/show_bug.cgi?id=194752
+
+ Reviewed by Daniel Bates.
+
+ * Platform/IPC/win/ConnectionWin.cpp:
+ (IPC::Connection::createServerAndClientIdentifiers): Use makeString instead of
+ String::format.
+ * Shared/win/WebEventFactory.cpp:
+ (WebKit::keyIdentifierFromEvent): Ditto.
+
+ * UIProcess/API/APINavigation.cpp:
+ (API::Navigation::loggingString const): Use hex instead of String::format.
+ * UIProcess/SuspendedPageProxy.cpp:
+ (WebKit::SuspendedPageProxy::loggingString const): Ditto.
+
+ * UIProcess/WebBackForwardList.cpp:
+ (WebKit::WebBackForwardList::loggingString): Added a "0x".
+
+ * UIProcess/gtk/InputMethodFilter.cpp:
+ (WebKit::InputMethodFilter::logHandleKeyboardEventForTesting): Use makeString and hex
+ instead of String::format and "%x".
+ (WebKit::InputMethodFilter::logHandleKeyboardEventWithCompositionResultsForTesting):
+ Ditto.
+
2019-02-18 Wenson Hsieh <wenson_hs...@apple.com>
[iOS] Support pasting item-provider-backed data on the pasteboard as attachment elements
Modified: trunk/Source/WebKit/Platform/IPC/win/ConnectionWin.cpp (241750 => 241751)
--- trunk/Source/WebKit/Platform/IPC/win/ConnectionWin.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebKit/Platform/IPC/win/ConnectionWin.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -27,8 +27,8 @@
#include "Connection.h"
#include "DataReference.h"
+#include <wtf/HexNumber.h>
#include <wtf/RandomNumber.h>
-#include <wtf/text/WTFString.h>
namespace IPC {
@@ -41,7 +41,7 @@
do {
unsigned uniqueID = randomNumber() * std::numeric_limits<unsigned>::max();
- pipeName = String::format("\\\\.\\pipe\\com.apple.WebKit.%x", uniqueID);
+ pipeName = makeString("\\\\.\\pipe\\com.apple.WebKit.", hex(uniqueID));
serverIdentifier = ::CreateNamedPipe(pipeName.charactersWithNullTermination().data(),
PIPE_ACCESS_DUPLEX | FILE_FLAG_FIRST_PIPE_INSTANCE | FILE_FLAG_OVERLAPPED,
Modified: trunk/Source/WebKit/Shared/win/WebEventFactory.cpp (241750 => 241751)
--- trunk/Source/WebKit/Shared/win/WebEventFactory.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebKit/Shared/win/WebEventFactory.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -33,6 +33,7 @@
#include <WebCore/WindowsKeyboardCodes.h>
#include <windowsx.h>
#include <wtf/ASCIICType.h>
+#include <wtf/HexNumber.h>
namespace WebKit {
@@ -324,7 +325,7 @@
case VK_DELETE:
return String("U+007F"); // Standard says that DEL becomes U+007F.
default:
- return String::format("U+%04X", toASCIIUpper(keyCode));
+ return makeString("U+", hex(toASCIIUpper(keyCode), 4));
}
}
Modified: trunk/Source/WebKit/UIProcess/API/APINavigation.cpp (241750 => 241751)
--- trunk/Source/WebKit/UIProcess/API/APINavigation.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebKit/UIProcess/API/APINavigation.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -29,6 +29,7 @@
#include "WebBackForwardListItem.h"
#include "WebNavigationState.h"
#include <wtf/DebugUtilities.h>
+#include <wtf/HexNumber.h>
namespace API {
using namespace WebCore;
@@ -82,10 +83,12 @@
}
#if !LOG_DISABLED
+
const char* Navigation::loggingString() const
{
- return debugString("Most recent URL: ", m_currentRequest.url().string(), " Back/forward list item URL: '", m_targetItem ? m_targetItem->url() : WTF::String { }, WTF::String::format("' (%p)", m_targetItem.get()));
+ return debugString("Most recent URL: ", m_currentRequest.url().string(), " Back/forward list item URL: '", m_targetItem ? m_targetItem->url() : WTF::String { }, "' (0x", hex(reinterpret_cast<uintptr_t>(m_targetItem.get())), ')');
}
+
#endif
} // namespace API
Modified: trunk/Source/WebKit/UIProcess/SuspendedPageProxy.cpp (241750 => 241751)
--- trunk/Source/WebKit/UIProcess/SuspendedPageProxy.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebKit/UIProcess/SuspendedPageProxy.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -35,6 +35,7 @@
#include "WebProcessPool.h"
#include "WebProcessProxy.h"
#include <wtf/DebugUtilities.h>
+#include <wtf/HexNumber.h>
#include <wtf/URL.h>
namespace WebKit {
@@ -207,10 +208,12 @@
}
#if !LOG_DISABLED
+
const char* SuspendedPageProxy::loggingString() const
{
- return debugString("(", String::format("%p", this), " page ID ", String::number(m_page.pageID()), ", m_suspensionState ", String::number(static_cast<unsigned>(m_suspensionState)), ")");
+ return debugString("(0x", hex(reinterpret_cast<uintptr_t>(this)), " page ID ", m_page.pageID(), ", m_suspensionState ", static_cast<unsigned>(m_suspensionState), ')');
}
+
#endif
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/WebBackForwardList.cpp (241750 => 241751)
--- trunk/Source/WebKit/UIProcess/WebBackForwardList.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebKit/UIProcess/WebBackForwardList.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -480,7 +480,7 @@
{
StringBuilder builder;
- builder.appendLiteral("WebBackForwardList ");
+ builder.appendLiteral("WebBackForwardList 0x");
appendUnsignedAsHex(reinterpret_cast<uintptr_t>(this), builder);
builder.appendLiteral(" - ");
builder.appendNumber(m_entries.size());
Modified: trunk/Source/WebKit/UIProcess/gtk/InputMethodFilter.cpp (241750 => 241751)
--- trunk/Source/WebKit/UIProcess/gtk/InputMethodFilter.cpp 2019-02-19 00:52:40 UTC (rev 241750)
+++ trunk/Source/WebKit/UIProcess/gtk/InputMethodFilter.cpp 2019-02-19 02:04:33 UTC (rev 241751)
@@ -29,6 +29,7 @@
#include <WebCore/IntRect.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
+#include <wtf/HexNumber.h>
#include <wtf/Vector.h>
#include <wtf/glib/GUniquePtr.h>
@@ -445,9 +446,9 @@
const char* eventType = event->type == GDK_KEY_RELEASE ? "release" : "press";
const char* fakedString = faked == EventFaked ? " (faked)" : "";
if (!eventString.isNull())
- m_events.append(String::format("sendSimpleKeyEvent type=%s keycode=%x text='%s'%s", eventType, event->keyval, eventString.utf8().data(), fakedString));
+ m_events.append(makeString("sendSimpleKeyEvent type=", eventType, " keycode=", hex(event->keyval), " text='", eventString, '\'', fakedString));
else
- m_events.append(String::format("sendSimpleKeyEvent type=%s keycode=%x%s", eventType, event->keyval, fakedString));
+ m_events.append(makeString("sendSimpleKeyEvent type=", eventType, " keycode=", hex(event->keyval), fakedString));
}
void InputMethodFilter::logHandleKeyboardEventWithCompositionResultsForTesting(GdkEventKey* event, ResultsToSend resultsToSend, EventFakedForComposition faked)
@@ -454,7 +455,7 @@
{
const char* eventType = event->type == GDK_KEY_RELEASE ? "release" : "press";
const char* fakedString = faked == EventFaked ? " (faked)" : "";
- m_events.append(String::format("sendKeyEventWithCompositionResults type=%s keycode=%x%s", eventType, event->keyval, fakedString));
+ m_events.append(makeString("sendKeyEventWithCompositionResults type=", eventType, " keycode=", hex(event->keyval), fakedString));
if (resultsToSend & Composition && !m_confirmedComposition.isNull())
logConfirmCompositionForTesting();