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

Unified Diff: Source/modules/accessibility/AXObject.h

Issue 1185343003: Implements the ability to get and set the caret position and the current selection from anywhere in… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed some compiler errors. Created 5 years, 6 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: Source/modules/accessibility/AXObject.h
diff --git a/Source/modules/accessibility/AXObject.h b/Source/modules/accessibility/AXObject.h
index 669e65e7a0904230289bed56a7cad1dfc3d1df44..e73561255f0e74242cb3b6c34f00df35939e3eea 100644
--- a/Source/modules/accessibility/AXObject.h
+++ b/Source/modules/accessibility/AXObject.h
@@ -355,22 +355,45 @@ class MODULES_EXPORT AXObject : public RefCounted<AXObject> {
public:
typedef Vector<RefPtr<AXObject>> AccessibilityChildrenVector;
- struct PlainTextRange {
-
- unsigned start;
- unsigned length;
+ struct AXRange {
+ // The deepest descendant in which the range starts.
+ // (nullptr means the current object.)
+ RefPtrWillBePersistent<AXObject> anchorObject;
+ // The number of characters and child objects in the anchor object
+ // before the range starts.
+ int anchorOffset;
+ // The deepest descendant in which the range ends.
+ // (nullptr means the current object.)
+ RefPtrWillBePersistent<AXObject> focusObject;
+ // The number of characters and child objects in the focus object
+ // before the range ends.
+ int focusOffset;
+
+ AXRange()
+ : anchorObject(nullptr)
+ , anchorOffset(-1)
+ , focusObject(nullptr)
+ , focusOffset(-1)
+ { }
- PlainTextRange()
- : start(0)
- , length(0)
+ AXRange(int startOffset, int endOffset)
+ : anchorObject(nullptr)
+ , anchorOffset(startOffset)
+ , focusObject(nullptr)
+ , focusOffset(endOffset)
{ }
- PlainTextRange(unsigned s, unsigned l)
- : start(s)
- , length(l)
+ AXRange(PassRefPtrWillBeRawPtr<AXObject> anchorObject, int anchorOffset,
+ PassRefPtrWillBeRawPtr<AXObject> focusObject, int focusOffset)
+ : anchorObject(anchorObject)
+ , anchorOffset(anchorOffset)
+ , focusObject(focusObject)
+ , focusOffset(focusOffset)
{ }
- bool isNull() const { return !start && !length; }
+ bool isNull() const { return anchorOffset < 0 || focusOffset < 0; }
+ // Determines if the range only refers to text offsets under the current object.
+ bool isSimple() const { return !anchorObject || !focusObject; }
};
protected:
@@ -583,7 +606,7 @@ public:
// The integer horizontal pixel offset of each character in the string; negative values for RTL.
virtual void textCharacterOffsets(Vector<int>&) const { }
// The start and end character offset of each word in the inline text box.
- virtual void wordBoundaries(Vector<PlainTextRange>& words) const { }
+ virtual void wordBoundaries(Vector<AXRange>& words) const { }
// Properties of interactive elements.
virtual String actionVerb() const;
@@ -697,8 +720,17 @@ public:
bool hasAttribute(const QualifiedName&) const;
const AtomicString& getAttribute(const QualifiedName&) const;
- // Selected text.
- virtual PlainTextRange selectedTextRange() const { return PlainTextRange(); }
+ //
+ // Methods that retrieve or manipulate the current selection.
+ //
+
+ // Get the current selection from anywhere in the accessibility tree.
+ virtual AXRange selection() const { return AXRange(); }
+ // Gets only the start and end offsets of the selection computed using the
+ // current object as the starting point. Returns a null selection if there is
+ // no selection in the subtree rooted at this object.
+ virtual AXRange selectionUnderObject() const { return AXRange(); }
+ virtual void setSelection(const AXRange&) { }
// Scrollable containers.
bool isScrollableContainer() const;
@@ -724,7 +756,6 @@ public:
virtual void setFocused(bool) { }
virtual void setSelected(bool) { }
void setSelectedText(const String&) { }
- virtual void setSelectedTextRange(const PlainTextRange&) { }
virtual void setValue(const String&) { }
virtual void setValue(float) { }

Powered by Google App Engine
This is Rietveld 408576698