OLD | NEW |
---|---|
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 { | 66 { |
67 if (WebInspector.Dialog._instance) | 67 if (WebInspector.Dialog._instance) |
68 WebInspector.Dialog._instance.detach(); | 68 WebInspector.Dialog._instance.detach(); |
69 WebInspector.Dialog._instance = this; | 69 WebInspector.Dialog._instance = this; |
70 | 70 |
71 var document = /** @type {!Document} */ (WebInspector.Dialog._modalHostV iew.element.ownerDocument); | 71 var document = /** @type {!Document} */ (WebInspector.Dialog._modalHostV iew.element.ownerDocument); |
72 this._disableTabIndexOnElements(document); | 72 this._disableTabIndexOnElements(document); |
73 | 73 |
74 this._glassPane = new WebInspector.GlassPane(document, this._dimmed); | 74 this._glassPane = new WebInspector.GlassPane(document, this._dimmed); |
75 this._glassPane.element.addEventListener("click", this._onGlassPaneClick .bind(this), false); | 75 this._glassPane.element.addEventListener("click", this._onGlassPaneClick .bind(this), false); |
76 WebInspector.GlassPane.DefaultFocusedViewStack.push(this); | 76 |
77 // When a dialog closes, focus should be restored to the previous focuse d element when | |
78 // possible, otherwise the default inspector view element. | |
79 WebInspector.Dialog._previousFocusedElement = WebInspector.currentFocusE lement() || WebInspector.inspectorView.defaultFocusedElement(); | |
dgozman
2016/05/27 01:05:59
Use WebInspector.Dialog._modalHostView instead of
luoe
2016/05/27 23:20:40
Done.
| |
77 | 80 |
78 WebInspector.Widget.prototype.show.call(this, this._glassPane.element); | 81 WebInspector.Widget.prototype.show.call(this, this._glassPane.element); |
79 | 82 |
80 this._position(); | 83 this._position(); |
81 this.focus(); | 84 this.focus(); |
82 }, | 85 }, |
83 | 86 |
84 /** | 87 /** |
85 * @override | 88 * @override |
86 */ | 89 */ |
87 detach: function() | 90 detach: function() |
88 { | 91 { |
89 WebInspector.Widget.prototype.detach.call(this); | 92 WebInspector.Widget.prototype.detach.call(this); |
90 | 93 |
91 WebInspector.GlassPane.DefaultFocusedViewStack.pop(); | |
92 this._glassPane.dispose(); | 94 this._glassPane.dispose(); |
93 delete this._glassPane; | 95 delete this._glassPane; |
94 | 96 |
97 if (WebInspector.Dialog._previousFocusedElement) | |
98 WebInspector.Dialog._previousFocusedElement.focus(); | |
dgozman
2016/05/27 01:05:59
delete WebInspector.Dialog._previousFocusedElement
luoe
2016/05/27 23:20:40
Done.
| |
95 this._restoreTabIndexOnElements(); | 99 this._restoreTabIndexOnElements(); |
96 | 100 |
97 delete WebInspector.Dialog._instance; | 101 delete WebInspector.Dialog._instance; |
98 }, | 102 }, |
99 | 103 |
100 addCloseButton: function() | 104 addCloseButton: function() |
101 { | 105 { |
102 var closeButton = this.contentElement.createChild("div", "dialog-close-b utton", "dt-close-button"); | 106 var closeButton = this.contentElement.createChild("div", "dialog-close-b utton", "dt-close-button"); |
103 closeButton.gray = true; | 107 closeButton.gray = true; |
104 closeButton.addEventListener("click", this.detach.bind(this, false), fal se); | 108 closeButton.addEventListener("click", this.detach.bind(this, false), fal se); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 { | 248 { |
245 var children = this.children(); | 249 var children = this.children(); |
246 if (children.length) | 250 if (children.length) |
247 return children[0].defaultFocusedElement(); | 251 return children[0].defaultFocusedElement(); |
248 return this.element; | 252 return this.element; |
249 }, | 253 }, |
250 | 254 |
251 __proto__: WebInspector.Widget.prototype | 255 __proto__: WebInspector.Widget.prototype |
252 }; | 256 }; |
253 | 257 |
258 /** @type {?Element} */ | |
259 WebInspector.Dialog._previousFocusedElement = null; | |
260 | |
254 /** @type {?WebInspector.Widget} */ | 261 /** @type {?WebInspector.Widget} */ |
255 WebInspector.Dialog._modalHostView = null; | 262 WebInspector.Dialog._modalHostView = null; |
256 | 263 |
257 /** | 264 /** |
258 * @param {!WebInspector.Widget} view | 265 * @param {!WebInspector.Widget} view |
259 */ | 266 */ |
260 WebInspector.Dialog.setModalHostView = function(view) | 267 WebInspector.Dialog.setModalHostView = function(view) |
261 { | 268 { |
262 WebInspector.Dialog._modalHostView = view; | 269 WebInspector.Dialog._modalHostView = view; |
263 }; | 270 }; |
264 | 271 |
265 /** | 272 /** |
266 * FIXME: make utility method in Dialog, so clients use it instead of this gette r. | 273 * FIXME: make utility method in Dialog, so clients use it instead of this gette r. |
267 * Method should be like Dialog.showModalElement(position params, reposition cal lback). | 274 * Method should be like Dialog.showModalElement(position params, reposition cal lback). |
268 * @return {?WebInspector.Widget} | 275 * @return {?WebInspector.Widget} |
269 */ | 276 */ |
270 WebInspector.Dialog.modalHostView = function() | 277 WebInspector.Dialog.modalHostView = function() |
271 { | 278 { |
272 return WebInspector.Dialog._modalHostView; | 279 return WebInspector.Dialog._modalHostView; |
273 }; | 280 }; |
274 | 281 |
275 WebInspector.Dialog.modalHostRepositioned = function() | 282 WebInspector.Dialog.modalHostRepositioned = function() |
276 { | 283 { |
277 if (WebInspector.Dialog._instance) | 284 if (WebInspector.Dialog._instance) |
278 WebInspector.Dialog._instance._position(); | 285 WebInspector.Dialog._instance._position(); |
279 }; | 286 }; |
280 | 287 |
OLD | NEW |