Chromium Code Reviews| 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; |
| 11 this._arrowElement = UI.Icon.create('', 'arrow hidden'); | 11 this._arrowElement = UI.Icon.create('', 'arrow hidden'); |
| 12 this.element.shadowRoot.appendChild(this._arrowElement); | 12 this.element.shadowRoot.appendChild(this._arrowElement); |
| 13 | 13 |
| 14 this.registerRequiredCSS('ui/glassPane.css'); | 14 this.registerRequiredCSS('ui/glassPane.css'); |
| 15 this.element.classList.add('no-pointer-events'); | 15 this.setPointerEventsBehavior(UI.GlassPane.PointerEventsBehavior.BlockedByGl assPane); |
| 16 | |
| 16 this._onMouseDownBound = this._onMouseDown.bind(this); | 17 this._onMouseDownBound = this._onMouseDown.bind(this); |
| 17 /** @type {?function(!Event)} */ | 18 /** @type {?function(!Event)} */ |
| 18 this._onClickOutsideCallback = null; | 19 this._onClickOutsideCallback = null; |
| 19 /** @type {?UI.Size} */ | 20 /** @type {?UI.Size} */ |
| 20 this._maxSize = null; | 21 this._maxSize = null; |
| 21 /** @type {?number} */ | 22 /** @type {?number} */ |
| 22 this._positionX = null; | 23 this._positionX = null; |
| 23 /** @type {?number} */ | 24 /** @type {?number} */ |
| 24 this._positionY = null; | 25 this._positionY = null; |
| 25 /** @type {?AnchorBox} */ | 26 /** @type {?AnchorBox} */ |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 44 } | 45 } |
| 45 | 46 |
| 46 /** | 47 /** |
| 47 * @param {boolean} dimmed | 48 * @param {boolean} dimmed |
| 48 */ | 49 */ |
| 49 setDimmed(dimmed) { | 50 setDimmed(dimmed) { |
| 50 this.element.classList.toggle('dimmed-pane', dimmed); | 51 this.element.classList.toggle('dimmed-pane', dimmed); |
| 51 } | 52 } |
| 52 | 53 |
| 53 /** | 54 /** |
| 54 * @param {boolean} blockPointerEvents | 55 * @param {!UI.GlassPane.PointerEventsBehavior} pointerEventsBehavior |
| 55 */ | 56 */ |
| 56 setBlockPointerEvents(blockPointerEvents) { | 57 setPointerEventsBehavior(pointerEventsBehavior) { |
| 57 this.element.classList.toggle('no-pointer-events', !blockPointerEvents); | 58 this.element.classList.toggle( |
| 59 'no-pointer-events', pointerEventsBehavior !== UI.GlassPane.PointerEvent sBehavior.BlockedByGlassPane); | |
| 60 this.contentElement.style.setProperty( | |
|
dgozman
2017/04/25 23:54:14
I believe this can be class as well, since content
alph
2017/04/26 00:13:48
Done.
| |
| 61 'pointer-events', | |
| 62 pointerEventsBehavior === UI.GlassPane.PointerEventsBehavior.PierceConte nts ? 'none' : 'auto'); | |
| 58 } | 63 } |
| 59 | 64 |
| 60 /** | 65 /** |
| 61 * @param {?function(!Event)} callback | 66 * @param {?function(!Event)} callback |
| 62 */ | 67 */ |
| 63 setSetOutsideClickCallback(callback) { | 68 setSetOutsideClickCallback(callback) { |
| 64 this._onClickOutsideCallback = callback; | 69 this._onClickOutsideCallback = callback; |
| 65 } | 70 } |
| 66 | 71 |
| 67 /** | 72 /** |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 357 * @param {!Element} element | 362 * @param {!Element} element |
| 358 */ | 363 */ |
| 359 static containerMoved(element) { | 364 static containerMoved(element) { |
| 360 for (var pane of UI.GlassPane._panes) { | 365 for (var pane of UI.GlassPane._panes) { |
| 361 if (pane.isShowing() && pane.element.ownerDocument === element.ownerDocume nt) | 366 if (pane.isShowing() && pane.element.ownerDocument === element.ownerDocume nt) |
| 362 pane._positionContent(); | 367 pane._positionContent(); |
| 363 } | 368 } |
| 364 } | 369 } |
| 365 }; | 370 }; |
| 366 | 371 |
| 367 /** | 372 /** @enum {symbol} */ |
| 368 * @enum {symbol} | 373 UI.GlassPane.PointerEventsBehavior = { |
| 369 */ | 374 BlockedByGlassPane: Symbol('BlockedByGlassPane'), |
| 375 PierceGlassPane: Symbol('PierceGlassPane'), | |
| 376 PierceContents: Symbol('PierceContents') | |
| 377 }; | |
| 378 | |
| 379 /** @enum {symbol} */ | |
| 370 UI.GlassPane.AnchorBehavior = { | 380 UI.GlassPane.AnchorBehavior = { |
| 371 PreferTop: Symbol('PreferTop'), | 381 PreferTop: Symbol('PreferTop'), |
| 372 PreferBottom: Symbol('PreferBottom'), | 382 PreferBottom: Symbol('PreferBottom'), |
| 373 PreferLeft: Symbol('PreferLeft'), | 383 PreferLeft: Symbol('PreferLeft'), |
| 374 PreferRight: Symbol('PreferRight'), | 384 PreferRight: Symbol('PreferRight'), |
| 375 }; | 385 }; |
| 376 | 386 |
| 377 /** | 387 /** @enum {symbol} */ |
| 378 * @enum {symbol} | |
| 379 */ | |
| 380 UI.GlassPane.SizeBehavior = { | 388 UI.GlassPane.SizeBehavior = { |
| 381 SetExactSize: Symbol('SetExactSize'), | 389 SetExactSize: Symbol('SetExactSize'), |
| 382 SetExactWidthMaxHeight: Symbol('SetExactWidthMaxHeight'), | 390 SetExactWidthMaxHeight: Symbol('SetExactWidthMaxHeight'), |
| 383 MeasureContent: Symbol('MeasureContent') | 391 MeasureContent: Symbol('MeasureContent') |
| 384 }; | 392 }; |
| 385 | 393 |
| 386 /** | 394 /** @enum {symbol} */ |
| 387 * @enum {symbol} | |
| 388 */ | |
| 389 UI.GlassPane.MarginBehavior = { | 395 UI.GlassPane.MarginBehavior = { |
| 390 Arrow: Symbol('Arrow'), | 396 Arrow: Symbol('Arrow'), |
| 391 DefaultMargin: Symbol('DefaultMargin'), | 397 DefaultMargin: Symbol('DefaultMargin'), |
| 392 NoMargin: Symbol('NoMargin') | 398 NoMargin: Symbol('NoMargin') |
| 393 }; | 399 }; |
| 394 | 400 |
| 395 /** @type {!Map<!Document, !Element>} */ | 401 /** @type {!Map<!Document, !Element>} */ |
| 396 UI.GlassPane._containers = new Map(); | 402 UI.GlassPane._containers = new Map(); |
| 397 /** @type {!Set<!UI.GlassPane>} */ | 403 /** @type {!Set<!UI.GlassPane>} */ |
| 398 UI.GlassPane._panes = new Set(); | 404 UI.GlassPane._panes = new Set(); |
| OLD | NEW |