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

Unified Diff: chrome/browser/resources/md_bookmarks/mouse_focus_behavior.js

Issue 2954273002: [MD Bookmarks] Restore focus after closing a dialog or context menu. (Closed)
Patch Set: fix deps Created 3 years, 6 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: chrome/browser/resources/md_bookmarks/mouse_focus_behavior.js
diff --git a/chrome/browser/resources/md_bookmarks/mouse_focus_behavior.js b/chrome/browser/resources/md_bookmarks/mouse_focus_behavior.js
index 2aec0e9ddf13e1ffef1730eaa0f5d609c4a88cb5..ce62e2aea4a64d09d0d85f39a74661842a396632 100644
--- a/chrome/browser/resources/md_bookmarks/mouse_focus_behavior.js
+++ b/chrome/browser/resources/md_bookmarks/mouse_focus_behavior.js
@@ -3,6 +3,9 @@
// found in the LICENSE file.
cr.define('bookmarks', function() {
+ /** @const */
+ var MOUSE_FOCUS_CLASS = 'mouse-focus';
+
/**
* Behavior which adds the 'mouse-focus' class to a target element when it
* gains focus from the mouse, allowing the outline to be hidden without
@@ -16,12 +19,14 @@ cr.define('bookmarks', function() {
var target = this.getFocusTarget();
target.addEventListener('mousedown', this.boundOnMousedown_);
+ target.addEventListener('contextmenu', this.boundOnMousedown_);
target.addEventListener('blur', this.boundClearMouseFocus_);
},
detached: function() {
var target = this.getFocusTarget();
target.removeEventListener('mousedown', this.boundOnMousedown_);
+ target.removeEventListener('contextmenu', this.boundOnMousedown_);
target.removeEventListener('blur', this.boundClearMouseFocus_);
},
@@ -37,12 +42,25 @@ cr.define('bookmarks', function() {
/** Reset the focus state when focus leaves the target element. */
clearMouseFocus: function() {
- this.getFocusTarget().classList.remove('mouse-focus');
+ this.getFocusTarget().classList.remove(MOUSE_FOCUS_CLASS);
},
/** @private */
onMousedown_: function() {
- this.getFocusTarget().classList.add('mouse-focus');
+ this.addMouseFocusClass(this.getFocusTarget());
+ },
+
+ /**
+ * @param {HTMLElement} element
+ * @return {boolean}
+ */
+ isMouseFocused: function(element) {
+ return element.classList.contains(MOUSE_FOCUS_CLASS);
+ },
+
+ /** @param {HTMLElement} element */
+ addMouseFocusClass: function(element) {
+ element.classList.add(MOUSE_FOCUS_CLASS);
},
};
« no previous file with comments | « chrome/browser/resources/md_bookmarks/item.js ('k') | chrome/browser/ui/webui/md_bookmarks/md_bookmarks_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698