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

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

Issue 2741863002: DevTools: Focus background in Toolbars (Closed)
Patch Set: raf Created 3 years, 9 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
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 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 if (event.target.document.nodeType === Node.DOCUMENT_NODE) 777 if (event.target.document.nodeType === Node.DOCUMENT_NODE)
778 document.body.classList.add('inactive'); 778 document.body.classList.add('inactive');
779 }; 779 };
780 780
781 /** 781 /**
782 * @param {!Event} event 782 * @param {!Event} event
783 */ 783 */
784 UI._focusChanged = function(event) { 784 UI._focusChanged = function(event) {
785 var document = event.target && event.target.ownerDocument; 785 var document = event.target && event.target.ownerDocument;
786 var element = document ? document.deepActiveElement() : null; 786 var element = document ? document.deepActiveElement() : null;
787 if (document && document.body)
788 document.body.classList.toggle('keyboard-focus', UI._keyboardFocus);
pfeldman 2017/03/27 21:17:35 What is this about?
einbinder 2017/03/27 23:12:59 To distinguish between tabbing into an element vs
pfeldman 2017/03/28 17:44:35 Somehow I don't like storing the 'last focus was g
787 UI.Widget.focusWidgetForNode(element); 789 UI.Widget.focusWidgetForNode(element);
788 }; 790 };
789 791
790 /** 792 /**
791 * @unrestricted 793 * @unrestricted
792 */ 794 */
793 UI.ElementFocusRestorer = class { 795 UI.ElementFocusRestorer = class {
794 /** 796 /**
795 * @param {!Element} element 797 * @param {!Element} element
796 */ 798 */
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 } 1177 }
1176 }; 1178 };
1177 1179
1178 /** 1180 /**
1179 * @param {!Document} document 1181 * @param {!Document} document
1180 * @param {!Common.Setting} themeSetting 1182 * @param {!Common.Setting} themeSetting
1181 */ 1183 */
1182 UI.initializeUIUtils = function(document, themeSetting) { 1184 UI.initializeUIUtils = function(document, themeSetting) {
1183 document.defaultView.addEventListener('focus', UI._windowFocused.bind(UI, docu ment), false); 1185 document.defaultView.addEventListener('focus', UI._windowFocused.bind(UI, docu ment), false);
1184 document.defaultView.addEventListener('blur', UI._windowBlurred.bind(UI, docum ent), false); 1186 document.defaultView.addEventListener('blur', UI._windowBlurred.bind(UI, docum ent), false);
1187 document.addEventListener('keydown', event => {
1188 UI._keyboardFocus = true;
1189 document.defaultView.requestAnimationFrame(() => UI._keyboardFocus = false);
pfeldman 2017/03/27 21:17:35 Seems like technical debt.
einbinder 2017/03/27 23:12:59 It is a hack, but it felt like the cleanest hack.
pfeldman 2017/03/28 03:23:38 Let me try to narrate this code: - every time key
einbinder 2017/03/28 08:28:39 The keyboard-focus class stays on until the focus
pfeldman 2017/03/28 17:44:35 This blurs the contract you are introducing. Code
1190 }, true);
1185 document.addEventListener('focus', UI._focusChanged.bind(UI), true); 1191 document.addEventListener('focus', UI._focusChanged.bind(UI), true);
1186 1192
1187 if (!UI.themeSupport) 1193 if (!UI.themeSupport)
1188 UI.themeSupport = new UI.ThemeSupport(themeSetting); 1194 UI.themeSupport = new UI.ThemeSupport(themeSetting);
1189 UI.themeSupport.applyTheme(document); 1195 UI.themeSupport.applyTheme(document);
1190 1196
1191 var body = /** @type {!Element} */ (document.body); 1197 var body = /** @type {!Element} */ (document.body);
1192 UI.appendStyle(body, 'ui/inspectorStyle.css'); 1198 UI.appendStyle(body, 'ui/inspectorStyle.css');
1193 UI.GlassPane.setContainer(/** @type {!Element} */ (document.body)); 1199 UI.GlassPane.setContainer(/** @type {!Element} */ (document.body));
1194 }; 1200 };
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 1412
1407 /** 1413 /**
1408 * @param {string} color 1414 * @param {string} color
1409 * @this {Element} 1415 * @this {Element}
1410 */ 1416 */
1411 set borderColor(color) { 1417 set borderColor(color) {
1412 this.checkboxElement.classList.add('dt-checkbox-themed'); 1418 this.checkboxElement.classList.add('dt-checkbox-themed');
1413 this.checkboxElement.style.borderColor = color; 1419 this.checkboxElement.style.borderColor = color;
1414 }, 1420 },
1415 1421
1416 /**
1417 * @param {boolean} focus
1418 * @this {Element}
1419 */
1420 set visualizeFocus(focus) {
einbinder 2017/03/14 09:14:36 This was used to selectively add focus rings to ch
1421 this.checkboxElement.classList.toggle('dt-checkbox-visualize-focus', focus );
1422 },
1423
1424 __proto__: HTMLLabelElement.prototype 1422 __proto__: HTMLLabelElement.prototype
1425 }); 1423 });
1426 1424
1427 UI.registerCustomElement('label', 'dt-icon-label', { 1425 UI.registerCustomElement('label', 'dt-icon-label', {
1428 /** 1426 /**
1429 * @this {Element} 1427 * @this {Element}
1430 */ 1428 */
1431 createdCallback: function() { 1429 createdCallback: function() {
1432 var root = UI.createShadowRootWithCoreStyles(this); 1430 var root = UI.createShadowRootWithCoreStyles(this);
1433 this._iconElement = UI.Icon.create(); 1431 this._iconElement = UI.Icon.create();
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
2064 */ 2062 */
2065 constructor(message, okCallback, cancelCallback) { 2063 constructor(message, okCallback, cancelCallback) {
2066 super(true); 2064 super(true);
2067 this.registerRequiredCSS('ui/confirmDialog.css'); 2065 this.registerRequiredCSS('ui/confirmDialog.css');
2068 this.contentElement.createChild('div', 'message').createChild('span').textCo ntent = message; 2066 this.contentElement.createChild('div', 'message').createChild('span').textCo ntent = message;
2069 var buttonsBar = this.contentElement.createChild('div', 'button'); 2067 var buttonsBar = this.contentElement.createChild('div', 'button');
2070 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Ok'), okCallback )); 2068 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Ok'), okCallback ));
2071 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Cancel'), cancel Callback)); 2069 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Cancel'), cancel Callback));
2072 } 2070 }
2073 }; 2071 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698