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

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

Issue 1397403003: [DevTools] Remove HelpScreen, turn SettingsScreen into dialog and web component. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@screens
Patch Set: Created 5 years, 2 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) 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 this._wrapsContent = false; 46 this._wrapsContent = false;
47 this._dimmed = false; 47 this._dimmed = false;
48 } 48 }
49 49
50 /** 50 /**
51 * TODO(dgozman): remove this method (it's only used for shortcuts handling). 51 * TODO(dgozman): remove this method (it's only used for shortcuts handling).
52 * @return {boolean} 52 * @return {boolean}
53 */ 53 */
54 WebInspector.Dialog.hasInstance = function() 54 WebInspector.Dialog.hasInstance = function()
55 { 55 {
56 return !!WebInspector.Dialog._instance; 56 return !!WebInspector.Dialog._instances.length;
57 } 57 }
58 58
59 /** @type {!Array<!WebInspector.Dialog>} */
60 WebInspector.Dialog._instances = [];
61
59 WebInspector.Dialog.prototype = { 62 WebInspector.Dialog.prototype = {
60 /** 63 /**
61 * @override 64 * @override
62 */ 65 */
63 show: function() 66 show: function()
64 { 67 {
65 if (WebInspector.Dialog._instance) 68 WebInspector.Dialog._instances.push(this);
66 WebInspector.Dialog._instance.detach();
67 WebInspector.Dialog._instance = this;
68 69
69 this._glassPane = new WebInspector.GlassPane(/** @type {!Document} */ (W ebInspector.Dialog._modalHostView.element.ownerDocument), this._dimmed); 70 this._glassPane = new WebInspector.GlassPane(/** @type {!Document} */ (W ebInspector.Dialog._modalHostView.element.ownerDocument), this._dimmed);
70 this._glassPane.element.addEventListener("click", this._onGlassPaneClick .bind(this), false); 71 this._glassPane.element.addEventListener("click", this._onGlassPaneClick .bind(this), false);
71 WebInspector.GlassPane.DefaultFocusedViewStack.push(this); 72 WebInspector.GlassPane.DefaultFocusedViewStack.push(this);
72 73
73 WebInspector.Widget.prototype.show.call(this, this._glassPane.element); 74 WebInspector.Widget.prototype.show.call(this, this._glassPane.element);
74 75
75 this._position(); 76 this._position();
76 this.focus(); 77 this.focus();
77 }, 78 },
78 79
79 /** 80 /**
80 * @override 81 * @override
81 */ 82 */
82 detach: function() 83 detach: function()
83 { 84 {
84 WebInspector.Widget.prototype.detach.call(this); 85 WebInspector.Widget.prototype.detach.call(this);
85 86
86 WebInspector.GlassPane.DefaultFocusedViewStack.pop(); 87 WebInspector.GlassPane.DefaultFocusedViewStack.pop();
87 this._glassPane.dispose(); 88 this._glassPane.dispose();
88 delete this._glassPane; 89 delete this._glassPane;
89 90
90 delete WebInspector.Dialog._instance; 91 console.assert(this === WebInspector.Dialog._instances.peekLast());
yurys 2015/10/13 00:52:11 How can you be sure that the dialogs are not close
dgozman 2015/10/13 01:57:42 They are stacked on top of each other. The alterna
92 WebInspector.Dialog._instances.pop();
91 }, 93 },
92 94
93 addCloseButton: function() 95 addCloseButton: function()
94 { 96 {
95 var closeButton = this.contentElement.createChild("div", "dialog-close-b utton", "dt-close-button"); 97 var closeButton = this.contentElement.createChild("div", "dialog-close-b utton", "dt-close-button");
96 closeButton.gray = true; 98 closeButton.gray = true;
97 closeButton.addEventListener("click", this.detach.bind(this, false), fal se); 99 closeButton.addEventListener("click", this.detach.bind(this, false), fal se);
98 }, 100 },
99 101
100 /** 102 /**
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 * Method should be like Dialog.showModalElement(position params, reposition cal lback). 219 * Method should be like Dialog.showModalElement(position params, reposition cal lback).
218 * @return {?WebInspector.Widget} 220 * @return {?WebInspector.Widget}
219 */ 221 */
220 WebInspector.Dialog.modalHostView = function() 222 WebInspector.Dialog.modalHostView = function()
221 { 223 {
222 return WebInspector.Dialog._modalHostView; 224 return WebInspector.Dialog._modalHostView;
223 }; 225 };
224 226
225 WebInspector.Dialog.modalHostRepositioned = function() 227 WebInspector.Dialog.modalHostRepositioned = function()
226 { 228 {
227 if (WebInspector.Dialog._instance) 229 for (var index = 0; index < WebInspector.Dialog._instances.length; ++index)
228 WebInspector.Dialog._instance._position(); 230 WebInspector.Dialog._instances[index]._position();
229 }; 231 };
230 232
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698