| 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 { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 var anchorBox = this._anchorElement.boxInWindow(this.element.window()); | 94 var anchorBox = this._anchorElement.boxInWindow(this.element.window()); |
| 95 const anchorOffset = 2; | 95 const anchorOffset = 2; |
| 96 const pageMargin = 2; | 96 const pageMargin = 2; |
| 97 this._tooltipElement.style.maxWidth = (containerOffsetWidth - pageMargin
* 2) + "px"; | 97 this._tooltipElement.style.maxWidth = (containerOffsetWidth - pageMargin
* 2) + "px"; |
| 98 var tooltipWidth = this._tooltipElement.offsetWidth; | 98 var tooltipWidth = this._tooltipElement.offsetWidth; |
| 99 var tooltipHeight = this._tooltipElement.offsetHeight; | 99 var tooltipHeight = this._tooltipElement.offsetHeight; |
| 100 var tooltipX = anchorBox.x; | 100 var tooltipX = anchorBox.x; |
| 101 tooltipX = Number.constrain(tooltipX, | 101 tooltipX = Number.constrain(tooltipX, |
| 102 containerOffset.x + pageMargin, | 102 containerOffset.x + pageMargin, |
| 103 containerOffset.x + containerOffsetWidth - tooltipWidth - pageMargin
); | 103 containerOffset.x + containerOffsetWidth - tooltipWidth - pageMargin
); |
| 104 var onBottom = anchorBox.y + anchorOffset + anchorBox.height < container
Offset.y + containerOffsetHeight; | 104 var onBottom = anchorBox.y + anchorOffset + anchorBox.height + tooltipHe
ight < containerOffset.y + containerOffsetHeight; |
| 105 var tooltipY = onBottom ? anchorBox.y + anchorBox.height + anchorOffset
: anchorBox.y - tooltipHeight - anchorOffset; | 105 var tooltipY = onBottom ? anchorBox.y + anchorBox.height + anchorOffset
: anchorBox.y - tooltipHeight - anchorOffset; |
| 106 this._tooltipElement.positionAt(tooltipX, tooltipY); | 106 this._tooltipElement.positionAt(tooltipX, tooltipY); |
| 107 }, | 107 }, |
| 108 | 108 |
| 109 _hide: function() | 109 _hide: function() |
| 110 { | 110 { |
| 111 delete this._anchorElement; | 111 delete this._anchorElement; |
| 112 this._tooltipElement.classList.remove("shown"); | 112 this._tooltipElement.classList.remove("shown"); |
| 113 if (Date.now() > this._tooltipLastOpened) | 113 if (Date.now() > this._tooltipLastOpened) |
| 114 this._tooltipLastClosed = Date.now(); | 114 this._tooltipLastClosed = Date.now(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 152 |
| 153 /** | 153 /** |
| 154 * @param {!Element|string} x | 154 * @param {!Element|string} x |
| 155 * @this {!Element} | 155 * @this {!Element} |
| 156 */ | 156 */ |
| 157 set: function(x) | 157 set: function(x) |
| 158 { | 158 { |
| 159 WebInspector.Tooltip.install(this, x); | 159 WebInspector.Tooltip.install(this, x); |
| 160 } | 160 } |
| 161 }); | 161 }); |
| OLD | NEW |