| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 var tooltip = anchorElement[WebInspector.Tooltip._symbol]; | 59 var tooltip = anchorElement[WebInspector.Tooltip._symbol]; |
| 60 this._anchorElement = anchorElement; | 60 this._anchorElement = anchorElement; |
| 61 this._tooltipElement.removeChildren(); | 61 this._tooltipElement.removeChildren(); |
| 62 if (typeof tooltip.content === "string") | 62 if (typeof tooltip.content === "string") |
| 63 this._tooltipElement.textContent = tooltip.content; | 63 this._tooltipElement.textContent = tooltip.content; |
| 64 else | 64 else |
| 65 this._tooltipElement.appendChild(tooltip.content); | 65 this._tooltipElement.appendChild(tooltip.content); |
| 66 | 66 |
| 67 if (tooltip.actionId) { | 67 if (tooltip.actionId) { |
| 68 var shortcuts = WebInspector.shortcutRegistry.shortcutDescriptorsFor
Action(tooltip.actionId); | 68 var shortcuts = WebInspector.shortcutRegistry.shortcutDescriptorsFor
Action(tooltip.actionId); |
| 69 if (shortcuts && shortcuts.length) { | 69 for (var shortcut of shortcuts) { |
| 70 var shortcutElement = this._tooltipElement.createChild("div", "t
ooltip-shortcut"); | 70 var shortcutElement = this._tooltipElement.createChild("div", "t
ooltip-shortcut"); |
| 71 shortcutElement.textContent = shortcuts[0].name; | 71 shortcutElement.textContent = shortcut.name; |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 | 74 |
| 75 this._tooltipElement.classList.add("shown"); | 75 this._tooltipElement.classList.add("shown"); |
| 76 // Reposition to ensure text doesn't overflow unnecessarily. | 76 // Reposition to ensure text doesn't overflow unnecessarily. |
| 77 this._tooltipElement.positionAt(0, 0); | 77 this._tooltipElement.positionAt(0, 0); |
| 78 | 78 |
| 79 // Show tooltip instantly if a tooltip was shown recently. | 79 // Show tooltip instantly if a tooltip was shown recently. |
| 80 var now = Date.now(); | 80 var now = Date.now(); |
| 81 var instant = (this._tooltipLastClosed && now - this._tooltipLastClosed
< WebInspector.Tooltip.Timing.InstantThreshold); | 81 var instant = (this._tooltipLastClosed && now - this._tooltipLastClosed
< WebInspector.Tooltip.Timing.InstantThreshold); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 */ | 138 */ |
| 139 WebInspector.Tooltip.install = function(element, tooltipContent, alignment, acti
onId) | 139 WebInspector.Tooltip.install = function(element, tooltipContent, alignment, acti
onId) |
| 140 { | 140 { |
| 141 if (Runtime.experiments.isEnabled("tooltips")) | 141 if (Runtime.experiments.isEnabled("tooltips")) |
| 142 element[WebInspector.Tooltip._symbol] = { content: tooltipContent, alig
nment: alignment, actionId: actionId }; | 142 element[WebInspector.Tooltip._symbol] = { content: tooltipContent, alig
nment: alignment, actionId: actionId }; |
| 143 else if (typeof tooltipContent === "string") | 143 else if (typeof tooltipContent === "string") |
| 144 element.title = tooltipContent; | 144 element.title = tooltipContent; |
| 145 else | 145 else |
| 146 console.assert("Cannot set an element without custom tooltips enabled"); | 146 console.assert("Cannot set an element without custom tooltips enabled"); |
| 147 } | 147 } |
| OLD | NEW |