Commit 227c3bf3 authored by Nektarios Paisios's avatar Nektarios Paisios Committed by Commit Bot

Focus affinity should be maintained if the requested text offset is equal to the caret offset

R=dmazzoni@chromium.org, aleventhal@chromium.org

Bug: 
Change-Id: I23f586ca63c037fb9a0adab24b090b694529d90c
Reviewed-on: https://chromium-review.googlesource.com/775520Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: Nektarios Paisios <nektar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517258}
parent 3f6ca074
...@@ -2261,14 +2261,15 @@ LONG BrowserAccessibilityComWin::FindBoundary( ...@@ -2261,14 +2261,15 @@ LONG BrowserAccessibilityComWin::FindBoundary(
IA2TextBoundaryType ia2_boundary, IA2TextBoundaryType ia2_boundary,
LONG start_offset, LONG start_offset,
ui::TextBoundaryDirection direction) { ui::TextBoundaryDirection direction) {
// If the boundary is relative to the caret, use the selection
// affinity, otherwise default to downstream affinity.
ui::AXTextAffinity affinity =
start_offset == IA2_TEXT_OFFSET_CARET
? Manager()->GetTreeData().sel_focus_affinity
: ui::AX_TEXT_AFFINITY_DOWNSTREAM;
HandleSpecialTextOffset(&start_offset); HandleSpecialTextOffset(&start_offset);
// If the |start_offset| is equal to the location of the caret, then use the
// focus affinity, otherwise default to downstream affinity.
ui::AXTextAffinity affinity = ui::AX_TEXT_AFFINITY_DOWNSTREAM;
int selection_start, selection_end;
GetSelectionOffsets(&selection_start, &selection_end);
if (selection_end >= 0 && start_offset == selection_end)
affinity = Manager()->GetTreeData().sel_focus_affinity;
if (ia2_boundary == IA2_TEXT_BOUNDARY_WORD) { if (ia2_boundary == IA2_TEXT_BOUNDARY_WORD) {
switch (direction) { switch (direction) {
case ui::FORWARDS_DIRECTION: { case ui::FORWARDS_DIRECTION: {
......
...@@ -3730,7 +3730,11 @@ void AXPlatformNodeWin::HandleSpecialTextOffset(LONG* offset) { ...@@ -3730,7 +3730,11 @@ void AXPlatformNodeWin::HandleSpecialTextOffset(LONG* offset) {
if (*offset == IA2_TEXT_OFFSET_LENGTH) { if (*offset == IA2_TEXT_OFFSET_LENGTH) {
*offset = static_cast<LONG>(GetText().length()); *offset = static_cast<LONG>(GetText().length());
} else if (*offset == IA2_TEXT_OFFSET_CARET) { } else if (*offset == IA2_TEXT_OFFSET_CARET) {
*offset = static_cast<LONG>(GetIntAttribute(AX_ATTR_TEXT_SEL_END)); int selection_start, selection_end;
GetSelectionOffsets(&selection_start, &selection_end);
if (selection_end < 0)
*offset = 0;
*offset = static_cast<LONG>(selection_end);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment