From 98451866053c7af48396dcd3845b201bbff2c1ca Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Fri, 21 Sep 2007 09:15:42 +0000 Subject: [PATCH] Bug 392761. getClientRects/getBoundingClientRect *do* take scrolling into account, including viewport scrolling. r+sr=dbaron git-svn-id: svn://10.0.0.236/trunk@236432 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/src/nsGenericElement.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/mozilla/content/base/src/nsGenericElement.cpp b/mozilla/content/base/src/nsGenericElement.cpp index 0082689e8cc..bc8d699d7a1 100644 --- a/mozilla/content/base/src/nsGenericElement.cpp +++ b/mozilla/content/base/src/nsGenericElement.cpp @@ -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; }