Make ScrollableArea TextStream-loggable
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Apr 2020 21:59:37 +0000 (21:59 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Apr 2020 21:59:37 +0000 (21:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=210042

Reviewed by Darin Adler.

ScrollableArea is a pure virtual base class, so has to dump via a virtual function,
so add debugDescription() and implement it in derived classes.

Make the common pattern be that operator<<(TextStream&, ...) calls debugDescription.

Source/WebCore:

* page/Frame.cpp:
(WebCore::Frame::debugDescription const):
(WebCore::operator<<):
* page/Frame.h:
* page/FrameView.cpp:
(WebCore::FrameView::debugDescription const):
(WebCore::operator<<):
* page/FrameView.h:
* platform/ScrollView.cpp:
(WebCore::ScrollView::debugDescription const):
* platform/ScrollView.h:
* platform/ScrollableArea.cpp:
(WebCore::operator<<):
* platform/ScrollableArea.h:
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::debugDescription const):
(WebCore::RenderLayer::calculateClipRects const):
* rendering/RenderLayer.h:
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::updateCompositingLayers):
* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::debugDescription const):
* rendering/RenderListBox.h:

Source/WebKit:

* UIProcess/win/WebPopupMenuProxyWin.cpp:
(WebKit::WebPopupMenuProxyWin::debugDescription const):
* UIProcess/win/WebPopupMenuProxyWin.h:
* WebProcess/Plugins/PDF/PDFPlugin.h:
* WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::debugDescription const):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259597 268f45cc-cd09-0410-ab3c-d52691b4dbfc

21 files changed:
Source/WebCore/ChangeLog
Source/WebCore/page/Frame.cpp
Source/WebCore/page/Frame.h
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/FrameView.h
Source/WebCore/platform/ScrollView.cpp
Source/WebCore/platform/ScrollView.h
Source/WebCore/platform/ScrollableArea.cpp
Source/WebCore/platform/ScrollableArea.h
Source/WebCore/platform/win/PopupMenuWin.cpp
Source/WebCore/platform/win/PopupMenuWin.h
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayer.h
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderListBox.cpp
Source/WebCore/rendering/RenderListBox.h
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/win/WebPopupMenuProxyWin.cpp
Source/WebKit/UIProcess/win/WebPopupMenuProxyWin.h
Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.h
Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm

index 7bbda67..f31f283 100644 (file)
@@ -1,3 +1,39 @@
+2020-04-06  Simon Fraser  <simon.fraser@apple.com>
+
+        Make ScrollableArea TextStream-loggable
+        https://bugs.webkit.org/show_bug.cgi?id=210042
+
+        Reviewed by Darin Adler.
+
+        ScrollableArea is a pure virtual base class, so has to dump via a virtual function,
+        so add debugDescription() and implement it in derived classes.
+
+        Make the common pattern be that operator<<(TextStream&, ...) calls debugDescription.
+
+        * page/Frame.cpp:
+        (WebCore::Frame::debugDescription const):
+        (WebCore::operator<<):
+        * page/Frame.h:
+        * page/FrameView.cpp:
+        (WebCore::FrameView::debugDescription const):
+        (WebCore::operator<<):
+        * page/FrameView.h:
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::debugDescription const):
+        * platform/ScrollView.h:
+        * platform/ScrollableArea.cpp:
+        (WebCore::operator<<):
+        * platform/ScrollableArea.h:
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::debugDescription const):
+        (WebCore::RenderLayer::calculateClipRects const):
+        * rendering/RenderLayer.h:
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::updateCompositingLayers):
+        * rendering/RenderListBox.cpp:
+        (WebCore::RenderListBox::debugDescription const):
+        * rendering/RenderListBox.h:
+
 2020-04-06  Jack Lee  <shihchieh_lee@apple.com>
 
         Nullptr crash in CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary with draggable text
index 051fdb3..e6271d7 100644 (file)
 #include "npruntime_impl.h"
 #include "runtime_root.h"
 #include <JavaScriptCore/RegularExpression.h>
+#include <wtf/HexNumber.h>
 #include <wtf/RefCountedLeakCounter.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/text/StringBuilder.h>
@@ -1058,9 +1059,23 @@ void Frame::selfOnlyDeref()
     deref();
 }
 
+String Frame::debugDescription() const
+{
+    StringBuilder builder;
+
+    builder.append("Frame 0x"_s, hex(reinterpret_cast<uintptr_t>(this), Lowercase));
+    if (isMainFrame())
+        builder.append(" (main frame)"_s);
+
+    if (auto document = this->document())
+        builder.append(' ', document->documentURI());
+    
+    return builder.toString();
+}
+
 TextStream& operator<<(TextStream& ts, const Frame& frame)
 {
-    ts << "Frame " << &frame << " view " << frame.view() << " (is main frame " << frame.isMainFrame() << ") " << (frame.document() ? frame.document()->documentURI() : emptyString());
+    ts << frame.debugDescription();
     return ts;
 }
 
index 2520e03..eb97a61 100644 (file)
@@ -190,6 +190,8 @@ public:
 
     bool requestDOMPasteAccess();
 
+    String debugDescription() const;
+
 // ======== All public functions below this point are candidates to move out of Frame into another class. ========
 
     WEBCORE_EXPORT void injectUserScripts(UserScriptInjectionTime);
index 01776fc..f59baa8 100644 (file)
 #include "VelocityData.h"
 #include "VisualViewport.h"
 #include "WheelEventTestMonitor.h"
-#include <wtf/text/TextStream.h>
-
+#include <wtf/HexNumber.h>
 #include <wtf/IsoMallocInlines.h>
 #include <wtf/MemoryPressureHandler.h>
 #include <wtf/Ref.h>
 #include <wtf/SetForScope.h>
 #include <wtf/SystemTracing.h>
+#include <wtf/text/TextStream.h>
 
 #if USE(COORDINATED_GRAPHICS)
 #include "TiledBackingStore.h"
@@ -1423,11 +1423,15 @@ void FrameView::logMockScrollAnimatorMessage(const String& message) const
     StringBuilder builder;
     if (frame().isMainFrame())
         builder.appendLiteral("Main");
-    builder.appendLiteral("FrameView: ");
-    builder.append(message);
+    builder.append("FrameView: ", message);
     document->addConsoleMessage(MessageSource::Other, MessageLevel::Debug, builder.toString());
 }
 
+String FrameView::debugDescription() const
+{
+    return makeString("FrameView 0x", hex(reinterpret_cast<uintptr_t>(this), Lowercase), ' ', frame().debugDescription());
+}
+
 bool FrameView::styleHidesScrollbarWithOrientation(ScrollbarOrientation orientation) const
 {
     auto element = rootElementForCustomScrollbarPartStyle(PseudoId::Scrollbar);
@@ -5458,7 +5462,7 @@ bool FrameView::shouldPlaceBlockDirectionScrollbarOnLeft() const
 
 TextStream& operator<<(TextStream& ts, const FrameView& view)
 {
-    ts << "FrameView " << &view << " frame " << view.frame();
+    ts << view.debugDescription();
     return ts;
 }
 
index bb95785..0aecde8 100644 (file)
@@ -664,6 +664,8 @@ public:
 
     bool inUpdateEmbeddedObjects() const { return m_inUpdateEmbeddedObjects; }
 
+    String debugDescription() const final;
+
 protected:
     bool scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect) final;
     void scrollContentsSlowPath(const IntRect& updateRect) final;
index 2fd15f7..3e216e1 100644 (file)
@@ -35,6 +35,7 @@
 #include "ScrollAnimator.h"
 #include "Scrollbar.h"
 #include "ScrollbarTheme.h"
+#include <wtf/HexNumber.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/text/TextStream.h>
 
@@ -1532,6 +1533,11 @@ IntPoint ScrollView::locationOfContents() const
     return result;
 }
 
+String ScrollView::debugDescription() const
+{
+    return makeString("ScrollView 0x", hex(reinterpret_cast<uintptr_t>(this), Lowercase));
+}
+
 #if !PLATFORM(COCOA)
 
 void ScrollView::platformAddChild(Widget*)
@@ -1542,10 +1548,6 @@ void ScrollView::platformRemoveChild(Widget*)
 {
 }
 
-#endif
-
-#if !PLATFORM(COCOA)
-
 void ScrollView::platformSetScrollbarsSuppressed(bool)
 {
 }
@@ -1558,10 +1560,6 @@ void ScrollView::platformSetScrollbarOverlayStyle(ScrollbarOverlayStyle)
 {
 }
 
-#endif
-
-#if !PLATFORM(COCOA)
-
 void ScrollView::platformSetScrollbarModes()
 {
 }
@@ -1652,6 +1650,6 @@ bool ScrollView::platformIsOffscreen() const
     return false;
 }
 
-#endif
+#endif // !PLATFORM(COCOA)
 
 }
index b64aa3b..14ad384 100644 (file)
@@ -449,6 +449,7 @@ private:
     bool setHasScrollbarInternal(RefPtr<Scrollbar>&, ScrollbarOrientation, bool hasBar, bool* contentSizeAffected);
 
     bool isScrollView() const final { return true; }
+    String debugDescription() const override;
 
     void init();
     void destroy();
index 5bda857..cdad360 100644 (file)
@@ -769,4 +769,10 @@ void ScrollableArea::computeScrollbarValueAndOverhang(float currentPosition, flo
     }
 }
 
+TextStream& operator<<(TextStream& ts, const ScrollableArea& scrollableArea)
+{
+    ts << scrollableArea.debugDescription();
+    return ts;
+}
+
 } // namespace WebCore
index d203aeb..45fac02 100644 (file)
 #include <wtf/Forward.h>
 #include <wtf/WeakPtr.h>
 
+namespace WTF {
+class TextStream;
+}
+
 namespace WebCore {
 
 class FloatPoint;
@@ -345,6 +349,8 @@ public:
     virtual void logMockScrollAnimatorMessage(const String&) const { };
 
     virtual bool shouldPlaceBlockDirectionScrollbarOnLeft() const = 0;
+    
+    virtual String debugDescription() const = 0;
 
 protected:
     WEBCORE_EXPORT ScrollableArea();
@@ -414,4 +420,6 @@ private:
     unsigned m_currentScrollBehaviorStatus : 1;
 };
 
+WTF::TextStream& operator<<(WTF::TextStream&, const ScrollableArea&);
+
 } // namespace WebCore
index 7c7bfdf..31d9354 100644 (file)
@@ -49,7 +49,9 @@
 #include "ScrollbarThemeWin.h"
 #include "TextRun.h"
 #include "WebCoreInstanceHandle.h"
+#include <wtf/HexNumber.h>
 #include <wtf/WindowsExtras.h>
+#include <wtf/text/StringBuilder.h>
 
 #include <windows.h>
 #include <windowsx.h>
@@ -1082,6 +1084,11 @@ LRESULT PopupMenuWin::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
     return lResult;
 }
 
+String PopupMenuWin::debugDescription() const
+{
+    return makeString("PopupMenuWin 0x", hex(reinterpret_cast<uintptr_t>(this), Lowercase));
+}
+
 AccessiblePopupMenu::AccessiblePopupMenu(const PopupMenuWin& popupMenu)
     : m_popupMenu(popupMenu)
 {
index 3529b8f..7d57daa 100644 (file)
@@ -49,6 +49,8 @@ public:
 
     static LPCWSTR popupClassName();
 
+    String debugDescription() const final;
+
 private:
     PopupMenuClient* client() const { return m_popupClient; }
 
index 821c4ae..2e90f0d 100644 (file)
 #include "TranslateTransformOperation.h"
 #include "WheelEventTestMonitor.h"
 #include <stdio.h>
+#include <wtf/HexNumber.h>
 #include <wtf/MonotonicTime.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/text/CString.h>
@@ -3625,6 +3626,36 @@ void RenderLayer::logMockScrollAnimatorMessage(const String& message) const
     renderer().document().addConsoleMessage(MessageSource::Other, MessageLevel::Debug, "RenderLayer: " + message);
 }
 
+String RenderLayer::debugDescription() const
+{
+    StringBuilder builder;
+    builder.append("RenderLayer 0x"_s, hex(reinterpret_cast<uintptr_t>(this), Lowercase), ' ', size().width(), 'x', size().height());
+
+    if (transform())
+        builder.append(" has transform"_s);
+
+    if (hasFilter())
+        builder.append(" has filter"_s);
+
+    if (hasBackdropFilter())
+        builder.append(" has backdrop filter"_s);
+
+    if (hasBlendMode())
+        builder.append(" has blend mode"_s);
+
+    if (isolatesBlending())
+        builder.append(" isolates blending"_s);
+
+    if (isComposited()) {
+        // Oh for better StringBuilder/TextStream integration.
+        TextStream stream;
+        stream << *backing();
+        builder.append(stream.release());
+    }
+
+    return builder.toString();
+}
+
 int RenderLayer::verticalScrollbarWidth(OverlayScrollbarSizeRelevancy relevancy) const
 {
     if (!m_vBar
@@ -7011,19 +7042,7 @@ TextStream& operator<<(WTF::TextStream& ts, ClipRectsType clipRectsType)
 
 TextStream& operator<<(TextStream& ts, const RenderLayer& layer)
 {
-    ts << "RenderLayer " << &layer << " " << layer.size();
-    if (layer.transform())
-        ts << " has transform";
-    if (layer.hasFilter())
-        ts << " has filter";
-    if (layer.hasBackdropFilter())
-        ts << " has backdrop filter";
-    if (layer.hasBlendMode())
-        ts << " has blend mode";
-    if (layer.isolatesBlending())
-        ts << " isolates blending";
-    if (layer.isComposited())
-        ts << " " << *layer.backing();
+    ts << layer.debugDescription();
     return ts;
 }
 
index d11393e..d1659b0 100644 (file)
@@ -926,6 +926,8 @@ public:
 
     void invalidateEventRegion();
 
+    String debugDescription() const final;
+
 private:
 
     void setNextSibling(RenderLayer* next) { m_next = next; }
index 3a038ce..f54d850 100644 (file)
@@ -710,7 +710,7 @@ static Optional<ScrollingNodeID> frameHostingNodeForFrame(Frame& frame)
 // Returns true on a successful update.
 bool RenderLayerCompositor::updateCompositingLayers(CompositingUpdateType updateType, RenderLayer* updateRoot)
 {
-    LOG_WITH_STREAM(Compositing, stream << "RenderLayerCompositor " << this << " updateCompositingLayers " << updateType << " contentLayersCount " << m_contentLayersCount);
+    LOG_WITH_STREAM(Compositing, stream << "RenderLayerCompositor " << this << " [" << m_renderView.frameView() << "] updateCompositingLayers " << updateType << " contentLayersCount " << m_contentLayersCount);
 
     TraceScope tracingScope(CompositingUpdateStart, CompositingUpdateEnd);
 
index 778df38..b57477d 100644 (file)
@@ -910,6 +910,11 @@ void RenderListBox::logMockScrollAnimatorMessage(const String& message) const
     document().addConsoleMessage(MessageSource::Other, MessageLevel::Debug, "RenderListBox: " + message);
 }
 
+String RenderListBox::debugDescription() const
+{
+    return RenderObject::debugDescription();
+}
+
 Ref<Scrollbar> RenderListBox::createScrollbar()
 {
     RefPtr<Scrollbar> widget;
index f48580a..8c5a8fa 100644 (file)
@@ -141,6 +141,7 @@ private:
     IntRect scrollableAreaBoundingBox(bool* = nullptr) const final;
     bool usesMockScrollAnimator() const final;
     void logMockScrollAnimatorMessage(const String&) const final;
+    String debugDescription() const final;
 
     // NOTE: This should only be called by the overridden setScrollOffset from ScrollableArea.
     void scrollTo(int newOffset);
index bf62deb..b7a6e04 100644 (file)
@@ -1,3 +1,22 @@
+2020-04-06  Simon Fraser  <simon.fraser@apple.com>
+
+        Make ScrollableArea TextStream-loggable
+        https://bugs.webkit.org/show_bug.cgi?id=210042
+
+        Reviewed by Darin Adler.
+
+        ScrollableArea is a pure virtual base class, so has to dump via a virtual function,
+        so add debugDescription() and implement it in derived classes.
+
+        Make the common pattern be that operator<<(TextStream&, ...) calls debugDescription.
+
+        * UIProcess/win/WebPopupMenuProxyWin.cpp:
+        (WebKit::WebPopupMenuProxyWin::debugDescription const):
+        * UIProcess/win/WebPopupMenuProxyWin.h:
+        * WebProcess/Plugins/PDF/PDFPlugin.h:
+        * WebProcess/Plugins/PDF/PDFPlugin.mm:
+        (WebKit::PDFPlugin::debugDescription const):
+
 2020-04-06  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, reverting r259469.
index 11b4dfd..4ce97ab 100644 (file)
@@ -41,6 +41,8 @@
 #include <WebCore/ScrollbarThemeWin.h>
 #include <WebCore/WebCoreInstanceHandle.h>
 #include <windowsx.h>
+#include <wtf/HexNumber.h>
+#include <wtf/text/StringBuilder.h>
 
 #if USE(DIRECT2D)
 #include <WebCore/Direct2DUtilities.h>
@@ -1033,4 +1035,10 @@ void WebPopupMenuProxyWin::configureBackingStore(const WebCore::IntSize& size)
     m_immediateContext->ClearRenderTargetView(m_renderTargetView.get(), DirectX::Colors::BlanchedAlmond); 
 }
 #endif
+
+String WebPopupMenuProxyWin::debugDescription() const
+{
+    return makeString("WebPopupMenuProxyWin 0x", hex(reinterpret_cast<uintptr_t>(this), Lowercase));
+}
+
 } // namespace WebKit
index ef6806a..57cf08f 100644 (file)
@@ -59,6 +59,8 @@ public:
 
     void hide() { hidePopupMenu(); }
 
+    String debugDescription() const final;
+
 private:
     WebPopupMenuProxyWin(WebView*, WebPopupMenuProxy::Client&);
 
index 7b8f258..b6883b7 100644 (file)
@@ -246,6 +246,7 @@ private:
     WebCore::IntPoint convertFromContainingViewToScrollbar(const WebCore::Scrollbar&, const WebCore::IntPoint& parentPoint) const final;
     bool forceUpdateScrollbarsOnMainThreadForPerformanceTesting() const final;
     bool shouldPlaceBlockDirectionScrollbarOnLeft() const final { return false; }
+    String debugDescription() const final;
 
     // PDFPlugin functions.
     void updateScrollbars();
index 298024f..10195fa 100644 (file)
@@ -89,6 +89,7 @@
 #import <WebCore/WheelEventTestMonitor.h>
 #import <pal/spi/cg/CoreGraphicsSPI.h>
 #import <pal/spi/mac/NSMenuSPI.h>
+#import <wtf/HexNumber.h>
 #import <wtf/UUID.h>
 #import <wtf/WTFSemaphore.h>
 #import <wtf/WorkQueue.h>
@@ -1283,6 +1284,11 @@ IntPoint PDFPlugin::convertFromContainingViewToScrollbar(const Scrollbar& scroll
     return point;
 }
 
+String PDFPlugin::debugDescription() const
+{
+    return makeString("PDFPlugin 0x", hex(reinterpret_cast<uintptr_t>(this), Lowercase));
+}
+
 bool PDFPlugin::handleScroll(ScrollDirection direction, ScrollGranularity granularity)
 {
     return scroll(direction, granularity);