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

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

Issue 392573002: HTMLTextAreaElement.setSelectionRange should not change focus. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rename FocusOption Created 6 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
« no previous file with comments | « Source/core/html/HTMLTextFormControlElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLTextFormControlElement.cpp
diff --git a/Source/core/html/HTMLTextFormControlElement.cpp b/Source/core/html/HTMLTextFormControlElement.cpp
index d6470ef46cfe6c21126637ee87e209af787ae120..d88c3d4f3c6000d65742e3cd092ba59caa7679a1 100644
--- a/Source/core/html/HTMLTextFormControlElement.cpp
+++ b/Source/core/html/HTMLTextFormControlElement.cpp
@@ -34,6 +34,7 @@
#include "core/dom/NodeTraversal.h"
#include "core/dom/Text.h"
#include "core/dom/shadow/ShadowRoot.h"
+#include "core/editing/Editor.h"
#include "core/editing/FrameSelection.h"
#include "core/editing/TextIterator.h"
#include "core/events/Event.h"
@@ -180,7 +181,7 @@ void HTMLTextFormControlElement::setSelectionDirection(const String& direction)
void HTMLTextFormControlElement::select()
{
- setSelectionRange(0, std::numeric_limits<int>::max(), SelectionHasNoDirection);
+ setSelectionRange(0, std::numeric_limits<int>::max(), SelectionHasNoDirection, ChangeFocus);
}
bool HTMLTextFormControlElement::shouldDispatchFormControlChangeEvent(String& oldValue, String& newValue)
@@ -274,11 +275,19 @@ void HTMLTextFormControlElement::setSelectionRange(int start, int end, const Str
else if (directionString == "backward")
direction = SelectionHasBackwardDirection;
+ if (direction == SelectionHasNoDirection && document().frame() && document().frame()->editor().behavior().shouldConsiderSelectionAsDirectional())
+ direction = SelectionHasForwardDirection;
+
return setSelectionRange(start, end, direction);
}
-void HTMLTextFormControlElement::setSelectionRange(int start, int end, TextFieldSelectionDirection direction)
+void HTMLTextFormControlElement::setSelectionRange(int start, int end, TextFieldSelectionDirection direction, FocusOption focusOption)
{
+ LocalFrame* frame = document().frame();
+
+ if (!frame)
+ return;
tkent 2014/07/16 23:35:19 Is this compatible with other browsers? Shouldn't
yoichio 2014/07/17 07:16:01 I'm not sure and this change is not related to thi
+
document().updateLayoutIgnorePendingStylesheets();
if (!renderer() || !renderer()->isTextControl())
@@ -288,15 +297,11 @@ void HTMLTextFormControlElement::setSelectionRange(int start, int end, TextField
end = std::max(std::min(end, textLength), 0);
start = std::max(std::min(start, end), 0);
cacheSelection(start, end, direction);
- bool isCaretSelection = start == end;
- bool shouldSetSelection = document().focusedElement() == this || (!isCaretSelection && start < textLength);
if (!hasVisibleTextArea(renderer(), innerEditorElement()))
return;
- LocalFrame* frame = document().frame();
-
- if (!frame || !shouldSetSelection)
+ if (focusOption == NotChangeFocus && document().focusedElement() != this)
return;
VisiblePosition startPosition = visiblePositionForIndex(start);
« no previous file with comments | « Source/core/html/HTMLTextFormControlElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698