| 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 11 matching lines...) Expand all Loading... |
| 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 * @unrestricted | 30 * @unrestricted |
| 31 */ | 31 */ |
| 32 WebInspector.SplitWidget = class extends WebInspector.Widget { | 32 UI.SplitWidget = class extends UI.Widget { |
| 33 /** | 33 /** |
| 34 * @param {boolean} isVertical | 34 * @param {boolean} isVertical |
| 35 * @param {boolean} secondIsSidebar | 35 * @param {boolean} secondIsSidebar |
| 36 * @param {string=} settingName | 36 * @param {string=} settingName |
| 37 * @param {number=} defaultSidebarWidth | 37 * @param {number=} defaultSidebarWidth |
| 38 * @param {number=} defaultSidebarHeight | 38 * @param {number=} defaultSidebarHeight |
| 39 * @param {boolean=} constraintsInDip | 39 * @param {boolean=} constraintsInDip |
| 40 */ | 40 */ |
| 41 constructor(isVertical, secondIsSidebar, settingName, defaultSidebarWidth, def
aultSidebarHeight, constraintsInDip) { | 41 constructor(isVertical, secondIsSidebar, settingName, defaultSidebarWidth, def
aultSidebarHeight, constraintsInDip) { |
| 42 super(true); | 42 super(true); |
| 43 this.element.classList.add('split-widget'); | 43 this.element.classList.add('split-widget'); |
| 44 this.registerRequiredCSS('ui/splitWidget.css'); | 44 this.registerRequiredCSS('ui/splitWidget.css'); |
| 45 | 45 |
| 46 this.contentElement.classList.add('shadow-split-widget'); | 46 this.contentElement.classList.add('shadow-split-widget'); |
| 47 this._mainElement = | 47 this._mainElement = |
| 48 this.contentElement.createChild('div', 'shadow-split-widget-contents sha
dow-split-widget-main vbox'); | 48 this.contentElement.createChild('div', 'shadow-split-widget-contents sha
dow-split-widget-main vbox'); |
| 49 this._mainElement.createChild('content').select = '.insertion-point-main'; | 49 this._mainElement.createChild('content').select = '.insertion-point-main'; |
| 50 this._sidebarElement = | 50 this._sidebarElement = |
| 51 this.contentElement.createChild('div', 'shadow-split-widget-contents sha
dow-split-widget-sidebar vbox'); | 51 this.contentElement.createChild('div', 'shadow-split-widget-contents sha
dow-split-widget-sidebar vbox'); |
| 52 this._sidebarElement.createChild('content').select = '.insertion-point-sideb
ar'; | 52 this._sidebarElement.createChild('content').select = '.insertion-point-sideb
ar'; |
| 53 this._resizerElement = this.contentElement.createChild('div', 'shadow-split-
widget-resizer'); | 53 this._resizerElement = this.contentElement.createChild('div', 'shadow-split-
widget-resizer'); |
| 54 | 54 |
| 55 this._resizerWidget = new WebInspector.SimpleResizerWidget(); | 55 this._resizerWidget = new UI.SimpleResizerWidget(); |
| 56 this._resizerWidget.setEnabled(true); | 56 this._resizerWidget.setEnabled(true); |
| 57 this._resizerWidget.addEventListener(WebInspector.ResizerWidget.Events.Resiz
eStart, this._onResizeStart, this); | 57 this._resizerWidget.addEventListener(UI.ResizerWidget.Events.ResizeStart, th
is._onResizeStart, this); |
| 58 this._resizerWidget.addEventListener(WebInspector.ResizerWidget.Events.Resiz
eUpdate, this._onResizeUpdate, this); | 58 this._resizerWidget.addEventListener(UI.ResizerWidget.Events.ResizeUpdate, t
his._onResizeUpdate, this); |
| 59 this._resizerWidget.addEventListener(WebInspector.ResizerWidget.Events.Resiz
eEnd, this._onResizeEnd, this); | 59 this._resizerWidget.addEventListener(UI.ResizerWidget.Events.ResizeEnd, this
._onResizeEnd, this); |
| 60 | 60 |
| 61 this._defaultSidebarWidth = defaultSidebarWidth || 200; | 61 this._defaultSidebarWidth = defaultSidebarWidth || 200; |
| 62 this._defaultSidebarHeight = defaultSidebarHeight || this._defaultSidebarWid
th; | 62 this._defaultSidebarHeight = defaultSidebarHeight || this._defaultSidebarWid
th; |
| 63 this._constraintsInDip = !!constraintsInDip; | 63 this._constraintsInDip = !!constraintsInDip; |
| 64 this._setting = settingName ? WebInspector.settings.createSetting(settingNam
e, {}) : null; | 64 this._setting = settingName ? Common.settings.createSetting(settingName, {})
: null; |
| 65 | 65 |
| 66 this.setSecondIsSidebar(secondIsSidebar); | 66 this.setSecondIsSidebar(secondIsSidebar); |
| 67 | 67 |
| 68 this._innerSetVertical(isVertical); | 68 this._innerSetVertical(isVertical); |
| 69 this._showMode = WebInspector.SplitWidget.ShowMode.Both; | 69 this._showMode = UI.SplitWidget.ShowMode.Both; |
| 70 | 70 |
| 71 // Should be called after isVertical has the right value. | 71 // Should be called after isVertical has the right value. |
| 72 this.installResizer(this._resizerElement); | 72 this.installResizer(this._resizerElement); |
| 73 } | 73 } |
| 74 | 74 |
| 75 /** | 75 /** |
| 76 * @return {boolean} | 76 * @return {boolean} |
| 77 */ | 77 */ |
| 78 isVertical() { | 78 isVertical() { |
| 79 return this._isVertical; | 79 return this._isVertical; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 // Remove properties that might affect total size calculation. | 121 // Remove properties that might affect total size calculation. |
| 122 this._mainElement.style.removeProperty('width'); | 122 this._mainElement.style.removeProperty('width'); |
| 123 this._mainElement.style.removeProperty('height'); | 123 this._mainElement.style.removeProperty('height'); |
| 124 this._sidebarElement.style.removeProperty('width'); | 124 this._sidebarElement.style.removeProperty('width'); |
| 125 this._sidebarElement.style.removeProperty('height'); | 125 this._sidebarElement.style.removeProperty('height'); |
| 126 | 126 |
| 127 this._innerSetSidebarSizeDIP(this._preferredSidebarSizeDIP(), !!animate); | 127 this._innerSetSidebarSizeDIP(this._preferredSidebarSizeDIP(), !!animate); |
| 128 } | 128 } |
| 129 | 129 |
| 130 /** | 130 /** |
| 131 * @param {!WebInspector.Widget} widget | 131 * @param {!UI.Widget} widget |
| 132 */ | 132 */ |
| 133 setMainWidget(widget) { | 133 setMainWidget(widget) { |
| 134 if (this._mainWidget === widget) | 134 if (this._mainWidget === widget) |
| 135 return; | 135 return; |
| 136 this.suspendInvalidations(); | 136 this.suspendInvalidations(); |
| 137 if (this._mainWidget) | 137 if (this._mainWidget) |
| 138 this._mainWidget.detach(); | 138 this._mainWidget.detach(); |
| 139 this._mainWidget = widget; | 139 this._mainWidget = widget; |
| 140 if (widget) { | 140 if (widget) { |
| 141 widget.element.classList.add('insertion-point-main'); | 141 widget.element.classList.add('insertion-point-main'); |
| 142 widget.element.classList.remove('insertion-point-sidebar'); | 142 widget.element.classList.remove('insertion-point-sidebar'); |
| 143 widget.attach(this); | 143 widget.attach(this); |
| 144 if (this._showMode === WebInspector.SplitWidget.ShowMode.OnlyMain || | 144 if (this._showMode === UI.SplitWidget.ShowMode.OnlyMain || |
| 145 this._showMode === WebInspector.SplitWidget.ShowMode.Both) | 145 this._showMode === UI.SplitWidget.ShowMode.Both) |
| 146 widget.showWidget(this.element); | 146 widget.showWidget(this.element); |
| 147 this.setDefaultFocusedChild(widget); | 147 this.setDefaultFocusedChild(widget); |
| 148 } | 148 } |
| 149 this.resumeInvalidations(); | 149 this.resumeInvalidations(); |
| 150 } | 150 } |
| 151 | 151 |
| 152 /** | 152 /** |
| 153 * @param {!WebInspector.Widget} widget | 153 * @param {!UI.Widget} widget |
| 154 */ | 154 */ |
| 155 setSidebarWidget(widget) { | 155 setSidebarWidget(widget) { |
| 156 if (this._sidebarWidget === widget) | 156 if (this._sidebarWidget === widget) |
| 157 return; | 157 return; |
| 158 this.suspendInvalidations(); | 158 this.suspendInvalidations(); |
| 159 if (this._sidebarWidget) | 159 if (this._sidebarWidget) |
| 160 this._sidebarWidget.detach(); | 160 this._sidebarWidget.detach(); |
| 161 this._sidebarWidget = widget; | 161 this._sidebarWidget = widget; |
| 162 if (widget) { | 162 if (widget) { |
| 163 widget.element.classList.add('insertion-point-sidebar'); | 163 widget.element.classList.add('insertion-point-sidebar'); |
| 164 widget.element.classList.remove('insertion-point-main'); | 164 widget.element.classList.remove('insertion-point-main'); |
| 165 widget.attach(this); | 165 widget.attach(this); |
| 166 if (this._showMode === WebInspector.SplitWidget.ShowMode.OnlySidebar || | 166 if (this._showMode === UI.SplitWidget.ShowMode.OnlySidebar || |
| 167 this._showMode === WebInspector.SplitWidget.ShowMode.Both) | 167 this._showMode === UI.SplitWidget.ShowMode.Both) |
| 168 widget.showWidget(this.element); | 168 widget.showWidget(this.element); |
| 169 } | 169 } |
| 170 this.resumeInvalidations(); | 170 this.resumeInvalidations(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 /** | 173 /** |
| 174 * @return {?WebInspector.Widget} | 174 * @return {?UI.Widget} |
| 175 */ | 175 */ |
| 176 mainWidget() { | 176 mainWidget() { |
| 177 return this._mainWidget; | 177 return this._mainWidget; |
| 178 } | 178 } |
| 179 | 179 |
| 180 /** | 180 /** |
| 181 * @return {?WebInspector.Widget} | 181 * @return {?UI.Widget} |
| 182 */ | 182 */ |
| 183 sidebarWidget() { | 183 sidebarWidget() { |
| 184 return this._sidebarWidget; | 184 return this._sidebarWidget; |
| 185 } | 185 } |
| 186 | 186 |
| 187 /** | 187 /** |
| 188 * @override | 188 * @override |
| 189 * @param {!WebInspector.Widget} widget | 189 * @param {!UI.Widget} widget |
| 190 */ | 190 */ |
| 191 childWasDetached(widget) { | 191 childWasDetached(widget) { |
| 192 if (this._mainWidget === widget) | 192 if (this._mainWidget === widget) |
| 193 delete this._mainWidget; | 193 delete this._mainWidget; |
| 194 if (this._sidebarWidget === widget) | 194 if (this._sidebarWidget === widget) |
| 195 delete this._sidebarWidget; | 195 delete this._sidebarWidget; |
| 196 } | 196 } |
| 197 | 197 |
| 198 /** | 198 /** |
| 199 * @return {boolean} | 199 * @return {boolean} |
| (...skipping 19 matching lines...) Expand all Loading... |
| 219 */ | 219 */ |
| 220 setSecondIsSidebar(secondIsSidebar) { | 220 setSecondIsSidebar(secondIsSidebar) { |
| 221 this.contentElement.classList.toggle('shadow-split-widget-first-is-sidebar',
!secondIsSidebar); | 221 this.contentElement.classList.toggle('shadow-split-widget-first-is-sidebar',
!secondIsSidebar); |
| 222 this._secondIsSidebar = secondIsSidebar; | 222 this._secondIsSidebar = secondIsSidebar; |
| 223 } | 223 } |
| 224 | 224 |
| 225 /** | 225 /** |
| 226 * @return {?string} | 226 * @return {?string} |
| 227 */ | 227 */ |
| 228 sidebarSide() { | 228 sidebarSide() { |
| 229 if (this._showMode !== WebInspector.SplitWidget.ShowMode.Both) | 229 if (this._showMode !== UI.SplitWidget.ShowMode.Both) |
| 230 return null; | 230 return null; |
| 231 return this._isVertical ? (this._secondIsSidebar ? 'right' : 'left') : (this
._secondIsSidebar ? 'bottom' : 'top'); | 231 return this._isVertical ? (this._secondIsSidebar ? 'right' : 'left') : (this
._secondIsSidebar ? 'bottom' : 'top'); |
| 232 } | 232 } |
| 233 | 233 |
| 234 /** | 234 /** |
| 235 * @return {!Element} | 235 * @return {!Element} |
| 236 */ | 236 */ |
| 237 resizerElement() { | 237 resizerElement() { |
| 238 return this._resizerElement; | 238 return this._resizerElement; |
| 239 } | 239 } |
| 240 | 240 |
| 241 /** | 241 /** |
| 242 * @param {boolean=} animate | 242 * @param {boolean=} animate |
| 243 */ | 243 */ |
| 244 hideMain(animate) { | 244 hideMain(animate) { |
| 245 this._showOnly(this._sidebarWidget, this._mainWidget, this._sidebarElement,
this._mainElement, animate); | 245 this._showOnly(this._sidebarWidget, this._mainWidget, this._sidebarElement,
this._mainElement, animate); |
| 246 this._updateShowMode(WebInspector.SplitWidget.ShowMode.OnlySidebar); | 246 this._updateShowMode(UI.SplitWidget.ShowMode.OnlySidebar); |
| 247 } | 247 } |
| 248 | 248 |
| 249 /** | 249 /** |
| 250 * @param {boolean=} animate | 250 * @param {boolean=} animate |
| 251 */ | 251 */ |
| 252 hideSidebar(animate) { | 252 hideSidebar(animate) { |
| 253 this._showOnly(this._mainWidget, this._sidebarWidget, this._mainElement, thi
s._sidebarElement, animate); | 253 this._showOnly(this._mainWidget, this._sidebarWidget, this._mainElement, thi
s._sidebarElement, animate); |
| 254 this._updateShowMode(WebInspector.SplitWidget.ShowMode.OnlyMain); | 254 this._updateShowMode(UI.SplitWidget.ShowMode.OnlyMain); |
| 255 } | 255 } |
| 256 | 256 |
| 257 /** | 257 /** |
| 258 * @param {boolean} minimized | 258 * @param {boolean} minimized |
| 259 */ | 259 */ |
| 260 setSidebarMinimized(minimized) { | 260 setSidebarMinimized(minimized) { |
| 261 this._sidebarMinimized = minimized; | 261 this._sidebarMinimized = minimized; |
| 262 this.invalidateConstraints(); | 262 this.invalidateConstraints(); |
| 263 } | 263 } |
| 264 | 264 |
| 265 /** | 265 /** |
| 266 * @return {boolean} | 266 * @return {boolean} |
| 267 */ | 267 */ |
| 268 isSidebarMinimized() { | 268 isSidebarMinimized() { |
| 269 return this._sidebarMinimized; | 269 return this._sidebarMinimized; |
| 270 } | 270 } |
| 271 | 271 |
| 272 /** | 272 /** |
| 273 * @param {!WebInspector.Widget} sideToShow | 273 * @param {!UI.Widget} sideToShow |
| 274 * @param {!WebInspector.Widget} sideToHide | 274 * @param {!UI.Widget} sideToHide |
| 275 * @param {!Element} shadowToShow | 275 * @param {!Element} shadowToShow |
| 276 * @param {!Element} shadowToHide | 276 * @param {!Element} shadowToHide |
| 277 * @param {boolean=} animate | 277 * @param {boolean=} animate |
| 278 */ | 278 */ |
| 279 _showOnly(sideToShow, sideToHide, shadowToShow, shadowToHide, animate) { | 279 _showOnly(sideToShow, sideToHide, shadowToShow, shadowToHide, animate) { |
| 280 this._cancelAnimation(); | 280 this._cancelAnimation(); |
| 281 | 281 |
| 282 /** | 282 /** |
| 283 * @this {WebInspector.SplitWidget} | 283 * @this {UI.SplitWidget} |
| 284 */ | 284 */ |
| 285 function callback() { | 285 function callback() { |
| 286 if (sideToShow) { | 286 if (sideToShow) { |
| 287 // Make sure main is first in the children list. | 287 // Make sure main is first in the children list. |
| 288 if (sideToShow === this._mainWidget) | 288 if (sideToShow === this._mainWidget) |
| 289 this._mainWidget.showWidget(this.element); | 289 this._mainWidget.showWidget(this.element); |
| 290 else | 290 else |
| 291 this._sidebarWidget.showWidget(this.element); | 291 this._sidebarWidget.showWidget(this.element); |
| 292 } | 292 } |
| 293 if (sideToHide) | 293 if (sideToHide) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 this._resizerElement.style.removeProperty('margin-left'); | 327 this._resizerElement.style.removeProperty('margin-left'); |
| 328 this._resizerElement.style.removeProperty('margin-right'); | 328 this._resizerElement.style.removeProperty('margin-right'); |
| 329 this._resizerElement.style.removeProperty('margin-top'); | 329 this._resizerElement.style.removeProperty('margin-top'); |
| 330 this._resizerElement.style.removeProperty('margin-bottom'); | 330 this._resizerElement.style.removeProperty('margin-bottom'); |
| 331 } | 331 } |
| 332 | 332 |
| 333 /** | 333 /** |
| 334 * @param {boolean=} animate | 334 * @param {boolean=} animate |
| 335 */ | 335 */ |
| 336 showBoth(animate) { | 336 showBoth(animate) { |
| 337 if (this._showMode === WebInspector.SplitWidget.ShowMode.Both) | 337 if (this._showMode === UI.SplitWidget.ShowMode.Both) |
| 338 animate = false; | 338 animate = false; |
| 339 | 339 |
| 340 this._cancelAnimation(); | 340 this._cancelAnimation(); |
| 341 this._mainElement.classList.remove('maximized', 'hidden'); | 341 this._mainElement.classList.remove('maximized', 'hidden'); |
| 342 this._sidebarElement.classList.remove('maximized', 'hidden'); | 342 this._sidebarElement.classList.remove('maximized', 'hidden'); |
| 343 this._resizerElement.classList.remove('hidden'); | 343 this._resizerElement.classList.remove('hidden'); |
| 344 this.setResizable(true); | 344 this.setResizable(true); |
| 345 | 345 |
| 346 // Make sure main is the first in the children list. | 346 // Make sure main is the first in the children list. |
| 347 this.suspendInvalidations(); | 347 this.suspendInvalidations(); |
| 348 if (this._sidebarWidget) | 348 if (this._sidebarWidget) |
| 349 this._sidebarWidget.showWidget(this.element); | 349 this._sidebarWidget.showWidget(this.element); |
| 350 if (this._mainWidget) | 350 if (this._mainWidget) |
| 351 this._mainWidget.showWidget(this.element); | 351 this._mainWidget.showWidget(this.element); |
| 352 this.resumeInvalidations(); | 352 this.resumeInvalidations(); |
| 353 // Order widgets in DOM properly. | 353 // Order widgets in DOM properly. |
| 354 this.setSecondIsSidebar(this._secondIsSidebar); | 354 this.setSecondIsSidebar(this._secondIsSidebar); |
| 355 | 355 |
| 356 this._sidebarSizeDIP = -1; | 356 this._sidebarSizeDIP = -1; |
| 357 this._updateShowMode(WebInspector.SplitWidget.ShowMode.Both); | 357 this._updateShowMode(UI.SplitWidget.ShowMode.Both); |
| 358 this._updateLayout(animate); | 358 this._updateLayout(animate); |
| 359 } | 359 } |
| 360 | 360 |
| 361 /** | 361 /** |
| 362 * @param {boolean} resizable | 362 * @param {boolean} resizable |
| 363 */ | 363 */ |
| 364 setResizable(resizable) { | 364 setResizable(resizable) { |
| 365 this._resizerWidget.setEnabled(resizable); | 365 this._resizerWidget.setEnabled(resizable); |
| 366 } | 366 } |
| 367 | 367 |
| 368 /** | 368 /** |
| 369 * @return {boolean} | 369 * @return {boolean} |
| 370 */ | 370 */ |
| 371 isResizable() { | 371 isResizable() { |
| 372 return this._resizerWidget.isEnabled(); | 372 return this._resizerWidget.isEnabled(); |
| 373 } | 373 } |
| 374 | 374 |
| 375 /** | 375 /** |
| 376 * @param {number} size | 376 * @param {number} size |
| 377 */ | 377 */ |
| 378 setSidebarSize(size) { | 378 setSidebarSize(size) { |
| 379 var sizeDIP = WebInspector.zoomManager.cssToDIP(size); | 379 var sizeDIP = UI.zoomManager.cssToDIP(size); |
| 380 this._savedSidebarSizeDIP = sizeDIP; | 380 this._savedSidebarSizeDIP = sizeDIP; |
| 381 this._saveSetting(); | 381 this._saveSetting(); |
| 382 this._innerSetSidebarSizeDIP(sizeDIP, false, true); | 382 this._innerSetSidebarSizeDIP(sizeDIP, false, true); |
| 383 } | 383 } |
| 384 | 384 |
| 385 /** | 385 /** |
| 386 * @return {number} | 386 * @return {number} |
| 387 */ | 387 */ |
| 388 sidebarSize() { | 388 sidebarSize() { |
| 389 var sizeDIP = Math.max(0, this._sidebarSizeDIP); | 389 var sizeDIP = Math.max(0, this._sidebarSizeDIP); |
| 390 return WebInspector.zoomManager.dipToCSS(sizeDIP); | 390 return UI.zoomManager.dipToCSS(sizeDIP); |
| 391 } | 391 } |
| 392 | 392 |
| 393 /** | 393 /** |
| 394 * Returns total size in DIP. | 394 * Returns total size in DIP. |
| 395 * @return {number} | 395 * @return {number} |
| 396 */ | 396 */ |
| 397 _totalSizeDIP() { | 397 _totalSizeDIP() { |
| 398 if (!this._totalSizeCSS) { | 398 if (!this._totalSizeCSS) { |
| 399 this._totalSizeCSS = this._isVertical ? this.contentElement.offsetWidth :
this.contentElement.offsetHeight; | 399 this._totalSizeCSS = this._isVertical ? this.contentElement.offsetWidth :
this.contentElement.offsetHeight; |
| 400 this._totalSizeOtherDimensionCSS = | 400 this._totalSizeOtherDimensionCSS = |
| 401 this._isVertical ? this.contentElement.offsetHeight : this.contentElem
ent.offsetWidth; | 401 this._isVertical ? this.contentElement.offsetHeight : this.contentElem
ent.offsetWidth; |
| 402 } | 402 } |
| 403 return WebInspector.zoomManager.cssToDIP(this._totalSizeCSS); | 403 return UI.zoomManager.cssToDIP(this._totalSizeCSS); |
| 404 } | 404 } |
| 405 | 405 |
| 406 /** | 406 /** |
| 407 * @param {string} showMode | 407 * @param {string} showMode |
| 408 */ | 408 */ |
| 409 _updateShowMode(showMode) { | 409 _updateShowMode(showMode) { |
| 410 this._showMode = showMode; | 410 this._showMode = showMode; |
| 411 this._saveShowModeToSettings(); | 411 this._saveShowModeToSettings(); |
| 412 this._updateShowHideSidebarButton(); | 412 this._updateShowHideSidebarButton(); |
| 413 this.dispatchEventToListeners(WebInspector.SplitWidget.Events.ShowModeChange
d, showMode); | 413 this.dispatchEventToListeners(UI.SplitWidget.Events.ShowModeChanged, showMod
e); |
| 414 this.invalidateConstraints(); | 414 this.invalidateConstraints(); |
| 415 } | 415 } |
| 416 | 416 |
| 417 /** | 417 /** |
| 418 * @param {number} sizeDIP | 418 * @param {number} sizeDIP |
| 419 * @param {boolean} animate | 419 * @param {boolean} animate |
| 420 * @param {boolean=} userAction | 420 * @param {boolean=} userAction |
| 421 */ | 421 */ |
| 422 _innerSetSidebarSizeDIP(sizeDIP, animate, userAction) { | 422 _innerSetSidebarSizeDIP(sizeDIP, animate, userAction) { |
| 423 if (this._showMode !== WebInspector.SplitWidget.ShowMode.Both || !this.isSho
wing()) | 423 if (this._showMode !== UI.SplitWidget.ShowMode.Both || !this.isShowing()) |
| 424 return; | 424 return; |
| 425 | 425 |
| 426 sizeDIP = this._applyConstraints(sizeDIP, userAction); | 426 sizeDIP = this._applyConstraints(sizeDIP, userAction); |
| 427 if (this._sidebarSizeDIP === sizeDIP) | 427 if (this._sidebarSizeDIP === sizeDIP) |
| 428 return; | 428 return; |
| 429 | 429 |
| 430 if (!this._resizerElementSize) | 430 if (!this._resizerElementSize) |
| 431 this._resizerElementSize = | 431 this._resizerElementSize = |
| 432 this._isVertical ? this._resizerElement.offsetWidth : this._resizerEle
ment.offsetHeight; | 432 this._isVertical ? this._resizerElement.offsetWidth : this._resizerEle
ment.offsetHeight; |
| 433 | 433 |
| 434 // Invalidate layout below. | 434 // Invalidate layout below. |
| 435 | 435 |
| 436 this._removeAllLayoutProperties(); | 436 this._removeAllLayoutProperties(); |
| 437 | 437 |
| 438 // this._totalSizeDIP is available below since we successfully applied const
raints. | 438 // this._totalSizeDIP is available below since we successfully applied const
raints. |
| 439 var roundSizeCSS = Math.round(WebInspector.zoomManager.dipToCSS(sizeDIP)); | 439 var roundSizeCSS = Math.round(UI.zoomManager.dipToCSS(sizeDIP)); |
| 440 var sidebarSizeValue = roundSizeCSS + 'px'; | 440 var sidebarSizeValue = roundSizeCSS + 'px'; |
| 441 var mainSizeValue = (this._totalSizeCSS - roundSizeCSS) + 'px'; | 441 var mainSizeValue = (this._totalSizeCSS - roundSizeCSS) + 'px'; |
| 442 this._sidebarElement.style.flexBasis = sidebarSizeValue; | 442 this._sidebarElement.style.flexBasis = sidebarSizeValue; |
| 443 | 443 |
| 444 // Make both sides relayout boundaries. | 444 // Make both sides relayout boundaries. |
| 445 if (this._isVertical) { | 445 if (this._isVertical) { |
| 446 this._sidebarElement.style.width = sidebarSizeValue; | 446 this._sidebarElement.style.width = sidebarSizeValue; |
| 447 this._mainElement.style.width = mainSizeValue; | 447 this._mainElement.style.width = mainSizeValue; |
| 448 this._sidebarElement.style.height = this._totalSizeOtherDimensionCSS + 'px
'; | 448 this._sidebarElement.style.height = this._totalSizeOtherDimensionCSS + 'px
'; |
| 449 this._mainElement.style.height = this._totalSizeOtherDimensionCSS + 'px'; | 449 this._mainElement.style.height = this._totalSizeOtherDimensionCSS + 'px'; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 475 | 475 |
| 476 this._sidebarSizeDIP = sizeDIP; | 476 this._sidebarSizeDIP = sizeDIP; |
| 477 | 477 |
| 478 // Force layout. | 478 // Force layout. |
| 479 | 479 |
| 480 if (animate) { | 480 if (animate) { |
| 481 this._animate(false); | 481 this._animate(false); |
| 482 } else { | 482 } else { |
| 483 // No need to recalculate this._sidebarSizeDIP and this._totalSizeDIP agai
n. | 483 // No need to recalculate this._sidebarSizeDIP and this._totalSizeDIP agai
n. |
| 484 this.doResize(); | 484 this.doResize(); |
| 485 this.dispatchEventToListeners(WebInspector.SplitWidget.Events.SidebarSizeC
hanged, this.sidebarSize()); | 485 this.dispatchEventToListeners(UI.SplitWidget.Events.SidebarSizeChanged, th
is.sidebarSize()); |
| 486 } | 486 } |
| 487 } | 487 } |
| 488 | 488 |
| 489 /** | 489 /** |
| 490 * @param {boolean} reverse | 490 * @param {boolean} reverse |
| 491 * @param {function()=} callback | 491 * @param {function()=} callback |
| 492 */ | 492 */ |
| 493 _animate(reverse, callback) { | 493 _animate(reverse, callback) { |
| 494 var animationTime = 50; | 494 var animationTime = 50; |
| 495 this._animationCallback = callback; | 495 this._animationCallback = callback; |
| 496 | 496 |
| 497 var animatedMarginPropertyName; | 497 var animatedMarginPropertyName; |
| 498 if (this._isVertical) | 498 if (this._isVertical) |
| 499 animatedMarginPropertyName = this._secondIsSidebar ? 'margin-right' : 'mar
gin-left'; | 499 animatedMarginPropertyName = this._secondIsSidebar ? 'margin-right' : 'mar
gin-left'; |
| 500 else | 500 else |
| 501 animatedMarginPropertyName = this._secondIsSidebar ? 'margin-bottom' : 'ma
rgin-top'; | 501 animatedMarginPropertyName = this._secondIsSidebar ? 'margin-bottom' : 'ma
rgin-top'; |
| 502 | 502 |
| 503 var marginFrom = reverse ? '0' : '-' + WebInspector.zoomManager.dipToCSS(thi
s._sidebarSizeDIP) + 'px'; | 503 var marginFrom = reverse ? '0' : '-' + UI.zoomManager.dipToCSS(this._sidebar
SizeDIP) + 'px'; |
| 504 var marginTo = reverse ? '-' + WebInspector.zoomManager.dipToCSS(this._sideb
arSizeDIP) + 'px' : '0'; | 504 var marginTo = reverse ? '-' + UI.zoomManager.dipToCSS(this._sidebarSizeDIP)
+ 'px' : '0'; |
| 505 | 505 |
| 506 // This order of things is important. | 506 // This order of things is important. |
| 507 // 1. Resize main element early and force layout. | 507 // 1. Resize main element early and force layout. |
| 508 this.contentElement.style.setProperty(animatedMarginPropertyName, marginFrom
); | 508 this.contentElement.style.setProperty(animatedMarginPropertyName, marginFrom
); |
| 509 if (!reverse) { | 509 if (!reverse) { |
| 510 suppressUnused(this._mainElement.offsetWidth); | 510 suppressUnused(this._mainElement.offsetWidth); |
| 511 suppressUnused(this._sidebarElement.offsetWidth); | 511 suppressUnused(this._sidebarElement.offsetWidth); |
| 512 } | 512 } |
| 513 | 513 |
| 514 // 2. Issue onresize to the sidebar element, its size won't change. | 514 // 2. Issue onresize to the sidebar element, its size won't change. |
| 515 if (!reverse) | 515 if (!reverse) |
| 516 this._sidebarWidget.doResize(); | 516 this._sidebarWidget.doResize(); |
| 517 | 517 |
| 518 // 3. Configure and run animation | 518 // 3. Configure and run animation |
| 519 this.contentElement.style.setProperty('transition', animatedMarginPropertyNa
me + ' ' + animationTime + 'ms linear'); | 519 this.contentElement.style.setProperty('transition', animatedMarginPropertyNa
me + ' ' + animationTime + 'ms linear'); |
| 520 | 520 |
| 521 var boundAnimationFrame; | 521 var boundAnimationFrame; |
| 522 var startTime; | 522 var startTime; |
| 523 /** | 523 /** |
| 524 * @this {WebInspector.SplitWidget} | 524 * @this {UI.SplitWidget} |
| 525 */ | 525 */ |
| 526 function animationFrame() { | 526 function animationFrame() { |
| 527 delete this._animationFrameHandle; | 527 delete this._animationFrameHandle; |
| 528 | 528 |
| 529 if (!startTime) { | 529 if (!startTime) { |
| 530 // Kick animation on first frame. | 530 // Kick animation on first frame. |
| 531 this.contentElement.style.setProperty(animatedMarginPropertyName, margin
To); | 531 this.contentElement.style.setProperty(animatedMarginPropertyName, margin
To); |
| 532 startTime = window.performance.now(); | 532 startTime = window.performance.now(); |
| 533 } else if (window.performance.now() < startTime + animationTime) { | 533 } else if (window.performance.now() < startTime + animationTime) { |
| 534 // Process regular animation frame. | 534 // Process regular animation frame. |
| 535 if (this._mainWidget) | 535 if (this._mainWidget) |
| 536 this._mainWidget.doResize(); | 536 this._mainWidget.doResize(); |
| 537 } else { | 537 } else { |
| 538 // Complete animation. | 538 // Complete animation. |
| 539 this._cancelAnimation(); | 539 this._cancelAnimation(); |
| 540 if (this._mainWidget) | 540 if (this._mainWidget) |
| 541 this._mainWidget.doResize(); | 541 this._mainWidget.doResize(); |
| 542 this.dispatchEventToListeners(WebInspector.SplitWidget.Events.SidebarSiz
eChanged, this.sidebarSize()); | 542 this.dispatchEventToListeners(UI.SplitWidget.Events.SidebarSizeChanged,
this.sidebarSize()); |
| 543 return; | 543 return; |
| 544 } | 544 } |
| 545 this._animationFrameHandle = this.contentElement.window().requestAnimation
Frame(boundAnimationFrame); | 545 this._animationFrameHandle = this.contentElement.window().requestAnimation
Frame(boundAnimationFrame); |
| 546 } | 546 } |
| 547 boundAnimationFrame = animationFrame.bind(this); | 547 boundAnimationFrame = animationFrame.bind(this); |
| 548 this._animationFrameHandle = this.contentElement.window().requestAnimationFr
ame(boundAnimationFrame); | 548 this._animationFrameHandle = this.contentElement.window().requestAnimationFr
ame(boundAnimationFrame); |
| 549 } | 549 } |
| 550 | 550 |
| 551 _cancelAnimation() { | 551 _cancelAnimation() { |
| 552 this.contentElement.style.removeProperty('margin-top'); | 552 this.contentElement.style.removeProperty('margin-top'); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 565 } | 565 } |
| 566 } | 566 } |
| 567 | 567 |
| 568 /** | 568 /** |
| 569 * @param {number} sidebarSize | 569 * @param {number} sidebarSize |
| 570 * @param {boolean=} userAction | 570 * @param {boolean=} userAction |
| 571 * @return {number} | 571 * @return {number} |
| 572 */ | 572 */ |
| 573 _applyConstraints(sidebarSize, userAction) { | 573 _applyConstraints(sidebarSize, userAction) { |
| 574 var totalSize = this._totalSizeDIP(); | 574 var totalSize = this._totalSizeDIP(); |
| 575 var zoomFactor = this._constraintsInDip ? 1 : WebInspector.zoomManager.zoomF
actor(); | 575 var zoomFactor = this._constraintsInDip ? 1 : UI.zoomManager.zoomFactor(); |
| 576 | 576 |
| 577 var constraints = this._sidebarWidget ? this._sidebarWidget.constraints() :
new Constraints(); | 577 var constraints = this._sidebarWidget ? this._sidebarWidget.constraints() :
new Constraints(); |
| 578 var minSidebarSize = this.isVertical() ? constraints.minimum.width : constra
ints.minimum.height; | 578 var minSidebarSize = this.isVertical() ? constraints.minimum.width : constra
ints.minimum.height; |
| 579 if (!minSidebarSize) | 579 if (!minSidebarSize) |
| 580 minSidebarSize = WebInspector.SplitWidget.MinPadding; | 580 minSidebarSize = UI.SplitWidget.MinPadding; |
| 581 minSidebarSize *= zoomFactor; | 581 minSidebarSize *= zoomFactor; |
| 582 if (this._sidebarMinimized) | 582 if (this._sidebarMinimized) |
| 583 sidebarSize = minSidebarSize; | 583 sidebarSize = minSidebarSize; |
| 584 | 584 |
| 585 var preferredSidebarSize = this.isVertical() ? constraints.preferred.width :
constraints.preferred.height; | 585 var preferredSidebarSize = this.isVertical() ? constraints.preferred.width :
constraints.preferred.height; |
| 586 if (!preferredSidebarSize) | 586 if (!preferredSidebarSize) |
| 587 preferredSidebarSize = WebInspector.SplitWidget.MinPadding; | 587 preferredSidebarSize = UI.SplitWidget.MinPadding; |
| 588 preferredSidebarSize *= zoomFactor; | 588 preferredSidebarSize *= zoomFactor; |
| 589 // Allow sidebar to be less than preferred by explicit user action. | 589 // Allow sidebar to be less than preferred by explicit user action. |
| 590 if (sidebarSize < preferredSidebarSize) | 590 if (sidebarSize < preferredSidebarSize) |
| 591 preferredSidebarSize = Math.max(sidebarSize, minSidebarSize); | 591 preferredSidebarSize = Math.max(sidebarSize, minSidebarSize); |
| 592 preferredSidebarSize += zoomFactor; // 1 css pixel for splitter border. | 592 preferredSidebarSize += zoomFactor; // 1 css pixel for splitter border. |
| 593 | 593 |
| 594 constraints = this._mainWidget ? this._mainWidget.constraints() : new Constr
aints(); | 594 constraints = this._mainWidget ? this._mainWidget.constraints() : new Constr
aints(); |
| 595 var minMainSize = this.isVertical() ? constraints.minimum.width : constraint
s.minimum.height; | 595 var minMainSize = this.isVertical() ? constraints.minimum.width : constraint
s.minimum.height; |
| 596 if (!minMainSize) | 596 if (!minMainSize) |
| 597 minMainSize = WebInspector.SplitWidget.MinPadding; | 597 minMainSize = UI.SplitWidget.MinPadding; |
| 598 minMainSize *= zoomFactor; | 598 minMainSize *= zoomFactor; |
| 599 | 599 |
| 600 var preferredMainSize = this.isVertical() ? constraints.preferred.width : co
nstraints.preferred.height; | 600 var preferredMainSize = this.isVertical() ? constraints.preferred.width : co
nstraints.preferred.height; |
| 601 if (!preferredMainSize) | 601 if (!preferredMainSize) |
| 602 preferredMainSize = WebInspector.SplitWidget.MinPadding; | 602 preferredMainSize = UI.SplitWidget.MinPadding; |
| 603 preferredMainSize *= zoomFactor; | 603 preferredMainSize *= zoomFactor; |
| 604 var savedMainSize = this.isVertical() ? this._savedVerticalMainSize : this._
savedHorizontalMainSize; | 604 var savedMainSize = this.isVertical() ? this._savedVerticalMainSize : this._
savedHorizontalMainSize; |
| 605 if (typeof savedMainSize !== 'undefined') | 605 if (typeof savedMainSize !== 'undefined') |
| 606 preferredMainSize = Math.min(preferredMainSize, savedMainSize * zoomFactor
); | 606 preferredMainSize = Math.min(preferredMainSize, savedMainSize * zoomFactor
); |
| 607 if (userAction) | 607 if (userAction) |
| 608 preferredMainSize = minMainSize; | 608 preferredMainSize = minMainSize; |
| 609 | 609 |
| 610 // Enough space for preferred. | 610 // Enough space for preferred. |
| 611 var totalPreferred = preferredMainSize + preferredSidebarSize; | 611 var totalPreferred = preferredMainSize + preferredSidebarSize; |
| 612 if (totalPreferred <= totalSize) | 612 if (totalPreferred <= totalSize) |
| 613 return Number.constrain(sidebarSize, preferredSidebarSize, totalSize - pre
ferredMainSize); | 613 return Number.constrain(sidebarSize, preferredSidebarSize, totalSize - pre
ferredMainSize); |
| 614 | 614 |
| 615 // Enough space for minimum. | 615 // Enough space for minimum. |
| 616 if (minMainSize + minSidebarSize <= totalSize) { | 616 if (minMainSize + minSidebarSize <= totalSize) { |
| 617 var delta = totalPreferred - totalSize; | 617 var delta = totalPreferred - totalSize; |
| 618 var sidebarDelta = delta * preferredSidebarSize / totalPreferred; | 618 var sidebarDelta = delta * preferredSidebarSize / totalPreferred; |
| 619 sidebarSize = preferredSidebarSize - sidebarDelta; | 619 sidebarSize = preferredSidebarSize - sidebarDelta; |
| 620 return Number.constrain(sidebarSize, minSidebarSize, totalSize - minMainSi
ze); | 620 return Number.constrain(sidebarSize, minSidebarSize, totalSize - minMainSi
ze); |
| 621 } | 621 } |
| 622 | 622 |
| 623 // Not enough space even for minimum sizes. | 623 // Not enough space even for minimum sizes. |
| 624 return Math.max(0, totalSize - minMainSize); | 624 return Math.max(0, totalSize - minMainSize); |
| 625 } | 625 } |
| 626 | 626 |
| 627 /** | 627 /** |
| 628 * @override | 628 * @override |
| 629 */ | 629 */ |
| 630 wasShown() { | 630 wasShown() { |
| 631 this._forceUpdateLayout(); | 631 this._forceUpdateLayout(); |
| 632 WebInspector.zoomManager.addEventListener(WebInspector.ZoomManager.Events.Zo
omChanged, this._onZoomChanged, this); | 632 UI.zoomManager.addEventListener(UI.ZoomManager.Events.ZoomChanged, this._onZ
oomChanged, this); |
| 633 } | 633 } |
| 634 | 634 |
| 635 /** | 635 /** |
| 636 * @override | 636 * @override |
| 637 */ | 637 */ |
| 638 willHide() { | 638 willHide() { |
| 639 WebInspector.zoomManager.removeEventListener( | 639 UI.zoomManager.removeEventListener( |
| 640 WebInspector.ZoomManager.Events.ZoomChanged, this._onZoomChanged, this); | 640 UI.ZoomManager.Events.ZoomChanged, this._onZoomChanged, this); |
| 641 } | 641 } |
| 642 | 642 |
| 643 /** | 643 /** |
| 644 * @override | 644 * @override |
| 645 */ | 645 */ |
| 646 onResize() { | 646 onResize() { |
| 647 this._updateLayout(); | 647 this._updateLayout(); |
| 648 } | 648 } |
| 649 | 649 |
| 650 /** | 650 /** |
| 651 * @override | 651 * @override |
| 652 */ | 652 */ |
| 653 onLayout() { | 653 onLayout() { |
| 654 this._updateLayout(); | 654 this._updateLayout(); |
| 655 } | 655 } |
| 656 | 656 |
| 657 /** | 657 /** |
| 658 * @override | 658 * @override |
| 659 * @return {!Constraints} | 659 * @return {!Constraints} |
| 660 */ | 660 */ |
| 661 calculateConstraints() { | 661 calculateConstraints() { |
| 662 if (this._showMode === WebInspector.SplitWidget.ShowMode.OnlyMain) | 662 if (this._showMode === UI.SplitWidget.ShowMode.OnlyMain) |
| 663 return this._mainWidget ? this._mainWidget.constraints() : new Constraints
(); | 663 return this._mainWidget ? this._mainWidget.constraints() : new Constraints
(); |
| 664 if (this._showMode === WebInspector.SplitWidget.ShowMode.OnlySidebar) | 664 if (this._showMode === UI.SplitWidget.ShowMode.OnlySidebar) |
| 665 return this._sidebarWidget ? this._sidebarWidget.constraints() : new Const
raints(); | 665 return this._sidebarWidget ? this._sidebarWidget.constraints() : new Const
raints(); |
| 666 | 666 |
| 667 var mainConstraints = this._mainWidget ? this._mainWidget.constraints() : ne
w Constraints(); | 667 var mainConstraints = this._mainWidget ? this._mainWidget.constraints() : ne
w Constraints(); |
| 668 var sidebarConstraints = this._sidebarWidget ? this._sidebarWidget.constrain
ts() : new Constraints(); | 668 var sidebarConstraints = this._sidebarWidget ? this._sidebarWidget.constrain
ts() : new Constraints(); |
| 669 var min = WebInspector.SplitWidget.MinPadding; | 669 var min = UI.SplitWidget.MinPadding; |
| 670 if (this._isVertical) { | 670 if (this._isVertical) { |
| 671 mainConstraints = mainConstraints.widthToMax(min).addWidth(1); // 1 for s
plitter | 671 mainConstraints = mainConstraints.widthToMax(min).addWidth(1); // 1 for s
plitter |
| 672 sidebarConstraints = sidebarConstraints.widthToMax(min); | 672 sidebarConstraints = sidebarConstraints.widthToMax(min); |
| 673 return mainConstraints.addWidth(sidebarConstraints).heightToMax(sidebarCon
straints); | 673 return mainConstraints.addWidth(sidebarConstraints).heightToMax(sidebarCon
straints); |
| 674 } else { | 674 } else { |
| 675 mainConstraints = mainConstraints.heightToMax(min).addHeight(1); // 1 for
splitter | 675 mainConstraints = mainConstraints.heightToMax(min).addHeight(1); // 1 for
splitter |
| 676 sidebarConstraints = sidebarConstraints.heightToMax(min); | 676 sidebarConstraints = sidebarConstraints.heightToMax(min); |
| 677 return mainConstraints.widthToMax(sidebarConstraints).addHeight(sidebarCon
straints); | 677 return mainConstraints.widthToMax(sidebarConstraints).addHeight(sidebarCon
straints); |
| 678 } | 678 } |
| 679 } | 679 } |
| 680 | 680 |
| 681 /** | 681 /** |
| 682 * @param {!WebInspector.Event} event | 682 * @param {!Common.Event} event |
| 683 */ | 683 */ |
| 684 _onResizeStart(event) { | 684 _onResizeStart(event) { |
| 685 this._resizeStartSizeDIP = this._sidebarSizeDIP; | 685 this._resizeStartSizeDIP = this._sidebarSizeDIP; |
| 686 } | 686 } |
| 687 | 687 |
| 688 /** | 688 /** |
| 689 * @param {!WebInspector.Event} event | 689 * @param {!Common.Event} event |
| 690 */ | 690 */ |
| 691 _onResizeUpdate(event) { | 691 _onResizeUpdate(event) { |
| 692 var offset = event.data.currentPosition - event.data.startPosition; | 692 var offset = event.data.currentPosition - event.data.startPosition; |
| 693 var offsetDIP = WebInspector.zoomManager.cssToDIP(offset); | 693 var offsetDIP = UI.zoomManager.cssToDIP(offset); |
| 694 var newSizeDIP = | 694 var newSizeDIP = |
| 695 this._secondIsSidebar ? this._resizeStartSizeDIP - offsetDIP : this._res
izeStartSizeDIP + offsetDIP; | 695 this._secondIsSidebar ? this._resizeStartSizeDIP - offsetDIP : this._res
izeStartSizeDIP + offsetDIP; |
| 696 var constrainedSizeDIP = this._applyConstraints(newSizeDIP, true); | 696 var constrainedSizeDIP = this._applyConstraints(newSizeDIP, true); |
| 697 this._savedSidebarSizeDIP = constrainedSizeDIP; | 697 this._savedSidebarSizeDIP = constrainedSizeDIP; |
| 698 this._saveSetting(); | 698 this._saveSetting(); |
| 699 this._innerSetSidebarSizeDIP(constrainedSizeDIP, false, true); | 699 this._innerSetSidebarSizeDIP(constrainedSizeDIP, false, true); |
| 700 if (this.isVertical()) | 700 if (this.isVertical()) |
| 701 this._savedVerticalMainSize = this._totalSizeDIP() - this._sidebarSizeDIP; | 701 this._savedVerticalMainSize = this._totalSizeDIP() - this._sidebarSizeDIP; |
| 702 else | 702 else |
| 703 this._savedHorizontalMainSize = this._totalSizeDIP() - this._sidebarSizeDI
P; | 703 this._savedHorizontalMainSize = this._totalSizeDIP() - this._sidebarSizeDI
P; |
| 704 } | 704 } |
| 705 | 705 |
| 706 /** | 706 /** |
| 707 * @param {!WebInspector.Event} event | 707 * @param {!Common.Event} event |
| 708 */ | 708 */ |
| 709 _onResizeEnd(event) { | 709 _onResizeEnd(event) { |
| 710 delete this._resizeStartSizeDIP; | 710 delete this._resizeStartSizeDIP; |
| 711 } | 711 } |
| 712 | 712 |
| 713 hideDefaultResizer() { | 713 hideDefaultResizer() { |
| 714 this.uninstallResizer(this._resizerElement); | 714 this.uninstallResizer(this._resizerElement); |
| 715 } | 715 } |
| 716 | 716 |
| 717 /** | 717 /** |
| (...skipping 23 matching lines...) Expand all Loading... |
| 741 * @param {boolean} on | 741 * @param {boolean} on |
| 742 */ | 742 */ |
| 743 toggleResizer(resizer, on) { | 743 toggleResizer(resizer, on) { |
| 744 if (on) | 744 if (on) |
| 745 this.installResizer(resizer); | 745 this.installResizer(resizer); |
| 746 else | 746 else |
| 747 this.uninstallResizer(resizer); | 747 this.uninstallResizer(resizer); |
| 748 } | 748 } |
| 749 | 749 |
| 750 /** | 750 /** |
| 751 * @return {?WebInspector.SplitWidget.SettingForOrientation} | 751 * @return {?UI.SplitWidget.SettingForOrientation} |
| 752 */ | 752 */ |
| 753 _settingForOrientation() { | 753 _settingForOrientation() { |
| 754 var state = this._setting ? this._setting.get() : {}; | 754 var state = this._setting ? this._setting.get() : {}; |
| 755 return this._isVertical ? state.vertical : state.horizontal; | 755 return this._isVertical ? state.vertical : state.horizontal; |
| 756 } | 756 } |
| 757 | 757 |
| 758 /** | 758 /** |
| 759 * @return {number} | 759 * @return {number} |
| 760 */ | 760 */ |
| 761 _preferredSidebarSizeDIP() { | 761 _preferredSidebarSizeDIP() { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 773 var settingForOrientation = this._settingForOrientation(); | 773 var settingForOrientation = this._settingForOrientation(); |
| 774 this._savedSidebarSizeDIP = settingForOrientation ? settingForOrientation.si
ze : 0; | 774 this._savedSidebarSizeDIP = settingForOrientation ? settingForOrientation.si
ze : 0; |
| 775 } | 775 } |
| 776 | 776 |
| 777 _restoreAndApplyShowModeFromSettings() { | 777 _restoreAndApplyShowModeFromSettings() { |
| 778 var orientationState = this._settingForOrientation(); | 778 var orientationState = this._settingForOrientation(); |
| 779 this._savedShowMode = orientationState && orientationState.showMode ? orient
ationState.showMode : this._showMode; | 779 this._savedShowMode = orientationState && orientationState.showMode ? orient
ationState.showMode : this._showMode; |
| 780 this._showMode = this._savedShowMode; | 780 this._showMode = this._savedShowMode; |
| 781 | 781 |
| 782 switch (this._savedShowMode) { | 782 switch (this._savedShowMode) { |
| 783 case WebInspector.SplitWidget.ShowMode.Both: | 783 case UI.SplitWidget.ShowMode.Both: |
| 784 this.showBoth(); | 784 this.showBoth(); |
| 785 break; | 785 break; |
| 786 case WebInspector.SplitWidget.ShowMode.OnlyMain: | 786 case UI.SplitWidget.ShowMode.OnlyMain: |
| 787 this.hideSidebar(); | 787 this.hideSidebar(); |
| 788 break; | 788 break; |
| 789 case WebInspector.SplitWidget.ShowMode.OnlySidebar: | 789 case UI.SplitWidget.ShowMode.OnlySidebar: |
| 790 this.hideMain(); | 790 this.hideMain(); |
| 791 break; | 791 break; |
| 792 } | 792 } |
| 793 } | 793 } |
| 794 | 794 |
| 795 _saveShowModeToSettings() { | 795 _saveShowModeToSettings() { |
| 796 this._savedShowMode = this._showMode; | 796 this._savedShowMode = this._showMode; |
| 797 this._saveSetting(); | 797 this._saveSetting(); |
| 798 } | 798 } |
| 799 | 799 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 814 this._setting.set(state); | 814 this._setting.set(state); |
| 815 } | 815 } |
| 816 | 816 |
| 817 _forceUpdateLayout() { | 817 _forceUpdateLayout() { |
| 818 // Force layout even if sidebar size does not change. | 818 // Force layout even if sidebar size does not change. |
| 819 this._sidebarSizeDIP = -1; | 819 this._sidebarSizeDIP = -1; |
| 820 this._updateLayout(); | 820 this._updateLayout(); |
| 821 } | 821 } |
| 822 | 822 |
| 823 /** | 823 /** |
| 824 * @param {!WebInspector.Event} event | 824 * @param {!Common.Event} event |
| 825 */ | 825 */ |
| 826 _onZoomChanged(event) { | 826 _onZoomChanged(event) { |
| 827 this._forceUpdateLayout(); | 827 this._forceUpdateLayout(); |
| 828 } | 828 } |
| 829 | 829 |
| 830 /** | 830 /** |
| 831 * @param {string} title | 831 * @param {string} title |
| 832 * @return {!WebInspector.ToolbarButton} | 832 * @return {!UI.ToolbarButton} |
| 833 */ | 833 */ |
| 834 createShowHideSidebarButton(title) { | 834 createShowHideSidebarButton(title) { |
| 835 this._showHideSidebarButtonTitle = WebInspector.UIString(title); | 835 this._showHideSidebarButtonTitle = Common.UIString(title); |
| 836 this._showHideSidebarButton = new WebInspector.ToolbarButton('', ''); | 836 this._showHideSidebarButton = new UI.ToolbarButton('', ''); |
| 837 this._showHideSidebarButton.addEventListener('click', buttonClicked.bind(thi
s)); | 837 this._showHideSidebarButton.addEventListener('click', buttonClicked.bind(thi
s)); |
| 838 this._updateShowHideSidebarButton(); | 838 this._updateShowHideSidebarButton(); |
| 839 | 839 |
| 840 /** | 840 /** |
| 841 * @param {!WebInspector.Event} event | 841 * @param {!Common.Event} event |
| 842 * @this {WebInspector.SplitWidget} | 842 * @this {UI.SplitWidget} |
| 843 */ | 843 */ |
| 844 function buttonClicked(event) { | 844 function buttonClicked(event) { |
| 845 if (this._showMode !== WebInspector.SplitWidget.ShowMode.Both) | 845 if (this._showMode !== UI.SplitWidget.ShowMode.Both) |
| 846 this.showBoth(true); | 846 this.showBoth(true); |
| 847 else | 847 else |
| 848 this.hideSidebar(true); | 848 this.hideSidebar(true); |
| 849 } | 849 } |
| 850 | 850 |
| 851 return this._showHideSidebarButton; | 851 return this._showHideSidebarButton; |
| 852 } | 852 } |
| 853 | 853 |
| 854 _updateShowHideSidebarButton() { | 854 _updateShowHideSidebarButton() { |
| 855 if (!this._showHideSidebarButton) | 855 if (!this._showHideSidebarButton) |
| 856 return; | 856 return; |
| 857 var sidebarHidden = this._showMode === WebInspector.SplitWidget.ShowMode.Onl
yMain; | 857 var sidebarHidden = this._showMode === UI.SplitWidget.ShowMode.OnlyMain; |
| 858 var glyph = ''; | 858 var glyph = ''; |
| 859 if (sidebarHidden) { | 859 if (sidebarHidden) { |
| 860 glyph = this.isVertical() ? | 860 glyph = this.isVertical() ? |
| 861 (this.isSidebarSecond() ? 'largeicon-show-right-sidebar' : 'largeicon-
show-left-sidebar') : | 861 (this.isSidebarSecond() ? 'largeicon-show-right-sidebar' : 'largeicon-
show-left-sidebar') : |
| 862 (this.isSidebarSecond() ? 'largeicon-show-bottom-sidebar' : 'largeicon
-show-top-sidebar'); | 862 (this.isSidebarSecond() ? 'largeicon-show-bottom-sidebar' : 'largeicon
-show-top-sidebar'); |
| 863 } else { | 863 } else { |
| 864 glyph = this.isVertical() ? | 864 glyph = this.isVertical() ? |
| 865 (this.isSidebarSecond() ? 'largeicon-hide-right-sidebar' : 'largeicon-
hide-left-sidebar') : | 865 (this.isSidebarSecond() ? 'largeicon-hide-right-sidebar' : 'largeicon-
hide-left-sidebar') : |
| 866 (this.isSidebarSecond() ? 'largeicon-hide-bottom-sidebar' : 'largeicon
-hide-top-sidebar'); | 866 (this.isSidebarSecond() ? 'largeicon-hide-bottom-sidebar' : 'largeicon
-hide-top-sidebar'); |
| 867 } | 867 } |
| 868 this._showHideSidebarButton.setGlyph(glyph); | 868 this._showHideSidebarButton.setGlyph(glyph); |
| 869 this._showHideSidebarButton.setTitle( | 869 this._showHideSidebarButton.setTitle( |
| 870 sidebarHidden ? WebInspector.UIString('Show %s', this._showHideSidebarBu
ttonTitle) : | 870 sidebarHidden ? Common.UIString('Show %s', this._showHideSidebarButtonTi
tle) : |
| 871 WebInspector.UIString('Hide %s', this._showHideSidebarBu
ttonTitle)); | 871 Common.UIString('Hide %s', this._showHideSidebarButtonTi
tle)); |
| 872 } | 872 } |
| 873 }; | 873 }; |
| 874 | 874 |
| 875 /** @typedef {{showMode: string, size: number}} */ | 875 /** @typedef {{showMode: string, size: number}} */ |
| 876 WebInspector.SplitWidget.SettingForOrientation; | 876 UI.SplitWidget.SettingForOrientation; |
| 877 | 877 |
| 878 WebInspector.SplitWidget.ShowMode = { | 878 UI.SplitWidget.ShowMode = { |
| 879 Both: 'Both', | 879 Both: 'Both', |
| 880 OnlyMain: 'OnlyMain', | 880 OnlyMain: 'OnlyMain', |
| 881 OnlySidebar: 'OnlySidebar' | 881 OnlySidebar: 'OnlySidebar' |
| 882 }; | 882 }; |
| 883 | 883 |
| 884 /** @enum {symbol} */ | 884 /** @enum {symbol} */ |
| 885 WebInspector.SplitWidget.Events = { | 885 UI.SplitWidget.Events = { |
| 886 SidebarSizeChanged: Symbol('SidebarSizeChanged'), | 886 SidebarSizeChanged: Symbol('SidebarSizeChanged'), |
| 887 ShowModeChanged: Symbol('ShowModeChanged') | 887 ShowModeChanged: Symbol('ShowModeChanged') |
| 888 }; | 888 }; |
| 889 | 889 |
| 890 WebInspector.SplitWidget.MinPadding = 20; | 890 UI.SplitWidget.MinPadding = 20; |
| OLD | NEW |