• Benjamin Beaudry's avatar
    Fix DCHECK in AXPosition::CompareTo with rich text fields · 67487b0d
    Benjamin Beaudry authored
    An accessible node that represents generated content (e.g., the ::before
    selector) is completely ignored in AXNodePosition::MaxTextOffset and
    AXNodePosition::GetText. Both methods return the
    ax::mojom::StringAttribute::kValue's length and value, respectively.
    Since this attribute's value doesn't include the value of the generated
    content (because this generated content is either before or after the
    main content of the text field), we return a wrong maximum text offset
    and text.
    
    To fix this, we should only use ax::mojom::StringAttribute::kValue's
    length and value when the node has no child. When a node has a child, we
    need to compute the maximum text offset by summing the maximum text
    offset values of all of its children. The same applies for
    AXNodePosition::GetText.
    
    Bug: 928948
    Change-Id: I624779a3e372d19ac2036de09fe9dbf1c4892867
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2037965
    Commit-Queue: Benjamin Beaudry <benjamin.beaudry@microsoft.com>
    Reviewed-by: default avatarNektarios Paisios <nektar@chromium.org>
    Reviewed-by: default avatarKurt Catti-Schmidt <kschmi@microsoft.com>
    Cr-Commit-Position: refs/heads/master@{#739228}
    67487b0d
ax_node_position.cc 10.8 KB