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

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

Issue 2616623002: Do not send redundant selectionchange-events (decouple focus) (Closed)
Patch Set: Fix spatnav tests (clear selection when focus goes to non editable element). Remove now invalid keeā€¦ Created 3 years, 10 months 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 2fde2c526802721659102806ad693fc66f3f70b6..147bb266e0eb3a1a14c019ff5615d12fa7ac44fa 100644
--- a/third_party/WebKit/Source/core/dom/Element.cpp
+++ b/third_party/WebKit/Source/core/dom/Element.cpp
@@ -2681,8 +2681,9 @@ void Element::updateFocusAppearance(
SelectionBehaviorOnFocus selectionBehavior) {
if (selectionBehavior == SelectionBehaviorOnFocus::None)
return;
+
+ LocalFrame* frame = document().frame();
yosin_UTC9 2017/02/09 13:02:17 We can early return here if |!frame|. Let's hoist
if (isRootEditableElement(*this)) {
- LocalFrame* frame = document().frame();
if (!frame)
return;
@@ -2706,8 +2707,13 @@ void Element::updateFocusAppearance(
FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle |
FrameSelection::DoNotSetFocus);
frame->selection().revealSelection();
- } else if (layoutObject() && !layoutObject()->isLayoutPart()) {
- layoutObject()->scrollRectToVisible(boundingBox());
+ } else {
+ // This element is non editable.
+ if (frame)
+ frame->selection().clear();
yosin_UTC9 2017/02/09 13:02:17 Focus and selection are individual identity. We do
hugoh_UTC2 2017/02/11 03:42:22 True, here we would clear() too often. Let's put t
+
+ if (layoutObject() && !layoutObject()->isLayoutPart())
+ layoutObject()->scrollRectToVisible(boundingBox());
}
}

Powered by Google App Engine
This is Rietveld 408576698