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

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 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
Index: Source/core/html/HTMLTextFormControlElement.cpp
diff --git a/Source/core/html/HTMLTextFormControlElement.cpp b/Source/core/html/HTMLTextFormControlElement.cpp
index d6470ef46cfe6c21126637ee87e209af787ae120..21e8d99945fba2b39f770c6bf94bd1fe05069bc4 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, MustFocus);
tkent 2014/07/16 07:11:34 Is this compatible with other browsers? Can we add
yoichio 2014/07/16 08:07:12 Both FF and IE do.
tkent 2014/07/16 23:34:16 Please have an investigation. Adding no flag is si
}
bool HTMLTextFormControlElement::shouldDispatchFormControlChangeEvent(String& oldValue, String& newValue)
@@ -274,10 +275,13 @@ 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)
{
document().updateLayoutIgnorePendingStylesheets();
@@ -288,15 +292,12 @@ 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()))
+ if (focusOption != MustFocus && (document().focusedElement() != this || !hasVisibleTextArea(renderer(), innerEditorElement())))
return;
LocalFrame* frame = document().frame();
yosin_UTC9 2014/07/16 07:09:14 nit: You can move |!frame| before L286.
yoichio 2014/07/16 08:07:12 Done.
- if (!frame || !shouldSetSelection)
+ if (!frame)
return;
VisiblePosition startPosition = visiblePositionForIndex(start);

Powered by Google App Engine
This is Rietveld 408576698