Avi Drissman | 3e1a26c | 2022-09-15 20:26:03 | [diff] [blame] | 1 | // Copyright 2018 The Chromium Authors |
Dominic Mazzoni | ccbaa9b | 2018-06-06 07:44:23 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "ui/accessibility/ax_event.h" |
| 6 | |
| 7 | #include "base/strings/string_number_conversions.h" |
| 8 | #include "ui/accessibility/ax_enum_util.h" |
Dominic Mazzoni | ccbaa9b | 2018-06-06 07:44:23 | [diff] [blame] | 9 | |
| 10 | namespace ui { |
| 11 | |
Nektarios Paisios | 56ee998 | 2020-04-22 07:53:06 | [diff] [blame] | 12 | AXEvent::AXEvent() = default; |
| 13 | |
Nektarios Paisios | 488275d | 2020-04-25 04:56:37 | [diff] [blame] | 14 | AXEvent::AXEvent(AXNodeData::AXID id, |
Nektarios Paisios | 56ee998 | 2020-04-22 07:53:06 | [diff] [blame] | 15 | ax::mojom::Event event_type, |
| 16 | ax::mojom::EventFrom event_from, |
Akihiro Ota | dacc8a5 | 2021-03-16 02:25:38 | [diff] [blame] | 17 | ax::mojom::Action event_from_action, |
Nektarios Paisios | 488275d | 2020-04-25 04:56:37 | [diff] [blame] | 18 | const std::vector<AXEventIntent>& event_intents, |
Nektarios Paisios | 56ee998 | 2020-04-22 07:53:06 | [diff] [blame] | 19 | int action_request_id) |
| 20 | : id(id), |
| 21 | event_type(event_type), |
| 22 | event_from(event_from), |
Akihiro Ota | dacc8a5 | 2021-03-16 02:25:38 | [diff] [blame] | 23 | event_from_action(event_from_action), |
Nektarios Paisios | 488275d | 2020-04-25 04:56:37 | [diff] [blame] | 24 | event_intents(event_intents), |
Nektarios Paisios | 56ee998 | 2020-04-22 07:53:06 | [diff] [blame] | 25 | action_request_id(action_request_id) {} |
Dominic Mazzoni | ccbaa9b | 2018-06-06 07:44:23 | [diff] [blame] | 26 | |
James Cook | 36cab7c | 2019-10-29 23:26:40 | [diff] [blame] | 27 | AXEvent::~AXEvent() = default; |
Dominic Mazzoni | ccbaa9b | 2018-06-06 07:44:23 | [diff] [blame] | 28 | |
David Tseng | 9025214 | 2024-04-01 17:36:43 | [diff] [blame] | 29 | AXEvent::AXEvent(AXEvent&& other) = default; |
| 30 | |
| 31 | AXEvent& AXEvent::operator=(AXEvent&& other) = default; |
| 32 | |
Nektarios Paisios | 56ee998 | 2020-04-22 07:53:06 | [diff] [blame] | 33 | AXEvent::AXEvent(const AXEvent& event) = default; |
| 34 | |
| 35 | AXEvent& AXEvent::operator=(const AXEvent& event) = default; |
| 36 | |
Dominic Mazzoni | ccbaa9b | 2018-06-06 07:44:23 | [diff] [blame] | 37 | std::string AXEvent::ToString() const { |
Nektarios Paisios | b349b65 | 2020-06-18 12:39:05 | [diff] [blame] | 38 | std::string result = "AXEvent "; |
Dominic Mazzoni | ccbaa9b | 2018-06-06 07:44:23 | [diff] [blame] | 39 | |
| 40 | result += ui::ToString(event_type); |
| 41 | result += " on node id=" + base::NumberToString(id); |
| 42 | if (event_from != ax::mojom::EventFrom::kNone) |
| 43 | result += std::string(" from ") + ui::ToString(event_from); |
Akihiro Ota | dacc8a5 | 2021-03-16 02:25:38 | [diff] [blame] | 44 | if (event_from_action != ax::mojom::Action::kNone) |
| 45 | result += std::string(" from accessibility action ") + |
| 46 | ui::ToString(event_from_action); |
Nektarios Paisios | 488275d | 2020-04-25 04:56:37 | [diff] [blame] | 47 | if (!event_intents.empty()) { |
| 48 | result += " caused by [ "; |
| 49 | for (const AXEventIntent& intent : event_intents) { |
| 50 | result += intent.ToString() + ' '; |
| 51 | } |
| 52 | result += ']'; |
| 53 | } |
Dominic Mazzoni | ccbaa9b | 2018-06-06 07:44:23 | [diff] [blame] | 54 | if (action_request_id) |
| 55 | result += " action_request_id=" + base::NumberToString(action_request_id); |
| 56 | return result; |
| 57 | } |
| 58 | |
| 59 | } // namespace ui |