Chromium Code Reviews| Index: third_party/WebKit/Source/core/page/FocusController.cpp |
| diff --git a/third_party/WebKit/Source/core/page/FocusController.cpp b/third_party/WebKit/Source/core/page/FocusController.cpp |
| index 110d8bf12a8de8c3fa4cf6a7c0088d3b2008b582..0550ba88b91978288ece59c458b25b3d5daa756c 100644 |
| --- a/third_party/WebKit/Source/core/page/FocusController.cpp |
| +++ b/third_party/WebKit/Source/core/page/FocusController.cpp |
| @@ -1040,6 +1040,10 @@ bool FocusController::advanceFocusInDocumentOrder( |
| setFocusedFrame(newDocument.frame()); |
| + if (!element->isTextControl() && !hasEditableStyle(*element->toNode())) { |
| + // TODO(blink-editing): Remove this clear(), crbug.com/692898. |
|
yosin_UTC9
2017/03/21 06:49:59
nit: s/blink-editing/editing-dev/
hugoh_UTC2
2017/03/22 02:54:47
Done.
|
| + focusedFrame()->selection().clear(); |
| + } |
| element->focus( |
| FocusParams(SelectionBehaviorOnFocus::Reset, type, sourceCapabilities)); |
| return true; |
| @@ -1066,35 +1070,6 @@ static bool relinquishesEditingFocus(const Element& element) { |
| return element.document().frame() && rootEditableElement(element); |
| } |
| -static void clearSelectionIfNeeded(LocalFrame* oldFocusedFrame, |
| - LocalFrame* newFocusedFrame, |
| - Element* newFocusedElement) { |
| - if (!oldFocusedFrame || !newFocusedFrame) |
| - return; |
| - |
| - if (oldFocusedFrame->document() != newFocusedFrame->document()) |
| - return; |
| - |
| - FrameSelection& selection = oldFocusedFrame->selection(); |
| - const SelectionInDOMTree& selectionInDOMTree = selection.selectionInDOMTree(); |
| - if (selectionInDOMTree.isNone()) |
| - return; |
| - |
| - Node* selectionStartNode = selectionInDOMTree.base().anchorNode(); |
| - if (selectionStartNode == newFocusedElement || |
| - selectionStartNode->isDescendantOf(newFocusedElement)) |
| - return; |
| - |
| - if (!enclosingTextControl(selectionStartNode)) |
| - return; |
| - |
| - if (selectionStartNode->isInShadowTree() && |
| - selectionStartNode->ownerShadowHost() == newFocusedElement) |
| - return; |
| - |
| - selection.clear(); |
| -} |
| - |
| bool FocusController::setFocusedElement(Element* element, |
| Frame* newFocusedFrame) { |
| return setFocusedElement( |
| @@ -1131,10 +1106,6 @@ bool FocusController::setFocusedElement(Element* element, |
| newDocument->focusedElement() == element) |
| return true; |
| - if (newFocusedFrame && newFocusedFrame->isLocalFrame()) |
| - clearSelectionIfNeeded(oldFocusedFrame, toLocalFrame(newFocusedFrame), |
| - element); |
| - |
| if (oldDocument && oldDocument != newDocument) |
| oldDocument->clearFocusedElement(); |
| @@ -1351,6 +1322,10 @@ bool FocusController::advanceFocusDirectionallyInContainer( |
| Element* element = toElement(focusCandidate.focusableNode); |
| DCHECK(element); |
| + if (!element->isTextControl() && !hasEditableStyle(*element->toNode())) { |
| + // TODO(blink-editing): Remove this clear(), crbug.com/692898. |
| + focusedFrame()->selection().clear(); |
| + } |
| element->focus(FocusParams(SelectionBehaviorOnFocus::Reset, type, nullptr)); |
| return true; |
| } |