Imagemap doesn't work properly if attribute 'coords' from <area> starts with comma. ie: coords=",10,10..."




DOM: Core & HTML
12 years ago
5 years ago


(Reporter: Gustavo, Unassigned)




Firefox Tracking Flags

(Not tracked)




(5 attachments, 1 obsolete attachment)



12 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; pt-BR; rv:1.7.12) Gecko/20050919 Firefox/1.0.7
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; pt-BR; rv:1.7.12) Gecko/20050919 Firefox/1.0.7

If the 'coords' attribute of an area tag starts with a leading comma then firefox/mozilla/netscape fails to layout it properly.  Ex:
   <MAP name="map01">
     <AREA shape="poly" coords=",50,50,50,150,150,150,50,50" />
Sometimes the shape is deformed, sometimes it doesn't show at all. 

Reproducible: Always

Steps to Reproduce:
1. Go to the example URL

Actual Results:  
If you move your mouse over the pictures whose imagemaps have a leading comma in the 'coords' attribute you'll notice that the shapes are deformed or don't appear at all.

Expected Results:  
The leading comma should be ignored.

Works fine on Opera, Konqueror, Icesoft java browser and InternetExplorer.

Comment 1

12 years ago
Created attachment 207508 [details]
Web page showing bug

Comment 2

12 years ago
Created attachment 207509 [details]
Image for imagemap

Comment 3

12 years ago
Created attachment 207510 [details]
Image for imagemap

Comment 4

12 years ago
This looks great for me in 1.5. Gustavo, could you download 1.5 and see if this is fixed for yourself as well?
Version: Trunk → 1.8 Branch

Comment 5

12 years ago
It didn't work for me. Adam, are you sure you checked the whole area of the two bottom pictures?

Here's the version I've tried:Mozilla/5.0 (Windows; U; Windows NT 5.0; pt-BR; rv:1.8) Gecko/20051111 Firefox/1.5

Comment 6

12 years ago
Gustavo, I think I see the problem, but could you make a new testcase and use the URLs of the images; e.g. so the images will show up correctly?
Keywords: testcase

Comment 7

12 years ago
Created attachment 208189 [details] [diff] [review]
Test Case
Attachment #207508 - Attachment is obsolete: true

Comment 8

12 years ago
Created attachment 208191 [details]
Web page showing bug


12 years ago

Comment 9

12 years ago
I think this is actually a parser bug...
Assignee: jdunn → mrbkap
Component: Layout: Images → HTML: Parser
QA Contact: layout.images → parser
Actually parsing the attribute value is a content/html sort of thing.
Component: HTML: Parser → DOM: HTML
it'd be pretty easy to just skip initial commas, but if we're going to emulate IE we might as well check more thoroughly what they do. What other junk characters can you stick at the beginning of the string without making IE change what it parses into?

Comment 12

11 years ago
(In reply to comment #11)
> What other junk
> characters can you stick at the beginning of the string without making IE
> change what it parses into?

I'll attach a test page next, but here is a short summary of my findings to answer your question. Given the input |coords="C1,2,3,4"|, Internet Explorer 6's result is
 - 1,2,3,4 if C is element of { Space + , ; No-break-space } or one of the Unicode space characters, range 0x2000-0x200b
 - -1,2,3,4 if C is -
 - 0,2,3,4 in all other cases

Other cases are more complicated and depend on the value of 'shape'. F.e.:

coords="1,2" shape="rect" -> coords="1,2,0,0"
coords="1,2" shape="poly" -> coords=""
coords="1,2" shape="circle" -> coords="1,2,0"
coords"1;5,2,3,4" shape="rect" -> coords="1,3,2,5"
coords"1;5,2,3,4" shape="poly" -> coords="1,5,2,3,4,0"
coords="1Q5,2,3,4,6" shape="poly" -> coords="0,2,3,4,6,0"

Basically, most of the times IE tries to extract the required number of values (4 for rect, 3 for circle, even for poly) from coords and fills missing numbers with 0.

Comment 13

11 years ago
Created attachment 213567 [details]
<area coords> test page


9 years ago
Component: DOM: HTML → DOM: Core & HTML
QA Contact: parser → general


8 years ago
Assignee: mrbkap → nobody
Hixie claims space, comma and semicolon.
Ever confirmed: true
Hardware: x86 → All
Version: 1.8 Branch → Trunk
What file needs to be modified to include the cases in comment #12 or as per URL ?
You need to log in before you can comment on or make changes to this bug.