| Index: ui/accessibility/ax_position.h
|
| diff --git a/ui/accessibility/ax_position.h b/ui/accessibility/ax_position.h
|
| index 8a1cf0dbffc765c3c2acebdcedaec996b7e2ea34..4c5e3ecd7cdbb1c6a039d7c9b791e6d6e3ebdb12 100644
|
| --- a/ui/accessibility/ax_position.h
|
| +++ b/ui/accessibility/ax_position.h
|
| @@ -278,13 +278,14 @@ class AXPosition {
|
| for (int i = 0; i < copy->AnchorChildCount(); ++i) {
|
| AXPositionInstance child = copy->CreateChildPositionAt(i);
|
| DCHECK(child);
|
| + int child_length = child->MaxTextOffsetInParent();
|
| if (copy->text_offset_ >= current_offset &&
|
| - copy->text_offset_ < (current_offset + child->MaxTextOffset())) {
|
| + copy->text_offset_ < (current_offset + child_length)) {
|
| copy->child_index_ = i;
|
| break;
|
| }
|
|
|
| - current_offset += child->MaxTextOffset();
|
| + current_offset += child_length;
|
| }
|
| }
|
|
|
| @@ -314,21 +315,22 @@ class AXPosition {
|
| for (int i = 0; i <= child_index_; ++i) {
|
| AXPositionInstance child = copy->CreateChildPositionAt(i);
|
| DCHECK(child);
|
| + int child_length = child->MaxTextOffsetInParent();
|
|
|
| // If the current text offset is valid, we don't touch it.
|
| // Otherwise, we reset it to the beginning of the current child node.
|
| if (i == child_index_ &&
|
| (copy->text_offset_ < new_offset ||
|
| - copy->text_offset_ > (new_offset + child->MaxTextOffset()) ||
|
| + copy->text_offset_ > (new_offset + child_length) ||
|
| // When the text offset is equal to the text's length but this is
|
| // not an "after text" position.
|
| (!copy->AtEndOfAnchor() &&
|
| - copy->text_offset_ == (new_offset + child->MaxTextOffset())))) {
|
| + copy->text_offset_ == (new_offset + child_length)))) {
|
| copy->text_offset_ = new_offset;
|
| break;
|
| }
|
|
|
| - new_offset += child->MaxTextOffset();
|
| + new_offset += child_length;
|
| }
|
| }
|
|
|
| @@ -1042,8 +1044,12 @@ class AXPosition {
|
| virtual void AnchorParent(int* tree_id, int32_t* parent_id) const = 0;
|
| virtual AXNodeType* GetNodeInTree(int tree_id, int32_t node_id) const = 0;
|
| // Returns the length of the text that is present inside the anchor node,
|
| - // including any text found in descendant nodes.
|
| + // including any text found in descendant text nodes.
|
| virtual int MaxTextOffset() const = 0;
|
| + // Returns the length of text that this anchor node takes up in its parent.
|
| + // On some platforms, embedded objects are represented in their parent with a
|
| + // single embedded object character.
|
| + virtual int MaxTextOffsetInParent() const { return MaxTextOffset(); }
|
| virtual bool IsInLineBreak() const = 0;
|
| virtual std::vector<int32_t> GetWordStartOffsets() const = 0;
|
| virtual std::vector<int32_t> GetWordEndOffsets() const = 0;
|
|
|