Bug 393451, getBoundingClientRect coordinates not correct for popups, r+sr=roc,a=schrep

This commit is contained in:
2008-01-10 07:48:26 -08:00
parent c41972436d
commit 313d294bc1
3 changed files with 146 additions and 10 deletions

View File

@@ -719,16 +719,16 @@ nsNSElementTearoff::GetElementsByClassName(const nsAString& aClasses,
static nsPoint
GetOffsetFromInitialContainingBlock(nsIFrame* aFrame)
{
nsIFrame* rootFrame = aFrame->PresContext()->FrameManager()->GetRootFrame();
nsPoint pt(0,0);
for (nsIFrame* p = aFrame; p != rootFrame; p = p->GetParent()) {
// coordinates of elements inside a foreignobject are relative to the top-left
// of the nearest foreignobject
if (p->IsFrameOfType(nsIFrame::eSVGForeignObject) && p != aFrame)
return pt;
pt += p->GetPosition();
}
return pt;
nsIFrame* refFrame = aFrame->GetParent();
if (!refFrame)
return nsPoint(0, 0);
// get the nearest enclosing SVG foreign object frame or the root frame
while (refFrame->GetParent() &&
!refFrame->IsFrameOfType(nsIFrame::eSVGForeignObject))
refFrame = refFrame->GetParent();
return aFrame->GetOffsetTo(refFrame);
}
static double