| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @param {!Document} doc | 7 * @param {!Document} doc |
| 8 */ | 8 */ |
| 9 WebInspector.Tooltip = function(doc) | 9 WebInspector.Tooltip = function(doc) |
| 10 { | 10 { |
| 11 this.element = doc.body.createChild("div"); | 11 this.element = doc.body.createChild("div"); |
| 12 this._shadowRoot = WebInspector.createShadowRootWithCoreStyles(this.element,
"ui/tooltip.css"); | 12 this._shadowRoot = WebInspector.createShadowRootWithCoreStyles(this.element,
"ui/tooltip.css"); |
| 13 | 13 |
| 14 this._tooltipElement = this._shadowRoot.createChild("div", "tooltip"); | 14 this._tooltipElement = this._shadowRoot.createChild("div", "tooltip"); |
| 15 doc.addEventListener("mousemove", this._mouseMove.bind(this), true); | 15 doc.addEventListener("mousemove", this._mouseMove.bind(this), true); |
| 16 doc.addEventListener("mousedown", this._hide.bind(this, true), true); | 16 doc.addEventListener("mousedown", this._hide.bind(this, true), true); |
| 17 doc.addEventListener("mouseleave", this._hide.bind(this, true), true); | 17 doc.addEventListener("mouseleave", this._hide.bind(this, true), true); |
| 18 doc.addEventListener("keydown", this._hide.bind(this, true), true); | 18 doc.addEventListener("keydown", this._hide.bind(this, true), true); |
| 19 WebInspector.zoomManager.addEventListener(WebInspector.ZoomManager.Events.Zo
omChanged, this._zoomChanged, this); | 19 WebInspector.zoomManager.addEventListener(WebInspector.ZoomManager.Events.Zo
omChanged, this._reset, this); |
| 20 doc.defaultView.addEventListener("resize", this._reset.bind(this), false); |
| 20 } | 21 } |
| 21 | 22 |
| 22 WebInspector.Tooltip.Timing = { | 23 WebInspector.Tooltip.Timing = { |
| 23 // Max time between tooltips showing that no opening delay is required. | 24 // Max time between tooltips showing that no opening delay is required. |
| 24 "InstantThreshold": 300, | 25 "InstantThreshold": 300, |
| 25 // Wait time before opening a tooltip. | 26 // Wait time before opening a tooltip. |
| 26 "OpeningDelay": 600 | 27 "OpeningDelay": 600 |
| 27 } | 28 } |
| 28 | 29 |
| 29 WebInspector.Tooltip.prototype = { | 30 WebInspector.Tooltip.prototype = { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 _hide: function(removeInstant) | 130 _hide: function(removeInstant) |
| 130 { | 131 { |
| 131 delete this._anchorElement; | 132 delete this._anchorElement; |
| 132 this._tooltipElement.classList.remove("shown"); | 133 this._tooltipElement.classList.remove("shown"); |
| 133 if (Date.now() > this._tooltipLastOpened) | 134 if (Date.now() > this._tooltipLastOpened) |
| 134 this._tooltipLastClosed = Date.now(); | 135 this._tooltipLastClosed = Date.now(); |
| 135 if (removeInstant) | 136 if (removeInstant) |
| 136 delete this._tooltipLastClosed; | 137 delete this._tooltipLastClosed; |
| 137 }, | 138 }, |
| 138 | 139 |
| 139 _zoomChanged: function() | 140 _reset: function() |
| 140 { | 141 { |
| 141 this._hide(true); | 142 this._hide(true); |
| 142 this._tooltipElement.positionAt(0, 0); | 143 this._tooltipElement.positionAt(0, 0); |
| 143 this._tooltipElement.style.maxWidth = "0"; | 144 this._tooltipElement.style.maxWidth = "0"; |
| 144 this._tooltipElement.style.maxHeight = "0"; | 145 this._tooltipElement.style.maxHeight = "0"; |
| 145 } | 146 } |
| 146 } | 147 } |
| 147 | 148 |
| 148 WebInspector.Tooltip._symbol = Symbol("Tooltip"); | 149 WebInspector.Tooltip._symbol = Symbol("Tooltip"); |
| 149 | 150 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 | 196 |
| 196 /** | 197 /** |
| 197 * @param {!Element|string} x | 198 * @param {!Element|string} x |
| 198 * @this {!Element} | 199 * @this {!Element} |
| 199 */ | 200 */ |
| 200 set: function(x) | 201 set: function(x) |
| 201 { | 202 { |
| 202 WebInspector.Tooltip.install(this, x); | 203 WebInspector.Tooltip.install(this, x); |
| 203 } | 204 } |
| 204 }); | 205 }); |
| OLD | NEW |