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..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); |