Index: Source/modules/accessibility/AXLayoutObject.cpp |
diff --git a/Source/modules/accessibility/AXLayoutObject.cpp b/Source/modules/accessibility/AXLayoutObject.cpp |
index 2d4976431777b4cb7ea0fd4af4c52b03afaaccf5..00fc26dfce5896778f4f1a3ba173498a0c73c941 100644 |
--- a/Source/modules/accessibility/AXLayoutObject.cpp |
+++ b/Source/modules/accessibility/AXLayoutObject.cpp |
@@ -2007,23 +2007,29 @@ void AXLayoutObject::setSelection(const AXRange& selection) |
if (!layoutObject() || !selection.isValid()) |
return; |
- if (selection.anchorObject && !isValidSelectionBound(selection.anchorObject.get())) |
- return; |
- |
- if (selection.focusObject && !isValidSelectionBound(selection.focusObject.get())) |
- return; |
- |
AXObject* anchorObject = selection.anchorObject ? |
selection.anchorObject.get() : this; |
AXObject* focusObject = selection.focusObject ? |
selection.focusObject.get() : this; |
- if (anchorObject == this && anchorObject == focusObject |
- && layoutObject()->isTextControl()) { |
+ if (!isValidSelectionBound(anchorObject) |
+ || !isValidSelectionBound(focusObject)) { |
+ return; |
+ } |
+ |
+ if (anchorObject == focusObject |
+ && anchorObject->layoutObject()->isTextControl()) { |
HTMLTextFormControlElement* textControl = toLayoutTextControl( |
- layoutObject())->textFormControlElement(); |
- textControl->setSelectionRange(selection.anchorOffset, selection.focusOffset, |
- SelectionHasNoDirection, NotDispatchSelectEvent); |
+ anchorObject->layoutObject())->textFormControlElement(); |
+ if (selection.anchorOffset <= selection.focusOffset) { |
+ textControl->setSelectionRange( |
+ selection.anchorOffset, selection.focusOffset, |
+ SelectionHasForwardDirection, NotDispatchSelectEvent); |
+ } else { |
+ textControl->setSelectionRange( |
+ selection.focusOffset, selection.anchorOffset, |
+ SelectionHasBackwardDirection, NotDispatchSelectEvent); |
+ } |
return; |
} |
@@ -2053,8 +2059,8 @@ void AXLayoutObject::setSelection(const AXRange& selection) |
bool AXLayoutObject::isValidSelectionBound(const AXObject* boundObject) const |
{ |
- return boundObject && !boundObject->isDetached() |
- && boundObject->isAXLayoutObject() |
+ return layoutObject() && boundObject && !boundObject->isDetached() |
+ && boundObject->isAXLayoutObject() && boundObject->layoutObject() |
&& boundObject->layoutObject()->frame() == layoutObject()->frame() |
&& &boundObject->axObjectCache() == &axObjectCache(); |
} |