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 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * | 10 * |
(...skipping 10 matching lines...) Expand all Loading... |
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 */ | 27 */ |
28 | 28 |
29 /** | 29 /** |
30 * @constructor | 30 * @constructor |
31 * @extends {WebInspector.View} | 31 * @extends {WebInspector.Widget} |
32 * @param {boolean} isVertical | 32 * @param {boolean} isVertical |
33 * @param {boolean} secondIsSidebar | 33 * @param {boolean} secondIsSidebar |
34 * @param {string=} settingName | 34 * @param {string=} settingName |
35 * @param {number=} defaultSidebarWidth | 35 * @param {number=} defaultSidebarWidth |
36 * @param {number=} defaultSidebarHeight | 36 * @param {number=} defaultSidebarHeight |
37 * @param {boolean=} constraintsInDip | 37 * @param {boolean=} constraintsInDip |
38 */ | 38 */ |
39 WebInspector.SplitView = function(isVertical, secondIsSidebar, settingName, defa
ultSidebarWidth, defaultSidebarHeight, constraintsInDip) | 39 WebInspector.SplitWidget = function(isVertical, secondIsSidebar, settingName, de
faultSidebarWidth, defaultSidebarHeight, constraintsInDip) |
40 { | 40 { |
41 WebInspector.View.call(this, true); | 41 WebInspector.Widget.call(this, true); |
42 this.element.classList.add("split-view"); | 42 this.element.classList.add("split-widget"); |
43 this.registerRequiredCSS("ui/splitView.css"); | 43 this.registerRequiredCSS("ui/splitWidget.css"); |
44 | 44 |
45 this.contentElement.classList.add("shadow-split-view"); | 45 this.contentElement.classList.add("shadow-split-widget"); |
46 this._mainElement = this.contentElement.createChild("div", "shadow-split-vie
w-contents shadow-split-view-main vbox"); | 46 this._mainElement = this.contentElement.createChild("div", "shadow-split-wid
get-contents shadow-split-widget-main vbox"); |
47 this._mainElement.createChild("content").select = ".insertion-point-main"; | 47 this._mainElement.createChild("content").select = ".insertion-point-main"; |
48 this._sidebarElement = this.contentElement.createChild("div", "shadow-split-
view-contents shadow-split-view-sidebar vbox"); | 48 this._sidebarElement = this.contentElement.createChild("div", "shadow-split-
widget-contents shadow-split-widget-sidebar vbox"); |
49 this._sidebarElement.createChild("content").select = ".insertion-point-sideb
ar"; | 49 this._sidebarElement.createChild("content").select = ".insertion-point-sideb
ar"; |
50 this._resizerElement = this.contentElement.createChild("div", "shadow-split-
view-resizer"); | 50 this._resizerElement = this.contentElement.createChild("div", "shadow-split-
widget-resizer"); |
51 | 51 |
52 this._resizerWidget = new WebInspector.SimpleResizerWidget(); | 52 this._resizerWidget = new WebInspector.SimpleResizerWidget(); |
53 this._resizerWidget.setEnabled(true); | 53 this._resizerWidget.setEnabled(true); |
54 this._resizerWidget.addEventListener(WebInspector.ResizerWidget.Events.Resiz
eStart, this._onResizeStart, this); | 54 this._resizerWidget.addEventListener(WebInspector.ResizerWidget.Events.Resiz
eStart, this._onResizeStart, this); |
55 this._resizerWidget.addEventListener(WebInspector.ResizerWidget.Events.Resiz
eUpdate, this._onResizeUpdate, this); | 55 this._resizerWidget.addEventListener(WebInspector.ResizerWidget.Events.Resiz
eUpdate, this._onResizeUpdate, this); |
56 this._resizerWidget.addEventListener(WebInspector.ResizerWidget.Events.Resiz
eEnd, this._onResizeEnd, this); | 56 this._resizerWidget.addEventListener(WebInspector.ResizerWidget.Events.Resiz
eEnd, this._onResizeEnd, this); |
57 | 57 |
58 this._defaultSidebarWidth = defaultSidebarWidth || 200; | 58 this._defaultSidebarWidth = defaultSidebarWidth || 200; |
59 this._defaultSidebarHeight = defaultSidebarHeight || this._defaultSidebarWid
th; | 59 this._defaultSidebarHeight = defaultSidebarHeight || this._defaultSidebarWid
th; |
60 this._constraintsInDip = !!constraintsInDip; | 60 this._constraintsInDip = !!constraintsInDip; |
61 this._setting = settingName ? WebInspector.settings.createSetting(settingNam
e, {}) : null; | 61 this._setting = settingName ? WebInspector.settings.createSetting(settingNam
e, {}) : null; |
62 | 62 |
63 this.setSecondIsSidebar(secondIsSidebar); | 63 this.setSecondIsSidebar(secondIsSidebar); |
64 | 64 |
65 this._innerSetVertical(isVertical); | 65 this._innerSetVertical(isVertical); |
66 this._showMode = WebInspector.SplitView.ShowMode.Both; | 66 this._showMode = WebInspector.SplitWidget.ShowMode.Both; |
67 | 67 |
68 // Should be called after isVertical has the right value. | 68 // Should be called after isVertical has the right value. |
69 this.installResizer(this._resizerElement); | 69 this.installResizer(this._resizerElement); |
70 } | 70 } |
71 | 71 |
72 /** @typedef {{showMode: string, size: number}} */ | 72 /** @typedef {{showMode: string, size: number}} */ |
73 WebInspector.SplitView.SettingForOrientation; | 73 WebInspector.SplitWidget.SettingForOrientation; |
74 | 74 |
75 WebInspector.SplitView.ShowMode = { | 75 WebInspector.SplitWidget.ShowMode = { |
76 Both: "Both", | 76 Both: "Both", |
77 OnlyMain: "OnlyMain", | 77 OnlyMain: "OnlyMain", |
78 OnlySidebar: "OnlySidebar" | 78 OnlySidebar: "OnlySidebar" |
79 } | 79 } |
80 | 80 |
81 WebInspector.SplitView.Events = { | 81 WebInspector.SplitWidget.Events = { |
82 SidebarSizeChanged: "SidebarSizeChanged", | 82 SidebarSizeChanged: "SidebarSizeChanged", |
83 ShowModeChanged: "ShowModeChanged" | 83 ShowModeChanged: "ShowModeChanged" |
84 } | 84 } |
85 | 85 |
86 WebInspector.SplitView.MinPadding = 20; | 86 WebInspector.SplitWidget.MinPadding = 20; |
87 | 87 |
88 WebInspector.SplitView.prototype = { | 88 WebInspector.SplitWidget.prototype = { |
89 /** | 89 /** |
90 * @return {boolean} | 90 * @return {boolean} |
91 */ | 91 */ |
92 isVertical: function() | 92 isVertical: function() |
93 { | 93 { |
94 return this._isVertical; | 94 return this._isVertical; |
95 }, | 95 }, |
96 | 96 |
97 /** | 97 /** |
98 * @param {boolean} isVertical | 98 * @param {boolean} isVertical |
(...skipping 17 matching lines...) Expand all Loading... |
116 this.contentElement.classList.toggle("vbox", !isVertical); | 116 this.contentElement.classList.toggle("vbox", !isVertical); |
117 this.contentElement.classList.toggle("hbox", isVertical); | 117 this.contentElement.classList.toggle("hbox", isVertical); |
118 this._isVertical = isVertical; | 118 this._isVertical = isVertical; |
119 | 119 |
120 delete this._resizerElementSize; | 120 delete this._resizerElementSize; |
121 this._sidebarSizeDIP = -1; | 121 this._sidebarSizeDIP = -1; |
122 this._restoreSidebarSizeFromSettings(); | 122 this._restoreSidebarSizeFromSettings(); |
123 if (this._shouldSaveShowMode) | 123 if (this._shouldSaveShowMode) |
124 this._restoreAndApplyShowModeFromSettings(); | 124 this._restoreAndApplyShowModeFromSettings(); |
125 this._updateShowHideSidebarButton(); | 125 this._updateShowHideSidebarButton(); |
126 // FIXME: reverse SplitView.isVertical meaning. | 126 // FIXME: reverse SplitWidget.isVertical meaning. |
127 this._resizerWidget.setVertical(!isVertical); | 127 this._resizerWidget.setVertical(!isVertical); |
128 this.invalidateConstraints(); | 128 this.invalidateConstraints(); |
129 }, | 129 }, |
130 | 130 |
131 /** | 131 /** |
132 * @param {boolean=} animate | 132 * @param {boolean=} animate |
133 */ | 133 */ |
134 _updateLayout: function(animate) | 134 _updateLayout: function(animate) |
135 { | 135 { |
136 delete this._totalSizeCSS; // Lazy update. | 136 delete this._totalSizeCSS; // Lazy update. |
137 delete this._totalSizeOtherDimensionCSS; | 137 delete this._totalSizeOtherDimensionCSS; |
138 | 138 |
139 // Remove properties that might affect total size calculation. | 139 // Remove properties that might affect total size calculation. |
140 this._mainElement.style.removeProperty("width"); | 140 this._mainElement.style.removeProperty("width"); |
141 this._mainElement.style.removeProperty("height"); | 141 this._mainElement.style.removeProperty("height"); |
142 this._sidebarElement.style.removeProperty("width"); | 142 this._sidebarElement.style.removeProperty("width"); |
143 this._sidebarElement.style.removeProperty("height"); | 143 this._sidebarElement.style.removeProperty("height"); |
144 | 144 |
145 this._innerSetSidebarSizeDIP(this._preferredSidebarSizeDIP(), !!animate)
; | 145 this._innerSetSidebarSizeDIP(this._preferredSidebarSizeDIP(), !!animate)
; |
146 }, | 146 }, |
147 | 147 |
148 /** | 148 /** |
149 * @param {!WebInspector.View} view | 149 * @param {!WebInspector.Widget} widget |
150 */ | 150 */ |
151 setMainView: function(view) | 151 setMainWidget: function(widget) |
152 { | 152 { |
153 if (this._mainView) | 153 if (this._mainWidget) |
154 this._mainView.detach(); | 154 this._mainWidget.detach(); |
155 this._mainView = view; | 155 this._mainWidget = widget; |
156 if (view) { | 156 if (widget) { |
157 view.element.classList.add("insertion-point-main"); | 157 widget.element.classList.add("insertion-point-main"); |
158 view.element.classList.remove("insertion-point-sidebar"); | 158 widget.element.classList.remove("insertion-point-sidebar"); |
159 if (this._showMode === WebInspector.SplitView.ShowMode.OnlyMain || t
his._showMode === WebInspector.SplitView.ShowMode.Both) | 159 if (this._showMode === WebInspector.SplitWidget.ShowMode.OnlyMain ||
this._showMode === WebInspector.SplitWidget.ShowMode.Both) |
160 view.show(this.element); | 160 widget.show(this.element); |
161 } | 161 } |
162 }, | 162 }, |
163 | 163 |
164 /** | 164 /** |
165 * @param {!WebInspector.View} view | 165 * @param {!WebInspector.Widget} widget |
166 */ | 166 */ |
167 setSidebarView: function(view) | 167 setSidebarWidget: function(widget) |
168 { | 168 { |
169 if (this._sidebarView) | 169 if (this._sidebarWidget) |
170 this._sidebarView.detach(); | 170 this._sidebarWidget.detach(); |
171 this._sidebarView = view; | 171 this._sidebarWidget = widget; |
172 if (view) { | 172 if (widget) { |
173 view.element.classList.add("insertion-point-sidebar"); | 173 widget.element.classList.add("insertion-point-sidebar"); |
174 view.element.classList.remove("insertion-point-main"); | 174 widget.element.classList.remove("insertion-point-main"); |
175 if (this._showMode === WebInspector.SplitView.ShowMode.OnlySidebar |
| this._showMode === WebInspector.SplitView.ShowMode.Both) | 175 if (this._showMode === WebInspector.SplitWidget.ShowMode.OnlySidebar
|| this._showMode === WebInspector.SplitWidget.ShowMode.Both) |
176 view.show(this.element); | 176 widget.show(this.element); |
177 } | 177 } |
178 }, | 178 }, |
179 | 179 |
180 /** | 180 /** |
181 * @return {?WebInspector.View} | 181 * @return {?WebInspector.Widget} |
182 */ | 182 */ |
183 mainView: function() | 183 mainWidget: function() |
184 { | 184 { |
185 return this._mainView; | 185 return this._mainWidget; |
186 }, | 186 }, |
187 | 187 |
188 /** | 188 /** |
189 * @return {?WebInspector.View} | 189 * @return {?WebInspector.Widget} |
190 */ | 190 */ |
191 sidebarView: function() | 191 sidebarWidget: function() |
192 { | 192 { |
193 return this._sidebarView; | 193 return this._sidebarWidget; |
194 }, | 194 }, |
195 | 195 |
196 /** | 196 /** |
197 * @override | 197 * @override |
198 * @param {!WebInspector.View} view | 198 * @param {!WebInspector.Widget} widget |
199 */ | 199 */ |
200 childWasDetached: function(view) | 200 childWasDetached: function(widget) |
201 { | 201 { |
202 if (this._detaching) | 202 if (this._detaching) |
203 return; | 203 return; |
204 if (this._mainView === view) | 204 if (this._mainWidget === widget) |
205 delete this._mainView; | 205 delete this._mainWidget; |
206 if (this._sidebarView === view) | 206 if (this._sidebarWidget === widget) |
207 delete this._sidebarView; | 207 delete this._sidebarWidget; |
208 }, | 208 }, |
209 | 209 |
210 /** | 210 /** |
211 * @return {boolean} | 211 * @return {boolean} |
212 */ | 212 */ |
213 isSidebarSecond: function() | 213 isSidebarSecond: function() |
214 { | 214 { |
215 return this._secondIsSidebar; | 215 return this._secondIsSidebar; |
216 }, | 216 }, |
217 | 217 |
218 enableShowModeSaving: function() | 218 enableShowModeSaving: function() |
219 { | 219 { |
220 this._shouldSaveShowMode = true; | 220 this._shouldSaveShowMode = true; |
221 this._restoreAndApplyShowModeFromSettings(); | 221 this._restoreAndApplyShowModeFromSettings(); |
222 }, | 222 }, |
223 | 223 |
224 /** | 224 /** |
225 * @return {string} | 225 * @return {string} |
226 */ | 226 */ |
227 showMode: function() | 227 showMode: function() |
228 { | 228 { |
229 return this._showMode; | 229 return this._showMode; |
230 }, | 230 }, |
231 | 231 |
232 /** | 232 /** |
233 * @param {boolean} secondIsSidebar | 233 * @param {boolean} secondIsSidebar |
234 */ | 234 */ |
235 setSecondIsSidebar: function(secondIsSidebar) | 235 setSecondIsSidebar: function(secondIsSidebar) |
236 { | 236 { |
237 this.contentElement.classList.toggle("shadow-split-view-first-is-sidebar
", !secondIsSidebar); | 237 this.contentElement.classList.toggle("shadow-split-widget-first-is-sideb
ar", !secondIsSidebar); |
238 this._secondIsSidebar = secondIsSidebar; | 238 this._secondIsSidebar = secondIsSidebar; |
239 }, | 239 }, |
240 | 240 |
241 /** | 241 /** |
242 * @return {?string} | 242 * @return {?string} |
243 */ | 243 */ |
244 sidebarSide: function() | 244 sidebarSide: function() |
245 { | 245 { |
246 if (this._showMode !== WebInspector.SplitView.ShowMode.Both) | 246 if (this._showMode !== WebInspector.SplitWidget.ShowMode.Both) |
247 return null; | 247 return null; |
248 return this._isVertical ? | 248 return this._isVertical ? |
249 (this._secondIsSidebar ? "right" : "left") : | 249 (this._secondIsSidebar ? "right" : "left") : |
250 (this._secondIsSidebar ? "bottom" : "top"); | 250 (this._secondIsSidebar ? "bottom" : "top"); |
251 }, | 251 }, |
252 | 252 |
253 /** | 253 /** |
254 * @return {!Element} | 254 * @return {!Element} |
255 */ | 255 */ |
256 resizerElement: function() | 256 resizerElement: function() |
257 { | 257 { |
258 return this._resizerElement; | 258 return this._resizerElement; |
259 }, | 259 }, |
260 | 260 |
261 /** | 261 /** |
262 * @param {boolean=} animate | 262 * @param {boolean=} animate |
263 */ | 263 */ |
264 hideMain: function(animate) | 264 hideMain: function(animate) |
265 { | 265 { |
266 this._showOnly(this._sidebarView, this._mainView, this._sidebarElement,
this._mainElement, animate); | 266 this._showOnly(this._sidebarWidget, this._mainWidget, this._sidebarEleme
nt, this._mainElement, animate); |
267 this._updateShowMode(WebInspector.SplitView.ShowMode.OnlySidebar); | 267 this._updateShowMode(WebInspector.SplitWidget.ShowMode.OnlySidebar); |
268 }, | 268 }, |
269 | 269 |
270 /** | 270 /** |
271 * @param {boolean=} animate | 271 * @param {boolean=} animate |
272 */ | 272 */ |
273 hideSidebar: function(animate) | 273 hideSidebar: function(animate) |
274 { | 274 { |
275 this._showOnly(this._mainView, this._sidebarView, this._mainElement, thi
s._sidebarElement, animate); | 275 this._showOnly(this._mainWidget, this._sidebarWidget, this._mainElement,
this._sidebarElement, animate); |
276 this._updateShowMode(WebInspector.SplitView.ShowMode.OnlyMain); | 276 this._updateShowMode(WebInspector.SplitWidget.ShowMode.OnlyMain); |
277 }, | 277 }, |
278 | 278 |
279 /** | 279 /** |
280 * @param {!WebInspector.View} sideToShow | 280 * @param {!WebInspector.Widget} sideToShow |
281 * @param {!WebInspector.View} sideToHide | 281 * @param {!WebInspector.Widget} sideToHide |
282 * @param {!Element} shadowToShow | 282 * @param {!Element} shadowToShow |
283 * @param {!Element} shadowToHide | 283 * @param {!Element} shadowToHide |
284 * @param {boolean=} animate | 284 * @param {boolean=} animate |
285 */ | 285 */ |
286 _showOnly: function(sideToShow, sideToHide, shadowToShow, shadowToHide, anim
ate) | 286 _showOnly: function(sideToShow, sideToHide, shadowToShow, shadowToHide, anim
ate) |
287 { | 287 { |
288 this._cancelAnimation(); | 288 this._cancelAnimation(); |
289 | 289 |
290 /** | 290 /** |
291 * @this {WebInspector.SplitView} | 291 * @this {WebInspector.SplitWidget} |
292 */ | 292 */ |
293 function callback() | 293 function callback() |
294 { | 294 { |
295 if (sideToShow) { | 295 if (sideToShow) { |
296 // Make sure main is first in the children list. | 296 // Make sure main is first in the children list. |
297 if (sideToShow === this._mainView) | 297 if (sideToShow === this._mainWidget) |
298 this._mainView.show(this.element, this._sidebarView ? this._
sidebarView.element : null); | 298 this._mainWidget.show(this.element, this._sidebarWidget ? th
is._sidebarWidget.element : null); |
299 else | 299 else |
300 this._sidebarView.show(this.element); | 300 this._sidebarWidget.show(this.element); |
301 } | 301 } |
302 if (sideToHide) { | 302 if (sideToHide) { |
303 this._detaching = true; | 303 this._detaching = true; |
304 sideToHide.detach(); | 304 sideToHide.detach(); |
305 delete this._detaching; | 305 delete this._detaching; |
306 } | 306 } |
307 | 307 |
308 this._resizerElement.classList.add("hidden"); | 308 this._resizerElement.classList.add("hidden"); |
309 shadowToShow.classList.remove("hidden"); | 309 shadowToShow.classList.remove("hidden"); |
310 shadowToShow.classList.add("maximized"); | 310 shadowToShow.classList.add("maximized"); |
(...skipping 30 matching lines...) Expand all Loading... |
341 this._resizerElement.style.removeProperty("margin-right"); | 341 this._resizerElement.style.removeProperty("margin-right"); |
342 this._resizerElement.style.removeProperty("margin-top"); | 342 this._resizerElement.style.removeProperty("margin-top"); |
343 this._resizerElement.style.removeProperty("margin-bottom"); | 343 this._resizerElement.style.removeProperty("margin-bottom"); |
344 }, | 344 }, |
345 | 345 |
346 /** | 346 /** |
347 * @param {boolean=} animate | 347 * @param {boolean=} animate |
348 */ | 348 */ |
349 showBoth: function(animate) | 349 showBoth: function(animate) |
350 { | 350 { |
351 if (this._showMode === WebInspector.SplitView.ShowMode.Both) | 351 if (this._showMode === WebInspector.SplitWidget.ShowMode.Both) |
352 animate = false; | 352 animate = false; |
353 | 353 |
354 this._cancelAnimation(); | 354 this._cancelAnimation(); |
355 this._mainElement.classList.remove("maximized", "hidden"); | 355 this._mainElement.classList.remove("maximized", "hidden"); |
356 this._sidebarElement.classList.remove("maximized", "hidden"); | 356 this._sidebarElement.classList.remove("maximized", "hidden"); |
357 this._resizerElement.classList.remove("hidden"); | 357 this._resizerElement.classList.remove("hidden"); |
358 | 358 |
359 // Make sure main is the first in the children list. | 359 // Make sure main is the first in the children list. |
360 if (this._sidebarView) | 360 if (this._sidebarWidget) |
361 this._sidebarView.show(this.element); | 361 this._sidebarWidget.show(this.element); |
362 if (this._mainView) | 362 if (this._mainWidget) |
363 this._mainView.show(this.element, this._sidebarView ? this._sidebarV
iew.element : null); | 363 this._mainWidget.show(this.element, this._sidebarWidget ? this._side
barWidget.element : null); |
364 // Order views in DOM properly. | 364 // Order widgets in DOM properly. |
365 this.setSecondIsSidebar(this._secondIsSidebar); | 365 this.setSecondIsSidebar(this._secondIsSidebar); |
366 | 366 |
367 this._sidebarSizeDIP = -1; | 367 this._sidebarSizeDIP = -1; |
368 this.setResizable(true); | 368 this.setResizable(true); |
369 this._updateShowMode(WebInspector.SplitView.ShowMode.Both); | 369 this._updateShowMode(WebInspector.SplitWidget.ShowMode.Both); |
370 this._updateLayout(animate); | 370 this._updateLayout(animate); |
371 }, | 371 }, |
372 | 372 |
373 /** | 373 /** |
374 * @param {boolean} resizable | 374 * @param {boolean} resizable |
375 */ | 375 */ |
376 setResizable: function(resizable) | 376 setResizable: function(resizable) |
377 { | 377 { |
378 this._resizerWidget.setEnabled(resizable); | 378 this._resizerWidget.setEnabled(resizable); |
379 }, | 379 }, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 }, | 420 }, |
421 | 421 |
422 /** | 422 /** |
423 * @param {string} showMode | 423 * @param {string} showMode |
424 */ | 424 */ |
425 _updateShowMode: function(showMode) | 425 _updateShowMode: function(showMode) |
426 { | 426 { |
427 this._showMode = showMode; | 427 this._showMode = showMode; |
428 this._saveShowModeToSettings(); | 428 this._saveShowModeToSettings(); |
429 this._updateShowHideSidebarButton(); | 429 this._updateShowHideSidebarButton(); |
430 this.dispatchEventToListeners(WebInspector.SplitView.Events.ShowModeChan
ged, showMode); | 430 this.dispatchEventToListeners(WebInspector.SplitWidget.Events.ShowModeCh
anged, showMode); |
431 this.invalidateConstraints(); | 431 this.invalidateConstraints(); |
432 }, | 432 }, |
433 | 433 |
434 /** | 434 /** |
435 * @param {number} sizeDIP | 435 * @param {number} sizeDIP |
436 * @param {boolean} animate | 436 * @param {boolean} animate |
437 * @param {boolean=} userAction | 437 * @param {boolean=} userAction |
438 */ | 438 */ |
439 _innerSetSidebarSizeDIP: function(sizeDIP, animate, userAction) | 439 _innerSetSidebarSizeDIP: function(sizeDIP, animate, userAction) |
440 { | 440 { |
441 if (this._showMode !== WebInspector.SplitView.ShowMode.Both || !this.isS
howing()) | 441 if (this._showMode !== WebInspector.SplitWidget.ShowMode.Both || !this.i
sShowing()) |
442 return; | 442 return; |
443 | 443 |
444 sizeDIP = this._applyConstraints(sizeDIP, userAction); | 444 sizeDIP = this._applyConstraints(sizeDIP, userAction); |
445 if (this._sidebarSizeDIP === sizeDIP) | 445 if (this._sidebarSizeDIP === sizeDIP) |
446 return; | 446 return; |
447 | 447 |
448 if (!this._resizerElementSize) | 448 if (!this._resizerElementSize) |
449 this._resizerElementSize = this._isVertical ? this._resizerElement.o
ffsetWidth : this._resizerElement.offsetHeight; | 449 this._resizerElementSize = this._isVertical ? this._resizerElement.o
ffsetWidth : this._resizerElement.offsetHeight; |
450 | 450 |
451 // Invalidate layout below. | 451 // Invalidate layout below. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 | 491 |
492 this._sidebarSizeDIP = sizeDIP; | 492 this._sidebarSizeDIP = sizeDIP; |
493 | 493 |
494 // Force layout. | 494 // Force layout. |
495 | 495 |
496 if (animate) { | 496 if (animate) { |
497 this._animate(false); | 497 this._animate(false); |
498 } else { | 498 } else { |
499 // No need to recalculate this._sidebarSizeDIP and this._totalSizeDI
P again. | 499 // No need to recalculate this._sidebarSizeDIP and this._totalSizeDI
P again. |
500 this.doResize(); | 500 this.doResize(); |
501 this.dispatchEventToListeners(WebInspector.SplitView.Events.SidebarS
izeChanged, this.sidebarSize()); | 501 this.dispatchEventToListeners(WebInspector.SplitWidget.Events.Sideba
rSizeChanged, this.sidebarSize()); |
502 } | 502 } |
503 }, | 503 }, |
504 | 504 |
505 /** | 505 /** |
506 * @param {boolean} reverse | 506 * @param {boolean} reverse |
507 * @param {function()=} callback | 507 * @param {function()=} callback |
508 */ | 508 */ |
509 _animate: function(reverse, callback) | 509 _animate: function(reverse, callback) |
510 { | 510 { |
511 var animationTime = 50; | 511 var animationTime = 50; |
(...skipping 11 matching lines...) Expand all Loading... |
523 // This order of things is important. | 523 // This order of things is important. |
524 // 1. Resize main element early and force layout. | 524 // 1. Resize main element early and force layout. |
525 this.contentElement.style.setProperty(animatedMarginPropertyName, margin
From); | 525 this.contentElement.style.setProperty(animatedMarginPropertyName, margin
From); |
526 if (!reverse) { | 526 if (!reverse) { |
527 suppressUnused(this._mainElement.offsetWidth); | 527 suppressUnused(this._mainElement.offsetWidth); |
528 suppressUnused(this._sidebarElement.offsetWidth); | 528 suppressUnused(this._sidebarElement.offsetWidth); |
529 } | 529 } |
530 | 530 |
531 // 2. Issue onresize to the sidebar element, its size won't change. | 531 // 2. Issue onresize to the sidebar element, its size won't change. |
532 if (!reverse) | 532 if (!reverse) |
533 this._sidebarView.doResize(); | 533 this._sidebarWidget.doResize(); |
534 | 534 |
535 // 3. Configure and run animation | 535 // 3. Configure and run animation |
536 this.contentElement.style.setProperty("transition", animatedMarginProper
tyName + " " + animationTime + "ms linear"); | 536 this.contentElement.style.setProperty("transition", animatedMarginProper
tyName + " " + animationTime + "ms linear"); |
537 | 537 |
538 var boundAnimationFrame; | 538 var boundAnimationFrame; |
539 var startTime; | 539 var startTime; |
540 /** | 540 /** |
541 * @this {WebInspector.SplitView} | 541 * @this {WebInspector.SplitWidget} |
542 */ | 542 */ |
543 function animationFrame() | 543 function animationFrame() |
544 { | 544 { |
545 delete this._animationFrameHandle; | 545 delete this._animationFrameHandle; |
546 | 546 |
547 if (!startTime) { | 547 if (!startTime) { |
548 // Kick animation on first frame. | 548 // Kick animation on first frame. |
549 this.contentElement.style.setProperty(animatedMarginPropertyName
, marginTo); | 549 this.contentElement.style.setProperty(animatedMarginPropertyName
, marginTo); |
550 startTime = window.performance.now(); | 550 startTime = window.performance.now(); |
551 } else if (window.performance.now() < startTime + animationTime) { | 551 } else if (window.performance.now() < startTime + animationTime) { |
552 // Process regular animation frame. | 552 // Process regular animation frame. |
553 if (this._mainView) | 553 if (this._mainWidget) |
554 this._mainView.doResize(); | 554 this._mainWidget.doResize(); |
555 } else { | 555 } else { |
556 // Complete animation. | 556 // Complete animation. |
557 this._cancelAnimation(); | 557 this._cancelAnimation(); |
558 if (this._mainView) | 558 if (this._mainWidget) |
559 this._mainView.doResize(); | 559 this._mainWidget.doResize(); |
560 this.dispatchEventToListeners(WebInspector.SplitView.Events.Side
barSizeChanged, this.sidebarSize()); | 560 this.dispatchEventToListeners(WebInspector.SplitWidget.Events.Si
debarSizeChanged, this.sidebarSize()); |
561 return; | 561 return; |
562 } | 562 } |
563 this._animationFrameHandle = this.contentElement.window().requestAni
mationFrame(boundAnimationFrame); | 563 this._animationFrameHandle = this.contentElement.window().requestAni
mationFrame(boundAnimationFrame); |
564 } | 564 } |
565 boundAnimationFrame = animationFrame.bind(this); | 565 boundAnimationFrame = animationFrame.bind(this); |
566 this._animationFrameHandle = this.contentElement.window().requestAnimati
onFrame(boundAnimationFrame); | 566 this._animationFrameHandle = this.contentElement.window().requestAnimati
onFrame(boundAnimationFrame); |
567 }, | 567 }, |
568 | 568 |
569 _cancelAnimation: function() | 569 _cancelAnimation: function() |
570 { | 570 { |
(...skipping 16 matching lines...) Expand all Loading... |
587 /** | 587 /** |
588 * @param {number} sidebarSize | 588 * @param {number} sidebarSize |
589 * @param {boolean=} userAction | 589 * @param {boolean=} userAction |
590 * @return {number} | 590 * @return {number} |
591 */ | 591 */ |
592 _applyConstraints: function(sidebarSize, userAction) | 592 _applyConstraints: function(sidebarSize, userAction) |
593 { | 593 { |
594 var totalSize = this._totalSizeDIP(); | 594 var totalSize = this._totalSizeDIP(); |
595 var zoomFactor = this._constraintsInDip ? 1 : WebInspector.zoomManager.z
oomFactor(); | 595 var zoomFactor = this._constraintsInDip ? 1 : WebInspector.zoomManager.z
oomFactor(); |
596 | 596 |
597 var constraints = this._sidebarView ? this._sidebarView.constraints() :
new Constraints(); | 597 var constraints = this._sidebarWidget ? this._sidebarWidget.constraints(
) : new Constraints(); |
598 var minSidebarSize = this.isVertical() ? constraints.minimum.width : con
straints.minimum.height; | 598 var minSidebarSize = this.isVertical() ? constraints.minimum.width : con
straints.minimum.height; |
599 if (!minSidebarSize) | 599 if (!minSidebarSize) |
600 minSidebarSize = WebInspector.SplitView.MinPadding; | 600 minSidebarSize = WebInspector.SplitWidget.MinPadding; |
601 minSidebarSize *= zoomFactor; | 601 minSidebarSize *= zoomFactor; |
602 | 602 |
603 var preferredSidebarSize = this.isVertical() ? constraints.preferred.wid
th : constraints.preferred.height; | 603 var preferredSidebarSize = this.isVertical() ? constraints.preferred.wid
th : constraints.preferred.height; |
604 if (!preferredSidebarSize) | 604 if (!preferredSidebarSize) |
605 preferredSidebarSize = WebInspector.SplitView.MinPadding; | 605 preferredSidebarSize = WebInspector.SplitWidget.MinPadding; |
606 preferredSidebarSize *= zoomFactor; | 606 preferredSidebarSize *= zoomFactor; |
607 // Allow sidebar to be less than preferred by explicit user action. | 607 // Allow sidebar to be less than preferred by explicit user action. |
608 if (sidebarSize < preferredSidebarSize) | 608 if (sidebarSize < preferredSidebarSize) |
609 preferredSidebarSize = Math.max(sidebarSize, minSidebarSize); | 609 preferredSidebarSize = Math.max(sidebarSize, minSidebarSize); |
610 preferredSidebarSize += zoomFactor; // 1 css pixel for splitter border. | 610 preferredSidebarSize += zoomFactor; // 1 css pixel for splitter border. |
611 | 611 |
612 constraints = this._mainView ? this._mainView.constraints() : new Constr
aints(); | 612 constraints = this._mainWidget ? this._mainWidget.constraints() : new Co
nstraints(); |
613 var minMainSize = this.isVertical() ? constraints.minimum.width : constr
aints.minimum.height; | 613 var minMainSize = this.isVertical() ? constraints.minimum.width : constr
aints.minimum.height; |
614 if (!minMainSize) | 614 if (!minMainSize) |
615 minMainSize = WebInspector.SplitView.MinPadding; | 615 minMainSize = WebInspector.SplitWidget.MinPadding; |
616 minMainSize *= zoomFactor; | 616 minMainSize *= zoomFactor; |
617 | 617 |
618 var preferredMainSize = this.isVertical() ? constraints.preferred.width
: constraints.preferred.height; | 618 var preferredMainSize = this.isVertical() ? constraints.preferred.width
: constraints.preferred.height; |
619 if (!preferredMainSize) | 619 if (!preferredMainSize) |
620 preferredMainSize = WebInspector.SplitView.MinPadding; | 620 preferredMainSize = WebInspector.SplitWidget.MinPadding; |
621 preferredMainSize *= zoomFactor; | 621 preferredMainSize *= zoomFactor; |
622 var savedMainSize = this.isVertical() ? this._savedVerticalMainSize : th
is._savedHorizontalMainSize; | 622 var savedMainSize = this.isVertical() ? this._savedVerticalMainSize : th
is._savedHorizontalMainSize; |
623 if (typeof savedMainSize !== "undefined") | 623 if (typeof savedMainSize !== "undefined") |
624 preferredMainSize = Math.min(preferredMainSize, savedMainSize * zoom
Factor); | 624 preferredMainSize = Math.min(preferredMainSize, savedMainSize * zoom
Factor); |
625 if (userAction) | 625 if (userAction) |
626 preferredMainSize = minMainSize; | 626 preferredMainSize = minMainSize; |
627 | 627 |
628 // Enough space for preferred. | 628 // Enough space for preferred. |
629 var totalPreferred = preferredMainSize + preferredSidebarSize; | 629 var totalPreferred = preferredMainSize + preferredSidebarSize; |
630 if (totalPreferred <= totalSize) | 630 if (totalPreferred <= totalSize) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 { | 662 { |
663 this._updateLayout(); | 663 this._updateLayout(); |
664 }, | 664 }, |
665 | 665 |
666 /** | 666 /** |
667 * @override | 667 * @override |
668 * @return {!Constraints} | 668 * @return {!Constraints} |
669 */ | 669 */ |
670 calculateConstraints: function() | 670 calculateConstraints: function() |
671 { | 671 { |
672 if (this._showMode === WebInspector.SplitView.ShowMode.OnlyMain) | 672 if (this._showMode === WebInspector.SplitWidget.ShowMode.OnlyMain) |
673 return this._mainView ? this._mainView.constraints() : new Constrain
ts(); | 673 return this._mainWidget ? this._mainWidget.constraints() : new Const
raints(); |
674 if (this._showMode === WebInspector.SplitView.ShowMode.OnlySidebar) | 674 if (this._showMode === WebInspector.SplitWidget.ShowMode.OnlySidebar) |
675 return this._sidebarView ? this._sidebarView.constraints() : new Con
straints(); | 675 return this._sidebarWidget ? this._sidebarWidget.constraints() : new
Constraints(); |
676 | 676 |
677 var mainConstraints = this._mainView ? this._mainView.constraints() : ne
w Constraints(); | 677 var mainConstraints = this._mainWidget ? this._mainWidget.constraints()
: new Constraints(); |
678 var sidebarConstraints = this._sidebarView ? this._sidebarView.constrain
ts() : new Constraints(); | 678 var sidebarConstraints = this._sidebarWidget ? this._sidebarWidget.const
raints() : new Constraints(); |
679 var min = WebInspector.SplitView.MinPadding; | 679 var min = WebInspector.SplitWidget.MinPadding; |
680 if (this._isVertical) { | 680 if (this._isVertical) { |
681 mainConstraints = mainConstraints.widthToMax(min).addWidth(1); // 1
for splitter | 681 mainConstraints = mainConstraints.widthToMax(min).addWidth(1); // 1
for splitter |
682 sidebarConstraints = sidebarConstraints.widthToMax(min); | 682 sidebarConstraints = sidebarConstraints.widthToMax(min); |
683 return mainConstraints.addWidth(sidebarConstraints).heightToMax(side
barConstraints); | 683 return mainConstraints.addWidth(sidebarConstraints).heightToMax(side
barConstraints); |
684 } else { | 684 } else { |
685 mainConstraints = mainConstraints.heightToMax(min).addHeight(1); //
1 for splitter | 685 mainConstraints = mainConstraints.heightToMax(min).addHeight(1); //
1 for splitter |
686 sidebarConstraints = sidebarConstraints.heightToMax(min); | 686 sidebarConstraints = sidebarConstraints.heightToMax(min); |
687 return mainConstraints.widthToMax(sidebarConstraints).addHeight(side
barConstraints); | 687 return mainConstraints.widthToMax(sidebarConstraints).addHeight(side
barConstraints); |
688 } | 688 } |
689 }, | 689 }, |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 */ | 758 */ |
759 toggleResizer: function(resizer, on) | 759 toggleResizer: function(resizer, on) |
760 { | 760 { |
761 if (on) | 761 if (on) |
762 this.installResizer(resizer); | 762 this.installResizer(resizer); |
763 else | 763 else |
764 this.uninstallResizer(resizer); | 764 this.uninstallResizer(resizer); |
765 }, | 765 }, |
766 | 766 |
767 /** | 767 /** |
768 * @return {?WebInspector.SplitView.SettingForOrientation} | 768 * @return {?WebInspector.SplitWidget.SettingForOrientation} |
769 */ | 769 */ |
770 _settingForOrientation: function() | 770 _settingForOrientation: function() |
771 { | 771 { |
772 var state = this._setting ? this._setting.get() : {}; | 772 var state = this._setting ? this._setting.get() : {}; |
773 return this._isVertical ? state.vertical : state.horizontal; | 773 return this._isVertical ? state.vertical : state.horizontal; |
774 }, | 774 }, |
775 | 775 |
776 /** | 776 /** |
777 * @return {number} | 777 * @return {number} |
778 */ | 778 */ |
(...skipping 15 matching lines...) Expand all Loading... |
794 this._savedSidebarSizeDIP = settingForOrientation ? settingForOrientatio
n.size : 0; | 794 this._savedSidebarSizeDIP = settingForOrientation ? settingForOrientatio
n.size : 0; |
795 }, | 795 }, |
796 | 796 |
797 _restoreAndApplyShowModeFromSettings: function() | 797 _restoreAndApplyShowModeFromSettings: function() |
798 { | 798 { |
799 var orientationState = this._settingForOrientation(); | 799 var orientationState = this._settingForOrientation(); |
800 this._savedShowMode = orientationState && orientationState.showMode ? or
ientationState.showMode : this._showMode; | 800 this._savedShowMode = orientationState && orientationState.showMode ? or
ientationState.showMode : this._showMode; |
801 this._showMode = this._savedShowMode; | 801 this._showMode = this._savedShowMode; |
802 | 802 |
803 switch (this._savedShowMode) { | 803 switch (this._savedShowMode) { |
804 case WebInspector.SplitView.ShowMode.Both: | 804 case WebInspector.SplitWidget.ShowMode.Both: |
805 this.showBoth(); | 805 this.showBoth(); |
806 break; | 806 break; |
807 case WebInspector.SplitView.ShowMode.OnlyMain: | 807 case WebInspector.SplitWidget.ShowMode.OnlyMain: |
808 this.hideSidebar(); | 808 this.hideSidebar(); |
809 break; | 809 break; |
810 case WebInspector.SplitView.ShowMode.OnlySidebar: | 810 case WebInspector.SplitWidget.ShowMode.OnlySidebar: |
811 this.hideMain(); | 811 this.hideMain(); |
812 break; | 812 break; |
813 } | 813 } |
814 }, | 814 }, |
815 | 815 |
816 _saveShowModeToSettings: function() | 816 _saveShowModeToSettings: function() |
817 { | 817 { |
818 this._savedShowMode = this._showMode; | 818 this._savedShowMode = this._showMode; |
819 this._saveSetting(); | 819 this._saveSetting(); |
820 }, | 820 }, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 this._forceUpdateLayout(); | 852 this._forceUpdateLayout(); |
853 }, | 853 }, |
854 | 854 |
855 /** | 855 /** |
856 * @param {string} title | 856 * @param {string} title |
857 * @param {string=} className | 857 * @param {string=} className |
858 * @return {!Element} | 858 * @return {!Element} |
859 */ | 859 */ |
860 displayShowHideSidebarButton: function(title, className) | 860 displayShowHideSidebarButton: function(title, className) |
861 { | 861 { |
862 console.assert(this.isVertical(), "Buttons for split view with horizonta
l split are not supported yet."); | 862 console.assert(this.isVertical(), "Buttons for split widget with horizon
tal split are not supported yet."); |
863 | 863 |
864 this._showHideSidebarButtonTitle = WebInspector.UIString(title); | 864 this._showHideSidebarButtonTitle = WebInspector.UIString(title); |
865 this._showHideSidebarButton = this._mainElement.createChild("button", "s
idebar-show-hide-button " + (className || "")); | 865 this._showHideSidebarButton = this._mainElement.createChild("button", "s
idebar-show-hide-button " + (className || "")); |
866 this._showHideSidebarButton.addEventListener("click", buttonClicked.bind
(this), false); | 866 this._showHideSidebarButton.addEventListener("click", buttonClicked.bind
(this), false); |
867 this._updateShowHideSidebarButton(); | 867 this._updateShowHideSidebarButton(); |
868 | 868 |
869 /** | 869 /** |
870 * @param {!Event} event | 870 * @param {!Event} event |
871 * @this {WebInspector.SplitView} | 871 * @this {WebInspector.SplitWidget} |
872 */ | 872 */ |
873 function buttonClicked(event) | 873 function buttonClicked(event) |
874 { | 874 { |
875 if (this._showMode !== WebInspector.SplitView.ShowMode.Both) | 875 if (this._showMode !== WebInspector.SplitWidget.ShowMode.Both) |
876 this.showBoth(true); | 876 this.showBoth(true); |
877 else | 877 else |
878 this.hideSidebar(true); | 878 this.hideSidebar(true); |
879 } | 879 } |
880 | 880 |
881 return this._showHideSidebarButton; | 881 return this._showHideSidebarButton; |
882 }, | 882 }, |
883 | 883 |
884 _updateShowHideSidebarButton: function() | 884 _updateShowHideSidebarButton: function() |
885 { | 885 { |
886 if (!this._showHideSidebarButton) | 886 if (!this._showHideSidebarButton) |
887 return; | 887 return; |
888 var sidebarHidden = this._showMode === WebInspector.SplitView.ShowMode.O
nlyMain; | 888 var sidebarHidden = this._showMode === WebInspector.SplitWidget.ShowMode
.OnlyMain; |
889 this._showHideSidebarButton.classList.toggle("toggled-show", sidebarHidd
en); | 889 this._showHideSidebarButton.classList.toggle("toggled-show", sidebarHidd
en); |
890 this._showHideSidebarButton.classList.toggle("toggled-hide", !sidebarHid
den); | 890 this._showHideSidebarButton.classList.toggle("toggled-hide", !sidebarHid
den); |
891 this._showHideSidebarButton.classList.toggle("top-sidebar-show-hide-butt
on", !this.isVertical() && !this.isSidebarSecond()); | 891 this._showHideSidebarButton.classList.toggle("top-sidebar-show-hide-butt
on", !this.isVertical() && !this.isSidebarSecond()); |
892 this._showHideSidebarButton.classList.toggle("right-sidebar-show-hide-bu
tton", this.isVertical() && this.isSidebarSecond()); | 892 this._showHideSidebarButton.classList.toggle("right-sidebar-show-hide-bu
tton", this.isVertical() && this.isSidebarSecond()); |
893 this._showHideSidebarButton.classList.toggle("bottom-sidebar-show-hide-b
utton", !this.isVertical() && this.isSidebarSecond()); | 893 this._showHideSidebarButton.classList.toggle("bottom-sidebar-show-hide-b
utton", !this.isVertical() && this.isSidebarSecond()); |
894 this._showHideSidebarButton.classList.toggle("left-sidebar-show-hide-but
ton", this.isVertical() && !this.isSidebarSecond()); | 894 this._showHideSidebarButton.classList.toggle("left-sidebar-show-hide-but
ton", this.isVertical() && !this.isSidebarSecond()); |
895 this._showHideSidebarButton.title = sidebarHidden ? WebInspector.UIStrin
g("Show %s", this._showHideSidebarButtonTitle) : WebInspector.UIString("Hide %s"
, this._showHideSidebarButtonTitle); | 895 this._showHideSidebarButton.title = sidebarHidden ? WebInspector.UIStrin
g("Show %s", this._showHideSidebarButtonTitle) : WebInspector.UIString("Hide %s"
, this._showHideSidebarButtonTitle); |
896 }, | 896 }, |
897 | 897 |
898 __proto__: WebInspector.View.prototype | 898 __proto__: WebInspector.Widget.prototype |
899 } | 899 } |
OLD | NEW |