Index: services/ui/public/interfaces/cursor/cursor_struct_traits.cc |
diff --git a/services/ui/public/interfaces/cursor/cursor_struct_traits.cc b/services/ui/public/interfaces/cursor/cursor_struct_traits.cc |
index 609ab837dec0b4d343539dfc38435b02b03e244e..fec26c2b3f19ecf5a92993dae02beb376bb7f786 100644 |
--- a/services/ui/public/interfaces/cursor/cursor_struct_traits.cc |
+++ b/services/ui/public/interfaces/cursor/cursor_struct_traits.cc |
@@ -6,6 +6,7 @@ |
#include "base/time/time.h" |
#include "mojo/common/common_custom_types_struct_traits.h" |
+#include "services/ui/public/interfaces/cursor/cursor.mojom.h" |
#include "skia/public/interfaces/bitmap_array_struct_traits.h" |
#include "skia/public/interfaces/bitmap_skbitmap_struct_traits.h" |
#include "third_party/skia/include/core/SkBitmap.h" |
@@ -15,6 +16,260 @@ |
namespace mojo { |
// static |
+ui::mojom::CursorType |
+EnumTraits<ui::mojom::CursorType, ui::CursorType>::ToMojom( |
+ ui::CursorType input) { |
+ switch (input) { |
+ case ui::CursorType::CURSOR_NULL: |
+ return ui::mojom::CursorType::CURSOR_NULL; |
+ case ui::CursorType::POINTER: |
+ return ui::mojom::CursorType::POINTER; |
+ case ui::CursorType::CROSS: |
+ return ui::mojom::CursorType::CROSS; |
+ case ui::CursorType::HAND: |
+ return ui::mojom::CursorType::HAND; |
+ case ui::CursorType::IBEAM: |
+ return ui::mojom::CursorType::IBEAM; |
+ case ui::CursorType::WAIT: |
+ return ui::mojom::CursorType::WAIT; |
+ case ui::CursorType::HELP: |
+ return ui::mojom::CursorType::HELP; |
+ case ui::CursorType::EAST_RESIZE: |
+ return ui::mojom::CursorType::EAST_RESIZE; |
+ case ui::CursorType::NORTH_RESIZE: |
+ return ui::mojom::CursorType::NORTH_RESIZE; |
+ case ui::CursorType::NORTH_EAST_RESIZE: |
+ return ui::mojom::CursorType::NORTH_EAST_RESIZE; |
+ case ui::CursorType::NORTH_WEST_RESIZE: |
+ return ui::mojom::CursorType::NORTH_WEST_RESIZE; |
+ case ui::CursorType::SOUTH_RESIZE: |
+ return ui::mojom::CursorType::SOUTH_RESIZE; |
+ case ui::CursorType::SOUTH_EAST_RESIZE: |
+ return ui::mojom::CursorType::SOUTH_EAST_RESIZE; |
+ case ui::CursorType::SOUTH_WEST_RESIZE: |
+ return ui::mojom::CursorType::SOUTH_WEST_RESIZE; |
+ case ui::CursorType::WEST_RESIZE: |
+ return ui::mojom::CursorType::WEST_RESIZE; |
+ case ui::CursorType::NORTH_SOUTH_RESIZE: |
+ return ui::mojom::CursorType::NORTH_SOUTH_RESIZE; |
+ case ui::CursorType::EAST_WEST_RESIZE: |
+ return ui::mojom::CursorType::EAST_WEST_RESIZE; |
+ case ui::CursorType::NORTH_EAST_SOUTH_WEST_RESIZE: |
+ return ui::mojom::CursorType::NORTH_EAST_SOUTH_WEST_RESIZE; |
+ case ui::CursorType::NORTH_WEST_SOUTH_EAST_RESIZE: |
+ return ui::mojom::CursorType::NORTH_WEST_SOUTH_EAST_RESIZE; |
+ case ui::CursorType::COLUMN_RESIZE: |
+ return ui::mojom::CursorType::COLUMN_RESIZE; |
+ case ui::CursorType::ROW_RESIZE: |
+ return ui::mojom::CursorType::ROW_RESIZE; |
+ case ui::CursorType::MIDDLE_PANNING: |
+ return ui::mojom::CursorType::MIDDLE_PANNING; |
+ case ui::CursorType::EAST_PANNING: |
+ return ui::mojom::CursorType::EAST_PANNING; |
+ case ui::CursorType::NORTH_PANNING: |
+ return ui::mojom::CursorType::NORTH_PANNING; |
+ case ui::CursorType::NORTH_EAST_PANNING: |
+ return ui::mojom::CursorType::NORTH_EAST_PANNING; |
+ case ui::CursorType::NORTH_WEST_PANNING: |
+ return ui::mojom::CursorType::NORTH_WEST_PANNING; |
+ case ui::CursorType::SOUTH_PANNING: |
+ return ui::mojom::CursorType::SOUTH_PANNING; |
+ case ui::CursorType::SOUTH_EAST_PANNING: |
+ return ui::mojom::CursorType::SOUTH_EAST_PANNING; |
+ case ui::CursorType::SOUTH_WEST_PANNING: |
+ return ui::mojom::CursorType::SOUTH_WEST_PANNING; |
+ case ui::CursorType::WEST_PANNING: |
+ return ui::mojom::CursorType::WEST_PANNING; |
+ case ui::CursorType::MOVE: |
+ return ui::mojom::CursorType::MOVE; |
+ case ui::CursorType::VERTICAL_TEXT: |
+ return ui::mojom::CursorType::VERTICAL_TEXT; |
+ case ui::CursorType::CELL: |
+ return ui::mojom::CursorType::CELL; |
+ case ui::CursorType::CONTEXT_MENU: |
+ return ui::mojom::CursorType::CONTEXT_MENU; |
+ case ui::CursorType::ALIAS: |
+ return ui::mojom::CursorType::ALIAS; |
+ case ui::CursorType::PROGRESS: |
+ return ui::mojom::CursorType::PROGRESS; |
+ case ui::CursorType::NO_DROP: |
+ return ui::mojom::CursorType::NO_DROP; |
+ case ui::CursorType::COPY: |
+ return ui::mojom::CursorType::COPY; |
+ case ui::CursorType::NONE: |
+ return ui::mojom::CursorType::NONE; |
+ case ui::CursorType::NOT_ALLOWED: |
+ return ui::mojom::CursorType::NOT_ALLOWED; |
+ case ui::CursorType::ZOOM_IN: |
+ return ui::mojom::CursorType::ZOOM_IN; |
+ case ui::CursorType::ZOOM_OUT: |
+ return ui::mojom::CursorType::ZOOM_OUT; |
+ case ui::CursorType::GRAB: |
+ return ui::mojom::CursorType::GRAB; |
+ case ui::CursorType::GRABBING: |
+ return ui::mojom::CursorType::GRABBING; |
+ case ui::CursorType::CUSTOM: |
+ return ui::mojom::CursorType::CUSTOM; |
+ case ui::CursorType::DND_NONE: |
+ case ui::CursorType::DND_MOVE: |
+ case ui::CursorType::DND_COPY: |
+ case ui::CursorType::DND_LINK: |
+ // The mojom version is the same as the restricted Webcursor constants; |
+ // don't allow system cursors to be transmitted. |
+ NOTREACHED(); |
+ return ui::mojom::CursorType::CURSOR_NULL; |
+ } |
+ NOTREACHED(); |
+ return ui::mojom::CursorType::CURSOR_NULL; |
+} |
+ |
+// static |
+bool EnumTraits<ui::mojom::CursorType, ui::CursorType>::FromMojom( |
+ ui::mojom::CursorType input, |
+ ui::CursorType* out) { |
+ switch (input) { |
+ case ui::mojom::CursorType::CURSOR_NULL: |
+ *out = ui::CursorType::CURSOR_NULL; |
+ return true; |
+ case ui::mojom::CursorType::POINTER: |
+ *out = ui::CursorType::POINTER; |
+ return true; |
+ case ui::mojom::CursorType::CROSS: |
+ *out = ui::CursorType::CROSS; |
+ return true; |
+ case ui::mojom::CursorType::HAND: |
+ *out = ui::CursorType::HAND; |
+ return true; |
+ case ui::mojom::CursorType::IBEAM: |
+ *out = ui::CursorType::IBEAM; |
+ return true; |
+ case ui::mojom::CursorType::WAIT: |
+ *out = ui::CursorType::WAIT; |
+ return true; |
+ case ui::mojom::CursorType::HELP: |
+ *out = ui::CursorType::HELP; |
+ return true; |
+ case ui::mojom::CursorType::EAST_RESIZE: |
+ *out = ui::CursorType::EAST_RESIZE; |
+ return true; |
+ case ui::mojom::CursorType::NORTH_RESIZE: |
+ *out = ui::CursorType::NORTH_RESIZE; |
+ return true; |
+ case ui::mojom::CursorType::NORTH_EAST_RESIZE: |
+ *out = ui::CursorType::NORTH_EAST_RESIZE; |
+ return true; |
+ case ui::mojom::CursorType::NORTH_WEST_RESIZE: |
+ *out = ui::CursorType::NORTH_WEST_RESIZE; |
+ return true; |
+ case ui::mojom::CursorType::SOUTH_RESIZE: |
+ *out = ui::CursorType::SOUTH_RESIZE; |
+ return true; |
+ case ui::mojom::CursorType::SOUTH_EAST_RESIZE: |
+ *out = ui::CursorType::SOUTH_EAST_RESIZE; |
+ return true; |
+ case ui::mojom::CursorType::SOUTH_WEST_RESIZE: |
+ *out = ui::CursorType::SOUTH_WEST_RESIZE; |
+ return true; |
+ case ui::mojom::CursorType::WEST_RESIZE: |
+ *out = ui::CursorType::WEST_RESIZE; |
+ return true; |
+ case ui::mojom::CursorType::NORTH_SOUTH_RESIZE: |
+ *out = ui::CursorType::NORTH_SOUTH_RESIZE; |
+ return true; |
+ case ui::mojom::CursorType::EAST_WEST_RESIZE: |
+ *out = ui::CursorType::EAST_WEST_RESIZE; |
+ return true; |
+ case ui::mojom::CursorType::NORTH_EAST_SOUTH_WEST_RESIZE: |
+ *out = ui::CursorType::NORTH_EAST_SOUTH_WEST_RESIZE; |
+ return true; |
+ case ui::mojom::CursorType::NORTH_WEST_SOUTH_EAST_RESIZE: |
+ *out = ui::CursorType::NORTH_WEST_SOUTH_EAST_RESIZE; |
+ return true; |
+ case ui::mojom::CursorType::COLUMN_RESIZE: |
+ *out = ui::CursorType::COLUMN_RESIZE; |
+ return true; |
+ case ui::mojom::CursorType::ROW_RESIZE: |
+ *out = ui::CursorType::ROW_RESIZE; |
+ return true; |
+ case ui::mojom::CursorType::MIDDLE_PANNING: |
+ *out = ui::CursorType::MIDDLE_PANNING; |
+ return true; |
+ case ui::mojom::CursorType::EAST_PANNING: |
+ *out = ui::CursorType::EAST_PANNING; |
+ return true; |
+ case ui::mojom::CursorType::NORTH_PANNING: |
+ *out = ui::CursorType::NORTH_PANNING; |
+ return true; |
+ case ui::mojom::CursorType::NORTH_EAST_PANNING: |
+ *out = ui::CursorType::NORTH_EAST_PANNING; |
+ return true; |
+ case ui::mojom::CursorType::NORTH_WEST_PANNING: |
+ *out = ui::CursorType::NORTH_WEST_PANNING; |
+ return true; |
+ case ui::mojom::CursorType::SOUTH_PANNING: |
+ *out = ui::CursorType::SOUTH_PANNING; |
+ return true; |
+ case ui::mojom::CursorType::SOUTH_EAST_PANNING: |
+ *out = ui::CursorType::SOUTH_EAST_PANNING; |
+ return true; |
+ case ui::mojom::CursorType::SOUTH_WEST_PANNING: |
+ *out = ui::CursorType::SOUTH_WEST_PANNING; |
+ return true; |
+ case ui::mojom::CursorType::WEST_PANNING: |
+ *out = ui::CursorType::WEST_PANNING; |
+ return true; |
+ case ui::mojom::CursorType::MOVE: |
+ *out = ui::CursorType::MOVE; |
+ return true; |
+ case ui::mojom::CursorType::VERTICAL_TEXT: |
+ *out = ui::CursorType::VERTICAL_TEXT; |
+ return true; |
+ case ui::mojom::CursorType::CELL: |
+ *out = ui::CursorType::CELL; |
+ return true; |
+ case ui::mojom::CursorType::CONTEXT_MENU: |
+ *out = ui::CursorType::CONTEXT_MENU; |
+ return true; |
+ case ui::mojom::CursorType::ALIAS: |
+ *out = ui::CursorType::ALIAS; |
+ return true; |
+ case ui::mojom::CursorType::PROGRESS: |
+ *out = ui::CursorType::PROGRESS; |
+ return true; |
+ case ui::mojom::CursorType::NO_DROP: |
+ *out = ui::CursorType::NO_DROP; |
+ return true; |
+ case ui::mojom::CursorType::COPY: |
+ *out = ui::CursorType::COPY; |
+ return true; |
+ case ui::mojom::CursorType::NONE: |
+ *out = ui::CursorType::NONE; |
+ return true; |
+ case ui::mojom::CursorType::NOT_ALLOWED: |
+ *out = ui::CursorType::NOT_ALLOWED; |
+ return true; |
+ case ui::mojom::CursorType::ZOOM_IN: |
+ *out = ui::CursorType::ZOOM_IN; |
+ return true; |
+ case ui::mojom::CursorType::ZOOM_OUT: |
+ *out = ui::CursorType::ZOOM_OUT; |
+ return true; |
+ case ui::mojom::CursorType::GRAB: |
+ *out = ui::CursorType::GRAB; |
+ return true; |
+ case ui::mojom::CursorType::GRABBING: |
+ *out = ui::CursorType::GRABBING; |
+ return true; |
+ case ui::mojom::CursorType::CUSTOM: |
+ *out = ui::CursorType::CUSTOM; |
+ return true; |
+ } |
+ |
+ NOTREACHED(); |
+ return false; |
+} |
+ |
+// static |
const base::TimeDelta& |
StructTraits<ui::mojom::CursorDataDataView, ui::CursorData>::frame_delay( |
const ui::CursorData& c) { |
@@ -39,9 +294,12 @@ StructTraits<ui::mojom::CursorDataDataView, ui::CursorData>::cursor_frames( |
bool StructTraits<ui::mojom::CursorDataDataView, ui::CursorData>::Read( |
ui::mojom::CursorDataDataView data, |
ui::CursorData* out) { |
- ui::mojom::CursorType type = data.cursor_type(); |
- if (type != ui::mojom::CursorType::CUSTOM) { |
- *out = ui::CursorData(static_cast<int>(type)); |
+ ui::CursorType type; |
+ if (!data.ReadCursorType(&type)) |
+ return false; |
+ |
+ if (type != ui::CursorType::CUSTOM) { |
+ *out = ui::CursorData(type); |
return true; |
} |