Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (240891 => 240892)
--- trunk/Source/_javascript_Core/ChangeLog 2019-02-02 02:30:53 UTC (rev 240891)
+++ trunk/Source/_javascript_Core/ChangeLog 2019-02-02 04:05:55 UTC (rev 240892)
@@ -1,3 +1,14 @@
+2018-12-16 Darin Adler <[email protected]>
+
+ Convert additional String::format clients to alternative approaches
+ https://bugs.webkit.org/show_bug.cgi?id=192746
+
+ Reviewed by Alexey Proskuryakov.
+
+ * inspector/agents/InspectorConsoleAgent.cpp:
+ (Inspector::InspectorConsoleAgent::stopTiming): Use makeString
+ and FormattedNumber::fixedWidth.
+
2019-02-01 Yusuke Suzuki <[email protected]>
[JSC] Remove some of IsoSubspaces for JSFunction subclasses
Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorConsoleAgent.cpp (240891 => 240892)
--- trunk/Source/_javascript_Core/inspector/agents/InspectorConsoleAgent.cpp 2019-02-02 02:30:53 UTC (rev 240891)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorConsoleAgent.cpp 2019-02-02 04:05:55 UTC (rev 240892)
@@ -164,7 +164,7 @@
m_times.remove(it);
Seconds elapsed = MonotonicTime::now() - startTime;
- String message = title + String::format(": %.3fms", elapsed.milliseconds());
+ String message = makeString(title, ": ", FormattedNumber::fixedWidth(elapsed.milliseconds(), 3), "ms");
addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Debug, message, WTFMove(callStack)));
}
Modified: trunk/Source/WTF/ChangeLog (240891 => 240892)
--- trunk/Source/WTF/ChangeLog 2019-02-02 02:30:53 UTC (rev 240891)
+++ trunk/Source/WTF/ChangeLog 2019-02-02 04:05:55 UTC (rev 240892)
@@ -1,3 +1,21 @@
+2018-12-16 Darin Adler <[email protected]>
+
+ Convert additional String::format clients to alternative approaches
+ https://bugs.webkit.org/show_bug.cgi?id=192746
+
+ Reviewed by Alexey Proskuryakov.
+
+ * wtf/JSONValues.cpp:
+ (WTF::appendDoubleQuotedStringEscapedCharacter): Renamed from
+ escapeChar and reordered arguments to make sense as an append function.
+ (WTF::appendDoubleQuotedString): Renamed from doubleQuoteString,
+ reordered arguments to make sense as an append function, take a
+ StringView instead of a String, used early exit to make the code
+ a bit easier to read. Use the ASCIIHexDigit functions to construct
+ a hex number a nibble at a time rather than using String::format.
+ (WTF::JSONImpl::Value::writeJSON const): Update for name change.
+ (WTF::JSONImpl::ObjectBase::writeJSON const): Ditto.
+
2019-01-31 Carlos Garcia Campos <[email protected]>
Unreviewed. Fix WPE compile warnings due to deprecated glib API.
Modified: trunk/Source/WTF/wtf/JSONValues.cpp (240891 => 240892)
--- trunk/Source/WTF/wtf/JSONValues.cpp 2019-02-02 02:30:53 UTC (rev 240891)
+++ trunk/Source/WTF/wtf/JSONValues.cpp 2019-02-02 04:05:55 UTC (rev 240892)
@@ -446,38 +446,48 @@
return result;
}
-inline bool escapeChar(UChar c, StringBuilder& dst)
+inline void appendDoubleQuotedString(StringBuilder& builder, StringView string)
{
- switch (c) {
- case '\b': dst.appendLiteral("\\b"); break;
- case '\f': dst.appendLiteral("\\f"); break;
- case '\n': dst.appendLiteral("\\n"); break;
- case '\r': dst.appendLiteral("\\r"); break;
- case '\t': dst.appendLiteral("\\t"); break;
- case '\\': dst.appendLiteral("\\\\"); break;
- case '"': dst.appendLiteral("\\\""); break;
- default:
- return false;
- }
- return true;
-}
-
-inline void doubleQuoteString(const String& str, StringBuilder& dst)
-{
- dst.append('"');
- for (unsigned i = 0; i < str.length(); ++i) {
- UChar c = str[i];
- if (!escapeChar(c, dst)) {
- if (c < 32 || c > 126 || c == '<' || c == '>') {
- // 1. Escaping <, > to prevent script execution.
- // 2. Technically, we could also pass through c > 126 as UTF8, but this
- // is also optional. It would also be a pain to implement here.
- dst.append(String::format("\\u%04X", c));
- } else
- dst.append(c);
+ builder.append('"');
+ for (UChar codeUnit : string.codeUnits()) {
+ switch (codeUnit) {
+ case '\b':
+ builder.appendLiteral("\\b");
+ continue;
+ case '\f':
+ builder.appendLiteral("\\f");
+ continue;
+ case '\n':
+ builder.appendLiteral("\\n");
+ continue;
+ case '\r':
+ builder.appendLiteral("\\r");
+ continue;
+ case '\t':
+ builder.appendLiteral("\\t");
+ continue;
+ case '\\':
+ builder.appendLiteral("\\\\");
+ continue;
+ case '"':
+ builder.appendLiteral("\\\"");
+ continue;
}
+ // We escape < and > to prevent script execution.
+ if (codeUnit >= 32 && codeUnit < 127 && codeUnit != '<' && codeUnit != '>') {
+ builder.append(codeUnit);
+ continue;
+ }
+ // We could encode characters >= 127 as UTF-8 instead of \u escape sequences.
+ // We could handle surrogates here if callers wanted that; for now we just
+ // write them out as a \u sequence, so a surrogate pair appears as two of them.
+ builder.appendLiteral("\\u");
+ builder.append(upperNibbleToASCIIHexDigit(codeUnit >> 8));
+ builder.append(lowerNibbleToASCIIHexDigit(codeUnit >> 8));
+ builder.append(upperNibbleToASCIIHexDigit(codeUnit));
+ builder.append(lowerNibbleToASCIIHexDigit(codeUnit));
}
- dst.append('"');
+ builder.append('"');
}
} // anonymous namespace
@@ -659,7 +669,7 @@
output.appendLiteral("false");
break;
case Type::String:
- doubleQuoteString(m_value.string, output);
+ appendDoubleQuotedString(output, m_value.string);
break;
case Type::Double:
case Type::Integer: {
@@ -786,7 +796,7 @@
ASSERT(findResult != m_map.end());
if (i)
output.append(',');
- doubleQuoteString(findResult->key, output);
+ appendDoubleQuotedString(output, findResult->key);
output.append(':');
findResult->value->writeJSON(output);
}
Modified: trunk/Source/WebCore/ChangeLog (240891 => 240892)
--- trunk/Source/WebCore/ChangeLog 2019-02-02 02:30:53 UTC (rev 240891)
+++ trunk/Source/WebCore/ChangeLog 2019-02-02 04:05:55 UTC (rev 240892)
@@ -1,3 +1,62 @@
+2018-12-16 Darin Adler <[email protected]>
+
+ Convert additional String::format clients to alternative approaches
+ https://bugs.webkit.org/show_bug.cgi?id=192746
+
+ Reviewed by Alexey Proskuryakov.
+
+ This round of conversions covers less-trivial cases such as floating
+ point numerals and hexadecimal. Not yet taking on pointer serialization
+ ("%p") or padding with spaces of zero digits, so call sites using those
+ have been left untouched.
+
+ In some cases these new idioms are a bit clumsy, and we could follow up
+ with additional convenience functions to make them more elegant.
+
+ * Modules/indexeddb/IDBKeyData.cpp:
+ (WebCore::IDBKeyData::loggingString const): Use more ASCIILiteral and
+ more appendLiteral for efficiency. Use upperNibbleToLowercaseASCIIHexDigit,
+ lowerNibbleToLowercaseASCIIHexDigit, and also makeString and FormattedNumber.
+
+ * css/MediaQueryEvaluator.cpp:
+ (WebCore::aspectRatioValueAsString): Use makeString and FormattedNumber.
+ Doing it this way makes it a little clearer that we have an unpleasant
+ use of fixed 6-digit precision here.
+
+ * html/FTPDirectoryDocument.cpp:
+ (WebCore::processFilesizeString): Use makeString and FormattedNumber.
+ * html/track/VTTCue.cpp:
+ (WebCore::VTTCueBox::applyCSSProperties): Ditto.
+ * page/CaptionUserPreferencesMediaAF.cpp:
+ (WebCore::CaptionUserPreferencesMediaAF::windowRoundedCornerRadiusCSS const): Ditto.
+ * page/History.cpp:
+ (WebCore::History::stateObjectAdded): Ditto.
+ * page/cocoa/ResourceUsageOverlayCocoa.mm:
+ (WebCore::formatByteNumber): Ditto.
+ (WebCore::gcTimerString): Use String::number.
+ (WebCore::ResourceUsageOverlay::platformDraw): Use makeString and FormattedNumber.
+
+ * page/scrolling/AxisScrollSnapOffsets.cpp:
+ (WebCore::snapOffsetsToString): Removed some unnecessary copying in the for loop,
+ use appendLiteral, and use appendFixedWidthNumber.
+ (WebCore::snapOffsetRangesToString): Ditto.
+ (WebCore::snapPortOrAreaToString): Use makeString and FormattedNumber.
+
+ * platform/animation/TimingFunction.cpp:
+ (WebCore::TimingFunction::cssText const): Use makeString.
+
+ * platform/cocoa/KeyEventCocoa.mm:
+ (WebCore::keyIdentifierForCharCode): Use makeString and the ASCIIHexDigit
+ functions.
+ * platform/graphics/Color.cpp:
+ (WebCore::Color::nameForRenderTreeAsText const): Ditto.
+
+ * platform/mock/MockRealtimeVideoSource.cpp:
+ (WebCore::MockRealtimeVideoSource::drawText): Use makeString and FormattedNumber.
+
+ * platform/text/PlatformLocale.cpp:
+ (WebCore::DateTimeStringBuilder::visitField): Use String::numberToStringFixedWidth.
+
2019-02-01 Simon Fraser <[email protected]>
Remove the unused layerForScrolling()
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp (240891 => 240892)
--- trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp 2019-02-02 02:30:53 UTC (rev 240891)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp 2019-02-02 04:05:55 UTC (rev 240892)
@@ -30,6 +30,7 @@
#include "KeyedCoding.h"
#include <wtf/text/StringBuilder.h>
+#include <wtf/text/StringConcatenateNumbers.h>
namespace WebCore {
@@ -315,13 +316,13 @@
String IDBKeyData::loggingString() const
{
if (m_isNull)
- return "<null>";
+ return "<null>"_s;
String result;
switch (m_type) {
case IndexedDB::KeyType::Invalid:
- return "<invalid>";
+ return "<invalid>"_s;
case IndexedDB::KeyType::Array: {
StringBuilder builder;
builder.appendLiteral("<array> - { ");
@@ -337,21 +338,24 @@
}
case IndexedDB::KeyType::Binary: {
StringBuilder builder;
- builder.append("<binary> - ");
+ builder.appendLiteral("<binary> - ");
auto* data = ""
if (!data) {
- builder.append("(null)");
+ builder.appendLiteral("(null)");
result = builder.toString();
break;
}
size_t i = 0;
- for (; i < 8 && i < data->size(); ++i)
- builder.append(String::format("%02x", data->at(i)));
+ for (; i < 8 && i < data->size(); ++i) {
+ uint8_t byte = data->at(i);
+ builder.append(upperNibbleToLowercaseASCIIHexDigit(byte));
+ builder.append(lowerNibbleToLowercaseASCIIHexDigit(byte));
+ }
if (data->size() > 8)
- builder.append("...");
+ builder.appendLiteral("...");
result = builder.toString();
break;
@@ -360,13 +364,13 @@
result = "<string> - " + WTF::get<String>(m_value);
break;
case IndexedDB::KeyType::Date:
- return String::format("<date> - %f", WTF::get<double>(m_value));
+ return makeString("<date> - ", FormattedNumber::fixedWidth(WTF::get<double>(m_value), 6));
case IndexedDB::KeyType::Number:
- return String::format("<number> - %f", WTF::get<double>(m_value));
+ return makeString("<number> - ", FormattedNumber::fixedWidth(WTF::get<double>(m_value), 6));
case IndexedDB::KeyType::Max:
- return "<maximum>";
+ return "<maximum>"_s;
case IndexedDB::KeyType::Min:
- return "<minimum>";
+ return "<minimum>"_s;
}
if (result.length() > 150) {
Modified: trunk/Source/WebCore/PAL/ChangeLog (240891 => 240892)
--- trunk/Source/WebCore/PAL/ChangeLog 2019-02-02 02:30:53 UTC (rev 240891)
+++ trunk/Source/WebCore/PAL/ChangeLog 2019-02-02 04:05:55 UTC (rev 240892)
@@ -1,3 +1,13 @@
+2018-12-16 Darin Adler <[email protected]>
+
+ Convert additional String::format clients to alternative approaches
+ https://bugs.webkit.org/show_bug.cgi?id=192746
+
+ Reviewed by Alexey Proskuryakov.
+
+ * pal/FileSizeFormatter.cpp:
+ (fileSizeDescription): Use makeString and FormattedNumber.
+
2019-02-01 David Kilzer <[email protected]>
Move soft-linking of TelephonyUtilities.framework out of TUCallSPI.h
Modified: trunk/Source/WebCore/PAL/pal/FileSizeFormatter.cpp (240891 => 240892)
--- trunk/Source/WebCore/PAL/pal/FileSizeFormatter.cpp 2019-02-02 02:30:53 UTC (rev 240891)
+++ trunk/Source/WebCore/PAL/pal/FileSizeFormatter.cpp 2019-02-02 04:05:55 UTC (rev 240892)
@@ -26,6 +26,8 @@
#include "config.h"
#include "FileSizeFormatter.h"
+#include <wtf/text/StringConcatenateNumbers.h>
+
#if !PLATFORM(COCOA)
String fileSizeDescription(uint64_t size)
@@ -35,10 +37,10 @@
if (size < 1000)
return String::format("%tu bytes", size);
if (size < 1000000)
- return String::format("%.1f KB", size / 1000.);
+ return makeString(FormattedNumber::fixedWidth(size / 1000., 1), " KB");
if (size < 1000000000)
- return String::format("%.1f MB", size / 1000000.);
- return String::format("%.1f GB", size / 1000000000.);
+ return makeString(FormattedNumber::fixedWidth(size / 1000000., 1), " MB");
+ return makeString(FormattedNumber::fixedWidth(size / 1000000000., 1), " GB");
}
#endif
Modified: trunk/Source/WebCore/css/MediaQueryEvaluator.cpp (240891 => 240892)
--- trunk/Source/WebCore/css/MediaQueryEvaluator.cpp 2019-02-02 02:30:53 UTC (rev 240891)
+++ trunk/Source/WebCore/css/MediaQueryEvaluator.cpp 2019-02-02 04:05:55 UTC (rev 240892)
@@ -50,6 +50,7 @@
#include "StyleResolver.h"
#include "Theme.h"
#include <wtf/HashMap.h>
+#include <wtf/text/StringConcatenateNumbers.h>
#include <wtf/text/TextStream.h>
#if ENABLE(3D_TRANSFORMS)
@@ -237,6 +238,7 @@
}
#if !LOG_DISABLED
+
static String aspectRatioValueAsString(CSSValue* value)
{
if (!is<CSSAspectRatioValue>(value))
@@ -243,8 +245,9 @@
return emptyString();
auto& aspectRatio = downcast<CSSAspectRatioValue>(*value);
- return String::format("%f/%f", aspectRatio.numeratorValue(), aspectRatio.denominatorValue());
+ return makeString(FormattedNumber::fixedWidth(aspectRatio.numeratorValue(), 6), '/', FormattedNumber::fixedWidth(aspectRatio.denominatorValue(), 6));
}
+
#endif
static bool compareAspectRatioValue(CSSValue* value, int width, int height, MediaFeaturePrefix op)
Modified: trunk/Source/WebCore/html/FTPDirectoryDocument.cpp (240891 => 240892)
--- trunk/Source/WebCore/html/FTPDirectoryDocument.cpp 2019-02-02 02:30:53 UTC (rev 240891)
+++ trunk/Source/WebCore/html/FTPDirectoryDocument.cpp 2019-02-02 04:05:55 UTC (rev 240892)
@@ -41,6 +41,7 @@
#include <wtf/GregorianDateTime.h>
#include <wtf/IsoMallocInlines.h>
#include <wtf/StdLibExtras.h>
+#include <wtf/text/StringConcatenateNumbers.h>
#include <wtf/unicode/CharacterNames.h>
namespace WebCore {
@@ -167,12 +168,12 @@
return unknownFileSizeText();
if (bytes < 1000000)
- return String::format("%.2f KB", static_cast<float>(bytes)/1000);
+ return makeString(FormattedNumber::fixedWidth(bytes / 1000., 2), " KB");
if (bytes < 1000000000)
- return String::format("%.2f MB", static_cast<float>(bytes)/1000000);
+ return makeString(FormattedNumber::fixedWidth(bytes / 1000000., 2), " MB");
- return String::format("%.2f GB", static_cast<float>(bytes)/1000000000);
+ return makeString(FormattedNumber::fixedWidth(bytes / 1000000000., 2), " GB");
}
static bool wasLastDayOfMonth(int year, int month, int day)
Modified: trunk/Source/WebCore/html/track/VTTCue.cpp (240891 => 240892)
--- trunk/Source/WebCore/html/track/VTTCue.cpp 2019-02-02 02:30:53 UTC (rev 240891)
+++ trunk/Source/WebCore/html/track/VTTCue.cpp 2019-02-02 04:05:55 UTC (rev 240892)
@@ -30,9 +30,9 @@
*/
#include "config.h"
+#include "VTTCue.h"
#if ENABLE(VIDEO_TRACK)
-#include "VTTCue.h"
#include "CSSPropertyNames.h"
#include "CSSValueKeywords.h"
@@ -55,6 +55,7 @@
#include <wtf/IsoMallocInlines.h>
#include <wtf/MathExtras.h>
#include <wtf/text/StringBuilder.h>
+#include <wtf/text/StringConcatenateNumbers.h>
namespace WebCore {
@@ -227,7 +228,7 @@
// maintaining the relative positions of the boxes in boxes to each
// other.
setInlineStyleProperty(CSSPropertyTransform,
- String::format("translate(-%.2f%%, -%.2f%%)", position.first, position.second));
+ makeString("translate(", FormattedNumber::fixedWidth(-position.first, 2), "%, ", FormattedNumber::fixedWidth(-position.second, 2), "%)"));
setInlineStyleProperty(CSSPropertyWhiteSpace, CSSValuePre);
}
Modified: trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp (240891 => 240892)
--- trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp 2019-02-02 02:30:53 UTC (rev 240891)
+++ trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp 2019-02-02 04:05:55 UTC (rev 240892)
@@ -32,9 +32,6 @@
#include "CaptionUserPreferencesMediaAF.h"
#include "AudioTrackList.h"
-#if PLATFORM(WIN)
-#include <pal/spi/win/CoreTextSPIWin.h>
-#endif
#include "FloatConversion.h"
#include "HTMLMediaElement.h"
#include "LocalizedStrings.h"
@@ -41,7 +38,6 @@
#include "Logging.h"
#include "MediaControlElements.h"
#include "TextTrackList.h"
-#include <wtf/URL.h>
#include "UserStyleSheetTypes.h"
#include "VTTCue.h"
#include <algorithm>
@@ -49,13 +45,19 @@
#include <wtf/NeverDestroyed.h>
#include <wtf/RetainPtr.h>
#include <wtf/SoftLinking.h>
+#include <wtf/URL.h>
#include <wtf/text/CString.h>
#include <wtf/text/StringBuilder.h>
+#include <wtf/text/StringConcatenateNumbers.h>
#if PLATFORM(IOS_FAMILY)
#import "WebCoreThreadRun.h"
#endif
+#if PLATFORM(WIN)
+#include <pal/spi/win/CoreTextSPIWin.h>
+#endif
+
#if COMPILER(MSVC)
// See https://msdn.microsoft.com/en-us/library/35bhkfb6.aspx
#pragma warning(disable: 4273)
@@ -62,6 +64,7 @@
#endif
#if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
+
#include <CoreText/CoreText.h>
#include <MediaAccessibility/MediaAccessibility.h>
@@ -83,12 +86,12 @@
SOFT_LINK_AVF_FRAMEWORK(CoreMedia)
SOFT_LINK_AVF_FRAMEWORK_IMPORT_OPTIONAL(CoreMedia, MTEnableCaption2015Behavior, Boolean, ())
-#else
+#else // PLATFORM(WIN)
SOFT_LINK_FRAMEWORK_OPTIONAL(MediaToolbox)
SOFT_LINK_OPTIONAL(MediaToolbox, MTEnableCaption2015Behavior, Boolean, (), ())
-#endif // PLATFORM(WIN)
+#endif // !PLATFORM(WIN)
#endif // HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
@@ -95,6 +98,7 @@
namespace WebCore {
#if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
+
static void userCaptionPreferencesChangedNotificationCallback(CFNotificationCenterRef, void* observer, CFStringRef, const void *, CFDictionaryRef)
{
#if !PLATFORM(IOS_FAMILY)
@@ -105,6 +109,7 @@
});
#endif
}
+
#endif
CaptionUserPreferencesMediaAF::CaptionUserPreferencesMediaAF(PageGroup& group)
@@ -346,7 +351,7 @@
return emptyString();
StringBuilder builder;
- appendCSS(builder, CSSPropertyBorderRadius, String::format("%.02fpx", radius), behavior == kMACaptionAppearanceBehaviorUseValue);
+ appendCSS(builder, CSSPropertyBorderRadius, makeString(FormattedNumber::fixedWidth(radius, 2), "px"), behavior == kMACaptionAppearanceBehaviorUseValue);
return builder.toString();
}
Modified: trunk/Source/WebCore/page/History.cpp (240891 => 240892)
--- trunk/Source/WebCore/page/History.cpp 2019-02-02 02:30:53 UTC (rev 240891)
+++ trunk/Source/WebCore/page/History.cpp 2019-02-02 04:05:55 UTC (rev 240892)
@@ -40,6 +40,7 @@
#include "SecurityOrigin.h"
#include <wtf/CheckedArithmetic.h>
#include <wtf/MainThread.h>
+#include <wtf/text/StringConcatenateNumbers.h>
namespace WebCore {
@@ -222,8 +223,8 @@
if (mainHistory.m_currentStateObjectTimeSpanObjectsAdded >= perStateObjectTimeSpanLimit) {
if (stateObjectType == StateObjectType::Replace)
- return Exception { SecurityError, String::format("Attempt to use history.replaceState() more than %u times per %f seconds", perStateObjectTimeSpanLimit, stateObjectTimeSpan.seconds()) };
- return Exception { SecurityError, String::format("Attempt to use history.pushState() more than %u times per %f seconds", perStateObjectTimeSpanLimit, stateObjectTimeSpan.seconds()) };
+ return Exception { SecurityError, makeString("Attempt to use history.replaceState() more than ", perStateObjectTimeSpanLimit, " times per ", FormattedNumber::fixedWidth(stateObjectTimeSpan.seconds(), 6), " seconds") };
+ return Exception { SecurityError, makeString("Attempt to use history.pushState() more than ", perStateObjectTimeSpanLimit, " times per ", FormattedNumber::fixedWidth(stateObjectTimeSpan.seconds(), 6), " seconds") };
}
Checked<unsigned> titleSize = title.length();
Modified: trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm (240891 => 240892)
--- trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm 2019-02-02 02:30:53 UTC (rev 240891)
+++ trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm 2019-02-02 04:05:55 UTC (rev 240892)
@@ -41,6 +41,7 @@
#include <wtf/MathExtras.h>
#include <wtf/MemoryFootprint.h>
#include <wtf/NeverDestroyed.h>
+#include <wtf/text/StringConcatenateNumbers.h>
using WebCore::ResourceUsageOverlay;
@interface WebOverlayLayer : CALayer {
@@ -426,11 +427,11 @@
static String formatByteNumber(size_t number)
{
if (number >= 1024 * 1048576)
- return String::format("%.3f GB", static_cast<double>(number) / (1024 * 1048576));
+ return makeString(FormattedNumber::fixedWidth(number / (1024. * 1048576), 3), " GB");
if (number >= 1048576)
- return String::format("%.2f MB", static_cast<double>(number) / 1048576);
+ return makeString(FormattedNumber::fixedWidth(number / 1048576., 2), " MB");
if (number >= 1024)
- return String::format("%.1f kB", static_cast<double>(number) / 1024);
+ return makeString(FormattedNumber::fixedWidth(number / 1024, 1), " kB");
return String::number(number);
}
@@ -438,7 +439,7 @@
{
if (std::isnan(timerFireDate))
return "[not scheduled]"_s;
- return String::format("%g", (timerFireDate - now).seconds());
+ return String::number((timerFireDate - now).seconds());
}
void ResourceUsageOverlay::platformDraw(CGContextRef context)
@@ -457,7 +458,7 @@
CGContextClearRect(context, viewBounds);
static CGColorRef colorForLabels = createColor(0.9, 0.9, 0.9, 1);
- showText(context, 10, 20, colorForLabels, String::format(" CPU: %g", data.cpu.last()));
+ showText(context, 10, 20, colorForLabels, makeString(" CPU: ", FormattedNumber::fixedPrecision(data.cpu.last())));
showText(context, 10, 30, colorForLabels, " Footprint: " + formatByteNumber(memoryFootprint()));
showText(context, 10, 40, colorForLabels, " External: " + formatByteNumber(data.totalExternalSize.last()));
Modified: trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp (240891 => 240892)
--- trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp 2019-02-02 02:30:53 UTC (rev 240891)
+++ trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp 2019-02-02 04:05:55 UTC (rev 240892)
@@ -35,6 +35,7 @@
#include "RenderView.h"
#include "ScrollableArea.h"
#include "StyleScrollSnapPoints.h"
+#include <wtf/text/StringConcatenateNumbers.h>
#if ENABLE(CSS_SCROLL_SNAP)
@@ -75,28 +76,38 @@
static String snapOffsetsToString(const Vector<LayoutUnit>& snapOffsets)
{
- StringBuilder s;
- s.append("[ ");
- for (auto offset : snapOffsets)
- s.append(String::format("%.1f ", offset.toFloat()));
-
- s.append("]");
- return s.toString();
+ StringBuilder builder;
+ builder.appendLiteral("[ ");
+ for (auto& offset : snapOffsets) {
+ builder.appendFixedWidthNumber(offset.toFloat(), 1);
+ builder.append(' ');
+ }
+ builder.append(']');
+ return builder.toString();
}
static String snapOffsetRangesToString(const Vector<ScrollOffsetRange<LayoutUnit>>& ranges)
{
- StringBuilder s;
- s.append("[ ");
- for (auto range : ranges)
- s.append(String::format("(%.1f, %.1f) ", range.start.toFloat(), range.end.toFloat()));
- s.append("]");
- return s.toString();
+ StringBuilder builder;
+ builder.appendLiteral("[ ");
+ for (auto& range : ranges) {
+ builder.append('(');
+ builder.appendFixedWidthNumber(range.start.toFloat(), 1);
+ builder.appendLiteral(", ");
+ builder.appendFixedWidthNumber(range.end.toFloat(), 1);
+ builder.appendLiteral(") ");
+ }
+ builder.append(']');
+ return builder.toString();
}
static String snapPortOrAreaToString(const LayoutRect& rect)
{
- return String::format("{{%.1f, %.1f} {%.1f, %.1f}}", rect.x().toFloat(), rect.y().toFloat(), rect.width().toFloat(), rect.height().toFloat());
+ return makeString("{{",
+ FormattedNumber::fixedWidth(rect.x(), 1), ", ",
+ FormattedNumber::fixedWidth(rect.y(), 1), "} {",
+ FormattedNumber::fixedWidth(rect.width(), 1), ", ",
+ FormattedNumber::fixedWidth(rect.height(), 1), "}}");
}
#endif
Modified: trunk/Source/WebCore/platform/animation/TimingFunction.cpp (240891 => 240892)
--- trunk/Source/WebCore/platform/animation/TimingFunction.cpp 2019-02-02 02:30:53 UTC (rev 240891)
+++ trunk/Source/WebCore/platform/animation/TimingFunction.cpp 2019-02-02 04:05:55 UTC (rev 240892)
@@ -176,7 +176,7 @@
return "ease-out";
if (function.x1() == 0.42 && !function.y1() && function.x2() == 0.58 && function.y2() == 1.0)
return "ease-in-out";
- return String::format("cubic-bezier(%g, %g, %g, %g)", function.x1(), function.y1(), function.x2(), function.y2());
+ return makeString("cubic-bezier(", function.x1(), ", ", function.y1(), ", ", function.x2(), ", ", function.y2(), ')');
}
if (m_type == TimingFunction::StepsFunction) {
Modified: trunk/Source/WebCore/platform/cocoa/KeyEventCocoa.mm (240891 => 240892)
--- trunk/Source/WebCore/platform/cocoa/KeyEventCocoa.mm 2019-02-02 02:30:53 UTC (rev 240891)
+++ trunk/Source/WebCore/platform/cocoa/KeyEventCocoa.mm 2019-02-02 04:05:55 UTC (rev 240892)
@@ -494,7 +494,12 @@
// 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:
- return String::format("U+%04X", toASCIIUpper(charCode));
+ UChar codeUnit = toASCIIUpper(charCode);
+ return makeString("U+",
+ upperNibbleToASCIIHexDigit(codeUnit >> 8),
+ lowerNibbleToASCIIHexDigit(codeUnit >> 8),
+ upperNibbleToASCIIHexDigit(codeUnit),
+ lowerNibbleToASCIIHexDigit(codeUnit));
}
}
Modified: trunk/Source/WebCore/platform/graphics/Color.cpp (240891 => 240892)
--- trunk/Source/WebCore/platform/graphics/Color.cpp 2019-02-02 02:30:53 UTC (rev 240891)
+++ trunk/Source/WebCore/platform/graphics/Color.cpp 2019-02-02 04:05:55 UTC (rev 240892)
@@ -391,9 +391,17 @@
String Color::nameForRenderTreeAsText() const
{
// FIXME: Handle ExtendedColors.
- if (alpha() < 0xFF)
- return String::format("#%02X%02X%02X%02X", red(), green(), blue(), alpha());
- return String::format("#%02X%02X%02X", red(), green(), blue());
+ 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()));
}
Color Color::light() const
Modified: trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp (240891 => 240892)
--- trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp 2019-02-02 02:30:53 UTC (rev 240891)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp 2019-02-02 04:05:55 UTC (rev 240892)
@@ -358,11 +358,11 @@
context.drawText(timeFont, TextRun((StringView(string))), timeLocation);
FloatPoint statsLocation(captureSize.width() * .45, captureSize.height() * .75);
- string = String::format("Requested frame rate: %.1f fps", frameRate());
+ string = makeString("Requested frame rate: ", FormattedNumber::fixedWidth(frameRate(), 1), " fps");
context.drawText(statsFont, TextRun((StringView(string))), statsLocation);
statsLocation.move(0, m_statsFontSize);
- string = String::format("Observed frame rate: %.1f fps", observedFrameRate());
+ string = makeString("Observed frame rate: ", FormattedNumber::fixedWidth(observedFrameRate(), 1), " fps");
context.drawText(statsFont, TextRun((StringView(string))), statsLocation);
auto size = this->size();
Modified: trunk/Source/WebCore/platform/text/PlatformLocale.cpp (240891 => 240892)
--- trunk/Source/WebCore/platform/text/PlatformLocale.cpp 2019-02-02 02:30:53 UTC (rev 240891)
+++ trunk/Source/WebCore/platform/text/PlatformLocale.cpp 2019-02-02 04:05:55 UTC (rev 240892)
@@ -158,7 +158,7 @@
appendNumber(m_date.second(), numberOfPatternCharacters);
else {
double second = m_date.second() + m_date.millisecond() / 1000.0;
- String zeroPaddedSecondString = zeroPadString(String::format("%.03f", second), numberOfPatternCharacters + 4);
+ String zeroPaddedSecondString = zeroPadString(String::numberToStringFixedWidth(second, 3), numberOfPatternCharacters + 4);
m_builder.append(m_localizer.convertToLocalizedNumber(zeroPaddedSecondString));
}
return;
Modified: trunk/Source/WebKit/ChangeLog (240891 => 240892)
--- trunk/Source/WebKit/ChangeLog 2019-02-02 02:30:53 UTC (rev 240891)
+++ trunk/Source/WebKit/ChangeLog 2019-02-02 04:05:55 UTC (rev 240892)
@@ -1,3 +1,18 @@
+2018-12-16 Darin Adler <[email protected]>
+
+ Convert additional String::format clients to alternative approaches
+ https://bugs.webkit.org/show_bug.cgi?id=192746
+
+ Reviewed by Alexey Proskuryakov.
+
+ * UIProcess/Cocoa/ViewGestureController.cpp:
+ (WebKit::ViewGestureController::SnapshotRemovalTracker::startWatchdog):
+ Use makeString and FormattedNumber.
+
+ * UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm:
+ (WebKit::LocalAuthenticator::getAssertion): Added a comment about an
+ incorrect format specifier and left this code as is for now.
+
2019-02-01 David Kilzer <[email protected]>
Move soft-linking of TelephonyUtilities.framework out of TUCallSPI.h
Modified: trunk/Source/WebKit/UIProcess/Cocoa/ViewGestureController.cpp (240891 => 240892)
--- trunk/Source/WebKit/UIProcess/Cocoa/ViewGestureController.cpp 2019-02-02 02:30:53 UTC (rev 240891)
+++ trunk/Source/WebKit/UIProcess/Cocoa/ViewGestureController.cpp 2019-02-02 04:05:55 UTC (rev 240892)
@@ -36,6 +36,7 @@
#import <wtf/MathExtras.h>
#import <wtf/NeverDestroyed.h>
#import <wtf/text/StringBuilder.h>
+#import <wtf/text/StringConcatenateNumbers.h>
namespace WebKit {
using namespace WebCore;
@@ -368,7 +369,7 @@
void ViewGestureController::SnapshotRemovalTracker::startWatchdog(Seconds duration)
{
- log(String::format("(re)started watchdog timer for %.1f seconds", duration.seconds()));
+ log(makeString("(re)started watchdog timer for ", FormattedNumber::fixedWidth(duration.seconds(), 1), " seconds"));
m_watchdogTimer.startOneShot(duration);
}
Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm (240891 => 240892)
--- trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm 2019-02-02 02:30:53 UTC (rev 240891)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm 2019-02-02 04:05:55 UTC (rev 240892)
@@ -404,7 +404,7 @@
String::format("Log into %s with %s.", requestData().requestOptions.rpId.utf8().data(), selectedCredentialAttributes[(id)kSecAttrApplicationTag]),
(__bridge SecAccessControlRef)selectedCredentialAttributes[(id)kSecAttrAccessControl],
WTFMove(callback));
-#endif // !PLATFORM(IOS_FAMILY)
+#endif // PLATFORM(IOS_FAMILY)
}
void LocalAuthenticator::continueGetAssertionAfterUserConsented(LocalConnection::UserConsent consent, LAContext *context, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& userhandle)
Modified: trunk/Tools/ChangeLog (240891 => 240892)
--- trunk/Tools/ChangeLog 2019-02-02 02:30:53 UTC (rev 240891)
+++ trunk/Tools/ChangeLog 2019-02-02 04:05:55 UTC (rev 240892)
@@ -1,3 +1,19 @@
+2018-12-16 Darin Adler <[email protected]>
+
+ Convert additional String::format clients to alternative approaches
+ https://bugs.webkit.org/show_bug.cgi?id=192746
+
+ Reviewed by Alexey Proskuryakov.
+
+ * WebKitTestRunner/TestController.cpp:
+ (WTR::originUserVisibleName): Use makeString and reduce the use of std::string
+ as an intermediate in code that ultimately constructs a WTF::String.
+ (WTR::userMediaOriginHash): Use makeString.
+ (WTR::TestController::didNavigateWithNavigationData): More of the same.
+ (WTR::TestController::didPerformClientRedirect): Ditto.
+ (WTR::TestController::didPerformServerRedirect): Ditto.
+ (WTR::TestController::didUpdateHistoryTitle): Ditto.
+
2019-02-01 Aakash Jain <[email protected]>
[ews-build] Add unit test to verify builder keys
Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (240891 => 240892)
--- trunk/Tools/WebKitTestRunner/TestController.cpp 2019-02-02 02:30:53 UTC (rev 240891)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp 2019-02-02 04:05:55 UTC (rev 240892)
@@ -2292,17 +2292,16 @@
if (!origin)
return emptyString();
- std::string host = toSTD(adoptWK(WKSecurityOriginCopyHost(origin))).c_str();
- std::string protocol = toSTD(adoptWK(WKSecurityOriginCopyProtocol(origin))).c_str();
+ auto host = toWTFString(adoptWK(WKSecurityOriginCopyHost(origin)));
+ auto protocol = toWTFString(adoptWK(WKSecurityOriginCopyProtocol(origin)));
- if (!host.length() || !protocol.length())
+ if (host.isEmpty() || protocol.isEmpty())
return emptyString();
- unsigned short port = WKSecurityOriginGetPort(origin);
- if (port)
- return String::format("%s://%s:%d", protocol.c_str(), host.c_str(), port);
+ if (int port = WKSecurityOriginGetPort(origin))
+ return makeString(protocol, "://", host, ':', port);
- return String::format("%s://%s", protocol.c_str(), host.c_str());
+ return makeString(protocol, "://", host);
}
static String userMediaOriginHash(WKSecurityOriginRef userMediaDocumentOrigin, WKSecurityOriginRef topLevelDocumentOrigin)
@@ -2313,7 +2312,7 @@
if (topLevelDocumentOriginString.isEmpty())
return userMediaDocumentOriginString;
- return String::format("%s-%s", userMediaDocumentOriginString.utf8().data(), topLevelDocumentOriginString.utf8().data());
+ return makeString(userMediaDocumentOriginString, '-', topLevelDocumentOriginString);
}
static String userMediaOriginHash(WKStringRef userMediaDocumentOriginString, WKStringRef topLevelDocumentOriginString)
@@ -2600,17 +2599,17 @@
return;
// URL
- WKRetainPtr<WKURLRef> urlWK = adoptWK(WKNavigationDataCopyURL(navigationData));
- WKRetainPtr<WKStringRef> urlStringWK = adoptWK(WKURLCopyString(urlWK.get()));
+ auto url = ""
+ auto urlString = toWTFString(adoptWK(WKURLCopyString(url.get())));
// Title
- WKRetainPtr<WKStringRef> titleWK = adoptWK(WKNavigationDataCopyTitle(navigationData));
+ auto title = toWTFString(adoptWK(WKNavigationDataCopyTitle(navigationData)));
// HTTP method
- WKRetainPtr<WKURLRequestRef> requestWK = adoptWK(WKNavigationDataCopyOriginalRequest(navigationData));
- WKRetainPtr<WKStringRef> methodWK = adoptWK(WKURLRequestCopyHTTPMethod(requestWK.get()));
+ auto request = adoptWK(WKNavigationDataCopyOriginalRequest(navigationData));
+ auto method = toWTFString(adoptWK(WKURLRequestCopyHTTPMethod(request.get())));
// FIXME: Determine whether the navigation was successful / a client redirect rather than hard-coding the message here.
- m_currentInvocation->outputText(String::format("WebView navigated to url \"%s\" with title \"%s\" with HTTP equivalent method \"%s\". The navigation was successful and was not a client redirect.\n",
- toSTD(urlStringWK).c_str(), toSTD(titleWK).c_str(), toSTD(methodWK).c_str()));
+ m_currentInvocation->outputText(makeString("WebView navigated to url \"", urlString, "\" with title \"", title, "\" with HTTP equivalent method \"", method,
+ "\". The navigation was successful and was not a client redirect.\n"));
}
void TestController::didPerformClientRedirect(WKContextRef, WKPageRef, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef frame, const void* clientInfo)
@@ -2626,10 +2625,10 @@
if (!m_shouldLogHistoryClientCallbacks)
return;
- WKRetainPtr<WKStringRef> sourceStringWK = adoptWK(WKURLCopyString(sourceURL));
- WKRetainPtr<WKStringRef> destinationStringWK = adoptWK(WKURLCopyString(destinationURL));
+ auto source = toWTFString(adoptWK(WKURLCopyString(sourceURL)));
+ auto destination = toWTFString(adoptWK(WKURLCopyString(destinationURL)));
- m_currentInvocation->outputText(String::format("WebView performed a client redirect from \"%s\" to \"%s\".\n", toSTD(sourceStringWK).c_str(), toSTD(destinationStringWK).c_str()));
+ m_currentInvocation->outputText(makeString("WebView performed a client redirect from \"", source, "\" to \"", destination, "\".\n"));
}
void TestController::didPerformServerRedirect(WKContextRef, WKPageRef, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef frame, const void* clientInfo)
@@ -2645,10 +2644,10 @@
if (!m_shouldLogHistoryClientCallbacks)
return;
- WKRetainPtr<WKStringRef> sourceStringWK = adoptWK(WKURLCopyString(sourceURL));
- WKRetainPtr<WKStringRef> destinationStringWK = adoptWK(WKURLCopyString(destinationURL));
+ auto source = toWTFString(adoptWK(WKURLCopyString(sourceURL)));
+ auto destination = toWTFString(adoptWK(WKURLCopyString(destinationURL)));
- m_currentInvocation->outputText(String::format("WebView performed a server redirect from \"%s\" to \"%s\".\n", toSTD(sourceStringWK).c_str(), toSTD(destinationStringWK).c_str()));
+ m_currentInvocation->outputText(makeString("WebView performed a server redirect from \"", source, "\" to \"", destination, "\".\n"));
}
void TestController::didUpdateHistoryTitle(WKContextRef, WKPageRef, WKStringRef title, WKURLRef URL, WKFrameRef frame, const void* clientInfo)
@@ -2664,8 +2663,8 @@
if (!m_shouldLogHistoryClientCallbacks)
return;
- WKRetainPtr<WKStringRef> urlStringWK(AdoptWK, WKURLCopyString(URL));
- m_currentInvocation->outputText(String::format("WebView updated the title for history URL \"%s\" to \"%s\".\n", toSTD(urlStringWK).c_str(), toSTD(title).c_str()));
+ auto urlString = toWTFString(adoptWK(WKURLCopyString(URL)));
+ m_currentInvocation->outputText(makeString("WebView updated the title for history URL \"", urlString, "\" to \"", toWTFString(title), "\".\n"));
}
void TestController::setNavigationGesturesEnabled(bool value)