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

Unified Diff: third_party/WebKit/Source/core/dom/Element.cpp

Issue 1437813002: Set selection to INPUT/TEXTAREA before dispatching 'focus' event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: improve selection-functions.html 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
Index: third_party/WebKit/Source/core/dom/Element.cpp
diff --git a/third_party/WebKit/Source/core/dom/Element.cpp b/third_party/WebKit/Source/core/dom/Element.cpp
index 2351061beffa6fe31b4f88515be7642791eec300..cdd30388ab6e0fcec2c79b5af31d6fcd7d287b81 100644
--- a/third_party/WebKit/Source/core/dom/Element.cpp
+++ b/third_party/WebKit/Source/core/dom/Element.cpp
@@ -2379,15 +2379,7 @@ void Element::focus(const FocusParams& params)
if (!document().page()->focusController().setFocusedElement(this, document().frame(), params))
return;
- // Setting the focused node above might have invalidated the layout due to scripts.
- document().updateLayoutIgnorePendingStylesheets();
- if (!isFocusable())
- return;
-
- cancelFocusAppearanceUpdate();
- updateFocusAppearance(params.selectionBehavior);
-
- if (UserGestureIndicator::processedUserGestureSinceLoad()) {
+ if (document().focusedElement() == this && UserGestureIndicator::processedUserGestureSinceLoad()) {
// Bring up the keyboard in the context of anything triggered by a user
// gesture. Since tracking that across arbitrary boundaries (eg.
// animations) is difficult, for now we match IE's heuristic and bring
@@ -2396,8 +2388,10 @@ void Element::focus(const FocusParams& params)
}
}
-void Element::updateFocusAppearance(SelectionBehaviorOnFocus)
+void Element::updateFocusAppearance(SelectionBehaviorOnFocus selectionBehavior)
{
+ if (selectionBehavior == SelectionBehaviorOnFocus::None)
+ return;
if (isRootEditableElement()) {
// Taking the ownership since setSelection() may release the last reference to |frame|.
RefPtrWillBeRawPtr<LocalFrame> frame(document().frame());
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | third_party/WebKit/Source/core/html/HTMLInputElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698