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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/UIUtils.js

Issue 2921363002: DevTools: Add keyboard focus highlight when focusing window (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). 4 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com).
5 * Copyright (C) 2009 Joseph Pecoraro 5 * Copyright (C) 2009 Joseph Pecoraro
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 10 *
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 return shadowRoot; 704 return shadowRoot;
705 }; 705 };
706 706
707 /** 707 /**
708 * @param {!Document} document 708 * @param {!Document} document
709 * @param {!Event} event 709 * @param {!Event} event
710 */ 710 */
711 UI._windowFocused = function(document, event) { 711 UI._windowFocused = function(document, event) {
712 if (event.target.document.nodeType === Node.DOCUMENT_NODE) 712 if (event.target.document.nodeType === Node.DOCUMENT_NODE)
713 document.body.classList.remove('inactive'); 713 document.body.classList.remove('inactive');
714 UI._keyboardFocus = true;
715 document.defaultView.requestAnimationFrame(() => UI._keyboardFocus = false);
714 }; 716 };
715 717
716 /** 718 /**
717 * @param {!Document} document 719 * @param {!Document} document
718 * @param {!Event} event 720 * @param {!Event} event
719 */ 721 */
720 UI._windowBlurred = function(document, event) { 722 UI._windowBlurred = function(document, event) {
721 if (event.target.document.nodeType === Node.DOCUMENT_NODE) 723 if (event.target.document.nodeType === Node.DOCUMENT_NODE)
722 document.body.classList.add('inactive'); 724 document.body.classList.add('inactive');
723 }; 725 };
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 */ 1131 */
1130 UI.initializeUIUtils = function(document, themeSetting) { 1132 UI.initializeUIUtils = function(document, themeSetting) {
1131 document.body.classList.toggle('inactive', !document.hasFocus()); 1133 document.body.classList.toggle('inactive', !document.hasFocus());
1132 document.defaultView.addEventListener('focus', UI._windowFocused.bind(UI, docu ment), false); 1134 document.defaultView.addEventListener('focus', UI._windowFocused.bind(UI, docu ment), false);
1133 document.defaultView.addEventListener('blur', UI._windowBlurred.bind(UI, docum ent), false); 1135 document.defaultView.addEventListener('blur', UI._windowBlurred.bind(UI, docum ent), false);
1134 document.addEventListener('focus', UI._focusChanged.bind(UI), true); 1136 document.addEventListener('focus', UI._focusChanged.bind(UI), true);
1135 document.addEventListener('keydown', event => { 1137 document.addEventListener('keydown', event => {
1136 UI._keyboardFocus = true; 1138 UI._keyboardFocus = true;
1137 document.defaultView.requestAnimationFrame(() => UI._keyboardFocus = false); 1139 document.defaultView.requestAnimationFrame(() => UI._keyboardFocus = false);
1138 }, true); 1140 }, true);
1141 document.addEventListener('mousedown', () => {
dgozman 2017/06/06 22:10:30 Let's move this listener to _windowFocused.
einbinder 2017/06/07 02:01:43 Done.
1142 var activeElement = document.deepActiveElement();
1143 if (activeElement)
1144 activeElement.removeAttribute('data-keyboard-focus');
1145 UI._keyboardFocus = false;
1146 }, true);
1139 1147
1140 if (!UI.themeSupport) 1148 if (!UI.themeSupport)
1141 UI.themeSupport = new UI.ThemeSupport(themeSetting); 1149 UI.themeSupport = new UI.ThemeSupport(themeSetting);
1142 UI.themeSupport.applyTheme(document); 1150 UI.themeSupport.applyTheme(document);
1143 1151
1144 var body = /** @type {!Element} */ (document.body); 1152 var body = /** @type {!Element} */ (document.body);
1145 UI.appendStyle(body, 'ui/inspectorStyle.css'); 1153 UI.appendStyle(body, 'ui/inspectorStyle.css');
1146 UI.GlassPane.setContainer(/** @type {!Element} */ (document.body)); 1154 UI.GlassPane.setContainer(/** @type {!Element} */ (document.body));
1147 }; 1155 };
1148 1156
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
2036 */ 2044 */
2037 UI.createInlineButton = function(toolbarButton) { 2045 UI.createInlineButton = function(toolbarButton) {
2038 var element = createElement('span'); 2046 var element = createElement('span');
2039 var shadowRoot = UI.createShadowRootWithCoreStyles(element, 'ui/inlineButton.c ss'); 2047 var shadowRoot = UI.createShadowRootWithCoreStyles(element, 'ui/inlineButton.c ss');
2040 element.classList.add('inline-button'); 2048 element.classList.add('inline-button');
2041 var toolbar = new UI.Toolbar(''); 2049 var toolbar = new UI.Toolbar('');
2042 toolbar.appendToolbarItem(toolbarButton); 2050 toolbar.appendToolbarItem(toolbarButton);
2043 shadowRoot.appendChild(toolbar.element); 2051 shadowRoot.appendChild(toolbar.element);
2044 return element; 2052 return element;
2045 }; 2053 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698