diff --git a/widget/public/nsIWidget.h b/widget/public/nsIWidget.h index fb14c4d96c68..305dea03526d 100644 --- a/widget/public/nsIWidget.h +++ b/widget/public/nsIWidget.h @@ -373,7 +373,16 @@ class nsIWidget : public nsISupports { NS_IMETHOD Invalidate(PRBool aIsSynchronous) = 0; - + /** + * Invalidate a specified rect for a widget and repaints it. + * + * @param aIsSynchronouse PR_TRUE then repaint synchronously. If PR_FALSE repaint later. + * + */ + + NS_IMETHOD Invalidate(const nsRect & aRect, PRBool aIsSynchronous) = 0; + + /** * Adds a mouse listener to this widget * Any existing mouse listener is replaced diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index 3cccdc808045..016b80c7c7aa 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -1028,6 +1028,29 @@ NS_METHOD nsWindow::Invalidate(PRBool aIsSynchronous) return NS_OK; } +//------------------------------------------------------------------------- +// +// Invalidate this component visible area +// +//------------------------------------------------------------------------- +NS_METHOD nsWindow::Invalidate(const nsRect & aRect, PRBool aIsSynchronous) +{ + RECT rect; + + if (mWnd) { + rect.left = aRect.x; + rect.top = aRect.y; + rect.right = aRect.x + aRect.width; + rect.bottom = aRect.y + aRect.height; + VERIFY(::InvalidateRect(mWnd, &rect, TRUE)); + if (aIsSynchronous) { + VERIFY(::UpdateWindow(mWnd)); + } + } + return NS_OK; +} + + //------------------------------------------------------------------------- // diff --git a/widget/src/windows/nsWindow.h b/widget/src/windows/nsWindow.h index 9b2422566df5..903d9ad9e03c 100644 --- a/widget/src/windows/nsWindow.h +++ b/widget/src/windows/nsWindow.h @@ -103,6 +103,7 @@ public: NS_IMETHOD SetFont(const nsFont &aFont); NS_IMETHOD SetCursor(nsCursor aCursor); NS_IMETHOD Invalidate(PRBool aIsSynchronous); + NS_IMETHOD Invalidate(const nsRect & aRect, PRBool aIsSynchronous); virtual void* GetNativeData(PRUint32 aDataType); NS_IMETHOD SetColorMap(nsColorMap *aColorMap); NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect);