diff --git a/mozilla/base/src/nsUnicharInputStream.cpp b/mozilla/base/src/nsUnicharInputStream.cpp index b724da7f262..73dca958566 100644 --- a/mozilla/base/src/nsUnicharInputStream.cpp +++ b/mozilla/base/src/nsUnicharInputStream.cpp @@ -69,7 +69,7 @@ nsresult StringUnicharInputStream::Read(PRUnichar* aBuf, { if (mPos >= mLen) { *aReadCount = 0; - return -1; + return (nsresult)-1; } const PRUnichar* us = mString->GetUnicode(); PRInt32 amount = mLen - mPos; diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index 30a426a6874..933bff373ef 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -909,7 +909,7 @@ HTMLContentSink::CloseContainer(const nsIParserNode& aNode) rootView->GetBounds(rect); rect.x = 0; rect.y = 0; - vm->Refresh(rootView, nsnull, &rect, NS_VMREFRESH_IMMEDIATE); + vm->UpdateView(rootView, rect, NS_VMREFRESH_IMMEDIATE); NS_RELEASE(rootView); } NS_RELEASE(vm); diff --git a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp index 30a426a6874..933bff373ef 100644 --- a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp @@ -909,7 +909,7 @@ HTMLContentSink::CloseContainer(const nsIParserNode& aNode) rootView->GetBounds(rect); rect.x = 0; rect.y = 0; - vm->Refresh(rootView, nsnull, &rect, NS_VMREFRESH_IMMEDIATE); + vm->UpdateView(rootView, rect, NS_VMREFRESH_IMMEDIATE); NS_RELEASE(rootView); } NS_RELEASE(vm); diff --git a/mozilla/view/public/nsIScrollableView.h b/mozilla/view/public/nsIScrollableView.h index 732cdb42218..83ae7bc4d1a 100644 --- a/mozilla/view/public/nsIScrollableView.h +++ b/mozilla/view/public/nsIScrollableView.h @@ -109,8 +109,19 @@ public: * Scroll the view to the given x,y, update's the scrollbar's thumb * positions and the view's offset. Clamps the values to be * legal. Updates the display based on aUpdateFlags. + * @param aX left edge to scroll to + * @param aY top edge to scroll to + * @param aUpdateFlags passed onto nsIViewManager->UpdateView() + * @return error status */ NS_IMETHOD ScrollTo(nscoord aX, nscoord aY, PRUint32 aUpdateFlags) = 0; + + /** + * Get the view that clips the contents of the scrolling view + * @param aClipView out param to hold view pointer + * @return error status + */ + NS_IMETHOD GetClipView(nsIView ** aClipView) = 0; }; #endif diff --git a/mozilla/view/public/nsIViewManager.h b/mozilla/view/public/nsIViewManager.h index c371822c2f0..a125b0e9d25 100644 --- a/mozilla/view/public/nsIViewManager.h +++ b/mozilla/view/public/nsIViewManager.h @@ -134,27 +134,6 @@ public: */ virtual void ResetScrolling(void) = 0; - /** - * Called to refresh an area of the root window. Often called in - * response to a paint/redraw event from the native windowing system. - * @param aContext rendering context to draw into - * @param region nsIRegion to be updated - * @param aUpdateFlags see bottom of nsIViewManager.h for description - */ - virtual void Refresh(nsIView *aView, nsIRenderingContext *aContext, - nsIRegion *region, PRUint32 aUpdateFlags) = 0; - - /** - * Called to refresh an area of the root window. Often called in - * response to a paint/redraw event from the native windowing system. - * @param aView view to paint. should be root view - * @param aContext rendering context to draw into - * @param rect nsRect to be updated - * @param aUpdateFlags see bottom of nsIViewManager.h for description - */ - virtual void Refresh(nsIView* aView, nsIRenderingContext *aContext, - nsRect *rect, PRUint32 aUpdateFlags) = 0; - /** * Called to force a redrawing of any dirty areas. */ @@ -384,6 +363,19 @@ public: * @param aShow if PR_TRUE, quality level will be displayed, else hidden */ virtual void SetQuality(nsContentQuality aQuality) = 0; + + /** + * prevent the view manager from refreshing. + * @return error status + */ + NS_IMETHOD DisableRefresh(void) = 0; + + /** + * allow the view manager to refresh. this may cause a synchronous + * paint to occur inside the call. + * @return error status + */ + NS_IMETHOD EnableRefresh(void) = 0; }; //when the refresh happens, should it be double buffered? diff --git a/mozilla/view/src/nsScrollingView.cpp b/mozilla/view/src/nsScrollingView.cpp index 6d4498e5049..0e83166e612 100644 --- a/mozilla/view/src/nsScrollingView.cpp +++ b/mozilla/view/src/nsScrollingView.cpp @@ -312,6 +312,7 @@ nsScrollingView :: nsScrollingView() mHScrollBarView = nsnull; mCornerView = nsnull; mScrollPref = nsScrollPreference_kAuto; + mClipView = nsnull; } nsScrollingView :: ~nsScrollingView() @@ -335,6 +336,12 @@ nsScrollingView :: ~nsScrollingView() NS_RELEASE(mCornerView); mCornerView = nsnull; } + + if (nsnull != mClipView) + { + NS_RELEASE(mClipView); + mClipView = nsnull; + } } nsresult nsScrollingView :: QueryInterface(const nsIID& aIID, void** aInstancePtr) @@ -404,6 +411,28 @@ nsresult nsScrollingView :: Init(nsIViewManager* aManager, mViewManager->InsertChild(this, mCornerView, -1); } +#if 0 + // Create a view for clipping + + mClipView = new ClipView(); + + if (nsnull != mClipView) + { + NS_ADDREF(mClipView); + + nsRect trect; + + trect.width = aBounds.XMost() - NS_TO_INT_ROUND(dx->GetScrollBarWidth()); + trect.x = 0; + trect.height = aBounds.YMost() - NS_TO_INT_ROUND(dx->GetScrollBarHeight()); + trect.y = 0; + + rv = mClipView->Init(mViewManager, trect, this, nsnull, nsnull, nsnull, -1); + + mViewManager->InsertChild(this, mCornerView, -1); + } +#endif + // Create a view for a vertical scrollbar mVScrollBarView = new ScrollBarView(this); @@ -422,7 +451,7 @@ nsresult nsScrollingView :: Init(nsIViewManager* aManager, rv = mVScrollBarView->Init(mViewManager, trect, this, &kCScrollbarIID, nsnull, nsnull, -2); - mViewManager->InsertChild(this, mVScrollBarView, -2); + mViewManager->InsertChild(this, mVScrollBarView, -3); } // Create a view for a horizontal scrollbar @@ -443,7 +472,7 @@ nsresult nsScrollingView :: Init(nsIViewManager* aManager, rv = mHScrollBarView->Init(mViewManager, trect, this, &kCHScrollbarIID, nsnull, nsnull, -2); - mViewManager->InsertChild(this, mHScrollBarView, -2); + mViewManager->InsertChild(this, mHScrollBarView, -3); } NS_RELEASE(dx); @@ -1044,6 +1073,14 @@ nsScrollingView :: ScrollTo(nscoord aX, nscoord aY, PRUint32 aUpdateFlags) return NS_OK; } +NS_IMETHODIMP nsScrollingView :: GetClipView(nsIView ** aClipView) +{ + NS_IF_ADDREF(mClipView); + *aClipView = mClipView; + + return NS_OK; +} + void nsScrollingView :: AdjustChildWidgets(nsScrollingView *aScrolling, nsIView *aView, nscoord aDx, nscoord aDy, float scale) { PRInt32 numkids = aView->GetChildCount(); diff --git a/mozilla/view/src/nsScrollingView.h b/mozilla/view/src/nsScrollingView.h index 8a478e4a58a..4c0385ddfa9 100644 --- a/mozilla/view/src/nsScrollingView.h +++ b/mozilla/view/src/nsScrollingView.h @@ -69,6 +69,7 @@ public: virtual void SetScrollPreference(nsScrollPreference aPref); virtual nsScrollPreference GetScrollPreference(void); NS_IMETHOD ScrollTo(nscoord aX, nscoord aY, PRUint32 aUpdateFlags); + NS_IMETHOD GetClipView(nsIView ** aClipView); //private void ComputeScrollArea(nsIView *aView, nsRect &aRect, nscoord aOffX, nscoord aOffY); @@ -83,6 +84,7 @@ protected: nsIView *mHScrollBarView; nsIView *mCornerView; nsScrollPreference mScrollPref; + nsIView *mClipView; }; #endif diff --git a/mozilla/view/src/nsView.cpp b/mozilla/view/src/nsView.cpp index b6b5bac7654..5dff8b200c7 100644 --- a/mozilla/view/src/nsView.cpp +++ b/mozilla/view/src/nsView.cpp @@ -96,8 +96,9 @@ nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent) //printf("damage repair...\n"); vm->UpdateView(view, trect, - NS_VMREFRESH_SCREEN_RECT); - vm->Composite(); + NS_VMREFRESH_SCREEN_RECT | + NS_VMREFRESH_IMMEDIATE | + NS_VMREFRESH_DOUBLE_BUFFER); NS_RELEASE(dx); NS_RELEASE(px); diff --git a/mozilla/view/src/nsViewManager.cpp b/mozilla/view/src/nsViewManager.cpp index d0536486486..e514a7f0bcc 100644 --- a/mozilla/view/src/nsViewManager.cpp +++ b/mozilla/view/src/nsViewManager.cpp @@ -137,6 +137,8 @@ nsresult nsViewManager::Init(nsIPresContext* aPresContext) mLastRefresh = PR_Now(); + mRefreshEnabled = PR_TRUE; + return rv; } @@ -285,6 +287,9 @@ void nsViewManager :: Refresh(nsIView *aView, nsIRenderingContext *aContext, nsI nscoord xoff, yoff; float scale; + if (PR_FALSE == mRefreshEnabled) + return; + //printf("refreshing region...\n"); //force double buffering because of non-opaque views? @@ -353,6 +358,9 @@ void nsViewManager :: Refresh(nsIView *aView, nsIRenderingContext *aContext, nsR nsIRenderingContext *localcx = nsnull; nscoord xoff, yoff; + if (PR_FALSE == mRefreshEnabled) + return; + //force double buffering because of non-opaque views? //printf("refreshing rect... "); @@ -1011,3 +1019,33 @@ void nsViewManager :: UpdateTransCnt(nsIView *oldview, nsIView *newview) (newview->GetOpacity() != 1.0f))) mTransCnt++; } + +NS_IMETHODIMP nsViewManager :: DisableRefresh(void) +{ + mRefreshEnabled = PR_FALSE; + + return NS_OK; +} + +NS_IMETHODIMP nsViewManager :: EnableRefresh(void) +{ + mRefreshEnabled = PR_TRUE; + + if (mFrameRate > 0) + { + PRTime now = PR_Now(); + PRTime conversion, ustoms; + PRInt32 deltams; + + LL_I2L(ustoms, 1000); + LL_SUB(conversion, now, mLastRefresh); + LL_DIV(conversion, conversion, ustoms); + LL_L2I(deltams, conversion); + + if (deltams > (1000 / (PRInt32)mFrameRate)) + Composite(); + } + + return NS_OK; +} + diff --git a/mozilla/view/src/nsViewManager.h b/mozilla/view/src/nsViewManager.h index d98d5c3c178..13aebd7326f 100644 --- a/mozilla/view/src/nsViewManager.h +++ b/mozilla/view/src/nsViewManager.h @@ -58,11 +58,6 @@ public: virtual void ResetScrolling(void); - virtual void Refresh(nsIView *aView, nsIRenderingContext *aContext, - nsIRegion *region, PRUint32 aUpdateFlags); - virtual void Refresh(nsIView* aView, nsIRenderingContext *aContext, - nsRect *rect, PRUint32 aUpdateFlags); - virtual void Composite(); virtual void UpdateView(nsIView *aView, nsIRegion *aRegion, @@ -117,12 +112,20 @@ public: virtual PRBool GetShowQuality(void); virtual void SetQuality(nsContentQuality aQuality); + NS_IMETHOD DisableRefresh(void); + NS_IMETHOD EnableRefresh(void); + private: virtual ~nsViewManager(); nsIRenderingContext *CreateRenderingContext(nsIView &aView); void AddRectToDirtyRegion(nsRect &aRect); void UpdateTransCnt(nsIView *oldview, nsIView *newview); + void Refresh(nsIView *aView, nsIRenderingContext *aContext, + nsIRegion *region, PRUint32 aUpdateFlags); + void Refresh(nsIView* aView, nsIRenderingContext *aContext, + nsRect *rect, PRUint32 aUpdateFlags); + nsIPresContext *mContext; nsIWidget *mRootWindow; nsRect mDSBounds; @@ -130,13 +133,14 @@ private: PRTime mLastRefresh; nsIRegion *mDirtyRegion; PRInt32 mTransCnt; + PRBool mRefreshEnabled; public: //these are public so that our timer callback can poke them. nsITimer *mTimer; nsRect mDirtyRect; nsIView *mRootView; - PRUint32 mFrameRate; + PRUint32 mFrameRate; }; #endif diff --git a/mozilla/xpcom/io/nsUnicharInputStream.cpp b/mozilla/xpcom/io/nsUnicharInputStream.cpp index b724da7f262..73dca958566 100644 --- a/mozilla/xpcom/io/nsUnicharInputStream.cpp +++ b/mozilla/xpcom/io/nsUnicharInputStream.cpp @@ -69,7 +69,7 @@ nsresult StringUnicharInputStream::Read(PRUnichar* aBuf, { if (mPos >= mLen) { *aReadCount = 0; - return -1; + return (nsresult)-1; } const PRUnichar* us = mString->GetUnicode(); PRInt32 amount = mLen - mPos;