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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_ACCESSIBILITY_PLATFORM_INSPECT_AX_INSPECT_H_
#define UI_ACCESSIBILITY_PLATFORM_INSPECT_AX_INSPECT_H_
#include <string>
#include "base/component_export.h"
#include "ui/gfx/native_widget_types.h"
namespace ui {
// Tree selector used to identify an accessible tree to traverse, it can be
// built by a pre-defined tree type like Chromium to indicate that Chromium
// browser tree should be traversed and/or by a string pattern which matches
// an accessible name of a root of some accessible subtree.
struct COMPONENT_EXPORT(AX_PLATFORM) AXTreeSelector {
enum Type {
None = 0,
// Browsers
Chrome = 1 << 0,
Chromium = 1 << 1,
Edge = 1 << 2,
Firefox = 1 << 3,
Safari = 1 << 4,
// Tree selectors
ActiveTab = 1 << 5,
IDOrClass = 1 << 6,
};
int types{None};
std::string pattern;
gfx::AcceleratedWidget widget{0};
AXTreeSelector() = default;
explicit AXTreeSelector(gfx::AcceleratedWidget widget) : widget(widget) {}
AXTreeSelector(gfx::AcceleratedWidget widget, int filter)
: types(filter), widget(widget) {}
AXTreeSelector(int types, const std::string& pattern)
: types(types), pattern(pattern) {}
AXTreeSelector(int types,
const std::string& pattern,
gfx::AcceleratedWidget widget)
: types(types), pattern(pattern), widget(widget) {}
AXTreeSelector(const AXTreeSelector&) = default;
AXTreeSelector& operator=(const AXTreeSelector&) = default;
bool empty() const {
return (types & ~(ActiveTab)) == None && widget == 0 && pattern.empty();
}
// Returns an application name for a type if the type specifies an
// application.
std::string AppName() const;
};
// A single property filter specification. Represents a parsed string of the
// filter_str;match_str format, where `filter_str` has
// :line_num_0,...:line_num_N format, `match_str` has format of
// property_str=value_str, value_str is optional. For example,
// AXSubrole=* or :1,:3;AXDOMClassList.
//
// Longer version: `filter_str` is a comma separated list of the line
// indexes from the output accessible tree, and serves to narrow down the
// property calls to the accessible object placed on those line indexes only;
// `match_str` is used to match properties by property name and value.
// For example, :1,:3;AXDOMClassList=*
// will query a AXDOMClassList attribute on accessible objects placed at 1st
// and 3rd lines in the output accessible tree.
// Also see AXInspectScenario::From() for more information.
struct COMPONENT_EXPORT(AX_PLATFORM) AXPropertyFilter {
enum Type { ALLOW, ALLOW_EMPTY, DENY, SCRIPT };
std::string match_str;
std::string property_str;
std::string filter_str;
Type type;
AXPropertyFilter(const std::string& str, Type type);
AXPropertyFilter(const AXPropertyFilter&);
AXPropertyFilter& operator=(const AXPropertyFilter&);
};
// A single node filter specification which will exclude any node where the
// value of the named property matches the given pattern.
//
// This can be used to exclude nodes based on properties like role, for
// example to exclude all inlineTextBox nodes under blink we would use a
// NodeFilter of the form:
// {property='internalRole', pattern='inlineTextBox'};
struct COMPONENT_EXPORT(AX_PLATFORM) AXNodeFilter {
std::string property;
std::string pattern;
AXNodeFilter(const std::string& property, const std::string& pattern)
: property(property), pattern(pattern) {}
};
} // namespace ui
#endif // UI_ACCESSIBILITY_PLATFORM_INSPECT_AX_INSPECT_H_
|