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

Unified Diff: third_party/WebKit/Source/core/layout/api/SelectionState.cpp

Issue 2732643004: Add operator<< to SelectionState for debug logging. (Closed)
Patch Set: Use FOR_EACH pattern and add test. Created 3 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/layout/api/SelectionState.cpp
diff --git a/third_party/WebKit/Source/core/layout/api/SelectionState.cpp b/third_party/WebKit/Source/core/layout/api/SelectionState.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7ba84f793d6276a29a4a555f8d84cc269ad8358d
--- /dev/null
+++ b/third_party/WebKit/Source/core/layout/api/SelectionState.cpp
@@ -0,0 +1,24 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/layout/api/SelectionState.h"
+
+#include "wtf/Assertions.h"
+
+namespace blink {
+
+std::ostream& operator<<(std::ostream& out, const SelectionState state) {
+ static const char* const kText[] = {
+#define V(state) #state,
+ FOR_EACH_SELECTION_STATE(V)
+#undef V
+ };
+
+ const auto& it = std::begin(kText) + static_cast<size_t>(state);
+ DCHECK_GE(it, std::begin(kText)) << "Unknown state value";
+ DCHECK_LT(it, std::end(kText)) << "Unknown state value";
+ return out << *it;
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698