Title: [250939] trunk/Source/WebCore
Revision
250939
Author
[email protected]
Date
2019-10-09 15:48:47 -0700 (Wed, 09 Oct 2019)

Log Message

Clean up WheelEventTestTriggers logging
https://bugs.webkit.org/show_bug.cgi?id=202764

Reviewed by Tim Horton.

Make DeferTestTriggerReason a bit set, and use OptionSet<> rather than StdSet. Make
DeferTestTriggerReason and ScrollableAreaReasonMap loggable, and simplify the logging.

* page/WheelEventTestTrigger.cpp:
(WebCore::WheelEventTestTrigger::clearAllTestDeferrals):
(WebCore::WheelEventTestTrigger::deferTestsForReason):
(WebCore::WheelEventTestTrigger::removeTestDeferralForReason):
(WebCore::WheelEventTestTrigger::triggerTestTimerFired):
(WebCore::operator<<):
(WebCore::dumpState): Deleted.
* page/WheelEventTestTrigger.h:
* page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::frameViewLayoutUpdated):
(WebCore::AsyncScrollingCoordinator::deferTestsForReason const):
(WebCore::AsyncScrollingCoordinator::removeTestDeferralForReason const):
* page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm:
(WebCore::ScrollingTreeScrollingNodeDelegateMac::deferTestsForReason const):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::removeTestDeferralForReason const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (250938 => 250939)


--- trunk/Source/WebCore/ChangeLog	2019-10-09 22:46:39 UTC (rev 250938)
+++ trunk/Source/WebCore/ChangeLog	2019-10-09 22:48:47 UTC (rev 250939)
@@ -640,6 +640,32 @@
         * dom/ActiveDOMObject.h:
         * dom/Document.h:
 
+2019-10-09  Simon Fraser  <[email protected]>
+
+        Clean up WheelEventTestTriggers logging
+        https://bugs.webkit.org/show_bug.cgi?id=202764
+
+        Reviewed by Tim Horton.
+
+        Make DeferTestTriggerReason a bit set, and use OptionSet<> rather than StdSet. Make
+        DeferTestTriggerReason and ScrollableAreaReasonMap loggable, and simplify the logging.
+
+        * page/WheelEventTestTrigger.cpp:
+        (WebCore::WheelEventTestTrigger::clearAllTestDeferrals):
+        (WebCore::WheelEventTestTrigger::deferTestsForReason):
+        (WebCore::WheelEventTestTrigger::removeTestDeferralForReason):
+        (WebCore::WheelEventTestTrigger::triggerTestTimerFired):
+        (WebCore::operator<<):
+        (WebCore::dumpState): Deleted.
+        * page/WheelEventTestTrigger.h:
+        * page/scrolling/AsyncScrollingCoordinator.cpp:
+        (WebCore::AsyncScrollingCoordinator::frameViewLayoutUpdated):
+        (WebCore::AsyncScrollingCoordinator::deferTestsForReason const):
+        (WebCore::AsyncScrollingCoordinator::removeTestDeferralForReason const):
+        * page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm:
+        (WebCore::ScrollingTreeScrollingNodeDelegateMac::deferTestsForReason const):
+        (WebCore::ScrollingTreeScrollingNodeDelegateMac::removeTestDeferralForReason const):
+
 2019-10-08  Ross Kirsling  <[email protected]>
 
         Unreviewed. Restabilize non-unified build.

Modified: trunk/Source/WebCore/page/WheelEventTestTrigger.cpp (250938 => 250939)


--- trunk/Source/WebCore/page/WheelEventTestTrigger.cpp	2019-10-09 22:46:39 UTC (rev 250938)
+++ trunk/Source/WebCore/page/WheelEventTestTrigger.cpp	2019-10-09 22:48:47 UTC (rev 250939)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Apple Inc.  All rights reserved.
+ * Copyright (C) 2015-2019 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -30,6 +30,7 @@
 #include "WheelEventTestTrigger.h"
 
 #include "Logging.h"
+#include <wtf/text/TextStream.h>
 
 #if !LOG_DISABLED
 #include <wtf/text/CString.h>
@@ -49,7 +50,7 @@
     m_deferTestTriggerReasons.clear();
     m_testNotificationCallback = nullptr;
     m_testTriggerTimer.stop();
-    LOG(WheelEventTestTriggers, "      (=) WheelEventTestTrigger::clearAllTestDeferrals: cleared all test state.");
+    LOG_WITH_STREAM(WheelEventTestTriggers, stream << "      (=) WheelEventTestTrigger::clearAllTestDeferrals: cleared all test state.");
 }
 
 void WheelEventTestTrigger::setTestCallbackAndStartNotificationTimer(WTF::Function<void()>&& functionCallback)
@@ -66,12 +67,11 @@
 void WheelEventTestTrigger::deferTestsForReason(ScrollableAreaIdentifier identifier, DeferTestTriggerReason reason)
 {
     std::lock_guard<Lock> lock(m_testTriggerMutex);
-    auto it = m_deferTestTriggerReasons.find(identifier);
-    if (it == m_deferTestTriggerReasons.end())
-        it = m_deferTestTriggerReasons.add(identifier, DeferTestTriggerReasonSet()).iterator;
+    m_deferTestTriggerReasons.ensure(identifier, [] {
+        return OptionSet<DeferTestTriggerReason>();
+    }).iterator->value.add(reason);
     
-    LOG(WheelEventTestTriggers, "      (=) WheelEventTestTrigger::deferTestsForReason: id=%p, reason=%d", identifier, reason);
-    it->value.insert(reason);
+    LOG_WITH_STREAM(WheelEventTestTriggers, stream << "      (=) WheelEventTestTrigger::deferTestsForReason: id=" << identifier << ", reason=" << reason);
 }
 
 void WheelEventTestTrigger::removeTestDeferralForReason(ScrollableAreaIdentifier identifier, DeferTestTriggerReason reason)
@@ -81,31 +81,12 @@
     if (it == m_deferTestTriggerReasons.end())
         return;
 
-    LOG(WheelEventTestTriggers, "      (=) WheelEventTestTrigger::removeTestDeferralForReason: id=%p, reason=%d", identifier, reason);
-    it->value.erase(reason);
+    LOG_WITH_STREAM(WheelEventTestTriggers, stream << "      (=) WheelEventTestTrigger::removeTestDeferralForReason: id=" << identifier << ", reason=" << reason);
+    it->value.remove(reason);
     
-    if (it->value.empty())
+    if (it->value.isEmpty())
         m_deferTestTriggerReasons.remove(it);
 }
-
-#if !LOG_DISABLED
-
-static void dumpState(WTF::HashMap<WheelEventTestTrigger::ScrollableAreaIdentifier, WheelEventTestTrigger::DeferTestTriggerReasonSet> reasons)
-{
-    LOG(WheelEventTestTriggers, "   WheelEventTestTrigger::dumpState:");
-    for (const auto& scrollRegion : reasons) {
-        LOG(WheelEventTestTriggers, "   For scroll region %p", scrollRegion.key);
-        StringBuilder reasons;
-        for (const auto& reason : scrollRegion.value) {
-            if (!reasons.isEmpty())
-                reasons.appendLiteral(", ");
-            reasons.appendNumber(static_cast<unsigned>(reason));
-        }
-        LOG(WheelEventTestTriggers, "     Reasons: %s", reasons.toString().utf8().data());
-    }
-}
-
-#endif
     
 void WheelEventTestTrigger::triggerTestTimerFired()
 {
@@ -114,10 +95,7 @@
     {
         std::lock_guard<Lock> lock(m_testTriggerMutex);
         if (!m_deferTestTriggerReasons.isEmpty()) {
-#if !LOG_DISABLED
-            if (isLogChannelEnabled("WheelEventTestTriggers"))
-                dumpState(m_deferTestTriggerReasons);
-#endif
+            LOG_WITH_STREAM(WheelEventTestTriggers, stream << "  WheelEventTestTrigger::triggerTestTimerFired - scrolling still active, reasons " << m_deferTestTriggerReasons);
             return;
         }
 
@@ -126,9 +104,28 @@
 
     m_testTriggerTimer.stop();
 
-    LOG(WheelEventTestTriggers, "  WheelEventTestTrigger::triggerTestTimerFired: FIRING TEST");
+    LOG_WITH_STREAM(WheelEventTestTriggers, stream << "  WheelEventTestTrigger::triggerTestTimerFired: scrolling is idle, FIRING TEST");
     if (functionCallback)
         functionCallback();
 }
 
+TextStream& operator<<(TextStream& ts, WheelEventTestTrigger::DeferTestTriggerReason reason)
+{
+    switch (reason) {
+    case WheelEventTestTrigger::RubberbandInProgress: ts << "rubberbanding"; break;
+    case WheelEventTestTrigger::ScrollSnapInProgress: ts << "scroll-snapping"; break;
+    case WheelEventTestTrigger::ScrollingThreadSyncNeeded: ts << "scrolling thread sync needed"; break;
+    case WheelEventTestTrigger::ContentScrollInProgress: ts << "content scrolling"; break;
+    }
+    return ts;
 }
+
+TextStream& operator<<(TextStream& ts, const WheelEventTestTrigger::ScrollableAreaReasonMap& reasonMap)
+{
+    for (const auto& regionReasonsPair : reasonMap)
+        ts << "   scroll region: " << regionReasonsPair.key << " reasons: " << regionReasonsPair.value;
+
+    return ts;
+}
+
+} // namespace WebCore

Modified: trunk/Source/WebCore/page/WheelEventTestTrigger.h (250938 => 250939)


--- trunk/Source/WebCore/page/WheelEventTestTrigger.h	2019-10-09 22:46:39 UTC (rev 250938)
+++ trunk/Source/WebCore/page/WheelEventTestTrigger.h	2019-10-09 22:48:47 UTC (rev 250939)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Apple Inc.  All rights reserved.
+ * Copyright (C) 2015-2019 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -47,22 +47,29 @@
     WEBCORE_EXPORT void clearAllTestDeferrals();
     
     enum DeferTestTriggerReason {
-        RubberbandInProgress,
-        ScrollSnapInProgress,
-        ScrollingThreadSyncNeeded,
-        ContentScrollInProgress
+        RubberbandInProgress        = 1 << 0,
+        ScrollSnapInProgress        = 1 << 1,
+        ScrollingThreadSyncNeeded   = 1 << 2,
+        ContentScrollInProgress     = 1 << 3
     };
-    using DeferTestTriggerReasonSet = StdSet<DeferTestTriggerReason>;
     typedef const void* ScrollableAreaIdentifier;
-    void WEBCORE_EXPORT deferTestsForReason(ScrollableAreaIdentifier, DeferTestTriggerReason);
-    void WEBCORE_EXPORT removeTestDeferralForReason(ScrollableAreaIdentifier, DeferTestTriggerReason);
+
+    WEBCORE_EXPORT void deferTestsForReason(ScrollableAreaIdentifier, DeferTestTriggerReason);
+    WEBCORE_EXPORT void removeTestDeferralForReason(ScrollableAreaIdentifier, DeferTestTriggerReason);
+    
     void triggerTestTimerFired();
 
+    using ScrollableAreaReasonMap = WTF::HashMap<ScrollableAreaIdentifier, OptionSet<DeferTestTriggerReason>>;
+
 private:
     WTF::Function<void()> m_testNotificationCallback;
     RunLoop::Timer<WheelEventTestTrigger> m_testTriggerTimer;
     mutable Lock m_testTriggerMutex;
-    WTF::HashMap<ScrollableAreaIdentifier, DeferTestTriggerReasonSet> m_deferTestTriggerReasons;
+    
+    ScrollableAreaReasonMap m_deferTestTriggerReasons;
 };
 
+WTF::TextStream& operator<<(WTF::TextStream&, WheelEventTestTrigger::DeferTestTriggerReason);
+WTF::TextStream& operator<<(WTF::TextStream&, const WheelEventTestTrigger::ScrollableAreaReasonMap&);
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp (250938 => 250939)


--- trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp	2019-10-09 22:46:39 UTC (rev 250938)
+++ trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp	2019-10-09 22:48:47 UTC (rev 250939)
@@ -138,7 +138,7 @@
 
     auto* page = frameView.frame().page();
     if (page && page->expectsWheelEventTriggers()) {
-        LOG(WheelEventTestTriggers, "    AsyncScrollingCoordinator::frameViewLayoutUpdated: Expects wheel event test trigger=%d", page->expectsWheelEventTriggers());
+        LOG_WITH_STREAM(WheelEventTestTriggers, stream << "    AsyncScrollingCoordinator::frameViewLayoutUpdated: Expects wheel event test trigger: " << page->expectsWheelEventTriggers());
 
         auto* node = m_scrollingStateTree->stateNodeForID(frameView.scrollingNodeID());
         if (!is<ScrollingStateFrameScrollingNode>(node))
@@ -861,7 +861,7 @@
         return;
 
     if (const auto& trigger = m_page->testTrigger()) {
-        LOG(WheelEventTestTriggers, "    (!) AsyncScrollingCoordinator::deferTestsForReason: Deferring %p for reason %d.", identifier, reason);
+        LOG_WITH_STREAM(WheelEventTestTriggers, stream << "    (!) AsyncScrollingCoordinator::deferTestsForReason: Deferring " << identifier << " for reason " << reason);
         trigger->deferTestsForReason(identifier, reason);
     }
 }
@@ -873,7 +873,7 @@
         return;
 
     if (const auto& trigger = m_page->testTrigger()) {
-        LOG(WheelEventTestTriggers, "    (!) AsyncScrollingCoordinator::removeTestDeferralForReason: Deferring %p for reason %d.", identifier, reason);
+        LOG_WITH_STREAM(WheelEventTestTriggers, stream << "    (!) AsyncScrollingCoordinator::removeTestDeferralForReason: Deferring " << identifier << " for reason " << reason);
         trigger->removeTestDeferralForReason(identifier, reason);
     }
 }

Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm (250938 => 250939)


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm	2019-10-09 22:46:39 UTC (rev 250938)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm	2019-10-09 22:48:47 UTC (rev 250939)
@@ -312,7 +312,7 @@
     if (!scrollingNode().expectsWheelEventTestTrigger())
         return;
 
-    LOG(WheelEventTestTriggers, "  ScrollingTreeScrollingNodeDelegateMac::deferTestsForReason: STARTING deferral for %p because of %d", identifier, reason);
+    LOG_WITH_STREAM(WheelEventTestTriggers, stream << isMainThread() << "  ScrollingTreeScrollingNodeDelegateMac::deferTestsForReason: STARTING deferral for " << identifier << " because of " << reason);
     scrollingTree().deferTestsForReason(identifier, reason);
 }
     
@@ -321,7 +321,7 @@
     if (!scrollingNode().expectsWheelEventTestTrigger())
         return;
     
-    LOG(WheelEventTestTriggers, "   ScrollingTreeScrollingNodeDelegateMac::deferTestsForReason: ENDING deferral for %p because of %d", identifier, reason);
+    LOG_WITH_STREAM(WheelEventTestTriggers, stream << isMainThread() << "  ScrollingTreeScrollingNodeDelegateMac::deferTestsForReason: ENDING deferral for " << identifier << " because of " << reason);
     scrollingTree().removeTestDeferralForReason(identifier, reason);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to