| Index: third_party/WebKit/Source/core/frame/FrameView.cpp
|
| diff --git a/third_party/WebKit/Source/core/frame/FrameView.cpp b/third_party/WebKit/Source/core/frame/FrameView.cpp
|
| index 24fc091624a459c1ada7a484b78466c91ee666ad..29096603d9b63a9755fa09492108724c80373533 100644
|
| --- a/third_party/WebKit/Source/core/frame/FrameView.cpp
|
| +++ b/third_party/WebKit/Source/core/frame/FrameView.cpp
|
| @@ -1451,11 +1451,17 @@ bool FrameView::processUrlFragmentHelper(const String& name, UrlFragmentBehavior
|
| if (behavior == UrlFragmentScroll)
|
| maintainScrollPositionAtAnchor(anchorNode ? static_cast<Node*>(anchorNode) : m_frame->document());
|
|
|
| - // If the anchor accepts keyboard focus, move focus there to aid users relying on keyboard navigation.
|
| - // If anchorNode is not focusable, setFocusedElement() will still clear focus, which matches the behavior of other browsers.
|
| - if (anchorNode)
|
| - m_frame->document()->setFocusedElement(anchorNode, FocusParams(SelectionBehaviorOnFocus::None, WebFocusTypeNone, nullptr));
|
| -
|
| + // If the anchor accepts keyboard focus, move focus there to aid users
|
| + // relying on keyboard navigation.
|
| + // If anchorNode is not focusable, clear focus, which matches the behavior
|
| + // of other browsers.
|
| + if (anchorNode) {
|
| + m_frame->document()->updateLayoutIgnorePendingStylesheets();
|
| + if (anchorNode->isFocusable())
|
| + anchorNode->focus();
|
| + else
|
| + m_frame->document()->clearFocusedElement();
|
| + }
|
| return true;
|
| }
|
|
|
|
|