зеркало из https://github.com/mozilla/pjs.git
made scrolling views more self sufficient.
This commit is contained in:
Родитель
38322eedd0
Коммит
3169c696c0
|
@ -245,6 +245,19 @@ void nsScrollingView :: SetDimensions(nscoord width, nscoord height)
|
|||
NS_RELEASE(cx);
|
||||
}
|
||||
|
||||
PRBool nsScrollingView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
|
||||
PRUint32 aPaintFlags, nsIView *aBackstop)
|
||||
{
|
||||
PRBool retval;
|
||||
|
||||
rc.PushState();
|
||||
rc.Translate(-mOffsetX, -mOffsetY);
|
||||
retval = nsView::Paint(rc, rect, aPaintFlags, aBackstop);
|
||||
rc.PopState();
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
nsEventStatus nsScrollingView :: HandleEvent(nsGUIEvent *aEvent, PRUint32 aEventFlags)
|
||||
{
|
||||
nsEventStatus retval = nsEventStatus_eIgnore;
|
||||
|
@ -316,7 +329,11 @@ nsEventStatus nsScrollingView :: HandleEvent(nsGUIEvent *aEvent, PRUint32 aEvent
|
|||
if (dy != 0)
|
||||
{
|
||||
AdjustChildWidgets(0, dy);
|
||||
mWindow->Scroll(0, dy, &clip);
|
||||
|
||||
if (nsnull != mWindow)
|
||||
mWindow->Scroll(0, dy, &clip);
|
||||
else
|
||||
mViewManager->UpdateView(this, nsnull, 0);
|
||||
}
|
||||
|
||||
if (nsnull != thiswin)
|
||||
|
@ -377,7 +394,11 @@ nsEventStatus nsScrollingView :: HandleEvent(nsGUIEvent *aEvent, PRUint32 aEvent
|
|||
if (dx != 0)
|
||||
{
|
||||
AdjustChildWidgets(dx, 0);
|
||||
mWindow->Scroll(dx, 0, &clip);
|
||||
|
||||
if (nsnull != mWindow)
|
||||
mWindow->Scroll(dx, 0, &clip);
|
||||
else
|
||||
mViewManager->UpdateView(this, nsnull, 0);
|
||||
}
|
||||
|
||||
if (nsnull != thiswin)
|
||||
|
|
|
@ -51,6 +51,8 @@ public:
|
|||
virtual void SetDimensions(nscoord width, nscoord height);
|
||||
virtual nsEventStatus HandleEvent(nsGUIEvent *aEvent, PRUint32 aEventFlags);
|
||||
virtual void AdjustChildWidgets(nscoord aDx, nscoord aDy);
|
||||
virtual PRBool Paint(nsIRenderingContext& rc, const nsRect& rect,
|
||||
PRUint32 aPaintFlags, nsIView *aBackstop = nsnull);
|
||||
|
||||
//nsIScrollableView interface
|
||||
virtual void ComputeContainerSize();
|
||||
|
|
|
@ -142,6 +142,34 @@ nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent)
|
|||
return result;
|
||||
}
|
||||
|
||||
// this should be added to nsView. maybe
|
||||
|
||||
nsIWidget * GetWindowTemp(nsIView *aView, nscoord *aDx, nscoord *aDy)
|
||||
{
|
||||
nsIWidget *window = nsnull;
|
||||
nsIView *ancestor = aView;
|
||||
|
||||
while (nsnull != ancestor)
|
||||
{
|
||||
if (nsnull != (window = ancestor->GetWidget()))
|
||||
return window;
|
||||
|
||||
ancestor = ancestor->GetParent();
|
||||
|
||||
if ((nsnull != aDx) && (nsnull != aDy))
|
||||
{
|
||||
nscoord offx, offy;
|
||||
|
||||
ancestor->GetPosition(&offx, &offy);
|
||||
|
||||
*aDx += offx;
|
||||
*aDy += offy;
|
||||
}
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsView :: nsView()
|
||||
{
|
||||
mVis = nsViewVisibility_kShow;
|
||||
|
@ -229,22 +257,6 @@ nsresult nsView :: QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
// this should be added to nsView
|
||||
nsIWidget*
|
||||
GetWindowTemp(nsIView *aView)
|
||||
{
|
||||
nsIWidget *window = nsnull;
|
||||
|
||||
nsIView *ancestor = aView;
|
||||
while (nsnull != ancestor) {
|
||||
if (nsnull != (window = ancestor->GetWidget())) {
|
||||
return window;
|
||||
}
|
||||
ancestor = ancestor->GetParent();
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsrefcnt nsView::AddRef()
|
||||
{
|
||||
return ++mRefCnt;
|
||||
|
@ -341,7 +353,7 @@ nsresult nsView :: Init(nsIViewManager* aManager,
|
|||
mWindow->Create(aNative, trect, ::HandleEvent, dx, nsnull, aWidgetInitData);
|
||||
else
|
||||
{
|
||||
nsIWidget *parent = GetWindowTemp(aParent);
|
||||
nsIWidget *parent = GetWindowTemp(aParent, nsnull, nsnull);
|
||||
mWindow->Create(parent, trect, ::HandleEvent, dx, nsnull, aWidgetInitData);
|
||||
NS_IF_RELEASE(parent);
|
||||
}
|
||||
|
@ -615,12 +627,22 @@ void nsView :: SetPosition(nscoord x, nscoord y)
|
|||
if (nsnull != mWindow)
|
||||
{
|
||||
nsIPresContext *px = mViewManager->GetPresContext();
|
||||
nscoord offx, offy;
|
||||
nscoord offx, offy, parx = 0, pary = 0;
|
||||
float scale = px->GetTwipsToPixels();
|
||||
|
||||
nsIView *par = GetParent();
|
||||
|
||||
mViewManager->GetWindowOffsets(&offx, &offy);
|
||||
|
||||
if (nsnull != par)
|
||||
{
|
||||
nsIWidget *pwidget = nsnull;
|
||||
|
||||
pwidget = GetWindowTemp(par, &parx, &pary);
|
||||
NS_IF_RELEASE(pwidget);
|
||||
}
|
||||
|
||||
mWindow->Move(NS_TO_INT_ROUND((x + offx) * scale), NS_TO_INT_ROUND((y + offy) * scale));
|
||||
mWindow->Move(NS_TO_INT_ROUND((x + parx + offx) * scale),
|
||||
NS_TO_INT_ROUND((y + pary + offy) * scale));
|
||||
|
||||
NS_RELEASE(px);
|
||||
}
|
||||
|
|
|
@ -321,16 +321,12 @@ void nsViewManager :: Refresh(nsIView *aView, nsIRenderingContext *aContext, nsI
|
|||
localcx->SetClipRegion(*region, nsClipCombine_kReplace);
|
||||
region->Offset(NS_TO_INT_ROUND(xoff * scale), NS_TO_INT_ROUND(yoff * scale));
|
||||
|
||||
localcx->Translate(-xoff, -yoff);
|
||||
|
||||
nsRect trect;
|
||||
|
||||
region->GetBoundingBox(&trect.x, &trect.y, &trect.width, &trect.height);
|
||||
trect *= mContext->GetPixelsToTwips();
|
||||
|
||||
localcx->PushState();
|
||||
aView->Paint(*localcx, trect, 0);
|
||||
localcx->PopState();
|
||||
|
||||
if (aUpdateFlags & NS_VMREFRESH_DOUBLE_BUFFER)
|
||||
localcx->CopyOffScreenBits(wrect);
|
||||
|
@ -386,18 +382,17 @@ void nsViewManager :: Refresh(nsIView *aView, nsIRenderingContext *aContext, nsR
|
|||
|
||||
GetWindowOffsets(&xoff, &yoff);
|
||||
|
||||
localcx->Translate(-xoff, -yoff);
|
||||
|
||||
nsRect trect = *rect;
|
||||
|
||||
if (aUpdateFlags & NS_VMREFRESH_SCREEN_RECT)
|
||||
trect.MoveBy(xoff, yoff);
|
||||
else
|
||||
{
|
||||
trect.MoveBy(-xoff, -yoff);
|
||||
localcx->SetClipRect(trect, nsClipCombine_kReplace);
|
||||
}
|
||||
|
||||
localcx->PushState();
|
||||
aView->Paint(*localcx, trect, 0);
|
||||
localcx->PopState();
|
||||
|
||||
if (aUpdateFlags & NS_VMREFRESH_DOUBLE_BUFFER)
|
||||
localcx->CopyOffScreenBits(wrect);
|
||||
|
|
Загрузка…
Ссылка в новой задаче