summaryrefslogtreecommitdiff
path: root/chromium/ui/accessibility/ax_action_data.cc
blob: 8b9dbbef3c6934b03b7e369d72d6eda5433f4713 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/accessibility/ax_action_data.h"

#include <set>

#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"

using base::IntToString;

namespace ui {

AXActionData::AXActionData()
    : action(AX_ACTION_NONE),
      target_node_id(-1),
      flags(0),
      anchor_node_id(-1),
      anchor_offset(-1),
      focus_node_id(-1),
      focus_offset(-1) {
}

AXActionData::AXActionData(const AXActionData& other) = default;

AXActionData::~AXActionData() {
}

// Note that this includes an initial space character if nonempty, but
// that works fine because this is normally printed by AXAction::ToString.
std::string AXActionData::ToString() const {
  std::string result = ui::ToString(action);

  if (target_node_id != -1)
    result += " target_node_id=" + IntToString(target_node_id);

  if (flags & (1 << ui::AX_ACTION_FLAGS_REQUEST_IMAGES))
    result += " flag_request_images";

  if (flags & (1 << ui::AX_ACTION_FLAGS_REQUEST_INLINE_TEXT_BOXES))
    result += " flag_request_inline_text_boxes";

  if (anchor_node_id != -1) {
    result += " anchor_node_id=" + IntToString(anchor_node_id);
    result += " anchor_offset=" + IntToString(anchor_offset);
  }
  if (focus_node_id != -1) {
    result += " focus_node_id=" + IntToString(focus_node_id);
    result += " focus_offset=" + IntToString(focus_offset);
  }

  return result;
}

}  // namespace ui