OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 UI.GlassPane = class { | 5 UI.GlassPane = class { |
6 constructor() { | 6 constructor() { |
7 this._widget = new UI.Widget(true); | 7 this._widget = new UI.Widget(true); |
8 this._widget.markAsRoot(); | 8 this._widget.markAsRoot(); |
9 this.element = this._widget.element; | 9 this.element = this._widget.element; |
10 this.contentElement = this._widget.contentElement; | 10 this.contentElement = this._widget.contentElement; |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 } | 298 } |
299 } | 299 } |
300 } else { | 300 } else { |
301 positionX = this._positionX !== null ? this._positionX : (containerWidth -
width) / 2; | 301 positionX = this._positionX !== null ? this._positionX : (containerWidth -
width) / 2; |
302 positionY = this._positionY !== null ? this._positionY : (containerHeight
- height) / 2; | 302 positionY = this._positionY !== null ? this._positionY : (containerHeight
- height) / 2; |
303 width = Math.min(width, containerWidth - positionX - gutterSize); | 303 width = Math.min(width, containerWidth - positionX - gutterSize); |
304 height = Math.min(height, containerHeight - positionY - gutterSize); | 304 height = Math.min(height, containerHeight - positionY - gutterSize); |
305 this._arrowElement.classList.add('arrow-none'); | 305 this._arrowElement.classList.add('arrow-none'); |
306 } | 306 } |
307 | 307 |
308 if (this._sizeBehavior === UI.GlassPane.SizeBehavior.SetMaxSize) | 308 this.contentElement.style.width = width + 'px'; |
309 this.contentElement.style.maxWidth = width + 'px'; | 309 if (this._sizeBehavior === UI.GlassPane.SizeBehavior.SetExactWidthMaxHeight) |
310 else | |
311 this.contentElement.style.width = width + 'px'; | |
312 | |
313 if (this._sizeBehavior === UI.GlassPane.SizeBehavior.SetMaxSize || | |
314 this._sizeBehavior === UI.GlassPane.SizeBehavior.SetExactWidthMaxHeight) | |
315 this.contentElement.style.maxHeight = height + 'px'; | 310 this.contentElement.style.maxHeight = height + 'px'; |
316 else | 311 else |
317 this.contentElement.style.height = height + 'px'; | 312 this.contentElement.style.height = height + 'px'; |
318 | 313 |
319 | |
320 this.contentElement.positionAt(positionX, positionY, container); | 314 this.contentElement.positionAt(positionX, positionY, container); |
321 this._widget.doResize(); | 315 this._widget.doResize(); |
322 } | 316 } |
323 | 317 |
324 /** | 318 /** |
325 * @protected | 319 * @protected |
326 * @return {!UI.Widget} | 320 * @return {!UI.Widget} |
327 */ | 321 */ |
328 widget() { | 322 widget() { |
329 return this._widget; | 323 return this._widget; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 PreferBottom: Symbol('PreferBottom'), | 358 PreferBottom: Symbol('PreferBottom'), |
365 PreferLeft: Symbol('PreferLeft'), | 359 PreferLeft: Symbol('PreferLeft'), |
366 PreferRight: Symbol('PreferRight'), | 360 PreferRight: Symbol('PreferRight'), |
367 }; | 361 }; |
368 | 362 |
369 /** | 363 /** |
370 * @enum {symbol} | 364 * @enum {symbol} |
371 */ | 365 */ |
372 UI.GlassPane.SizeBehavior = { | 366 UI.GlassPane.SizeBehavior = { |
373 SetExactSize: Symbol('SetExactSize'), | 367 SetExactSize: Symbol('SetExactSize'), |
374 SetMaxSize: Symbol('SetMaxSize'), | |
375 SetExactWidthMaxHeight: Symbol('SetExactWidthMaxHeight'), | 368 SetExactWidthMaxHeight: Symbol('SetExactWidthMaxHeight'), |
376 MeasureContent: Symbol('MeasureContent') | 369 MeasureContent: Symbol('MeasureContent') |
377 }; | 370 }; |
378 | 371 |
379 /** @type {!Map<!Document, !Element>} */ | 372 /** @type {!Map<!Document, !Element>} */ |
380 UI.GlassPane._containers = new Map(); | 373 UI.GlassPane._containers = new Map(); |
381 /** @type {!Set<!UI.GlassPane>} */ | 374 /** @type {!Set<!UI.GlassPane>} */ |
382 UI.GlassPane._panes = new Set(); | 375 UI.GlassPane._panes = new Set(); |
OLD | NEW |