From 4c6302760718509a061092ede2c0d9e9151b3fe4 Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Wed, 7 Jun 2006 02:35:57 +0000 Subject: [PATCH] Bug 334765. Testing backout to see if it was responsible for btek's Tp change. --- .../html/content/src/nsGenericHTMLElement.cpp | 20 +++++++-- layout/base/nsLayoutUtils.cpp | 41 ------------------- layout/base/nsLayoutUtils.h | 13 ------ layout/xul/base/src/nsBoxObject.cpp | 12 ++++-- 4 files changed, 24 insertions(+), 62 deletions(-) diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index 4e851c91a618..12dde33ddc5d 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -142,7 +142,6 @@ #include "nsIEditor.h" #include "nsIEditorIMESupport.h" #include "nsEventDispatcher.h" -#include "nsLayoutUtils.h" // XXX todo: add in missing out-of-memory checks @@ -626,7 +625,20 @@ nsGenericHTMLElement::GetOffsetRect(nsRect& aRect, nsIContent** aOffsetParent) } // Get the union of all rectangles in this and continuation frames - nsRect rcFrame = nsLayoutUtils::GetUnionOfAllRects(frame); + nsRect rcFrame; + nsIFrame* next = frame; + + do { + rcFrame.UnionRect(rcFrame, next->GetRect()); + next = next->GetNextContinuation(); + } while (next); + + if (rcFrame.IsEmpty()) { + // It could happen that all the rects are empty (eg zero-width or + // zero-height). In that case, use the first rect for the frame. + rcFrame = frame->GetRect(); + } + nsIContent *docElement = document->GetRootContent(); // Find the frame parent whose content's tagName either matches @@ -650,7 +662,7 @@ nsGenericHTMLElement::GetOffsetRect(nsRect& aRect, nsIContent** aOffsetParent) PRBool is_absolutely_positioned = PR_FALSE; PRBool is_positioned = PR_FALSE; - origin = nsLayoutUtils::GetPositionIgnoringScrolling(frame); + origin = frame->GetPosition(); const nsStyleDisplay* display = frame->GetStyleDisplay(); @@ -686,7 +698,7 @@ nsGenericHTMLElement::GetOffsetRect(nsRect& aRect, nsIContent** aOffsetParent) // right coordinate system if (!is_absolutely_positioned) { - origin += nsLayoutUtils::GetPositionIgnoringScrolling(parent); + origin += parent->GetPosition(); } content = parent->GetContent(); diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index ea692c03ce54..adc0f286c7f6 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -473,47 +473,6 @@ nsLayoutUtils::GetNearestScrollingView(nsIView* aView, Direction aDirection) return scrollableView; } -nsPoint -nsLayoutUtils::GetPositionIgnoringScrolling(nsIFrame* aFrame) -{ - nsIFrame* parent = aFrame->GetParent(); - if (!parent) - return aFrame->GetPosition(); - nsIScrollableFrame* scrollable; - CallQueryInterface(parent, &scrollable); - if (!scrollable) - return aFrame->GetPosition(); - // Compensate for the scroll position ... this might not result in (0,0) - // if there is a scrollbar above or to the left of the content. Note that - // scrolling moves the frame's position by the negative of GetScrollPosition. - return aFrame->GetPosition() + scrollable->GetScrollPosition(); -} - -nsRect -nsLayoutUtils::GetUnionOfAllRects(nsIFrame* aFrame) -{ - nsRect rcFrame; - nsIFrame* next = aFrame; - nsIFrame* frameParent = aFrame->GetParent(); - if (!frameParent) - return aFrame->GetRect(); - - do { - nsRect r = next->GetRect() + next->GetParent()->GetOffsetTo(frameParent); - rcFrame.UnionRect(rcFrame, r); - next = next->GetNextContinuation(); - } while (next); - - if (rcFrame.IsEmpty()) { - // It could happen that all the rects are empty (eg zero-width or - // zero-height). In that case, use the first rect for the frame, so the - // x and y coordinates are usable. - rcFrame = aFrame->GetRect(); - } - - return rcFrame; -} - nsPoint nsLayoutUtils::GetDOMEventCoordinatesRelativeTo(nsIDOMEvent* aDOMEvent, nsIFrame* aFrame) { diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index b2637c3adbb2..dfc8bc56be4f 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -261,19 +261,6 @@ public: * its pres-shell */ static PRBool IsInitialContainingBlock(nsIFrame* aFrame); - - /** - * @return the offset of aFrame from its parent, as if it were scrolled to - * the top. - */ - static nsPoint GetPositionIgnoringScrolling(nsIFrame* aFrame); - - /** - * @return a rectangle relative to aFrame's parent that is the union of - * aFrame->GetRect() plus the GetRect()s of all aFrame's continuations. If - * all the rects are empty we just return aFrame->GetRect(). - */ - static nsRect GetUnionOfAllRects(nsIFrame* aFrame); /** * Get the coordinates of a given DOM mouse event, relative to a given diff --git a/layout/xul/base/src/nsBoxObject.cpp b/layout/xul/base/src/nsBoxObject.cpp index aa73fea52a39..1435fb036ab5 100644 --- a/layout/xul/base/src/nsBoxObject.cpp +++ b/layout/xul/base/src/nsBoxObject.cpp @@ -56,7 +56,6 @@ #include "nsIWidget.h" #include "nsIDOMXULElement.h" #include "nsIFrame.h" -#include "nsLayoutUtils.h" // Static IIDs/CIDs. Try to minimize these. static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID); @@ -196,10 +195,15 @@ nsBoxObject::GetOffsetRect(nsRect& aRect) nsIFrame* frame = GetFrame(PR_TRUE); if (frame) { // Get its origin - nsPoint origin = nsLayoutUtils::GetPositionIgnoringScrolling(frame); + nsPoint origin = frame->GetPosition(); // Get the union of all rectangles in this and continuation frames - nsRect rcFrame = nsLayoutUtils::GetUnionOfAllRects(frame); + nsRect rcFrame; + nsIFrame* next = frame; + do { + rcFrame.UnionRect(rcFrame, next->GetRect()); + next = next->GetNextContinuation(); + } while (nsnull != next); // Find the frame parent whose content is the document element. nsIContent *docElement = mContent->GetCurrentDoc()->GetRootContent(); @@ -212,7 +216,7 @@ nsBoxObject::GetOffsetRect(nsRect& aRect) // Add the parent's origin to our own to get to the // right coordinate system - origin += nsLayoutUtils::GetPositionIgnoringScrolling(parent); + origin += parent->GetPosition(); parent = parent->GetParent(); }