1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef UI_ACCESSIBILITY_AX_ACTION_DATA_H_
6 #define UI_ACCESSIBILITY_AX_ACTION_DATA_H_
7 
8 #include "ui/accessibility/ax_enums.mojom-forward.h"
9 #include "ui/accessibility/ax_export.h"
10 #include "ui/accessibility/ax_tree_id.h"
11 #include "ui/gfx/geometry/rect.h"
12 
13 namespace ui {
14 
15 // A compact representation of an accessibility action and the arguments
16 // associated with that action.
17 struct AX_EXPORT AXActionData {
18   AXActionData();
19   AXActionData(const AXActionData& other);
20   ~AXActionData();
21 
22   // This is a simple serializable struct. All member variables should be
23   // public and copyable.
24 
25   // See the ax::mojom::Action enums in ax_enums.mojom for explanations of which
26   // parameters apply.
27 
28   // The action to take.
29   ax::mojom::Action action;
30 
31   // The ID of the tree that this action should be performed on.
32   ui::AXTreeID target_tree_id = ui::AXTreeIDUnknown();
33 
34   // The source extension id (if any) of this action.
35   std::string source_extension_id;
36 
37   // The ID of the node that this action should be performed on.
38   int target_node_id = -1;
39 
40   // The request id of this action tracked by the client.
41   int request_id = -1;
42 
43   // Use enums from ax::mojom::ActionFlags
44   int flags = 0;
45 
46   // For an action that creates a selection, the selection anchor and focus
47   // (see ax_tree_data.h for definitions).
48   int anchor_node_id = -1;
49   int anchor_offset = -1;
50 
51   int focus_node_id = -1;
52   int focus_offset = -1;
53 
54   // Start index of the text which should be queried for.
55   int32_t start_index = -1;
56 
57   // End index of the text which should be queried for.
58   int32_t end_index = -1;
59 
60   // For custom action.
61   int custom_action_id = -1;
62 
63   // The target rect for the action.
64   gfx::Rect target_rect;
65 
66   // The target point for the action.
67   gfx::Point target_point;
68 
69   // The new value for a node, for the SET_VALUE action. UTF-8 encoded.
70   std::string value;
71 
72   // The event to fire in response to a HIT_TEST action.
73   ax::mojom::Event hit_test_event_to_fire;
74 
75   // The scroll alignment to use for a SCROLL_TO_MAKE_VISIBLE action. The
76   // scroll alignment controls where a node is scrolled within the viewport.
77   ax::mojom::ScrollAlignment horizontal_scroll_alignment;
78   ax::mojom::ScrollAlignment vertical_scroll_alignment;
79 
80   // The behavior to use for a SCROLL_TO_MAKE_VISIBLE. This controls whether or
81   // not the viewport is scrolled when the node is already visible.
82   ax::mojom::ScrollBehavior scroll_behavior;
83 };
84 
85 }  // namespace ui
86 
87 #endif  // UI_ACCESSIBILITY_AX_ACTION_DATA_H_
88