summaryrefslogtreecommitdiff
path: root/chromium/ui/accessibility/ax_node_data.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-12 14:27:29 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-13 09:35:20 +0000
commitc30a6232df03e1efbd9f3b226777b07e087a1122 (patch)
treee992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/ui/accessibility/ax_node_data.cc
parent7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff)
downloadqtwebengine-chromium-85-based.tar.gz
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/ui/accessibility/ax_node_data.cc')
-rw-r--r--chromium/ui/accessibility/ax_node_data.cc49
1 files changed, 33 insertions, 16 deletions
diff --git a/chromium/ui/accessibility/ax_node_data.cc b/chromium/ui/accessibility/ax_node_data.cc
index 1780711a1ae..789e9e01feb 100644
--- a/chromium/ui/accessibility/ax_node_data.cc
+++ b/chromium/ui/accessibility/ax_node_data.cc
@@ -570,17 +570,42 @@ AXNodeTextStyles AXNodeData::GetTextStyles() const {
}
void AXNodeData::SetName(const std::string& name) {
+ DCHECK_NE(role, ax::mojom::Role::kNone)
+ << "A valid role is required before setting the name attribute, because "
+ "the role is used for setting the required NameFrom attribute.";
+
auto iter = std::find_if(string_attributes.begin(), string_attributes.end(),
[](const auto& string_attribute) {
return string_attribute.first ==
ax::mojom::StringAttribute::kName;
});
+
if (iter == string_attributes.end()) {
string_attributes.push_back(
std::make_pair(ax::mojom::StringAttribute::kName, name));
} else {
iter->second = name;
}
+
+ if (HasIntAttribute(ax::mojom::IntAttribute::kNameFrom))
+ return;
+ // Since this method is mostly used by tests which don't always set the
+ // "NameFrom" attribute, we need to set it here to the most likely value if
+ // not set, otherwise code that tries to calculate the node's inner text, its
+ // hypertext, or even its value, might not know whether to include the name in
+ // the result or not.
+ //
+ // For example, if there is a text field, but it is empty, i.e. it has no
+ // value, its value could be its name if "NameFrom" is set to "kPlaceholder"
+ // or to "kContents" but not if it's set to "kAttribute". Similarly, if there
+ // is a button without any unignored children, it's name can only be
+ // equivalent to its inner text if "NameFrom" is set to "kContents" or to
+ // "kValue", but not if it is set to "kAttribute".
+ if (IsText(role)) {
+ SetNameFrom(ax::mojom::NameFrom::kContents);
+ } else {
+ SetNameFrom(ax::mojom::NameFrom::kAttribute);
+ }
}
void AXNodeData::SetName(const base::string16& name) {
@@ -729,7 +754,7 @@ ax::mojom::CheckedState AXNodeData::GetCheckedState() const {
}
void AXNodeData::SetCheckedState(ax::mojom::CheckedState checked_state) {
- if (HasIntAttribute(ax::mojom::IntAttribute::kCheckedState))
+ if (HasCheckedState())
RemoveIntAttribute(ax::mojom::IntAttribute::kCheckedState);
if (checked_state != ax::mojom::CheckedState::kNone) {
AddIntAttribute(ax::mojom::IntAttribute::kCheckedState,
@@ -737,6 +762,10 @@ void AXNodeData::SetCheckedState(ax::mojom::CheckedState checked_state) {
}
}
+bool AXNodeData::HasCheckedState() const {
+ return HasIntAttribute(ax::mojom::IntAttribute::kCheckedState);
+}
+
ax::mojom::DefaultActionVerb AXNodeData::GetDefaultActionVerb() const {
return static_cast<ax::mojom::DefaultActionVerb>(
GetIntAttribute(ax::mojom::IntAttribute::kDefaultActionVerb));
@@ -1001,21 +1030,6 @@ bool AXNodeData::SupportsExpandCollapse() const {
return ui::SupportsExpandCollapse(role);
}
-bool AXNodeData::IsContainedInActiveLiveRegion() const {
- if (!HasStringAttribute(ax::mojom::StringAttribute::kContainerLiveStatus))
- return false;
-
- if (base::CompareCaseInsensitiveASCII(
- GetStringAttribute(ax::mojom::StringAttribute::kContainerLiveStatus),
- "off") == 0)
- return false;
-
- if (GetBoolAttribute(ax::mojom::BoolAttribute::kContainerLiveBusy))
- return false;
-
- return true;
-}
-
std::string AXNodeData::ToString() const {
std::string result;
@@ -1539,6 +1553,9 @@ std::string AXNodeData::ToString() const {
case ax::mojom::BoolAttribute::kSelected:
result += " selected=" + value;
break;
+ case ax::mojom::BoolAttribute::kSelectedFromFocus:
+ result += " selected_from_focus=" + value;
+ break;
case ax::mojom::BoolAttribute::kSupportsTextLocation:
result += " supports_text_location=" + value;
break;