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

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

Issue 1314253002: Removed the requirement to call setSelection directly on the text field in order to set its selecti… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed compiler error. Created 5 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698