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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 new WebInspector.Tooltip(doc); | 125 new WebInspector.Tooltip(doc); |
126 } | 126 } |
127 | 127 |
128 /** | 128 /** |
129 * @param {!Element} element | 129 * @param {!Element} element |
130 * @param {!Element|string} tooltipContent | 130 * @param {!Element|string} tooltipContent |
131 * @param {string=} actionId | 131 * @param {string=} actionId |
132 */ | 132 */ |
133 WebInspector.Tooltip.install = function(element, tooltipContent, actionId) | 133 WebInspector.Tooltip.install = function(element, tooltipContent, actionId) |
134 { | 134 { |
135 if (typeof tooltipContent === "string" && tooltipContent === "") | 135 if (typeof tooltipContent === "string" && tooltipContent === "") { |
| 136 delete element[WebInspector.Tooltip._symbol]; |
136 return; | 137 return; |
| 138 } |
137 element[WebInspector.Tooltip._symbol] = { content: tooltipContent, actionId
: actionId }; | 139 element[WebInspector.Tooltip._symbol] = { content: tooltipContent, actionId
: actionId }; |
138 } | 140 } |
| 141 |
| 142 Object.defineProperty(HTMLElement.prototype, "title", { |
| 143 /** |
| 144 * @return {!Element|string} |
| 145 * @this {!Element} |
| 146 */ |
| 147 get: function() |
| 148 { |
| 149 var tooltip = this[WebInspector.Tooltip._symbol]; |
| 150 return tooltip ? tooltip.content : ""; |
| 151 }, |
| 152 |
| 153 /** |
| 154 * @param {!Element|string} x |
| 155 * @this {!Element} |
| 156 */ |
| 157 set: function(x) |
| 158 { |
| 159 WebInspector.Tooltip.install(this, x); |
| 160 } |
| 161 }); |
OLD | NEW |