diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index e7978bc0e25..857cafeda02 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -1615,7 +1615,7 @@ nsGfxScrollFrameInner::SetScrollbarVisibility(nsIBox* aScrollbar, PRBool aVisibl scrollbar->GetScrollbarMediator(getter_AddRefs(mediator)); if (mediator) { // Inform the mediator of the visibility change. - mediator->VisibilityChanged(aVisible); + mediator->VisibilityChanged(scrollbar, aVisible); } } } diff --git a/layout/html/base/src/nsGfxScrollFrame.cpp b/layout/html/base/src/nsGfxScrollFrame.cpp index e7978bc0e25..857cafeda02 100644 --- a/layout/html/base/src/nsGfxScrollFrame.cpp +++ b/layout/html/base/src/nsGfxScrollFrame.cpp @@ -1615,7 +1615,7 @@ nsGfxScrollFrameInner::SetScrollbarVisibility(nsIBox* aScrollbar, PRBool aVisibl scrollbar->GetScrollbarMediator(getter_AddRefs(mediator)); if (mediator) { // Inform the mediator of the visibility change. - mediator->VisibilityChanged(aVisible); + mediator->VisibilityChanged(scrollbar, aVisible); } } } diff --git a/layout/xul/base/public/nsIScrollbarMediator.h b/layout/xul/base/public/nsIScrollbarMediator.h index 8d45f4750cb..967b3a3bc00 100644 --- a/layout/xul/base/public/nsIScrollbarMediator.h +++ b/layout/xul/base/public/nsIScrollbarMediator.h @@ -21,6 +21,7 @@ * * Contributor(s): * Original Author: David W. Hyatt (hyatt@netscape.com) + * Nate Nielsen (nielsen@memberwebs.com) * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), @@ -39,21 +40,25 @@ #ifndef nsIScrollbarMediator_h___ #define nsIScrollbarMediator_h___ -// {351C003A-E8F7-4d10-8BFA-635C9860D650} +// {b589027f-271b-4c68-91df-04f139885e9a} #define NS_ISCROLLBARMEDIATOR_IID \ -{ 0x351c003a, 0xe8f7, 0x4d10, { 0x8b, 0xfa, 0x63, 0x5c, 0x98, 0x60, 0xd6, 0x50 } } +{ 0xb589027f, 0x271b, 0x4c68, { 0x91, 0xdf, 0x04, 0xf1, 0x39, 0x88, 0x5e, 0x9a } } -static NS_DEFINE_IID(kIScrollbarMediatorIID, NS_ISCROLLBARMEDIATOR_IID); +static NS_DEFINE_IID(kIScrollbarMediatorIID, NS_ISCROLLBARMEDIATOR_IID); class nsIScrollbarMediator : public nsISupports { public: NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISCROLLBARMEDIATOR_IID) - - NS_IMETHOD PositionChanged(PRInt32 aOldIndex, PRInt32& aNewIndex) = 0; - NS_IMETHOD ScrollbarButtonPressed(PRInt32 aOldIndex, PRInt32 aNewIndex) = 0; - NS_IMETHOD VisibilityChanged(PRBool aVisible) = 0; + // The nsISupports aScrollbar argument below denotes the + // scrollbar that's firing the notification. It should be + // where the same object as where nsIScrollbarFrame is implemented + + NS_IMETHOD PositionChanged(nsISupports* aScrollbar, PRInt32 aOldIndex, PRInt32& aNewIndex) = 0; + NS_IMETHOD ScrollbarButtonPressed(nsISupports* aScrollbar, PRInt32 aOldIndex, PRInt32 aNewIndex) = 0; + + NS_IMETHOD VisibilityChanged(nsISupports* aScrollbar, PRBool aVisible) = 0; }; #endif diff --git a/layout/xul/base/src/nsListBoxBodyFrame.cpp b/layout/xul/base/src/nsListBoxBodyFrame.cpp index ec90f1fbfce..f6a41554479 100644 --- a/layout/xul/base/src/nsListBoxBodyFrame.cpp +++ b/layout/xul/base/src/nsListBoxBodyFrame.cpp @@ -373,7 +373,7 @@ nsListBoxBodyFrame::DoLayout(nsBoxLayoutState& aBoxLayoutState) ///////////// nsIScrollbarMediator /////////////// NS_IMETHODIMP -nsListBoxBodyFrame::PositionChanged(PRInt32 aOldIndex, PRInt32& aNewIndex) +nsListBoxBodyFrame::PositionChanged(nsISupports* aScrollbar, PRInt32 aOldIndex, PRInt32& aNewIndex) { if (mScrolling) return NS_OK; @@ -428,7 +428,7 @@ nsListBoxBodyFrame::PositionChanged(PRInt32 aOldIndex, PRInt32& aNewIndex) } NS_IMETHODIMP -nsListBoxBodyFrame::VisibilityChanged(PRBool aVisible) +nsListBoxBodyFrame::VisibilityChanged(nsISupports* aScrollbar, PRBool aVisible) { PRInt32 lastPageTopRow = GetRowCount() - (GetAvailableHeight() / mRowHeight); if (lastPageTopRow < 0) @@ -443,7 +443,7 @@ nsListBoxBodyFrame::VisibilityChanged(PRBool aVisible) } NS_IMETHODIMP -nsListBoxBodyFrame::ScrollbarButtonPressed(PRInt32 aOldIndex, PRInt32 aNewIndex) +nsListBoxBodyFrame::ScrollbarButtonPressed(nsISupports* aScrollbar, PRInt32 aOldIndex, PRInt32 aNewIndex) { if (aOldIndex == aNewIndex) return NS_OK; diff --git a/layout/xul/base/src/nsListBoxBodyFrame.h b/layout/xul/base/src/nsListBoxBodyFrame.h index 25ad0050714..d6caa35b13b 100644 --- a/layout/xul/base/src/nsListBoxBodyFrame.h +++ b/layout/xul/base/src/nsListBoxBodyFrame.h @@ -82,9 +82,9 @@ public: PRInt32 aModType); // nsIScrollbarMediator - NS_IMETHOD PositionChanged(PRInt32 aOldIndex, PRInt32& aNewIndex); - NS_IMETHOD ScrollbarButtonPressed(PRInt32 aOldIndex, PRInt32 aNewIndex); - NS_IMETHOD VisibilityChanged(PRBool aVisible); + NS_IMETHOD PositionChanged(nsISupports* aScrollbar, PRInt32 aOldIndex, PRInt32& aNewIndex); + NS_IMETHOD ScrollbarButtonPressed(nsISupports* aScrollbar, PRInt32 aOldIndex, PRInt32 aNewIndex); + NS_IMETHOD VisibilityChanged(nsISupports* aScrollbar, PRBool aVisible); // nsIReflowCallback NS_IMETHOD ReflowFinished(nsIPresShell* aPresShell, PRBool* aFlushFlag); diff --git a/layout/xul/base/src/nsNativeScrollbarFrame.cpp b/layout/xul/base/src/nsNativeScrollbarFrame.cpp index 4c20355bab6..978a9881c45 100644 --- a/layout/xul/base/src/nsNativeScrollbarFrame.cpp +++ b/layout/xul/base/src/nsNativeScrollbarFrame.cpp @@ -90,7 +90,7 @@ nsNativeScrollbarFrame::~nsNativeScrollbarFrame ( ) // the content node just to be safe about lifetime issues nsCOMPtr scrollbar ( do_QueryInterface(mScrollbar) ); if ( scrollbar ) - scrollbar->SetContent(nsnull, nsnull); + scrollbar->SetContent(nsnull, nsnull, nsnull); } @@ -240,7 +240,7 @@ nsNativeScrollbarFrame::AttributeChanged(nsIPresContext* aPresContext, nsCOMPtr mediator; scrollbarFrame->GetScrollbarMediator(getter_AddRefs(mediator)); if (mediator) - mediator->PositionChanged(oldPosition, /* inout */ curPosition); + mediator->PositionChanged(scrollbarFrame, oldPosition, /* inout */ curPosition); } nsAutoString currentStr; @@ -327,7 +327,7 @@ nsNativeScrollbarFrame::Hookup() return; } - scrollbar->SetContent(scrollbarContent, mediator); + scrollbar->SetContent(scrollbarContent, sb, mediator); mScrollbarNeedsContent = PR_FALSE; if (!scrollbarContent) diff --git a/layout/xul/base/src/nsScrollbarButtonFrame.cpp b/layout/xul/base/src/nsScrollbarButtonFrame.cpp index 11cc047aba3..beb5bac030b 100644 --- a/layout/xul/base/src/nsScrollbarButtonFrame.cpp +++ b/layout/xul/base/src/nsScrollbarButtonFrame.cpp @@ -195,7 +195,7 @@ nsScrollbarButtonFrame::MouseClicked() nsCOMPtr m; sb->GetScrollbarMediator(getter_AddRefs(m)); if (m) { - m->ScrollbarButtonPressed(oldpos, curpos); + m->ScrollbarButtonPressed(sb, oldpos, curpos); return; } } diff --git a/layout/xul/base/src/nsSliderFrame.cpp b/layout/xul/base/src/nsSliderFrame.cpp index 58eb4ed7e9a..2b77e2b46fd 100644 --- a/layout/xul/base/src/nsSliderFrame.cpp +++ b/layout/xul/base/src/nsSliderFrame.cpp @@ -267,7 +267,7 @@ nsSliderFrame::AttributeChanged(nsIPresContext* aPresContext, nsCOMPtr mediator; scrollbarFrame->GetScrollbarMediator(getter_AddRefs(mediator)); if (mediator) { - mediator->PositionChanged(GetCurrentPosition(scrollbar), current); + mediator->PositionChanged(scrollbarFrame, GetCurrentPosition(scrollbar), current); } } @@ -833,7 +833,7 @@ nsSliderFrame::SetCurrentPosition(nsIContent* scrollbar, nsIFrame* aThumbFrame, nsCOMPtr mediator; scrollbarFrame->GetScrollbarMediator(getter_AddRefs(mediator)); if (mediator) { - mediator->PositionChanged(GetCurrentPosition(scrollbar), newpos); + mediator->PositionChanged(scrollbarFrame, GetCurrentPosition(scrollbar), newpos); UpdateAttribute(scrollbar, newpos, PR_FALSE, aIsSmooth); CurrentPositionChanged(GetPresContext()); return; diff --git a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index c27597d2c76..8df85a3bd16 100644 --- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -3269,7 +3269,7 @@ nsTreeBodyFrame::ScrollInternal(PRInt32 aRow) } NS_IMETHODIMP -nsTreeBodyFrame::ScrollbarButtonPressed(PRInt32 aOldIndex, PRInt32 aNewIndex) +nsTreeBodyFrame::ScrollbarButtonPressed(nsISupports* aScrollbar, PRInt32 aOldIndex, PRInt32 aNewIndex) { if (aNewIndex > aOldIndex) ScrollToRow(mTopRowIndex+1); @@ -3279,7 +3279,7 @@ nsTreeBodyFrame::ScrollbarButtonPressed(PRInt32 aOldIndex, PRInt32 aNewIndex) } NS_IMETHODIMP -nsTreeBodyFrame::PositionChanged(PRInt32 aOldIndex, PRInt32& aNewIndex) +nsTreeBodyFrame::PositionChanged(nsISupports* aScrollbar, PRInt32 aOldIndex, PRInt32& aNewIndex) { if (!EnsureScrollbar()) return NS_ERROR_UNEXPECTED; diff --git a/layout/xul/base/src/tree/src/nsTreeBodyFrame.h b/layout/xul/base/src/tree/src/nsTreeBodyFrame.h index c5d41cce530..6d629e7c7bb 100644 --- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.h +++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.h @@ -79,9 +79,9 @@ public: NS_IMETHOD PseudoMatches(nsIAtom* aTag, nsCSSSelector* aSelector, PRBool* aResult); // nsIScrollbarMediator - NS_IMETHOD PositionChanged(PRInt32 aOldIndex, PRInt32& aNewIndex); - NS_IMETHOD ScrollbarButtonPressed(PRInt32 aOldIndex, PRInt32 aNewIndex); - NS_IMETHOD VisibilityChanged(PRBool aVisible) { Invalidate(); return NS_OK; }; + NS_IMETHOD PositionChanged(nsISupports* aScrollbar, PRInt32 aOldIndex, PRInt32& aNewIndex); + NS_IMETHOD ScrollbarButtonPressed(nsISupports* aScrollbar, PRInt32 aOldIndex, PRInt32 aNewIndex); + NS_IMETHOD VisibilityChanged(nsISupports* aScrollbar, PRBool aVisible) { Invalidate(); return NS_OK; }; // Overridden from nsIFrame to cache our pres context. NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, diff --git a/widget/public/nsINativeScrollbar.idl b/widget/public/nsINativeScrollbar.idl index 1d67760a911..3ce91c8863c 100644 --- a/widget/public/nsINativeScrollbar.idl +++ b/widget/public/nsINativeScrollbar.idl @@ -53,10 +53,10 @@ interface nsIContent; interface nsIScrollbarMediator; -[uuid(dd1cb116-1dd1-11b2-9e67-abac4e09d533)] +[uuid(b77380bc-610b-49e3-8df7-18cc946285c5)] interface nsINativeScrollbar : nsISupports { - void setContent ( in nsIContent content, in nsIScrollbarMediator mediator); + void setContent ( in nsIContent content, in nsISupports scrollbar, in nsIScrollbarMediator mediator); readonly attribute long narrowSize; // the width of a vertical scrollbar, height of horizontal diff --git a/widget/src/cocoa/nsNativeScrollbar.h b/widget/src/cocoa/nsNativeScrollbar.h index c4123bef857..d8495243a71 100644 --- a/widget/src/cocoa/nsNativeScrollbar.h +++ b/widget/src/cocoa/nsNativeScrollbar.h @@ -93,7 +93,8 @@ private: nsIContent* mContent; // the content node that affects the scrollbar's value nsIScrollbarMediator* mMediator; // for scrolling with outliners - + nsISupports* mScrollbar; // for calling into the mediator + PRUint32 mValue; PRUint32 mMaxValue; PRUint32 mVisibleImageSize; diff --git a/widget/src/cocoa/nsNativeScrollbar.mm b/widget/src/cocoa/nsNativeScrollbar.mm index 367ec087d0a..1ebb2742c63 100644 --- a/widget/src/cocoa/nsNativeScrollbar.mm +++ b/widget/src/cocoa/nsNativeScrollbar.mm @@ -63,6 +63,7 @@ nsNativeScrollbar::nsNativeScrollbar() : nsChildView() , mContent(nsnull) , mMediator(nsnull) + , mScrollbar(nsnull) , mValue(0) , mMaxValue(0) , mVisibleImageSize(0) @@ -143,7 +144,7 @@ nsNativeScrollbar::DoScroll(NSScrollerPart inPart) newPos = oldPos - (mLineIncrement ? mLineIncrement : 1); if ( mMediator ) { BoundsCheck(0, newPos, mMaxValue); - mMediator->ScrollbarButtonPressed(oldPos, newPos); + mMediator->ScrollbarButtonPressed(mScrollbar, oldPos, newPos); } else { UpdateContentPosition(newPos); } @@ -153,7 +154,7 @@ nsNativeScrollbar::DoScroll(NSScrollerPart inPart) newPos = oldPos + (mLineIncrement ? mLineIncrement : 1); if ( mMediator ) { BoundsCheck(0, newPos, mMaxValue); - mMediator->ScrollbarButtonPressed(oldPos, newPos); + mMediator->ScrollbarButtonPressed(mScrollbar, oldPos, newPos); } else { UpdateContentPosition(newPos); } @@ -174,7 +175,7 @@ nsNativeScrollbar::DoScroll(NSScrollerPart inPart) PRInt32 op = oldPos, np = mValue; if ( np < 0 ) np = 0; - mMediator->PositionChanged(op, np); + mMediator->PositionChanged(mScrollbar, op, np); } break; @@ -185,7 +186,7 @@ nsNativeScrollbar::DoScroll(NSScrollerPart inPart) PRInt32 op = oldPos, np = mValue; if ( np < 0 ) np = 0; - mMediator->PositionChanged(op, np); + mMediator->PositionChanged(mScrollbar, op, np); } break; @@ -202,7 +203,7 @@ nsNativeScrollbar::DoScroll(NSScrollerPart inPart) PRInt32 op = oldPos, np = mValue; if ( np < 0 ) np = 0; - mMediator->PositionChanged(op, np); + mMediator->PositionChanged(mScrollbar, op, np); } break; @@ -414,10 +415,12 @@ nsNativeScrollbar::GetNarrowSize(PRInt32* outSize) // care about the mediator for so we can do row-based scrolling. // NS_IMETHODIMP -nsNativeScrollbar::SetContent(nsIContent* inContent, nsIScrollbarMediator* inMediator) +nsNativeScrollbar::SetContent(nsIContent* inContent, nsISupports* inScrollbar, + nsIScrollbarMediator* inMediator) { mContent = inContent; mMediator = inMediator; + mScrollbar = inScrollbar; if ( mContent ) { // we may have to re-create the scrollbar view as horizontal. Check the diff --git a/widget/src/mac/nsNativeScrollbar.cpp b/widget/src/mac/nsNativeScrollbar.cpp index 3f86382f140..da90b0fe866 100644 --- a/widget/src/mac/nsNativeScrollbar.cpp +++ b/widget/src/mac/nsNativeScrollbar.cpp @@ -101,6 +101,7 @@ nsNativeScrollbar::nsNativeScrollbar() : nsMacControl() , mContent(nsnull) , mMediator(nsnull) + , mScrollbar(nsnull) , mLineIncrement(0) , mMaxValue(0) , mVisibleImageSize(0) @@ -157,7 +158,7 @@ nsNativeScrollbar::DoScrollAction(ControlPartCode part) // update the attributes on the content node (the scroll frame listens // for these attributes and will scroll accordingly). However, // if we have a mediator, we're in an outliner and we have to scroll by - // lines. Outliner ignores the params to ScrollbarButtonPressed() except + // lines. Outliner ignores the indexes in ScrollbarButtonPressed() except // to check if one is greater than the other to indicate direction. // @@ -165,7 +166,7 @@ nsNativeScrollbar::DoScrollAction(ControlPartCode part) newPos = oldPos - (mLineIncrement ? mLineIncrement : 1); if ( mMediator ) { BoundsCheck(0, newPos, mMaxValue); - mMediator->ScrollbarButtonPressed(oldPos, newPos); + mMediator->ScrollbarButtonPressed(mScrollbar, oldPos, newPos); } else { UpdateContentPosition(newPos); } @@ -175,7 +176,7 @@ nsNativeScrollbar::DoScrollAction(ControlPartCode part) newPos = oldPos + (mLineIncrement ? mLineIncrement : 1); if ( mMediator ) { BoundsCheck(0, newPos, mMaxValue); - mMediator->ScrollbarButtonPressed(oldPos, newPos); + mMediator->ScrollbarButtonPressed(mScrollbar, oldPos, newPos); } else { UpdateContentPosition(newPos); } @@ -197,7 +198,7 @@ nsNativeScrollbar::DoScrollAction(ControlPartCode part) PRInt32 op = oldPos, np = mValue; if ( np < 0 ) np = 0; - mMediator->PositionChanged(op, np); + mMediator->PositionChanged(mScrollbar, op, np); } break; @@ -208,7 +209,7 @@ nsNativeScrollbar::DoScrollAction(ControlPartCode part) PRInt32 op = oldPos, np = mValue; if ( np < 0 ) np = 0; - mMediator->PositionChanged(op, np); + mMediator->PositionChanged(mScrollbar, op, np); } break; @@ -219,7 +220,7 @@ nsNativeScrollbar::DoScrollAction(ControlPartCode part) PRInt32 op = oldPos, np = mValue; if ( np < 0 ) np = 0; - mMediator->PositionChanged(op, np); + mMediator->PositionChanged(mScrollbar, op, np); } break; } @@ -512,9 +513,11 @@ nsNativeScrollbar::GetNarrowSize(PRInt32* outSize) // care about the mediator for so we can do row-based scrolling. // NS_IMETHODIMP -nsNativeScrollbar::SetContent(nsIContent* inContent, nsIScrollbarMediator* inMediator) +nsNativeScrollbar::SetContent(nsIContent* inContent, nsISupports* inScrollbar, + nsIScrollbarMediator* inMediator) { mContent = inContent; mMediator = inMediator; + mScrollbar = inScrollbar; return NS_OK; } diff --git a/widget/src/mac/nsNativeScrollbar.h b/widget/src/mac/nsNativeScrollbar.h index 80c92d10c69..850e9448760 100644 --- a/widget/src/mac/nsNativeScrollbar.h +++ b/widget/src/mac/nsNativeScrollbar.h @@ -89,6 +89,7 @@ private: nsIContent* mContent; // the content node that affects the scrollbar's value nsIScrollbarMediator* mMediator; // for scrolling with outliners + nsISupports* mScrollbar; // for calling into the mediator PRUint32 mMaxValue; PRUint32 mVisibleImageSize;