| 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 0b5aa3331fc4ac12396ea84b1c09af7ceae97fd5..8065b70f63dbbbd9537c1f1609e78ddce3ec31af 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(editing-dev): Remove this clear(), crbug.com/692898.
|
| + 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();
|
|
|
| @@ -1355,6 +1326,10 @@ bool FocusController::advanceFocusDirectionallyInContainer(
|
| Element* element = toElement(focusCandidate.focusableNode);
|
| DCHECK(element);
|
|
|
| + if (!element->isTextControl() && !hasEditableStyle(*element->toNode())) {
|
| + // TODO(editing-dev): Remove this clear(), crbug.com/692898.
|
| + focusedFrame()->selection().clear();
|
| + }
|
| element->focus(FocusParams(SelectionBehaviorOnFocus::Reset, type, nullptr));
|
| return true;
|
| }
|
|
|