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

Unified Diff: ui/webui/resources/js/cr/ui/focus_row.js

Issue 1281483008: Move downloads.FocusRow.shouldFocus to cr.ui.FocusRow.isFocusable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@focus-row2
Patch Set: whoops Created 5 years, 4 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
« no previous file with comments | « chrome/browser/resources/downloads/manager.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/webui/resources/js/cr/ui/focus_row.js
diff --git a/ui/webui/resources/js/cr/ui/focus_row.js b/ui/webui/resources/js/cr/ui/focus_row.js
index 3006d640075dee45c262a6c94f09b3c836039c2c..1065c0aa3e88a955c957eb7114ba418271b5457f 100644
--- a/ui/webui/resources/js/cr/ui/focus_row.js
+++ b/ui/webui/resources/js/cr/ui/focus_row.js
@@ -57,6 +57,24 @@ cr.define('cr.ui', function() {
/** @const {string} */
FocusRow.ACTIVE_CLASS = 'focus-row-active';
+ /**
+ * Whether it's possible that |element| can be focused.
+ * @param {Element} element
+ * @return {boolean} Whether the item is focusable.
+ */
+ FocusRow.isFocusable = function isFocusable(element) {
+ if (!element)
+ return false;
+
+ // Hidden elements are not focusable.
+ var style = window.getComputedStyle(element);
+ if (style.visibility == 'hidden' || style.display == 'none')
+ return false;
+
+ // Verify all ancestors are focusable.
+ return !element.parentElement || isFocusable(element.parentElement);
+ };
+
FocusRow.prototype = {
__proto__: HTMLDivElement.prototype,
« no previous file with comments | « chrome/browser/resources/downloads/manager.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698