Chromium Code Reviews| 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>; |