MCPcopy Index your code
hub / github.com/SeleniumHQ/selenium / maybeFindImageMap

Function maybeFindImageMap

javascript/atoms/typescript/is-displayed.ts:212–238  ·  view source on GitHub ↗
(elem: Element)

Source from the content-addressed store, hash-verified

210 }
211
212 function maybeFindImageMap(elem: Element): ImageMapResult | null {
213 var isMap = isElement(elem, 'MAP');
214 if (!isMap && !isElement(elem, 'AREA')) {
215 return null;
216 }
217
218 var map = isMap ? elem : isElement(elem.parentNode, 'MAP') ? elem.parentNode : null;
219 var image: Element | null = null;
220 var rect = createRect(0, 0, 0, 0);
221
222 if (isElement(map, 'MAP') && (map as HTMLMapElement).name) {
223 image = findImageUsingMap((map as HTMLMapElement).name, (map as HTMLMapElement).ownerDocument);
224 if (image) {
225 rect = getClientRect(image);
226 if (!isMap && isElement(elem, 'AREA') && (elem as HTMLAreaElement).shape.toLowerCase() !== 'default') {
227 var relativeRect = getAreaRelativeRect(elem as HTMLAreaElement);
228 var relativeX = Math.min(Math.max(relativeRect.left, 0), rect.width);
229 var relativeY = Math.min(Math.max(relativeRect.top, 0), rect.height);
230 var width = Math.min(relativeRect.width, rect.width - relativeX);
231 var height = Math.min(relativeRect.height, rect.height - relativeY);
232 rect = createRect(relativeX + rect.left, relativeY + rect.top, width, height);
233 }
234 }
235 }
236
237 return { image: image, rect: rect };
238 }
239
240 function getClientRegion(elem: Element): Rect {
241 return getClientRect(elem);

Callers 2

getClientRectFunction · 0.85
isShownInternalFunction · 0.85

Calls 5

createRectFunction · 0.85
findImageUsingMapFunction · 0.85
getAreaRelativeRectFunction · 0.85
isElementFunction · 0.70
getClientRectFunction · 0.70

Tested by

no test coverage detected