Open Bug 1227469 Opened 9 years ago Updated 27 days ago

elementFromPoint returns the <img> instead of <area> in image map

Categories

(Core :: DOM: CSS Object Model, defect, P5)

defect

Tracking

()

People

(Reporter: automatedtester, Unassigned)

References

(Blocks 2 open bugs, )

Details

(Keywords: parity-chrome, parity-edge, parity-ie)

When using elementFromPoint on an image map [failing test in url field] we are returning the <img> instead of the area. 

From reading https://html.spec.whatwg.org/multipage/embedded-content.html#processing-model it should return the <area> because that is element is the one being targetted in hit testing.

IE doesnt return either img or area and webkit/blink does return the area
The basic issue is that nsDocument::ElementFromPointHelper does:

  nsIFrame *ptFrame = nsLayoutUtils::GetFrameForPoint(stuff);
  nsIContent* elem = GetContentInThisDocument(ptFrame);

whereas actual mouse event delivery ends up using nsIFrame::GetContentForEvent once it has located a frame, which nsImageFrame overrides to return the <area>.

Note that in both cases the _box_ (nsIFrame) being targeted by hit testing is the one for the <img>.
FYI this bug prevents automated testing of coords parsing; see https://github.com/whatwg/html/pull/514
Blocks: 1240011
(In reply to David Burns :automatedtester from comment #0)
> IE doesnt return either img or area and webkit/blink does return the area

I'm not sure about other versions of IE, but elementFromPoint() works as expected for me in IE 10 (i.e., it has the same behavior as Chrome and Safari). To test this, I went to a sample image map test page (http://thdoan.github.io/magnify/demo-map.html) and simulated clicking on the Yahoo! rectangle of the image map by executing this in the console:

document.elementFromPoint(916, 363).click()
Whiteboard: [parity-chrome][parity-edge][parity-IE]
Mass bug change to replace various 'parity' whiteboard flags with the new canonical keywords. (See bug 1443764 comment 13.)
Whiteboard: [parity-chrome][parity-edge][parity-IE]
Priority: -- → P5
Severity: normal → S3

This should be the reason for our final test failure at https://wpt.fyi/results/css/cssom-view/elementFromPoint.html

Blocks: 1887054
You need to log in before you can comment on or make changes to this bug.