Closed Bug 116843 Opened 24 years ago Closed 24 years ago

image.x and image.y incorrect when image in a table (since 0.9.7)

Categories

(Core :: DOM: Core & HTML, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla0.9.8

People

(Reporter: julienw, Assigned: jst)

References

()

Details

(Keywords: regression, Whiteboard: [HAVE FIX])

Attachments

(2 files)

From Bugzilla Helper: User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.7) Gecko/20011221 BuildID: 2001122106 image.x and image.y are mapped respectively to offsetLeft and offsetTop. This is incorrect when the image is in a table (but only since Mozilla 0.9.7) Reproducible: Always Steps to Reproduce: 1. Go on http://www2.minet.net/portail.old/ 2. Click on 'Assoces' Actual Results: A menu opens, but too much in the left. Expected Results: The menu should appear just under the item. testcase of Bug 98292, modified to put the image in a table: <HTML> <HEAD><TITLE></TITLE></HEAD> <BODY> <table width='50%'><tr><td align="center"><img src="something.jpg" height="200" width="200"></img></td></tr></table> <form name="workform"> <input type="button" value="show me image.x & image.y" onclick="alert('image.x=' + document.images[0].x + ' & image.y=' + document.images[0].y);"> </form> </BODY> </HTML>
Attached file testcase
testcase taken from Bug 98292, with a small change
Status: UNCONFIRMED → NEW
Ever confirmed: true
Attached patch Proposed fix.Splinter Review
The attached patch should revert image.x/y back to what they were before the .offset* changes were made. The patch also cleans some code up and reduces the size of some of the code.
Status: NEW → ASSIGNED
Keywords: regression
OS: Windows 2000 → All
Priority: -- → P2
Hardware: PC → All
Whiteboard: [HAVE FIX]
Target Milestone: --- → mozilla0.9.8
Comment on attachment 62735 [details] [diff] [review] Proposed fix. Maybe use GetImageFrame in GetXY. Otherwise sr=vidur.
Attachment #62735 - Flags: superreview+
Comment on attachment 62735 [details] [diff] [review] Proposed fix. >Index: content/html/content/src/nsHTMLImageElement.cpp >=================================================================== >RCS file: /cvsroot/mozilla/content/html/content/src/nsHTMLImageElement.cpp,v >retrieving revision 1.101 >diff -u -r1.101 nsHTMLImageElement.cpp >--- content/html/content/src/nsHTMLImageElement.cpp 24 Oct 2001 00:00:01 -0000 1.101 >+++ content/html/content/src/nsHTMLImageElement.cpp 25 Dec 2001 17:21:24 -0000 >@@ -656,17 +733,16 @@ >+ nsCOMPtr<nsIDOMWindowInternal> domWindow(do_QueryInterface(globalObject)); >+ >+ if (domWindow) { >+ nsCOMPtr<nsIDOMDocument> domDocument; >+ result = domWindow->GetDocument(getter_AddRefs(domDocument)); >+ if (NS_SUCCEEDED(result)) { >+ // Maintain the reference >+ result = domDocument->QueryInterface(NS_GET_IID(nsIDocument), >+ (void**)&mOwnerDocument); > } > } > One more place you could use CallQueryInterface. Nice work! r=jag
Attachment #62735 - Flags: review+
Fixed, thanks for the reviews.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: