<area shape="circle"> with negative radius in coords is ignored

RESOLVED WONTFIX

Status

()

Core
Layout
--
trivial
RESOLVED WONTFIX
14 years ago
14 years ago

People

(Reporter: Jeremy Wells, Assigned: mats)

Tracking

({compat, testcase})

Trunk
compat, testcase
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(3 attachments, 2 obsolete attachments)

(Reporter)

Description

14 years ago
User-Agent:       
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007 Firebird/0.7

Client side image map on page referenced above will not work properly in 
Firebird, but it does work in Internet Explorer. Only about 1/4 of the links 
work.

Reproducible: Always
Steps to Reproduce:
1. Go to http://www.oldtowncape.org/walking_tour/central.htm
2. Try clicking on number 33, 32, 1, etc.
3. Repeat the same thing using Internet Explorer

Actual Results:  
Image-mapped links don't work.

Expected Results:  
The links should have worked.
Can circle coordinates for HTML image maps have negative radii?  33, 32, and 1
all have -10 as the value of their radii, and based on the conventional wisdom
of polar coordinates, negative radii are invalid.  I didn't test all of them to
see if only <area>s with a negative radius worked, tho.

Also reassigning to Browser product as that does layout, not Firebird.
Component: General → Layout
Product: Firebird → Browser
Version: unspecified → Trunk
> Can circle coordinates for HTML image maps have negative radii?

I don't see how that could be reasonably implemented... what does IE actually do
here?

Comment 3

14 years ago
> what does IE actually do here?

I think IE treats negative CSS lengths as their positive counterpart by simply
dropping minus (probably only where applying negative is not relevant in
context). This misfeature is also seen in other places such as 'font-size: -20px'.
Yeah, I don't think we want to do that.
-->NEW, seems unique to me.

http://lxr.mozilla.org/mozilla/source/layout/html/base/src/nsImageMap.cpp#685
http://lxr.mozilla.org/mozilla/source/layout/html/base/src/nsImageMap.cpp#707

Could inserting the line:

radius=-radius;

in the if() code blocks referenced above instead of return; or return PR_FALSE;
do the trick?  Forgive me if I'm completely off here, but I think I've tracked
the code correctly.  Following LXR seems to suggest that that action is possible
for "nscoord" variables, as they're "PRInt32" which appears to be just a signed
32-bit number.
Severity: major → normal
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows XP → All
Hardware: PC → All
Summary: Client side image map that works in IE won't work properly in Firebird → Client side image map that works in IE won't work properly in Firefox
at least in that first line, I'd do
     nscoord radius = PR_MAX(0, mCoords[2]);
instead...

but do we want to fix this? a negative radius is a pretty stupid thing to do,
I'd say the webmasters should fix their page.
While opening the Javascript Console to check for errors in another site, I ran
across this warning for download.com:

------------------------------------------------------------------------------
Warning: The "coords" attribute of the <area shape="rect"> tag is not in the
"left,top,right,bottom" format.
Source File: http://www.download.com/
Line: 0
Source Code:
265,50,75,20
------------------------------------------------------------------------------

Recognizing the similarity between this bug and the coding mistake shown in the
warning, I realized it might make sense to *not* fix the initial bug but instead
fire off a similar warning to the Javascript Console, e.g.:

------------------------------------------------------------------------------
Warning: The "coords" attribute of the <area shape="circle"> tag has a negative
radius (-10).
Source File: http://www.oldtowncape.org/walking_tour/central.htm
Line: 18
Source Code:
298,38,-10
------------------------------------------------------------------------------

Thoughts?
Summary: Client side image map that works in IE won't work properly in Firefox → <area shape="circle"> with negative radius in coords is ignored
Note that for rect shapes we actaully "do what I mean" in addition to giving the
warning.  See RectArea::ParseCoords.

If we decide to do this sign-flipping thing, it should only be done at parse time.

Note that unlike the case of rects (where it's really easy to screw up the
order), setting a negative radius requires malice, pretty much.  Which is why I
feel we shouldn't go out of our way to make it work.
(Assignee)

Comment 9

14 years ago
Created attachment 153809 [details]
Testcase #1 (circle & poly)
(Assignee)

Updated

14 years ago
Assignee: firefox → mats.palmgren
Severity: normal → trivial
Keywords: compat, testcase
Summary: <area shape="circle"> with negative radius in coords is ignored → [FIX] <area shape="circle"> with negative radius in coords is ignored
(Assignee)

Comment 10

14 years ago
Created attachment 153810 [details] [diff] [review]
Patch A rev. 1
(Assignee)

Comment 11

14 years ago
Created attachment 153811 [details]
Screenshot of JS Console with patch A rev. 1
(Assignee)

Updated

14 years ago
Attachment #153810 - Flags: review?(bzbarsky)
I'm still wondering why we want to flip this sign, exactly...  Again, unlike
rect this one requires _effort_ to screw up.

The rest looks OK at first glance; I'll try to do a thorough review within the
next day or two.
Comment on attachment 153810 [details] [diff] [review]
Patch A rev. 1

r=bzbarsky for the code.  I still don't think we should be correcting the
negative issue (though I'm ok with having an error message about it).
Attachment #153810 - Flags: review?(bzbarsky) → review+
(Assignee)

Comment 14

14 years ago
Created attachment 155448 [details] [diff] [review]
Patch A rev. 2

Ok, I removed the error correction on the radius.
Consequently, I also made it an error rather than a warning.
Attachment #153810 - Attachment is obsolete: true
Attachment #153811 - Attachment is obsolete: true
(Assignee)

Comment 15

14 years ago
Created attachment 155449 [details]
Screenshot of JS Console with patch A rev. 2
(Assignee)

Updated

14 years ago
Attachment #155448 - Flags: superreview?(dbaron)
Attachment #155448 - Flags: review?(bzbarsky)
Comment on attachment 155448 [details] [diff] [review]
Patch A rev. 2

r+sr=bzbarsky

The error messages may look better if instead of using "aSpec" for the source
line one uses:

NS_LITERAL_STRING("coords=\"") + aSpec + NS_LITERAL_STRING("\"")

but either way is fine with me.
Attachment #155448 - Flags: superreview?(dbaron)
Attachment #155448 - Flags: superreview+
Attachment #155448 - Flags: review?(bzbarsky)
Attachment #155448 - Flags: review+
(Assignee)

Comment 17

14 years ago
Yes, it looked much better.  I added that and checked in to trunk at
2004-08-08 07:05 PDT

The original bug report is WONTFIX, but there is an error message about it now...

-> WONTFIX
Status: NEW → RESOLVED
Last Resolved: 14 years ago
Resolution: --- → WONTFIX
Summary: [FIX] <area shape="circle"> with negative radius in coords is ignored → <area shape="circle"> with negative radius in coords is ignored
You need to log in before you can comment on or make changes to this bug.