Commit 1e151ae3 authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Chromium LUCI CQ

[a11y] Update DCHECK on GetTextContainerForPlainTextField()

This CL updates DCHECK for checking the child count of the text
field on GetTextContainerForPlainTextField(). The text field
could have a sibling of the static text when it has a
placeholder break element. So, this change increases the child
count.

AX-Relnotes: n/a

Bug: 1137292
Change-Id: Ib6d6826ce23156e8d5562d9561ad8061d46b6946
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2578718
Commit-Queue: Julie Kim <jkim@igalia.com>
Reviewed-by: default avatarAaron Leventhal <aleventhal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836355}
parent fdbb2b4f
......@@ -2157,4 +2157,20 @@ IN_PROC_BROWSER_TEST_F(AccessibilityAuraLinuxBrowserTest,
}
}
// Tests if it does not DCHECK when textarea has a placeholder break element.
IN_PROC_BROWSER_TEST_F(AccessibilityAuraLinuxBrowserTest,
TestGetTextContainerFromTextArea) {
std::string content = std::string("<textarea style=\"height:100px;\">hello") +
std::string("\n") + std::string("</textarea>");
LoadInitialAccessibilityTreeFromHtml(content);
AtkText* atk_text = FindNode(ATK_ROLE_ENTRY);
AtkTextRectangle atk_rect;
// atk_text_get_range_extents() calls GetTextContainerForPlainTextField() and
// DCHECK on checking children counts.
atk_text_get_range_extents(atk_text, 0, 7, AtkCoordType::ATK_XY_SCREEN,
&atk_rect);
g_object_unref(atk_text);
}
} // namespace content
......@@ -64,10 +64,12 @@ const BrowserAccessibility* GetTextContainerForPlainTextField(
// ---- Generic container (optional, only occurs in some controls)
// ------ Static text <-- (optional, does not exist if field is empty)
// -------- Inline text box children (can be multiple)
// ------ Line Break (optional, a placeholder break element if the text data
// ends with '\n' or '\r')
// This method will return the lowest generic container.
const BrowserAccessibility* child = text_field.InternalGetFirstChild();
DCHECK_EQ(child->GetRole(), ax::mojom::Role::kGenericContainer);
DCHECK_LE(child->InternalChildCount(), 1u);
DCHECK_LE(child->InternalChildCount(), 2u);
if (child->InternalChildCount() == 1) {
const BrowserAccessibility* grand_child = child->InternalGetFirstChild();
if (grand_child->GetRole() == ax::mojom::Role::kGenericContainer) {
......
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