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

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

Issue 2531323002: Struct traits for gfx::Range and gfx::RangeF. (Closed)
Patch Set: Add a missing include. 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
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..a7e22ecd15acc27b068febb9844233b1d63001f8
--- /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 int start(const gfx::Range& r) { return r.start(); }
Robert Sesek 2016/11/28 22:17:31 uint32_t instead of int?
Hadi 2016/11/28 22:36:38 Done.
+ static int 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_

Powered by Google App Engine
This is Rietveld 408576698