WebKit Bugzilla
Attachment 362287 Details for
Bug 194752
: Continue reducing use of String::format, now focusing on hex: "%p", "%x", etc.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194752-20190218035724.patch (text/plain), 72.48 KB, created by
Darin Adler
on 2019-02-18 03:57:25 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Darin Adler
Created:
2019-02-18 03:57:25 PST
Size:
72.48 KB
patch
obsolete
>Subversion Revision: 241652 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 165c1820f75845e5e77b2981132b8a8ff9decd53..4f7dc7ae31c4e437d0f1e30d78a8f5fcbe22d848 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,19 @@ >+2019-02-16 Darin Adler <darin@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 NOBODY (OOPS!). >+ >+ * 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 lets do that. >+ >+ * parser/Lexer.cpp: >+ (JSC::Lexer<T>::invalidCharacterMessage const): Use makeString and hex instead of >+ String::format and "%04x". >+ > 2019-02-17 Commit Queue <commit-queue@webkit.org> > > Unreviewed, rolling out r241612. >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index af993227756a028a20044760ade9b421a555e55e..5e6ba11a80335cb57f8ff31d8f0d9257e3de67fd 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,39 @@ >+2019-02-16 Darin Adler <darin@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 NOBODY (OOPS!). >+ >+ * 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-15 Ross Kirsling <ross.kirsling@sony.com> > > [WTF] Add environment variable helpers >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 2a1ed8afd7f4823ceb0091d4aa6f6512e4e9b717..7e5737e2e0030acda48117970f9cb9abfd4c7558 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,96 @@ >+2019-02-16 Darin Adler <darin@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 NOBODY (OOPS!). >+ >+ * 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-16 Zalan Bujtas <zalan@apple.com> > > [LFC] RenderImage's default intrinsic size is 0. >diff --git a/Source/WebCore/PAL/ChangeLog b/Source/WebCore/PAL/ChangeLog >index cb28b2c0b230b6bd076258a55f2df357fb33ab18..2cbf3f92ef9a0968612a28554295c27e15267ea5 100644 >--- a/Source/WebCore/PAL/ChangeLog >+++ b/Source/WebCore/PAL/ChangeLog >@@ -1,3 +1,13 @@ >+2019-02-16 Darin Adler <darin@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 NOBODY (OOPS!). >+ >+ * pal/FileSizeFormatter.cpp: >+ (fileSizeDescription): Use makeString instead of String::format. >+ > 2019-02-15 Ross Kirsling <ross.kirsling@sony.com> > > [WTF] Add environment variable helpers >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 8522ca45ea81707e2fc853bee7a09b30c9b6015e..036d20565ebdb7c81423b340764e5a762158f740 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,30 @@ >+2019-02-16 Darin Adler <darin@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 NOBODY (OOPS!). >+ >+ * 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-15 Youenn Fablet <youenn@apple.com> > > NetworkDataTask should check its client before calling shouldCaptureExtraNetworkLoadMetrics >diff --git a/Source/JavaScriptCore/heap/HeapSnapshotBuilder.cpp b/Source/JavaScriptCore/heap/HeapSnapshotBuilder.cpp >index cd91f800f80d664a11332463492e63c8ca31c0ca..233f68308addd1359dfc4d50fa193e221ca147b6 100644 >--- a/Source/JavaScriptCore/heap/HeapSnapshotBuilder.cpp >+++ b/Source/JavaScriptCore/heap/HeapSnapshotBuilder.cpp >@@ -435,9 +435,9 @@ String HeapSnapshotBuilder::json(Function<bool (const HeapSnapshotNode&)> allowN > 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('"'); > } >diff --git a/Source/JavaScriptCore/parser/Lexer.cpp b/Source/JavaScriptCore/parser/Lexer.cpp >index ecf72eaa7d0acb7bf4f936cc16187a898113e3f1..9dc9de349a20be4e131a1c65ff3dcb0f572212cd 100644 >--- a/Source/JavaScriptCore/parser/Lexer.cpp >+++ b/Source/JavaScriptCore/parser/Lexer.cpp >@@ -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 @@ String Lexer<T>::invalidCharacterMessage() const > 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), '\''); > } > } > >diff --git a/Source/WTF/WTF.xcodeproj/project.pbxproj b/Source/WTF/WTF.xcodeproj/project.pbxproj >index 7e5ae223bd779b4d11a085e4be10b3bc2aa3c9c8..3e4e8301d50e960d6d42f6f3eaa51499f4cc7fa3 100644 >--- a/Source/WTF/WTF.xcodeproj/project.pbxproj >+++ b/Source/WTF/WTF.xcodeproj/project.pbxproj >@@ -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 */; }; > A307FD29220CB4350021B62C /* EnvironmentPOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A307FD28220CB4350021B62C /* EnvironmentPOSIX.cpp */; }; >@@ -430,6 +432,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>"; }; >@@ -972,6 +976,7 @@ > A8A472B8151A825A004123FF /* HashTable.cpp */, > A8A472B9151A825A004123FF /* HashTable.h */, > A8A472BA151A825A004123FF /* HashTraits.h */, >+ 93B5B44D2213D616004B7AA7 /* HexNumber.cpp */, > A8A472BB151A825A004123FF /* HexNumber.h */, > 517A53571F5734B700DCDC0A /* Identified.h */, > FE8925AF1D00DAEC0046907E /* Indenter.h */, >@@ -1006,6 +1011,7 @@ > 0F60F32E1DFCBD1B00416D6C /* LockedPrintStream.h */, > A8A472C3151A825A004123FF /* Locker.h */, > 5311BD551EA7E15A00525281 /* LocklessBag.h */, >+ 93B5B45022171EE9004B7AA7 /* Logger.cpp */, > 077CD86A1FD9CFD200828587 /* Logger.h */, > 077CD86B1FD9CFD300828587 /* LoggerHelper.h */, > 513E170A1CD7D5BF00E3650B /* LoggingAccumulator.h */, >@@ -1542,6 +1548,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 */, >@@ -1549,6 +1556,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 */, >diff --git a/Source/WTF/wtf/CMakeLists.txt b/Source/WTF/wtf/CMakeLists.txt >index 8104da3b8d9ca4b0c118f899ef99ebddf28652a0..a835d4ddbf493cbc906752535fa4bd799051cf35 100644 >--- a/Source/WTF/wtf/CMakeLists.txt >+++ b/Source/WTF/wtf/CMakeLists.txt >@@ -364,11 +364,13 @@ set(WTF_SOURCES > 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 >diff --git a/Source/WTF/wtf/HexNumber.cpp b/Source/WTF/wtf/HexNumber.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..e3c7f82452a828476c66eec95aa200452867b3fd >--- /dev/null >+++ b/Source/WTF/wtf/HexNumber.cpp >@@ -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 >diff --git a/Source/WTF/wtf/HexNumber.h b/Source/WTF/wtf/HexNumber.h >index 43a1a10fe04bd9761723e73d6df7e4731204476d..2edf0b8809598fe6dff212152e15a9fa2b9dd2fd 100644 >--- a/Source/WTF/wtf/HexNumber.h >+++ b/Source/WTF/wtf/HexNumber.h >@@ -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 @@ inline const LChar* hexDigitsForMode(HexConversionMode mode) > 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 @@ inline void appendByteAsHex(unsigned char byte, T& destination, HexConversionMod > 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) >+{ >+ // 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) > { >- 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); >+ 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; >diff --git a/Source/WTF/wtf/Logger.cpp b/Source/WTF/wtf/Logger.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..6c9b0abff471b3d38bdf84c65c040f4e0a20c53e >--- /dev/null >+++ b/Source/WTF/wtf/Logger.cpp >@@ -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; >diff --git a/Source/WTF/wtf/Logger.h b/Source/WTF/wtf/Logger.h >index 2897d00af7ec6e95fb5d08e6116212b2827a6efc..b0cdbf8a6fd923e2a9c3e4f0d4f97e8724050fb6 100644 >--- a/Source/WTF/wtf/Logger.h >+++ b/Source/WTF/wtf/Logger.h >@@ -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 @@ public: > { > } > >+ WTF_EXPORT String toString() const; >+ > const char* className { nullptr }; > const char* methodName { nullptr }; > const uintptr_t objectPtr { 0 }; >@@ -260,22 +256,8 @@ private: > 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 >diff --git a/Source/WTF/wtf/text/StringConcatenateNumbers.h b/Source/WTF/wtf/text/StringConcatenateNumbers.h >index 6ce72782af43db72b5d6c989273dc15557b7cfb2..5c0cba9a9f9c9a3f9cf323d96e753f07814c8067 100644 >--- a/Source/WTF/wtf/text/StringConcatenateNumbers.h >+++ b/Source/WTF/wtf/text/StringConcatenateNumbers.h >@@ -41,10 +41,7 @@ public: > > 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: >@@ -61,10 +58,7 @@ public: > > 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 @@ public: > > unsigned length() const { return m_length; } > bool is8Bit() const { return true; } >- >- void writeTo(LChar* destination) const >- { >- for (unsigned i = 0; i < m_length; ++i) >- destination[i] = m_buffer[i]; >- } >- >- 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 }; } >+ 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); } >+ > NumberToStringBuffer m_buffer; > unsigned m_length; > }; >@@ -131,34 +115,18 @@ private: > 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; } >- >- 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() }; } >+ 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_numberFormatter; >+ const FormattedNumber& m_number; > }; > > } >diff --git a/Source/WebCore/Modules/websockets/WebSocket.cpp b/Source/WebCore/Modules/websockets/WebSocket.cpp >index 351be8bc1e65507a2fa72a727471929ddb7d6ef5..05494c4d86682b4a30642699280f5d824a7c0556 100644 >--- a/Source/WebCore/Modules/websockets/WebSocket.cpp >+++ b/Source/WebCore/Modules/websockets/WebSocket.cpp >@@ -55,12 +55,12 @@ > #include <JavaScriptCore/ArrayBufferView.h> > #include <JavaScriptCore/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" >diff --git a/Source/WebCore/PAL/pal/FileSizeFormatter.cpp b/Source/WebCore/PAL/pal/FileSizeFormatter.cpp >index e017450490d3c13d6374ab33a33e2c3566612a58..a18615d27c1802d4d2772a0b5123bc9605555c8b 100644 >--- a/Source/WebCore/PAL/pal/FileSizeFormatter.cpp >+++ b/Source/WebCore/PAL/pal/FileSizeFormatter.cpp >@@ -35,7 +35,7 @@ String fileSizeDescription(uint64_t size) > // 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) >diff --git a/Source/WebCore/css/CSSMarkup.cpp b/Source/WebCore/css/CSSMarkup.cpp >index 9a75ed59c076f479ffe5de1ed452b3cca7e2c47d..51a52da480b688f0645b0e67d6e4463081268c52 100644 >--- a/Source/WebCore/css/CSSMarkup.cpp >+++ b/Source/WebCore/css/CSSMarkup.cpp >@@ -29,7 +29,6 @@ > > #include "CSSParserIdioms.h" > #include <wtf/HexNumber.h> >-#include <wtf/text/StringBuffer.h> > #include <wtf/text/StringBuilder.h> > > namespace WebCore { >diff --git a/Source/WebCore/css/CSSPrimitiveValue.cpp b/Source/WebCore/css/CSSPrimitiveValue.cpp >index 26eed35b014bc1f518dab58c075ca70ab617bdca..25688db3302e36935f54d8075331c51a655e3bdc 100644 >--- a/Source/WebCore/css/CSSPrimitiveValue.cpp >+++ b/Source/WebCore/css/CSSPrimitiveValue.cpp >@@ -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) >diff --git a/Source/WebCore/css/CSSUnicodeRangeValue.cpp b/Source/WebCore/css/CSSUnicodeRangeValue.cpp >index 8426ceebe7b7c8dd117b9a3dabda9a1e456eeb9e..a37a1d687755c247a3221e563ca897233db5f6a9 100644 >--- a/Source/WebCore/css/CSSUnicodeRangeValue.cpp >+++ b/Source/WebCore/css/CSSUnicodeRangeValue.cpp >@@ -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 >diff --git a/Source/WebCore/html/HTMLMediaElement.h b/Source/WebCore/html/HTMLMediaElement.h >index 34e184ae70ca2001988dd1749fa3ca7579b77852..65e0b83f6a26030594184adc3bd576f19726e480 100644 >--- a/Source/WebCore/html/HTMLMediaElement.h >+++ b/Source/WebCore/html/HTMLMediaElement.h >@@ -1206,46 +1206,29 @@ String convertEnumerationToString(HTMLMediaElement::AutoplayEventPlaybackState); > > 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(const 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(WebCore::TextTrackCue* const& 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)); } >diff --git a/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp b/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp >index b0109b7cb137f72fe554062dc88ef3e93aa6e54d..1cb4935c401a859078d24cac66d28562be6f8861 100644 >--- a/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp >+++ b/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp >@@ -98,6 +98,7 @@ > #include <JavaScriptCore/TypedArrayInlines.h> > #include <JavaScriptCore/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 @@ namespace { > 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), ')'); > } > } > >diff --git a/Source/WebCore/html/track/TextTrackCue.cpp b/Source/WebCore/html/track/TextTrackCue.cpp >index c47b4805390b5419fd4a68cb74857e3749b2135c..5b948e3d17d11f31aed32ed4acbd1fb1b301c37f 100644 >--- a/Source/WebCore/html/track/TextTrackCue.cpp >+++ b/Source/WebCore/html/track/TextTrackCue.cpp >@@ -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 @@ String TextTrackCue::toJSONString() const > 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 >diff --git a/Source/WebCore/html/track/TextTrackCue.h b/Source/WebCore/html/track/TextTrackCue.h >index cfee47d844a47d4fb15ae5436f326717354bd76b..de1db300162e258fffdae81d234eed905972307e 100644 >--- a/Source/WebCore/html/track/TextTrackCue.h >+++ b/Source/WebCore/html/track/TextTrackCue.h >@@ -86,6 +86,7 @@ public: > virtual void didChange(); > > String toJSONString() const; >+ String debugString() const; > > using RefCounted::ref; > using RefCounted::deref; >@@ -126,15 +127,10 @@ private: > > 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(); } > }; > > } >diff --git a/Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp b/Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp >index e6ac8cbe3a82f83e6c486c5cbbcaa6fda16b52ad..e78ffaa619569781f71823ae73ccdea439ad1f6c 100644 >--- a/Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp >+++ b/Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp >@@ -36,6 +36,7 @@ > #include "RenderTheme.h" > #include "ResourceUsageThread.h" > #include <JavaScriptCore/VM.h> >+#include <wtf/text/StringConcatenateNumbers.h> > > namespace WebCore { > >@@ -51,11 +52,11 @@ static String cpuUsageString(float cpuUsage) > 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); > } > >diff --git a/Source/WebCore/platform/cocoa/KeyEventCocoa.mm b/Source/WebCore/platform/cocoa/KeyEventCocoa.mm >index 13af35e8fb69305db7f1c9a785a40c72dbdc07b9..62f1e46fd9bc4d385ec3f55bb4100ce7f38ca9d6 100644 >--- a/Source/WebCore/platform/cocoa/KeyEventCocoa.mm >+++ b/Source/WebCore/platform/cocoa/KeyEventCocoa.mm >@@ -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 @@ String keyIdentifierForCharCode(unichar charCode) > // 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)); > } > } > >diff --git a/Source/WebCore/platform/gamepad/mac/HIDGamepad.cpp b/Source/WebCore/platform/gamepad/mac/HIDGamepad.cpp >index 7c1ee8ffd3811bd47262f97a89ea7a55122a4c4f..4f5d90e566e272117b553ece9211d479ddd0487c 100644 >--- a/Source/WebCore/platform/gamepad/mac/HIDGamepad.cpp >+++ b/Source/WebCore/platform/gamepad/mac/HIDGamepad.cpp >@@ -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 @@ HIDGamepad::HIDGamepad(IOHIDDeviceRef hidDevice, unsigned index) > > // 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(); > } >diff --git a/Source/WebCore/platform/graphics/Color.cpp b/Source/WebCore/platform/graphics/Color.cpp >index 9532c91ee675c1a0d51d55cacc3ac402183c8fdb..ee72938828c61963b95be701ffe0664201d9a813 100644 >--- a/Source/WebCore/platform/graphics/Color.cpp >+++ b/Source/WebCore/platform/graphics/Color.cpp >@@ -388,17 +388,9 @@ String Color::cssText() const > 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 >diff --git a/Source/WebCore/platform/graphics/FloatPolygon.cpp b/Source/WebCore/platform/graphics/FloatPolygon.cpp >index 8c897315ee7bcab6c337be50c56da4d6016f58a9..504cfaddf6e43f2f22d3487bbe9b5aac3c28ed41 100644 >--- a/Source/WebCore/platform/graphics/FloatPolygon.cpp >+++ b/Source/WebCore/platform/graphics/FloatPolygon.cpp >@@ -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 @@ bool VertexPair::intersection(const VertexPair& other, FloatPoint& point) const > 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 >diff --git a/Source/WebCore/platform/graphics/FloatPolygon.h b/Source/WebCore/platform/graphics/FloatPolygon.h >index a0cf8c6ce906e07451ced57f0cac9ec2b538b267..9461fe129f0ea4f32b2fdf05f7f258f5fb8656f8 100644 >--- a/Source/WebCore/platform/graphics/FloatPolygon.h >+++ b/Source/WebCore/platform/graphics/FloatPolygon.h >@@ -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 @@ public: > 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 @@ private: > > } // 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 >+#endif >diff --git a/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp b/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp >index c60b770a58176799139a58e616b6b991eee5b6d4..70c5f9e59d6dc30b3ca701323c228bcb1d1b814e 100644 >--- a/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp >+++ b/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp >@@ -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 @@ void GraphicsLayerCA::setName(const String& name) > { > #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 @@ void GraphicsLayerCA::recursiveCommitChanges(CommitState& commitState, const Tra > 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); >diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp >index 9e50cdc40dac032755c9212e88f6156cd19ab0b9..050ca6d9b1b59a0ad1053e02b4c47fa17890af60 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp >+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp >@@ -53,6 +53,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" >@@ -331,8 +332,9 @@ void MediaPlayerPrivateGStreamer::load(MediaStreamPrivate& stream) > { > #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); >@@ -2432,7 +2434,7 @@ void MediaPlayerPrivateGStreamer::createGSTPlayBin(const gchar* playbinName, con > // 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)); >diff --git a/Source/WebCore/platform/gtk/PlatformKeyboardEventGtk.cpp b/Source/WebCore/platform/gtk/PlatformKeyboardEventGtk.cpp >index 31784f620be9e076974f8fdfc87b616698ab4ba1..623d815f251571cc3d030c407e4bdd95b67e7662 100644 >--- a/Source/WebCore/platform/gtk/PlatformKeyboardEventGtk.cpp >+++ b/Source/WebCore/platform/gtk/PlatformKeyboardEventGtk.cpp >@@ -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 @@ String PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(unsigned keyCode) > 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)); > } > } > >diff --git a/Source/WebCore/platform/libwpe/PlatformKeyboardEventLibWPE.cpp b/Source/WebCore/platform/libwpe/PlatformKeyboardEventLibWPE.cpp >index db2824605ea8fe1f2dab30845e2e55dea7a953d1..c65de80616c9edfc3d6e0742d0dcb583f1d9e632 100644 >--- a/Source/WebCore/platform/libwpe/PlatformKeyboardEventLibWPE.cpp >+++ b/Source/WebCore/platform/libwpe/PlatformKeyboardEventLibWPE.cpp >@@ -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 @@ String PlatformKeyboardEvent::keyIdentifierForWPEKeyCode(unsigned keyCode) > 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) >diff --git a/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp b/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp >index ee740b4a4d288db306610083dd43c619d5567dab..7f0d48221f44c58d358e5724963a30852e133104 100644 >--- a/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp >+++ b/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp >@@ -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 @@ public: > > 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 @@ public: > 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); >diff --git a/Source/WebCore/platform/text/TextCodecLatin1.cpp b/Source/WebCore/platform/text/TextCodecLatin1.cpp >index fda78e1745da772601daf13b4be652b0cd871a3b..931453328a6f669485ee01f8a4e2cede502677ff 100644 >--- a/Source/WebCore/platform/text/TextCodecLatin1.cpp >+++ b/Source/WebCore/platform/text/TextCodecLatin1.cpp >@@ -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 @@ String TextCodecLatin1::decode(const char* bytes, size_t length, bool, bool, boo > > 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 @@ upConvertTo16Bit: > 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) >diff --git a/Source/WebCore/platform/win/GDIObjectCounter.cpp b/Source/WebCore/platform/win/GDIObjectCounter.cpp >index a939f2b529584f6dfe6a1d43886827d1eb799dd5..f3ed18eceeef3847c846f819f778576fe75bcd9b 100644 >--- a/Source/WebCore/platform/win/GDIObjectCounter.cpp >+++ b/Source/WebCore/platform/win/GDIObjectCounter.cpp >@@ -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& identifier) > > 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) >diff --git a/Source/WebCore/platform/win/KeyEventWin.cpp b/Source/WebCore/platform/win/KeyEventWin.cpp >index da903a16d603e70ce3bfeafe2522323845384fad..b2356c5f4fc4d467d8cc475f7bcbf57472cec179 100644 >--- a/Source/WebCore/platform/win/KeyEventWin.cpp >+++ b/Source/WebCore/platform/win/KeyEventWin.cpp >@@ -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 @@ static String keyIdentifierForWindowsKeyCode(unsigned short keyCode) > case VK_DELETE: > return "U+007F"; > default: >- return String::format("U+%04X", toASCIIUpper(keyCode)); >+ return makeString("U+", hex(toASCIIUpper(keyCode), 4)); > } > } > >diff --git a/Source/WebCore/rendering/FloatingObjects.cpp b/Source/WebCore/rendering/FloatingObjects.cpp >index 1115d885d01d3f3eb117faa5de086c83db307374..53b8d5ce1329b8d6beb0fb8f0dd47ab21a633f8b 100644 >--- a/Source/WebCore/rendering/FloatingObjects.cpp >+++ b/Source/WebCore/rendering/FloatingObjects.cpp >@@ -2,7 +2,7 @@ > * Copyright (C) 1999 Lars Knoll (knoll@kde.org) > * (C) 1999 Antti Koivisto (koivisto@kde.org) > * (C) 2007 David Smith (catfish.man@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 @@ LayoutSize FloatingObject::translationOffsetToAncestor() const > 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) >diff --git a/Source/WebCore/rendering/FloatingObjects.h b/Source/WebCore/rendering/FloatingObjects.h >index 1e91d9b78fc1c99bf034f2b70a4a871c27523013..250b33d45067d726c1587b06aa7da0d217b2f807 100644 >--- a/Source/WebCore/rendering/FloatingObjects.h >+++ b/Source/WebCore/rendering/FloatingObjects.h >@@ -2,7 +2,7 @@ > * Copyright (C) 1999 Lars Knoll (knoll@kde.org) > * (C) 1999 Antti Koivisto (koivisto@kde.org) > * (C) 2007 David Smith (catfish.man@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 @@ public: > 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 @@ private: > } // 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 >diff --git a/Source/WebCore/rendering/RenderFragmentContainer.cpp b/Source/WebCore/rendering/RenderFragmentContainer.cpp >index 5661f006d161e2353b2dc32967a7ad78a77e1d48..51a9e4684344d2637d04a91fb59a3cd6ef8f06ed 100644 >--- a/Source/WebCore/rendering/RenderFragmentContainer.cpp >+++ b/Source/WebCore/rendering/RenderFragmentContainer.cpp >@@ -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 @@ CurrentRenderFragmentContainerMaintainer::~CurrentRenderFragmentContainerMaintai > fragmentedFlow->setCurrentFragmentMaintainer(nullptr); > } > >+#ifndef NDEBUG >+ >+String RenderFragmentContainer::debugString() const >+{ >+ return makeString("0x", hex(reinterpret_cast<uintptr_t>(this), Lowercase)); >+} >+ >+#endif >+ > } // namespace WebCore >diff --git a/Source/WebCore/rendering/RenderFragmentContainer.h b/Source/WebCore/rendering/RenderFragmentContainer.h >index b05bada000ef79ed5584fda834bfd5f0d4a180ed..8d989691363b81bfd9caad44ea7f433414718be2 100644 >--- a/Source/WebCore/rendering/RenderFragmentContainer.h >+++ b/Source/WebCore/rendering/RenderFragmentContainer.h >@@ -121,6 +121,8 @@ public: > > virtual void absoluteQuadsForBoxInFragment(Vector<FloatQuad>&, bool*, const RenderBox*, float, float) { } > >+ String debugString() const; >+ > protected: > RenderFragmentContainer(Element&, RenderStyle&&, RenderFragmentedFlow*); > RenderFragmentContainer(Document&, RenderStyle&&, RenderFragmentedFlow*); >diff --git a/Source/WebCore/rendering/RenderFragmentedFlow.h b/Source/WebCore/rendering/RenderFragmentedFlow.h >index f14d0857c7268bde8b245df7212227c989092c8d..439c18716a824b716a6958edd01b376a6ae68ad2 100644 >--- a/Source/WebCore/rendering/RenderFragmentedFlow.h >+++ b/Source/WebCore/rendering/RenderFragmentedFlow.h >@@ -275,19 +275,20 @@ protected: > > } // 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.get() ? value->debugString() : String(); } > }; > > } // namespace WTF >+ > #endif > > SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderFragmentedFlow, isRenderFragmentedFlow()) >diff --git a/Source/WebCore/testing/Internals.cpp b/Source/WebCore/testing/Internals.cpp >index 21a0597b675ce3a430504c4f8a725eb644e272cb..b06a1f83c37c84b6271d09d29a2532bd77d4cc60 100644 >--- a/Source/WebCore/testing/Internals.cpp >+++ b/Source/WebCore/testing/Internals.cpp >@@ -115,9 +115,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" >@@ -181,15 +178,18 @@ > #include <JavaScriptCore/InspectorFrontendChannel.h> > #include <JavaScriptCore/JSCInlines.h> > #include <JavaScriptCore/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" >@@ -619,7 +619,7 @@ ExceptionOr<double> Internals::svgAnimationsInterval(SVGSVGElement& element) con > > String Internals::address(Node& node) > { >- return String::format("%p", &node); >+ return makeString("0x", hex(reinterpret_cast<uintptr_t>(&node))); > } > > bool Internals::nodeNeedsStyleRecalc(Node& node) >diff --git a/Source/WebKit/Platform/IPC/win/ConnectionWin.cpp b/Source/WebKit/Platform/IPC/win/ConnectionWin.cpp >index 4e5f8712ad0dacf9f2cf113b2d02f70399f89b4e..ebb37384c337bf12f5d6de8a6b46f6f0481c78f9 100644 >--- a/Source/WebKit/Platform/IPC/win/ConnectionWin.cpp >+++ b/Source/WebKit/Platform/IPC/win/ConnectionWin.cpp >@@ -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 @@ bool Connection::createServerAndClientIdentifiers(HANDLE& serverIdentifier, HAND > > 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, >diff --git a/Source/WebKit/Shared/win/WebEventFactory.cpp b/Source/WebKit/Shared/win/WebEventFactory.cpp >index 8e40d60f017ec27427df30d20a3f9d4f711cefbc..acfa3bafffb072b030732b9baea3a604641c5980 100644 >--- a/Source/WebKit/Shared/win/WebEventFactory.cpp >+++ b/Source/WebKit/Shared/win/WebEventFactory.cpp >@@ -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 @@ static String keyIdentifierFromEvent(WPARAM wparam, WebEvent::Type type) > 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)); > } > } > >diff --git a/Source/WebKit/UIProcess/API/APINavigation.cpp b/Source/WebKit/UIProcess/API/APINavigation.cpp >index d8d82e40b2bdd98007566adadd0e350521e9ed0a..13c2daa141d13fb15980d36cdb991e119cc90867 100644 >--- a/Source/WebKit/UIProcess/API/APINavigation.cpp >+++ b/Source/WebKit/UIProcess/API/APINavigation.cpp >@@ -29,10 +29,9 @@ > #include "WebBackForwardListItem.h" > #include "WebNavigationState.h" > #include <wtf/DebugUtilities.h> >+#include <wtf/HexNumber.h> > > namespace API { >-using namespace WebCore; >-using namespace WebKit; > > Navigation::Navigation(WebNavigationState& state) > : m_navigationID(state.generateNavigationID()) >@@ -82,10 +81,12 @@ void Navigation::appendRedirectionURL(const WTF::URL& url) > } > > #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 >diff --git a/Source/WebKit/UIProcess/SuspendedPageProxy.cpp b/Source/WebKit/UIProcess/SuspendedPageProxy.cpp >index 0c981f2976f86b17fecf9b465fb657c0cb208c0c..59e0e0b0325e61ad81d85d1e1257562fcc749d50 100644 >--- a/Source/WebKit/UIProcess/SuspendedPageProxy.cpp >+++ b/Source/WebKit/UIProcess/SuspendedPageProxy.cpp >@@ -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 @@ void SuspendedPageProxy::didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, > } > > #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 >diff --git a/Source/WebKit/UIProcess/WebBackForwardList.cpp b/Source/WebKit/UIProcess/WebBackForwardList.cpp >index d6a2938e18a6519e32074f13ee83b3776b14170e..10f5d825957c58be65b792616c907cdef059a699 100644 >--- a/Source/WebKit/UIProcess/WebBackForwardList.cpp >+++ b/Source/WebKit/UIProcess/WebBackForwardList.cpp >@@ -480,7 +480,7 @@ const char* WebBackForwardList::loggingString() > { > StringBuilder builder; > >- builder.appendLiteral("WebBackForwardList "); >+ builder.appendLiteral("WebBackForwardList 0x"); > appendUnsignedAsHex(reinterpret_cast<uintptr_t>(this), builder); > builder.appendLiteral(" - "); > builder.appendNumber(m_entries.size()); >diff --git a/Source/WebKit/UIProcess/gtk/InputMethodFilter.cpp b/Source/WebKit/UIProcess/gtk/InputMethodFilter.cpp >index 6a43f178b6adef7c9331e56ed4bb2c4d7c939598..f2b860f3bee52b03ef23a4aec8af5a5e4abd9e08 100644 >--- a/Source/WebKit/UIProcess/gtk/InputMethodFilter.cpp >+++ b/Source/WebKit/UIProcess/gtk/InputMethodFilter.cpp >@@ -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,16 +446,16 @@ void InputMethodFilter::logHandleKeyboardEventForTesting(GdkEventKey* event, con > 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) > { > 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();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194752
:
362226
|
362227
|
362228
|
362229
|
362230
|
362249
|
362287
|
362293