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

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

Issue 2741863002: DevTools: Focus background in Toolbars (Closed)
Patch Set: remove host-context 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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 } 1179 }
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);
1189 document.addEventListener('keydown', event => {
1190 UI._keyboardFocus = true;
1191 document.defaultView.requestAnimationFrame(() => UI._keyboardFocus = false);
1192 }, true);
1185 document.addEventListener('focus', UI._focusChanged.bind(UI), true); 1193 document.addEventListener('focus', UI._focusChanged.bind(UI), 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 };
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 1414
1407 /** 1415 /**
1408 * @param {string} color 1416 * @param {string} color
1409 * @this {Element} 1417 * @this {Element}
1410 */ 1418 */
1411 set borderColor(color) { 1419 set borderColor(color) {
1412 this.checkboxElement.classList.add('dt-checkbox-themed'); 1420 this.checkboxElement.classList.add('dt-checkbox-themed');
1413 this.checkboxElement.style.borderColor = color; 1421 this.checkboxElement.style.borderColor = color;
1414 }, 1422 },
1415 1423
1416 /**
1417 * @param {boolean} focus
1418 * @this {Element}
1419 */
1420 set visualizeFocus(focus) {
1421 this.checkboxElement.classList.toggle('dt-checkbox-visualize-focus', focus );
1422 },
1423
1424 __proto__: HTMLLabelElement.prototype 1424 __proto__: HTMLLabelElement.prototype
1425 }); 1425 });
1426 1426
1427 UI.registerCustomElement('label', 'dt-icon-label', { 1427 UI.registerCustomElement('label', 'dt-icon-label', {
1428 /** 1428 /**
1429 * @this {Element} 1429 * @this {Element}
1430 */ 1430 */
1431 createdCallback: function() { 1431 createdCallback: function() {
1432 var root = UI.createShadowRootWithCoreStyles(this); 1432 var root = UI.createShadowRootWithCoreStyles(this);
1433 this._iconElement = UI.Icon.create(); 1433 this._iconElement = UI.Icon.create();
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
2064 */ 2064 */
2065 constructor(message, okCallback, cancelCallback) { 2065 constructor(message, okCallback, cancelCallback) {
2066 super(true); 2066 super(true);
2067 this.registerRequiredCSS('ui/confirmDialog.css'); 2067 this.registerRequiredCSS('ui/confirmDialog.css');
2068 this.contentElement.createChild('div', 'message').createChild('span').textCo ntent = message; 2068 this.contentElement.createChild('div', 'message').createChild('span').textCo ntent = message;
2069 var buttonsBar = this.contentElement.createChild('div', 'button'); 2069 var buttonsBar = this.contentElement.createChild('div', 'button');
2070 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Ok'), okCallback )); 2070 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Ok'), okCallback ));
2071 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Cancel'), cancel Callback)); 2071 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Cancel'), cancel Callback));
2072 } 2072 }
2073 }; 2073 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698