Bug 392761. getClientRects/getBoundingClientRect *do* take scrolling into account, including viewport scrolling. r+sr=dbaron

This commit is contained in:
roc+@cs.cmu.edu 2007-09-21 02:15:42 -07:00
parent f3071cd153
commit 3febe0fecf

View File

@ -83,6 +83,7 @@
#ifdef MOZ_XUL
#include "nsXULElement.h"
#endif /* MOZ_XUL */
#include "nsFrameManager.h"
#include "nsBindingManager.h"
#include "nsXBLBinding.h"
@ -694,19 +695,14 @@ nsNSElementTearoff::GetElementsByClassName(const nsAString& aClasses,
static nsPoint
GetOffsetFromInitialContainingBlock(nsIFrame* aFrame)
{
nsPresContext* presContext = aFrame->PresContext();
nsIPresShell* shell = presContext->PresShell();
nsIFrame* rootScrollFrame = shell->GetRootScrollFrame();
nsIFrame* rootFrame = aFrame->PresContext()->FrameManager()->GetRootFrame();
nsPoint pt(0,0);
nsIFrame* child = aFrame;
for (nsIFrame* p = aFrame->GetParent(); p && p != rootScrollFrame;
p = p->GetParent()) {
pt += p->GetPositionOfChildIgnoringScrolling(child);
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))
if (p->IsFrameOfType(nsIFrame::eSVGForeignObject) && p != aFrame)
return pt;
child = p;
pt += p->GetPosition();
}
return pt;
}