1 // Copyright (c) 2012 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.
5 // IPC messages for accessibility.
6 // Multiply-included message file, hence no include guard.
8 #include "base/basictypes.h"
9 #include "content/common/ax_content_node_data.h"
10 #include "content/common/content_export.h"
11 #include "content/common/view_message_enums.h"
12 #include "content/public/common/common_param_traits.h"
13 #include "ipc/ipc_message_macros.h"
14 #include "ipc/ipc_message_utils.h"
15 #include "ipc/ipc_param_traits.h"
16 #include "ipc/param_traits_macros.h"
17 #include "third_party/WebKit/public/web/WebAXEnums.h"
18 #include "ui/accessibility/ax_node_data.h"
19 #include "ui/accessibility/ax_tree_update.h"
21 #undef IPC_MESSAGE_EXPORT
22 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
24 #define IPC_MESSAGE_START AccessibilityMsgStart
26 IPC_ENUM_TRAITS_MAX_VALUE(content::AXContentIntAttribute
,
27 content::AX_CONTENT_INT_ATTRIBUTE_LAST
)
29 IPC_STRUCT_TRAITS_BEGIN(content::AXContentNodeData
)
30 IPC_STRUCT_TRAITS_MEMBER(id
)
31 IPC_STRUCT_TRAITS_MEMBER(role
)
32 IPC_STRUCT_TRAITS_MEMBER(state
)
33 IPC_STRUCT_TRAITS_MEMBER(location
)
34 IPC_STRUCT_TRAITS_MEMBER(string_attributes
)
35 IPC_STRUCT_TRAITS_MEMBER(int_attributes
)
36 IPC_STRUCT_TRAITS_MEMBER(float_attributes
)
37 IPC_STRUCT_TRAITS_MEMBER(bool_attributes
)
38 IPC_STRUCT_TRAITS_MEMBER(intlist_attributes
)
39 IPC_STRUCT_TRAITS_MEMBER(html_attributes
)
40 IPC_STRUCT_TRAITS_MEMBER(child_ids
)
41 IPC_STRUCT_TRAITS_MEMBER(content_int_attributes
)
42 IPC_STRUCT_TRAITS_END()
44 IPC_STRUCT_TRAITS_BEGIN(ui::AXTreeUpdate
<content::AXContentNodeData
>)
45 IPC_STRUCT_TRAITS_MEMBER(node_id_to_clear
)
46 IPC_STRUCT_TRAITS_MEMBER(nodes
)
47 IPC_STRUCT_TRAITS_END()
49 IPC_STRUCT_BEGIN(AccessibilityHostMsg_EventParams
)
51 IPC_STRUCT_MEMBER(ui::AXTreeUpdate
<content::AXContentNodeData
>, update
)
54 IPC_STRUCT_MEMBER(ui::AXEvent
, event_type
)
56 // ID of the node that the event applies to.
57 IPC_STRUCT_MEMBER(int, id
)
60 IPC_STRUCT_BEGIN(AccessibilityHostMsg_LocationChangeParams
)
61 // ID of the object whose location is changing.
62 IPC_STRUCT_MEMBER(int, id
)
64 // The object's new location, in frame-relative coordinates (same
65 // as the coordinates in AccessibilityNodeData).
66 IPC_STRUCT_MEMBER(gfx::Rect
, new_location
)
69 IPC_STRUCT_BEGIN(AccessibilityHostMsg_FindInPageResultParams
)
70 // The find in page request id.
71 IPC_STRUCT_MEMBER(int, request_id
)
73 // The index of the result match.
74 IPC_STRUCT_MEMBER(int, match_index
)
76 // The id of the accessibility object for the start of the match range.
77 IPC_STRUCT_MEMBER(int, start_id
)
79 // The character offset into the text of the start object.
80 IPC_STRUCT_MEMBER(int, start_offset
)
82 // The id of the accessibility object for the end of the match range.
83 IPC_STRUCT_MEMBER(int, end_id
)
85 // The character offset into the text of the end object.
86 IPC_STRUCT_MEMBER(int, end_offset
)
89 // Messages sent from the browser to the renderer.
91 // Relay a request from assistive technology to set focus to a given node.
92 IPC_MESSAGE_ROUTED1(AccessibilityMsg_SetFocus
,
95 // Relay a request from assistive technology to perform the default action
97 IPC_MESSAGE_ROUTED1(AccessibilityMsg_DoDefaultAction
,
100 // Relay a request from assistive technology to make a given object
101 // visible by scrolling as many scrollable containers as possible.
102 // In addition, if it's not possible to make the entire object visible,
103 // scroll so that the |subfocus| rect is visible at least. The subfocus
104 // rect is in local coordinates of the object itself.
105 IPC_MESSAGE_ROUTED2(AccessibilityMsg_ScrollToMakeVisible
,
107 gfx::Rect
/* subfocus */)
109 // Relay a request from assistive technology to show the context menu for a
111 IPC_MESSAGE_ROUTED1(AccessibilityMsg_ShowContextMenu
, int /* object id */)
113 // Relay a request from assistive technology to move a given object
114 // to a specific location, in the WebContents area coordinate space, i.e.
115 // (0, 0) is the top-left corner of the WebContents.
116 IPC_MESSAGE_ROUTED2(AccessibilityMsg_ScrollToPoint
,
118 gfx::Point
/* new location */)
120 // Relay a request from assistive technology to set the scroll offset
121 // of an accessibility object that's a scroll container, to a specific
123 IPC_MESSAGE_ROUTED2(AccessibilityMsg_SetScrollOffset
,
125 gfx::Point
/* new offset */)
127 // Relay a request from assistive technology to set the cursor or
128 // selection within an editable text element.
129 IPC_MESSAGE_ROUTED3(AccessibilityMsg_SetTextSelection
,
131 int /* New start offset */,
132 int /* New end offset */)
134 // Relay a request from assistive technology to set the value of an
135 // editable text element.
136 IPC_MESSAGE_ROUTED2(AccessibilityMsg_SetValue
,
138 base::string16
/* Value */)
140 // Determine the accessibility object under a given point and reply with
141 // a AccessibilityHostMsg_HitTestResult with the same id.
142 IPC_MESSAGE_ROUTED1(AccessibilityMsg_HitTest
,
143 gfx::Point
/* location to test */)
145 // Relay a request from assistive technology to set accessibility focus
146 // to a given node. On platforms where this is used (currently Android),
147 // inline text boxes are only computed for the node with accessibility focus,
148 // rather than for the whole tree.
149 IPC_MESSAGE_ROUTED1(AccessibilityMsg_SetAccessibilityFocus
,
152 // Tells the render view that a AccessibilityHostMsg_Events
153 // message was processed and it can send addition events.
154 IPC_MESSAGE_ROUTED0(AccessibilityMsg_Events_ACK
)
156 // Tell the renderer to reset and send a new accessibility tree from
157 // scratch because the browser is out of sync. It passes a sequential
158 // reset token. This should be rare, and if we need reset the same renderer
159 // too many times we just kill it. After sending a reset, the browser ignores
160 // incoming accessibility IPCs until it receives one with the matching reset
161 // token. Conversely, it ignores IPCs with a reset token if it was not
162 // expecting a reset.
163 IPC_MESSAGE_ROUTED1(AccessibilityMsg_Reset
,
164 int /* reset token */)
166 // Kill the renderer because we got a fatal error in the accessibility tree
167 // and we've already reset too many times.
168 IPC_MESSAGE_ROUTED0(AccessibilityMsg_FatalError
)
170 // Request a one-time snapshot of the accessibility tree without
171 // enabling accessibility if it wasn't already enabled. The passed id
172 // will be returned in the AccessibilityHostMsg_SnapshotResponse message.
173 IPC_MESSAGE_ROUTED1(AccessibilityMsg_SnapshotTree
,
174 int /* callback id */)
176 // Messages sent from the renderer to the browser.
178 // Sent to notify the browser about renderer accessibility events.
179 // The browser responds with a AccessibilityMsg_Events_ACK.
180 // The second parameter, reset_token, is set if this IPC was sent in response
181 // to a reset request from the browser. When the browser requests a reset,
182 // it ignores incoming IPCs until it sees one with the correct reset token.
183 // Any other time, it ignores IPCs with a reset token.
185 AccessibilityHostMsg_Events
,
186 std::vector
<AccessibilityHostMsg_EventParams
> /* events */,
187 int /* reset_token */)
189 // Sent to update the browser of the location of accessibility objects.
191 AccessibilityHostMsg_LocationChanges
,
192 std::vector
<AccessibilityHostMsg_LocationChangeParams
>)
194 // Sent to update the browser of the location of accessibility objects.
196 AccessibilityHostMsg_FindInPageResult
,
197 AccessibilityHostMsg_FindInPageResultParams
)
199 // Sent in response to AccessibilityMsg_SnapshotTree. The callback id that was
200 // passed to the request will be returned in |callback_id|, along with
201 // a standalone snapshot of the accessibility tree.
202 IPC_MESSAGE_ROUTED2(AccessibilityHostMsg_SnapshotResponse
,
203 int /* callback_id */,
204 ui::AXTreeUpdate
<content::AXContentNodeData
>)