From e89c78b98ab525d69c08042c87beac0260e736ba Mon Sep 17 00:00:00 2001 From: "kmcclusk%netscape.com" Date: Tue, 2 Jul 2002 04:38:35 +0000 Subject: [PATCH] backing out change to see if pageload times go back to normal (Don't place position:absolute, fixed, relative elements above non positioned elements) b=137853 --- layout/generic/nsContainerFrame.cpp | 11 ++--- layout/generic/nsHTMLContainerFrame.cpp | 13 ++--- layout/html/base/src/nsContainerFrame.cpp | 11 ++--- layout/html/base/src/nsHTMLContainerFrame.cpp | 13 ++--- view/public/nsIView.h | 9 +--- view/public/nsIViewManager.h | 8 +--- view/src/nsScrollingView.cpp | 12 ++--- view/src/nsScrollingView.h | 2 +- view/src/nsView.cpp | 10 ++-- view/src/nsView.h | 11 +---- view/src/nsViewManager.cpp | 48 +++++-------------- view/src/nsViewManager.h | 3 +- 12 files changed, 42 insertions(+), 109 deletions(-) diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp index 290dbc2ae2a..623182eebed 100644 --- a/layout/generic/nsContainerFrame.cpp +++ b/layout/generic/nsContainerFrame.cpp @@ -650,23 +650,18 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsIPresContext* aPresContext, // Make sure z-index is correct PRInt32 zIndex = 0; - PRInt32 oldZIndex; - PRBool oldAutoZIndex; - PRBool oldTopMost; PRBool autoZIndex = PR_FALSE; const nsStylePosition* position; - aView->GetZIndex(oldZIndex, oldAutoZIndex, oldTopMost); - aFrame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&)position); if (position->mZIndex.GetUnit() == eStyleUnit_Integer) { zIndex = position->mZIndex.GetIntValue(); } else if (position->mZIndex.GetUnit() == eStyleUnit_Auto) { autoZIndex = PR_TRUE; - } - - vm->SetViewZIndex(aView, autoZIndex, zIndex, oldTopMost); + } + + vm->SetViewZIndex(aView, autoZIndex, zIndex); // There are two types of clipping: // - 'clip' which only applies to absolutely positioned elements, and is diff --git a/layout/generic/nsHTMLContainerFrame.cpp b/layout/generic/nsHTMLContainerFrame.cpp index 9b84b7f13a0..5674a0ab0df 100644 --- a/layout/generic/nsHTMLContainerFrame.cpp +++ b/layout/generic/nsHTMLContainerFrame.cpp @@ -449,7 +449,6 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext, nsIFrame* aContentParentFrame, PRBool aForce) { - PRBool isTopMostView = PR_FALSE; nsIView* view; aFrame->GetView(aPresContext, &view); // If we don't yet have a view, see if we need a view @@ -490,18 +489,12 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext, ("nsHTMLContainerFrame::CreateViewForFrame: frame=%p relatively positioned", aFrame)); aForce = PR_TRUE; - isTopMostView = PR_TRUE; } else if (display->IsAbsolutelyPositioned()) { NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, ("nsHTMLContainerFrame::CreateViewForFrame: frame=%p absolutely positioned", aFrame)); aForce = PR_TRUE; - isTopMostView = PR_TRUE; - } - } - - if (NS_STYLE_POSITION_FIXED == display->mPosition) { - isTopMostView = PR_TRUE; + } } // See if the frame is a scrolled frame @@ -592,7 +585,7 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext, autoZIndex = PR_TRUE; } - viewManager->SetViewZIndex(view, autoZIndex, zIndex, isTopMostView); + viewManager->SetViewZIndex(view, autoZIndex, zIndex); // XXX Drop it at the end of the document order until we can do better viewManager->InsertChild(parentView, view, nsnull, PR_TRUE); @@ -607,7 +600,7 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext, if (nsnull == zParentView) { nsIFrame* zParentFrame = nsnull; - + aContentParentFrame->GetParentWithView(aPresContext, &zParentFrame); NS_ASSERTION(zParentFrame, "GetParentWithView failed"); zParentFrame->GetView(aPresContext, &zParentView); diff --git a/layout/html/base/src/nsContainerFrame.cpp b/layout/html/base/src/nsContainerFrame.cpp index 290dbc2ae2a..623182eebed 100644 --- a/layout/html/base/src/nsContainerFrame.cpp +++ b/layout/html/base/src/nsContainerFrame.cpp @@ -650,23 +650,18 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsIPresContext* aPresContext, // Make sure z-index is correct PRInt32 zIndex = 0; - PRInt32 oldZIndex; - PRBool oldAutoZIndex; - PRBool oldTopMost; PRBool autoZIndex = PR_FALSE; const nsStylePosition* position; - aView->GetZIndex(oldZIndex, oldAutoZIndex, oldTopMost); - aFrame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&)position); if (position->mZIndex.GetUnit() == eStyleUnit_Integer) { zIndex = position->mZIndex.GetIntValue(); } else if (position->mZIndex.GetUnit() == eStyleUnit_Auto) { autoZIndex = PR_TRUE; - } - - vm->SetViewZIndex(aView, autoZIndex, zIndex, oldTopMost); + } + + vm->SetViewZIndex(aView, autoZIndex, zIndex); // There are two types of clipping: // - 'clip' which only applies to absolutely positioned elements, and is diff --git a/layout/html/base/src/nsHTMLContainerFrame.cpp b/layout/html/base/src/nsHTMLContainerFrame.cpp index 9b84b7f13a0..5674a0ab0df 100644 --- a/layout/html/base/src/nsHTMLContainerFrame.cpp +++ b/layout/html/base/src/nsHTMLContainerFrame.cpp @@ -449,7 +449,6 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext, nsIFrame* aContentParentFrame, PRBool aForce) { - PRBool isTopMostView = PR_FALSE; nsIView* view; aFrame->GetView(aPresContext, &view); // If we don't yet have a view, see if we need a view @@ -490,18 +489,12 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext, ("nsHTMLContainerFrame::CreateViewForFrame: frame=%p relatively positioned", aFrame)); aForce = PR_TRUE; - isTopMostView = PR_TRUE; } else if (display->IsAbsolutelyPositioned()) { NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, ("nsHTMLContainerFrame::CreateViewForFrame: frame=%p absolutely positioned", aFrame)); aForce = PR_TRUE; - isTopMostView = PR_TRUE; - } - } - - if (NS_STYLE_POSITION_FIXED == display->mPosition) { - isTopMostView = PR_TRUE; + } } // See if the frame is a scrolled frame @@ -592,7 +585,7 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext, autoZIndex = PR_TRUE; } - viewManager->SetViewZIndex(view, autoZIndex, zIndex, isTopMostView); + viewManager->SetViewZIndex(view, autoZIndex, zIndex); // XXX Drop it at the end of the document order until we can do better viewManager->InsertChild(parentView, view, nsnull, PR_TRUE); @@ -607,7 +600,7 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext, if (nsnull == zParentView) { nsIFrame* zParentFrame = nsnull; - + aContentParentFrame->GetParentWithView(aPresContext, &zParentFrame); NS_ASSERTION(zParentFrame, "GetParentWithView failed"); zParentFrame->GetView(aPresContext, &zParentView); diff --git a/view/public/nsIView.h b/view/public/nsIView.h index a36caab43ba..bb258d67884 100644 --- a/view/public/nsIView.h +++ b/view/public/nsIView.h @@ -144,14 +144,9 @@ public: /** * Called to query the z-index of a view. * The z-index is relative to all siblings of the view. - * @param aAuto PR_TRUE if the view is zindex:auto - * @param aZIndex explicit z-index value. - * @param aTopMost used when this view is zindex:auto - * PR_TRUE if the view is topmost when compared - * with another z-index:auto view - * + * @result current z depth */ - NS_IMETHOD GetZIndex(PRBool &aAuto, PRInt32 &aZIndex, PRBool &aTopMost) const = 0; + NS_IMETHOD GetZIndex(PRBool &aAuto, PRInt32 &aZIndex) const = 0; /** * Get whether the view "floats" above all other views, diff --git a/view/public/nsIViewManager.h b/view/public/nsIViewManager.h index b57450c9773..b4dcf8bbf4a 100644 --- a/view/public/nsIViewManager.h +++ b/view/public/nsIViewManager.h @@ -288,13 +288,9 @@ public: * which means that the z-indicies of the view's children are * relative to the view's siblings. * @param aView view to change z depth of - * @param aZindex explicit z depth - * @param aTopMost used when this view is z-index:auto to compare against - * other z-index:auto views. - * PR_TRUE if the view should be topmost when compared with - * other z-index:auto views. + * @param zindex new z depth */ - NS_IMETHOD SetViewZIndex(nsIView *aView, PRBool aAutoZIndex, PRInt32 aZindex, PRBool aTopMost = PR_FALSE) = 0; + NS_IMETHOD SetViewZIndex(nsIView *aView, PRBool aAutoZIndex, PRInt32 aZindex) = 0; /** * Set whether the view "floats" above all other views, diff --git a/view/src/nsScrollingView.cpp b/view/src/nsScrollingView.cpp index 69e9938acd0..c35e1e8a0af 100644 --- a/view/src/nsScrollingView.cpp +++ b/view/src/nsScrollingView.cpp @@ -950,17 +950,17 @@ NS_IMETHODIMP nsScrollingView::SetWidget(nsIWidget *aWidget) return NS_OK; } -NS_IMETHODIMP nsScrollingView::SetZIndex(PRBool aAuto, PRInt32 aZIndex, PRBool aTopMost) +NS_IMETHODIMP nsScrollingView::SetZIndex(PRBool aAuto, PRInt32 aZIndex) { - nsView::SetZIndex(aAuto, aZIndex, aTopMost); + nsView::SetZIndex(aAuto, aZIndex); // inform all views that the z-index has changed. // XXX why are we doing this? they're all a child of this view, so they // shouldn't need to be re-z-indexed. - if (mClipView) mViewManager->SetViewZIndex(mClipView, aAuto, aZIndex, aTopMost); - if (mCornerView) mViewManager->SetViewZIndex(mCornerView, aAuto, aZIndex, aTopMost); - if (mVScrollBarView) mViewManager->SetViewZIndex(mVScrollBarView, aAuto, aZIndex, aTopMost); - if (mHScrollBarView) mViewManager->SetViewZIndex(mHScrollBarView, aAuto, aZIndex, aTopMost); + if (mClipView) mViewManager->SetViewZIndex(mClipView, aAuto, aZIndex); + if (mCornerView) mViewManager->SetViewZIndex(mCornerView, aAuto, aZIndex); + if (mVScrollBarView) mViewManager->SetViewZIndex(mVScrollBarView, aAuto, aZIndex); + if (mHScrollBarView) mViewManager->SetViewZIndex(mHScrollBarView, aAuto, aZIndex); return NS_OK; } diff --git a/view/src/nsScrollingView.h b/view/src/nsScrollingView.h index cfa48ae437e..2a9bb667829 100644 --- a/view/src/nsScrollingView.h +++ b/view/src/nsScrollingView.h @@ -68,7 +68,7 @@ public: NS_IMETHOD SetVisibility(nsViewVisibility visibility); NS_IMETHOD SetWidget(nsIWidget *aWidget); - NS_IMETHOD SetZIndex(PRBool aAuto, PRInt32 aZIndex, PRBool aTopMost); + NS_IMETHOD SetZIndex(PRBool aAuto, PRInt32 aZIndex); //nsIScrollableView interface NS_IMETHOD CreateScrollControls(nsNativeWidget aNative = nsnull); diff --git a/view/src/nsView.cpp b/view/src/nsView.cpp index 537b02db7c4..17741c5baea 100644 --- a/view/src/nsView.cpp +++ b/view/src/nsView.cpp @@ -607,11 +607,10 @@ NS_IMETHODIMP nsView::GetVisibility(nsViewVisibility &aVisibility) const return NS_OK; } -NS_IMETHODIMP nsView::GetZIndex(PRBool &aAuto, PRInt32 &aZIndex, PRBool &aTopMost) const +NS_IMETHODIMP nsView::GetZIndex(PRBool &aAuto, PRInt32 &aZIndex) const { - aAuto = (mVFlags & NS_VIEW_FLAG_AUTO_ZINDEX) != 0; + aAuto = (mVFlags & NS_VIEW_FLAG_AUTO_ZINDEX) != 0; aZIndex = mZIndex; - aTopMost = (mVFlags & NS_VIEW_FLAG_TOPMOST) != 0; return NS_OK; } @@ -826,12 +825,11 @@ NS_IMETHODIMP nsView::CreateWidget(const nsIID &aWindowIID, return NS_OK; } -void nsView::SetZIndex(PRBool aAuto, PRInt32 aZIndex, PRBool aTopMost) +void nsView::SetZIndex(PRBool aAuto, PRInt32 aZIndex) { mVFlags = (mVFlags & ~NS_VIEW_FLAG_AUTO_ZINDEX) | (aAuto ? NS_VIEW_FLAG_AUTO_ZINDEX : 0); mZIndex = aZIndex; - SetTopMost(aTopMost); - + if (nsnull != mWindow) { mWindow->SetZIndex(aZIndex); } diff --git a/view/src/nsView.h b/view/src/nsView.h index 72eebcbe92c..ea0b7d09e91 100644 --- a/view/src/nsView.h +++ b/view/src/nsView.h @@ -84,10 +84,6 @@ public: // set if our widget moved. #define NS_VIEW_FLAG_WIDGET_MOVED 0x0100 #define NS_VIEW_FLAG_CLIPCHILDREN 0x0200 -// if set it indicates that this view should be -// displayed above z-index:auto views if this view -// is z-index:auto also -#define NS_VIEW_FLAG_TOPMOST 0x0400 //indicates that the view should not be bitblt'd when moved //or scrolled and instead must be repainted #define NS_VIEW_FLAG_DONT_BITBLT 0x0010 @@ -114,7 +110,7 @@ public: NS_IMETHOD GetPosition(nscoord *x, nscoord *y) const; NS_IMETHOD GetBounds(nsRect &aBounds) const; NS_IMETHOD GetVisibility(nsViewVisibility &aVisibility) const; - NS_IMETHOD GetZIndex(PRBool &aAuto, PRInt32 &aZIndex, PRBool &aTopMost) const; + NS_IMETHOD GetZIndex(PRBool &aAuto, PRInt32 &aZIndex) const; PRInt32 GetZIndex() const { return mZIndex; } PRBool GetZIndexIsAuto() const { return (mVFlags & NS_VIEW_FLAG_AUTO_ZINDEX) != 0; } NS_IMETHOD GetFloating(PRBool &aFloatingView) const; @@ -222,7 +218,7 @@ public: * relative to the view's siblings. * @param zindex new z depth */ - void SetZIndex(PRBool aAuto, PRInt32 aZIndex, PRBool aTopMost); + void SetZIndex(PRBool aAuto, PRInt32 aZIndex); /** * Set/Get whether the view "floats" above all other views, @@ -319,9 +315,6 @@ public: // NOT in nsIView, so only available in view module PRUint32 GetViewFlags() const { return mVFlags; } void SetViewFlags(PRUint32 aFlags) { mVFlags = aFlags; } - void SetTopMost(PRBool aTopMost) { aTopMost ? mVFlags |= NS_VIEW_FLAG_TOPMOST : mVFlags &= ~NS_VIEW_FLAG_TOPMOST; } - PRBool IsTopMost() { return((mVFlags & NS_VIEW_FLAG_TOPMOST) != 0); } - void ConvertToParentCoords(nscoord* aX, nscoord* aY) const { *aX += mPosX; *aY += mPosY; } void ConvertFromParentCoords(nscoord* aX, nscoord* aY) const { *aX -= mPosX; *aY -= mPosY; } diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index 283a044fd69..173bcd15e6e 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -252,26 +252,6 @@ nsInvalidateEvent::nsInvalidateEvent(nsViewManager* aViewManager) //-------------- End Invalidate Event Definition --------------------------- -// Compare two Z-index values taking into account topmost and -// auto flags. the topmost flag is only used when both views are -// zindex:auto. -// -// returns 0 if equal -// > 0 if first z-index is greater than the second -// < 0 if first z-index is less than the second - -static PRInt32 CompareZIndex(PRInt32 aZIndex1, PRBool aTopMost1, PRBool aIsAuto1, - PRInt32 aZIndex2, PRBool aTopMost2, PRBool aIsAuto2) -{ - NS_ASSERTION(!aIsAuto1 || aZIndex1 == 0,"auto is set and the z-index is not 0"); - NS_ASSERTION(!aIsAuto2 || aZIndex2 == 0,"auto is set and the z-index is not 0"); - - if (aZIndex1 != aZIndex2) { - return aZIndex1 - aZIndex2; - } else { - return aTopMost1 - aTopMost2; - } -} void nsViewManager::PostInvalidateEvent() @@ -546,7 +526,7 @@ NS_IMETHODIMP nsViewManager::SetRootView(nsIView *aView, nsIWidget* aWidget) parent->InsertChild(mRootView, nsnull); } - mRootView->SetZIndex(PR_FALSE, 0, PR_FALSE); + mRootView->SetZIndex(PR_FALSE, 0); mRootView->GetWidget(mRootWindow); if (nsnull != mRootWindow) { @@ -1827,7 +1807,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS obs->HandleEvent(view, aEvent, aStatus, PR_TRUE, handled); } } - break; + break; default: { @@ -2225,8 +2205,7 @@ NS_IMETHODIMP nsViewManager::InsertChild(nsIView *aParent, nsIView *aChild, nsIV { PRInt32 idx = kid->GetZIndex(); - if (CompareZIndex(zIndex, child->IsTopMost(), child->GetZIndexIsAuto(), - idx, kid->IsTopMost(), kid->GetZIndexIsAuto()) >= 0) + if (zIndex >= idx) break; prev = kid; @@ -2269,7 +2248,7 @@ NS_IMETHODIMP nsViewManager::InsertZPlaceholder(nsIView *aParent, nsIView *aChil // mark the placeholder as "shown" so that it will be included in a built display list placeholder->Init(this, bounds, parent, nsViewVisibility_kShow); placeholder->SetReparentedView(child); - placeholder->SetZIndex(child->GetZIndexIsAuto(), child->GetZIndex(), child->IsTopMost()); + placeholder->SetZIndex(child->GetZIndexIsAuto(), child->GetZIndex()); child->SetZParent(placeholder); return InsertChild(parent, placeholder, aSibling, aAfter); @@ -2294,10 +2273,8 @@ NS_IMETHODIMP nsViewManager::InsertChild(nsIView *aParent, nsIView *aChild, PRIn { PRInt32 idx = kid->GetZIndex(); - if (CompareZIndex(aZIndex, child->IsTopMost(), child->GetZIndexIsAuto(), - idx, kid->IsTopMost(), kid->GetZIndexIsAuto()) >= 0) { + if (aZIndex >= idx) break; - } //get the next sibling view @@ -2307,7 +2284,7 @@ NS_IMETHODIMP nsViewManager::InsertChild(nsIView *aParent, nsIView *aChild, PRIn //in case this hasn't been set yet... maybe we should not do this? MMP - child->SetZIndex(child->GetZIndexIsAuto(), aZIndex, child->IsTopMost()); + child->SetZIndex(child->GetZIndexIsAuto(), aZIndex); parent->InsertChild(child, prev); UpdateTransCnt(nsnull, child); @@ -2727,7 +2704,7 @@ PRBool nsViewManager::IsViewInserted(nsView *aView) } } -NS_IMETHODIMP nsViewManager::SetViewZIndex(nsIView *aView, PRBool aAutoZIndex, PRInt32 aZIndex, PRBool aTopMost) +NS_IMETHODIMP nsViewManager::SetViewZIndex(nsIView *aView, PRBool aAutoZIndex, PRInt32 aZIndex) { nsView* view = NS_STATIC_CAST(nsView*, aView); nsresult rv = NS_OK; @@ -2740,19 +2717,16 @@ NS_IMETHODIMP nsViewManager::SetViewZIndex(nsIView *aView, PRBool aAutoZIndex, P return rv; } - PRBool oldTopMost = view->IsTopMost(); - PRBool oldIsAuto = view->GetZIndexIsAuto(); - if (aAutoZIndex) { aZIndex = 0; } PRInt32 oldidx = view->GetZIndex(); - view->SetZIndex(aAutoZIndex, aZIndex, aTopMost); + + view->SetZIndex(aAutoZIndex, aZIndex); if (IsViewInserted(view)) { - if (CompareZIndex(oldidx, oldTopMost, oldIsAuto, - aZIndex, aTopMost, aAutoZIndex) != 0) { + if (oldidx != aZIndex) { nsView *parent = view->GetParent(); if (nsnull != parent) { //we don't just call the view manager's RemoveChild() @@ -2774,7 +2748,7 @@ NS_IMETHODIMP nsViewManager::SetViewZIndex(nsIView *aView, PRBool aAutoZIndex, P nsZPlaceholderView* zParentView = view->GetZParent(); if (nsnull != zParentView) { - SetViewZIndex(zParentView, aAutoZIndex, aZIndex, aTopMost); + SetViewZIndex(zParentView, aAutoZIndex, aZIndex); } } diff --git a/view/src/nsViewManager.h b/view/src/nsViewManager.h index db43ee70ce8..701ff3e1456 100644 --- a/view/src/nsViewManager.h +++ b/view/src/nsViewManager.h @@ -180,7 +180,8 @@ public: NS_IMETHOD SetViewVisibility(nsIView *aView, nsViewVisibility aVisible); - NS_IMETHOD SetViewZIndex(nsIView *aView, PRBool aAuto, PRInt32 aZIndex, PRBool aTopMost=PR_FALSE); + NS_IMETHOD SetViewZIndex(nsIView *aView, PRBool aAuto, PRInt32 aZIndex); + NS_IMETHOD SetViewContentTransparency(nsIView *aView, PRBool aTransparent); NS_IMETHOD SetViewOpacity(nsIView *aView, float aOpacity);