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

Unified Diff: third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp

Issue 2191833003: Use text affinity to return correct accessible line boundaries. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bug in browser_accessibility_win.cc Created 4 years, 5 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: third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp
diff --git a/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp b/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp
index 1585354fce6f6cde6b69deb1aa9c78284951f5d8..2a2b061b2ee7bc4fe464453a4c9181eec8d34a80 100644
--- a/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp
+++ b/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp
@@ -1819,10 +1819,14 @@ AXObject::AXRange AXLayoutObject::selection() const
if (selection.isNone())
return AXRange();
- Position visibleStart = selection.visibleStart().toParentAnchoredPosition();
- Position visibleEnd = selection.visibleEnd().toParentAnchoredPosition();
-
- Node* anchorNode = visibleStart.anchorNode();
+ VisiblePosition visibleStart = selection.visibleStart();
+ Position start = visibleStart.toParentAnchoredPosition();
+ TextAffinity startAffinity = visibleStart.affinity();
+ VisiblePosition visibleEnd = selection.visibleEnd();
+ Position end = visibleEnd.toParentAnchoredPosition();
+ TextAffinity endAffinity = visibleEnd.affinity();
+
+ Node* anchorNode = start.anchorNode();
ASSERT(anchorNode);
AXLayoutObject* anchorObject = nullptr;
@@ -1840,7 +1844,7 @@ AXObject::AXRange AXLayoutObject::selection() const
anchorNode = anchorNode->parentNode();
}
- Node* focusNode = visibleEnd.anchorNode();
+ Node* focusNode = end.anchorNode();
ASSERT(focusNode);
AXLayoutObject* focusObject = nullptr;
@@ -1858,15 +1862,12 @@ AXObject::AXRange AXLayoutObject::selection() const
if (!anchorObject || !focusObject)
return AXRange();
- int anchorOffset = anchorObject->indexForVisiblePosition(
- selection.visibleStart());
+ int anchorOffset = anchorObject->indexForVisiblePosition(visibleStart);
ASSERT(anchorOffset >= 0);
- int focusOffset = focusObject->indexForVisiblePosition(
- selection.visibleEnd());
+ int focusOffset = focusObject->indexForVisiblePosition(visibleEnd);
ASSERT(focusOffset >= 0);
- return AXRange(
- anchorObject, anchorOffset,
- focusObject, focusOffset);
+ return AXRange(anchorObject, anchorOffset, startAffinity,
+ focusObject, focusOffset, endAffinity);
}
// Gets only the start and end offsets of the selection computed using the
@@ -1923,12 +1924,15 @@ AXObject::AXRange AXLayoutObject::textControlSelection() const
if (!axObject || !axObject->isAXLayoutObject())
return AXRange();
+ VisibleSelection selection = layout->frame()->selection().selection();
HTMLTextFormControlElement* textControl = toLayoutTextControl(
layout)->textFormControlElement();
ASSERT(textControl);
int start = textControl->selectionStart();
int end = textControl->selectionEnd();
- return AXRange(axObject, start, axObject, end);
+
+ return AXRange(axObject, start, selection.visibleStart().affinity(),
+ axObject, end, selection.visibleEnd().affinity());
}
int AXLayoutObject::indexForVisiblePosition(const VisiblePosition& position) const

Powered by Google App Engine
This is Rietveld 408576698