Commit d2f373aa authored by Aaron Leventhal's avatar Aaron Leventhal Committed by Chromium LUCI CQ

Cache correct parent for AXObject of inline text boxes

When an AXInlineTextBox::NextOnLine()/PrevOnLine() is used, the parent
of any newly created AXInlineTextBox is not necessarily going to be
the same one. Compute the correct parent in all cases.

Addresses DCHECKs that are triggered in text-overflow:ellipsis cases.

Bug: 1168643
Change-Id: Ib41bc4617bee4761ccad35ad94ab33fb8be4ab43
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2639167Reviewed-by: default avatarNektarios Paisios <nektar@chromium.org>
Commit-Queue: Aaron Leventhal <aleventhal@chromium.org>
Auto-Submit: Aaron Leventhal <aleventhal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#846087}
parent 1c42fa01
......@@ -329,6 +329,11 @@ IN_PROC_BROWSER_TEST_P(DumpAccessibilityTreeTest,
RunCSSTest(FILE_PATH_LITERAL("display-to-block.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityTreeTest,
AccessibilityCSSTextOverflowEllipsis) {
RunCSSTest(FILE_PATH_LITERAL("text-overflow-ellipsis.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityTreeTest,
AccessibilityCSSInlinePositionRelative) {
RunCSSTest(FILE_PATH_LITERAL("inline-position-relative.html"));
......
rootWebArea
++genericContainer ignored
++++genericContainer ignored
++++++genericContainer
++++++++staticText name='SPAN NESTED INSIDE DIV'
++++++++++inlineTextBox name='SPAN NESTED INSIDE DIV'
++++++++++inlineTextBox name='SPAN NESTED INS'
++++++++++inlineTextBox name='…'
++++++++staticText name=' CONTAINER DIV'
++++++++++inlineTextBox name=' CONTAINER DIV'
<style>
div {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
width: 400px;
}
div, span {
outline: 1px solid;
font-size: 40px;
font-family: monospace;
}
</style>
<div><span>SPAN NESTED INSIDE DIV</span> CONTAINER DIV</div>
......@@ -200,7 +200,7 @@ AXObject* AXInlineTextBox::NextOnLine() const {
scoped_refptr<AbstractInlineTextBox> next_on_line =
inline_text_box_->NextOnLine();
if (next_on_line)
return AXObjectCache().GetOrCreate(next_on_line.get(), parent_);
return AXObjectCache().GetOrCreate(next_on_line.get(), nullptr);
return nullptr;
}
......@@ -215,7 +215,7 @@ AXObject* AXInlineTextBox::PreviousOnLine() const {
scoped_refptr<AbstractInlineTextBox> previous_on_line =
inline_text_box_->PreviousOnLine();
if (previous_on_line)
return AXObjectCache().GetOrCreate(previous_on_line.get(), parent_);
return AXObjectCache().GetOrCreate(previous_on_line.get(), nullptr);
return nullptr;
}
......
......@@ -721,14 +721,17 @@ AXObject* AXObjectCacheImpl::GetOrCreate(AbstractInlineTextBox* inline_text_box,
if (!inline_text_box)
return nullptr;
DCHECK(parent);
if (!parent) {
Node* text_parent = inline_text_box->GetLineLayoutItem().GetNode();
DCHECK(text_parent);
DCHECK(IsA<Text>(text_parent));
parent = GetOrCreate(text_parent);
DCHECK(parent);
}
if (AXObject* obj = Get(inline_text_box)) {
if (obj->CachedParentObject()) {
// It is possible that the parent AXObject has changed, but the related
// text node will be the same.
// TODO(alventhal) When is the cached parent different?
if (obj->CachedParentObject())
DCHECK_EQ(obj->CachedParentObject()->GetNode(), parent->GetNode());
}
obj->SetParent(parent);
return obj;
}
......
......@@ -195,7 +195,7 @@ class MODULES_EXPORT AXObjectCacheImpl
AXObject* GetOrCreate(Node*, AXObject* parent_if_known);
AXObject* GetOrCreate(Node*);
AXObject* GetOrCreate(const Node*);
AXObject* GetOrCreate(AbstractInlineTextBox*, AXObject* parent);
AXObject* GetOrCreate(AbstractInlineTextBox*, AXObject* parent_if_known);
AXID GetAXID(Node*) override;
Element* GetElementFromAXID(AXID) override;
......
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