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

Side by Side Diff: third_party/WebKit/Source/core/testing/CoreTestPrinters.cpp

Issue 1826283004: Revert NotImplemented() changes in r383029 and r383047. (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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/editing/Position.h" 5 #include "core/dom/Document.h"
6 #include "core/dom/Range.h"
7 #include "core/dom/Text.h"
8 #include "core/html/HTMLElement.h"
9 #include "wtf/text/StringBuilder.h"
6 #include <ios> 10 #include <ios>
7 #include <ostream> // NOLINT 11 #include <ostream> // NOLINT
8 12
9 namespace blink { 13 namespace blink {
10 14
11 namespace { 15 namespace {
12 16
17 // Copied from "dom/Node.cpp".
18 void appendAttributeDesc(const Node& node, StringBuilder& stringBuilder, const Q ualifiedName& name, const char* attrDesc)
19 {
20 if (!node.isElementNode())
21 return;
22
23 String attr = toElement(node).getAttribute(name);
24 if (attr.isEmpty())
25 return;
26
27 stringBuilder.append(attrDesc);
28 stringBuilder.appendLiteral("=\"");
29 stringBuilder.append(attr);
30 stringBuilder.appendLiteral("\"");
31 }
32
13 template <typename PositionType> 33 template <typename PositionType>
14 std::ostream& printPosition(std::ostream& ostream, const PositionType& position) 34 std::ostream& printPosition(std::ostream& ostream, const PositionType& position)
15 { 35 {
16 if (position.isNull()) 36 if (position.isNull())
17 return ostream << "null"; 37 return ostream << "null";
18 ostream << position.anchorNode() << "@"; 38 ostream << position.anchorNode() << "@";
19 if (position.isOffsetInAnchor()) 39 if (position.isOffsetInAnchor())
20 return ostream << position.offsetInContainerNode(); 40 return ostream << position.offsetInContainerNode();
21 return ostream << position.anchorType(); 41 return ostream << position.anchorType();
22 } 42 }
(...skipping 11 matching lines...) Expand all
34 return ostream << "beforeAnchor"; 54 return ostream << "beforeAnchor";
35 case PositionAnchorType::BeforeChildren: 55 case PositionAnchorType::BeforeChildren:
36 return ostream << "beforeChildren"; 56 return ostream << "beforeChildren";
37 case PositionAnchorType::OffsetInAnchor: 57 case PositionAnchorType::OffsetInAnchor:
38 return ostream << "offsetInAnchor"; 58 return ostream << "offsetInAnchor";
39 } 59 }
40 ASSERT_NOT_REACHED(); 60 ASSERT_NOT_REACHED();
41 return ostream << "anchorType=" << static_cast<int>(anchorType); 61 return ostream << "anchorType=" << static_cast<int>(anchorType);
42 } 62 }
43 63
64 // |std::ostream| version of |Node::showNode|
65 std::ostream& operator<<(std::ostream& ostream, const Node& node)
66 {
67 ostream << node.nodeName().utf8().data();
68 if (node.isTextNode())
69 return ostream << " " << node.nodeValue();
70 StringBuilder attrs;
71 appendAttributeDesc(node, attrs, HTMLNames::idAttr, " ID");
72 appendAttributeDesc(node, attrs, HTMLNames::classAttr, " CLASS");
73 appendAttributeDesc(node, attrs, HTMLNames::styleAttr, " STYLE");
74 return ostream << attrs.toString().utf8().data();
75 }
76
77 std::ostream& operator<<(std::ostream& ostream, const Node* node)
78 {
79 if (!node)
80 return ostream << "null";
81 return ostream << *node;
82 }
83
44 std::ostream& operator<<(std::ostream& ostream, const Position& position) 84 std::ostream& operator<<(std::ostream& ostream, const Position& position)
45 { 85 {
46 return printPosition(ostream, position); 86 return printPosition(ostream, position);
47 } 87 }
48 88
49 std::ostream& operator<<(std::ostream& ostream, const PositionInFlatTree& positi on) 89 std::ostream& operator<<(std::ostream& ostream, const PositionInFlatTree& positi on)
50 { 90 {
51 return printPosition(ostream, position); 91 return printPosition(ostream, position);
52 } 92 }
53 93
54 } // namespace blink 94 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698