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

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: 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 1fa46b3d1990e4d919b171cf63a6b0299dc030a8..e7b8b68e6aee319a5d2ebdc2722ce360aefdece1 100644
--- a/Source/modules/accessibility/AXObject.h
+++ b/Source/modules/accessibility/AXObject.h
@@ -355,22 +355,44 @@ class MODULES_EXPORT AXObject : public RefCounted<AXObject> {
public:
typedef Vector<RefPtr<AXObject>> AccessibilityChildrenVector;
- struct PlainTextRange {
-
- unsigned start;
- unsigned length;
+ struct AXSelection {
+ // The ID of the deepest descendant in which the selection starts.
+ // (A value of 0 means the current object.)
+ AXID anchorId;
+ // The number of characters and child objects in the anchor object
+ // before the selection starts.
+ unsigned anchorOffset;
+ // The ID of the deepest descendant in which the selection ends.
+ // (A value of 0 means the current object.)
+ AXID focusId;
+ // The number of characters and child objects in the focus object
+ // before the selection ends.
+ unsigned focusOffset;
+
+ AXSelection()
+ : anchorId(0)
+ , anchorOffset(0)
+ , focusId(0)
+ , focusOffset(0)
+ { }
- PlainTextRange()
- : start(0)
- , length(0)
+ AXSelection(unsigned startOffset, unsigned endOffset)
+ : anchorId(0)
+ , anchorOffset(startOffset)
+ , focusId(0)
+ , focusOffset(endOffset)
{ }
- PlainTextRange(unsigned s, unsigned l)
- : start(s)
- , length(l)
+ AXSelection(AXID anchorId, unsigned anchorOffset, AXID focusId, unsigned focusOffset)
+ : anchorId(anchorId)
+ , anchorOffset(anchorOffset)
+ , focusId(focusId)
+ , focusOffset(focusOffset)
{ }
- bool isNull() const { return !start && !length; }
+ bool isNull() const { return !anchorOffset && !focusOffset; }
+ bool hasAnchor() const { return !anchorId; }
+ bool hasFocus() const { return !focusId; }
};
protected:
@@ -583,7 +605,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<AXSelection>& words) const { }
// Properties of interactive elements.
virtual String actionVerb() const;
@@ -699,9 +721,8 @@ public:
String language() const;
bool hasAttribute(const QualifiedName&) const;
const AtomicString& getAttribute(const QualifiedName&) const;
-
- // Selected text.
- virtual PlainTextRange selectedTextRange() const { return PlainTextRange(); }
+ virtual AXSelection selection() const { return AXSelection(); }
+ virtual AXSelection selectionUnderObject() const { return AXSelection(); }
// Scrollable containers.
bool isScrollableContainer() const;
@@ -727,7 +748,7 @@ public:
virtual void setFocused(bool) { }
virtual void setSelected(bool) { }
void setSelectedText(const String&) { }
- virtual void setSelectedTextRange(const PlainTextRange&) { }
+ virtual void setSelection(const AXSelection&) { }
dmazzoni 2015/06/16 17:24:04 Why is setSelection implemented here but not expos
virtual void setValue(const String&) { }
virtual void setValue(float) { }

Powered by Google App Engine
This is Rietveld 408576698