(area: HTMLAreaElement)
| 171 | } |
| 172 | |
| 173 | function getAreaRelativeRect(area: HTMLAreaElement): Rect { |
| 174 | var shape = area.shape.toLowerCase(); |
| 175 | var coords = area.coords.split(',').map(function (value) { |
| 176 | return Number(value.trim()); |
| 177 | }); |
| 178 | |
| 179 | if (shape === 'rect' && coords.length === 4) { |
| 180 | return createRect(coords[0], coords[1], coords[2] - coords[0], coords[3] - coords[1]); |
| 181 | } |
| 182 | |
| 183 | if (shape === 'circle' && coords.length === 3) { |
| 184 | return createRect(coords[0] - coords[2], coords[1] - coords[2], coords[2] * 2, coords[2] * 2); |
| 185 | } |
| 186 | |
| 187 | if (shape === 'poly' && coords.length > 2) { |
| 188 | var minX = coords[0]; |
| 189 | var minY = coords[1]; |
| 190 | var maxX = minX; |
| 191 | var maxY = minY; |
| 192 | |
| 193 | for (var index = 2; index + 1 < coords.length; index += 2) { |
| 194 | minX = Math.min(minX, coords[index]); |
| 195 | maxX = Math.max(maxX, coords[index]); |
| 196 | minY = Math.min(minY, coords[index + 1]); |
| 197 | maxY = Math.max(maxY, coords[index + 1]); |
| 198 | } |
| 199 | |
| 200 | return createRect(minX, minY, maxX - minX, maxY - minY); |
| 201 | } |
| 202 | |
| 203 | return createRect(0, 0, 0, 0); |
| 204 | } |
| 205 | |
| 206 | function findImageUsingMap(mapName: string, doc: Document): Element | null { |
| 207 | // Use querySelector instead of a full-DOM scan; escape the map name so |
no test coverage detected