This commit is contained in:
michaelp 1998-04-29 02:24:07 +00:00
Родитель f4c0f974bb
Коммит c1742af35d
6 изменённых файлов: 51 добавлений и 25 удалений

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

@ -85,14 +85,16 @@ nsIView* AbsoluteFrame::CreateView(nsIView* aContainingView,
// See if the containing view is a scroll view
nsIScrollableView* scrollView = nsnull;
nsresult result;
nsRect clip;
nsRect* pClip = NS_STYLE_CLIP_RECT == aPosition->mClipFlags ?
nsViewClip clip;
nsViewClip* pClip = NS_STYLE_CLIP_RECT == aPosition->mClipFlags ?
&clip : nsnull;
// Is there a clip rect specified?
if (NS_STYLE_CLIP_RECT == aPosition->mClipFlags) {
clip.SetRect(aPosition->mClip.left, aPosition->mClip.top,
aPosition->mClip.right, aPosition->mClip.bottom);
clip.mLeft = aPosition->mClip.left;
clip.mRight = aPosition->mClip.right;
clip.mTop = aPosition->mClip.top;
clip.mBottom = aPosition->mClip.bottom;
}
result = aContainingView->QueryInterface(kIScrollableViewIID, (void**)&scrollView);

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

@ -32,6 +32,17 @@ class nsTransform2D;
class nsIFrame;
struct nsRect;
//this is used by the view clipping APIs since the description of
//a clip rect is different than a rect
typedef struct
{
nscoord mLeft;
nscoord mRight;
nscoord mTop;
nscoord mBottom;
} nsViewClip;
// Enumerated type to indicate the visibility of a layer.
// hide - the layer is not shown.
// show - the layer is shown irrespective of the visibility of
@ -84,7 +95,7 @@ public:
void *aWidgetInitData = nsnull,
nsNativeWindow aNative = nsnull,
PRInt32 aZIndex = 0,
const nsRect *aClipRect = nsnull,
const nsViewClip *aClip = nsnull,
float aOpacity = 1.0f,
nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow) = 0;

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

@ -119,13 +119,13 @@ nsresult nsScrollingView :: Init(nsIViewManager* aManager,
void *aWidgetInitData,
nsNativeWindow aNative,
PRInt32 aZIndex,
const nsRect *aClipRect,
const nsViewClip *aClip,
float aOpacity,
nsViewVisibility aVisibilityFlag)
{
nsresult rv;
rv = nsView :: Init(aManager, aBounds, aParent, aWindowIID, aWidgetInitData, aNative, aZIndex, aClipRect, aOpacity, aVisibilityFlag);
rv = nsView :: Init(aManager, aBounds, aParent, aWindowIID, aWidgetInitData, aNative, aZIndex, aClip, aOpacity, aVisibilityFlag);
if (rv == NS_OK)
{

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

@ -43,7 +43,7 @@ public:
void *aWidgetInitData = nsnull,
nsNativeWindow aNative = nsnull,
PRInt32 aZIndex = 0,
const nsRect *aClipRect = nsnull,
const nsViewClip *aClip = nsnull,
float aOpacity = 1.0f,
nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow);

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

@ -256,7 +256,7 @@ nsresult nsView :: Init(nsIViewManager* aManager,
void *aWidgetInitData,
nsNativeWindow aNative,
PRInt32 aZIndex,
const nsRect *aClipRect,
const nsViewClip *aClip,
float aOpacity,
nsViewVisibility aVisibilityFlag)
{
@ -274,10 +274,15 @@ nsresult nsView :: Init(nsIViewManager* aManager,
mBounds = aBounds;
if (aClipRect != nsnull)
mClipRect = *aClipRect;
if (aClip != nsnull)
mClip = *aClip;
else
mClipRect.Empty();
{
mClip.mLeft = 0;
mClip.mRight = 0;
mClip.mTop = 0;
mClip.mBottom = 0;
}
mOpacity = aOpacity;
mZindex = aZIndex;
@ -337,10 +342,18 @@ void nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect, PRUint32 aPain
{
rc.PushState();
if (mClipRect.IsEmpty() == PR_FALSE)
if ((mClip.mLeft != mClip.mRight) && (mClip.mTop != mClip.mBottom))
{
rc.Translate(mBounds.x, mBounds.y);
rc.SetClipRect(mClipRect, PR_TRUE);
nsRect crect;
crect.x = mClip.mLeft;
crect.y = mClip.mTop;
crect.width = mClip.mRight - mClip.mLeft;
crect.height = mClip.mBottom - mClip.mTop;
rc.SetClipRect(crect, PR_TRUE);
}
else
{
@ -601,22 +614,22 @@ void nsView :: GetBounds(nsRect &aBounds)
void nsView :: SetClip(nscoord aLeft, nscoord aTop, nscoord aRight, nscoord aBottom)
{
mClipRect.x = aLeft;
mClipRect.y = aTop;
mClipRect.width = aRight - aLeft;
mClipRect.height = aBottom - aTop;
mClip.mLeft = aLeft;
mClip.mTop = aTop;
mClip.mRight = aRight;
mClip.mBottom = aBottom;
}
PRBool nsView :: GetClip(nscoord *aLeft, nscoord *aTop, nscoord *aRight, nscoord *aBottom)
{
if (mClipRect.IsEmpty() == PR_TRUE)
if ((mClip.mLeft == mClip.mRight) || (mClip.mTop == mClip.mBottom))
return PR_FALSE;
else
{
*aLeft = mClipRect.x;
*aTop = mClipRect.y;
*aRight = mClipRect.width + mClipRect.x;
*aBottom = mClipRect.height + mClipRect.y;
*aLeft = mClip.mLeft;
*aTop = mClip.mTop;
*aRight = mClip.mRight;
*aBottom = mClip.mBottom;
return PR_TRUE;
}

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

@ -49,7 +49,7 @@ public:
void *aWidgetInitData = nsnull,
nsNativeWindow aNative = nsnull,
PRInt32 aZIndex = 0,
const nsRect *aClipRect = nsnull,
const nsViewClip *aClip = nsnull,
float aOpacity = 1.0f,
nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow);
@ -116,7 +116,7 @@ protected:
nsViewVisibility mVis;
PRInt32 mNumKids;
nsRect mBounds;
nsRect mClipRect;
nsViewClip mClip;
nsTransform2D *mXForm;
float mOpacity;
};