Chromium Code Reviews| 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); |