Bug 168294. Make sure all types of clipping are applied using the zParent view chain. r=kmcclusk,sr=kin

This commit is contained in:
roc+%cs.cmu.edu 2002-09-17 04:16:25 +00:00
Родитель 931b7d6b24
Коммит 1787614f42
2 изменённых файлов: 41 добавлений и 20 удалений

Просмотреть файл

@ -985,8 +985,9 @@ PRBool nsView::PointIsInside(nsView& aView, nscoord x, nscoord y) const
NS_IMETHODIMP nsView::GetClippedRect(nsRect& aClippedRect, PRBool& aIsClipped, PRBool& aEmpty) const
{
// Keep track of the view's offset
// from its ancestor.
// Keep track of the view's offset from its ancestor.
// This is the origin of this view's parent view in the
// coordinate space of 'parentView' below.
nscoord ancestorX = 0;
nscoord ancestorY = 0;
@ -994,13 +995,39 @@ NS_IMETHODIMP nsView::GetClippedRect(nsRect& aClippedRect, PRBool& aIsClipped, P
aIsClipped = PR_FALSE;
GetBounds(aClippedRect);
const nsView* parentView = GetParent();
PRBool lastViewIsFloating = GetFloating();
// Walk all of the way up the views to see if any
// ancestor sets the NS_VIEW_PUBLIC_FLAG_CLIPCHILDREN.
// don't consider non-floating ancestors of a floating view.
while (parentView) {
const nsView* view = this;
while (PR_TRUE) {
const nsView* zParent = view->GetZParent();
const nsView* parentView = view->GetParent();
if (zParent) {
// This view was reparented. We need to move back down the view tree
// to where it should be to collect whatever might be clipping it there.
// parentView is an ancestor of zParent ... this is guaranteed by the way these
// reparented views are set up; a reparented view is always reparented to one of its
// own ancestors
// we need to get ancestorX and ancestorY into the right coordinate system.
// They are the offset of this view within parentView
const nsView* zParentChain;
for (zParentChain = zParent; zParentChain != parentView;
zParentChain = zParentChain->GetParent()) {
NS_ASSERTION(zParentChain != nsnull, "Error in view reparenting logic");
zParentChain->ConvertFromParentCoords(&ancestorX, &ancestorY);
}
parentView = zParent;
// Now start again at zParent to collect all its clip information
}
if (!parentView) {
break;
}
PRBool parentIsFloating = parentView->GetFloating();
if (lastViewIsFloating && !parentIsFloating) {
break;
@ -1012,8 +1039,8 @@ NS_IMETHODIMP nsView::GetClippedRect(nsRect& aClippedRect, PRBool& aIsClipped, P
nsRect clipRect;
parentView->GetChildClip(clipRect);
//Offset the cliprect by the amount the child offsets from the parent
clipRect.x += ancestorX;
clipRect.y += ancestorY;
clipRect.x -= ancestorX;
clipRect.y -= ancestorY;
PRBool overlap = aClippedRect.IntersectRect(clipRect, aClippedRect);
if (!overlap) {
aEmpty = PR_TRUE; // Does not intersect so the rect is empty.
@ -1021,13 +1048,12 @@ NS_IMETHODIMP nsView::GetClippedRect(nsRect& aClippedRect, PRBool& aIsClipped, P
}
}
parentView->ConvertFromParentCoords(&ancestorX, &ancestorY);
parentView->ConvertToParentCoords(&ancestorX, &ancestorY);
lastViewIsFloating = parentIsFloating;
parentView = parentView->GetParent();
view = parentView;
}
return NS_OK;
}

Просмотреть файл

@ -1075,13 +1075,9 @@ void nsViewManager::RenderViews(nsView *aRootView, nsIRenderingContext& aRC, con
{
BuildDisplayList(aRootView, aRect, PR_FALSE, PR_FALSE);
nsRect fakeClipRect;
PRInt32 index = 0;
PRBool anyRendered;
nsRect finalTransparentRect;
ReapplyClipInstructions(PR_FALSE, fakeClipRect, index);
nsRegion opaqueRgn;
AddCoveringWidgetsToOpaqueRegion(opaqueRgn, mContext, aRootView);
OptimizeDisplayList(aRect, finalTransparentRect, opaqueRgn);
@ -1103,7 +1099,8 @@ void nsViewManager::RenderViews(nsView *aRootView, nsIRenderingContext& aRC, con
mTranslucentViewCount = 0;
mTranslucentArea.SetRect(0, 0, 0, 0);
index = 0;
PRInt32 index = 0;
nsRect fakeClipRect;
OptimizeDisplayListClipping(PR_FALSE, fakeClipRect, index, anyRendered);
// We keep a list of all the rendering contexts whose clip rects
@ -2625,9 +2622,6 @@ PRBool nsViewManager::CanScrollWithBitBlt(nsView* aView)
}
nsRect r;
nsRect fakeClipRect;
PRInt32 index = 0;
// Only check the area that intersects the view's non clipped rectangle
PRBool isClipped;
PRBool isEmpty;
@ -2638,7 +2632,6 @@ PRBool nsViewManager::CanScrollWithBitBlt(nsView* aView)
aView->ConvertFromParentCoords(&r.x, &r.y);
BuildDisplayList(aView, r, PR_FALSE, PR_FALSE);
ReapplyClipInstructions(PR_FALSE, fakeClipRect, index);
PRInt32 i;
for (i = 0; i < mDisplayListCount; i++) {
@ -3566,6 +3559,7 @@ PRBool nsViewManager::AddToDisplayList(nsView *aView, DisplayZTreeNode* &aParent
// They might not be because of the Z-reparenting mess: a fixed-position view might have
// created a display element with bounds that do not reflect the clipping instructions that now
// surround the element. This would cause problems in the optimizer.
// XXX No longer used. REMOVE IN THE GREAT VIEW MANAGER PURGE
void nsViewManager::ReapplyClipInstructions(PRBool aHaveClip, nsRect& aClipRect, PRInt32& aIndex)
{
while (aIndex < mDisplayListCount) {
@ -3731,14 +3725,15 @@ void nsViewManager::ShowDisplayList(PRInt32 flatlen)
view->GetPosition(&vx, &vy);
nsView* parent = view->GetParent();
PRInt32 zindex = view->GetZIndex();
nsView* zParent = view->GetZParent();
nest[nestcnt << 1] = 0;
printf("%snsIView@%p{%d,%d,%d,%d @ %d,%d; p=%p,m=%p z=%d} [x=%d, y=%d, w=%d, h=%d, absX=%d, absY=%d]\n",
printf("%snsIView@%p{%d,%d,%d,%d @ %d,%d; p=%p,m=%p z=%d,zp=%p} [x=%d, y=%d, w=%d, h=%d, absX=%d, absY=%d]\n",
nest, (void*)view,
dim.x, dim.y, dim.width, dim.height,
vx, vy,
(void*)parent, (void*)view->GetViewManager(), zindex,
(void*)parent, (void*)view->GetViewManager(), zindex, (void*)zParent,
rect.x, rect.y, rect.width, rect.height,
element->mAbsX, element->mAbsY);