diff --git a/extensions/inspector/base/src/inFlasher.cpp b/extensions/inspector/base/src/inFlasher.cpp index 516beb808dc..a58036d7f60 100644 --- a/extensions/inspector/base/src/inFlasher.cpp +++ b/extensions/inspector/base/src/inFlasher.cpp @@ -111,20 +111,11 @@ inFlasher::DrawElementOutline(nsIDOMElement* aElement, const PRUnichar* aColor, presShell->CreateRenderingContext(frame, getter_AddRefs(rcontext)); // get view bounds in case this frame is being scrolled - nsIFrame* parentFrame = nsnull; - frame->GetParentWithView(presContext, &parentFrame); - if (!parentFrame) - return NS_OK; - nsIView* parentView = nsnull; - parentFrame->GetView(presContext, &parentView); - nsRect bounds; - parentView->GetBounds(bounds); - nsRect rect; frame->GetRect(rect); - nsPoint origin = inLayoutUtils::GetClientOrigin(frame); - rect.x = origin.x + bounds.x; - rect.y = origin.y + bounds.y; + nsPoint origin = inLayoutUtils::GetClientOrigin(presContext, frame); + rect.x = origin.x; + rect.y = origin.y; mCSSUtils->AdjustRectForMargins(frame, rect); nsAutoString colorStr; diff --git a/extensions/inspector/base/src/inLayoutUtils.cpp b/extensions/inspector/base/src/inLayoutUtils.cpp index b3de7a49420..1788607345f 100644 --- a/extensions/inspector/base/src/inLayoutUtils.cpp +++ b/extensions/inspector/base/src/inLayoutUtils.cpp @@ -143,16 +143,18 @@ inLayoutUtils::GetEventStateManagerFor(nsIDOMElement *aElement) } nsPoint -inLayoutUtils::GetClientOrigin(nsIFrame* aFrame) +inLayoutUtils::GetClientOrigin(nsIPresContext* aPresContext, + nsIFrame* aFrame) { nsPoint result(0,0); - nsIFrame* parent = aFrame; - while (parent) { - nsPoint origin; - parent->GetOrigin(origin); - result.x += origin.x; - result.y += origin.y; - parent->GetParent(&parent); + nsIView* view; + aFrame->GetOffsetFromView(aPresContext, result, &view); + while (view) { + nscoord x, y; + view->GetPosition(&x, &y); + result.x += x; + result.y += y; + view->GetParent(view); } return result; } @@ -313,7 +315,7 @@ inLayoutUtils::IsDocumentElement(nsIDOMNode* aNode) if (parent) { PRUint16 nodeType; parent->GetNodeType(&nodeType); - if (nodeType == 9) + if (nodeType == nsIDOMNode::DOCUMENT_NODE) result = PR_TRUE; } diff --git a/extensions/inspector/base/src/inLayoutUtils.h b/extensions/inspector/base/src/inLayoutUtils.h index 49762ba95f0..581710a9a51 100644 --- a/extensions/inspector/base/src/inLayoutUtils.h +++ b/extensions/inspector/base/src/inLayoutUtils.h @@ -62,7 +62,16 @@ public: static nsIDOMDocument* GetSubDocumentFor(nsIDOMNode* aNode); static nsIDOMNode* GetContainerFor(nsIDOMDocument* aDoc); static PRBool IsDocumentElement(nsIDOMNode* aNode); - static nsPoint GetClientOrigin(nsIFrame* aFrame); + /** + * This function returns the offset of a frame with respect to the + * root view (for use by inFlasher::DrawElementOutline and the like + * + * @param aFrame the frame whose offset we want + * @param aPresContext the presentation context + * @return the offset + */ + static nsPoint GetClientOrigin(nsIPresContext* aPresContext, + nsIFrame* aFrame); static nsRect& GetScreenOrigin(nsIDOMElement* aElement); };