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

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

Issue 2741863002: DevTools: Focus background in Toolbars (Closed)
Patch Set: clean up code Created 3 years, 8 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 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 UI.Widget.focusWidgetForNode(element); 787 UI.Widget.focusWidgetForNode(element);
788 if (!UI._keyboardFocus)
789 return;
790 element.setAttribute('data-keyboard-focus', 'true');
791 element.addEventListener('blur', () => element.removeAttribute('data-keyboard- focus'), {once: true, capture: true});
788 }; 792 };
789 793
790 /** 794 /**
791 * @unrestricted 795 * @unrestricted
792 */ 796 */
793 UI.ElementFocusRestorer = class { 797 UI.ElementFocusRestorer = class {
794 /** 798 /**
795 * @param {!Element} element 799 * @param {!Element} element
796 */ 800 */
797 constructor(element) { 801 constructor(element) {
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 }; 1180 };
1177 1181
1178 /** 1182 /**
1179 * @param {!Document} document 1183 * @param {!Document} document
1180 * @param {!Common.Setting} themeSetting 1184 * @param {!Common.Setting} themeSetting
1181 */ 1185 */
1182 UI.initializeUIUtils = function(document, themeSetting) { 1186 UI.initializeUIUtils = function(document, themeSetting) {
1183 document.defaultView.addEventListener('focus', UI._windowFocused.bind(UI, docu ment), false); 1187 document.defaultView.addEventListener('focus', UI._windowFocused.bind(UI, docu ment), false);
1184 document.defaultView.addEventListener('blur', UI._windowBlurred.bind(UI, docum ent), false); 1188 document.defaultView.addEventListener('blur', UI._windowBlurred.bind(UI, docum ent), false);
1185 document.addEventListener('focus', UI._focusChanged.bind(UI), true); 1189 document.addEventListener('focus', UI._focusChanged.bind(UI), true);
1190 document.addEventListener('keydown', event => {
1191 UI._keyboardFocus = true;
1192 document.defaultView.requestAnimationFrame(() => UI._keyboardFocus = false);
1193 }, true);
1186 1194
1187 if (!UI.themeSupport) 1195 if (!UI.themeSupport)
1188 UI.themeSupport = new UI.ThemeSupport(themeSetting); 1196 UI.themeSupport = new UI.ThemeSupport(themeSetting);
1189 UI.themeSupport.applyTheme(document); 1197 UI.themeSupport.applyTheme(document);
1190 1198
1191 var body = /** @type {!Element} */ (document.body); 1199 var body = /** @type {!Element} */ (document.body);
1192 UI.appendStyle(body, 'ui/inspectorStyle.css'); 1200 UI.appendStyle(body, 'ui/inspectorStyle.css');
1193 UI.GlassPane.setContainer(/** @type {!Element} */ (document.body)); 1201 UI.GlassPane.setContainer(/** @type {!Element} */ (document.body));
1194 }; 1202 };
1195 1203
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 } 1372 }
1365 1373
1366 /** 1374 /**
1367 * @param {string} color 1375 * @param {string} color
1368 * @this {Element} 1376 * @this {Element}
1369 */ 1377 */
1370 set borderColor(color) { 1378 set borderColor(color) {
1371 this.checkboxElement.classList.add('dt-checkbox-themed'); 1379 this.checkboxElement.classList.add('dt-checkbox-themed');
1372 this.checkboxElement.style.borderColor = color; 1380 this.checkboxElement.style.borderColor = color;
1373 } 1381 }
1374
1375 /**
1376 * @param {boolean} focus
1377 * @this {Element}
1378 */
1379 set visualizeFocus(focus) {
1380 this.checkboxElement.classList.toggle('dt-checkbox-visualize-focus', focus);
1381 }
1382 }; 1382 };
1383 1383
1384 (function() { 1384 (function() {
1385 UI.registerCustomElement('button', 'text-button', { 1385 UI.registerCustomElement('button', 'text-button', {
1386 /** 1386 /**
1387 * @this {Element} 1387 * @this {Element}
1388 */ 1388 */
1389 createdCallback: function() { 1389 createdCallback: function() {
1390 this.type = 'button'; 1390 this.type = 'button';
1391 var root = UI.createShadowRootWithCoreStyles(this, 'ui/textButton.css'); 1391 var root = UI.createShadowRootWithCoreStyles(this, 'ui/textButton.css');
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
2063 */ 2063 */
2064 constructor(message, okCallback, cancelCallback) { 2064 constructor(message, okCallback, cancelCallback) {
2065 super(true); 2065 super(true);
2066 this.registerRequiredCSS('ui/confirmDialog.css'); 2066 this.registerRequiredCSS('ui/confirmDialog.css');
2067 this.contentElement.createChild('div', 'message').createChild('span').textCo ntent = message; 2067 this.contentElement.createChild('div', 'message').createChild('span').textCo ntent = message;
2068 var buttonsBar = this.contentElement.createChild('div', 'button'); 2068 var buttonsBar = this.contentElement.createChild('div', 'button');
2069 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Ok'), okCallback )); 2069 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Ok'), okCallback ));
2070 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Cancel'), cancel Callback)); 2070 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Cancel'), cancel Callback));
2071 } 2071 }
2072 }; 2072 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698