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

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

Issue 2094873002: DevTools: fix deepActiveElement and focus on Dialog when document blurs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 4 years, 5 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 | « third_party/WebKit/Source/devtools/front_end/settings/FrameworkBlackboxSettingsTab.js ('k') | 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 23 matching lines...) Expand all
34 */ 34 */
35 WebInspector.Dialog = function() 35 WebInspector.Dialog = function()
36 { 36 {
37 WebInspector.Widget.call(this, true); 37 WebInspector.Widget.call(this, true);
38 this.markAsRoot(); 38 this.markAsRoot();
39 this.registerRequiredCSS("ui/dialog.css"); 39 this.registerRequiredCSS("ui/dialog.css");
40 40
41 this.contentElement.createChild("content"); 41 this.contentElement.createChild("content");
42 this.contentElement.tabIndex = 0; 42 this.contentElement.tabIndex = 0;
43 this.contentElement.addEventListener("focus", this._onFocus.bind(this), fals e); 43 this.contentElement.addEventListener("focus", this._onFocus.bind(this), fals e);
44 this.contentElement.addEventListener("keydown", this._onKeyDown.bind(this), false); 44 this._keyDownBound = this._onKeyDown.bind(this);
45 45
46 this._wrapsContent = false; 46 this._wrapsContent = false;
47 this._dimmed = false; 47 this._dimmed = false;
48 /** @type {!Map<!HTMLElement, number>} */ 48 /** @type {!Map<!HTMLElement, number>} */
49 this._tabIndexMap = new Map(); 49 this._tabIndexMap = new Map();
50 } 50 }
51 51
52 /** 52 /**
53 * TODO(dgozman): remove this method (it's only used for shortcuts handling).
54 * @return {boolean} 53 * @return {boolean}
55 */ 54 */
56 WebInspector.Dialog.hasInstance = function() 55 WebInspector.Dialog.hasInstance = function()
57 { 56 {
58 return !!WebInspector.Dialog._instance; 57 return !!WebInspector.Dialog._instance;
59 } 58 }
60 59
60 WebInspector.Dialog.focus = function()
dgozman 2016/06/30 17:06:55 Unused.
luoe 2016/06/30 17:48:05 Done.
61 {
62 if (WebInspector.Dialog._instance)
63 WebInspector.Dialog._instance.focus();
64 }
65
61 WebInspector.Dialog.prototype = { 66 WebInspector.Dialog.prototype = {
62 /** 67 /**
63 * @override 68 * @override
64 */ 69 */
65 show: function() 70 show: function()
66 { 71 {
67 if (WebInspector.Dialog._instance) 72 if (WebInspector.Dialog._instance)
68 WebInspector.Dialog._instance.detach(); 73 WebInspector.Dialog._instance.detach();
69 WebInspector.Dialog._instance = this; 74 WebInspector.Dialog._instance = this;
70 75
71 var document = /** @type {!Document} */ (WebInspector.Dialog._modalHostV iew.element.ownerDocument); 76 var document = /** @type {!Document} */ (WebInspector.Dialog._modalHostV iew.element.ownerDocument);
72 this._disableTabIndexOnElements(document); 77 this._disableTabIndexOnElements(document);
73 78
74 this._glassPane = new WebInspector.GlassPane(document, this._dimmed); 79 this._glassPane = new WebInspector.GlassPane(document, this._dimmed);
75 this._glassPane.element.addEventListener("click", this._onGlassPaneClick .bind(this), false); 80 this._glassPane.element.addEventListener("click", this._onGlassPaneClick .bind(this), false);
81 this.element.ownerDocument.body.addEventListener("keydown", this._keyDow nBound, false);
76 82
77 // When a dialog closes, focus should be restored to the previous focuse d element when 83 // When a dialog closes, focus should be restored to the previous focuse d element when
78 // possible, otherwise the default inspector view element. 84 // possible, otherwise the default inspector view element.
79 WebInspector.Dialog._previousFocusedElement = WebInspector.currentFocusE lement() || WebInspector.Dialog._modalHostView.defaultFocusedElement(); 85 WebInspector.Dialog._previousFocusedElement = WebInspector.currentFocusE lement() || WebInspector.Dialog._modalHostView.defaultFocusedElement();
80 86
81 WebInspector.Widget.prototype.show.call(this, this._glassPane.element); 87 WebInspector.Widget.prototype.show.call(this, this._glassPane.element);
82 88
83 this._position(); 89 this._position();
84 this.focus(); 90 this.focus();
85 }, 91 },
86 92
87 /** 93 /**
88 * @override 94 * @override
89 */ 95 */
90 detach: function() 96 detach: function()
91 { 97 {
98 this.element.ownerDocument.body.removeEventListener("keydown", this._key DownBound, false);
92 WebInspector.Widget.prototype.detach.call(this); 99 WebInspector.Widget.prototype.detach.call(this);
93 100
94 this._glassPane.dispose(); 101 this._glassPane.dispose();
95 delete this._glassPane; 102 delete this._glassPane;
96 103
97 if (WebInspector.Dialog._previousFocusedElement) 104 if (WebInspector.Dialog._previousFocusedElement)
98 WebInspector.Dialog._previousFocusedElement.focus(); 105 WebInspector.Dialog._previousFocusedElement.focus();
99 delete WebInspector.Dialog._previousFocusedElement; 106 delete WebInspector.Dialog._previousFocusedElement;
100 107
101 this._restoreTabIndexOnElements(); 108 this._restoreTabIndexOnElements();
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 { 287 {
281 return WebInspector.Dialog._modalHostView; 288 return WebInspector.Dialog._modalHostView;
282 }; 289 };
283 290
284 WebInspector.Dialog.modalHostRepositioned = function() 291 WebInspector.Dialog.modalHostRepositioned = function()
285 { 292 {
286 if (WebInspector.Dialog._instance) 293 if (WebInspector.Dialog._instance)
287 WebInspector.Dialog._instance._position(); 294 WebInspector.Dialog._instance._position();
288 }; 295 };
289 296
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/settings/FrameworkBlackboxSettingsTab.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698