Bug 54636 - Area element doesn't update region when dynamically altered
Summary: Area element doesn't update region when dynamically altered
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Images (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Andreas Kling
URL:
Keywords: HTML5
Depends on:
Blocks:
 
Reported: 2011-02-17 04:48 PST by bz
Modified: 2011-05-17 12:26 PDT (History)
2 users (show)

See Also:


Attachments
Proposed patch (7.97 KB, patch)
2011-05-17 07:35 PDT, Andreas Kling
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description bz 2011-02-17 04:48:04 PST
If you create an image map with an area, and then you change the coordinates for that area after you have moved the mouse over it, then the area will not update to the new coordinates.

In the following example, there is a single area to the left of the image. If you click on it, the area should move to the right, but it doesn't.

<img ismap usemap="#map1" style="width:200; height:100"/>
<map name="map1">
<area id="area1" shape="rect" coords="0,0,100,100" href="#" title="xx"/ onclick="document.getElementById ('area1').coords = '100,0,200,100'">
</map>

I believe the bug lies in HTMLAreaElement.cpp in the mapMouseEvent() function.
It only recreates the region for the area if the associated image size changes.
If I resize the image as in the code below, then it works.

<img id="image1" ismap usemap="#map1" style="width:200; height:100"/>
<map name="map1">
<area id="area1" shape="rect" coords="0,0,100,100" href="#" title="xx"/ onclick="document.getElementById ('area1').coords = '100,0,200,100'; document.getElementById ('image1').style.width = 201">
</map>

The code needs changing to recalculate the region when the shape type or coordinates of the area have changed since the last call.
i.e. add a recalculate flag that gets set when either of these attributes change.
Comment 1 Xavi 2011-03-09 05:05:42 PST
I've also ran into this problem.  Here's a page that reproduces this bug:

http://xavi.co/static/image-map-test.html

Also here's a link to a chromium bug reporting the same issue: 

http://code.google.com/p/chromium/issues/detail?id=34530
Comment 2 Andreas Kling 2011-05-17 07:35:55 PDT
Created attachment 93764 [details]
Proposed patch
Comment 3 Kenneth Rohde Christiansen 2011-05-17 12:16:08 PDT
Comment on attachment 93764 [details]
Proposed patch

View in context: https://bugs.webkit.org/attachment.cgi?id=93764&action=review

> LayoutTests/fast/images/script-tests/imagemap-dynamic-area-updates.js:7
> +image.setAttribute('usemap', '#m');

So long since I have used this :-)

> LayoutTests/fast/images/script-tests/imagemap-dynamic-area-updates.js:72
> +var successfullyParsed = true;

Who sets this to false in case of failure? Is that handled by the wrapper?
Comment 4 Andreas Kling 2011-05-17 12:22:46 PDT
(In reply to comment #3)
> > LayoutTests/fast/images/script-tests/imagemap-dynamic-area-updates.js:72
> > +var successfullyParsed = true;
> 
> Who sets this to false in case of failure? Is that handled by the wrapper?

Indeed! finishJSTest() in js-test-pre.js checks that successfullyParsed is true.
Comment 5 Andreas Kling 2011-05-17 12:26:20 PDT
Comment on attachment 93764 [details]
Proposed patch

Clearing flags on attachment: 93764

Committed r86695: <http://trac.webkit.org/changeset/86695>
Comment 6 Andreas Kling 2011-05-17 12:26:29 PDT
All reviewed patches have been landed.  Closing bug.