2017-08-23 20:01:59 +00:00
|
|
|
/*
|
2019-09-18 00:36:19 +00:00
|
|
|
* Copyright (C) 2017-2019 Apple Inc. All rights reserved.
|
2017-08-23 20:01:59 +00:00
|
|
|
*
|
|
|
|
* 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
|
2017-08-29 02:59:18 +00:00
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2017-08-23 20:01:59 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-05-24 18:29:01 +00:00
|
|
|
#include <wtf/Lock.h>
|
2019-08-08 22:57:10 +00:00
|
|
|
#include <wtf/ThreadSafeRefCounted.h>
|
2017-08-29 02:59:18 +00:00
|
|
|
#include <wtf/text/StringBuilder.h>
|
2017-08-23 20:01:59 +00:00
|
|
|
|
2020-03-17 14:56:07 +00:00
|
|
|
#if USE(JOURNALD)
|
|
|
|
#define SD_JOURNAL_SUPPRESS_LOCATION
|
|
|
|
#include <systemd/sd-journal.h>
|
|
|
|
#endif
|
|
|
|
|
2017-12-08 20:33:53 +00:00
|
|
|
namespace WTF {
|
2017-08-23 20:01:59 +00:00
|
|
|
|
2017-08-29 02:59:18 +00:00
|
|
|
template<typename T>
|
|
|
|
struct LogArgument {
|
2018-06-23 08:39:34 +00:00
|
|
|
template<typename U = T> static typename std::enable_if<std::is_same<U, bool>::value, String>::type toString(bool argument) { return argument ? "true"_s : "false"_s; }
|
2017-08-29 02:59:18 +00:00
|
|
|
template<typename U = T> static typename std::enable_if<std::is_same<U, int>::value, String>::type toString(int argument) { return String::number(argument); }
|
2017-09-12 18:34:22 +00:00
|
|
|
template<typename U = T> static typename std::enable_if<std::is_same<U, unsigned>::value, String>::type toString(unsigned argument) { return String::number(argument); }
|
|
|
|
template<typename U = T> static typename std::enable_if<std::is_same<U, unsigned long>::value, String>::type toString(unsigned long argument) { return String::number(argument); }
|
2017-09-15 16:20:07 +00:00
|
|
|
template<typename U = T> static typename std::enable_if<std::is_same<U, long>::value, String>::type toString(long argument) { return String::number(argument); }
|
2019-07-31 16:13:33 +00:00
|
|
|
template<typename U = T> static typename std::enable_if<std::is_same<U, unsigned long long>::value, String>::type toString(unsigned long long argument) { return String::number(argument); }
|
|
|
|
template<typename U = T> static typename std::enable_if<std::is_same<U, long long>::value, String>::type toString(long long argument) { return String::number(argument); }
|
2019-03-13 21:22:33 +00:00
|
|
|
template<typename U = T> static typename std::enable_if<std::is_enum<U>::value, String>::type toString(U argument) { return String::number(static_cast<typename std::underlying_type<U>::type>(argument)); }
|
2020-01-14 17:16:03 +00:00
|
|
|
template<typename U = T> static typename std::enable_if<std::is_same<U, float>::value, String>::type toString(float argument) { return String::number(argument); }
|
|
|
|
template<typename U = T> static typename std::enable_if<std::is_same<U, double>::value, String>::type toString(double argument) { return String::number(argument); }
|
2019-06-17 01:48:13 +00:00
|
|
|
template<typename U = T> static typename std::enable_if<std::is_same<typename std::remove_reference<U>::type, AtomString>::value, String>::type toString(const AtomString& argument) { return argument.string(); }
|
2017-08-30 19:06:49 +00:00
|
|
|
template<typename U = T> static typename std::enable_if<std::is_same<typename std::remove_reference<U>::type, String>::value, String>::type toString(String argument) { return argument; }
|
2017-09-15 16:20:07 +00:00
|
|
|
template<typename U = T> static typename std::enable_if<std::is_same<typename std::remove_reference<U>::type, StringBuilder*>::value, String>::type toString(StringBuilder* argument) { return argument->toString(); }
|
2017-08-29 02:59:18 +00:00
|
|
|
template<typename U = T> static typename std::enable_if<std::is_same<U, const char*>::value, String>::type toString(const char* argument) { return String(argument); }
|
|
|
|
template<size_t length> static String toString(const char (&argument)[length]) { return String(argument); }
|
|
|
|
};
|
|
|
|
|
2017-12-12 00:41:54 +00:00
|
|
|
struct JSONLogValue {
|
|
|
|
enum class Type { String, JSON };
|
|
|
|
Type type { Type::JSON };
|
|
|
|
String value;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<class C>
|
|
|
|
class HasToJSONString {
|
|
|
|
template <class T> static std::true_type testSignature(String (T::*)() const);
|
|
|
|
|
|
|
|
template <class T> static decltype(testSignature(&T::toJSONString)) test(std::nullptr_t);
|
|
|
|
template <class T> static std::false_type test(...);
|
|
|
|
|
|
|
|
public:
|
2019-09-18 00:36:19 +00:00
|
|
|
static constexpr bool value = decltype(test<C>(nullptr))::value;
|
2017-12-12 00:41:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template<typename Argument, bool hasJSON = HasToJSONString<Argument>::value>
|
|
|
|
struct ConsoleLogValueImpl;
|
|
|
|
|
|
|
|
template<typename Argument>
|
|
|
|
struct ConsoleLogValueImpl<Argument, true> {
|
|
|
|
static JSONLogValue toValue(const Argument& value)
|
|
|
|
{
|
|
|
|
return JSONLogValue { JSONLogValue::Type::JSON, value.toJSONString() };
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename Argument>
|
|
|
|
struct ConsoleLogValueImpl<Argument, false> {
|
|
|
|
static JSONLogValue toValue(const Argument& value)
|
|
|
|
{
|
|
|
|
return JSONLogValue { JSONLogValue::Type::String, LogArgument<Argument>::toString(value) };
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename Argument, bool hasJSON = std::is_class<Argument>::value>
|
|
|
|
struct ConsoleLogValue;
|
|
|
|
|
|
|
|
template<typename Argument>
|
|
|
|
struct ConsoleLogValue<Argument, true> {
|
|
|
|
static JSONLogValue toValue(const Argument& value)
|
|
|
|
{
|
|
|
|
return ConsoleLogValueImpl<Argument>::toValue(value);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Specialization for non-class types
|
|
|
|
template<typename Argument>
|
|
|
|
struct ConsoleLogValue<Argument, false> {
|
|
|
|
template<typename T>
|
|
|
|
static JSONLogValue toValue(T value)
|
|
|
|
{
|
|
|
|
return JSONLogValue { JSONLogValue::Type::String, LogArgument<T>::toString(value) };
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-05-24 18:29:01 +00:00
|
|
|
WTF_EXPORT_PRIVATE extern Lock loggerObserverLock;
|
2020-08-15 18:40:50 +00:00
|
|
|
|
2019-08-08 22:57:10 +00:00
|
|
|
class Logger : public ThreadSafeRefCounted<Logger> {
|
2017-08-23 20:01:59 +00:00
|
|
|
WTF_MAKE_NONCOPYABLE(Logger);
|
|
|
|
public:
|
2017-08-30 19:06:49 +00:00
|
|
|
|
|
|
|
class Observer {
|
|
|
|
public:
|
2017-10-19 23:48:45 +00:00
|
|
|
virtual ~Observer() = default;
|
2019-08-06 03:45:40 +00:00
|
|
|
// Can be called on any thread.
|
2017-12-12 00:41:54 +00:00
|
|
|
virtual void didLogMessage(const WTFLogChannel&, WTFLogLevel, Vector<JSONLogValue>&&) = 0;
|
2017-08-30 19:06:49 +00:00
|
|
|
};
|
|
|
|
|
2017-08-23 20:01:59 +00:00
|
|
|
static Ref<Logger> create(const void* owner)
|
|
|
|
{
|
|
|
|
return adoptRef(*new Logger(owner));
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename... Arguments>
|
2017-09-05 03:44:05 +00:00
|
|
|
inline void logAlways(WTFLogChannel& channel, UNUSED_FUNCTION const Arguments&... arguments) const
|
2017-08-26 03:30:41 +00:00
|
|
|
{
|
|
|
|
#if RELEASE_LOG_DISABLED
|
|
|
|
// "Standard" WebCore logging goes to stderr, which is captured in layout test output and can generally be a problem
|
|
|
|
// on some systems, so don't allow it.
|
|
|
|
UNUSED_PARAM(channel);
|
|
|
|
#else
|
2019-03-19 16:47:04 +00:00
|
|
|
if (!willLog(channel, WTFLogLevel::Always))
|
2017-08-26 03:30:41 +00:00
|
|
|
return;
|
|
|
|
|
2019-03-19 16:47:04 +00:00
|
|
|
log(channel, WTFLogLevel::Always, arguments...);
|
2017-08-26 03:30:41 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename... Arguments>
|
2017-08-30 19:06:49 +00:00
|
|
|
inline void error(WTFLogChannel& channel, const Arguments&... arguments) const
|
2017-08-23 20:01:59 +00:00
|
|
|
{
|
2019-03-19 16:47:04 +00:00
|
|
|
if (!willLog(channel, WTFLogLevel::Error))
|
2017-08-23 20:01:59 +00:00
|
|
|
return;
|
|
|
|
|
2019-03-19 16:47:04 +00:00
|
|
|
log(channel, WTFLogLevel::Error, arguments...);
|
2017-08-23 20:01:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename... Arguments>
|
2017-08-30 19:06:49 +00:00
|
|
|
inline void warning(WTFLogChannel& channel, const Arguments&... arguments) const
|
2017-08-23 20:01:59 +00:00
|
|
|
{
|
2019-03-19 16:47:04 +00:00
|
|
|
if (!willLog(channel, WTFLogLevel::Warning))
|
2017-08-23 20:01:59 +00:00
|
|
|
return;
|
|
|
|
|
2019-03-19 16:47:04 +00:00
|
|
|
log(channel, WTFLogLevel::Warning, arguments...);
|
2017-08-23 20:01:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename... Arguments>
|
2017-08-30 19:06:49 +00:00
|
|
|
inline void info(WTFLogChannel& channel, const Arguments&... arguments) const
|
2017-08-23 20:01:59 +00:00
|
|
|
{
|
2019-03-19 16:47:04 +00:00
|
|
|
if (!willLog(channel, WTFLogLevel::Info))
|
2017-08-23 20:01:59 +00:00
|
|
|
return;
|
|
|
|
|
2019-03-19 16:47:04 +00:00
|
|
|
log(channel, WTFLogLevel::Info, arguments...);
|
2017-08-23 20:01:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename... Arguments>
|
2017-08-30 19:06:49 +00:00
|
|
|
inline void debug(WTFLogChannel& channel, const Arguments&... arguments) const
|
2017-08-23 20:01:59 +00:00
|
|
|
{
|
2019-03-19 16:47:04 +00:00
|
|
|
if (!willLog(channel, WTFLogLevel::Debug))
|
2017-08-23 20:01:59 +00:00
|
|
|
return;
|
|
|
|
|
2019-03-19 16:47:04 +00:00
|
|
|
log(channel, WTFLogLevel::Debug, arguments...);
|
2017-08-23 20:01:59 +00:00
|
|
|
}
|
|
|
|
|
2020-03-17 14:56:07 +00:00
|
|
|
template<typename... Arguments>
|
|
|
|
inline void logAlwaysVerbose(WTFLogChannel& channel, const char* file, const char* function, int line, UNUSED_FUNCTION const Arguments&... arguments) const
|
|
|
|
{
|
|
|
|
#if RELEASE_LOG_DISABLED
|
|
|
|
// "Standard" WebCore logging goes to stderr, which is captured in layout test output and can generally be a problem
|
|
|
|
// on some systems, so don't allow it.
|
|
|
|
UNUSED_PARAM(channel);
|
2020-03-19 10:26:23 +00:00
|
|
|
UNUSED_PARAM(file);
|
|
|
|
UNUSED_PARAM(function);
|
|
|
|
UNUSED_PARAM(line);
|
2020-03-17 14:56:07 +00:00
|
|
|
#else
|
|
|
|
if (!willLog(channel, WTFLogLevel::Always))
|
|
|
|
return;
|
|
|
|
|
|
|
|
logVerbose(channel, WTFLogLevel::Always, file, function, line, arguments...);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename... Arguments>
|
|
|
|
inline void errorVerbose(WTFLogChannel& channel, const char* file, const char* function, int line, const Arguments&... arguments) const
|
|
|
|
{
|
|
|
|
if (!willLog(channel, WTFLogLevel::Error))
|
|
|
|
return;
|
|
|
|
|
|
|
|
logVerbose(channel, WTFLogLevel::Error, file, function, line, arguments...);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename... Arguments>
|
|
|
|
inline void warningVerbose(WTFLogChannel& channel, const char* file, const char* function, int line, const Arguments&... arguments) const
|
|
|
|
{
|
|
|
|
if (!willLog(channel, WTFLogLevel::Warning))
|
|
|
|
return;
|
|
|
|
|
|
|
|
logVerbose(channel, WTFLogLevel::Warning, file, function, line, arguments...);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename... Arguments>
|
|
|
|
inline void infoVerbose(WTFLogChannel& channel, const char* file, const char* function, int line, const Arguments&... arguments) const
|
|
|
|
{
|
|
|
|
if (!willLog(channel, WTFLogLevel::Info))
|
|
|
|
return;
|
|
|
|
|
|
|
|
logVerbose(channel, WTFLogLevel::Info, file, function, line, arguments...);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename... Arguments>
|
|
|
|
inline void debugVerbose(WTFLogChannel& channel, const char* file, const char* function, int line, const Arguments&... arguments) const
|
|
|
|
{
|
|
|
|
if (!willLog(channel, WTFLogLevel::Debug))
|
|
|
|
return;
|
|
|
|
|
|
|
|
logVerbose(channel, WTFLogLevel::Debug, file, function, line, arguments...);
|
|
|
|
}
|
|
|
|
|
2017-08-30 19:06:49 +00:00
|
|
|
inline bool willLog(const WTFLogChannel& channel, WTFLogLevel level) const
|
2017-08-23 20:01:59 +00:00
|
|
|
{
|
Web Inspector: Enable WebKit logging configuration and display
https://bugs.webkit.org/show_bug.cgi?id=177027
<rdar://problem/33964767>
Reviewed by Joseph Pecoraro.
Source/JavaScriptCore:
* inspector/ConsoleMessage.cpp:
(Inspector::messageSourceValue): Inspector::Protocol::Console::ConsoleMessage ->
Inspector::Protocol::Console::ChannelSource.
* inspector/agents/JSGlobalObjectConsoleAgent.cpp:
(Inspector::JSGlobalObjectConsoleAgent::getLoggingChannels): There are no logging channels
specific to a JSContext yet, so return an empty channel array.
(Inspector::JSGlobalObjectConsoleAgent::setLoggingChannelLevel): No channels, return an error.
* inspector/agents/JSGlobalObjectConsoleAgent.h:
* inspector/protocol/Console.json: Add ChannelSource, ChannelLevel, and Channel. Add getLoggingChannels
and setLoggingChannelLevel.
* inspector/scripts/codegen/generator.py: Special case "webrtc"-> "WebRTC".
* inspector/scripts/tests/generic/expected/enum-values.json-result:
* inspector/scripts/tests/generic/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/generic/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/generic/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result:
* runtime/ConsoleTypes.h: Add Media and WebRTC.
Source/WebCore:
Test: inspector/console/webcore-logging.html
* dom/Document.cpp:
(WebCore::Document::~Document): Stop observing the logger.
(WebCore::Document::logger): Observe the logger.
(WebCore::Document::didLogMessage): Forward logging messages to the inspector.
* dom/Document.h:
* inspector/WebConsoleAgent.cpp:
(WebCore::WebConsoleAgent::getLoggingChannels): New, return the state of log runtime channels.
(WebCore::WebConsoleAgent::setLoggingChannelLevel): New, set the state of a channel.
* inspector/WebConsoleAgent.h:
* platform/Logging.cpp:
(WebCore::getLogChannel): New, get a log channel by name.
* platform/Logging.h:
Source/WebCore/PAL:
* pal/Logger.h:
(PAL::Logger::willLog const): Always return true for Always and Error so those messages are
always logged to the system.
(PAL::Logger::log): Always log Always and Error to the system, but pay strict attention to level
and channel state for logging to observers so logging only shows up in the inspector when
explicitly enabled by the user.
Source/WebInspectorUI:
* Localizations/en.lproj/localizedStrings.js: Add new localized strings.
* UserInterface/Controllers/LogManager.js:
(WI.LogManager): Initialize _loggingChannelSources, fetch _customLoggingChannels.
(WI.LogManager.supportsLogChannels): New.
(WI.LogManager.prototype.get customLoggingChannels): New.
(WI.LogManager.prototype.get logChannelSources): New.
* UserInterface/Main.html:
* UserInterface/Models/ConsoleMessage.js: Add Media and WebRTC.
* UserInterface/Models/IssueMessage.js:
(WI.IssueMessage): Add media and webrtc.
* UserInterface/Models/LoggingChannel.js: Added.
(WI.LoggingChannel):
(WI.LoggingChannel.fromPayload):
(WI.LoggingChannel.prototype.get source):
(WI.LoggingChannel.prototype.get level):
* UserInterface/Views/LogContentView.js:
(WI.LogContentView): Add new scope buttons for "Log", "Info", and "Debug". Create log channel
scope buttons once logging has started.
(WI.LogContentView.prototype.get navigationItems): Add the log message scope bar when necessary.
(WI.LogContentView.prototype._scopeFromMessageSource): New.
(WI.LogContentView.prototype._scopeFromMessageLevel): Don't group Info, Log, and Debug.
(WI.LogContentView.prototype._messageAdded): Force a UI update the first time a WebKit log
message is added.
(WI.LogContentView.prototype._messageShouldBeVisible): New, deal with message source bar buttons.
(WI.LogContentView.prototype._messageSourceBarSelectionDidChange): New.
(WI.LogContentView.prototype._filterMessageElements): Deal with message source bar buttons.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createGeneralSettingsView): Create and initialize menus
for each log channel.
Source/WebKitLegacy/mac:
* WebCoreSupport/WebChromeClient.mm:
(stringForMessageSource): Deal with Media and WebRTC message sources.
Tools:
Allow new 'dumpJSConsoleLogInStdErr' test header to redirect log console output to stderr.
* DumpRenderTree/TestOptions.h:
* DumpRenderTree/TestOptions.mm:
(TestOptions::TestOptions):
* DumpRenderTree/mac/DumpRenderTree.mm:
(runTest):
* WebKitTestRunner/TestController.cpp:
(WTR::updateTestOptionsFromTestHeader):
(WTR::TestController::runTest):
* WebKitTestRunner/TestOptions.h:
(WTR::TestOptions::hasSameInitializationOptions const):
LayoutTests:
* inspector/console/webcore-logging-expected.txt: Added.
* inspector/console/webcore-logging.html: Added.
* platform/mac/TestExpectations: Skip new test on Yosemite and ElCapitan.
* platform/win/TestExpectations: Skip new test.
Canonical link: https://commits.webkit.org/194925@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223929 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-24 22:00:53 +00:00
|
|
|
if (!m_enabled)
|
2017-08-26 03:30:41 +00:00
|
|
|
return false;
|
|
|
|
|
2020-04-08 08:40:19 +00:00
|
|
|
#if USE(SYSTEMD)
|
|
|
|
if (channel.state == WTFLogChannelState::Off)
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
|
2019-03-19 16:47:04 +00:00
|
|
|
if (level <= WTFLogLevel::Error)
|
Web Inspector: Enable WebKit logging configuration and display
https://bugs.webkit.org/show_bug.cgi?id=177027
<rdar://problem/33964767>
Reviewed by Joseph Pecoraro.
Source/JavaScriptCore:
* inspector/ConsoleMessage.cpp:
(Inspector::messageSourceValue): Inspector::Protocol::Console::ConsoleMessage ->
Inspector::Protocol::Console::ChannelSource.
* inspector/agents/JSGlobalObjectConsoleAgent.cpp:
(Inspector::JSGlobalObjectConsoleAgent::getLoggingChannels): There are no logging channels
specific to a JSContext yet, so return an empty channel array.
(Inspector::JSGlobalObjectConsoleAgent::setLoggingChannelLevel): No channels, return an error.
* inspector/agents/JSGlobalObjectConsoleAgent.h:
* inspector/protocol/Console.json: Add ChannelSource, ChannelLevel, and Channel. Add getLoggingChannels
and setLoggingChannelLevel.
* inspector/scripts/codegen/generator.py: Special case "webrtc"-> "WebRTC".
* inspector/scripts/tests/generic/expected/enum-values.json-result:
* inspector/scripts/tests/generic/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/generic/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/generic/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result:
* runtime/ConsoleTypes.h: Add Media and WebRTC.
Source/WebCore:
Test: inspector/console/webcore-logging.html
* dom/Document.cpp:
(WebCore::Document::~Document): Stop observing the logger.
(WebCore::Document::logger): Observe the logger.
(WebCore::Document::didLogMessage): Forward logging messages to the inspector.
* dom/Document.h:
* inspector/WebConsoleAgent.cpp:
(WebCore::WebConsoleAgent::getLoggingChannels): New, return the state of log runtime channels.
(WebCore::WebConsoleAgent::setLoggingChannelLevel): New, set the state of a channel.
* inspector/WebConsoleAgent.h:
* platform/Logging.cpp:
(WebCore::getLogChannel): New, get a log channel by name.
* platform/Logging.h:
Source/WebCore/PAL:
* pal/Logger.h:
(PAL::Logger::willLog const): Always return true for Always and Error so those messages are
always logged to the system.
(PAL::Logger::log): Always log Always and Error to the system, but pay strict attention to level
and channel state for logging to observers so logging only shows up in the inspector when
explicitly enabled by the user.
Source/WebInspectorUI:
* Localizations/en.lproj/localizedStrings.js: Add new localized strings.
* UserInterface/Controllers/LogManager.js:
(WI.LogManager): Initialize _loggingChannelSources, fetch _customLoggingChannels.
(WI.LogManager.supportsLogChannels): New.
(WI.LogManager.prototype.get customLoggingChannels): New.
(WI.LogManager.prototype.get logChannelSources): New.
* UserInterface/Main.html:
* UserInterface/Models/ConsoleMessage.js: Add Media and WebRTC.
* UserInterface/Models/IssueMessage.js:
(WI.IssueMessage): Add media and webrtc.
* UserInterface/Models/LoggingChannel.js: Added.
(WI.LoggingChannel):
(WI.LoggingChannel.fromPayload):
(WI.LoggingChannel.prototype.get source):
(WI.LoggingChannel.prototype.get level):
* UserInterface/Views/LogContentView.js:
(WI.LogContentView): Add new scope buttons for "Log", "Info", and "Debug". Create log channel
scope buttons once logging has started.
(WI.LogContentView.prototype.get navigationItems): Add the log message scope bar when necessary.
(WI.LogContentView.prototype._scopeFromMessageSource): New.
(WI.LogContentView.prototype._scopeFromMessageLevel): Don't group Info, Log, and Debug.
(WI.LogContentView.prototype._messageAdded): Force a UI update the first time a WebKit log
message is added.
(WI.LogContentView.prototype._messageShouldBeVisible): New, deal with message source bar buttons.
(WI.LogContentView.prototype._messageSourceBarSelectionDidChange): New.
(WI.LogContentView.prototype._filterMessageElements): Deal with message source bar buttons.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createGeneralSettingsView): Create and initialize menus
for each log channel.
Source/WebKitLegacy/mac:
* WebCoreSupport/WebChromeClient.mm:
(stringForMessageSource): Deal with Media and WebRTC message sources.
Tools:
Allow new 'dumpJSConsoleLogInStdErr' test header to redirect log console output to stderr.
* DumpRenderTree/TestOptions.h:
* DumpRenderTree/TestOptions.mm:
(TestOptions::TestOptions):
* DumpRenderTree/mac/DumpRenderTree.mm:
(runTest):
* WebKitTestRunner/TestController.cpp:
(WTR::updateTestOptionsFromTestHeader):
(WTR::TestController::runTest):
* WebKitTestRunner/TestOptions.h:
(WTR::TestOptions::hasSameInitializationOptions const):
LayoutTests:
* inspector/console/webcore-logging-expected.txt: Added.
* inspector/console/webcore-logging.html: Added.
* platform/mac/TestExpectations: Skip new test on Yosemite and ElCapitan.
* platform/win/TestExpectations: Skip new test.
Canonical link: https://commits.webkit.org/194925@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223929 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-24 22:00:53 +00:00
|
|
|
return true;
|
|
|
|
|
2019-03-19 16:47:04 +00:00
|
|
|
if (channel.state == WTFLogChannelState::Off || level > channel.level)
|
2017-08-26 03:30:41 +00:00
|
|
|
return false;
|
|
|
|
|
2019-12-24 18:10:53 +00:00
|
|
|
return true;
|
2017-08-23 20:01:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool enabled() const { return m_enabled; }
|
|
|
|
void setEnabled(const void* owner, bool enabled)
|
|
|
|
{
|
|
|
|
ASSERT(owner == m_owner);
|
|
|
|
if (owner == m_owner)
|
|
|
|
m_enabled = enabled;
|
|
|
|
}
|
|
|
|
|
2017-09-07 02:32:57 +00:00
|
|
|
struct LogSiteIdentifier {
|
|
|
|
LogSiteIdentifier(const char* methodName, const void* objectPtr)
|
2017-08-30 19:06:49 +00:00
|
|
|
: methodName { methodName }
|
|
|
|
, objectPtr { reinterpret_cast<uintptr_t>(objectPtr) }
|
2017-08-29 02:59:18 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-09-07 02:32:57 +00:00
|
|
|
LogSiteIdentifier(const char* className, const char* methodName, const void* objectPtr)
|
2017-08-30 19:06:49 +00:00
|
|
|
: className { className }
|
|
|
|
, methodName { methodName }
|
|
|
|
, objectPtr { reinterpret_cast<uintptr_t>(objectPtr) }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-02-12 01:59:28 +00:00
|
|
|
WTF_EXPORT_PRIVATE String toString() const;
|
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
|
|
|
|
2017-08-30 19:06:49 +00:00
|
|
|
const char* className { nullptr };
|
|
|
|
const char* methodName { nullptr };
|
|
|
|
const uintptr_t objectPtr { 0 };
|
2017-08-29 02:59:18 +00:00
|
|
|
};
|
|
|
|
|
2017-08-30 19:06:49 +00:00
|
|
|
static inline void addObserver(Observer& observer)
|
|
|
|
{
|
2021-05-21 19:24:05 +00:00
|
|
|
Locker locker { observerLock() };
|
2017-08-30 19:06:49 +00:00
|
|
|
observers().append(observer);
|
|
|
|
}
|
|
|
|
static inline void removeObserver(Observer& observer)
|
|
|
|
{
|
2021-05-21 19:24:05 +00:00
|
|
|
Locker locker { observerLock() };
|
2017-08-30 19:06:49 +00:00
|
|
|
observers().removeFirstMatching([&observer](auto anObserver) {
|
|
|
|
return &anObserver.get() == &observer;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-08-23 20:01:59 +00:00
|
|
|
private:
|
2019-03-13 20:18:08 +00:00
|
|
|
friend class AggregateLogger;
|
|
|
|
|
2017-08-30 19:06:49 +00:00
|
|
|
Logger(const void* owner)
|
|
|
|
: m_owner { owner }
|
|
|
|
{
|
|
|
|
}
|
2017-08-23 20:01:59 +00:00
|
|
|
|
2017-08-29 02:59:18 +00:00
|
|
|
template<typename... Argument>
|
2017-09-05 03:44:05 +00:00
|
|
|
static inline void log(WTFLogChannel& channel, WTFLogLevel level, const Argument&... arguments)
|
2017-08-23 20:01:59 +00:00
|
|
|
{
|
Remove StringBuilder::appendLiteral
https://bugs.webkit.org/show_bug.cgi?id=226137
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* API/tests/PingPongStackOverflowTest.cpp:
(PingPongStackOverflowObject_hasInstance): Use append instead of appendLiteral.
* bindings/ScriptFunctionCall.cpp:
(Deprecated::ScriptCallArgumentHandler::appendArgument): Remove unnecessary cast
from const char* to String, which defeats optimization and has no benefit.
* bytecompiler/NodesCodegen.cpp:
(JSC::ArrayPatternNode::toString const): Use append instead of appendLiteral.
(JSC::RestParameterNode::toString const): Ditto.
* heap/HeapSnapshotBuilder.cpp:
(JSC::HeapSnapshotBuilder::json): Use append instead of appendLiteral.
Removed unnecesary use of appendQuotedJSONString to append the result of
snapshotTypeToString and edgeTypeToString, which return a const char* that
never contains characters that require special quoting consideration, so
can be appended efficiently with the normal append function.
* inspector/agents/InspectorAuditAgent.cpp:
(Inspector::InspectorAuditAgent::run): Use makeString instead of StringBuilder.
* inspector/agents/InspectorConsoleAgent.cpp: Use auto for the result of makeString.
* jsc.cpp: Use appned instead of appendLiteral.
* parser/ParserArena.cpp:
(JSC::IdentifierArena::makePrivateIdentifier): Use auto for the result of makeString.
* runtime/ConsoleClient.cpp:
(JSC::ConsoleClient::printConsoleMessage): Use append instead of appendLiteral.
Also use variadic append when practical for better efficiency.
(JSC::ConsoleClient::printConsoleMessageWithArguments): Ditto.
* runtime/DateConversion.cpp:
(JSC::formatDateTime): Ditto.
* runtime/ErrorInstance.cpp:
(JSC::ErrorInstance::sanitizedToString): Use makeString instead of StringBuilder.
* runtime/ExceptionHelpers.cpp:
(JSC::notAFunctionSourceAppender): Use append instead of appendLiteral.
* runtime/IntlDateTimeFormat.cpp:
(JSC::IntlDateTimeFormat::initializeDateTimeFormat): Ditto.
* runtime/IntlNumberFormat.cpp:
(JSC::IntlNumberFormat::initializeNumberFormat): Ditto.
* runtime/JSCustomGetterFunction.cpp:
(JSC::JSCustomGetterFunction::create): Use auto and cut down on reference count
churn by using passing the StringImpl to makeString.
* runtime/JSCustomSetterFunction.cpp:
(JSC::JSCustomSetterFunction::create): Ditto.
* runtime/JSGlobalObjectFunctions.cpp: Use more const and use variadic
append for better efficiency.
* runtime/JSONObject.cpp:
(JSC::Stringifier::appendStringifiedValue): Use append instead of appendLiteral.
(JSC::Stringifier::Holder::appendNextProperty): Ditto.
* runtime/JSStringJoiner.h: Deleted unused appendLiteral function.
Unrelated to StringBuilder::appendLiteral, but dead code.
* runtime/Options.cpp:
(JSC::Options::dumpOption): Use append instead of appendLiteral.
* runtime/RegExpPrototype.cpp:
(JSC::appendLineTerminatorEscape<UChar>): Ditto.
* runtime/SamplingProfiler.cpp:
(JSC::SamplingProfiler::reportTopFunctions): Use auto for the result of makeString.
(JSC::SamplingProfiler::reportTopBytecodes): Ditto.
* runtime/TypeProfiler.cpp:
(JSC::TypeProfiler::typeInformationForExpressionAtOffset): Use append instead of
appendLiteral.
* runtime/TypeSet.cpp:
(JSC::TypeSet::dumpTypes const): Use append instead of appendLiteral.
(JSC::TypeSet::toJSONString const): Ditto.
(JSC::StructureShape::propertyHash): Ditto.
(JSC::StructureShape::toJSONString const): Ditto.
Source/WebCore:
* Modules/fetch/FetchBodyConsumer.cpp:
(WebCore::packageFormData): Use auto for the result of makeString.
* Modules/indexeddb/IDBKeyData.cpp:
(WebCore::IDBKeyData::loggingString const): Use append instead
of appendLiteral.
* Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
(WebCore::IDBServer::SQLiteIDBBackingStore::addRecord): Use auto
for the result of makeString.
* Modules/indexeddb/server/SQLiteIDBCursor.cpp:
(WebCore::IDBServer::buildPreIndexStatement): Use makeString
instead of StringBuilder.
(WebCore::IDBServer::buildIndexStatement): Ditto.
(WebCore::IDBServer::buildObjectStoreStatement): Ditto.
* Modules/websockets/WebSocket.cpp:
(WebCore::encodeProtocolString): Use append instead of appendLiteral.
* Modules/websockets/WebSocketExtensionDispatcher.cpp:
(WebCore::WebSocketExtensionDispatcher::appendAcceptedExtension): Ditto.
* Modules/websockets/WebSocketHandshake.cpp:
(WebCore::WebSocketHandshake::clientHandshakeMessage const): Use
makeString instead of StringBuilder.
(WebCore::WebSocketHandshake::clientHandshakeRequest const): Tweak
to match the function above more closely, and use ASCIILiteral.
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(formatForDebugger): Use makeString instead of StringBuilder.
* contentextensions/CombinedURLFilters.cpp:
(WebCore::ContentExtensions::prefixTreeVertexToString): Use
append instead of appendLiteral.
* css/CSSBasicShapes.cpp:
(WebCore::buildCircleString): Ditto.
(WebCore::buildEllipseString): Ditto.
(WebCore::buildPathString): Ditto.
(WebCore::buildPolygonString): Ditto.
(WebCore::buildInsetString): Ditto.
* css/CSSGradientValue.cpp:
(WebCore::CSSLinearGradientValue::customCSSText const): Ditto.
(WebCore::CSSRadialGradientValue::customCSSText const): Ditto.
(WebCore::CSSConicGradientValue::customCSSText const): Ditto.
* css/CSSGridIntegerRepeatValue.cpp:
(WebCore::CSSGridIntegerRepeatValue::customCSSText const):
Use makeString instead of StringBuilder.
* css/CSSImageSetValue.cpp:
(WebCore::CSSImageSetValue::customCSSText const): Use append
instead of appendLiteral.
* css/CSSImportRule.cpp:
(WebCore::CSSImportRule::cssText const): Use makeString instead
of StringBuilder.
* css/CSSKeyframeRule.cpp:
(WebCore::StyleRuleKeyframe::cssText const): Ditto.
* css/CSSKeyframesRule.cpp:
(WebCore::CSSKeyframesRule::cssText const): Use variadic append.
* css/CSSLineBoxContainValue.cpp:
(WebCore::CSSLineBoxContainValue::customCSSText const): Use
append instead of appendLiteral.
* css/CSSNamespaceRule.cpp:
(WebCore::CSSNamespaceRule::cssText const): Ditto.
* css/CSSPageRule.cpp:
(WebCore::CSSPageRule::cssText const): Use makeString instead of
StringBuilder.
* css/CSSPaintImageValue.cpp:
(WebCore::CSSPaintImageValue::customCSSText const): Ditto.
* css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText const):
Use append instead of appendLiteral.
* css/CSSSelector.cpp:
(WebCore::appendLangArgumentList): Use variadic append.
(WebCore::CSSSelector::selectorText const): Ditto. Also use
append instead of appendLiteral and make some improvements to
cut down on allocations a little.
* css/CSSSelectorList.cpp:
(WebCore::CSSSelectorList::buildSelectorsText const): Use
append instead of appendLiteral.
* css/CSSStyleSheet.cpp:
(WebCore::CSSStyleSheet::CSSStyleSheet): Moved more of the
data member initialization to the class definition.
(WebCore::CSSStyleSheet::addRule): Use makeString instead of
StringBuilder.
* css/CSSStyleSheet.h: Moved initialization here.
* css/CSSTimingFunctionValue.cpp:
(WebCore::CSSStepsTimingFunctionValue::customCSSText const):
Use makeString instead of StringBuilder.
(WebCore::CSSSpringTimingFunctionValue::customCSSText const):
Ditto.
* css/MediaList.cpp:
(WebCore::MediaQuerySet::mediaText const): Use append instead
of appendLiteral.
* css/MediaQuery.cpp:
(WebCore::MediaQuery::serialize const): Ditto.
* css/MediaQueryExpression.cpp:
(WebCore::MediaQueryExpression::serialize const): Use makeString
instead of StringBuilder.
* css/StyleProperties.cpp:
(WebCore::StyleProperties::getLayeredShorthandValue const):
Use append instead of appendLiteral.
* css/parser/CSSParserToken.cpp:
(WebCore::CSSParserToken::serialize const): Removed a lot of
unnecessary braces. Use variadic append and append instead of appendLiteral.
* dom/Document.cpp:
(WebCore::Document::initSecurityContext): Use auto for the result
of makeString.
* dom/Element.cpp:
(WebCore::appendAttributes): Use variadic append and append
instead of appendLiteral.
* dom/SecurityContext.cpp:
(WebCore::SecurityContext::parseSandboxPolicy): Ditto.
* editing/HTMLInterchange.cpp:
(WebCore::convertHTMLTextToInterchangeFormat): Ditto.
* editing/TextIterator.cpp:
(WebCore::createSearcher): Use auto for the result of makeString.
* editing/markup.cpp:
(WebCore::StyledMarkupAccumulator::appendStyleNodeOpenTag):
Use append instead of appendLiteral.
(WebCore::StyledMarkupAccumulator::appendStartTag): Ditto.
(WebCore::urlToMarkup): Ditto.
* html/FormController.cpp:
(WebCore::recordFormStructure): Ditto.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::reportValidity): Use auto for
the result of makeString.
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::validateInteractively): Ditto.
* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::completeURLsInAttributeValue const):
Use append insteaed of appendLiteral.
* html/MediaElementSession.cpp:
(WebCore::restrictionNames): Use auto for the result of makeString.
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::getUniformLocation): Ditto.
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::ExternalCharacterTokenBuffer::takeRemaining): Ditto.
* html/parser/XSSAuditorDelegate.cpp:
(WebCore::buildConsoleError): Use makeString instead of StringBuilder.
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::rebuildDisplayTree): Ditto.
* inspector/InspectorFrontendAPIDispatcher.cpp:
(WebCore::expressionForEvaluatingCommand): Use append instead of appendLiteral.
* inspector/InspectorOverlay.cpp:
(WebCore::InspectorOverlay::drawElementTitle): Use auto for the result of makeString.
* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyleSheet::addRule): Use append instead of appendLiteral.
* inspector/agents/InspectorApplicationCacheAgent.cpp:
(WebCore::InspectorApplicationCacheAgent::buildObjectForApplicationCacheResource):
Use makeString instead of StringBuilder.
* inspector/agents/WebConsoleAgent.cpp:
(WebCore::WebConsoleAgent::didReceiveResponse): Use auto for the result of makeString.
(WebCore::WebConsoleAgent::didFailLoading): Ditto.
* loader/MixedContentChecker.cpp:
(WebCore::logWarning): Ditto
(WebCore::MixedContentChecker::checkFormForMixedContent): Ditto
* loader/PrivateClickMeasurement.cpp:
(WebCore::makeValidURL): Added. Used for various cases below that all construct
URLs in the same way with the same kinds of checks. Use makeString here instead
of StringBuilder.
(WebCore::attributionReportURL): Call makeValidURL.
(WebCore::PrivateClickMeasurement::tokenSignatureURL const): Ditto.
(WebCore::PrivateClickMeasurement::tokenPublicKeyURL const): Ditto.
* loader/ResourceLoadStatistics.cpp:
(WebCore::appendBoolean): Use append instead of appendLiteral.
(WebCore::appendHashSet): Ditto.
(WebCore::appendNavigatorAPIOptionSet): Ditto.
(WebCore::appendScreenAPIOptionSet): Ditto.
(WebCore::ResourceLoadStatistics::toString const): Ditto.
* loader/WorkerThreadableLoader.cpp:
(WebCore::WorkerThreadableLoader::loadResourceSynchronously): Use auto for
the result of makeString.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::postMessage): Ditto.
* page/Frame.cpp:
(WebCore::createRegExpForLabels): Use append instead of appendLiteral.
Also tweak coding style a bit.
* page/FrameView.cpp:
(WebCore::FrameView::logMockScrollAnimatorMessage const): Use makeString
instead of StringBuilder.
* page/PageSerializer.cpp:
(WebCore::PageSerializer::SerializerMarkupAccumulator::appendStartTag):
Use append instead of appendLiteral.
(WebCore::PageSerializer::serializeCSSStyleSheet): Ditto.
(WebCore::PageSerializer::urlForBlankFrame): Use auto for the result of
makeString.
* page/PerformanceLoggingClient.cpp:
(WebCore::PerformanceLoggingClient::synchronousScrollingReasonsAsString):
Use makeString instead of StringBuilder.
* page/cocoa/ResourceUsageOverlayCocoa.mm:
(WebCore::ResourceUsageOverlay::platformDraw): Use auto for the result of
makeString.
* page/csp/ContentSecurityPolicy.cpp:
(WebCore::consoleMessageForViolation): Use makeString instsead of StringBuilder.
(WebCore::ContentSecurityPolicy::allowRunningOrDisplayingInsecureContent): Ditto.
(WebCore::ContentSecurityPolicy::reportInvalidDirectiveValueCharacter const):
Get rid of local variable for result of makeString.
(WebCore::ContentSecurityPolicy::reportInvalidPathCharacter const): Ditto.
(WebCore::ContentSecurityPolicy::reportInvalidSourceExpression const): Ditto.
* page/csp/ContentSecurityPolicyDirectiveList.cpp:
(WebCore::ContentSecurityPolicyDirectiveList::create): Get rid of local
variable for result of makeString.
* page/scrolling/ScrollingCoordinator.cpp:
(WebCore::ScrollingCoordinator::synchronousScrollingReasonsAsText):
Use makeString instead of StringBulder.
* platform/Decimal.cpp:
(WebCore::Decimal::toString const): Use append instead of appendLiteral.
* platform/animation/TimingFunction.cpp:
(WebCore::TimingFunction::createFromCSSText): Use makeString instead
of StringBuilder.
* platform/audio/HRTFElevation.cpp:
(WebCore::HRTFElevation::calculateKernelsForAzimuthElevation): Use auto
for the result of makeString.
* platform/glib/UserAgentGLib.cpp:
(WebCore::buildUserAgentString): Use append instead of appendLiteral.
* platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
(WebCore::InbandTextTrackPrivateAVF::processCueAttributes): Use
append instead of appendLiteral.
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::recursiveCommitChanges): Got rid of local
variable for result of makeString.
(WebCore::GraphicsLayerCA::appendToUncommittedAnimations): Use auto
for result of makeString.
* platform/graphics/ca/TileController.cpp:
(WebCore::TileController::tileRevalidationTimerFired): Update to
use OptionSet.
* platform/graphics/ca/TileGrid.cpp:
(WebCore::validationPolicyAsString): Use OptionSet.
(WebCore::TileGrid::setNeedsDisplayInRect): Use auto for iterator
and range-based for loop.
(WebCore::TileGrid::updateTileLayerProperties): Ditto.
(WebCore::TileGrid::blankPixelCount const): Ditto.
(WebCore::TileGrid::removeTiles): Use HashCountedSet.
(WebCore::TileGrid::revalidateTiles): Use OptionSet.
(WebCore::TileGrid::retainedTileBackingStoreMemory const): Use
ranged-based for loop.
(WebCore::TileGrid::drawTileMapContents const): Use range-based
for loop and use writeIntegerToBuffer instead of String::number.
(WebCore::TileGrid::platformCALayerRepaintCount const): Use
HashCountedSet.
(WebCore::TileGrid::platformCALayerIncrementRepaintCount): Ditto.
This cuts us down from 3 hash table lookups to 1.
(WebCore::TileGrid::removeUnparentedTilesNow): Removed local
variable to make code a little tighter.
* platform/graphics/ca/TileGrid.h: Use OptionSet and HashCountedSet.
Removed some type names.
* platform/graphics/ca/cocoa/PlatformCAFiltersCocoa.mm:
(WebCore::PlatformCAFilters::setFiltersOnLayer): Use auto for
reuslt of makeString.
* platform/mock/MockRealtimeVideoSource.cpp:
(WebCore::MockRealtimeVideoSource::drawText): Ditto.
* platform/mock/ScrollAnimatorMock.cpp:
(WebCore::ScrollAnimatorMock::scrollbarPrefix const): Added
helper function for use below.
(WebCore::ScrollAnimatorMock::mouseEnteredScrollbar const): Use
makeString instead of StringBuilder.
(WebCore::ScrollAnimatorMock::mouseExitedScrollbar const): Ditto.
(WebCore::ScrollAnimatorMock::mouseIsDownInScrollbar const): Ditto.
* platform/mock/ScrollAnimatorMock.h: Ditto.
* platform/network/ProxyServer.cpp:
(WebCore::appendProxyServerString): Use append instead of appendLiteral.
(WebCore::toString): Ditto.
* platform/network/ResourceResponseBase.cpp:
(WebCore::ResourceResponseBase::sanitizeSuggestedFilename): Get rid
of local variable with result of maekString in it.
* platform/playstation/UserAgentPlayStation.cpp:
(WebCore::platformForUAString): Deleted. No need for a global variable
to hold the result of something called only once.
(WebCore::platformVersionForUAString): Ditto.
(WebCore::buildUserAgentString): Deleted.
(WebCore::standardUserAgentStatic): Moved the logic from buildUserAgentString
here, using makeString instead of StringBuilder.
* platform/sql/SQLiteDatabase.cpp:
(WebCore::SQLiteDatabase::open): Use auto for result of makeString.
* platform/sql/SQLiteFileSystem.cpp:
(WebCore::SQLiteFileSystem::deleteDatabaseFile): Ditto.
* platform/text/DateTimeFormat.cpp:
(WebCore::DateTimeFormat::quoteAndAppendLiteral): Use append instead
of appendLiteral and StringView::substring instead of String::substring.
* platform/win/ClipboardUtilitiesWin.cpp:
(WebCore::replaceNewlinesWithWindowsStyleNewlines): Use append
instead of appendLiteral.
* platform/win/UserAgentWin.cpp:
(WebCore::standardUserAgent): Use makeString instead of StringBuildeer.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::name const): Ditto.
(WebCore::RenderLayer::debugDescription const): Ditto.
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::logLayerInfo): Use append instead of
appendLiteral.
* rendering/RenderTreeAsText.cpp:
(WebCore::quoteAndEscapeNonPrintables): Ditto.
(WebCore::nodePosition): Ditto.
* svg/SVGPathStringBuilder.cpp:
(WebCore::SVGPathStringBuilder::moveTo): Ditto.
(WebCore::SVGPathStringBuilder::lineTo): Ditto.
(WebCore::SVGPathStringBuilder::lineToHorizontal): Ditto.
(WebCore::SVGPathStringBuilder::lineToVertical): Ditto.
(WebCore::SVGPathStringBuilder::curveToCubic): Ditto.
(WebCore::SVGPathStringBuilder::curveToCubicSmooth): Ditto.
(WebCore::SVGPathStringBuilder::curveToQuadratic): Ditto.
(WebCore::SVGPathStringBuilder::curveToQuadraticSmooth): Ditto.
(WebCore::SVGPathStringBuilder::arcTo): Ditto.
(WebCore::SVGPathStringBuilder::closePath): Ditto.
* testing/Internals.cpp:
(WebCore::Internals::dumpMarkerRects): Ditto.
(WebCore::appendOffsets):
(WebCore::Internals::scrollSnapOffsets): Ditto.
* workers/WorkerScriptLoader.cpp:
(WebCore::WorkerScriptLoader::validateWorkerResponse): Use auto
for reuslt of makeString.
Source/WebKit:
* NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
(WebKit::ResourceLoadStatisticsDatabaseStore::ensureAndMakeDomainList): Use append
instead of appendLiteral.
(WebKit::domainsToString): Ditto.
(WebKit::buildList): Ditto.
(WebKit::ResourceLoadStatisticsDatabaseStore::findNotVeryPrevalentResources): Ditto.
(WebKit::ResourceLoadStatisticsDatabaseStore::dumpResourceLoadStatistics): Ditto.
(WebKit::appendBoolean): Ditto.
(WebKit::appendNextEntry): Ditto.
(WebKit::ResourceLoadStatisticsDatabaseStore::appendSubStatisticList const): Ditto.
(WebKit::ResourceLoadStatisticsDatabaseStore::resourceToString const): Ditto.
(WebKit::ResourceLoadStatisticsDatabaseStore::attributionToString): Ditto.
(WebKit::ResourceLoadStatisticsDatabaseStore::privateClickMeasurementToString): Ditto.
* NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
(WebKit::ResourceLoadStatisticsMemoryStore::dumpResourceLoadStatistics): Ditto.
* NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp: Ditto.
(WebKit::domainsToString): Ditto.
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::create): Moved this here from the header.
(WebKit::WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty::toString const): Ditto.
(WebKit::WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty::encode const): Ditto.
(WebKit::WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty::decode): Ditto.
(WebKit::WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty::operator== const): Ditto.
(WebKit::WebResourceLoadStatisticsStore::ThirdPartyData::toString const): Ditto.
(WebKit::WebResourceLoadStatisticsStore::ThirdPartyData::encode const): Ditto.
(WebKit::WebResourceLoadStatisticsStore::ThirdPartyData::decode): Ditto.
(WebKit::WebResourceLoadStatisticsStore::ThirdPartyData::operator< const): Ditto.
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h: Moved member
functions of the nested structures into the implementation file and fixed
the indentation of the structures to indicate the nesting.
* NetworkProcess/NetworkLoadChecker.cpp:
(WebKit::NetworkLoadChecker::continueCheckingRequest): Do not use a local
variable for the reuslt of makeString.
* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::newTestingSession): Ditto.
* NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::Cache::dumpContentsToFile): Use append instead of appendLiteral
* NetworkProcess/cache/NetworkCacheEntry.cpp:
(WebKit::NetworkCache::Entry::asJSON const): Ditto.
* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::makeVersionedDirectoryPath): Do not use a local variable for
the result of makeString.
* NetworkProcess/soup/NetworkProcessSoup.cpp:
(WebKit::buildAcceptLanguages): Use append instead of appendLiteral.
* NetworkProcess/soup/WebSocketTaskSoup.cpp:
(WebKit::WebSocketTask::acceptedExtensions const): Ditto.
* NetworkProcess/webrtc/NetworkMDNSRegister.cpp:
(WebKit::NetworkMDNSRegister::registerMDNSName): Use auto for the result of makeString.
* Shared/WebMemorySampler.cpp:
(WebKit::WebMemorySampler::writeHeaders): Ditto.
* Shared/mac/AuxiliaryProcessMac.mm:
(WebKit::initializeSandboxParameters): Do not use a local variable for the result of
makeString. Also, take advantage of the support for concatenating an NSString instead
of converting it to a WTF::String.
* Shared/mac/WebMemorySampler.mac.mm:
(WebKit::WebMemorySampler::sampleWebKit const): Use ASCIILiteral and remove explicit
conversion to String.
* UIProcess/API/glib/WebKitWebView.cpp:
(webkitWebViewRunJavaScriptCallback): Use append instead of appendLiteral.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::fileCanBeAcceptedForUpload): Use auto for result of makeString.
* WebProcess/InjectedBundle/API/glib/WebKitWebPage.cpp: Use makeString instead of
StringBuilder.
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::requestStorageSpace): Use auto for result of makeString.
* UIProcess/WebBackForwardList.cpp:
(WebKit::WebBackForwardList::loggingString): Use append instead of appendLiteral.
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::processDidFinishLaunching): Use auto for result of makeString.
(WebKit::WebProcessPool::startMemorySampler): Ditto.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::dumpHistoryItem): Use append instead of appendLiteral.
(WebKit::WebPage::getContentsAsString): Ditto.
Source/WebKitLegacy:
* WebCoreSupport/NetworkStorageSessionMap.cpp:
(NetworkStorageSessionMap::switchToNewTestingSession): Do not use local
for return value of makeString.
Source/WebKitLegacy/mac:
* WebView/WebHTMLRepresentation.mm:
(regExpForLabels): Use append instead of appendLiteral.
Also imrpove local variable names a bit.
Source/WebKitLegacy/win:
* AccessibleBase.cpp:
(AccessibleBase::get_accKeyboardShortcut): Use append instead of appnedLiteral.
* WebView.cpp: Ditto.
Source/WTF:
The optimization done by appendLiteral has minimal value and is something we
can do without. It does not cut down the number of allocations, which is the
main cost of the StringBuilder class. Getting rid of the differently named
appendLiteral improves the design of the StringBuilder class for callers.
Our goal is to get as close as possible to a single append function.
If we decide we need an optimization for literals, we can come up with a
different way that is compatible with append. For example, we could assume
that any char array is a literal and check that at compile time in
StringConcatenate; that optimization would work for both makeString and
StringBuilder. Or we could use a strategy like ASCIILiteral.
* wtf/FileSystem.cpp:
(WTF::FileSystemImpl::encodeForFileName): Streamline logic,
and use variadic append to make this more efficient.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::escapeString): Use append instead
of appendLiteral.
(WTF::JSONImpl::Value::writeJSON const): Ditto.
* wtf/Logger.h:
(WTF::Logger::log): Use auto for result of makeString.
(WTF::Logger::logVerbose): Ditto.
* wtf/MediaTime.cpp:
(WTF::MediaTime::toString const): Use makeString instead of StringBuilder.
* wtf/text/IntegerToStringConversion.h:
Made lengthOfIntegerAsString a constexpr function so we can use it to
compute the required size of arrays for conversion. Added using for both
lengthOfIntegerAsString and writeIntegerToBuffer so we can use them without
the WTF prefix as is customary for functions in WTF.
* wtf/text/StringBuilder.h:
(WTF::StringBuilder::appendLiteral): Deleted.
* wtf/text/StringConcatenate.h: Added support for appending StringImpl&,
StringImpl*, AtomStringImpl&, and AtomStringImpl*.
Tools:
* TestWebKitAPI/Tests/WTF/StringBuilder.cpp:
Use append instead of appendLiteral.
* TestWebKitAPI/Tests/WebCore/FileMonitor.cpp:
(TestWebKitAPI::createCommand): Use makeString instead of StringBuilder.
* TestWebKitAPI/Tests/WebCore/Logging.cpp:
(TestWebKitAPI::TEST_F): Made lots of fixes to code inside #if TEST_OUTPUT,
which hasn't compiled in a long time. Still not 100% there, but closer.
* TestWebKitAPI/Tests/WebCore/TextCodec.cpp:
(TestWebKitAPI::testDecode): Use append instead of appendLiteral.
* WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
(WTR::AccessibilityUIElement::helpText const): Ditto.
Canonical link: https://commits.webkit.org/238091@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277967 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-24 21:51:47 +00:00
|
|
|
auto logMessage = makeString(LogArgument<Argument>::toString(arguments)...);
|
2017-08-23 20:01:59 +00:00
|
|
|
|
|
|
|
#if RELEASE_LOG_DISABLED
|
2017-08-30 19:06:49 +00:00
|
|
|
WTFLog(&channel, "%s", logMessage.utf8().data());
|
2020-03-17 14:56:07 +00:00
|
|
|
#endif
|
|
|
|
#if USE(OS_LOG) && !RELEASE_LOG_DISABLED
|
2017-08-30 19:06:49 +00:00
|
|
|
os_log(channel.osLogChannel, "%{public}s", logMessage.utf8().data());
|
2017-08-23 20:01:59 +00:00
|
|
|
#endif
|
2020-03-17 14:56:07 +00:00
|
|
|
#if USE(JOURNALD) && !RELEASE_LOG_DISABLED
|
|
|
|
sd_journal_send("WEBKIT_SUBSYSTEM=%s", channel.subsystem, "WEBKIT_CHANNEL=%s", channel.name, "MESSAGE=%s", logMessage.utf8().data(), nullptr);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (channel.state == WTFLogChannelState::Off || level > channel.level)
|
|
|
|
return;
|
|
|
|
|
2021-05-21 19:24:05 +00:00
|
|
|
if (!observerLock().tryLock())
|
2020-03-17 14:56:07 +00:00
|
|
|
return;
|
|
|
|
|
2021-05-23 19:55:32 +00:00
|
|
|
Locker locker { AdoptLock, observerLock() };
|
2020-03-17 14:56:07 +00:00
|
|
|
for (Observer& observer : observers())
|
|
|
|
observer.didLogMessage(channel, level, { ConsoleLogValue<Argument>::toValue(arguments)... });
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename... Argument>
|
|
|
|
static inline void logVerbose(WTFLogChannel& channel, WTFLogLevel level, const char* file, const char* function, int line, const Argument&... arguments)
|
|
|
|
{
|
Remove StringBuilder::appendLiteral
https://bugs.webkit.org/show_bug.cgi?id=226137
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* API/tests/PingPongStackOverflowTest.cpp:
(PingPongStackOverflowObject_hasInstance): Use append instead of appendLiteral.
* bindings/ScriptFunctionCall.cpp:
(Deprecated::ScriptCallArgumentHandler::appendArgument): Remove unnecessary cast
from const char* to String, which defeats optimization and has no benefit.
* bytecompiler/NodesCodegen.cpp:
(JSC::ArrayPatternNode::toString const): Use append instead of appendLiteral.
(JSC::RestParameterNode::toString const): Ditto.
* heap/HeapSnapshotBuilder.cpp:
(JSC::HeapSnapshotBuilder::json): Use append instead of appendLiteral.
Removed unnecesary use of appendQuotedJSONString to append the result of
snapshotTypeToString and edgeTypeToString, which return a const char* that
never contains characters that require special quoting consideration, so
can be appended efficiently with the normal append function.
* inspector/agents/InspectorAuditAgent.cpp:
(Inspector::InspectorAuditAgent::run): Use makeString instead of StringBuilder.
* inspector/agents/InspectorConsoleAgent.cpp: Use auto for the result of makeString.
* jsc.cpp: Use appned instead of appendLiteral.
* parser/ParserArena.cpp:
(JSC::IdentifierArena::makePrivateIdentifier): Use auto for the result of makeString.
* runtime/ConsoleClient.cpp:
(JSC::ConsoleClient::printConsoleMessage): Use append instead of appendLiteral.
Also use variadic append when practical for better efficiency.
(JSC::ConsoleClient::printConsoleMessageWithArguments): Ditto.
* runtime/DateConversion.cpp:
(JSC::formatDateTime): Ditto.
* runtime/ErrorInstance.cpp:
(JSC::ErrorInstance::sanitizedToString): Use makeString instead of StringBuilder.
* runtime/ExceptionHelpers.cpp:
(JSC::notAFunctionSourceAppender): Use append instead of appendLiteral.
* runtime/IntlDateTimeFormat.cpp:
(JSC::IntlDateTimeFormat::initializeDateTimeFormat): Ditto.
* runtime/IntlNumberFormat.cpp:
(JSC::IntlNumberFormat::initializeNumberFormat): Ditto.
* runtime/JSCustomGetterFunction.cpp:
(JSC::JSCustomGetterFunction::create): Use auto and cut down on reference count
churn by using passing the StringImpl to makeString.
* runtime/JSCustomSetterFunction.cpp:
(JSC::JSCustomSetterFunction::create): Ditto.
* runtime/JSGlobalObjectFunctions.cpp: Use more const and use variadic
append for better efficiency.
* runtime/JSONObject.cpp:
(JSC::Stringifier::appendStringifiedValue): Use append instead of appendLiteral.
(JSC::Stringifier::Holder::appendNextProperty): Ditto.
* runtime/JSStringJoiner.h: Deleted unused appendLiteral function.
Unrelated to StringBuilder::appendLiteral, but dead code.
* runtime/Options.cpp:
(JSC::Options::dumpOption): Use append instead of appendLiteral.
* runtime/RegExpPrototype.cpp:
(JSC::appendLineTerminatorEscape<UChar>): Ditto.
* runtime/SamplingProfiler.cpp:
(JSC::SamplingProfiler::reportTopFunctions): Use auto for the result of makeString.
(JSC::SamplingProfiler::reportTopBytecodes): Ditto.
* runtime/TypeProfiler.cpp:
(JSC::TypeProfiler::typeInformationForExpressionAtOffset): Use append instead of
appendLiteral.
* runtime/TypeSet.cpp:
(JSC::TypeSet::dumpTypes const): Use append instead of appendLiteral.
(JSC::TypeSet::toJSONString const): Ditto.
(JSC::StructureShape::propertyHash): Ditto.
(JSC::StructureShape::toJSONString const): Ditto.
Source/WebCore:
* Modules/fetch/FetchBodyConsumer.cpp:
(WebCore::packageFormData): Use auto for the result of makeString.
* Modules/indexeddb/IDBKeyData.cpp:
(WebCore::IDBKeyData::loggingString const): Use append instead
of appendLiteral.
* Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
(WebCore::IDBServer::SQLiteIDBBackingStore::addRecord): Use auto
for the result of makeString.
* Modules/indexeddb/server/SQLiteIDBCursor.cpp:
(WebCore::IDBServer::buildPreIndexStatement): Use makeString
instead of StringBuilder.
(WebCore::IDBServer::buildIndexStatement): Ditto.
(WebCore::IDBServer::buildObjectStoreStatement): Ditto.
* Modules/websockets/WebSocket.cpp:
(WebCore::encodeProtocolString): Use append instead of appendLiteral.
* Modules/websockets/WebSocketExtensionDispatcher.cpp:
(WebCore::WebSocketExtensionDispatcher::appendAcceptedExtension): Ditto.
* Modules/websockets/WebSocketHandshake.cpp:
(WebCore::WebSocketHandshake::clientHandshakeMessage const): Use
makeString instead of StringBuilder.
(WebCore::WebSocketHandshake::clientHandshakeRequest const): Tweak
to match the function above more closely, and use ASCIILiteral.
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(formatForDebugger): Use makeString instead of StringBuilder.
* contentextensions/CombinedURLFilters.cpp:
(WebCore::ContentExtensions::prefixTreeVertexToString): Use
append instead of appendLiteral.
* css/CSSBasicShapes.cpp:
(WebCore::buildCircleString): Ditto.
(WebCore::buildEllipseString): Ditto.
(WebCore::buildPathString): Ditto.
(WebCore::buildPolygonString): Ditto.
(WebCore::buildInsetString): Ditto.
* css/CSSGradientValue.cpp:
(WebCore::CSSLinearGradientValue::customCSSText const): Ditto.
(WebCore::CSSRadialGradientValue::customCSSText const): Ditto.
(WebCore::CSSConicGradientValue::customCSSText const): Ditto.
* css/CSSGridIntegerRepeatValue.cpp:
(WebCore::CSSGridIntegerRepeatValue::customCSSText const):
Use makeString instead of StringBuilder.
* css/CSSImageSetValue.cpp:
(WebCore::CSSImageSetValue::customCSSText const): Use append
instead of appendLiteral.
* css/CSSImportRule.cpp:
(WebCore::CSSImportRule::cssText const): Use makeString instead
of StringBuilder.
* css/CSSKeyframeRule.cpp:
(WebCore::StyleRuleKeyframe::cssText const): Ditto.
* css/CSSKeyframesRule.cpp:
(WebCore::CSSKeyframesRule::cssText const): Use variadic append.
* css/CSSLineBoxContainValue.cpp:
(WebCore::CSSLineBoxContainValue::customCSSText const): Use
append instead of appendLiteral.
* css/CSSNamespaceRule.cpp:
(WebCore::CSSNamespaceRule::cssText const): Ditto.
* css/CSSPageRule.cpp:
(WebCore::CSSPageRule::cssText const): Use makeString instead of
StringBuilder.
* css/CSSPaintImageValue.cpp:
(WebCore::CSSPaintImageValue::customCSSText const): Ditto.
* css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText const):
Use append instead of appendLiteral.
* css/CSSSelector.cpp:
(WebCore::appendLangArgumentList): Use variadic append.
(WebCore::CSSSelector::selectorText const): Ditto. Also use
append instead of appendLiteral and make some improvements to
cut down on allocations a little.
* css/CSSSelectorList.cpp:
(WebCore::CSSSelectorList::buildSelectorsText const): Use
append instead of appendLiteral.
* css/CSSStyleSheet.cpp:
(WebCore::CSSStyleSheet::CSSStyleSheet): Moved more of the
data member initialization to the class definition.
(WebCore::CSSStyleSheet::addRule): Use makeString instead of
StringBuilder.
* css/CSSStyleSheet.h: Moved initialization here.
* css/CSSTimingFunctionValue.cpp:
(WebCore::CSSStepsTimingFunctionValue::customCSSText const):
Use makeString instead of StringBuilder.
(WebCore::CSSSpringTimingFunctionValue::customCSSText const):
Ditto.
* css/MediaList.cpp:
(WebCore::MediaQuerySet::mediaText const): Use append instead
of appendLiteral.
* css/MediaQuery.cpp:
(WebCore::MediaQuery::serialize const): Ditto.
* css/MediaQueryExpression.cpp:
(WebCore::MediaQueryExpression::serialize const): Use makeString
instead of StringBuilder.
* css/StyleProperties.cpp:
(WebCore::StyleProperties::getLayeredShorthandValue const):
Use append instead of appendLiteral.
* css/parser/CSSParserToken.cpp:
(WebCore::CSSParserToken::serialize const): Removed a lot of
unnecessary braces. Use variadic append and append instead of appendLiteral.
* dom/Document.cpp:
(WebCore::Document::initSecurityContext): Use auto for the result
of makeString.
* dom/Element.cpp:
(WebCore::appendAttributes): Use variadic append and append
instead of appendLiteral.
* dom/SecurityContext.cpp:
(WebCore::SecurityContext::parseSandboxPolicy): Ditto.
* editing/HTMLInterchange.cpp:
(WebCore::convertHTMLTextToInterchangeFormat): Ditto.
* editing/TextIterator.cpp:
(WebCore::createSearcher): Use auto for the result of makeString.
* editing/markup.cpp:
(WebCore::StyledMarkupAccumulator::appendStyleNodeOpenTag):
Use append instead of appendLiteral.
(WebCore::StyledMarkupAccumulator::appendStartTag): Ditto.
(WebCore::urlToMarkup): Ditto.
* html/FormController.cpp:
(WebCore::recordFormStructure): Ditto.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::reportValidity): Use auto for
the result of makeString.
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::validateInteractively): Ditto.
* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::completeURLsInAttributeValue const):
Use append insteaed of appendLiteral.
* html/MediaElementSession.cpp:
(WebCore::restrictionNames): Use auto for the result of makeString.
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::getUniformLocation): Ditto.
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::ExternalCharacterTokenBuffer::takeRemaining): Ditto.
* html/parser/XSSAuditorDelegate.cpp:
(WebCore::buildConsoleError): Use makeString instead of StringBuilder.
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::rebuildDisplayTree): Ditto.
* inspector/InspectorFrontendAPIDispatcher.cpp:
(WebCore::expressionForEvaluatingCommand): Use append instead of appendLiteral.
* inspector/InspectorOverlay.cpp:
(WebCore::InspectorOverlay::drawElementTitle): Use auto for the result of makeString.
* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyleSheet::addRule): Use append instead of appendLiteral.
* inspector/agents/InspectorApplicationCacheAgent.cpp:
(WebCore::InspectorApplicationCacheAgent::buildObjectForApplicationCacheResource):
Use makeString instead of StringBuilder.
* inspector/agents/WebConsoleAgent.cpp:
(WebCore::WebConsoleAgent::didReceiveResponse): Use auto for the result of makeString.
(WebCore::WebConsoleAgent::didFailLoading): Ditto.
* loader/MixedContentChecker.cpp:
(WebCore::logWarning): Ditto
(WebCore::MixedContentChecker::checkFormForMixedContent): Ditto
* loader/PrivateClickMeasurement.cpp:
(WebCore::makeValidURL): Added. Used for various cases below that all construct
URLs in the same way with the same kinds of checks. Use makeString here instead
of StringBuilder.
(WebCore::attributionReportURL): Call makeValidURL.
(WebCore::PrivateClickMeasurement::tokenSignatureURL const): Ditto.
(WebCore::PrivateClickMeasurement::tokenPublicKeyURL const): Ditto.
* loader/ResourceLoadStatistics.cpp:
(WebCore::appendBoolean): Use append instead of appendLiteral.
(WebCore::appendHashSet): Ditto.
(WebCore::appendNavigatorAPIOptionSet): Ditto.
(WebCore::appendScreenAPIOptionSet): Ditto.
(WebCore::ResourceLoadStatistics::toString const): Ditto.
* loader/WorkerThreadableLoader.cpp:
(WebCore::WorkerThreadableLoader::loadResourceSynchronously): Use auto for
the result of makeString.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::postMessage): Ditto.
* page/Frame.cpp:
(WebCore::createRegExpForLabels): Use append instead of appendLiteral.
Also tweak coding style a bit.
* page/FrameView.cpp:
(WebCore::FrameView::logMockScrollAnimatorMessage const): Use makeString
instead of StringBuilder.
* page/PageSerializer.cpp:
(WebCore::PageSerializer::SerializerMarkupAccumulator::appendStartTag):
Use append instead of appendLiteral.
(WebCore::PageSerializer::serializeCSSStyleSheet): Ditto.
(WebCore::PageSerializer::urlForBlankFrame): Use auto for the result of
makeString.
* page/PerformanceLoggingClient.cpp:
(WebCore::PerformanceLoggingClient::synchronousScrollingReasonsAsString):
Use makeString instead of StringBuilder.
* page/cocoa/ResourceUsageOverlayCocoa.mm:
(WebCore::ResourceUsageOverlay::platformDraw): Use auto for the result of
makeString.
* page/csp/ContentSecurityPolicy.cpp:
(WebCore::consoleMessageForViolation): Use makeString instsead of StringBuilder.
(WebCore::ContentSecurityPolicy::allowRunningOrDisplayingInsecureContent): Ditto.
(WebCore::ContentSecurityPolicy::reportInvalidDirectiveValueCharacter const):
Get rid of local variable for result of makeString.
(WebCore::ContentSecurityPolicy::reportInvalidPathCharacter const): Ditto.
(WebCore::ContentSecurityPolicy::reportInvalidSourceExpression const): Ditto.
* page/csp/ContentSecurityPolicyDirectiveList.cpp:
(WebCore::ContentSecurityPolicyDirectiveList::create): Get rid of local
variable for result of makeString.
* page/scrolling/ScrollingCoordinator.cpp:
(WebCore::ScrollingCoordinator::synchronousScrollingReasonsAsText):
Use makeString instead of StringBulder.
* platform/Decimal.cpp:
(WebCore::Decimal::toString const): Use append instead of appendLiteral.
* platform/animation/TimingFunction.cpp:
(WebCore::TimingFunction::createFromCSSText): Use makeString instead
of StringBuilder.
* platform/audio/HRTFElevation.cpp:
(WebCore::HRTFElevation::calculateKernelsForAzimuthElevation): Use auto
for the result of makeString.
* platform/glib/UserAgentGLib.cpp:
(WebCore::buildUserAgentString): Use append instead of appendLiteral.
* platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
(WebCore::InbandTextTrackPrivateAVF::processCueAttributes): Use
append instead of appendLiteral.
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::recursiveCommitChanges): Got rid of local
variable for result of makeString.
(WebCore::GraphicsLayerCA::appendToUncommittedAnimations): Use auto
for result of makeString.
* platform/graphics/ca/TileController.cpp:
(WebCore::TileController::tileRevalidationTimerFired): Update to
use OptionSet.
* platform/graphics/ca/TileGrid.cpp:
(WebCore::validationPolicyAsString): Use OptionSet.
(WebCore::TileGrid::setNeedsDisplayInRect): Use auto for iterator
and range-based for loop.
(WebCore::TileGrid::updateTileLayerProperties): Ditto.
(WebCore::TileGrid::blankPixelCount const): Ditto.
(WebCore::TileGrid::removeTiles): Use HashCountedSet.
(WebCore::TileGrid::revalidateTiles): Use OptionSet.
(WebCore::TileGrid::retainedTileBackingStoreMemory const): Use
ranged-based for loop.
(WebCore::TileGrid::drawTileMapContents const): Use range-based
for loop and use writeIntegerToBuffer instead of String::number.
(WebCore::TileGrid::platformCALayerRepaintCount const): Use
HashCountedSet.
(WebCore::TileGrid::platformCALayerIncrementRepaintCount): Ditto.
This cuts us down from 3 hash table lookups to 1.
(WebCore::TileGrid::removeUnparentedTilesNow): Removed local
variable to make code a little tighter.
* platform/graphics/ca/TileGrid.h: Use OptionSet and HashCountedSet.
Removed some type names.
* platform/graphics/ca/cocoa/PlatformCAFiltersCocoa.mm:
(WebCore::PlatformCAFilters::setFiltersOnLayer): Use auto for
reuslt of makeString.
* platform/mock/MockRealtimeVideoSource.cpp:
(WebCore::MockRealtimeVideoSource::drawText): Ditto.
* platform/mock/ScrollAnimatorMock.cpp:
(WebCore::ScrollAnimatorMock::scrollbarPrefix const): Added
helper function for use below.
(WebCore::ScrollAnimatorMock::mouseEnteredScrollbar const): Use
makeString instead of StringBuilder.
(WebCore::ScrollAnimatorMock::mouseExitedScrollbar const): Ditto.
(WebCore::ScrollAnimatorMock::mouseIsDownInScrollbar const): Ditto.
* platform/mock/ScrollAnimatorMock.h: Ditto.
* platform/network/ProxyServer.cpp:
(WebCore::appendProxyServerString): Use append instead of appendLiteral.
(WebCore::toString): Ditto.
* platform/network/ResourceResponseBase.cpp:
(WebCore::ResourceResponseBase::sanitizeSuggestedFilename): Get rid
of local variable with result of maekString in it.
* platform/playstation/UserAgentPlayStation.cpp:
(WebCore::platformForUAString): Deleted. No need for a global variable
to hold the result of something called only once.
(WebCore::platformVersionForUAString): Ditto.
(WebCore::buildUserAgentString): Deleted.
(WebCore::standardUserAgentStatic): Moved the logic from buildUserAgentString
here, using makeString instead of StringBuilder.
* platform/sql/SQLiteDatabase.cpp:
(WebCore::SQLiteDatabase::open): Use auto for result of makeString.
* platform/sql/SQLiteFileSystem.cpp:
(WebCore::SQLiteFileSystem::deleteDatabaseFile): Ditto.
* platform/text/DateTimeFormat.cpp:
(WebCore::DateTimeFormat::quoteAndAppendLiteral): Use append instead
of appendLiteral and StringView::substring instead of String::substring.
* platform/win/ClipboardUtilitiesWin.cpp:
(WebCore::replaceNewlinesWithWindowsStyleNewlines): Use append
instead of appendLiteral.
* platform/win/UserAgentWin.cpp:
(WebCore::standardUserAgent): Use makeString instead of StringBuildeer.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::name const): Ditto.
(WebCore::RenderLayer::debugDescription const): Ditto.
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::logLayerInfo): Use append instead of
appendLiteral.
* rendering/RenderTreeAsText.cpp:
(WebCore::quoteAndEscapeNonPrintables): Ditto.
(WebCore::nodePosition): Ditto.
* svg/SVGPathStringBuilder.cpp:
(WebCore::SVGPathStringBuilder::moveTo): Ditto.
(WebCore::SVGPathStringBuilder::lineTo): Ditto.
(WebCore::SVGPathStringBuilder::lineToHorizontal): Ditto.
(WebCore::SVGPathStringBuilder::lineToVertical): Ditto.
(WebCore::SVGPathStringBuilder::curveToCubic): Ditto.
(WebCore::SVGPathStringBuilder::curveToCubicSmooth): Ditto.
(WebCore::SVGPathStringBuilder::curveToQuadratic): Ditto.
(WebCore::SVGPathStringBuilder::curveToQuadraticSmooth): Ditto.
(WebCore::SVGPathStringBuilder::arcTo): Ditto.
(WebCore::SVGPathStringBuilder::closePath): Ditto.
* testing/Internals.cpp:
(WebCore::Internals::dumpMarkerRects): Ditto.
(WebCore::appendOffsets):
(WebCore::Internals::scrollSnapOffsets): Ditto.
* workers/WorkerScriptLoader.cpp:
(WebCore::WorkerScriptLoader::validateWorkerResponse): Use auto
for reuslt of makeString.
Source/WebKit:
* NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
(WebKit::ResourceLoadStatisticsDatabaseStore::ensureAndMakeDomainList): Use append
instead of appendLiteral.
(WebKit::domainsToString): Ditto.
(WebKit::buildList): Ditto.
(WebKit::ResourceLoadStatisticsDatabaseStore::findNotVeryPrevalentResources): Ditto.
(WebKit::ResourceLoadStatisticsDatabaseStore::dumpResourceLoadStatistics): Ditto.
(WebKit::appendBoolean): Ditto.
(WebKit::appendNextEntry): Ditto.
(WebKit::ResourceLoadStatisticsDatabaseStore::appendSubStatisticList const): Ditto.
(WebKit::ResourceLoadStatisticsDatabaseStore::resourceToString const): Ditto.
(WebKit::ResourceLoadStatisticsDatabaseStore::attributionToString): Ditto.
(WebKit::ResourceLoadStatisticsDatabaseStore::privateClickMeasurementToString): Ditto.
* NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
(WebKit::ResourceLoadStatisticsMemoryStore::dumpResourceLoadStatistics): Ditto.
* NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp: Ditto.
(WebKit::domainsToString): Ditto.
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::create): Moved this here from the header.
(WebKit::WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty::toString const): Ditto.
(WebKit::WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty::encode const): Ditto.
(WebKit::WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty::decode): Ditto.
(WebKit::WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty::operator== const): Ditto.
(WebKit::WebResourceLoadStatisticsStore::ThirdPartyData::toString const): Ditto.
(WebKit::WebResourceLoadStatisticsStore::ThirdPartyData::encode const): Ditto.
(WebKit::WebResourceLoadStatisticsStore::ThirdPartyData::decode): Ditto.
(WebKit::WebResourceLoadStatisticsStore::ThirdPartyData::operator< const): Ditto.
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h: Moved member
functions of the nested structures into the implementation file and fixed
the indentation of the structures to indicate the nesting.
* NetworkProcess/NetworkLoadChecker.cpp:
(WebKit::NetworkLoadChecker::continueCheckingRequest): Do not use a local
variable for the reuslt of makeString.
* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::newTestingSession): Ditto.
* NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::Cache::dumpContentsToFile): Use append instead of appendLiteral
* NetworkProcess/cache/NetworkCacheEntry.cpp:
(WebKit::NetworkCache::Entry::asJSON const): Ditto.
* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::makeVersionedDirectoryPath): Do not use a local variable for
the result of makeString.
* NetworkProcess/soup/NetworkProcessSoup.cpp:
(WebKit::buildAcceptLanguages): Use append instead of appendLiteral.
* NetworkProcess/soup/WebSocketTaskSoup.cpp:
(WebKit::WebSocketTask::acceptedExtensions const): Ditto.
* NetworkProcess/webrtc/NetworkMDNSRegister.cpp:
(WebKit::NetworkMDNSRegister::registerMDNSName): Use auto for the result of makeString.
* Shared/WebMemorySampler.cpp:
(WebKit::WebMemorySampler::writeHeaders): Ditto.
* Shared/mac/AuxiliaryProcessMac.mm:
(WebKit::initializeSandboxParameters): Do not use a local variable for the result of
makeString. Also, take advantage of the support for concatenating an NSString instead
of converting it to a WTF::String.
* Shared/mac/WebMemorySampler.mac.mm:
(WebKit::WebMemorySampler::sampleWebKit const): Use ASCIILiteral and remove explicit
conversion to String.
* UIProcess/API/glib/WebKitWebView.cpp:
(webkitWebViewRunJavaScriptCallback): Use append instead of appendLiteral.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::fileCanBeAcceptedForUpload): Use auto for result of makeString.
* WebProcess/InjectedBundle/API/glib/WebKitWebPage.cpp: Use makeString instead of
StringBuilder.
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::requestStorageSpace): Use auto for result of makeString.
* UIProcess/WebBackForwardList.cpp:
(WebKit::WebBackForwardList::loggingString): Use append instead of appendLiteral.
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::processDidFinishLaunching): Use auto for result of makeString.
(WebKit::WebProcessPool::startMemorySampler): Ditto.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::dumpHistoryItem): Use append instead of appendLiteral.
(WebKit::WebPage::getContentsAsString): Ditto.
Source/WebKitLegacy:
* WebCoreSupport/NetworkStorageSessionMap.cpp:
(NetworkStorageSessionMap::switchToNewTestingSession): Do not use local
for return value of makeString.
Source/WebKitLegacy/mac:
* WebView/WebHTMLRepresentation.mm:
(regExpForLabels): Use append instead of appendLiteral.
Also imrpove local variable names a bit.
Source/WebKitLegacy/win:
* AccessibleBase.cpp:
(AccessibleBase::get_accKeyboardShortcut): Use append instead of appnedLiteral.
* WebView.cpp: Ditto.
Source/WTF:
The optimization done by appendLiteral has minimal value and is something we
can do without. It does not cut down the number of allocations, which is the
main cost of the StringBuilder class. Getting rid of the differently named
appendLiteral improves the design of the StringBuilder class for callers.
Our goal is to get as close as possible to a single append function.
If we decide we need an optimization for literals, we can come up with a
different way that is compatible with append. For example, we could assume
that any char array is a literal and check that at compile time in
StringConcatenate; that optimization would work for both makeString and
StringBuilder. Or we could use a strategy like ASCIILiteral.
* wtf/FileSystem.cpp:
(WTF::FileSystemImpl::encodeForFileName): Streamline logic,
and use variadic append to make this more efficient.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::escapeString): Use append instead
of appendLiteral.
(WTF::JSONImpl::Value::writeJSON const): Ditto.
* wtf/Logger.h:
(WTF::Logger::log): Use auto for result of makeString.
(WTF::Logger::logVerbose): Ditto.
* wtf/MediaTime.cpp:
(WTF::MediaTime::toString const): Use makeString instead of StringBuilder.
* wtf/text/IntegerToStringConversion.h:
Made lengthOfIntegerAsString a constexpr function so we can use it to
compute the required size of arrays for conversion. Added using for both
lengthOfIntegerAsString and writeIntegerToBuffer so we can use them without
the WTF prefix as is customary for functions in WTF.
* wtf/text/StringBuilder.h:
(WTF::StringBuilder::appendLiteral): Deleted.
* wtf/text/StringConcatenate.h: Added support for appending StringImpl&,
StringImpl*, AtomStringImpl&, and AtomStringImpl*.
Tools:
* TestWebKitAPI/Tests/WTF/StringBuilder.cpp:
Use append instead of appendLiteral.
* TestWebKitAPI/Tests/WebCore/FileMonitor.cpp:
(TestWebKitAPI::createCommand): Use makeString instead of StringBuilder.
* TestWebKitAPI/Tests/WebCore/Logging.cpp:
(TestWebKitAPI::TEST_F): Made lots of fixes to code inside #if TEST_OUTPUT,
which hasn't compiled in a long time. Still not 100% there, but closer.
* TestWebKitAPI/Tests/WebCore/TextCodec.cpp:
(TestWebKitAPI::testDecode): Use append instead of appendLiteral.
* WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
(WTR::AccessibilityUIElement::helpText const): Ditto.
Canonical link: https://commits.webkit.org/238091@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277967 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-24 21:51:47 +00:00
|
|
|
auto logMessage = makeString(LogArgument<Argument>::toString(arguments)...);
|
2020-03-17 14:56:07 +00:00
|
|
|
|
|
|
|
#if RELEASE_LOG_DISABLED
|
|
|
|
WTFLogVerbose(file, line, function, &channel, "%s", logMessage.utf8().data());
|
|
|
|
#endif
|
|
|
|
#if USE(OS_LOG) && !RELEASE_LOG_DISABLED
|
|
|
|
os_log(channel.osLogChannel, "%{public}s", logMessage.utf8().data());
|
|
|
|
UNUSED_PARAM(file);
|
|
|
|
UNUSED_PARAM(line);
|
|
|
|
UNUSED_PARAM(function);
|
|
|
|
#endif
|
|
|
|
#if USE(JOURNALD) && !RELEASE_LOG_DISABLED
|
|
|
|
auto fileString = makeString("CODE_FILE=", file);
|
|
|
|
auto lineString = makeString("CODE_LINE=", line);
|
|
|
|
sd_journal_send_with_location(fileString.utf8().data(), lineString.utf8().data(), function, "WEBKIT_SUBSYSTEM=%s", channel.subsystem, "WEBKIT_CHANNEL=%s", channel.name, "MESSAGE=%s", logMessage.utf8().data(), nullptr);
|
|
|
|
#endif
|
2017-08-30 19:06:49 +00:00
|
|
|
|
2019-03-19 16:47:04 +00:00
|
|
|
if (channel.state == WTFLogChannelState::Off || level > channel.level)
|
Web Inspector: Enable WebKit logging configuration and display
https://bugs.webkit.org/show_bug.cgi?id=177027
<rdar://problem/33964767>
Reviewed by Joseph Pecoraro.
Source/JavaScriptCore:
* inspector/ConsoleMessage.cpp:
(Inspector::messageSourceValue): Inspector::Protocol::Console::ConsoleMessage ->
Inspector::Protocol::Console::ChannelSource.
* inspector/agents/JSGlobalObjectConsoleAgent.cpp:
(Inspector::JSGlobalObjectConsoleAgent::getLoggingChannels): There are no logging channels
specific to a JSContext yet, so return an empty channel array.
(Inspector::JSGlobalObjectConsoleAgent::setLoggingChannelLevel): No channels, return an error.
* inspector/agents/JSGlobalObjectConsoleAgent.h:
* inspector/protocol/Console.json: Add ChannelSource, ChannelLevel, and Channel. Add getLoggingChannels
and setLoggingChannelLevel.
* inspector/scripts/codegen/generator.py: Special case "webrtc"-> "WebRTC".
* inspector/scripts/tests/generic/expected/enum-values.json-result:
* inspector/scripts/tests/generic/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/generic/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/generic/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result:
* runtime/ConsoleTypes.h: Add Media and WebRTC.
Source/WebCore:
Test: inspector/console/webcore-logging.html
* dom/Document.cpp:
(WebCore::Document::~Document): Stop observing the logger.
(WebCore::Document::logger): Observe the logger.
(WebCore::Document::didLogMessage): Forward logging messages to the inspector.
* dom/Document.h:
* inspector/WebConsoleAgent.cpp:
(WebCore::WebConsoleAgent::getLoggingChannels): New, return the state of log runtime channels.
(WebCore::WebConsoleAgent::setLoggingChannelLevel): New, set the state of a channel.
* inspector/WebConsoleAgent.h:
* platform/Logging.cpp:
(WebCore::getLogChannel): New, get a log channel by name.
* platform/Logging.h:
Source/WebCore/PAL:
* pal/Logger.h:
(PAL::Logger::willLog const): Always return true for Always and Error so those messages are
always logged to the system.
(PAL::Logger::log): Always log Always and Error to the system, but pay strict attention to level
and channel state for logging to observers so logging only shows up in the inspector when
explicitly enabled by the user.
Source/WebInspectorUI:
* Localizations/en.lproj/localizedStrings.js: Add new localized strings.
* UserInterface/Controllers/LogManager.js:
(WI.LogManager): Initialize _loggingChannelSources, fetch _customLoggingChannels.
(WI.LogManager.supportsLogChannels): New.
(WI.LogManager.prototype.get customLoggingChannels): New.
(WI.LogManager.prototype.get logChannelSources): New.
* UserInterface/Main.html:
* UserInterface/Models/ConsoleMessage.js: Add Media and WebRTC.
* UserInterface/Models/IssueMessage.js:
(WI.IssueMessage): Add media and webrtc.
* UserInterface/Models/LoggingChannel.js: Added.
(WI.LoggingChannel):
(WI.LoggingChannel.fromPayload):
(WI.LoggingChannel.prototype.get source):
(WI.LoggingChannel.prototype.get level):
* UserInterface/Views/LogContentView.js:
(WI.LogContentView): Add new scope buttons for "Log", "Info", and "Debug". Create log channel
scope buttons once logging has started.
(WI.LogContentView.prototype.get navigationItems): Add the log message scope bar when necessary.
(WI.LogContentView.prototype._scopeFromMessageSource): New.
(WI.LogContentView.prototype._scopeFromMessageLevel): Don't group Info, Log, and Debug.
(WI.LogContentView.prototype._messageAdded): Force a UI update the first time a WebKit log
message is added.
(WI.LogContentView.prototype._messageShouldBeVisible): New, deal with message source bar buttons.
(WI.LogContentView.prototype._messageSourceBarSelectionDidChange): New.
(WI.LogContentView.prototype._filterMessageElements): Deal with message source bar buttons.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createGeneralSettingsView): Create and initialize menus
for each log channel.
Source/WebKitLegacy/mac:
* WebCoreSupport/WebChromeClient.mm:
(stringForMessageSource): Deal with Media and WebRTC message sources.
Tools:
Allow new 'dumpJSConsoleLogInStdErr' test header to redirect log console output to stderr.
* DumpRenderTree/TestOptions.h:
* DumpRenderTree/TestOptions.mm:
(TestOptions::TestOptions):
* DumpRenderTree/mac/DumpRenderTree.mm:
(runTest):
* WebKitTestRunner/TestController.cpp:
(WTR::updateTestOptionsFromTestHeader):
(WTR::TestController::runTest):
* WebKitTestRunner/TestOptions.h:
(WTR::TestOptions::hasSameInitializationOptions const):
LayoutTests:
* inspector/console/webcore-logging-expected.txt: Added.
* inspector/console/webcore-logging.html: Added.
* platform/mac/TestExpectations: Skip new test on Yosemite and ElCapitan.
* platform/win/TestExpectations: Skip new test.
Canonical link: https://commits.webkit.org/194925@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223929 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-24 22:00:53 +00:00
|
|
|
return;
|
|
|
|
|
2021-05-21 19:24:05 +00:00
|
|
|
if (!observerLock().tryLock())
|
2019-08-06 03:45:40 +00:00
|
|
|
return;
|
|
|
|
|
2021-05-23 19:55:32 +00:00
|
|
|
Locker locker { AdoptLock, observerLock() };
|
2017-08-30 19:06:49 +00:00
|
|
|
for (Observer& observer : observers())
|
2017-12-12 00:41:54 +00:00
|
|
|
observer.didLogMessage(channel, level, { ConsoleLogValue<Argument>::toValue(arguments)... });
|
2017-08-30 19:06:49 +00:00
|
|
|
}
|
|
|
|
|
2021-05-21 19:24:05 +00:00
|
|
|
WTF_EXPORT_PRIVATE static Vector<std::reference_wrapper<Observer>>& observers() WTF_REQUIRES_LOCK(observerLock());
|
2017-08-23 20:01:59 +00:00
|
|
|
|
2021-05-24 18:29:01 +00:00
|
|
|
static Lock& observerLock() WTF_RETURNS_LOCK(loggerObserverLock)
|
2019-08-06 03:45:40 +00:00
|
|
|
{
|
2020-08-15 18:40:50 +00:00
|
|
|
return loggerObserverLock;
|
2019-08-06 03:45:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-08-23 20:01:59 +00:00
|
|
|
bool m_enabled { true };
|
2019-03-12 19:07:04 +00:00
|
|
|
const void* m_owner;
|
2017-08-23 20:01:59 +00:00
|
|
|
};
|
|
|
|
|
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
|
|
|
template<> struct LogArgument<Logger::LogSiteIdentifier> {
|
|
|
|
static String toString(const Logger::LogSiteIdentifier& value) { return value.toString(); }
|
2017-08-29 02:59:18 +00:00
|
|
|
};
|
2019-03-13 20:18:08 +00:00
|
|
|
template<> struct LogArgument<const void*> {
|
2020-02-12 01:59:28 +00:00
|
|
|
WTF_EXPORT_PRIVATE static String toString(const void*);
|
2019-03-13 20:18:08 +00:00
|
|
|
};
|
2017-08-29 02:59:18 +00:00
|
|
|
|
2017-12-08 20:33:53 +00:00
|
|
|
} // namespace WTF
|
|
|
|
|
|
|
|
using WTF::Logger;
|
2017-12-12 00:41:54 +00:00
|
|
|
using WTF::JSONLogValue;
|