Title: [159159] trunk/Source/WebCore
Revision
159159
Author
[email protected]
Date
2013-11-12 16:31:31 -0800 (Tue, 12 Nov 2013)

Log Message

Move ValueToString out to its own header file to remove duplication
https://bugs.webkit.org/show_bug.cgi?id=124237

Reviewed by Alexandru Chiculita.

The ValueToString struct is used in many places for debugging. Move it
out to its own header file to remove all the duplicated definitions
and make it possible for the specializations to be placed in the
header files with the implementation of the classes they print.

No new tests, no behavior change.

* GNUmakefile.list.am:
* WebCore.xcodeproj/project.pbxproj:
* html/HTMLMediaElement.h:
* platform/LayoutUnit.h:
* platform/PODInterval.h:
* platform/PODIntervalTree.h:
* platform/PODRedBlackTree.h:
* platform/ValueToString.h: Added.
* platform/graphics/FloatPolygon.h:
* rendering/FloatingObjects.cpp:
* rendering/FloatingObjects.h:
* rendering/RenderBlock.h:
* rendering/RenderBlockFlow.h:
* rendering/RenderFlowThread.h:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (159158 => 159159)


--- trunk/Source/WebCore/ChangeLog	2013-11-13 00:28:05 UTC (rev 159158)
+++ trunk/Source/WebCore/ChangeLog	2013-11-13 00:31:31 UTC (rev 159159)
@@ -1,3 +1,32 @@
+2013-11-12  Bem Jones-Bey  <[email protected]>
+
+        Move ValueToString out to its own header file to remove duplication
+        https://bugs.webkit.org/show_bug.cgi?id=124237
+
+        Reviewed by Alexandru Chiculita.
+
+        The ValueToString struct is used in many places for debugging. Move it
+        out to its own header file to remove all the duplicated definitions
+        and make it possible for the specializations to be placed in the
+        header files with the implementation of the classes they print.
+
+        No new tests, no behavior change.
+
+        * GNUmakefile.list.am:
+        * WebCore.xcodeproj/project.pbxproj:
+        * html/HTMLMediaElement.h:
+        * platform/LayoutUnit.h:
+        * platform/PODInterval.h:
+        * platform/PODIntervalTree.h:
+        * platform/PODRedBlackTree.h:
+        * platform/ValueToString.h: Added.
+        * platform/graphics/FloatPolygon.h:
+        * rendering/FloatingObjects.cpp:
+        * rendering/FloatingObjects.h:
+        * rendering/RenderBlock.h:
+        * rendering/RenderBlockFlow.h:
+        * rendering/RenderFlowThread.h:
+
 2013-11-11  David Hyatt  <[email protected]>
 
         Make RenderBlockRareData be in a hashtable instead of being a member variable.

Modified: trunk/Source/WebCore/GNUmakefile.list.am (159158 => 159159)


--- trunk/Source/WebCore/GNUmakefile.list.am	2013-11-13 00:28:05 UTC (rev 159158)
+++ trunk/Source/WebCore/GNUmakefile.list.am	2013-11-13 00:31:31 UTC (rev 159159)
@@ -6059,6 +6059,7 @@
 	Source/WebCore/platform/TreeShared.h \
 	Source/WebCore/platform/UUID.cpp \
 	Source/WebCore/platform/UUID.h \
+	Source/WebCore/platform/ValueToString.h \
 	Source/WebCore/platform/VisitedLinkStrategy.h \
 	Source/WebCore/platform/Widget.cpp \
 	Source/WebCore/platform/Widget.h \

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (159158 => 159159)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2013-11-13 00:28:05 UTC (rev 159158)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2013-11-13 00:31:31 UTC (rev 159159)
@@ -3395,6 +3395,7 @@
 		98CE4326129E00BD005821DC /* LinkLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 98CE4325129E00BD005821DC /* LinkLoader.cpp */; };
 		98CE432A129E00E5005821DC /* LinkLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 98CE4329129E00E5005821DC /* LinkLoader.h */; };
 		98EB1F951313FE0500D0E1EA /* NotImplemented.h in Headers */ = {isa = PBXBuildFile; fileRef = 98EB1F941313FE0500D0E1EA /* NotImplemented.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		9A1142041832D135000BB8AD /* ValueToString.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A1142031832D134000BB8AD /* ValueToString.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		9A1B6F97158869C80011A8C4 /* JSDOMStringListCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A1B6F96158869C80011A8C4 /* JSDOMStringListCustom.cpp */; };
 		9A528E8317D7F52F00AA9518 /* FloatingObjects.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A528E8117D7F52F00AA9518 /* FloatingObjects.cpp */; };
 		9A528E8417D7F52F00AA9518 /* FloatingObjects.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A528E8217D7F52F00AA9518 /* FloatingObjects.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -10148,6 +10149,7 @@
 		98CE4325129E00BD005821DC /* LinkLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LinkLoader.cpp; sourceTree = "<group>"; };
 		98CE4329129E00E5005821DC /* LinkLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LinkLoader.h; sourceTree = "<group>"; };
 		98EB1F941313FE0500D0E1EA /* NotImplemented.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NotImplemented.h; sourceTree = "<group>"; };
+		9A1142031832D134000BB8AD /* ValueToString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ValueToString.h; sourceTree = "<group>"; };
 		9A1B6F96158869C80011A8C4 /* JSDOMStringListCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMStringListCustom.cpp; sourceTree = "<group>"; };
 		9A528E8117D7F52F00AA9518 /* FloatingObjects.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FloatingObjects.cpp; sourceTree = "<group>"; };
 		9A528E8217D7F52F00AA9518 /* FloatingObjects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FloatingObjects.h; sourceTree = "<group>"; };
@@ -20158,6 +20160,7 @@
 				BCBD21AA0E417AD400A070F2 /* URLHash.h */,
 				2E3BBF051162DA1100B9409A /* UUID.cpp */,
 				2E3BBF061162DA1100B9409A /* UUID.h */,
+				9A1142031832D134000BB8AD /* ValueToString.h */,
 				515788C01207852C00A37C4A /* VisitedLinkStrategy.h */,
 				9380F47109A11AB4001FDB34 /* Widget.cpp */,
 				9380F47209A11AB4001FDB34 /* Widget.h */,
@@ -21878,6 +21881,7 @@
 			isa = PBXHeadersBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				9A1142041832D135000BB8AD /* ValueToString.h in Headers */,
 				932AD70617EFA2C40038F8FF /* MainFrame.h in Headers */,
 				FEDBFF16182B7A8D0017FA64 /* BreakpointID.h in Headers */,
 				FE115FAB167988CD00249134 /* AbstractDatabaseServer.h in Headers */,

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (159158 => 159159)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2013-11-13 00:28:05 UTC (rev 159158)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2013-11-13 00:31:31 UTC (rev 159159)
@@ -799,16 +799,8 @@
 
 #if ENABLE(VIDEO_TRACK)
 #ifndef NDEBUG
-// Template specializations required by PodIntervalTree in debug mode.
+// Template specialization required by PodIntervalTree in debug mode.
 template <>
-struct ValueToString<double> {
-    static String string(const double value)
-    {
-        return String::number(value);
-    }
-};
-
-template <>
 struct ValueToString<TextTrackCue*> {
     static String string(TextTrackCue* const& cue)
     {

Modified: trunk/Source/WebCore/platform/LayoutUnit.h (159158 => 159159)


--- trunk/Source/WebCore/platform/LayoutUnit.h	2013-11-13 00:28:05 UTC (rev 159158)
+++ trunk/Source/WebCore/platform/LayoutUnit.h	2013-11-13 00:31:31 UTC (rev 159159)
@@ -31,6 +31,7 @@
 #ifndef LayoutUnit_h
 #define LayoutUnit_h
 
+#include "ValueToString.h"
 #include <limits.h>
 #include <limits>
 #include <math.h>
@@ -962,6 +963,14 @@
     return value.toInt() == value;
 }
 
+#ifndef NDEBUG
+// This structure is used by PODIntervalTree for debugging.
+template <>
+struct ValueToString<LayoutUnit> {
+    static String string(const LayoutUnit value) { return String::number(value.toFloat()); }
+};
+#endif
+
 } // namespace WebCore
 
 #endif // LayoutUnit_h

Modified: trunk/Source/WebCore/platform/PODInterval.h (159158 => 159159)


--- trunk/Source/WebCore/platform/PODInterval.h	2013-11-13 00:28:05 UTC (rev 159158)
+++ trunk/Source/WebCore/platform/PODInterval.h	2013-11-13 00:31:31 UTC (rev 159159)
@@ -27,6 +27,7 @@
 #define PODInterval_h
 
 #ifndef NDEBUG
+#include "ValueToString.h"
 #include <wtf/text/StringBuilder.h>
 #endif
 
@@ -70,11 +71,6 @@
 // Note that this class requires a copy constructor and assignment
 // operator in order to be stored in the red-black tree.
 
-#ifndef NDEBUG
-template<class T>
-struct ValueToString;
-#endif
-
 template<class T, class UserData = void*>
 class PODInterval {
 public:

Modified: trunk/Source/WebCore/platform/PODIntervalTree.h (159158 => 159159)


--- trunk/Source/WebCore/platform/PODIntervalTree.h	2013-11-13 00:28:05 UTC (rev 159158)
+++ trunk/Source/WebCore/platform/PODIntervalTree.h	2013-11-13 00:31:31 UTC (rev 159159)
@@ -29,17 +29,13 @@
 #include "PODArena.h"
 #include "PODInterval.h"
 #include "PODRedBlackTree.h"
+#include "ValueToString.h"
 #include <wtf/Assertions.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/Vector.h>
 
 namespace WebCore {
 
-#ifndef NDEBUG
-template<class T>
-struct ValueToString;
-#endif
-
 template <class T, class UserData = void*>
 class PODIntervalSearchAdapter {
 public:

Modified: trunk/Source/WebCore/platform/PODRedBlackTree.h (159158 => 159159)


--- trunk/Source/WebCore/platform/PODRedBlackTree.h	2013-11-13 00:28:05 UTC (rev 159158)
+++ trunk/Source/WebCore/platform/PODRedBlackTree.h	2013-11-13 00:31:31 UTC (rev 159159)
@@ -73,6 +73,7 @@
 #define PODRedBlackTree_h
 
 #include "PODFreeListArena.h"
+#include "ValueToString.h"
 #include <wtf/Assertions.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/RefPtr.h>
@@ -84,11 +85,6 @@
 
 namespace WebCore {
 
-#ifndef NDEBUG
-template<class T>
-struct ValueToString;
-#endif
-
 enum UninitializedTreeEnum {
     UninitializedTree
 };

Added: trunk/Source/WebCore/platform/ValueToString.h (0 => 159159)


--- trunk/Source/WebCore/platform/ValueToString.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/ValueToString.h	2013-11-13 00:31:31 UTC (rev 159159)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2013 Adobe Systems Incorporated. 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 THE COPYRIGHT HOLDER "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 THE COPYRIGHT HOLDER 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.
+ */
+
+#ifndef ValueToString_h
+#define ValueToString_h
+
+#ifndef NDEBUG
+
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+template<class T>
+struct ValueToString;
+
+template <>
+struct ValueToString<int> {
+    static String string(const int value) { return String::number(value); }
+};
+
+template <>
+struct ValueToString<float> {
+    static String string(const float value) { return String::number(value); }
+};
+
+template <>
+struct ValueToString<double> {
+    static String string(const double value) { return String::number(value); }
+};
+
+};
+
+#endif
+
+#endif
+

Modified: trunk/Source/WebCore/platform/graphics/FloatPolygon.h (159158 => 159159)


--- trunk/Source/WebCore/platform/graphics/FloatPolygon.h	2013-11-13 00:28:05 UTC (rev 159158)
+++ trunk/Source/WebCore/platform/graphics/FloatPolygon.h	2013-11-13 00:31:31 UTC (rev 159159)
@@ -33,6 +33,7 @@
 #include "FloatPoint.h"
 #include "FloatRect.h"
 #include "PODIntervalTree.h"
+#include "ValueToString.h"
 #include "WindRule.h"
 #include <wtf/OwnPtr.h>
 #include <wtf/PassOwnPtr.h>
@@ -42,11 +43,6 @@
 
 class FloatPolygonEdge;
 
-// This class is used by PODIntervalTree for debugging.
-#ifndef NDEBUG
-template <class> struct ValueToString;
-#endif
-
 class FloatPolygon {
 public:
     FloatPolygon(PassOwnPtr<Vector<FloatPoint>> vertices, WindRule fillRule);
@@ -137,12 +133,8 @@
     const FloatPolygon* m_polygon;
 };
 
-// These structures are used by PODIntervalTree for debugging.
+// This structure is used by PODIntervalTree for debugging.
 #ifndef NDEBUG
-template <> struct ValueToString<float> {
-    static String string(const float value) { return String::number(value); }
-};
-
 template<> struct ValueToString<FloatPolygonEdge*> {
     static String string(const FloatPolygonEdge* edge) { return String::format("%p (%f,%f %f,%f)", edge, edge->vertex1().x(), edge->vertex1().y(), edge->vertex2().x(), edge->vertex2().y()); }
 };

Modified: trunk/Source/WebCore/rendering/FloatingObjects.cpp (159158 => 159159)


--- trunk/Source/WebCore/rendering/FloatingObjects.cpp	2013-11-13 00:28:05 UTC (rev 159158)
+++ trunk/Source/WebCore/rendering/FloatingObjects.cpp	2013-11-13 00:31:31 UTC (rev 159159)
@@ -473,18 +473,4 @@
     return m_outermostFloat ? m_renderer.logicalBottomForFloat(m_outermostFloat) - m_lineTop : LayoutUnit(1);
 }
 
-#ifndef NDEBUG
-// These helpers are only used by the PODIntervalTree for debugging purposes.
-String ValueToString<int>::string(const int value)
-{
-    return String::number(value);
-}
-
-String ValueToString<FloatingObject*>::string(const FloatingObject* floatingObject)
-{
-    return String::format("%p (%ix%i %ix%i)", floatingObject, floatingObject->frameRect().x().toInt(), floatingObject->frameRect().y().toInt(), floatingObject->frameRect().maxX().toInt(), floatingObject->frameRect().maxY().toInt());
-}
-#endif
-
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/FloatingObjects.h (159158 => 159159)


--- trunk/Source/WebCore/rendering/FloatingObjects.h	2013-11-13 00:28:05 UTC (rev 159158)
+++ trunk/Source/WebCore/rendering/FloatingObjects.h	2013-11-13 00:31:31 UTC (rev 159159)
@@ -165,12 +165,12 @@
 };
 
 #ifndef NDEBUG
-// These structures are used by PODIntervalTree for debugging purposes.
-template <> struct ValueToString<int> {
-    static String string(const int value);
-};
+// This helper is used by PODIntervalTree for debugging purposes.
 template<> struct ValueToString<FloatingObject*> {
-    static String string(const FloatingObject*);
+    static String string(const FloatingObject* floatingObject)
+    {
+        return String::format("%p (%ix%i %ix%i)", floatingObject, floatingObject->frameRect().x().toInt(), floatingObject->frameRect().y().toInt(), floatingObject->frameRect().maxX().toInt(), floatingObject->frameRect().maxY().toInt());
+    }
 };
 #endif
 

Modified: trunk/Source/WebCore/rendering/RenderBlock.h (159158 => 159159)


--- trunk/Source/WebCore/rendering/RenderBlock.h	2013-11-13 00:28:05 UTC (rev 159158)
+++ trunk/Source/WebCore/rendering/RenderBlock.h	2013-11-13 00:31:31 UTC (rev 159159)
@@ -24,7 +24,6 @@
 #define RenderBlock_h
 
 #include "ColumnInfo.h"
-#include "FloatingObjects.h"
 #include "GapRects.h"
 #include "PODIntervalTree.h"
 #include "RenderBox.h"
@@ -90,10 +89,6 @@
 class RenderBlock : public RenderBox {
 public:
     friend class LineLayoutState;
-#ifndef NDEBUG
-    // Used by the PODIntervalTree for debugging the FloatingObject.
-    template <class> friend struct ValueToString;
-#endif
 
 protected:
     RenderBlock(Element&, PassRef<RenderStyle>, unsigned baseTypeFlags);

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.h (159158 => 159159)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.h	2013-11-13 00:28:05 UTC (rev 159158)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.h	2013-11-13 00:31:31 UTC (rev 159159)
@@ -23,6 +23,7 @@
 #ifndef RenderBlockFlow_h
 #define RenderBlockFlow_h
 
+#include "FloatingObjects.h"
 #include "RenderBlock.h"
 #include "RenderLineBoxList.h"
 #include "SimpleLineLayout.h"

Modified: trunk/Source/WebCore/rendering/RenderFlowThread.h (159158 => 159159)


--- trunk/Source/WebCore/rendering/RenderFlowThread.h	2013-11-13 00:28:05 UTC (rev 159158)
+++ trunk/Source/WebCore/rendering/RenderFlowThread.h	2013-11-13 00:31:31 UTC (rev 159159)
@@ -369,12 +369,8 @@
     RenderFlowThread* m_previousRenderFlowThread;
 };
 
-// These structures are used by PODIntervalTree for debugging.
+// This structure is used by PODIntervalTree for debugging.
 #ifndef NDEBUG
-template <> struct ValueToString<LayoutUnit> {
-    static String string(const LayoutUnit value) { return String::number(value.toFloat()); }
-};
-
 template <> struct ValueToString<RenderRegion*> {
     static String string(const RenderRegion* value) { return String::format("%p", value); }
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to