Commit 3f3d9cc5 authored by Benjamin Beaudry's avatar Benjamin Beaudry Committed by Commit Bot

Reland "Do not return InlineTextBox nodes from UIA GetEnclosingElement"

This is a reland of 507f4ee8

It seems like CL:1935027 caused the failures and the revert. Once this change
relands with a fix (CL:1935212), I'll reland this one.

Original change's description:
> Do not return InlineTextBox nodes from UIA GetEnclosingElement
>
> In AXPlatformNodeTextRangeProviderWin, nodes with role kInlineTextBox
> should never be exposed to UIA. This CL introduces a simple fix.
>
> In GetEnclosingElement(), if the enclosing node is an inline text box,
> we simply return its parent. I also updated a unit test for this case.
>
> Bug: 928948
> Change-Id: I31a31566461c3091bed36ebad626c4f51afc55a3
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1931753
> Commit-Queue: Benjamin Beaudry <benjamin.beaudry@microsoft.com>
> Reviewed-by: Kurt Catti-Schmidt <kschmi@microsoft.com>
> Cr-Commit-Position: refs/heads/master@{#718920}

Bug: 928948
Change-Id: I6dbac3eae0a17d29f13c3d6b75532018729782de
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1937134Reviewed-by: default avatarKurt Catti-Schmidt <kschmi@microsoft.com>
Commit-Queue: Benjamin Beaudry <benjamin.beaudry@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#719387}
parent 8985a8ce
......@@ -559,7 +559,8 @@ STDMETHODIMP AXPlatformNodeTextRangeProviderWin::GetEnclosingElement(
enclosing_node = enclosing_node->GetLowestAccessibleElement();
DCHECK(enclosing_node);
while (ui::IsIgnored(enclosing_node->GetData())) {
while (ui::IsIgnored(enclosing_node->GetData()) ||
enclosing_node->GetData().role == ax::mojom::Role::kInlineTextBox) {
AXPlatformNodeWin* parent = static_cast<AXPlatformNodeWin*>(
AXPlatformNode::FromNativeViewAccessible(enclosing_node->GetParent()));
DCHECK(parent);
......
......@@ -2841,14 +2841,17 @@ TEST_F(AXPlatformNodeTextRangeProviderTest,
ComPtr<IRawElementProviderSimple> link_node_raw =
QueryInterfaceFromNode<IRawElementProviderSimple>(link_node);
ComPtr<IRawElementProviderSimple> static_text_node_raw1 =
QueryInterfaceFromNode<IRawElementProviderSimple>(static_text_node1);
ComPtr<IRawElementProviderSimple> inline_text_node_raw1 =
QueryInterfaceFromNode<IRawElementProviderSimple>(inline_text_node1);
ComPtr<IRawElementProviderSimple> inline_text_node_raw2 =
QueryInterfaceFromNode<IRawElementProviderSimple>(inline_text_node2);
// Test GetEnclosingElement for the two leaves text nodes. The enclosing
// element of the first one should be itself and the enclosing element for the
// text node that is grandchild of the link node should return the link node.
// element of the first one should be its static text parent (because inline
// text boxes shouldn't be exposed) and the enclosing element for the text
// node that is grandchild of the link node should return the link node.
ComPtr<ITextProvider> text_provider;
EXPECT_HRESULT_SUCCEEDED(inline_text_node_raw1->GetPatternProvider(
UIA_TextPatternId, &text_provider));
......@@ -2860,7 +2863,7 @@ TEST_F(AXPlatformNodeTextRangeProviderTest,
ComPtr<IRawElementProviderSimple> enclosing_element;
EXPECT_HRESULT_SUCCEEDED(
text_range_provider->GetEnclosingElement(&enclosing_element));
EXPECT_EQ(inline_text_node_raw1.Get(), enclosing_element.Get());
EXPECT_EQ(static_text_node_raw1.Get(), enclosing_element.Get());
EXPECT_HRESULT_SUCCEEDED(inline_text_node_raw2->GetPatternProvider(
UIA_TextPatternId, &text_provider));
......
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