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

Unified Diff: third_party/WebKit/Source/core/editing/Position.cpp

Issue 1843403002: Move Position printer to Pointer.cpp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
Index: third_party/WebKit/Source/core/editing/Position.cpp
diff --git a/third_party/WebKit/Source/core/editing/Position.cpp b/third_party/WebKit/Source/core/editing/Position.cpp
index 254b560324ce3fde3842a29e346c20f666035867..b7a21735d51691faf9d1ec5632a1aa1928d930c4 100644
--- a/third_party/WebKit/Source/core/editing/Position.cpp
+++ b/third_party/WebKit/Source/core/editing/Position.cpp
@@ -30,6 +30,7 @@
#include "core/editing/TextAffinity.h"
#include "wtf/text/CString.h"
#include <stdio.h>
+#include <ostream> // NOLINT
tkent 2016/03/31 07:59:58 please sort headers in the alphabetical order. BT
yosin_UTC9 2016/03/31 08:31:27 Per discussion offline. We'll commit as is. Here
namespace blink {
@@ -523,6 +524,45 @@ void PositionTemplate<Strategy>::showTreeForThisInFlatTree() const
#endif
+template <typename PositionType>
+static std::ostream& printPosition(std::ostream& ostream, const PositionType& position)
+{
+ if (position.isNull())
+ return ostream << "null";
+ ostream << position.anchorNode() << "@";
+ if (position.isOffsetInAnchor())
+ return ostream << position.offsetInContainerNode();
+ return ostream << position.anchorType();
+}
+
+std::ostream& operator<<(std::ostream& ostream, PositionAnchorType anchorType)
+{
+ switch (anchorType) {
+ case PositionAnchorType::AfterAnchor:
+ return ostream << "afterAnchor";
+ case PositionAnchorType::AfterChildren:
+ return ostream << "afterChildren";
+ case PositionAnchorType::BeforeAnchor:
+ return ostream << "beforeAnchor";
+ case PositionAnchorType::BeforeChildren:
+ return ostream << "beforeChildren";
+ case PositionAnchorType::OffsetInAnchor:
+ return ostream << "offsetInAnchor";
+ }
+ NOTREACHED();
+ return ostream << "anchorType=" << static_cast<int>(anchorType);
+}
+
+std::ostream& operator<<(std::ostream& ostream, const Position& position)
+{
+ return printPosition(ostream, position);
+}
+
+std::ostream& operator<<(std::ostream& ostream, const PositionInFlatTree& position)
+{
+ return printPosition(ostream, position);
+}
+
template class CORE_TEMPLATE_EXPORT PositionTemplate<EditingStrategy>;
template class CORE_TEMPLATE_EXPORT PositionTemplate<EditingInFlatTreeStrategy>;
« no previous file with comments | « third_party/WebKit/Source/core/editing/Position.h ('k') | third_party/WebKit/Source/core/testing/CoreTestPrinters.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698