Commit 92971c16 authored by Adam Ettenberger's avatar Adam Ettenberger Committed by Commit Bot

Performance improvement in UpdateComputedHypertext

AXPlatformNodeBase::UpdateComputedHypertext was using an expensive path
to navigate unignored children. Replacing use of |ChildAtIndex| with
|GetFirstChild| and |GetNextSibling| when iterating unignored children.

Now instead of having to walk over all children up to the Nth unignored
child for each iteration, it will find the first unignored child, then
chain finding each unignored sibling.

For the scenario I was measuring, this CL reduced the overall amount
of time spent in AXTree::Unserialize by ~77%, and time spent in
AXPlatformNodeBase::UpdateComputedHypertext by ~90%!

I crafted a document where loading the document resulted in Unserialize
having to process ~40k AXNodeData items in one AXTreeUpdate.

I used "UI for ETW" to capture perf traces, and WPA to view the data.

Before :
  * Weight in callstack of AXTree::Unserialize : 6424
  * Weight in callstack of UpdateComputedHypertext : 5449

After :
  * Weight in callstack of AXTree::Unserialize : 1457
  * Weight in callstack of UpdateComputedHypertext : 447

Bug: 1017829
Change-Id: I0edd29f4bba4811942a96c4f65fa96401dd10cea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1879767Reviewed-by: default avatarKurt Catti-Schmidt <kschmi@microsoft.com>
Reviewed-by: default avatarNektarios Paisios <nektar@chromium.org>
Commit-Queue: Nektarios Paisios <nektar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709956}
parent 8d74bc2a
...@@ -1139,9 +1139,7 @@ void AXPlatformNodeBase::UpdateComputedHypertext() { ...@@ -1139,9 +1139,7 @@ void AXPlatformNodeBase::UpdateComputedHypertext() {
return; return;
} }
int child_count = GetChildCount(); if (!GetChildCount()) {
if (!child_count) {
if (IsRichTextField()) { if (IsRichTextField()) {
// We don't want to expose any associated label in IA2 Hypertext. // We don't want to expose any associated label in IA2 Hypertext.
return; return;
...@@ -1157,10 +1155,8 @@ void AXPlatformNodeBase::UpdateComputedHypertext() { ...@@ -1157,10 +1155,8 @@ void AXPlatformNodeBase::UpdateComputedHypertext() {
// the character index of each embedded object character to the id of the // the character index of each embedded object character to the id of the
// child object it points to. // child object it points to.
base::string16 hypertext; base::string16 hypertext;
for (int i = 0; i < child_count; ++i) { for (AXPlatformNodeBase* child = GetFirstChild(); child;
const auto* child = FromNativeViewAccessible(ChildAtIndex(i)); child = child->GetNextSibling()) {
DCHECK(child);
// Similar to Firefox, we don't expose text-only objects in IA2 hypertext. // Similar to Firefox, we don't expose text-only objects in IA2 hypertext.
if (child->IsTextOnlyObject()) { if (child->IsTextOnlyObject()) {
hypertext_.hypertext += hypertext_.hypertext +=
......
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