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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/testing/CoreTestPrinters.cpp
diff --git a/third_party/WebKit/Source/core/testing/CoreTestPrinters.cpp b/third_party/WebKit/Source/core/testing/CoreTestPrinters.cpp
index f21b74bca6e684223e2671be51b57353cd7dae40..60d56fa74ef3e1bee6aed3fa76ba2a3bf048920c 100644
--- a/third_party/WebKit/Source/core/testing/CoreTestPrinters.cpp
+++ b/third_party/WebKit/Source/core/testing/CoreTestPrinters.cpp
@@ -2,7 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "core/editing/Position.h"
+#include "core/dom/Document.h"
+#include "core/dom/Range.h"
+#include "core/dom/Text.h"
+#include "core/html/HTMLElement.h"
+#include "wtf/text/StringBuilder.h"
#include <ios>
#include <ostream> // NOLINT
@@ -10,6 +14,22 @@ namespace blink {
namespace {
+// Copied from "dom/Node.cpp".
+void appendAttributeDesc(const Node& node, StringBuilder& stringBuilder, const QualifiedName& name, const char* attrDesc)
+{
+ if (!node.isElementNode())
+ return;
+
+ String attr = toElement(node).getAttribute(name);
+ if (attr.isEmpty())
+ return;
+
+ stringBuilder.append(attrDesc);
+ stringBuilder.appendLiteral("=\"");
+ stringBuilder.append(attr);
+ stringBuilder.appendLiteral("\"");
+}
+
template <typename PositionType>
std::ostream& printPosition(std::ostream& ostream, const PositionType& position)
{
@@ -41,6 +61,26 @@ std::ostream& operator<<(std::ostream& ostream, PositionAnchorType anchorType)
return ostream << "anchorType=" << static_cast<int>(anchorType);
}
+// |std::ostream| version of |Node::showNode|
+std::ostream& operator<<(std::ostream& ostream, const Node& node)
+{
+ ostream << node.nodeName().utf8().data();
+ if (node.isTextNode())
+ return ostream << " " << node.nodeValue();
+ StringBuilder attrs;
+ appendAttributeDesc(node, attrs, HTMLNames::idAttr, " ID");
+ appendAttributeDesc(node, attrs, HTMLNames::classAttr, " CLASS");
+ appendAttributeDesc(node, attrs, HTMLNames::styleAttr, " STYLE");
+ return ostream << attrs.toString().utf8().data();
+}
+
+std::ostream& operator<<(std::ostream& ostream, const Node* node)
+{
+ if (!node)
+ return ostream << "null";
+ return ostream << *node;
+}
+
std::ostream& operator<<(std::ostream& ostream, const Position& position)
{
return printPosition(ostream, position);

Powered by Google App Engine
This is Rietveld 408576698