| 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 /** | 6 /** |
| 7 * @param {!Document} document | 7 * @param {!Document} document |
| 8 * @param {boolean} dimmed | 8 * @param {boolean} dimmed |
| 9 * @param {boolean} blockPointerEvents | 9 * @param {boolean} blockPointerEvents |
| 10 * @param {function(!Event)} onClickOutside | 10 * @param {function(!Event)} onClickOutside |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 this._visible = false; | 24 this._visible = false; |
| 25 /** @type {?UI.Size} */ | 25 /** @type {?UI.Size} */ |
| 26 this._maxSize = null; | 26 this._maxSize = null; |
| 27 /** @type {?number} */ | 27 /** @type {?number} */ |
| 28 this._positionX = null; | 28 this._positionX = null; |
| 29 /** @type {?number} */ | 29 /** @type {?number} */ |
| 30 this._positionY = null; | 30 this._positionY = null; |
| 31 /** @type {?AnchorBox} */ | 31 /** @type {?AnchorBox} */ |
| 32 this._anchorBox = null; | 32 this._anchorBox = null; |
| 33 this._anchorBehavior = UI.GlassPane.AnchorBehavior.PreferTop; | 33 this._anchorBehavior = UI.GlassPane.AnchorBehavior.PreferTop; |
| 34 this._fixedHeight = true; |
| 34 } | 35 } |
| 35 | 36 |
| 36 /** | 37 /** |
| 37 * @param {?UI.Size} size | 38 * @param {?UI.Size} size |
| 38 */ | 39 */ |
| 39 setMaxContentSize(size) { | 40 setMaxContentSize(size) { |
| 40 this._maxSize = size; | 41 this._maxSize = size; |
| 41 this._positionContent(); | 42 this._positionContent(); |
| 42 } | 43 } |
| 43 | 44 |
| 44 /** | 45 /** |
| 46 * @param {boolean} fixedHeight |
| 47 */ |
| 48 setFixedHeight(fixedHeight) { |
| 49 this._fixedHeight = fixedHeight; |
| 50 } |
| 51 |
| 52 /** |
| 45 * @param {?number} x | 53 * @param {?number} x |
| 46 * @param {?number} y | 54 * @param {?number} y |
| 47 * Position is relative to root element. | 55 * Position is relative to root element. |
| 48 */ | 56 */ |
| 49 setContentPosition(x, y) { | 57 setContentPosition(x, y) { |
| 50 this._positionX = x; | 58 this._positionX = x; |
| 51 this._positionY = y; | 59 this._positionY = y; |
| 52 this._positionContent(); | 60 this._positionContent(); |
| 53 } | 61 } |
| 54 | 62 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 } | 162 } |
| 155 } | 163 } |
| 156 } else { | 164 } else { |
| 157 positionX = this._positionX !== null ? this._positionX : (containerWidth -
width) / 2; | 165 positionX = this._positionX !== null ? this._positionX : (containerWidth -
width) / 2; |
| 158 positionY = this._positionY !== null ? this._positionY : (containerHeight
- height) / 2; | 166 positionY = this._positionY !== null ? this._positionY : (containerHeight
- height) / 2; |
| 159 width = Math.min(width, containerWidth - positionX - gutterSize); | 167 width = Math.min(width, containerWidth - positionX - gutterSize); |
| 160 height = Math.min(height, containerHeight - positionY - gutterSize); | 168 height = Math.min(height, containerHeight - positionY - gutterSize); |
| 161 } | 169 } |
| 162 | 170 |
| 163 this.contentElement.style.width = width + 'px'; | 171 this.contentElement.style.width = width + 'px'; |
| 164 this.contentElement.style.height = height + 'px'; | 172 if (this._fixedHeight) |
| 173 this.contentElement.style.height = height + 'px'; |
| 174 else |
| 175 this.contentElement.style.maxHeight = height + 'px'; |
| 165 this.contentElement.positionAt(positionX, positionY, container); | 176 this.contentElement.positionAt(positionX, positionY, container); |
| 166 } | 177 } |
| 167 | 178 |
| 168 /** | 179 /** |
| 169 * @param {!Element} element | 180 * @param {!Element} element |
| 170 */ | 181 */ |
| 171 static setContainer(element) { | 182 static setContainer(element) { |
| 172 UI.GlassPane._containers.set(/** @type {!Document} */ (element.ownerDocument
), element); | 183 UI.GlassPane._containers.set(/** @type {!Document} */ (element.ownerDocument
), element); |
| 173 UI.GlassPane.containerMoved(element); | 184 UI.GlassPane.containerMoved(element); |
| 174 } | 185 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 199 PreferTop: Symbol('PreferTop'), | 210 PreferTop: Symbol('PreferTop'), |
| 200 PreferBottom: Symbol('PreferBottom'), | 211 PreferBottom: Symbol('PreferBottom'), |
| 201 PreferLeft: Symbol('PreferLeft'), | 212 PreferLeft: Symbol('PreferLeft'), |
| 202 PreferRight: Symbol('PreferRight'), | 213 PreferRight: Symbol('PreferRight'), |
| 203 }; | 214 }; |
| 204 | 215 |
| 205 /** @type {!Map<!Document, !Element>} */ | 216 /** @type {!Map<!Document, !Element>} */ |
| 206 UI.GlassPane._containers = new Map(); | 217 UI.GlassPane._containers = new Map(); |
| 207 /** @type {!Set<!UI.GlassPane>} */ | 218 /** @type {!Set<!UI.GlassPane>} */ |
| 208 UI.GlassPane._panes = new Set(); | 219 UI.GlassPane._panes = new Set(); |
| OLD | NEW |