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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 container = this.element.parentElement; | 99 container = this.element.parentElement; |
100 | 100 |
101 // Posititon tooltip based on the anchor element. | 101 // Posititon tooltip based on the anchor element. |
102 var containerOffset = container.offsetRelativeToWindow(this.element.wind
ow()); | 102 var containerOffset = container.offsetRelativeToWindow(this.element.wind
ow()); |
103 var containerOffsetWidth = container.offsetWidth; | 103 var containerOffsetWidth = container.offsetWidth; |
104 var containerOffsetHeight = container.offsetHeight; | 104 var containerOffsetHeight = container.offsetHeight; |
105 var anchorBox = this._anchorElement.boxInWindow(this.element.window()); | 105 var anchorBox = this._anchorElement.boxInWindow(this.element.window()); |
106 const anchorOffset = 2; | 106 const anchorOffset = 2; |
107 const pageMargin = 2; | 107 const pageMargin = 2; |
108 var cursorOffset = 10; | 108 var cursorOffset = 10; |
| 109 this._tooltipElement.classList.toggle("tooltip-breakword", !this._toolti
pElement.textContent.match("\\s")); |
109 this._tooltipElement.style.maxWidth = (containerOffsetWidth - pageMargin
* 2) + "px"; | 110 this._tooltipElement.style.maxWidth = (containerOffsetWidth - pageMargin
* 2) + "px"; |
110 this._tooltipElement.style.maxHeight = ""; | 111 this._tooltipElement.style.maxHeight = ""; |
111 var tooltipWidth = this._tooltipElement.offsetWidth; | 112 var tooltipWidth = this._tooltipElement.offsetWidth; |
112 var tooltipHeight = this._tooltipElement.offsetHeight; | 113 var tooltipHeight = this._tooltipElement.offsetHeight; |
113 var anchorTooltipAtElement = this._anchorElement.nodeName === "BUTTON" |
| this._anchorElement.nodeName === "LABEL"; | 114 var anchorTooltipAtElement = this._anchorElement.nodeName === "BUTTON" |
| this._anchorElement.nodeName === "LABEL"; |
114 var tooltipX = anchorTooltipAtElement ? anchorBox.x : event.x + cursorOf
fset; | 115 var tooltipX = anchorTooltipAtElement ? anchorBox.x : event.x + cursorOf
fset; |
115 tooltipX = Number.constrain(tooltipX, | 116 tooltipX = Number.constrain(tooltipX, |
116 containerOffset.x + pageMargin, | 117 containerOffset.x + pageMargin, |
117 containerOffset.x + containerOffsetWidth - tooltipWidth - pageMargin
); | 118 containerOffset.x + containerOffsetWidth - tooltipWidth - pageMargin
); |
118 var tooltipY; | 119 var tooltipY; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 | 198 |
198 /** | 199 /** |
199 * @param {!Element|string} x | 200 * @param {!Element|string} x |
200 * @this {!Element} | 201 * @this {!Element} |
201 */ | 202 */ |
202 set: function(x) | 203 set: function(x) |
203 { | 204 { |
204 WebInspector.Tooltip.install(this, x); | 205 WebInspector.Tooltip.install(this, x); |
205 } | 206 } |
206 }); | 207 }); |
OLD | NEW |