Commit d2b8afa2 authored by Martin Robinson's avatar Martin Robinson Committed by Commit Bot

Fix crash in spelling attribute computation for AXPlatformNodeAuraLinux

AXNodeRange can include the node that we are currently calculating
spelling attributes for, so we should be careful to avoid infinite
recursion here.

Bug: 987675
Change-Id: If3a85191e70edb87f26166fe0e043d58715ae494
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1720869Reviewed-by: default avatarJoanmarie Diggs <jdiggs@igalia.com>
Commit-Queue: Martin Robinson <mrobinson@igalia.com>
Cr-Commit-Position: refs/heads/master@{#681730}
parent 1f56d90b
...@@ -970,4 +970,30 @@ IN_PROC_BROWSER_TEST_F(AccessibilityAuraLinuxBrowserTest, ...@@ -970,4 +970,30 @@ IN_PROC_BROWSER_TEST_F(AccessibilityAuraLinuxBrowserTest,
g_object_unref(text); g_object_unref(text);
} }
IN_PROC_BROWSER_TEST_F(AccessibilityAuraLinuxBrowserTest,
TextAttributesInInputWithAriaHidden) {
LoadInitialAccessibilityTreeFromHtml(std::string(
R"HTML(<!DOCTYPE html>
<html>
<body>
<input aria-hidden="true">
</body>
</html>)HTML"));
AtkObject* document = GetRendererAccessible();
EXPECT_EQ(1, atk_object_get_n_accessible_children(document));
AtkObject* section = atk_object_ref_accessible_child(document, 0);
AtkText* input_element =
ATK_TEXT(atk_object_ref_accessible_child(section, 0));
AtkAttributeSet* attributes =
atk_text_get_run_attributes(input_element, 0, nullptr, nullptr);
ASSERT_NE(attributes, nullptr);
atk_attribute_set_free(attributes);
g_object_unref(input_element);
g_object_unref(section);
}
} // namespace content } // namespace content
...@@ -4169,6 +4169,12 @@ void AXPlatformNodeAuraLinux::MergeSpellingIntoAtkTextAttributesAtOffset( ...@@ -4169,6 +4169,12 @@ void AXPlatformNodeAuraLinux::MergeSpellingIntoAtkTextAttributesAtOffset(
<< "An leaf text range should only span a single object."; << "An leaf text range should only span a single object.";
auto* node = static_cast<AXPlatformNodeAuraLinux*>( auto* node = static_cast<AXPlatformNodeAuraLinux*>(
delegate->GetFromNodeID(leaf_text_range.anchor()->GetAnchor()->id())); delegate->GetFromNodeID(leaf_text_range.anchor()->GetAnchor()->id()));
// The AXNodeRange may include this node as well. We need to skip
// that one to avoid an infinite recursive loop.
if (node == this)
continue;
node->MergeSpellingIntoAtkTextAttributesAtOffset(anchor_start_offset, node->MergeSpellingIntoAtkTextAttributesAtOffset(anchor_start_offset,
text_attributes); text_attributes);
anchor_start_offset += leaf_text_range.GetText().length(); anchor_start_offset += leaf_text_range.GetText().length();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment