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

Unified Diff: third_party/WebKit/Source/core/html/HTMLTextFormControlElement.cpp

Issue 2277903003: Fix selectionDirection after setting value of TEXTAREA/INPUT. (Closed)
Patch Set: Revert DCHECK_LE Created 4 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
Index: third_party/WebKit/Source/core/html/HTMLTextFormControlElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLTextFormControlElement.cpp b/third_party/WebKit/Source/core/html/HTMLTextFormControlElement.cpp
index f65dd4c030df7a0137deda28a5d07d2f31518990..734699240e0c1b6444e27de2cd87add6c028c9b5 100644
--- a/third_party/WebKit/Source/core/html/HTMLTextFormControlElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLTextFormControlElement.cpp
@@ -270,11 +270,7 @@ void HTMLTextFormControlElement::setSelectionRangeForBinding(int start, int end,
direction = SelectionHasForwardDirection;
else if (directionString == "backward")
direction = SelectionHasBackwardDirection;
-
- if (direction == SelectionHasNoDirection && document().frame() && document().frame()->editor().behavior().shouldConsiderSelectionAsDirectional())
- direction = SelectionHasForwardDirection;
-
- return setSelectionRange(start, end, direction);
+ setSelectionRange(start, end, direction);
}
static Position positionForIndex(HTMLElement* innerEditor, int index)
@@ -351,6 +347,9 @@ void HTMLTextFormControlElement::setSelectionRange(int start, int end, TextField
DCHECK_GE(editorValueLength, 0);
end = std::max(std::min(end, editorValueLength), 0);
start = std::min(std::max(start, 0), end);
+ LocalFrame* frame = document().frame();
+ if (direction == SelectionHasNoDirection && frame && frame->editor().behavior().shouldConsiderSelectionAsDirectional())
+ direction = SelectionHasForwardDirection;
cacheSelection(start, end, direction);
if (document().focusedElement() != this) {
@@ -359,7 +358,6 @@ void HTMLTextFormControlElement::setSelectionRange(int start, int end, TextField
return;
}
- LocalFrame* frame = document().frame();
HTMLElement* innerEditor = innerEditorElement();
if (!frame || !innerEditor)
return;
@@ -471,11 +469,10 @@ static const AtomicString& directionString(TextFieldSelectionDirection direction
const AtomicString& HTMLTextFormControlElement::selectionDirection() const
{
- if (!isTextFormControl())
- return directionString(SelectionHasNoDirection);
+ // Ensured by HTMLInputElement::selectionDirectionForBinding().
+ DCHECK(isTextFormControl());
if (document().focusedElement() != this)
return directionString(m_cachedSelectionDirection);
-
return directionString(computeSelectionDirection());
}

Powered by Google App Engine
This is Rietveld 408576698