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

Side by Side Diff: third_party/WebKit/Source/core/testing/CoreTestPrinters.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, 8 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "core/editing/Position.h"
6 #include <ios>
7 #include <ostream> // NOLINT
8
9 namespace blink {
10
11 namespace {
12
13 template <typename PositionType>
14 std::ostream& printPosition(std::ostream& ostream, const PositionType& position)
15 {
16 if (position.isNull())
17 return ostream << "null";
18 ostream << position.anchorNode() << "@";
19 if (position.isOffsetInAnchor())
20 return ostream << position.offsetInContainerNode();
21 return ostream << position.anchorType();
22 }
23
24 } // namespace
25
26 std::ostream& operator<<(std::ostream& ostream, PositionAnchorType anchorType)
27 {
28 switch (anchorType) {
29 case PositionAnchorType::AfterAnchor:
30 return ostream << "afterAnchor";
31 case PositionAnchorType::AfterChildren:
32 return ostream << "afterChildren";
33 case PositionAnchorType::BeforeAnchor:
34 return ostream << "beforeAnchor";
35 case PositionAnchorType::BeforeChildren:
36 return ostream << "beforeChildren";
37 case PositionAnchorType::OffsetInAnchor:
38 return ostream << "offsetInAnchor";
39 }
40 ASSERT_NOT_REACHED();
41 return ostream << "anchorType=" << static_cast<int>(anchorType);
42 }
43
44 std::ostream& operator<<(std::ostream& ostream, const Position& position)
45 {
46 return printPosition(ostream, position);
47 }
48
49 std::ostream& operator<<(std::ostream& ostream, const PositionInFlatTree& positi on)
50 {
51 return printPosition(ostream, position);
52 }
53
54 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698