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

Unified Diff: cc/ipc/selection_struct_traits.h

Issue 2041503002: Implement cc::Selection<gfx::SelectionBound> StructTraits (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix deps Created 4 years, 6 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
« no previous file with comments | « cc/ipc/selection.typemap ('k') | cc/ipc/struct_traits_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/ipc/selection_struct_traits.h
diff --git a/cc/ipc/selection_struct_traits.h b/cc/ipc/selection_struct_traits.h
new file mode 100644
index 0000000000000000000000000000000000000000..d4b29ea363723c11460ea0a724076629224f0683
--- /dev/null
+++ b/cc/ipc/selection_struct_traits.h
@@ -0,0 +1,47 @@
+// Copyright 2016 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.
+
+#ifndef CC_IPC_SELECTION_STRUCT_TRAITS_H_
+#define CC_IPC_SELECTION_STRUCT_TRAITS_H_
+
+#include "cc/input/selection.h"
+#include "cc/ipc/selection.mojom.h"
+
+namespace mojo {
+
+template <>
+struct StructTraits<cc::mojom::Selection, cc::Selection<gfx::SelectionBound>> {
+ static gfx::SelectionBound start(
+ const cc::Selection<gfx::SelectionBound>& selection) {
+ return selection.start;
+ }
+
+ static gfx::SelectionBound end(
+ const cc::Selection<gfx::SelectionBound>& selection) {
+ return selection.end;
+ }
+
+ static bool is_editable(const cc::Selection<gfx::SelectionBound>& selection) {
+ return selection.is_editable;
+ }
+
+ static bool is_empty_text_form_control(
+ const cc::Selection<gfx::SelectionBound>& selection) {
+ return selection.is_empty_text_form_control;
+ }
+
+ static bool Read(cc::mojom::SelectionDataView data,
+ cc::Selection<gfx::SelectionBound>* out) {
+ if (!data.ReadStart(&out->start) || !data.ReadEnd(&out->end))
+ return false;
+
+ out->is_editable = data.is_editable();
+ out->is_empty_text_form_control = data.is_empty_text_form_control();
+ return true;
+ }
+};
+
+} // namespace mojo
+
+#endif // CC_IPC_SELECTION_STRUCT_TRAITS_H_
« no previous file with comments | « cc/ipc/selection.typemap ('k') | cc/ipc/struct_traits_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698