зеркало из https://github.com/mozilla/gecko-dev.git
Bug 13213. Allow views to extend above and to the left of their owner frames. r=kmcclusk,rs=waterson
This commit is contained in:
Родитель
c7b73c1a18
Коммит
71f8f6558e
|
@ -2269,9 +2269,10 @@ nsListControlFrame::GetViewOffset(nsIViewManager* aManager, nsIView* aView,
|
|||
|
||||
parent = aView;
|
||||
while (nsnull != parent) {
|
||||
parent->GetBounds(bounds);
|
||||
aPoint.x += bounds.x;
|
||||
aPoint.y += bounds.y;
|
||||
nscoord x, y;
|
||||
parent->GetPosition(&x, &y);
|
||||
aPoint.x += x;
|
||||
aPoint.y += y;
|
||||
parent->GetParent(parent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -367,11 +367,11 @@ static PRBool
|
|||
TranslatePointTo(nsPoint& aPoint, nsIView* aChildView, nsIView* aParentView)
|
||||
{
|
||||
do {
|
||||
nsRect bounds;
|
||||
nscoord x, y;
|
||||
|
||||
aChildView->GetBounds(bounds);
|
||||
aPoint.x += bounds.x;
|
||||
aPoint.y += bounds.y;
|
||||
aChildView->GetPosition(&x, &y);
|
||||
aPoint.x += x;
|
||||
aPoint.y += y;
|
||||
aChildView->GetParent(aChildView);
|
||||
} while (aChildView && (aChildView != aParentView));
|
||||
|
||||
|
@ -416,10 +416,10 @@ nsContainerFrame::PositionFrameView(nsIPresContext* aPresContext,
|
|||
if (data)
|
||||
break;
|
||||
|
||||
nsRect bounds;
|
||||
parentView->GetBounds(bounds);
|
||||
origin.x -= bounds.x;
|
||||
origin.y -= bounds.y;
|
||||
nscoord x, y;
|
||||
parentView->GetPosition(&x, &y);
|
||||
origin.x -= x;
|
||||
origin.y -= y;
|
||||
parentView->GetParent(parentView);
|
||||
}
|
||||
|
||||
|
|
|
@ -3878,10 +3878,10 @@ aContainerWidget)
|
|||
|
||||
// GetOffsetFromWidget does not include the views offset, so we need to add
|
||||
// that in.
|
||||
nsRect bounds;
|
||||
view->GetBounds(bounds);
|
||||
aAbs.x += bounds.x;
|
||||
aAbs.y += bounds.y;
|
||||
nscoord x, y;
|
||||
view->GetPosition(&x, &y);
|
||||
aAbs.x += x;
|
||||
aAbs.y += y;
|
||||
}
|
||||
|
||||
nsRect widgetBounds;
|
||||
|
|
|
@ -367,11 +367,11 @@ static PRBool
|
|||
TranslatePointTo(nsPoint& aPoint, nsIView* aChildView, nsIView* aParentView)
|
||||
{
|
||||
do {
|
||||
nsRect bounds;
|
||||
nscoord x, y;
|
||||
|
||||
aChildView->GetBounds(bounds);
|
||||
aPoint.x += bounds.x;
|
||||
aPoint.y += bounds.y;
|
||||
aChildView->GetPosition(&x, &y);
|
||||
aPoint.x += x;
|
||||
aPoint.y += y;
|
||||
aChildView->GetParent(aChildView);
|
||||
} while (aChildView && (aChildView != aParentView));
|
||||
|
||||
|
@ -416,10 +416,10 @@ nsContainerFrame::PositionFrameView(nsIPresContext* aPresContext,
|
|||
if (data)
|
||||
break;
|
||||
|
||||
nsRect bounds;
|
||||
parentView->GetBounds(bounds);
|
||||
origin.x -= bounds.x;
|
||||
origin.y -= bounds.y;
|
||||
nscoord x, y;
|
||||
parentView->GetPosition(&x, &y);
|
||||
origin.x -= x;
|
||||
origin.y -= y;
|
||||
parentView->GetParent(parentView);
|
||||
}
|
||||
|
||||
|
|
|
@ -3878,10 +3878,10 @@ aContainerWidget)
|
|||
|
||||
// GetOffsetFromWidget does not include the views offset, so we need to add
|
||||
// that in.
|
||||
nsRect bounds;
|
||||
view->GetBounds(bounds);
|
||||
aAbs.x += bounds.x;
|
||||
aAbs.y += bounds.y;
|
||||
nscoord x, y;
|
||||
view->GetPosition(&x, &y);
|
||||
aAbs.x += x;
|
||||
aAbs.y += y;
|
||||
}
|
||||
|
||||
nsRect widgetBounds;
|
||||
|
|
|
@ -2269,9 +2269,10 @@ nsListControlFrame::GetViewOffset(nsIViewManager* aManager, nsIView* aView,
|
|||
|
||||
parent = aView;
|
||||
while (nsnull != parent) {
|
||||
parent->GetBounds(bounds);
|
||||
aPoint.x += bounds.x;
|
||||
aPoint.y += bounds.y;
|
||||
nscoord x, y;
|
||||
parent->GetPosition(&x, &y);
|
||||
aPoint.x += x;
|
||||
aPoint.y += y;
|
||||
parent->GetParent(parent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,31 +115,6 @@ nsrefcnt nsScrollPortView::Release()
|
|||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsScrollPortView::Init(nsIViewManager* aManager,
|
||||
const nsRect &aBounds,
|
||||
const nsIView *aParent,
|
||||
nsViewVisibility aVisibilityFlag)
|
||||
{
|
||||
return nsView::Init(aManager, aBounds, aParent, aVisibilityFlag);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollPortView::SetDimensions(nscoord width, nscoord height, PRBool aPaint)
|
||||
{
|
||||
return nsView::SetDimensions(width, height, aPaint);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollPortView::SetPosition(nscoord aX, nscoord aY)
|
||||
{
|
||||
|
||||
return nsView::SetPosition(aX, aY);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsScrollPortView::SetVisibility(nsViewVisibility aVisibility)
|
||||
{
|
||||
return nsView::SetVisibility(aVisibility);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollPortView::GetClipView(const nsIView** aClipView) const
|
||||
{
|
||||
*aClipView = this;
|
||||
|
@ -203,7 +178,11 @@ NS_IMETHODIMP nsScrollPortView::GetContainerSize(nscoord *aWidth, nscoord *aHeig
|
|||
if (!scrolledView)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return scrolledView->GetDimensions(aWidth, aHeight);
|
||||
nsSize sz;
|
||||
scrolledView->GetDimensions(sz);
|
||||
*aWidth = sz.width;
|
||||
*aHeight = sz.height;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollPortView::ShowQuality(PRBool aShow)
|
||||
|
@ -264,10 +243,10 @@ NS_IMETHODIMP nsScrollPortView::ScrollTo(nscoord aX, nscoord aY, PRUint32 aUpdat
|
|||
#endif
|
||||
|
||||
if (!scrolledView) return NS_ERROR_FAILURE;
|
||||
scrolledView->GetDimensions(&scrolledSize.width, &scrolledSize.height);
|
||||
scrolledView->GetDimensions(scrolledSize);
|
||||
|
||||
nsSize portSize;
|
||||
GetDimensions(&portSize.width, &portSize.height);
|
||||
GetDimensions(portSize);
|
||||
|
||||
nscoord maxX = scrolledSize.width - portSize.width;
|
||||
nscoord maxY = scrolledSize.height - portSize.height;
|
||||
|
@ -484,7 +463,7 @@ NS_IMETHODIMP nsScrollPortView::ScrollByLines(PRInt32 aNumLinesX, PRInt32 aNumLi
|
|||
NS_IMETHODIMP nsScrollPortView::ScrollByPages(PRInt32 aNumPages)
|
||||
{
|
||||
nsSize size;
|
||||
GetDimensions(&size.width, &size.height);
|
||||
GetDimensions(size);
|
||||
|
||||
// scroll % of the window
|
||||
nscoord dy = nscoord(float(size.height)*PAGE_SCROLL_PERCENT);
|
||||
|
@ -505,7 +484,7 @@ NS_IMETHODIMP nsScrollPortView::ScrollByWhole(PRBool aTop)
|
|||
if (!aTop) {
|
||||
nsSize scrolledSize;
|
||||
nsView* scrolledView = GetScrolledView();
|
||||
scrolledView->GetDimensions(&scrolledSize.width, &scrolledSize.height);
|
||||
scrolledView->GetDimensions(scrolledSize);
|
||||
newPos = scrolledSize.height;
|
||||
}
|
||||
|
||||
|
@ -569,7 +548,8 @@ NS_IMETHODIMP nsScrollPortView::Paint(nsIRenderingContext& rc, const nsRect& rec
|
|||
{
|
||||
PRBool clipEmpty;
|
||||
rc.PushState();
|
||||
nsRect bounds = mBounds;
|
||||
nsRect bounds;
|
||||
GetDimensions(bounds);
|
||||
bounds.x = bounds.y = 0;
|
||||
rc.SetClipRect(bounds, nsClipCombine_kIntersect, clipEmpty);
|
||||
|
||||
|
@ -585,7 +565,8 @@ NS_IMETHODIMP nsScrollPortView::Paint(nsIRenderingContext& aRC, const nsIRegion&
|
|||
{
|
||||
PRBool clipEmpty;
|
||||
aRC.PushState();
|
||||
nsRect bounds = mBounds;
|
||||
nsRect bounds;
|
||||
GetDimensions(bounds);
|
||||
bounds.x = bounds.y = 0;
|
||||
aRC.SetClipRect(bounds, nsClipCombine_kIntersect, clipEmpty);
|
||||
|
||||
|
|
|
@ -54,16 +54,6 @@ public:
|
|||
NS_IMETHOD QueryInterface(REFNSIID aIID,
|
||||
void** aInstancePtr);
|
||||
|
||||
//overrides
|
||||
NS_IMETHOD Init(nsIViewManager* aManager,
|
||||
const nsRect &aBounds,
|
||||
const nsIView *aParent,
|
||||
nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow);
|
||||
NS_IMETHOD SetDimensions(nscoord width, nscoord height, PRBool aPaint = PR_TRUE);
|
||||
NS_IMETHOD SetPosition(nscoord aX, nscoord aY);
|
||||
// SetVisibility is overriden so that it will set it's components visibility (ClipView,
|
||||
// CornerView, ScrollBarView's),as well as it's own visibility.
|
||||
NS_IMETHOD SetVisibility(nsViewVisibility visibility);
|
||||
NS_IMETHOD SetWidget(nsIWidget *aWidget);
|
||||
|
||||
//nsIScrollableView interface
|
||||
|
|
|
@ -478,7 +478,7 @@ NS_IMETHODIMP nsScrollingView::Init(nsIViewManager* aManager,
|
|||
return nsView::Init(aManager, aBounds, aParent, aVisibilityFlag);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollingView::SetDimensions(nscoord width, nscoord height, PRBool aPaint)
|
||||
void nsScrollingView::SetDimensions(const nsRect& aRect, PRBool aPaint)
|
||||
{
|
||||
nsIDeviceContext *dx;
|
||||
mViewManager->GetDeviceContext(dx);
|
||||
|
@ -488,7 +488,7 @@ NS_IMETHODIMP nsScrollingView::SetDimensions(nscoord width, nscoord height, PRBo
|
|||
nsRect clipRect;
|
||||
|
||||
// Set our bounds and size our widget if we have one
|
||||
nsView::SetDimensions(width, height, aPaint);
|
||||
nsView::SetDimensions(aRect, aPaint);
|
||||
|
||||
#if 0
|
||||
//this will fix the size of the thumb when we resize the root window,
|
||||
|
@ -499,6 +499,8 @@ NS_IMETHODIMP nsScrollingView::SetDimensions(nscoord width, nscoord height, PRBo
|
|||
ComputeScrollOffsets();
|
||||
#endif
|
||||
|
||||
NS_ASSERTION(aRect.x == 0 && aRect.y == 0, "ScrollingView has contents sticking above or to left");
|
||||
|
||||
// Determine how much space is actually taken up by the scrollbars
|
||||
if (mHScrollBarView && ViewIsShowing((ScrollBarView *)mHScrollBarView))
|
||||
showHorz = NSToCoordRound(scrollHeight);
|
||||
|
@ -507,20 +509,21 @@ NS_IMETHODIMP nsScrollingView::SetDimensions(nscoord width, nscoord height, PRBo
|
|||
showVert = NSToCoordRound(scrollWidth);
|
||||
|
||||
// Compute the clip view rect
|
||||
clipRect.SetRect(0, 0, PR_MAX((width - showVert), mInsets.left+mInsets.right), PR_MAX((height - showHorz), mInsets.top+mInsets.bottom));
|
||||
clipRect.SetRect(0, 0, PR_MAX((aRect.width - showVert), mInsets.left+mInsets.right), PR_MAX((aRect.height - showHorz), mInsets.top+mInsets.bottom));
|
||||
clipRect.Deflate(mInsets);
|
||||
|
||||
// Size and position the clip view
|
||||
if (nsnull != mClipView) {
|
||||
mClipView->SetBounds(clipRect, aPaint);
|
||||
UpdateScrollControls(aPaint);
|
||||
mClipView->SetPosition(clipRect.x, clipRect.y);
|
||||
clipRect.x = clipRect.y = 0;
|
||||
mClipView->SetDimensions(clipRect, aPaint);
|
||||
UpdateScrollControls(aPaint);
|
||||
}
|
||||
|
||||
NS_RELEASE(dx);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollingView::SetPosition(nscoord aX, nscoord aY)
|
||||
void nsScrollingView::SetPosition(nscoord aX, nscoord aY)
|
||||
{
|
||||
// If we have a widget then there's no need to adjust child widgets,
|
||||
// because they're relative to our window
|
||||
|
@ -561,7 +564,6 @@ NS_IMETHODIMP nsScrollingView::SetPosition(nscoord aX, nscoord aY)
|
|||
|
||||
NS_RELEASE(dx);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -683,7 +685,7 @@ void nsScrollingView::HandleScrollEvent(nsGUIEvent *aEvent, PRUint32 aEventFlags
|
|||
NS_RELEASE(px);
|
||||
|
||||
// Get the size of the clip view
|
||||
mClipView->GetDimensions(&clipSize.width, &clipSize.height);
|
||||
mClipView->GetDimensions(clipSize);
|
||||
|
||||
nscoord offsetX = mOffsetX;
|
||||
nscoord offsetY = mOffsetY;
|
||||
|
@ -828,7 +830,7 @@ NS_IMETHODIMP nsScrollingView::CreateScrollControls(nsNativeWidget aNative)
|
|||
// child views with widgets. Note that the clip view has an opacity
|
||||
// of 0.0f (completely transparent)
|
||||
// XXX The clip widget should be created on demand only...
|
||||
rv = mClipView->Init(mViewManager, mBounds, this);
|
||||
rv = mClipView->Init(mViewManager, mDimBounds, this);
|
||||
rv = mViewManager->InsertChild(this, mClipView, mZIndex);
|
||||
rv = mViewManager->SetViewOpacity(mClipView, 0.0f);
|
||||
rv = mClipView->CreateWidget(kWidgetCID, &initData,
|
||||
|
@ -845,9 +847,9 @@ NS_IMETHODIMP nsScrollingView::CreateScrollControls(nsNativeWidget aNative)
|
|||
|
||||
dx->GetScrollBarDimensions(sbWidth, sbHeight);
|
||||
trect.width = NSToCoordRound(sbWidth);
|
||||
trect.x = mBounds.x + mBounds.XMost() - trect.width;
|
||||
trect.x = mDimBounds.width - trect.width;
|
||||
trect.height = NSToCoordRound(sbHeight);
|
||||
trect.y = mBounds.y + mBounds.YMost() - trect.height;
|
||||
trect.y = mDimBounds.height - trect.height;
|
||||
|
||||
rv = mCornerView->Init(mViewManager, trect, this, nsViewVisibility_kHide);
|
||||
mViewManager->InsertChild(this, mCornerView, mZIndex);
|
||||
|
@ -860,13 +862,14 @@ NS_IMETHODIMP nsScrollingView::CreateScrollControls(nsNativeWidget aNative)
|
|||
|
||||
if (nsnull != mVScrollBarView)
|
||||
{
|
||||
nsRect trect = mBounds;
|
||||
nsRect trect;
|
||||
float sbWidth, sbHeight;
|
||||
|
||||
dx->GetScrollBarDimensions(sbWidth, sbHeight);
|
||||
trect.width = NSToCoordRound(sbWidth);
|
||||
trect.x += mBounds.XMost() - trect.width;
|
||||
trect.x = mDimBounds.width - trect.width;
|
||||
trect.height -= NSToCoordRound(sbHeight);
|
||||
trect.y = 0;
|
||||
|
||||
static NS_DEFINE_IID(kCScrollbarIID, NS_VERTSCROLLBAR_CID);
|
||||
|
||||
|
@ -920,13 +923,14 @@ NS_IMETHODIMP nsScrollingView::CreateScrollControls(nsNativeWidget aNative)
|
|||
|
||||
if (nsnull != mHScrollBarView)
|
||||
{
|
||||
nsRect trect = mBounds;
|
||||
nsRect trect;
|
||||
float sbWidth, sbHeight;
|
||||
|
||||
dx->GetScrollBarDimensions(sbWidth, sbHeight);
|
||||
trect.height = NSToCoordRound(sbHeight);
|
||||
trect.y += mBounds.YMost() - trect.height;
|
||||
trect.y = mDimBounds.height - trect.height;
|
||||
trect.width -= NSToCoordRound(sbWidth);
|
||||
trect.x = 0;
|
||||
|
||||
static NS_DEFINE_IID(kCHScrollbarIID, NS_HORZSCROLLBAR_CID);
|
||||
|
||||
|
@ -977,22 +981,25 @@ NS_IMETHODIMP nsScrollingView::ComputeScrollOffsets(PRBool aAdjustWidgets)
|
|||
{
|
||||
nscoord dx = 0, dy = 0;
|
||||
nsIDeviceContext *px;
|
||||
nscoord hwidth, hheight;
|
||||
nscoord vwidth, vheight;
|
||||
nsSize hSize;
|
||||
nsSize vSize;
|
||||
PRUint32 oldsizey = mSizeY, oldsizex = mSizeX;
|
||||
nscoord offx, offy;
|
||||
float scale;
|
||||
nsRect controlRect(0, 0, mBounds.width, mBounds.height);
|
||||
nsRect controlRect(0, 0, mDimBounds.width, mDimBounds.height);
|
||||
|
||||
controlRect.Deflate(mInsets);
|
||||
|
||||
mViewManager->GetDeviceContext(px);
|
||||
px->GetAppUnitsToDevUnits(scale);
|
||||
|
||||
scrolledView->GetDimensions(&mSizeX, &mSizeY);
|
||||
nsSize sz;
|
||||
scrolledView->GetDimensions(sz);
|
||||
mSizeX = sz.width;
|
||||
mSizeY = sz.height;
|
||||
|
||||
if (nsnull != mHScrollBarView) {
|
||||
mHScrollBarView->GetDimensions(&hwidth, &hheight);
|
||||
mHScrollBarView->GetDimensions(hSize);
|
||||
mHScrollBarView->GetWidget(win);
|
||||
|
||||
if (NS_OK == win->QueryInterface(NS_GET_IID(nsIScrollbar), (void **)&scrollh)) {
|
||||
|
@ -1010,13 +1017,13 @@ NS_IMETHODIMP nsScrollingView::ComputeScrollOffsets(PRBool aAdjustWidgets)
|
|||
}
|
||||
|
||||
if (nsnull != mVScrollBarView) {
|
||||
mVScrollBarView->GetDimensions(&vwidth, &vheight);
|
||||
mVScrollBarView->GetDimensions(vSize);
|
||||
offy = mOffsetY;
|
||||
|
||||
mVScrollBarView->GetWidget(win);
|
||||
|
||||
if (NS_OK == win->QueryInterface(NS_GET_IID(nsIScrollbar), (void **)&scrollv)) {
|
||||
if ((mSizeY > (controlRect.height - (hasHorizontal ? hheight : 0)))) {
|
||||
if ((mSizeY > (controlRect.height - (hasHorizontal ? hSize.height : 0)))) {
|
||||
// if we are scrollable
|
||||
if (mScrollPref != nsScrollPreference_kNeverScroll) {
|
||||
//we need to be able to scroll
|
||||
|
@ -1033,7 +1040,7 @@ NS_IMETHODIMP nsScrollingView::ComputeScrollOffsets(PRBool aAdjustWidgets)
|
|||
scrollv->GetPosition(oldpos);
|
||||
px->GetDevUnitsToAppUnits(p2t);
|
||||
|
||||
availheight = controlRect.height - (hasHorizontal ? hheight : 0);
|
||||
availheight = controlRect.height - (hasHorizontal ? hSize.height : 0);
|
||||
|
||||
// XXX Check for 0 initial size. This is really indicative
|
||||
// of a problem.
|
||||
|
@ -1089,7 +1096,7 @@ NS_IMETHODIMP nsScrollingView::ComputeScrollOffsets(PRBool aAdjustWidgets)
|
|||
mHScrollBarView->GetWidget(win);
|
||||
|
||||
if (NS_OK == win->QueryInterface(NS_GET_IID(nsIScrollbar), (void **)&scrollh)) {
|
||||
if ((mSizeX > (controlRect.width - (hasVertical ? vwidth : 0)))) {
|
||||
if ((mSizeX > (controlRect.width - (hasVertical ? vSize.width : 0)))) {
|
||||
if (mScrollPref != nsScrollPreference_kNeverScroll) {
|
||||
//we need to be able to scroll
|
||||
|
||||
|
@ -1105,7 +1112,7 @@ NS_IMETHODIMP nsScrollingView::ComputeScrollOffsets(PRBool aAdjustWidgets)
|
|||
scrollh->GetPosition(oldpos);
|
||||
px->GetDevUnitsToAppUnits(p2t);
|
||||
|
||||
availwidth = controlRect.width - (hasVertical ? vwidth : 0);
|
||||
availwidth = controlRect.width - (hasVertical ? vSize.width : 0);
|
||||
|
||||
// XXX Check for 0 initial size. This is really indicative
|
||||
// of a problem.
|
||||
|
@ -1158,16 +1165,17 @@ NS_IMETHODIMP nsScrollingView::ComputeScrollOffsets(PRBool aAdjustWidgets)
|
|||
// Adjust the size of the clip view to account for scrollbars that are
|
||||
// showing
|
||||
if (mHScrollBarView && ViewIsShowing((ScrollBarView *)mHScrollBarView)) {
|
||||
controlRect.height -= hheight;
|
||||
controlRect.height -= hSize.height;
|
||||
controlRect.height = PR_MAX(controlRect.height, 0);
|
||||
}
|
||||
|
||||
if (mVScrollBarView && ViewIsShowing((ScrollBarView *)mVScrollBarView)) {
|
||||
controlRect.width -= vwidth;
|
||||
controlRect.width -= vSize.width;
|
||||
controlRect.width = PR_MAX(controlRect.width, 0);
|
||||
}
|
||||
|
||||
mClipView->SetDimensions(controlRect.width, controlRect.height, PR_FALSE);
|
||||
nsRect r(0, 0, controlRect.width, controlRect.height);
|
||||
mClipView->SetDimensions(r, PR_FALSE);
|
||||
|
||||
// Position the scrolled view
|
||||
scrolledView->SetPosition(-mOffsetX, -mOffsetY);
|
||||
|
@ -1281,7 +1289,7 @@ NS_IMETHODIMP nsScrollingView::ScrollTo(nscoord aX, nscoord aY, PRUint32 aUpdate
|
|||
|
||||
NS_RELEASE(dev);
|
||||
|
||||
mClipView->GetDimensions(&clipSize.width, &clipSize.height);
|
||||
mClipView->GetDimensions(clipSize);
|
||||
|
||||
// Clamp aX
|
||||
|
||||
|
@ -1463,7 +1471,7 @@ void nsScrollingView::UpdateScrollControls(PRBool aPaint)
|
|||
|
||||
if (nsnull != mCornerView)
|
||||
{
|
||||
mCornerView->GetDimensions(&cornerSize.width, &cornerSize.height);
|
||||
mCornerView->GetDimensions(cornerSize);
|
||||
|
||||
// If both the vertical and horizontal scrollbars are enabled, so is the corner view.
|
||||
if (vertVis && horzVis)
|
||||
|
@ -1481,9 +1489,10 @@ void nsScrollingView::UpdateScrollControls(PRBool aPaint)
|
|||
{
|
||||
nsSize vertSize;
|
||||
|
||||
mVScrollBarView->GetDimensions(&vertSize.width, &vertSize.height);
|
||||
mVScrollBarView->SetBounds(clipRect.XMost(), clipRect.y, vertSize.width,
|
||||
clipRect.height - visCornerSize.height, aPaint);
|
||||
mVScrollBarView->GetDimensions(vertSize);
|
||||
mVScrollBarView->SetPosition(clipRect.XMost(), clipRect.y);
|
||||
nsRect r(0, 0, vertSize.width, clipRect.height - visCornerSize.height);
|
||||
mVScrollBarView->SetDimensions(r, aPaint);
|
||||
|
||||
if (vertVis == nsViewVisibility_kShow)
|
||||
cornerPos.x = clipRect.XMost();
|
||||
|
@ -1496,9 +1505,10 @@ void nsScrollingView::UpdateScrollControls(PRBool aPaint)
|
|||
{
|
||||
nsSize horzSize;
|
||||
|
||||
mHScrollBarView->GetDimensions(&horzSize.width, &horzSize.height);
|
||||
mHScrollBarView->SetBounds(clipRect.x, clipRect.YMost(), clipRect.width - visCornerSize.width,
|
||||
horzSize.height, aPaint);
|
||||
mHScrollBarView->GetDimensions(horzSize);
|
||||
mHScrollBarView->SetPosition(clipRect.x, clipRect.YMost());
|
||||
nsRect r(0, 0, clipRect.width - visCornerSize.width, horzSize.height);
|
||||
mHScrollBarView->SetDimensions(r, aPaint);
|
||||
|
||||
if (horzVis == nsViewVisibility_kShow)
|
||||
cornerPos.y = clipRect.YMost();
|
||||
|
@ -1604,7 +1614,7 @@ NS_IMETHODIMP nsScrollingView::ScrollByLines(PRInt32 aNumLinesX, PRInt32 aNumLin
|
|||
}
|
||||
|
||||
nsSize clipSize;
|
||||
mClipView->GetDimensions(&clipSize.width, &clipSize.height);
|
||||
mClipView->GetDimensions(clipSize);
|
||||
|
||||
//sanity check values
|
||||
if (newPosX > (mSizeX - clipSize.height))
|
||||
|
@ -1635,7 +1645,7 @@ NS_IMETHODIMP nsScrollingView::ScrollByPages(PRInt32 aNumPages)
|
|||
scrollv->GetPosition(oldPos);
|
||||
NS_RELEASE(scrollv);
|
||||
|
||||
mClipView->GetDimensions(&clipSize.width, &clipSize.height);
|
||||
mClipView->GetDimensions(clipSize);
|
||||
|
||||
newPos = oldPos + clipSize.height * aNumPages;
|
||||
|
||||
|
@ -1662,7 +1672,7 @@ NS_IMETHODIMP nsScrollingView::ScrollByWhole(PRBool aTop)
|
|||
}
|
||||
else {
|
||||
nsSize clipSize;
|
||||
mClipView->GetDimensions(&clipSize.width, &clipSize.height);
|
||||
mClipView->GetDimensions(clipSize);
|
||||
newPos = mSizeY - clipSize.height;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,8 +61,8 @@ public:
|
|||
const nsRect &aBounds,
|
||||
const nsIView *aParent,
|
||||
nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow);
|
||||
NS_IMETHOD SetDimensions(nscoord width, nscoord height, PRBool aPaint = PR_TRUE);
|
||||
NS_IMETHOD SetPosition(nscoord aX, nscoord aY);
|
||||
virtual void SetDimensions(const nsRect& aRect, PRBool aPaint = PR_TRUE);
|
||||
virtual void SetPosition(nscoord aX, nscoord aY);
|
||||
// SetVisibility is overriden so that it will set it's components visibility (ClipView,
|
||||
// CornerView, ScrollBarView's),as well as it's own visibility.
|
||||
NS_IMETHOD SetVisibility(nsViewVisibility visibility);
|
||||
|
|
|
@ -229,7 +229,10 @@ NS_IMETHODIMP nsView::Init(nsIViewManager* aManager,
|
|||
mChildClip.mTop = 0;
|
||||
mChildClip.mBottom = 0;
|
||||
|
||||
SetBounds(aBounds);
|
||||
SetPosition(aBounds.x, aBounds.y);
|
||||
nsRect dim(0, 0, aBounds.width, aBounds.height);
|
||||
|
||||
SetDimensions(dim, PR_FALSE);
|
||||
|
||||
//temporarily set it...
|
||||
SetParent(NS_CONST_CAST(nsView*, NS_STATIC_CAST(const nsView*, aParent)));
|
||||
|
@ -317,7 +320,6 @@ NS_IMETHODIMP nsView::HandleEvent(nsGUIEvent *event, PRUint32 aEventFlags,
|
|||
|
||||
//see if any of this view's children can process the event
|
||||
if ( !(mVFlags & NS_VIEW_FLAG_DONT_CHECK_CHILDREN) ) {
|
||||
nsRect trect;
|
||||
nscoord x, y;
|
||||
|
||||
x = event->point.x;
|
||||
|
@ -327,7 +329,8 @@ NS_IMETHODIMP nsView::HandleEvent(nsGUIEvent *event, PRUint32 aEventFlags,
|
|||
PRInt32 cnt = 0;
|
||||
while (pKid != nsnull && (!aHandled))
|
||||
{
|
||||
pKid->GetBounds(trect);
|
||||
nscoord tx, ty;
|
||||
pKid->GetPosition(&tx, &ty);
|
||||
|
||||
mChildRemoved = PR_FALSE;
|
||||
if (PointIsInside(*pKid, x, y))
|
||||
|
@ -336,13 +339,13 @@ NS_IMETHODIMP nsView::HandleEvent(nsGUIEvent *event, PRUint32 aEventFlags,
|
|||
//is inside this child view, so give it the
|
||||
//opportunity to handle the event
|
||||
|
||||
event->point.x -= trect.x;
|
||||
event->point.y -= trect.y;
|
||||
event->point.x -= tx;
|
||||
event->point.y -= ty;
|
||||
|
||||
pKid->HandleEvent(event, 0, aStatus, PR_FALSE, aHandled);
|
||||
|
||||
event->point.x += trect.x;
|
||||
event->point.y += trect.y;
|
||||
event->point.x += tx;
|
||||
event->point.y += ty;
|
||||
}
|
||||
|
||||
if (!aHandled) {
|
||||
|
@ -393,13 +396,13 @@ NS_IMETHODIMP nsView::IgnoreSetPosition(PRBool aShouldIgnore)
|
|||
mShouldIgnoreSetPosition = aShouldIgnore;
|
||||
// resync here
|
||||
if (!mShouldIgnoreSetPosition) {
|
||||
SetPosition(mBounds.x, mBounds.y);
|
||||
SetPosition(mPosX, mPosY);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
// XXX End Temporary fix for Bug #19416
|
||||
|
||||
NS_IMETHODIMP nsView::SetPosition(nscoord aX, nscoord aY)
|
||||
void nsView::SetPosition(nscoord aX, nscoord aY)
|
||||
{
|
||||
nscoord x = aX;
|
||||
nscoord y = aY;
|
||||
|
@ -413,11 +416,14 @@ NS_IMETHODIMP nsView::SetPosition(nscoord aX, nscoord aY)
|
|||
x += offsetX;
|
||||
y += offsetY;
|
||||
}
|
||||
mBounds.MoveTo(x, y);
|
||||
mDimBounds.x += aX - mPosX;
|
||||
mDimBounds.y += aY - mPosY;
|
||||
mPosX = aX;
|
||||
mPosY = aY;
|
||||
|
||||
// XXX Start Temporary fix for Bug #19416
|
||||
if (mShouldIgnoreSetPosition) {
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
// XXX End Temporary fix for Bug #19416
|
||||
|
||||
|
@ -430,7 +436,7 @@ NS_IMETHODIMP nsView::SetPosition(nscoord aX, nscoord aY)
|
|||
mViewManager->IsCachingWidgetChanges(&caching);
|
||||
if (caching) {
|
||||
mVFlags |= NS_VIEW_FLAG_WIDGET_MOVED;
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
nsIDeviceContext *dx;
|
||||
|
@ -444,12 +450,10 @@ NS_IMETHODIMP nsView::SetPosition(nscoord aX, nscoord aY)
|
|||
|
||||
GetOffsetFromWidget(&parx, &pary, pwidget);
|
||||
NS_IF_RELEASE(pwidget);
|
||||
|
||||
mWindow->Move(NSTwipsToIntPixels((x + parx), scale),
|
||||
NSTwipsToIntPixels((y + pary), scale));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
mWindow->Move(NSTwipsToIntPixels((mDimBounds.x + parx), scale),
|
||||
NSTwipsToIntPixels((mDimBounds.y + pary), scale));
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsView::SynchWidgetSizePosition()
|
||||
|
@ -478,10 +482,10 @@ NS_IMETHODIMP nsView::SynchWidgetSizePosition()
|
|||
GetOffsetFromWidget(&parx, &pary, pwidget);
|
||||
NS_IF_RELEASE(pwidget);
|
||||
|
||||
PRInt32 x = NSTwipsToIntPixels(mBounds.x + parx, t2p);
|
||||
PRInt32 y = NSTwipsToIntPixels(mBounds.y + pary, t2p);
|
||||
PRInt32 width = NSTwipsToIntPixels(mBounds.width, t2p);
|
||||
PRInt32 height = NSTwipsToIntPixels(mBounds.height, t2p);
|
||||
PRInt32 x = NSTwipsToIntPixels(mDimBounds.x + parx, t2p);
|
||||
PRInt32 y = NSTwipsToIntPixels(mDimBounds.y + pary, t2p);
|
||||
PRInt32 width = NSTwipsToIntPixels(mDimBounds.width, t2p);
|
||||
PRInt32 height = NSTwipsToIntPixels(mDimBounds.height, t2p);
|
||||
|
||||
nsRect bounds;
|
||||
mWindow->GetBounds(bounds);
|
||||
|
@ -490,7 +494,6 @@ NS_IMETHODIMP nsView::SynchWidgetSizePosition()
|
|||
else if (bounds.width == width && bounds.height == bounds.height)
|
||||
mVFlags &= ~NS_VIEW_FLAG_WIDGET_RESIZED;
|
||||
else {
|
||||
printf("%d) SetBounds(%d,%d,%d,%d)\n", this, x, y, width, height);
|
||||
mWindow->Resize(x,y,width,height, PR_TRUE);
|
||||
mVFlags &= ~NS_VIEW_FLAG_WIDGET_RESIZED;
|
||||
mVFlags &= ~NS_VIEW_FLAG_WIDGET_MOVED;
|
||||
|
@ -502,8 +505,8 @@ NS_IMETHODIMP nsView::SynchWidgetSizePosition()
|
|||
if (mVFlags & NS_VIEW_FLAG_WIDGET_RESIZED)
|
||||
{
|
||||
|
||||
PRInt32 width = NSTwipsToIntPixels(mBounds.width, t2p);
|
||||
PRInt32 height = NSTwipsToIntPixels(mBounds.height, t2p);
|
||||
PRInt32 width = NSTwipsToIntPixels(mDimBounds.width, t2p);
|
||||
PRInt32 height = NSTwipsToIntPixels(mDimBounds.height, t2p);
|
||||
|
||||
nsRect bounds;
|
||||
mWindow->GetBounds(bounds);
|
||||
|
@ -526,8 +529,8 @@ NS_IMETHODIMP nsView::SynchWidgetSizePosition()
|
|||
GetOffsetFromWidget(&parx, &pary, pwidget);
|
||||
NS_IF_RELEASE(pwidget);
|
||||
|
||||
PRInt32 x = NSTwipsToIntPixels(mBounds.x + parx, t2p);
|
||||
PRInt32 y = NSTwipsToIntPixels(mBounds.y + pary, t2p);
|
||||
PRInt32 x = NSTwipsToIntPixels(mDimBounds.x + parx, t2p);
|
||||
PRInt32 y = NSTwipsToIntPixels(mDimBounds.y + pary, t2p);
|
||||
|
||||
nsRect bounds;
|
||||
mWindow->GetBounds(bounds);
|
||||
|
@ -557,8 +560,8 @@ NS_IMETHODIMP nsView::GetPosition(nscoord *x, nscoord *y) const
|
|||
else
|
||||
{
|
||||
|
||||
*x = mBounds.x;
|
||||
*y = mBounds.y;
|
||||
*x = mPosX;
|
||||
*y = mPosY;
|
||||
|
||||
}
|
||||
|
||||
|
@ -566,77 +569,53 @@ NS_IMETHODIMP nsView::GetPosition(nscoord *x, nscoord *y) const
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsView::SetDimensions(nscoord width, nscoord height, PRBool aPaint)
|
||||
void nsView::SetDimensions(const nsRect& aRect, PRBool aPaint)
|
||||
{
|
||||
if ((mBounds.width == width) &&
|
||||
(mBounds.height == height))
|
||||
return NS_OK;
|
||||
|
||||
mBounds.SizeTo(width, height);
|
||||
nsRect dims = aRect;
|
||||
dims.MoveBy(mPosX, mPosY);
|
||||
|
||||
#if 0
|
||||
if (nsnull != mParent)
|
||||
{
|
||||
nsIScrollableView *scroller;
|
||||
|
||||
static NS_DEFINE_IID(kscroller, NS_ISCROLLABLEVIEW_IID);
|
||||
|
||||
// XXX The scrolled view is a child of the clip view which is a child of
|
||||
// the scrolling view. It's kind of yucky the way this works. A parent
|
||||
// notification that the child's size changed would be cleaner.
|
||||
nsIView *grandParent;
|
||||
mParent->GetParent(grandParent);
|
||||
if ((nsnull != grandParent) &&
|
||||
(NS_OK == grandParent->QueryInterface(kscroller, (void **)&scroller)))
|
||||
{
|
||||
scroller->ComputeContainerSize();
|
||||
}
|
||||
if (mDimBounds.x == dims.x && mDimBounds.y == dims.y && mDimBounds.width == dims.width
|
||||
&& mDimBounds.height == dims.height) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (nsnull != mWindow)
|
||||
|
||||
if (nsnull == mWindow)
|
||||
{
|
||||
mDimBounds = dims;
|
||||
}
|
||||
else
|
||||
{
|
||||
PRBool needToMoveWidget = mDimBounds.x != dims.x || mDimBounds.y != dims.y;
|
||||
|
||||
mDimBounds = dims;
|
||||
|
||||
PRBool caching = PR_FALSE;
|
||||
mViewManager->IsCachingWidgetChanges(&caching);
|
||||
if (caching) {
|
||||
mVFlags |= NS_VIEW_FLAG_WIDGET_RESIZED;
|
||||
return NS_OK;
|
||||
mVFlags |= NS_VIEW_FLAG_WIDGET_RESIZED | (needToMoveWidget ? NS_VIEW_FLAG_WIDGET_MOVED : 0);
|
||||
return;
|
||||
}
|
||||
|
||||
nsIDeviceContext *dx;
|
||||
float t2p;
|
||||
nsIWidget *pwidget = nsnull;
|
||||
nscoord parx = 0, pary = 0;
|
||||
|
||||
mViewManager->GetDeviceContext(dx);
|
||||
dx->GetAppUnitsToDevUnits(t2p);
|
||||
|
||||
mWindow->Resize(NSTwipsToIntPixels(width, t2p), NSTwipsToIntPixels(height, t2p),
|
||||
GetOffsetFromWidget(&parx, &pary, pwidget);
|
||||
NS_IF_RELEASE(pwidget);
|
||||
|
||||
if (needToMoveWidget) {
|
||||
mWindow->Move(NSTwipsToIntPixels((mDimBounds.x + parx), t2p),
|
||||
NSTwipsToIntPixels((mDimBounds.y + pary), t2p));
|
||||
}
|
||||
mWindow->Resize(NSTwipsToIntPixels(mDimBounds.width, t2p), NSTwipsToIntPixels(mDimBounds.height, t2p),
|
||||
aPaint);
|
||||
|
||||
NS_RELEASE(dx);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsView::GetDimensions(nscoord *width, nscoord *height) const
|
||||
{
|
||||
*width = mBounds.width;
|
||||
*height = mBounds.height;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsView::SetBounds(const nsRect &aBounds, PRBool aPaint)
|
||||
{
|
||||
SetPosition(aBounds.x, aBounds.y);
|
||||
SetDimensions(aBounds.width, aBounds.height, aPaint);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsView::SetBounds(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, PRBool aPaint)
|
||||
{
|
||||
SetPosition(aX, aY);
|
||||
SetDimensions(aWidth, aHeight, aPaint);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsView::GetBounds(nsRect &aBounds) const
|
||||
|
@ -648,7 +627,7 @@ NS_IMETHODIMP nsView::GetBounds(nsRect &aBounds) const
|
|||
}
|
||||
|
||||
nsView *rootView = mViewManager->GetRootView();
|
||||
aBounds = mBounds;
|
||||
aBounds = mDimBounds;
|
||||
|
||||
if (this == rootView)
|
||||
aBounds.x = aBounds.y = 0;
|
||||
|
@ -872,7 +851,7 @@ NS_IMETHODIMP nsView::CreateWidget(const nsIID &aWindowIID,
|
|||
PRBool aResetVisibility)
|
||||
{
|
||||
nsIDeviceContext *dx;
|
||||
nsRect trect = mBounds;
|
||||
nsRect trect = mDimBounds;
|
||||
float scale;
|
||||
|
||||
NS_IF_RELEASE(mWindow);
|
||||
|
@ -1044,17 +1023,18 @@ NS_IMETHODIMP nsView::GetOffsetFromWidget(nscoord *aDx, nscoord *aDy, nsIWidget
|
|||
while (nsnull != ancestor)
|
||||
{
|
||||
ancestor->GetWidget(aWidget);
|
||||
if (nsnull != aWidget)
|
||||
if (nsnull != aWidget) {
|
||||
// the widget's (0,0) is at the top left of the view's bounds, NOT its position
|
||||
nsRect r;
|
||||
ancestor->GetDimensions(r);
|
||||
aDx -= r.x;
|
||||
aDy -= r.y;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if ((nsnull != aDx) && (nsnull != aDy))
|
||||
{
|
||||
nscoord offx, offy;
|
||||
|
||||
ancestor->GetPosition(&offx, &offy);
|
||||
|
||||
*aDx += offx;
|
||||
*aDy += offy;
|
||||
ancestor->ConvertToParentCoords(aDx, aDy);
|
||||
}
|
||||
|
||||
ancestor = ancestor->GetParent();
|
||||
|
@ -1173,10 +1153,7 @@ NS_IMETHODIMP nsView::GetClippedRect(nsRect& aClippedRect, PRBool& aIsClipped, P
|
|||
}
|
||||
}
|
||||
|
||||
nsRect bounds;
|
||||
parentView->GetBounds(bounds);
|
||||
ancestorX -= bounds.x;
|
||||
ancestorY -= bounds.y;
|
||||
parentView->ConvertFromParentCoords(&ancestorX, &ancestorY);
|
||||
|
||||
parentView = parentView->GetParent();
|
||||
}
|
||||
|
|
|
@ -172,30 +172,16 @@ public:
|
|||
* @param x new x position
|
||||
* @param y new y position
|
||||
*/
|
||||
NS_IMETHOD SetPosition(nscoord x, nscoord y);
|
||||
virtual void SetPosition(nscoord aX, nscoord aY);
|
||||
/**
|
||||
* Called to indicate that the dimensions of the view (actually the
|
||||
* width and height of the clip) have been changed.
|
||||
* @param width new width
|
||||
* @param height new height
|
||||
* Called to indicate that the dimensions of the view have been changed.
|
||||
* The x and y coordinates may be < 0, indicating that the view extends above
|
||||
* or to the left of its origin position.
|
||||
*/
|
||||
NS_IMETHOD SetDimensions(nscoord width, nscoord height, PRBool aPaint = PR_TRUE);
|
||||
NS_IMETHOD GetDimensions(nscoord *width, nscoord *height) const;
|
||||
/**
|
||||
* Called to indicate that the dimensions and position of the view have
|
||||
* been changed.
|
||||
* @param aBounds new bounds
|
||||
*/
|
||||
NS_IMETHOD SetBounds(const nsRect &aBounds, PRBool aPaint = PR_TRUE);
|
||||
/**
|
||||
* Called to indicate that the dimensions and position of the view have
|
||||
* been changed.
|
||||
* @param aX new x position
|
||||
* @param aY new y position
|
||||
* @param aWidth new width
|
||||
* @param aHeight new height
|
||||
*/
|
||||
NS_IMETHOD SetBounds(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, PRBool aPaint = PR_TRUE);
|
||||
virtual void SetDimensions(const nsRect &aRect, PRBool aPaint = PR_TRUE);
|
||||
void GetDimensions(nsRect &aRect) const { aRect = mDimBounds; aRect.x -= mPosX; aRect.y -= mPosY; }
|
||||
void GetDimensions(nsSize &aSize) const { aSize.width = mDimBounds.width; aSize.height = mDimBounds.height; }
|
||||
|
||||
/**
|
||||
* Called to set the clip of the children of this view.
|
||||
* The clip is relative to the origin of the view.
|
||||
|
@ -341,6 +327,9 @@ public: // NOT in nsIView, so only available in view module
|
|||
|
||||
PRUint32 GetViewFlags() const { return mVFlags; }
|
||||
|
||||
void ConvertToParentCoords(nscoord* aX, nscoord* aY) { *aX += mPosX; *aY += mPosY; }
|
||||
void ConvertFromParentCoords(nscoord* aX, nscoord* aY) { *aX -= mPosX; *aY -= mPosY; }
|
||||
|
||||
protected:
|
||||
virtual ~nsView();
|
||||
//
|
||||
|
@ -360,7 +349,8 @@ protected:
|
|||
PRInt32 mZIndex;
|
||||
nsViewVisibility mVis;
|
||||
PRInt32 mNumKids;
|
||||
nsRect mBounds;
|
||||
nscoord mPosX, mPosY;
|
||||
nsRect mDimBounds; // relative to parent
|
||||
nsViewClip mChildClip;
|
||||
float mOpacity;
|
||||
PRUint32 mVFlags;
|
||||
|
|
|
@ -558,28 +558,34 @@ NS_IMETHODIMP nsViewManager::SetWindowOffset(nscoord aX, nscoord aY)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsViewManager::GetWindowDimensions(nscoord *width, nscoord *height)
|
||||
NS_IMETHODIMP nsViewManager::GetWindowDimensions(nscoord *aWidth, nscoord *aHeight)
|
||||
{
|
||||
if (nsnull != mRootView)
|
||||
mRootView->GetDimensions(width, height);
|
||||
if (nsnull != mRootView) {
|
||||
nsRect dim;
|
||||
mRootView->GetDimensions(dim);
|
||||
*aWidth = dim.width;
|
||||
*aHeight = dim.height;
|
||||
}
|
||||
else
|
||||
{
|
||||
*width = 0;
|
||||
*height = 0;
|
||||
*aWidth = 0;
|
||||
*aHeight = 0;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsViewManager::SetWindowDimensions(nscoord width, nscoord height)
|
||||
NS_IMETHODIMP nsViewManager::SetWindowDimensions(nscoord aWidth, nscoord aHeight)
|
||||
{
|
||||
// Resize the root view
|
||||
if (nsnull != mRootView)
|
||||
mRootView->SetDimensions(width, height);
|
||||
if (nsnull != mRootView) {
|
||||
nsRect dim(0, 0, aWidth, aHeight);
|
||||
mRootView->SetDimensions(dim);
|
||||
}
|
||||
|
||||
//printf("new dims: %d %d\n", width, height);
|
||||
//printf("new dims: %d %d\n", aWidth, aHeight);
|
||||
// Inform the presentation shell that we've been resized
|
||||
if (nsnull != mObserver)
|
||||
mObserver->ResizeReflow(mRootView, width, height);
|
||||
mObserver->ResizeReflow(mRootView, aWidth, aHeight);
|
||||
//printf("reflow done\n");
|
||||
|
||||
return NS_OK;
|
||||
|
@ -678,8 +684,7 @@ void nsViewManager::Refresh(nsView *aView, nsIRenderingContext *aContext, nsIReg
|
|||
}
|
||||
|
||||
nsRect viewRect;
|
||||
aView->GetBounds(viewRect);
|
||||
viewRect.x = viewRect.y = 0;
|
||||
aView->GetDimensions(viewRect);
|
||||
|
||||
nsRect damageRect = damageRectInPixels;
|
||||
nsRect paintRect;
|
||||
|
@ -687,6 +692,10 @@ void nsViewManager::Refresh(nsView *aView, nsIRenderingContext *aContext, nsIReg
|
|||
mContext->GetDevUnitsToAppUnits(p2t);
|
||||
damageRect.ScaleRoundOut(p2t);
|
||||
|
||||
// move the view rect into widget coordinates
|
||||
viewRect.x = 0;
|
||||
viewRect.y = 0;
|
||||
|
||||
if (paintRect.IntersectRect(damageRect, viewRect)) {
|
||||
|
||||
if ((aUpdateFlags & NS_VMREFRESH_DOUBLE_BUFFER) && ds) {
|
||||
|
@ -696,9 +705,22 @@ void nsViewManager::Refresh(nsView *aView, nsIRenderingContext *aContext, nsIReg
|
|||
}
|
||||
|
||||
PRBool result;
|
||||
// Note that nsIRenderingContext::SetClipRegion always works in pixel coordinates,
|
||||
// and nsIRenderingContext::SetClipRect always works in app coordinates. Stupid huh?
|
||||
localcx->SetClipRegion(*aRegion, nsClipCombine_kReplace, result);
|
||||
localcx->SetClipRect(paintRect, nsClipCombine_kIntersect, result);
|
||||
RenderViews(aView, *localcx, paintRect, result);
|
||||
|
||||
// pass in a damage rectangle in aView's coordinates.
|
||||
nsRect r = paintRect;
|
||||
nsRect dims;
|
||||
aView->GetDimensions(dims);
|
||||
r.x += dims.x;
|
||||
r.y += dims.y;
|
||||
|
||||
// painting will be done in aView's coordinates, so shift them back to widget coordinates
|
||||
localcx->Translate(-dims.x, -dims.y);
|
||||
RenderViews(aView, *localcx, r, result);
|
||||
localcx->Translate(dims.x, dims.y);
|
||||
|
||||
if ((aUpdateFlags & NS_VMREFRESH_DOUBLE_BUFFER) && ds) {
|
||||
// Setup the region relative to the destination's coordinates
|
||||
|
@ -998,11 +1020,7 @@ void nsViewManager::AddCoveringWidgetsToOpaqueRegion(nsIRegion* aRgn, nsIDeviceC
|
|||
nsView* viewParent = view->GetParent();
|
||||
|
||||
while (viewParent && viewParent != aRootView) {
|
||||
nsRect parentBounds;
|
||||
|
||||
viewParent->GetBounds(parentBounds);
|
||||
bounds.x += parentBounds.x;
|
||||
bounds.y += parentBounds.y;
|
||||
viewParent->ConvertToParentCoords(&bounds.x, &bounds.y);
|
||||
viewParent = viewParent->GetParent();
|
||||
}
|
||||
|
||||
|
@ -1049,9 +1067,6 @@ void nsViewManager::RenderViews(nsView *aRootView, nsIRenderingContext& aRC, con
|
|||
break;
|
||||
}
|
||||
displayRoot = displayParent;
|
||||
|
||||
nsRect bounds;
|
||||
displayRoot->GetBounds(bounds);
|
||||
}
|
||||
|
||||
DisplayZTreeNode *zTree;
|
||||
|
@ -1145,7 +1160,7 @@ void nsViewManager::RenderViews(nsView *aRootView, nsIRenderingContext& aRC, con
|
|||
//mOffScreenCX->SetColor(NS_RGB(0, 255, 0));
|
||||
//mOffScreenCX->FillRect(nsRect(0, 0, gOffScreenSize.width, gOffScreenSize.height));
|
||||
}
|
||||
|
||||
|
||||
// draw all views in the display list, from back to front.
|
||||
for (PRInt32 i = 0; i < mDisplayListCount; i++) {
|
||||
DisplayListElement2* element = NS_STATIC_CAST(DisplayListElement2*, mDisplayList.ElementAt(i));
|
||||
|
@ -1199,37 +1214,19 @@ void nsViewManager::RenderViews(nsView *aRootView, nsIRenderingContext& aRC, con
|
|||
}
|
||||
}
|
||||
|
||||
void nsViewManager::RenderView(nsView *aView, nsIRenderingContext &aRC, const nsRect &aDamageRect,
|
||||
nsRect &aGlobalRect, PRBool &aResult)
|
||||
{
|
||||
nsRect drect;
|
||||
|
||||
NS_ASSERTION((nsnull != aView), "no view");
|
||||
|
||||
aRC.PushState();
|
||||
|
||||
aRC.Translate(aGlobalRect.x, aGlobalRect.y);
|
||||
|
||||
drect.IntersectRect(aDamageRect, aGlobalRect);
|
||||
|
||||
drect.x -= aGlobalRect.x;
|
||||
drect.y -= aGlobalRect.y;
|
||||
|
||||
// should use blender here if opacity < 1.0
|
||||
|
||||
aView->Paint(aRC, drect, 0, aResult);
|
||||
|
||||
aRC.PopState(aResult);
|
||||
}
|
||||
|
||||
void nsViewManager::RenderDisplayListElement(DisplayListElement2* element, nsIRenderingContext &aRC)
|
||||
{
|
||||
PRBool isTranslucent = (element->mFlags & VIEW_TRANSLUCENT) != 0;
|
||||
PRBool clipEmpty;
|
||||
nsRect r;
|
||||
nsView* view = element->mView;
|
||||
|
||||
view->GetDimensions(r);
|
||||
|
||||
if (!isTranslucent) {
|
||||
aRC.PushState();
|
||||
|
||||
nscoord x = element->mAbsX, y = element->mAbsY;
|
||||
nscoord x = element->mAbsX - r.x, y = element->mAbsY - r.y;
|
||||
aRC.Translate(x, y);
|
||||
|
||||
nsRect drect(element->mBounds.x - x, element->mBounds.y - y,
|
||||
|
@ -1248,7 +1245,7 @@ void nsViewManager::RenderDisplayListElement(DisplayListElement2* element, nsIRe
|
|||
|
||||
// compute the origin of the view, relative to the offscreen buffer, which has the
|
||||
// same dimensions as mTranslucentArea.
|
||||
nscoord x = element->mAbsX, y = element->mAbsY;
|
||||
nscoord x = element->mAbsX - r.x, y = element->mAbsY - r.y;
|
||||
nscoord viewX = x - mTranslucentArea.x, viewY = y - mTranslucentArea.y;
|
||||
|
||||
nsRect damageRect(element->mBounds);
|
||||
|
@ -1257,8 +1254,6 @@ void nsViewManager::RenderDisplayListElement(DisplayListElement2* element, nsIRe
|
|||
damageRect.x -= x, damageRect.y -= y;
|
||||
|
||||
if (element->mFlags & VIEW_TRANSLUCENT) {
|
||||
nsView* view = element->mView;
|
||||
|
||||
// paint the view twice, first in the black buffer, then the white;
|
||||
// the blender will pick up the touched pixels only.
|
||||
PaintView(view, *mBlackCX, viewX, viewY, damageRect);
|
||||
|
@ -1300,7 +1295,7 @@ void nsViewManager::RenderDisplayListElement(DisplayListElement2* element, nsIRe
|
|||
mWhiteCX->SetColor(NS_RGB(255, 255, 255));
|
||||
mWhiteCX->FillRect(damageRect);
|
||||
} else {
|
||||
PaintView(element->mView, *mOffScreenCX, viewX, viewY, damageRect);
|
||||
PaintView(view, *mOffScreenCX, viewX, viewY, damageRect);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -1480,7 +1475,7 @@ NS_IMETHODIMP nsViewManager::UpdateView(nsIView *aView, PRUint32 aUpdateFlags)
|
|||
|
||||
nsRect bounds;
|
||||
view->GetBounds(bounds);
|
||||
bounds.x = bounds.y = 0;
|
||||
view->ConvertFromParentCoords(&bounds.x, &bounds.y);
|
||||
return UpdateView(view, bounds, aUpdateFlags);
|
||||
}
|
||||
|
||||
|
@ -1494,14 +1489,15 @@ nsViewManager::UpdateViewAfterScroll(nsIView *aView, PRInt32 aDX, PRInt32 aDY)
|
|||
nsPoint origin(0, 0);
|
||||
ComputeViewOffset(view, &origin);
|
||||
nsRect damageRect;
|
||||
aView->GetBounds(damageRect);
|
||||
damageRect.x = origin.x;
|
||||
damageRect.y = origin.y;
|
||||
view->GetBounds(damageRect);
|
||||
view->ConvertFromParentCoords(&damageRect.x, &damageRect.y);
|
||||
damageRect.x += origin.x;
|
||||
damageRect.y += origin.y;
|
||||
|
||||
// if this is a floating view, it isn't covered by any widgets other than
|
||||
// its children, which are handled by the widget scroller.
|
||||
PRBool viewIsFloating = PR_FALSE;
|
||||
aView->GetFloating(viewIsFloating);
|
||||
view->GetFloating(viewIsFloating);
|
||||
if (viewIsFloating) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1524,8 +1520,7 @@ PRBool nsViewManager::UpdateAllCoveringWidgets(nsView *aView, nsView *aTarget,
|
|||
|
||||
nsRect bounds;
|
||||
aView->GetBounds(bounds);
|
||||
bounds.x = 0; // aDamagedRect is already in this view's coordinate system
|
||||
bounds.y = 0;
|
||||
aView->ConvertFromParentCoords(&bounds.x, &bounds.y);
|
||||
PRBool overlap = bounds.IntersectRect(bounds, aDamagedRect);
|
||||
|
||||
if (!overlap) {
|
||||
|
@ -1549,10 +1544,7 @@ PRBool nsViewManager::UpdateAllCoveringWidgets(nsView *aView, nsView *aTarget,
|
|||
PRBool childCovers = PR_FALSE;
|
||||
while (nsnull != childView) {
|
||||
nsRect childRect = bounds;
|
||||
nsRect childBounds;
|
||||
childView->GetBounds(childBounds);
|
||||
childRect.x -= childBounds.x;
|
||||
childRect.y -= childBounds.y;
|
||||
childView->ConvertFromParentCoords(&childRect.x, &childRect.y);
|
||||
if (UpdateAllCoveringWidgets(childView, aTarget, childRect, aRepaintOnlyUnblittableViews)) {
|
||||
childCovers = PR_TRUE;
|
||||
// we can't stop here. We're not making any assumptions about how the child
|
||||
|
@ -1640,10 +1632,7 @@ NS_IMETHODIMP nsViewManager::UpdateView(nsIView *aView, const nsRect &aRect, PRU
|
|||
widgetParent->HasWidget(&hasWidget);
|
||||
|
||||
while (!hasWidget) {
|
||||
nsRect bounds;
|
||||
widgetParent->GetBounds(bounds);
|
||||
damagedRect.x += bounds.x;
|
||||
damagedRect.y += bounds.y;
|
||||
widgetParent->ConvertToParentCoords(&damagedRect.x, &damagedRect.y);
|
||||
|
||||
widgetParent = widgetParent->GetParent();
|
||||
widgetParent->HasWidget(&hasWidget);
|
||||
|
@ -1731,7 +1720,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS
|
|||
case NS_PAINT:
|
||||
{
|
||||
nsView *view = nsView::GetViewFor(aEvent->widget);
|
||||
|
||||
|
||||
if (nsnull != view)
|
||||
{
|
||||
// Do an immediate refresh
|
||||
|
@ -1843,7 +1832,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS
|
|||
|
||||
//Find the view whose coordinates system we're in.
|
||||
baseView = nsView::GetViewFor(aEvent->widget);
|
||||
|
||||
|
||||
//Find the view to which we're initially going to send the event
|
||||
//for hittesting.
|
||||
if (nsnull != mMouseGrabber && (NS_IS_MOUSE_EVENT(aEvent) || (NS_IS_DRAG_EVENT(aEvent)))) {
|
||||
|
@ -1866,39 +1855,39 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS
|
|||
if (baseView != view) {
|
||||
//Get offset from root of baseView
|
||||
nsView *parent;
|
||||
nsRect bounds;
|
||||
|
||||
parent = baseView;
|
||||
while (nsnull != parent) {
|
||||
parent->GetBounds(bounds);
|
||||
offset.x += bounds.x;
|
||||
offset.y += bounds.y;
|
||||
parent->ConvertToParentCoords(&offset.x, &offset.y);
|
||||
parent = parent->GetParent();
|
||||
}
|
||||
|
||||
//Subtract back offset from root of view
|
||||
parent = view;
|
||||
while (nsnull != parent) {
|
||||
parent->GetBounds(bounds);
|
||||
offset.x -= bounds.x;
|
||||
offset.y -= bounds.y;
|
||||
parent->ConvertFromParentCoords(&offset.x, &offset.y);
|
||||
parent = parent->GetParent();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Dispatch the event
|
||||
float p2t, t2p;
|
||||
|
||||
mContext->GetDevUnitsToAppUnits(p2t);
|
||||
mContext->GetAppUnitsToDevUnits(t2p);
|
||||
|
||||
//Before we start mucking with coords, make sure we know our baseline
|
||||
aEvent->refPoint.x = aEvent->point.x;
|
||||
aEvent->refPoint.y = aEvent->point.y;
|
||||
|
||||
aEvent->point.x = NSIntPixelsToTwips(aEvent->point.x, p2t);
|
||||
aEvent->point.y = NSIntPixelsToTwips(aEvent->point.y, p2t);
|
||||
nsRect baseViewDimensions;
|
||||
if (baseView != nsnull) {
|
||||
baseView->GetDimensions(baseViewDimensions);
|
||||
}
|
||||
|
||||
float t2p;
|
||||
mContext->GetAppUnitsToDevUnits(t2p);
|
||||
float p2t;
|
||||
mContext->GetDevUnitsToAppUnits(p2t);
|
||||
|
||||
aEvent->point.x = baseViewDimensions.x + NSIntPixelsToTwips(aEvent->point.x, p2t);
|
||||
aEvent->point.y = baseViewDimensions.y + NSIntPixelsToTwips(aEvent->point.y, p2t);
|
||||
|
||||
aEvent->point.x += offset.x;
|
||||
aEvent->point.y += offset.y;
|
||||
|
@ -1906,11 +1895,13 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS
|
|||
PRBool handled = PR_FALSE;
|
||||
view->HandleEvent(aEvent, 0, aStatus, PR_TRUE, handled);
|
||||
|
||||
// From here on out, "this" could have been deleted!!!
|
||||
|
||||
aEvent->point.x -= offset.x;
|
||||
aEvent->point.y -= offset.y;
|
||||
|
||||
aEvent->point.x = NSTwipsToIntPixels(aEvent->point.x, t2p);
|
||||
aEvent->point.y = NSTwipsToIntPixels(aEvent->point.y, t2p);
|
||||
aEvent->point.x = NSTwipsToIntPixels(aEvent->point.x - baseViewDimensions.x, t2p);
|
||||
aEvent->point.y = NSTwipsToIntPixels(aEvent->point.y - baseViewDimensions.y, t2p);
|
||||
|
||||
//
|
||||
// if the event is an nsTextEvent, we need to map the reply back into platform coordinates
|
||||
|
@ -2156,7 +2147,9 @@ NS_IMETHODIMP nsViewManager::MoveViewTo(nsIView *aView, nscoord aX, nscoord aY)
|
|||
{
|
||||
nscoord oldX, oldY;
|
||||
nsView* view = NS_STATIC_CAST(nsView*, aView);
|
||||
nsRect oldArea;
|
||||
view->GetPosition(&oldX, &oldY);
|
||||
view->GetBounds(oldArea);
|
||||
view->SetPosition(aX, aY);
|
||||
|
||||
// only do damage control if the view is visible
|
||||
|
@ -2165,32 +2158,55 @@ NS_IMETHODIMP nsViewManager::MoveViewTo(nsIView *aView, nscoord aX, nscoord aY)
|
|||
nsViewVisibility visibility;
|
||||
view->GetVisibility(visibility);
|
||||
if (visibility != nsViewVisibility_kHide) {
|
||||
nsRect bounds;
|
||||
view->GetBounds(bounds);
|
||||
nsRect oldArea(oldX, oldY, bounds.width, bounds.height);
|
||||
nsView* parentView = view->GetParent();
|
||||
UpdateView(parentView, oldArea, NS_VMREFRESH_NO_SYNC);
|
||||
nsRect newArea(aX, aY, bounds.width, bounds.height);
|
||||
nsRect newArea;
|
||||
view->GetBounds(newArea);
|
||||
UpdateView(parentView, newArea, NS_VMREFRESH_NO_SYNC);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsViewManager::InvalidateHorizontalBandDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut,
|
||||
PRUint32 aUpdateFlags, nscoord aY1, nscoord aY2, PRBool aInCutOut) {
|
||||
nscoord height = aY2 - aY1;
|
||||
if (aRect.x < aCutOut.x) {
|
||||
nsRect r(aRect.x, aY1, aCutOut.x - aRect.x, height);
|
||||
UpdateView(aView, r, aUpdateFlags);
|
||||
}
|
||||
if (!aInCutOut && aCutOut.x < aCutOut.XMost()) {
|
||||
nsRect r(aCutOut.x, aY1, aCutOut.width, height);
|
||||
UpdateView(aView, r, aUpdateFlags);
|
||||
}
|
||||
if (aCutOut.XMost() < aRect.XMost()) {
|
||||
nsRect r(aCutOut.XMost(), aY1, aRect.XMost() - aCutOut.XMost(), height);
|
||||
UpdateView(aView, r, aUpdateFlags);
|
||||
}
|
||||
}
|
||||
|
||||
void nsViewManager::InvalidateRectDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut,
|
||||
PRUint32 aUpdateFlags) {
|
||||
if (aRect.y < aCutOut.y) {
|
||||
InvalidateHorizontalBandDifference(aView, aRect, aCutOut, aUpdateFlags, aRect.y, aCutOut.y, PR_FALSE);
|
||||
}
|
||||
if (aCutOut.y < aCutOut.YMost()) {
|
||||
InvalidateHorizontalBandDifference(aView, aRect, aCutOut, aUpdateFlags, aCutOut.y, aCutOut.YMost(), PR_TRUE);
|
||||
}
|
||||
if (aCutOut.YMost() < aRect.YMost()) {
|
||||
InvalidateHorizontalBandDifference(aView, aRect, aCutOut, aUpdateFlags, aCutOut.YMost(), aRect.YMost(), PR_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsViewManager::ResizeView(nsIView *aView, const nsRect &aRect, PRBool aRepaintExposedAreaOnly)
|
||||
{
|
||||
nscoord oldWidth, oldHeight;
|
||||
nsView* view = NS_STATIC_CAST(nsView*, aView);
|
||||
PRInt32 width = aRect.XMost();
|
||||
PRInt32 height = aRect.YMost();
|
||||
nsRect oldDimensions;
|
||||
|
||||
view->GetDimensions(&oldWidth, &oldHeight);
|
||||
if ((width != oldWidth) || (height != oldHeight)) {
|
||||
nscoord x = 0, y = 0;
|
||||
view->GetDimensions(oldDimensions);
|
||||
if (oldDimensions != aRect) {
|
||||
nsView* parentView = view->GetParent();
|
||||
if (parentView != nsnull)
|
||||
view->GetPosition(&x, &y);
|
||||
else
|
||||
if (parentView == nsnull)
|
||||
parentView = view;
|
||||
|
||||
// resize the view.
|
||||
|
@ -2199,54 +2215,23 @@ NS_IMETHODIMP nsViewManager::ResizeView(nsIView *aView, const nsRect &aRect, PRB
|
|||
|
||||
// Prevent Invalidation of hidden views
|
||||
if (visibility == nsViewVisibility_kHide) {
|
||||
view->SetDimensions(width, height, PR_FALSE);
|
||||
view->SetDimensions(aRect, PR_FALSE);
|
||||
} else {
|
||||
if (!aRepaintExposedAreaOnly) {
|
||||
//Invalidate the union of the old and new size
|
||||
view->SetDimensions(width, height, PR_TRUE);
|
||||
nscoord maxWidth = (oldWidth < width ? width : oldWidth);
|
||||
nscoord maxHeight = (oldHeight < height ? height : oldHeight);
|
||||
nsRect boundingArea(x, y, maxWidth, maxHeight);
|
||||
UpdateView(parentView, boundingArea, NS_VMREFRESH_NO_SYNC);
|
||||
view->SetDimensions(aRect, PR_TRUE);
|
||||
|
||||
UpdateView(parentView, oldDimensions, NS_VMREFRESH_NO_SYNC);
|
||||
nsRect r = aRect;
|
||||
view->ConvertFromParentCoords(&r.x, &r.y);
|
||||
UpdateView(view, r, NS_VMREFRESH_NO_SYNC);
|
||||
} else {
|
||||
// Invalidate only the newly exposed or contracted region
|
||||
nscoord shortWidth, longWidth, shortHeight, longHeight;
|
||||
if (width < oldWidth) {
|
||||
shortWidth = width;
|
||||
longWidth = oldWidth;
|
||||
}
|
||||
else {
|
||||
shortWidth = oldWidth;
|
||||
longWidth = width;
|
||||
}
|
||||
|
||||
if (height < oldHeight) {
|
||||
shortHeight = height;
|
||||
longHeight = oldHeight;
|
||||
}
|
||||
else {
|
||||
shortHeight = oldHeight;
|
||||
longHeight = height;
|
||||
}
|
||||
|
||||
nsRect damageRect;
|
||||
|
||||
//damage the right edge of the parent's view
|
||||
damageRect.x = x + shortWidth;
|
||||
damageRect.y = y;
|
||||
damageRect.width = longWidth - shortWidth;
|
||||
damageRect.height = longHeight;
|
||||
UpdateView(parentView, damageRect, NS_VMREFRESH_NO_SYNC);
|
||||
|
||||
//damage the bottom edge of the parent's view
|
||||
damageRect.x = x;
|
||||
damageRect.y = y + shortHeight;
|
||||
damageRect.width = longWidth;
|
||||
damageRect.height = longHeight - shortHeight;
|
||||
UpdateView(parentView, damageRect, NS_VMREFRESH_NO_SYNC);
|
||||
|
||||
|
||||
view->SetDimensions(width, height);
|
||||
view->SetDimensions(aRect, PR_FALSE);
|
||||
InvalidateRectDifference(parentView, oldDimensions, aRect, NS_VMREFRESH_NO_SYNC);
|
||||
nsRect r = aRect;
|
||||
view->ConvertFromParentCoords(&r.x, &r.y);
|
||||
view->ConvertFromParentCoords(&oldDimensions.x, &oldDimensions.y);
|
||||
InvalidateRectDifference(view, r, oldDimensions, NS_VMREFRESH_NO_SYNC);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2530,7 +2515,7 @@ nsIRenderingContext * nsViewManager::CreateRenderingContext(nsView &aView)
|
|||
nsView *par = &aView;
|
||||
nsCOMPtr<nsIWidget> win;
|
||||
nsIRenderingContext *cx = nsnull;
|
||||
nscoord x, y, ax = 0, ay = 0;
|
||||
nscoord ax = 0, ay = 0;
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -2546,10 +2531,7 @@ nsIRenderingContext * nsViewManager::CreateRenderingContext(nsView &aView)
|
|||
|
||||
if (par != &aView)
|
||||
{
|
||||
par->GetPosition(&x, &y);
|
||||
|
||||
ax += x;
|
||||
ay += y;
|
||||
par->ConvertToParentCoords(&ax, &ay);
|
||||
}
|
||||
|
||||
par = par->GetParent();
|
||||
|
@ -2716,12 +2698,12 @@ NS_IMETHODIMP nsViewManager::Display(nsIView* aView, nscoord aX, nscoord aY, con
|
|||
}
|
||||
|
||||
view->GetBounds(trect);
|
||||
view->ConvertFromParentCoords(&trect.x, &trect.y);
|
||||
|
||||
localcx->Translate(aX, aY);
|
||||
|
||||
PRBool result;
|
||||
|
||||
trect.x = trect.y = 0;
|
||||
localcx->SetClipRect(aClipRect, nsClipCombine_kReplace, result);
|
||||
|
||||
// Paint the view. The clipping rect was set above set don't clip again.
|
||||
|
@ -2833,15 +2815,19 @@ PRBool nsViewManager::CreateDisplayList(nsView *aView, PRBool aReparentedViewsPr
|
|||
|
||||
nsRect bounds;
|
||||
aView->GetBounds(bounds);
|
||||
nscoord posX, posY;
|
||||
aView->GetPosition(&posX, &posY);
|
||||
|
||||
if (aView == aTopView) {
|
||||
bounds.x = 0;
|
||||
bounds.y = 0;
|
||||
aView->ConvertFromParentCoords(&bounds.x, &bounds.y);
|
||||
posX = posY = 0;
|
||||
}
|
||||
|
||||
// -> to global coordinates (relative to aTopView)
|
||||
bounds.x += aX;
|
||||
bounds.y += aY;
|
||||
posX += aX;
|
||||
posY += aY;
|
||||
|
||||
// is this a clip view?
|
||||
PRBool isClipView = IsClipView(aView);
|
||||
|
@ -2923,7 +2909,7 @@ PRBool nsViewManager::CreateDisplayList(nsView *aView, PRBool aReparentedViewsPr
|
|||
DisplayZTreeNode* createdNode;
|
||||
retval = CreateDisplayList(childView, aReparentedViewsPresent, createdNode,
|
||||
aInsideRealView || aRealView == aView,
|
||||
aOriginX, aOriginY, aRealView, aDamageRect, aTopView, bounds.x, bounds.y, aPaintFloaters);
|
||||
aOriginX, aOriginY, aRealView, aDamageRect, aTopView, posX, posY, aPaintFloaters);
|
||||
if (createdNode != nsnull) {
|
||||
EnsureZTreeNodeCreated(aView, aResult);
|
||||
createdNode->mZSibling = aResult->mZChild;
|
||||
|
@ -2979,7 +2965,7 @@ PRBool nsViewManager::CreateDisplayList(nsView *aView, PRBool aReparentedViewsPr
|
|||
DisplayZTreeNode* createdNode;
|
||||
retval = CreateDisplayList(childView, aReparentedViewsPresent, createdNode,
|
||||
aInsideRealView || aRealView == aView,
|
||||
aOriginX, aOriginY, aRealView, aDamageRect, aTopView, bounds.x, bounds.y, aPaintFloaters);
|
||||
aOriginX, aOriginY, aRealView, aDamageRect, aTopView, posX, posY, aPaintFloaters);
|
||||
if (createdNode != nsnull) {
|
||||
EnsureZTreeNodeCreated(aView, aResult);
|
||||
createdNode->mZSibling = aResult->mZChild;
|
||||
|
@ -3263,16 +3249,24 @@ void nsViewManager::ShowDisplayList(PRInt32 flatlen)
|
|||
nsView* view = element->mView;
|
||||
nsRect rect = element->mBounds;
|
||||
PRUint32 flags = element->mFlags;
|
||||
nsRect dim;
|
||||
nscoord vx, vy;
|
||||
|
||||
view->GetDimensions(dim);
|
||||
view->GetPosition(&vx, &vy);
|
||||
nsView* parent = view->GetParent();
|
||||
PRInt32 zindex = view->GetZIndex();
|
||||
|
||||
nest[nestcnt << 1] = 0;
|
||||
|
||||
rect *= t2p;
|
||||
printf("%snsIView@%p [z=%d, x=%d, y=%d, w=%d, h=%d, p=%p]\n",
|
||||
nest, (void*)view, zindex,
|
||||
rect.x, rect.y, rect.width, rect.height, (void*)parent);
|
||||
printf("%snsIView@%p{%d,%d,%d,%d @ %d,%d; p=%p, z=%d} [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, zindex,
|
||||
rect.x, rect.y, rect.width, rect.height,
|
||||
element->mAbsX, element->mAbsY);
|
||||
|
||||
newnestcnt = nestcnt;
|
||||
|
||||
|
@ -3308,11 +3302,7 @@ void nsViewManager::ComputeViewOffset(nsView *aView, nsPoint *aOrigin)
|
|||
if (aOrigin) {
|
||||
while (aView != nsnull) {
|
||||
// compute the view's global position in the view hierarchy.
|
||||
nsRect bounds;
|
||||
aView->GetBounds(bounds);
|
||||
aOrigin->x += bounds.x;
|
||||
aOrigin->y += bounds.y;
|
||||
|
||||
aView->ConvertToParentCoords(&aOrigin->x, &aOrigin->y);
|
||||
aView = aView->GetParent();
|
||||
}
|
||||
}
|
||||
|
@ -3350,17 +3340,17 @@ nsView* nsViewManager::GetWidgetView(nsView *aView) const
|
|||
void nsViewManager::ViewToWidget(nsView *aView, nsView* aWidgetView, nsRect &aRect) const
|
||||
{
|
||||
while (aView != aWidgetView) {
|
||||
nscoord x, y;
|
||||
aView->GetPosition(&x, &y);
|
||||
aRect.MoveBy(x, y);
|
||||
aView->ConvertToParentCoords(&aRect.x, &aRect.y);
|
||||
aView = aView->GetParent();
|
||||
}
|
||||
|
||||
// intersect aRect with bounds of aWidgetView, to prevent generating any illegal rectangles.
|
||||
nsRect bounds;
|
||||
aWidgetView->GetBounds(bounds);
|
||||
bounds.x = bounds.y = 0;
|
||||
aWidgetView->GetDimensions(bounds);
|
||||
aRect.IntersectRect(aRect, bounds);
|
||||
// account for the view's origin not lining up with the widget's
|
||||
aRect.x -= bounds.x;
|
||||
aRect.y -= bounds.y;
|
||||
|
||||
// finally, convert to device coordinates.
|
||||
float t2p;
|
||||
|
@ -3380,12 +3370,12 @@ nsresult nsViewManager::GetVisibleRect(nsRect& aVisibleRect)
|
|||
// Determine the visible rect in the scrolled view's coordinate space.
|
||||
// The size of the visible area is the clip view size
|
||||
const nsIView* clipViewI;
|
||||
|
||||
scrollingView->GetScrollPosition(aVisibleRect.x, aVisibleRect.y);
|
||||
scrollingView->GetClipView(&clipViewI);
|
||||
|
||||
const nsView* clipView = NS_STATIC_CAST(const nsView*, clipViewI);
|
||||
clipView->GetDimensions(&aVisibleRect.width, &aVisibleRect.height);
|
||||
clipView->GetDimensions(aVisibleRect);
|
||||
|
||||
scrollingView->GetScrollPosition(aVisibleRect.x, aVisibleRect.y);
|
||||
} else {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -3412,9 +3402,7 @@ nsresult nsViewManager::GetAbsoluteRect(nsView *aView, const nsRect &aRect,
|
|||
aAbsRect = aRect;
|
||||
nsView *parentView = aView;
|
||||
while ((parentView != nsnull) && (parentView != scrolledView)) {
|
||||
nscoord x, y;
|
||||
parentView->GetPosition(&x, &y);
|
||||
aAbsRect.MoveBy(x, y);
|
||||
parentView->ConvertToParentCoords(&aAbsRect.x, &aAbsRect.y);
|
||||
parentView = parentView->GetParent();
|
||||
}
|
||||
|
||||
|
|
|
@ -262,13 +262,15 @@ private:
|
|||
void RenderViews(nsView *aRootView, nsIRenderingContext& aRC, const nsRect& aRect,
|
||||
PRBool &aResult);
|
||||
|
||||
void RenderView(nsView *aView, nsIRenderingContext &aRC,
|
||||
const nsRect &aDamageRect, nsRect &aGlobalRect, PRBool &aResult);
|
||||
|
||||
void RenderDisplayListElement(DisplayListElement2* element, nsIRenderingContext &aRC);
|
||||
|
||||
void PaintView(nsView *aView, nsIRenderingContext &aRC, nscoord x, nscoord y,
|
||||
const nsRect &aDamageRect);
|
||||
|
||||
void InvalidateRectDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut, PRUint32 aUpdateFlags);
|
||||
|
||||
void InvalidateHorizontalBandDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut,
|
||||
PRUint32 aUpdateFlags, nscoord aY1, nscoord aY2, PRBool aInCutOut);
|
||||
|
||||
nsresult CreateBlendingBuffers(nsIRenderingContext &aRC);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче