ax_event.cc 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright 2018 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. #include "ui/accessibility/ax_event.h"
  5. #include "base/strings/string_number_conversions.h"
  6. #include "ui/accessibility/ax_enum_util.h"
  7. namespace ui {
  8. AXEvent::AXEvent() = default;
  9. AXEvent::AXEvent(AXNodeData::AXID id,
  10. ax::mojom::Event event_type,
  11. ax::mojom::EventFrom event_from,
  12. ax::mojom::Action event_from_action,
  13. const std::vector<AXEventIntent>& event_intents,
  14. int action_request_id)
  15. : id(id),
  16. event_type(event_type),
  17. event_from(event_from),
  18. event_from_action(event_from_action),
  19. event_intents(event_intents),
  20. action_request_id(action_request_id) {}
  21. AXEvent::~AXEvent() = default;
  22. AXEvent::AXEvent(const AXEvent& event) = default;
  23. AXEvent& AXEvent::operator=(const AXEvent& event) = default;
  24. std::string AXEvent::ToString() const {
  25. std::string result = "AXEvent ";
  26. result += ui::ToString(event_type);
  27. result += " on node id=" + base::NumberToString(id);
  28. if (event_from != ax::mojom::EventFrom::kNone)
  29. result += std::string(" from ") + ui::ToString(event_from);
  30. if (event_from_action != ax::mojom::Action::kNone)
  31. result += std::string(" from accessibility action ") +
  32. ui::ToString(event_from_action);
  33. if (!event_intents.empty()) {
  34. result += " caused by [ ";
  35. for (const AXEventIntent& intent : event_intents) {
  36. result += intent.ToString() + ' ';
  37. }
  38. result += ']';
  39. }
  40. if (action_request_id)
  41. result += " action_request_id=" + base::NumberToString(action_request_id);
  42. return result;
  43. }
  44. } // namespace ui