Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1268)

Unified Diff: third_party/WebKit/Source/platform/LayoutUnit.h

Issue 2191233002: Add platform/geometry pretty printers for logging and testing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/blink_platform.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/LayoutUnit.h
diff --git a/third_party/WebKit/Source/platform/LayoutUnit.h b/third_party/WebKit/Source/platform/LayoutUnit.h
index 16677770cb0f7be5762cf5721fd9ef0027c4a294..9afc99705b97924e0e9df7d2d3624a3e409d9226 100644
--- a/third_party/WebKit/Source/platform/LayoutUnit.h
+++ b/third_party/WebKit/Source/platform/LayoutUnit.h
@@ -35,6 +35,7 @@
#include "wtf/Assertions.h"
#include "wtf/MathExtras.h"
#include "wtf/SaturatedArithmetic.h"
+#include "wtf/text/WTFString.h"
#include <algorithm>
#include <limits.h>
#include <limits>
@@ -212,6 +213,19 @@ public:
return clampTo<LayoutUnit>(value, LayoutUnit::min(), LayoutUnit::max());
}
+ String toString() const
+ {
+ if (m_value == LayoutUnit::max().rawValue())
esprehn 2016/08/19 17:58:52 can we make this out of line?
+ return String::format("LayoutUnit::max(%f)", toDouble());
esprehn 2016/08/19 17:58:53 fwiw this is slow, doing "LayoutUnit::max(" + Stri
+ if (m_value == LayoutUnit::min().rawValue())
+ return String::format("LayoutUnit::min(%f)", toDouble());
+ if (m_value == LayoutUnit::nearlyMax().rawValue())
+ return String::format("LayoutUnit::nearlyMax(%f)", toDouble());
+ if (m_value == LayoutUnit::nearlyMin().rawValue())
+ return String::format("LayoutUnit::nearlyMin(%f)", toDouble());
+ return String::number(toDouble());
+ }
+
private:
static bool isInBounds(int value)
{
@@ -808,7 +822,7 @@ inline LayoutUnit clampToLayoutUnit(LayoutUnit value, LayoutUnit min, LayoutUnit
inline std::ostream& operator<<(std::ostream& stream, const LayoutUnit& value)
{
- return stream << value.toDouble();
+ return stream << value.toString();
}
} // namespace blink
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/blink_platform.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698