Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(386)

Unified Diff: ui/accessibility/ax_position.h

Issue 2745713002: WIP: Modified AXPosition to work with objects with both embedded object characters and text. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
« content/browser/accessibility/ax_platform_position.cc ('K') | « ui/accessibility/ax_node.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698