haikuwebkit/Source/WTF/wtf/HexNumber.cpp

55 lines
1.7 KiB
C++
Raw Permalink Normal View History

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. Source/JavaScriptCore: * 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". Source/WebCore: * 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. Source/WebCore/PAL: * pal/FileSizeFormatter.cpp: (fileSizeDescription): Use makeString instead of String::format. Source/WebKit: * 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. Source/WTF: * 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. Canonical link: https://commits.webkit.org/209182@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241751 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-02-19 02:04:33 +00:00
/*
* 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"
[JSC] Improve Wasm binary test coverage https://bugs.webkit.org/show_bug.cgi?id=204843 Reviewed by Darin Adler. JSTests: * wasm/function-tests/grow-memory.js: (binaryShouldNotParse): * wasm/spec-tests/binary-leb128.wast.js: * wasm/spec-tests/binary.wast.js: * wasm/wasm.json: Source/JavaScriptCore: This patch fixes some of bugs in wasm parser so that we validate malformed wasm modules more strictly. 1. current_memory / grow_memory should have uint8 flag, not varuint32 flag. 2. global section should have uint8 mutability information, not varuint32. 3. memory section should have varuint32 memory count. * wasm/WasmFunctionParser.h: (JSC::Wasm::FunctionParser<Context>::parseExpression): (JSC::Wasm::FunctionParser<Context>::parseUnreachableExpression): * wasm/WasmSectionParser.cpp: (JSC::Wasm::SectionParser::parseResizableLimits): (JSC::Wasm::SectionParser::parseMemory): (JSC::Wasm::SectionParser::parseGlobalType): * wasm/wasm.json: Source/WTF: LEBDecoder should have more strict validation. One thing is that, we should reject pattern that includes ignored bits. For example, in uint32_t, we can represent UINT32_MAX in 5 bytes like this. 0xff, 0xff, 0xff, 0xff, 0x0f 0b1111111_1111111_1111111_1111111_1111 Leading bytes has 0x80 trailing marker. And they includes each 7 bit slice. And the last byte includes 0b1111 part. But we can also make it in the following form 0xff, 0xff, 0xff, 0xff, 0xff 0b1111111_1111111_1111111_1111111_1111 In the above case, the last byte's upper 4 bits are ignored in the result, and this is wrong in LEB128 encoding. We should reject this input since the last byte includes overflown bits. This patch adds this validation to WTF. * wtf/LEBDecoder.h: (WTF::LEBDecoder::maxByteLength): (WTF::LEBDecoder::lastByteMask): (WTF::LEBDecoder::decodeUInt): (WTF::LEBDecoder::decodeInt): Tools: We add more tests for LEBDecoder. In particular, the added tests focus on the case which overflow bits. * TestWebKitAPI/Tests/WTF/LEBDecoder.cpp: (TestWebKitAPI::toString): (TestWebKitAPI::testUInt32LEBDecode): (TestWebKitAPI::TEST): (TestWebKitAPI::testUInt64LEBDecode): (TestWebKitAPI::testInt32LEBDecode): (TestWebKitAPI::testInt64LEBDecode): Canonical link: https://commits.webkit.org/231741@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269998 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-11-18 23:50:34 +00:00
#include <wtf/PrintStream.h>
#include <wtf/text/StringView.h>
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. Source/JavaScriptCore: * 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". Source/WebCore: * 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. Source/WebCore/PAL: * pal/FileSizeFormatter.cpp: (fileSizeDescription): Use makeString instead of String::format. Source/WebKit: * 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. Source/WTF: * 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. Canonical link: https://commits.webkit.org/209182@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241751 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-02-19 02:04:33 +00:00
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 };
}
}
[JSC] Improve Wasm binary test coverage https://bugs.webkit.org/show_bug.cgi?id=204843 Reviewed by Darin Adler. JSTests: * wasm/function-tests/grow-memory.js: (binaryShouldNotParse): * wasm/spec-tests/binary-leb128.wast.js: * wasm/spec-tests/binary.wast.js: * wasm/wasm.json: Source/JavaScriptCore: This patch fixes some of bugs in wasm parser so that we validate malformed wasm modules more strictly. 1. current_memory / grow_memory should have uint8 flag, not varuint32 flag. 2. global section should have uint8 mutability information, not varuint32. 3. memory section should have varuint32 memory count. * wasm/WasmFunctionParser.h: (JSC::Wasm::FunctionParser<Context>::parseExpression): (JSC::Wasm::FunctionParser<Context>::parseUnreachableExpression): * wasm/WasmSectionParser.cpp: (JSC::Wasm::SectionParser::parseResizableLimits): (JSC::Wasm::SectionParser::parseMemory): (JSC::Wasm::SectionParser::parseGlobalType): * wasm/wasm.json: Source/WTF: LEBDecoder should have more strict validation. One thing is that, we should reject pattern that includes ignored bits. For example, in uint32_t, we can represent UINT32_MAX in 5 bytes like this. 0xff, 0xff, 0xff, 0xff, 0x0f 0b1111111_1111111_1111111_1111111_1111 Leading bytes has 0x80 trailing marker. And they includes each 7 bit slice. And the last byte includes 0b1111 part. But we can also make it in the following form 0xff, 0xff, 0xff, 0xff, 0xff 0b1111111_1111111_1111111_1111111_1111 In the above case, the last byte's upper 4 bits are ignored in the result, and this is wrong in LEB128 encoding. We should reject this input since the last byte includes overflown bits. This patch adds this validation to WTF. * wtf/LEBDecoder.h: (WTF::LEBDecoder::maxByteLength): (WTF::LEBDecoder::lastByteMask): (WTF::LEBDecoder::decodeUInt): (WTF::LEBDecoder::decodeInt): Tools: We add more tests for LEBDecoder. In particular, the added tests focus on the case which overflow bits. * TestWebKitAPI/Tests/WTF/LEBDecoder.cpp: (TestWebKitAPI::toString): (TestWebKitAPI::testUInt32LEBDecode): (TestWebKitAPI::TEST): (TestWebKitAPI::testUInt64LEBDecode): (TestWebKitAPI::testInt32LEBDecode): (TestWebKitAPI::testInt64LEBDecode): Canonical link: https://commits.webkit.org/231741@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269998 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-11-18 23:50:34 +00:00
void printInternal(PrintStream& out, HexNumberBuffer buffer)
{
out.print(StringView(buffer.characters(), buffer.length));
}
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. Source/JavaScriptCore: * 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". Source/WebCore: * 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. Source/WebCore/PAL: * pal/FileSizeFormatter.cpp: (fileSizeDescription): Use makeString instead of String::format. Source/WebKit: * 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. Source/WTF: * 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. Canonical link: https://commits.webkit.org/209182@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241751 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-02-19 02:04:33 +00:00
} // namespace WTF