• Adam Ettenberger's avatar
    Performance improvement for ITextRangeProvider::GetEnclosingElement · 86af2537
    Adam Ettenberger authored
    This change is an optimizaiton for UIAs GetEnclosingElement.
    
    The cost was in calling |LowestCommonAncestor| because it would compute
    multiple parent AXPositions until reaching the common anchor. Creating
    a parent Text position is expensive because it calls |MaxTextOffset|.
    
    GetEnclosingElement didn't need an AXPosition so to reduce that cost
    a new method |LowestCommonAnchor| has been added which returns the
    AXNodeType* that we can use to find the relevant AXPlatformNodeDelegate
    to do our work on. |LowestCommonAnchor| may also be used to optimize
    other similar APIs which don't necessarily need an AXPosition object.
    
    In order to derive the AXTreeID which is necessary to find the correct
    AXPlatformNodeDelegate, AXNode::OwnerTree now exposes its AXTreeID.
    This way we can know what the AXTreeID is for an AXNode of an
    AXNodePosition anchor. This is already easily accessible from the other
    position type BrowserAccessibilityPosition, since BrowserAccessibility
    has access to the relevant AXTreeData. Now anchors of  both position
    types can know what the relevant AXTreeID is for creating delegates!
    
    I measured the perf difference with std::chrono::high_resolution_clock
    on an unoptimized debug build.
    With a document that contains 2 columns of 100 divs each, and a single
    leaf text child in each column, and a text range that spans between the
    two columns.
    
    Without Patch :
    439.006ms
    
    With Patch :
    0.1371ms
    
    Bug: 928948
    Change-Id: Ic9648ff34c7c7030c299c8484fb188a873e3af92
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1790066
    Commit-Queue: Adam Ettenberger <adettenb@microsoft.com>
    Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
    Reviewed-by: default avatarKurt Catti-Schmidt <kschmi@microsoft.com>
    Cr-Commit-Position: refs/heads/master@{#697344}
    86af2537
ax_position.h 112 KB