Modified: trunk/Source/WebCore/ChangeLog (288858 => 288859)
--- trunk/Source/WebCore/ChangeLog 2022-02-01 00:31:48 UTC (rev 288858)
+++ trunk/Source/WebCore/ChangeLog 2022-02-01 01:10:48 UTC (rev 288859)
@@ -1,3 +1,27 @@
+2022-01-31 Andres Gonzalez <[email protected]>
+
+ Add to AXLogger the ability to log only from the specified thread.
+ https://bugs.webkit.org/show_bug.cgi?id=235843
+ <rdar://problem/88211205>
+
+ Reviewed by Chris Fleizach.
+
+ No change in functionality, debugging code.
+
+ Determine whether to log messages for the invoking thread based on the
+ value of a static hardcoded variable. It makes figuring out the flow of
+ method calls and messages when you can log only from the main thread,
+ off the main thread, or the combination.
+
+ * accessibility/AXLogger.cpp:
+ (WebCore::shouldLog):
+ (WebCore::AXLogger::AXLogger):
+ (WebCore::AXLogger::~AXLogger):
+ (WebCore::AXLogger::log):
+ (WebCore::AXLogger::add):
+ (WebCore::operator<<):
+ * accessibility/AXLogger.h:
+
2022-01-31 Ryosuke Niwa <[email protected]>
Delete runtime flag for subresource integrity
Modified: trunk/Source/WebCore/accessibility/AXLogger.cpp (288858 => 288859)
--- trunk/Source/WebCore/accessibility/AXLogger.cpp 2022-02-01 00:31:48 UTC (rev 288858)
+++ trunk/Source/WebCore/accessibility/AXLogger.cpp 2022-02-01 01:10:48 UTC (rev 288859)
@@ -38,10 +38,20 @@
#include "FrameView.h"
#include "LogInitialization.h"
#include "Logging.h"
+#include <wtf/OptionSet.h>
#include <wtf/text/TextStream.h>
namespace WebCore {
+static bool shouldLog()
+{
+ // Modify the initializer list below to choose what thread you want to log messages from.
+ static OptionSet<AXLoggingOptions> loggingOptions { AXLoggingOptions::MainThread, AXLoggingOptions::OffMainThread };
+
+ return (isMainThread() && loggingOptions & AXLoggingOptions::MainThread)
+ || (!isMainThread() && loggingOptions & AXLoggingOptions::OffMainThread);
+}
+
AXLogger::AXLogger(const String& methodName)
: m_methodName(methodName)
{
@@ -48,73 +58,86 @@
if (auto* channel = getLogChannel("Accessibility"))
channel->level = WTFLogLevel::Debug;
- if (!m_methodName.isEmpty())
- LOG_WITH_STREAM(Accessibility, stream << m_methodName << " {");
+ if (shouldLog()) {
+ if (!m_methodName.isEmpty())
+ LOG_WITH_STREAM(Accessibility, stream << m_methodName << " {");
+ }
}
AXLogger::~AXLogger()
{
- if (!m_methodName.isEmpty())
- LOG_WITH_STREAM(Accessibility, stream << "} " << m_methodName);
+ if (shouldLog()) {
+ if (!m_methodName.isEmpty())
+ LOG_WITH_STREAM(Accessibility, stream << "} " << m_methodName);
+ }
}
void AXLogger::log(const String& message)
{
- LOG(Accessibility, "%s", message.utf8().data());
+ if (shouldLog())
+ LOG(Accessibility, "%s", message.utf8().data());
}
void AXLogger::log(RefPtr<AXCoreObject> object)
{
- TextStream stream(TextStream::LineMode::MultipleLine);
+ if (shouldLog()) {
+ TextStream stream(TextStream::LineMode::MultipleLine);
- if (object)
- stream << *object;
- else
- stream << "null";
+ if (object)
+ stream << *object;
+ else
+ stream << "null";
- LOG(Accessibility, "%s", stream.release().utf8().data());
+ LOG(Accessibility, "%s", stream.release().utf8().data());
+ }
}
void AXLogger::log(const Vector<RefPtr<AXCoreObject>>& objects)
{
- TextStream stream(TextStream::LineMode::MultipleLine);
+ if (shouldLog()) {
+ TextStream stream(TextStream::LineMode::MultipleLine);
- stream << "[";
- for (auto object : objects) {
- if (object)
- stream << *object;
- else
- stream << "null";
+ stream << "[";
+ for (auto object : objects) {
+ if (object)
+ stream << *object;
+ else
+ stream << "null";
+ }
+ stream << "]";
+
+ LOG(Accessibility, "%s", stream.release().utf8().data());
}
- stream << "]";
-
- LOG(Accessibility, "%s", stream.release().utf8().data());
}
void AXLogger::add(TextStream& stream, const RefPtr<AXCoreObject>& object, bool recursive)
{
- if (!object)
- return;
+ if (shouldLog()) {
+ if (!object)
+ return;
- stream.increaseIndent();
- stream << *object;
+ stream.increaseIndent();
+ stream << *object;
- if (recursive) {
- for (auto& child : object->children(false))
- add(stream, child, true);
+ if (recursive) {
+ for (auto& child : object->children(false))
+ add(stream, child, true);
+ }
+ stream.decreaseIndent();
}
- stream.decreaseIndent();
}
void AXLogger::log(const std::pair<RefPtr<AXCoreObject>, AXObjectCache::AXNotification>& notification)
{
- TextStream stream(TextStream::LineMode::MultipleLine);
- stream << "Notification " << notification.second << " for object ";
- if (notification.first)
- stream << *notification.first;
- else
- stream << "null";
- LOG(Accessibility, "%s", stream.release().utf8().data());
+ if (shouldLog()) {
+ TextStream stream(TextStream::LineMode::MultipleLine);
+ stream << "Notification " << notification.second << " for object ";
+ if (notification.first)
+ stream << *notification.first;
+ else
+ stream << "null";
+ LOG(Accessibility, "%s", stream.release().utf8().data());
+ }
}
void AXLogger::log(const AccessibilitySearchCriteria& criteria)
@@ -134,17 +157,21 @@
#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
void AXLogger::log(AXIsolatedTree& tree)
{
- TextStream stream(TextStream::LineMode::MultipleLine);
- stream << tree;
- LOG(Accessibility, "%s", stream.release().utf8().data());
+ if (shouldLog()) {
+ TextStream stream(TextStream::LineMode::MultipleLine);
+ stream << tree;
+ LOG(Accessibility, "%s", stream.release().utf8().data());
+ }
}
#endif
void AXLogger::log(AXObjectCache& axObjectCache)
{
- TextStream stream(TextStream::LineMode::MultipleLine);
- stream << axObjectCache;
- LOG(Accessibility, "%s", stream.release().utf8().data());
+ if (shouldLog()) {
+ TextStream stream(TextStream::LineMode::MultipleLine);
+ stream << axObjectCache;
+ LOG(Accessibility, "%s", stream.release().utf8().data());
+ }
}
TextStream& operator<<(TextStream& stream, AccessibilityRole role)
@@ -500,9 +527,6 @@
stream.dumpProperty("wrapper", object.wrapper());
stream.dumpProperty("parentObject", parent ? parent->objectID() : AXID());
-#if PLATFORM(COCOA)
- stream.dumpProperty("remoteParentObject", object.remoteParentObject());
-#endif
return stream;
}
Modified: trunk/Source/WebCore/accessibility/AXLogger.h (288858 => 288859)
--- trunk/Source/WebCore/accessibility/AXLogger.h 2022-02-01 00:31:48 UTC (rev 288858)
+++ trunk/Source/WebCore/accessibility/AXLogger.h 2022-02-01 01:10:48 UTC (rev 288859)
@@ -32,6 +32,11 @@
namespace WebCore {
+enum class AXLoggingOptions : uint8_t {
+ MainThread = 1 << 0, // Logs messages on the main thread.
+ OffMainThread = 1 << 1, // Logs messages off the main thread.
+};
+
class AXLogger {
public:
AXLogger() = default;