From 36d34c6c70837e374aa5fb5e76f5b01d3016d59a Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Mon, 17 Jun 2002 23:45:21 +0000 Subject: [PATCH] NS4 measures image.x/image.y from the enclosing layer, not from the body. Bug 130415, r=jkeiser, sr=jst --- .../html/content/src/nsHTMLImageElement.cpp | 51 ++----------------- 1 file changed, 4 insertions(+), 47 deletions(-) diff --git a/content/html/content/src/nsHTMLImageElement.cpp b/content/html/content/src/nsHTMLImageElement.cpp index 933ce0b1552..4aea8d1c1a5 100644 --- a/content/html/content/src/nsHTMLImageElement.cpp +++ b/content/html/content/src/nsHTMLImageElement.cpp @@ -79,6 +79,7 @@ #include "nsRuleNode.h" #include "nsIJSContextStack.h" +#include "nsIView.h" static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID); @@ -358,54 +359,10 @@ nsHTMLImageElement::GetXY(PRInt32* aX, PRInt32* aY) return NS_OK; } - nsCOMPtr docElement; - mDocument->GetRootContent(getter_AddRefs(docElement)); - nsPoint origin(0, 0); - - while (frame) { - // Add the parent's origin to our own to get to the right - // coordinate system - - nsPoint frameOrigin; - frame->GetOrigin(frameOrigin); - origin += frameOrigin; - - nsCOMPtr content; - frame->GetContent(getter_AddRefs(content)); - - if (content) { - // If we've hit the document element, break here - if (content == docElement) { - break; - } - - nsCOMPtr tag; - content->GetTag(*getter_AddRefs(tag)); - - if (tag == nsHTMLAtoms::body) { - break; - } - } - - frame->GetParent(&frame); - } - - if (frame) { - // For the origin subtract out the border for the parent - const nsStyleBorder* border = nsnull; - nsStyleCoord coord; - - frame->GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)border); - if (border) { - if (eStyleUnit_Coord == border->mBorder.GetLeftUnit()) { - origin.x -= border->mBorder.GetLeft(coord).GetCoordValue(); - } - if (eStyleUnit_Coord == border->mBorder.GetTopUnit()) { - origin.y -= border->mBorder.GetTop(coord).GetCoordValue(); - } - } - } + nsCOMPtr parentView; + nsresult rv = frame->GetOffsetFromView(context, origin, getter_AddRefs(parentView)); + NS_ENSURE_SUCCESS(rv, rv); // Get the scale from that Presentation Context float scale;