Title: [191216] trunk/Source
Revision
191216
Author
simon.fra...@apple.com
Date
2015-10-16 15:31:26 -0700 (Fri, 16 Oct 2015)

Log Message

Make TextStream the canonical way to log classes in WebCore
https://bugs.webkit.org/show_bug.cgi?id=150256

Reviewed by Sam Weinig.

We vacillated between PrintStream and TextStream as being the canonical way
to stringify WebCore data structures. This patch solidifies TextStream
as the solution, since it has convenient stream syntax, and is what we
use for render tree dumps.

Remove TextStream member functions that output non-simple structs
(sizes, points and rects), replacing them with free operator<< functions
in the .cpp file for the relevant class. Formatting is currently consistent
with RenderTreeAsText output, to avoid breaking tests.

Remove custom FloatRect outputting in SVG and RemoteLayerTreeTransaction.

Source/WebCore:

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/FloatPoint.cpp:
(WebCore::operator<<):
(WebCore::FloatPoint::dump): Deleted.
* platform/graphics/FloatPoint.h:
* platform/graphics/FloatRect.cpp:
(WebCore::operator<<):
(WebCore::FloatRect::dump): Deleted.
* platform/graphics/FloatRect.h:
* platform/graphics/FloatSize.cpp:
(WebCore::FloatSize::FloatSize):
(WebCore::operator<<):
(WebCore::FloatSize::dump): Deleted.
* platform/graphics/FloatSize.h:
* platform/graphics/IntPoint.cpp:
(WebCore::operator<<):
(WebCore::IntPoint::dump): Deleted.
* platform/graphics/IntPoint.h:
* platform/graphics/IntRect.cpp:
(WebCore::operator<<):
(WebCore::IntRect::dump): Deleted.
* platform/graphics/IntRect.h:
* platform/graphics/IntSize.cpp:
(WebCore::operator<<):
(WebCore::IntSize::dump): Deleted.
* platform/graphics/IntSize.h:
* platform/graphics/LayoutPoint.cpp: Copied from Source/WebCore/platform/graphics/IntPoint.cpp.
(WebCore::operator<<):
* platform/graphics/LayoutPoint.h:
* platform/graphics/LayoutRect.cpp:
(WebCore::operator<<):
* platform/graphics/LayoutRect.h:
* platform/graphics/LayoutSize.cpp: Copied from Source/WebCore/platform/graphics/IntPoint.cpp.
(WebCore::operator<<):
* platform/graphics/LayoutSize.h:
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(WebCore::MediaSampleAVFObjC::dump):
* platform/text/TextStream.cpp:
(WebCore::TextStream::operator<<):
* platform/text/TextStream.h:
* rendering/svg/SVGRenderTreeAsText.cpp:
(WebCore::operator<<): Deleted.

Source/WebKit2:

* Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp:
(WebKit::RemoteScrollingTreeTextStream::operator<<): Deleted.
* Shared/mac/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTextStream::operator<<): Deleted.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (191215 => 191216)


--- trunk/Source/WebCore/CMakeLists.txt	2015-10-16 22:18:42 UTC (rev 191215)
+++ trunk/Source/WebCore/CMakeLists.txt	2015-10-16 22:31:26 UTC (rev 191216)
@@ -2213,7 +2213,9 @@
     platform/graphics/IntPoint.cpp
     platform/graphics/IntRect.cpp
     platform/graphics/IntSize.cpp
+    platform/graphics/LayoutPoint.cpp
     platform/graphics/LayoutRect.cpp
+    platform/graphics/LayoutSize.cpp
     platform/graphics/MediaPlayer.cpp
     platform/graphics/NamedImageGeneratedImage.cpp
     platform/graphics/Path.cpp

Modified: trunk/Source/WebCore/ChangeLog (191215 => 191216)


--- trunk/Source/WebCore/ChangeLog	2015-10-16 22:18:42 UTC (rev 191215)
+++ trunk/Source/WebCore/ChangeLog	2015-10-16 22:31:26 UTC (rev 191216)
@@ -1,3 +1,66 @@
+2015-10-16  Simon Fraser  <simon.fra...@apple.com>
+
+        Make TextStream the canonical way to log classes in WebCore
+        https://bugs.webkit.org/show_bug.cgi?id=150256
+
+        Reviewed by Sam Weinig.
+
+        We vacillated between PrintStream and TextStream as being the canonical way
+        to stringify WebCore data structures. This patch solidifies TextStream
+        as the solution, since it has convenient stream syntax, and is what we
+        use for render tree dumps.
+
+        Remove TextStream member functions that output non-simple structs
+        (sizes, points and rects), replacing them with free operator<< functions
+        in the .cpp file for the relevant class. Formatting is currently consistent
+        with RenderTreeAsText output, to avoid breaking tests.
+
+        Remove custom FloatRect outputting in SVG and RemoteLayerTreeTransaction.
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/graphics/FloatPoint.cpp:
+        (WebCore::operator<<):
+        (WebCore::FloatPoint::dump): Deleted.
+        * platform/graphics/FloatPoint.h:
+        * platform/graphics/FloatRect.cpp:
+        (WebCore::operator<<):
+        (WebCore::FloatRect::dump): Deleted.
+        * platform/graphics/FloatRect.h:
+        * platform/graphics/FloatSize.cpp:
+        (WebCore::FloatSize::FloatSize):
+        (WebCore::operator<<):
+        (WebCore::FloatSize::dump): Deleted.
+        * platform/graphics/FloatSize.h:
+        * platform/graphics/IntPoint.cpp:
+        (WebCore::operator<<):
+        (WebCore::IntPoint::dump): Deleted.
+        * platform/graphics/IntPoint.h:
+        * platform/graphics/IntRect.cpp:
+        (WebCore::operator<<):
+        (WebCore::IntRect::dump): Deleted.
+        * platform/graphics/IntRect.h:
+        * platform/graphics/IntSize.cpp:
+        (WebCore::operator<<):
+        (WebCore::IntSize::dump): Deleted.
+        * platform/graphics/IntSize.h:
+        * platform/graphics/LayoutPoint.cpp: Copied from Source/WebCore/platform/graphics/IntPoint.cpp.
+        (WebCore::operator<<):
+        * platform/graphics/LayoutPoint.h:
+        * platform/graphics/LayoutRect.cpp:
+        (WebCore::operator<<):
+        * platform/graphics/LayoutRect.h:
+        * platform/graphics/LayoutSize.cpp: Copied from Source/WebCore/platform/graphics/IntPoint.cpp.
+        (WebCore::operator<<):
+        * platform/graphics/LayoutSize.h:
+        * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
+        (WebCore::MediaSampleAVFObjC::dump):
+        * platform/text/TextStream.cpp:
+        (WebCore::TextStream::operator<<):
+        * platform/text/TextStream.h:
+        * rendering/svg/SVGRenderTreeAsText.cpp:
+        (WebCore::operator<<): Deleted.
+
 2015-10-16  Brent Fulgham  <bfulg...@apple.com>
 
         Hide all plugin names except Flash, Java, and QuickTime

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (191215 => 191216)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2015-10-16 22:18:42 UTC (rev 191215)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2015-10-16 22:31:26 UTC (rev 191216)
@@ -480,6 +480,8 @@
 		0F15ED5C1B7EC7C500EDDFEB /* WillChangeData.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F15ED5A1B7EC7C500EDDFEB /* WillChangeData.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		0F1774801378B772009DA76A /* ScrollAnimatorIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F17747E1378B771009DA76A /* ScrollAnimatorIOS.h */; };
 		0F1774811378B772009DA76A /* ScrollAnimatorIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F17747F1378B772009DA76A /* ScrollAnimatorIOS.mm */; };
+		0F36E7371BD1837A002DB891 /* LayoutPoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F36E7361BD1837A002DB891 /* LayoutPoint.cpp */; settings = {ASSET_TAGS = (); }; };
+		0F36E7391BD184B9002DB891 /* LayoutSize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F36E7381BD184B9002DB891 /* LayoutSize.cpp */; settings = {ASSET_TAGS = (); }; };
 		0F3C725E1974874B00AEDD0C /* ImageSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F3C725D1974874B00AEDD0C /* ImageSource.cpp */; };
 		0F3DD44F12F5EA1B000D9190 /* ShadowBlur.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F3DD44D12F5EA1B000D9190 /* ShadowBlur.cpp */; };
 		0F3DD45012F5EA1B000D9190 /* ShadowBlur.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F3DD44E12F5EA1B000D9190 /* ShadowBlur.h */; };
@@ -7709,6 +7711,8 @@
 		0F15ED5A1B7EC7C500EDDFEB /* WillChangeData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WillChangeData.h; sourceTree = "<group>"; };
 		0F17747E1378B771009DA76A /* ScrollAnimatorIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollAnimatorIOS.h; sourceTree = "<group>"; };
 		0F17747F1378B772009DA76A /* ScrollAnimatorIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollAnimatorIOS.mm; sourceTree = "<group>"; };
+		0F36E7361BD1837A002DB891 /* LayoutPoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutPoint.cpp; sourceTree = "<group>"; };
+		0F36E7381BD184B9002DB891 /* LayoutSize.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutSize.cpp; sourceTree = "<group>"; };
 		0F3C725D1974874B00AEDD0C /* ImageSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageSource.cpp; sourceTree = "<group>"; };
 		0F3DD44D12F5EA1B000D9190 /* ShadowBlur.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShadowBlur.cpp; sourceTree = "<group>"; };
 		0F3DD44E12F5EA1B000D9190 /* ShadowBlur.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShadowBlur.h; sourceTree = "<group>"; };
@@ -21431,9 +21435,11 @@
 				07AC46FF1952102100EE9723 /* ISOVTTCue.cpp */,
 				07AC47001952102100EE9723 /* ISOVTTCue.h */,
 				65CC6BED16014EC0000ED27D /* Latin1TextIterator.h */,
+				0F36E7361BD1837A002DB891 /* LayoutPoint.cpp */,
 				141DC04B164834B900371E5A /* LayoutPoint.h */,
 				141DC04C164834B900371E5A /* LayoutRect.cpp */,
 				141DC04D164834B900371E5A /* LayoutRect.h */,
+				0F36E7381BD184B9002DB891 /* LayoutSize.cpp */,
 				141DC04E164834B900371E5A /* LayoutSize.h */,
 				07E3DFD01A9E786500764CA8 /* MediaPlaybackTarget.h */,
 				079216531AA560AA00A3C049 /* MediaPlaybackTargetClient.h */,
@@ -29371,6 +29377,7 @@
 				E157A8E01817331C009F821D /* JSCryptoKey.cpp in Sources */,
 				E157A8E818184C67009F821D /* JSCryptoKeyCustom.cpp in Sources */,
 				E1F80B8D183172B5007885C3 /* JSCryptoKeyPair.cpp in Sources */,
+				0F36E7391BD184B9002DB891 /* LayoutSize.cpp in Sources */,
 				E1F80B8A183172A2007885C3 /* JSCryptoKeyPairCustom.cpp in Sources */,
 				E125F85118283A5600D84CD9 /* JSCryptoKeySerializationJWK.cpp in Sources */,
 				E125F83D182411E700D84CD9 /* JSCryptoOperationData.cpp in Sources */,
@@ -29417,6 +29424,7 @@
 				659DDC8209E198BA001BF3C6 /* JSDocument.cpp in Sources */,
 				49C7BA8D1042F5B10009D447 /* JSDocumentCustom.cpp in Sources */,
 				1A494EDE0A123F4C00FDAFC1 /* JSDocumentFragment.cpp in Sources */,
+				0F36E7371BD1837A002DB891 /* LayoutPoint.cpp in Sources */,
 				7C33F3621B4A050400502CAF /* JSDocumentFragmentCustom.cpp in Sources */,
 				65DF31F509D1CC60000BE325 /* JSDocumentType.cpp in Sources */,
 				7C33F35E1B4A04CE00502CAF /* JSDocumentTypeCustom.cpp in Sources */,

Modified: trunk/Source/WebCore/platform/graphics/FloatPoint.cpp (191215 => 191216)


--- trunk/Source/WebCore/platform/graphics/FloatPoint.cpp	2015-10-16 22:18:42 UTC (rev 191215)
+++ trunk/Source/WebCore/platform/graphics/FloatPoint.cpp	2015-10-16 22:31:26 UTC (rev 191216)
@@ -30,10 +30,10 @@
 #include "AffineTransform.h"
 #include "FloatConversion.h"
 #include "IntPoint.h"
+#include "TextStream.h"
 #include "TransformationMatrix.h"
 #include <limits>
 #include <math.h>
-#include <wtf/PrintStream.h>
 
 namespace WebCore {
 
@@ -80,9 +80,9 @@
     return FloatPoint(narrowPrecisionToFloat(x), narrowPrecisionToFloat(y));
 }
 
-void FloatPoint::dump(PrintStream& out) const
+TextStream& operator<<(TextStream& ts, const FloatPoint& p)
 {
-    out.printf("(%f, %f)", x(), y());
+    return ts << "(" << TextStream::FormatNumberRespectingIntegers(p.x()) << "," << TextStream::FormatNumberRespectingIntegers(p.y()) << ")";
 }
 
 }

Modified: trunk/Source/WebCore/platform/graphics/FloatPoint.h (191215 => 191216)


--- trunk/Source/WebCore/platform/graphics/FloatPoint.h	2015-10-16 22:18:42 UTC (rev 191215)
+++ trunk/Source/WebCore/platform/graphics/FloatPoint.h	2015-10-16 22:31:26 UTC (rev 191216)
@@ -53,6 +53,7 @@
 class TransformationMatrix;
 class IntPoint;
 class IntSize;
+class TextStream;
 
 class FloatPoint {
 public:
@@ -148,8 +149,6 @@
     FloatPoint matrixTransform(const TransformationMatrix&) const;
     FloatPoint matrixTransform(const AffineTransform&) const;
 
-    void dump(WTF::PrintStream& out) const;
-
 private:
     float m_x, m_y;
 };
@@ -259,6 +258,8 @@
     return WTF::areEssentiallyEqual(a.x(), b.x()) && WTF::areEssentiallyEqual(a.y(), b.y());
 }
 
+WEBCORE_EXPORT TextStream& operator<<(TextStream&, const FloatPoint&);
+
 }
 
 #endif

Modified: trunk/Source/WebCore/platform/graphics/FloatRect.cpp (191215 => 191216)


--- trunk/Source/WebCore/platform/graphics/FloatRect.cpp	2015-10-16 22:18:42 UTC (rev 191215)
+++ trunk/Source/WebCore/platform/graphics/FloatRect.cpp	2015-10-16 22:31:26 UTC (rev 191216)
@@ -29,10 +29,10 @@
 
 #include "FloatConversion.h"
 #include "IntRect.h"
+#include "TextStream.h"
 #include <algorithm>
 #include <math.h>
 #include <wtf/MathExtras.h>
-#include <wtf/PrintStream.h>
 
 namespace WebCore {
 
@@ -226,9 +226,10 @@
     return IntRect(roundedIntPoint(rect.location()), roundedIntSize(rect.size()));
 }
 
-void FloatRect::dump(PrintStream& out) const
+TextStream& operator<<(TextStream& ts, const FloatRect &r)
 {
-    out.print(location(), " ", size());
+    return ts << "at (" << TextStream::FormatNumberRespectingIntegers(r.x()) << "," << TextStream::FormatNumberRespectingIntegers(r.y())
+        << ") size " << TextStream::FormatNumberRespectingIntegers(r.width()) << "x" << TextStream::FormatNumberRespectingIntegers(r.height());
 }
 
 }

Modified: trunk/Source/WebCore/platform/graphics/FloatRect.h (191215 => 191216)


--- trunk/Source/WebCore/platform/graphics/FloatRect.h	2015-10-16 22:18:42 UTC (rev 191215)
+++ trunk/Source/WebCore/platform/graphics/FloatRect.h	2015-10-16 22:31:26 UTC (rev 191216)
@@ -49,6 +49,7 @@
 
 class IntRect;
 class IntPoint;
+class TextStream;
 
 class FloatRect {
 public:
@@ -181,8 +182,6 @@
     operator cairo_rectangle_t() const;
 #endif
 
-    void dump(WTF::PrintStream& out) const;
-
     static FloatRect infiniteRect();
     bool isInfinite() const;
 
@@ -252,6 +251,8 @@
 WEBCORE_EXPORT IntRect enclosingIntRect(const FloatRect&);
 WEBCORE_EXPORT IntRect roundedIntRect(const FloatRect&);
 
+WEBCORE_EXPORT TextStream& operator<<(TextStream&, const FloatRect&);
+
 }
 
 #endif

Modified: trunk/Source/WebCore/platform/graphics/FloatSize.cpp (191215 => 191216)


--- trunk/Source/WebCore/platform/graphics/FloatSize.cpp	2015-10-16 22:18:42 UTC (rev 191215)
+++ trunk/Source/WebCore/platform/graphics/FloatSize.cpp	2015-10-16 22:31:26 UTC (rev 191216)
@@ -29,13 +29,15 @@
 
 #include "FloatConversion.h"
 #include "IntSize.h"
+#include "TextStream.h"
 #include <limits>
 #include <math.h>
-#include <wtf/PrintStream.h>
 
 namespace WebCore {
 
-FloatSize::FloatSize(const IntSize& size) : m_width(size.width()), m_height(size.height())
+FloatSize::FloatSize(const IntSize& size)
+    : m_width(size.width())
+    , m_height(size.height())
 {
 }
 
@@ -59,9 +61,10 @@
     return FloatSize(narrowPrecisionToFloat(width), narrowPrecisionToFloat(height));
 }
 
-void FloatSize::dump(PrintStream& out) const
+TextStream& operator<<(TextStream& ts, const FloatSize& size)
 {
-    out.printf("(%f x %f)", width(), height());
+    return ts << "width=" << TextStream::FormatNumberRespectingIntegers(size.width())
+        << " height=" << TextStream::FormatNumberRespectingIntegers(size.height());
 }
 
 }

Modified: trunk/Source/WebCore/platform/graphics/FloatSize.h (191215 => 191216)


--- trunk/Source/WebCore/platform/graphics/FloatSize.h	2015-10-16 22:18:42 UTC (rev 191215)
+++ trunk/Source/WebCore/platform/graphics/FloatSize.h	2015-10-16 22:31:26 UTC (rev 191216)
@@ -50,6 +50,7 @@
 namespace WebCore {
 
 class IntSize;
+class TextStream;
 
 class FloatSize {
 public:
@@ -118,10 +119,9 @@
     operator NSSize() const;
 #endif
 
-    void dump(WTF::PrintStream& out) const;
-
 private:
-    float m_width, m_height;
+    float m_width;
+    float m_height;
 };
 
 inline FloatSize& operator+=(FloatSize& a, const FloatSize& b)
@@ -208,6 +208,8 @@
     return IntPoint(clampToInteger(floorf(p.width())), clampToInteger(floorf(p.height())));
 }
 
+WEBCORE_EXPORT TextStream& operator<<(TextStream&, const FloatSize&);
+
 } // namespace WebCore
 
 #endif // FloatSize_h

Modified: trunk/Source/WebCore/platform/graphics/IntPoint.cpp (191215 => 191216)


--- trunk/Source/WebCore/platform/graphics/IntPoint.cpp	2015-10-16 22:18:42 UTC (rev 191215)
+++ trunk/Source/WebCore/platform/graphics/IntPoint.cpp	2015-10-16 22:31:26 UTC (rev 191216)
@@ -27,19 +27,19 @@
 #include "IntPoint.h"
 
 #include "FloatPoint.h"
-#include <wtf/PrintStream.h>
+#include "TextStream.h"
 
 namespace WebCore {
 
-void IntPoint::dump(PrintStream& out) const
-{
-    out.printf("(%d, %d)", x(), y());
-}
-
 IntPoint::IntPoint(const FloatPoint& p)
     : m_x(clampToInteger(p.x()))
     , m_y(clampToInteger(p.y()))
 {
 }
 
+TextStream& operator<<(TextStream& ts, const IntPoint& p)
+{
+    return ts << "(" << p.x() << "," << p.y() << ")";
 }
+
+}

Modified: trunk/Source/WebCore/platform/graphics/IntPoint.h (191215 => 191216)


--- trunk/Source/WebCore/platform/graphics/IntPoint.h	2015-10-16 22:18:42 UTC (rev 191215)
+++ trunk/Source/WebCore/platform/graphics/IntPoint.h	2015-10-16 22:31:26 UTC (rev 191216)
@@ -56,6 +56,7 @@
 namespace WebCore {
 
 class FloatPoint;
+class TextStream;
 
 class IntPoint {
 public:
@@ -127,8 +128,6 @@
     operator Evas_Point() const;
 #endif
 
-    void dump(WTF::PrintStream& out) const;
-
 private:
     int m_x, m_y;
 };
@@ -190,6 +189,8 @@
     return ((*this) - point).diagonalLengthSquared();
 }
 
+WEBCORE_EXPORT TextStream& operator<<(TextStream&, const IntPoint&);
+
 } // namespace WebCore
 
 #endif // IntPoint_h

Modified: trunk/Source/WebCore/platform/graphics/IntRect.cpp (191215 => 191216)


--- trunk/Source/WebCore/platform/graphics/IntRect.cpp	2015-10-16 22:18:42 UTC (rev 191215)
+++ trunk/Source/WebCore/platform/graphics/IntRect.cpp	2015-10-16 22:31:26 UTC (rev 191216)
@@ -28,8 +28,8 @@
 
 #include "FloatRect.h"
 #include "LayoutRect.h"
+#include "TextStream.h"
 #include <algorithm>
-#include <wtf/PrintStream.h>
 
 namespace WebCore {
 
@@ -146,9 +146,9 @@
     return IntSize(xdistance, ydistance);
 }
 
-void IntRect::dump(PrintStream& out) const
+TextStream& operator<<(TextStream& ts, const IntRect& r)
 {
-    out.print(location(), " ", size());
+    return ts << "at (" << r.x() << "," << r.y() << ") size " << r.width() << "x" << r.height();
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/IntRect.h (191215 => 191216)


--- trunk/Source/WebCore/platform/graphics/IntRect.h	2015-10-16 22:18:42 UTC (rev 191215)
+++ trunk/Source/WebCore/platform/graphics/IntRect.h	2015-10-16 22:31:26 UTC (rev 191216)
@@ -59,6 +59,7 @@
 
 class FloatRect;
 class LayoutRect;
+class TextStream;
 
 class IntRect {
     WTF_MAKE_FAST_ALLOCATED;
@@ -185,8 +186,6 @@
     WEBCORE_EXPORT operator NSRect() const;
 #endif
 
-    void dump(WTF::PrintStream& out) const;
-
 private:
     IntPoint m_location;
     IntSize m_size;
@@ -236,6 +235,8 @@
 WEBCORE_EXPORT IntRect enclosingIntRect(const NSRect&);
 #endif
 
+WEBCORE_EXPORT TextStream& operator<<(TextStream&, const IntRect&);
+
 } // namespace WebCore
 
 #endif // IntRect_h

Modified: trunk/Source/WebCore/platform/graphics/IntSize.cpp (191215 => 191216)


--- trunk/Source/WebCore/platform/graphics/IntSize.cpp	2015-10-16 22:18:42 UTC (rev 191215)
+++ trunk/Source/WebCore/platform/graphics/IntSize.cpp	2015-10-16 22:31:26 UTC (rev 191216)
@@ -27,19 +27,19 @@
 #include "IntSize.h"
 
 #include "FloatSize.h"
-#include <wtf/PrintStream.h>
+#include "TextStream.h"
 
 namespace WebCore {
 
-void IntSize::dump(PrintStream& out) const
-{
-    out.printf("(%d x %d)", width(), height());
-}
-
 IntSize::IntSize(const FloatSize& s)
     : m_width(clampToInteger(s.width()))
     , m_height(clampToInteger(s.height()))
 {
 }
 
+TextStream& operator<<(TextStream& ts, const IntSize& size)
+{
+    return ts << "width=" << size.width() << " height=" << size.height();
 }
+
+}

Modified: trunk/Source/WebCore/platform/graphics/IntSize.h (191215 => 191216)


--- trunk/Source/WebCore/platform/graphics/IntSize.h	2015-10-16 22:18:42 UTC (rev 191215)
+++ trunk/Source/WebCore/platform/graphics/IntSize.h	2015-10-16 22:31:26 UTC (rev 191216)
@@ -55,13 +55,10 @@
 typedef struct tagSIZE SIZE;
 #endif
 
-namespace WTF {
-class PrintStream;
-}
-
 namespace WebCore {
 
 class FloatSize;
+class TextStream;
 
 class IntSize {
 public:
@@ -156,8 +153,6 @@
     operator SIZE() const;
 #endif
 
-    void dump(WTF::PrintStream& out) const;
-
 private:
     int m_width, m_height;
 };
@@ -201,6 +196,8 @@
     return a.width() != b.width() || a.height() != b.height();
 }
 
+WEBCORE_EXPORT TextStream& operator<<(TextStream&, const IntSize&);
+
 } // namespace WebCore
 
 #endif // IntSize_h

Copied: trunk/Source/WebCore/platform/graphics/LayoutPoint.cpp (from rev 191215, trunk/Source/WebCore/platform/graphics/IntPoint.cpp) (0 => 191216)


--- trunk/Source/WebCore/platform/graphics/LayoutPoint.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/LayoutPoint.cpp	2015-10-16 22:31:26 UTC (rev 191216)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * 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
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "LayoutPoint.h"
+
+#include "TextStream.h"
+
+namespace WebCore {
+
+TextStream& operator<<(TextStream& ts, const LayoutPoint& p)
+{
+    // FIXME: These should be printed as floats. Keeping them ints for consistency with pervious test expectations.
+    return ts << "(" << p.x().toInt() << "," << p.y().toInt() << ")";
+}
+
+} // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/LayoutPoint.h (191215 => 191216)


--- trunk/Source/WebCore/platform/graphics/LayoutPoint.h	2015-10-16 22:18:42 UTC (rev 191215)
+++ trunk/Source/WebCore/platform/graphics/LayoutPoint.h	2015-10-16 22:31:26 UTC (rev 191216)
@@ -212,6 +212,8 @@
     return FloatSize(snap(size.width(), location.x()), snap(size.height(), location.y()));
 }
 
+TextStream& operator<<(TextStream&, const LayoutPoint&);
+
 } // namespace WebCore
 
 #endif // LayoutPoint_h

Modified: trunk/Source/WebCore/platform/graphics/LayoutRect.cpp (191215 => 191216)


--- trunk/Source/WebCore/platform/graphics/LayoutRect.cpp	2015-10-16 22:18:42 UTC (rev 191215)
+++ trunk/Source/WebCore/platform/graphics/LayoutRect.cpp	2015-10-16 22:31:26 UTC (rev 191216)
@@ -31,6 +31,7 @@
 #include "config.h"
 #include "LayoutRect.h"
 
+#include "TextStream.h"
 #include <algorithm>
 
 namespace WebCore {
@@ -153,4 +154,10 @@
     return FloatRect(location, maxPoint - location);
 }
 
+TextStream& operator<<(TextStream& ts, const LayoutRect& r)
+{
+    // FIXME: These should be printed as floats. Keeping them ints for consistency with previous test expectations.
+    return ts << snappedIntRect(r);
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/LayoutRect.h (191215 => 191216)


--- trunk/Source/WebCore/platform/graphics/LayoutRect.h	2015-10-16 22:18:42 UTC (rev 191215)
+++ trunk/Source/WebCore/platform/graphics/LayoutRect.h	2015-10-16 22:31:26 UTC (rev 191216)
@@ -39,6 +39,8 @@
 
 namespace WebCore {
 
+class TextStream;
+
 class LayoutRect {
 public:
     LayoutRect() { }
@@ -235,6 +237,8 @@
 
 FloatRect encloseRectToDevicePixels(const LayoutRect&, float pixelSnappingFactor);
 
+TextStream& operator<<(TextStream&, const LayoutRect&);
+
 } // namespace WebCore
 
 #endif // LayoutRect_h

Copied: trunk/Source/WebCore/platform/graphics/LayoutSize.cpp (from rev 191215, trunk/Source/WebCore/platform/graphics/IntPoint.cpp) (0 => 191216)


--- trunk/Source/WebCore/platform/graphics/LayoutSize.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/LayoutSize.cpp	2015-10-16 22:31:26 UTC (rev 191216)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * 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
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "LayoutSize.h"
+
+#include "TextStream.h"
+
+namespace WebCore {
+
+TextStream& operator<<(TextStream& ts, const LayoutSize& size)
+{
+    return ts << "width=" << size.width().toFloat() << " height=" << size.height().toFloat();
+}
+
+} // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/LayoutSize.h (191215 => 191216)


--- trunk/Source/WebCore/platform/graphics/LayoutSize.h	2015-10-16 22:18:42 UTC (rev 191215)
+++ trunk/Source/WebCore/platform/graphics/LayoutSize.h	2015-10-16 22:31:26 UTC (rev 191216)
@@ -38,6 +38,7 @@
 namespace WebCore {
 
 class LayoutPoint;
+class TextStream;
 
 enum AspectRatioFit {
     AspectRatioFitShrink,
@@ -188,6 +189,8 @@
     return FloatSize(floorToDevicePixel(size.width(), pixelSnappingFactor), floorToDevicePixel(size.height(), pixelSnappingFactor));
 }
 
+TextStream& operator<<(TextStream&, const LayoutSize&);
+
 } // namespace WebCore
 
 #endif // LayoutSize_h

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm (191215 => 191216)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm	2015-10-16 22:18:42 UTC (rev 191215)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm	2015-10-16 22:31:26 UTC (rev 191216)
@@ -506,7 +506,7 @@
 
 void MediaSampleAVFObjC::dump(PrintStream& out) const
 {
-    out.print("{PTS(", presentationTime(), "), DTS(", decodeTime(), "), duration(", duration(), "), flags(", (int)flags(), "), presentationSize(", presentationSize(), ")}");
+    out.print("{PTS(", presentationTime(), "), DTS(", decodeTime(), "), duration(", duration(), "), flags(", (int)flags(), "), presentationSize(", presentationSize().width(), "x", presentationSize().height(), ")}");
 }
 
 void MediaSampleAVFObjC::offsetTimestampsBy(const MediaTime& offset)

Modified: trunk/Source/WebCore/platform/text/TextStream.cpp (191215 => 191216)


--- trunk/Source/WebCore/platform/text/TextStream.cpp	2015-10-16 22:18:42 UTC (rev 191215)
+++ trunk/Source/WebCore/platform/text/TextStream.cpp	2015-10-16 22:31:26 UTC (rev 191216)
@@ -27,9 +27,7 @@
 #include "TextStream.h"
 
 #include "FloatPoint.h"
-#include "FloatRect.h"
 #include "IntPoint.h"
-#include "IntRect.h"
 #include "LayoutRect.h"
 #include "LayoutUnit.h"
 #include <wtf/MathExtras.h>
@@ -129,45 +127,11 @@
     return *this;
 }
 
-TextStream& TextStream::operator<<(const IntPoint& p)
+TextStream& TextStream::operator<<(LayoutUnit v)
 {
-    return *this << "(" << p.x() << "," << p.y() << ")";
-}
-
-TextStream& TextStream::operator<<(const IntRect& r)
-{
-    return *this  << "at (" << r.x() << "," << r.y() << ") size " << r.width() << "x" << r.height();
-}
-
-TextStream& TextStream::operator<<(const FloatPoint& p)
-{
-    return *this << "(" << TextStream::FormatNumberRespectingIntegers(p.x())
-        << "," << TextStream::FormatNumberRespectingIntegers(p.y()) << ")";
-}
-
-TextStream& TextStream::operator<<(const FloatSize& s)
-{
-    return *this << "width=" << TextStream::FormatNumberRespectingIntegers(s.width())
-        << " height=" << TextStream::FormatNumberRespectingIntegers(s.height());
-}
-
-TextStream& TextStream::operator<<(const LayoutUnit& v)
-{
     return *this << TextStream::FormatNumberRespectingIntegers(v.toFloat());
 }
 
-TextStream& TextStream::operator<<(const LayoutPoint& p)
-{
-    // FIXME: These should be printed as floats. Keeping them ints for consistency with pervious test expectations.
-    return *this << "(" << p.x().toInt() << "," << p.y().toInt() << ")";
-}
-
-TextStream& TextStream::operator<<(const LayoutRect& r)
-{
-    // FIXME: These should be printed as floats. Keeping them ints for consistency with previous test expectations.
-    return *this << snappedIntRect(r);
-}
-
 String TextStream::release()
 {
     String result = m_text.toString();

Modified: trunk/Source/WebCore/platform/text/TextStream.h (191215 => 191216)


--- trunk/Source/WebCore/platform/text/TextStream.h	2015-10-16 22:18:42 UTC (rev 191215)
+++ trunk/Source/WebCore/platform/text/TextStream.h	2015-10-16 22:31:26 UTC (rev 191216)
@@ -31,10 +31,8 @@
 
 namespace WebCore {
 
-class IntPoint;
-class IntRect;
 class FloatPoint;
-class FloatSize;
+class IntPoint;
 class LayoutPoint;
 class LayoutRect;
 class LayoutUnit;
@@ -60,13 +58,7 @@
     WEBCORE_EXPORT TextStream& operator<<(const String&);
     TextStream& operator<<(const FormatNumberRespectingIntegers&);
 
-    WEBCORE_EXPORT TextStream& operator<<(const IntPoint&);
-    WEBCORE_EXPORT TextStream& operator<<(const IntRect&);
-    WEBCORE_EXPORT TextStream& operator<<(const FloatPoint&);
-    WEBCORE_EXPORT TextStream& operator<<(const FloatSize&);
-    TextStream& operator<<(const LayoutUnit&);
-    TextStream& operator<<(const LayoutPoint&);
-    TextStream& operator<<(const LayoutRect&);
+    TextStream& operator<<(LayoutUnit);
 
     template<typename Item>
     TextStream& operator<<(const Vector<Item>& vector)

Modified: trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp (191215 => 191216)


--- trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp	2015-10-16 22:18:42 UTC (rev 191215)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp	2015-10-16 22:31:26 UTC (rev 191216)
@@ -118,15 +118,6 @@
         writeNameValuePair(ts, name, value);
 }
 
-TextStream& operator<<(TextStream& ts, const FloatRect& r)
-{
-    ts << "at (" << TextStream::FormatNumberRespectingIntegers(r.x());
-    ts << "," << TextStream::FormatNumberRespectingIntegers(r.y());
-    ts << ") size " << TextStream::FormatNumberRespectingIntegers(r.width());
-    ts << "x" << TextStream::FormatNumberRespectingIntegers(r.height());
-    return ts;
-}
-
 TextStream& operator<<(TextStream& ts, const AffineTransform& transform)
 {
     if (transform.isIdentity())

Modified: trunk/Source/WebKit2/ChangeLog (191215 => 191216)


--- trunk/Source/WebKit2/ChangeLog	2015-10-16 22:18:42 UTC (rev 191215)
+++ trunk/Source/WebKit2/ChangeLog	2015-10-16 22:31:26 UTC (rev 191216)
@@ -1,3 +1,27 @@
+2015-10-16  Simon Fraser  <simon.fra...@apple.com>
+
+        Make TextStream the canonical way to log classes in WebCore
+        https://bugs.webkit.org/show_bug.cgi?id=150256
+
+        Reviewed by Sam Weinig.
+
+        We vacillated between PrintStream and TextStream as being the canonical way
+        to stringify WebCore data structures. This patch solidifies TextStream
+        as the solution, since it has convenient stream syntax, and is what we
+        use for render tree dumps.
+
+        Remove TextStream member functions that output non-simple structs
+        (sizes, points and rects), replacing them with free operator<< functions
+        in the .cpp file for the relevant class. Formatting is currently consistent
+        with RenderTreeAsText output, to avoid breaking tests.
+
+        Remove custom FloatRect outputting in SVG and RemoteLayerTreeTransaction.
+
+        * Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp:
+        (WebKit::RemoteScrollingTreeTextStream::operator<<): Deleted.
+        * Shared/mac/RemoteLayerTreeTransaction.mm:
+        (WebKit::RemoteLayerTreeTextStream::operator<<): Deleted.
+
 2015-10-16  Anders Carlsson  <ander...@apple.com>
 
         Remove some dead menu code

Modified: trunk/Source/WebKit2/Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp (191215 => 191216)


--- trunk/Source/WebKit2/Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp	2015-10-16 22:18:42 UTC (rev 191215)
+++ trunk/Source/WebKit2/Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp	2015-10-16 22:31:26 UTC (rev 191216)
@@ -463,7 +463,6 @@
     {
     }
 
-    RemoteScrollingTreeTextStream& operator<<(FloatRect);
     RemoteScrollingTreeTextStream& operator<<(ScrollingNodeType);
 
     RemoteScrollingTreeTextStream& operator<<(const FixedPositionViewportConstraints&);
@@ -506,13 +505,6 @@
     ts.decreaseIndent();
 }
 
-RemoteScrollingTreeTextStream& RemoteScrollingTreeTextStream::operator<<(FloatRect rect)
-{
-    RemoteScrollingTreeTextStream& ts = *this;
-    ts << rect.x() << " " << rect.y() << " " << rect.width() << " " << rect.height();
-    return ts;
-}
-
 RemoteScrollingTreeTextStream& RemoteScrollingTreeTextStream::operator<<(ScrollingNodeType nodeType)
 {
     RemoteScrollingTreeTextStream& ts = *this;

Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm (191215 => 191216)


--- trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm	2015-10-16 22:18:42 UTC (rev 191215)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm	2015-10-16 22:31:26 UTC (rev 191216)
@@ -662,7 +662,6 @@
     RemoteLayerTreeTextStream& operator<<(const FloatRoundedRect&);
     RemoteLayerTreeTextStream& operator<<(FloatPoint3D);
     RemoteLayerTreeTextStream& operator<<(Color);
-    RemoteLayerTreeTextStream& operator<<(FloatRect);
     RemoteLayerTreeTextStream& operator<<(const Vector<WebCore::GraphicsLayer::PlatformLayerID>&);
     RemoteLayerTreeTextStream& operator<<(const FilterOperation&);
     RemoteLayerTreeTextStream& operator<<(const FilterOperations&);
@@ -1059,13 +1058,6 @@
     return ts;
 }
 
-RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(FloatRect rect)
-{
-    RemoteLayerTreeTextStream& ts = *this;
-    ts << rect.x() << " " << rect.y() << " " << rect.width() << " " << rect.height();
-    return ts;
-}
-
 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const Vector<GraphicsLayer::PlatformLayerID>& layers)
 {
     RemoteLayerTreeTextStream& ts = *this;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to