From c1304ffecc73b8ea9ee26bb6afd348bcb64da1ef Mon Sep 17 00:00:00 2001 From: "mjudge%netscape.com" Date: Sun, 21 Feb 1999 19:43:40 +0000 Subject: [PATCH] Needed methods to disable the ScrollFrameIntoView because of resizing causing scrolling to snap selection into view. 3 helper fucs, 1 variable, PRBool mEnableScrolling defaulted to true of course git-svn-id: svn://10.0.0.236/trunk@21438 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/nsPresShell.cpp | 17 ++++++++++++++--- mozilla/layout/html/base/src/nsPresShell.cpp | 17 ++++++++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 009a48cf5e2..2cc66fa63d3 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -351,8 +351,13 @@ protected: nsCOMPtr mSelection; nsCOMPtr mCaret; - + PRBool mScrollingEnabled; //used to disable programmable scrolling from outside FrameHashTable* mPlaceholderMap; +private: + //helper funcs for disabing autoscrolling + void DisableScrolling(){mScrollingEnabled = PR_FALSE;} + void EnableScrolling(){mScrollingEnabled = PR_TRUE;} + PRBool IsScrollingEnabled(){return mScrollingEnabled;} }; #ifdef NS_DEBUG @@ -414,6 +419,7 @@ PresShell::PresShell() { //XXX joki 11/17 - temporary event hack. mIsDestroying = PR_FALSE; + EnableScrolling(); } #ifdef NS_DEBUG @@ -909,8 +915,11 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight) NS_IF_RELEASE(rcx); NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, ("exit nsPresShell::ResizeReflow")); - if (mSelection) + if (mSelection){ + DisableScrolling(); mSelection->ResetSelection(this, mRootFrame); + EnableScrolling(); + } // XXX if debugging then we should assert that the cache is empty } else { @@ -948,9 +957,11 @@ PresShell::GetFocus(nsIFrame **aFrame, nsIFrame **aAnchorFrame){ NS_IMETHODIMP PresShell::ScrollFrameIntoView(nsIFrame *aFrame){ if (!aFrame) return NS_ERROR_NULL_POINTER; - return ScrollFrameIntoView(aFrame, + if (IsScrollingEnabled()) + return ScrollFrameIntoView(aFrame, 0, NS_PRESSHELL_SCROLL_TOP |NS_PRESSHELL_SCROLL_ANYWHERE, 0, NS_PRESSHELL_SCROLL_LEFT|NS_PRESSHELL_SCROLL_ANYWHERE); + return NS_OK; } diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index 009a48cf5e2..2cc66fa63d3 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -351,8 +351,13 @@ protected: nsCOMPtr mSelection; nsCOMPtr mCaret; - + PRBool mScrollingEnabled; //used to disable programmable scrolling from outside FrameHashTable* mPlaceholderMap; +private: + //helper funcs for disabing autoscrolling + void DisableScrolling(){mScrollingEnabled = PR_FALSE;} + void EnableScrolling(){mScrollingEnabled = PR_TRUE;} + PRBool IsScrollingEnabled(){return mScrollingEnabled;} }; #ifdef NS_DEBUG @@ -414,6 +419,7 @@ PresShell::PresShell() { //XXX joki 11/17 - temporary event hack. mIsDestroying = PR_FALSE; + EnableScrolling(); } #ifdef NS_DEBUG @@ -909,8 +915,11 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight) NS_IF_RELEASE(rcx); NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, ("exit nsPresShell::ResizeReflow")); - if (mSelection) + if (mSelection){ + DisableScrolling(); mSelection->ResetSelection(this, mRootFrame); + EnableScrolling(); + } // XXX if debugging then we should assert that the cache is empty } else { @@ -948,9 +957,11 @@ PresShell::GetFocus(nsIFrame **aFrame, nsIFrame **aAnchorFrame){ NS_IMETHODIMP PresShell::ScrollFrameIntoView(nsIFrame *aFrame){ if (!aFrame) return NS_ERROR_NULL_POINTER; - return ScrollFrameIntoView(aFrame, + if (IsScrollingEnabled()) + return ScrollFrameIntoView(aFrame, 0, NS_PRESSHELL_SCROLL_TOP |NS_PRESSHELL_SCROLL_ANYWHERE, 0, NS_PRESSHELL_SCROLL_LEFT|NS_PRESSHELL_SCROLL_ANYWHERE); + return NS_OK; }