Make LayerOverlapMap able to output to a TextStream
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 May 2019 02:51:12 +0000 (02:51 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 May 2019 02:51:12 +0000 (02:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197923

Reviewed by Zalan Bujtas.

Make it possible output LayerOverlapMap to a TextStream for logging.

* rendering/LayerOverlapMap.cpp:
(WebCore::OverlapMapContainer::rectList const):
(WebCore::operator<<):
* rendering/LayerOverlapMap.h:
(WebCore::LayerOverlapMap::overlapStack const):

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/LayerOverlapMap.cpp
Source/WebCore/rendering/LayerOverlapMap.h

index 3deb599..c35bf04 100644 (file)
         * loader/PingLoader.cpp:
         (WebCore::PingLoader::sendPing):
 
+2019-05-15  Simon Fraser  <simon.fraser@apple.com>
+
+        Make LayerOverlapMap able to output to a TextStream
+        https://bugs.webkit.org/show_bug.cgi?id=197923
+
+        Reviewed by Zalan Bujtas.
+
+        Make it possible output LayerOverlapMap to a TextStream for logging.
+
+        * rendering/LayerOverlapMap.cpp:
+        (WebCore::OverlapMapContainer::rectList const):
+        (WebCore::operator<<):
+        * rendering/LayerOverlapMap.h:
+        (WebCore::LayerOverlapMap::overlapStack const):
+
 2019-05-15  Youenn Fablet  <youenn@apple.com>
 
         getUserMedia sandbox extensions should not be revoked when a getUserMedia allowed request is being processed
index 78100c7..31f9550 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "config.h"
 #include "LayerOverlapMap.h"
+#include <wtf/text/TextStream.h>
 
 namespace WebCore {
 
@@ -73,6 +74,8 @@ public:
     {
         m_rectList.append(otherContainer.m_rectList);
     }
+    
+    const RectList& rectList() const { return m_rectList; }
 
 private:
     RectList m_rectList;
@@ -115,4 +118,30 @@ void LayerOverlapMap::popCompositingContainer()
     m_overlapStack.removeLast();
 }
 
+static TextStream& operator<<(TextStream& ts, const RectList& rectList)
+{
+    ts << "bounds " << rectList.boundingRect << " (" << rectList.rects << " rects)";
+    return ts;
+}
+
+static TextStream& operator<<(TextStream& ts, const OverlapMapContainer& container)
+{
+    ts << container.rectList();
+    return ts;
+}
+
+TextStream& operator<<(TextStream& ts, const LayerOverlapMap& overlapMap)
+{
+    TextStream multilineStream;
+
+    TextStream::GroupScope scope(ts);
+    multilineStream << indent << "LayerOverlapMap\n";
+
+    for (auto& container : overlapMap.overlapStack())
+        multilineStream << "  " << *container << "\n";
+
+    ts << multilineStream.release();
+    return ts;
+}
+
 } // namespace WebCore
index 66cfc39..2b40a43 100644 (file)
 #include "LayoutRect.h"
 #include "RenderGeometryMap.h"
 
+namespace WTF {
+class TextStream;
+}
+
 namespace WebCore {
 
 class OverlapMapContainer;
@@ -48,10 +52,14 @@ public:
     const RenderGeometryMap& geometryMap() const { return m_geometryMap; }
     RenderGeometryMap& geometryMap() { return m_geometryMap; }
 
+    const Vector<std::unique_ptr<OverlapMapContainer>>& overlapStack() const { return m_overlapStack; }
+
 private:
     Vector<std::unique_ptr<OverlapMapContainer>> m_overlapStack;
     RenderGeometryMap m_geometryMap;
     bool m_isEmpty { true };
 };
 
+TextStream& operator<<(TextStream&, const LayerOverlapMap&);
+
 } // namespace WebCore