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

Unified Diff: ui/gfx/range/mojo/range_struct_traits.h

Issue 2531323002: Struct traits for gfx::Range and gfx::RangeF. (Closed)
Patch Set: Addressed feedback. Created 4 years, 1 month 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 | « ui/gfx/range/mojo/range.typemap ('k') | ui/gfx/range/mojo/range_struct_traits_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/range/mojo/range_struct_traits.h
diff --git a/ui/gfx/range/mojo/range_struct_traits.h b/ui/gfx/range/mojo/range_struct_traits.h
new file mode 100644
index 0000000000000000000000000000000000000000..e717d418c46fe148899cc0177ecb7bc90116d188
--- /dev/null
+++ b/ui/gfx/range/mojo/range_struct_traits.h
@@ -0,0 +1,38 @@
+// 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 UI_GFX_RANGE_MOJO_RANGE_STRUCT_TRAITS_H_
+#define UI_GFX_RANGE_MOJO_RANGE_STRUCT_TRAITS_H_
+
+#include "ui/gfx/range/mojo/range.mojom-shared.h"
+#include "ui/gfx/range/range.h"
+#include "ui/gfx/range/range_f.h"
+
+namespace mojo {
+
+template <>
+struct StructTraits<gfx::mojom::RangeDataView, gfx::Range> {
+ static uint32_t start(const gfx::Range& r) { return r.start(); }
+ static uint32_t end(const gfx::Range& r) { return r.end(); }
+ static bool Read(gfx::mojom::RangeDataView data, gfx::Range* out) {
+ out->set_start(data.start());
+ out->set_end(data.end());
+ return true;
+ }
+};
+
+template <>
+struct StructTraits<gfx::mojom::RangeFDataView, gfx::RangeF> {
+ static float start(const gfx::RangeF& r) { return r.start(); }
+ static float end(const gfx::RangeF& r) { return r.end(); }
+ static bool Read(gfx::mojom::RangeFDataView data, gfx::RangeF* out) {
+ out->set_start(data.start());
+ out->set_end(data.end());
+ return true;
+ }
+};
+
+} // namespace mojo
+
+#endif // UI_GFX_RANGE_MOJO_RANGE_STRUCT_TRAITS_H_
« no previous file with comments | « ui/gfx/range/mojo/range.typemap ('k') | ui/gfx/range/mojo/range_struct_traits_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698