blob: 2b3dfb9db47b783c1c29dfb402c2085509038ba7 [file] [log] [blame]
Avi Drissman3e1a26c2022-09-15 20:26:031// Copyright 2018 The Chromium Authors
Dominic Mazzoniccbaa9b2018-06-06 07:44:232// 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 Mazzoniccbaa9b2018-06-06 07:44:239
10namespace ui {
11
Nektarios Paisios56ee9982020-04-22 07:53:0612AXEvent::AXEvent() = default;
13
Nektarios Paisios488275d2020-04-25 04:56:3714AXEvent::AXEvent(AXNodeData::AXID id,
Nektarios Paisios56ee9982020-04-22 07:53:0615 ax::mojom::Event event_type,
16 ax::mojom::EventFrom event_from,
Akihiro Otadacc8a52021-03-16 02:25:3817 ax::mojom::Action event_from_action,
Nektarios Paisios488275d2020-04-25 04:56:3718 const std::vector<AXEventIntent>& event_intents,
Nektarios Paisios56ee9982020-04-22 07:53:0619 int action_request_id)
20 : id(id),
21 event_type(event_type),
22 event_from(event_from),
Akihiro Otadacc8a52021-03-16 02:25:3823 event_from_action(event_from_action),
Nektarios Paisios488275d2020-04-25 04:56:3724 event_intents(event_intents),
Nektarios Paisios56ee9982020-04-22 07:53:0625 action_request_id(action_request_id) {}
Dominic Mazzoniccbaa9b2018-06-06 07:44:2326
James Cook36cab7c2019-10-29 23:26:4027AXEvent::~AXEvent() = default;
Dominic Mazzoniccbaa9b2018-06-06 07:44:2328
David Tseng90252142024-04-01 17:36:4329AXEvent::AXEvent(AXEvent&& other) = default;
30
31AXEvent& AXEvent::operator=(AXEvent&& other) = default;
32
Nektarios Paisios56ee9982020-04-22 07:53:0633AXEvent::AXEvent(const AXEvent& event) = default;
34
35AXEvent& AXEvent::operator=(const AXEvent& event) = default;
36
Dominic Mazzoniccbaa9b2018-06-06 07:44:2337std::string AXEvent::ToString() const {
Nektarios Paisiosb349b652020-06-18 12:39:0538 std::string result = "AXEvent ";
Dominic Mazzoniccbaa9b2018-06-06 07:44:2339
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 Otadacc8a52021-03-16 02:25:3844 if (event_from_action != ax::mojom::Action::kNone)
45 result += std::string(" from accessibility action ") +
46 ui::ToString(event_from_action);
Nektarios Paisios488275d2020-04-25 04:56:3747 if (!event_intents.empty()) {
48 result += " caused by [ ";
49 for (const AXEventIntent& intent : event_intents) {
50 result += intent.ToString() + ' ';
51 }
52 result += ']';
53 }
Dominic Mazzoniccbaa9b2018-06-06 07:44:2354 if (action_request_id)
55 result += " action_request_id=" + base::NumberToString(action_request_id);
56 return result;
57}
58
59} // namespace ui