Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(341)

Unified Diff: third_party/WebKit/Source/core/frame/FrameView.cpp

Issue 1438953002: Update selection when an element is focused by in-document fragment link. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/dom/fragment-activation-focuses-target-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/dom/fragment-activation-focuses-target-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698