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