diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 7109bdb830e8..1f46f4eeece8 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -8690,9 +8690,8 @@ PRBool NotifyListBoxBody(nsPresContext* aPresContext, xulElement->GetBoxObject(getter_AddRefs(boxObject)); nsCOMPtr listBoxObject = do_QueryInterface(boxObject); if (listBoxObject) { - nsIListBoxObject* listboxBody = listBoxObject->GetListBoxBody(PR_FALSE); - if (listboxBody) { - nsListBoxBodyFrame *listBoxBodyFrame = static_cast(listboxBody); + nsListBoxBodyFrame* listBoxBodyFrame = listBoxObject->GetListBoxBody(PR_FALSE); + if (listBoxBodyFrame) { if (aOperation == CONTENT_REMOVED) { // Except if we have an aChildFrame and its parent is not the right // thing, then we don't do this. Pseudo frames are so much fun.... diff --git a/layout/xul/base/src/nsListBoxBodyFrame.cpp b/layout/xul/base/src/nsListBoxBodyFrame.cpp index 51aec8a884cd..f13ccd8b981e 100644 --- a/layout/xul/base/src/nsListBoxBodyFrame.cpp +++ b/layout/xul/base/src/nsListBoxBodyFrame.cpp @@ -224,8 +224,12 @@ nsListBoxBodyFrame::Release(void) // QueryInterface // NS_INTERFACE_MAP_BEGIN(nsListBoxBodyFrame) - NS_INTERFACE_MAP_ENTRY(nsIListBoxObject) NS_INTERFACE_MAP_ENTRY(nsIScrollbarMediator) + if (aIID.Equals(NS_GET_IID(nsListBoxBodyFrame))) { + *aInstancePtr = this; + return NS_OK; + } + else NS_INTERFACE_MAP_END_INHERITING(nsBoxFrame) diff --git a/layout/xul/base/src/nsListBoxBodyFrame.h b/layout/xul/base/src/nsListBoxBodyFrame.h index c2994a2a3efc..671507a1645c 100644 --- a/layout/xul/base/src/nsListBoxBodyFrame.h +++ b/layout/xul/base/src/nsListBoxBodyFrame.h @@ -51,6 +51,10 @@ #include "nsThreadUtils.h" #include "nsPIBoxObject.h" +#define NS_LISTBOXBODYFRAME_IID \ +{ 0x6e0acf13, 0x0b07, 0x481d, \ + { 0xa3, 0x39, 0x4c, 0xb6, 0x44, 0xbc, 0x1b, 0xd8 } } + class nsListScrollSmoother; nsIFrame* NS_NewListBoxBodyFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, @@ -58,7 +62,6 @@ nsIFrame* NS_NewListBoxBodyFrame(nsIPresShell* aPresShell, nsIBoxLayout* aLayoutManager = nsnull); class nsListBoxBodyFrame : public nsBoxFrame, - public nsIListBoxObject, public nsIScrollbarMediator, public nsIReflowCallback { @@ -66,8 +69,19 @@ class nsListBoxBodyFrame : public nsBoxFrame, virtual ~nsListBoxBodyFrame(); public: + NS_DECLARE_STATIC_IID_ACCESSOR(NS_LISTBOXBODYFRAME_IID) + NS_DECL_ISUPPORTS - NS_DECL_NSILISTBOXOBJECT + + // non-virtual nsIListBoxObject + nsresult GetRowCount(PRInt32 *aResult); + nsresult GetNumberOfVisibleRows(PRInt32 *aResult); + nsresult GetIndexOfFirstVisibleRow(PRInt32 *aResult); + nsresult EnsureIndexIsVisible(PRInt32 aRowIndex); + nsresult ScrollToIndex(PRInt32 aRowIndex); + nsresult ScrollByLines(PRInt32 aNumLines); + nsresult GetItemAtIndex(PRInt32 aIndex, nsIDOMElement **aResult); + nsresult GetIndexOfItem(nsIDOMElement *aItem, PRInt32 *aResult); friend nsIFrame* NS_NewListBoxBodyFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, @@ -209,4 +223,6 @@ protected: nsCOMPtr mBoxObject; }; +NS_DEFINE_STATIC_IID_ACCESSOR(nsListBoxBodyFrame, NS_LISTBOXBODYFRAME_IID) + #endif // nsListBoxBodyFrame_h diff --git a/layout/xul/base/src/nsListBoxObject.cpp b/layout/xul/base/src/nsListBoxObject.cpp index 97cdc558f1b8..2fb640abf049 100644 --- a/layout/xul/base/src/nsListBoxObject.cpp +++ b/layout/xul/base/src/nsListBoxObject.cpp @@ -56,7 +56,7 @@ public: NS_DECL_NSILISTBOXOBJECT // nsPIListBoxObject - virtual nsIListBoxObject* GetListBoxBody(PRBool aFlush); + virtual nsListBoxBodyFrame* GetListBoxBody(PRBool aFlush); nsListBoxObject(); @@ -65,7 +65,7 @@ public: virtual void ClearCachedValues(); protected: - nsIListBoxObject* mListBoxBody; + nsListBoxBodyFrame *mListBoxBody; }; NS_IMPL_ISUPPORTS_INHERITED2(nsListBoxObject, nsBoxObject, nsIListBoxObject, @@ -82,7 +82,7 @@ nsListBoxObject::nsListBoxObject() NS_IMETHODIMP nsListBoxObject::GetRowCount(PRInt32 *aResult) { - nsIListBoxObject* body = GetListBoxBody(PR_TRUE); + nsListBoxBodyFrame* body = GetListBoxBody(PR_TRUE); if (body) return body->GetRowCount(aResult); return NS_OK; @@ -91,7 +91,7 @@ nsListBoxObject::GetRowCount(PRInt32 *aResult) NS_IMETHODIMP nsListBoxObject::GetNumberOfVisibleRows(PRInt32 *aResult) { - nsIListBoxObject* body = GetListBoxBody(PR_TRUE); + nsListBoxBodyFrame* body = GetListBoxBody(PR_TRUE); if (body) return body->GetNumberOfVisibleRows(aResult); return NS_OK; @@ -100,7 +100,7 @@ nsListBoxObject::GetNumberOfVisibleRows(PRInt32 *aResult) NS_IMETHODIMP nsListBoxObject::GetIndexOfFirstVisibleRow(PRInt32 *aResult) { - nsIListBoxObject* body = GetListBoxBody(PR_TRUE); + nsListBoxBodyFrame* body = GetListBoxBody(PR_TRUE); if (body) return body->GetIndexOfFirstVisibleRow(aResult); return NS_OK; @@ -108,7 +108,7 @@ nsListBoxObject::GetIndexOfFirstVisibleRow(PRInt32 *aResult) NS_IMETHODIMP nsListBoxObject::EnsureIndexIsVisible(PRInt32 aRowIndex) { - nsIListBoxObject* body = GetListBoxBody(PR_TRUE); + nsListBoxBodyFrame* body = GetListBoxBody(PR_TRUE); if (body) return body->EnsureIndexIsVisible(aRowIndex); return NS_OK; @@ -117,7 +117,7 @@ NS_IMETHODIMP nsListBoxObject::EnsureIndexIsVisible(PRInt32 aRowIndex) NS_IMETHODIMP nsListBoxObject::ScrollToIndex(PRInt32 aRowIndex) { - nsIListBoxObject* body = GetListBoxBody(PR_TRUE); + nsListBoxBodyFrame* body = GetListBoxBody(PR_TRUE); if (body) return body->ScrollToIndex(aRowIndex); return NS_OK; @@ -126,7 +126,7 @@ nsListBoxObject::ScrollToIndex(PRInt32 aRowIndex) NS_IMETHODIMP nsListBoxObject::ScrollByLines(PRInt32 aNumLines) { - nsIListBoxObject* body = GetListBoxBody(PR_TRUE); + nsListBoxBodyFrame* body = GetListBoxBody(PR_TRUE); if (body) return body->ScrollByLines(aNumLines); return NS_OK; @@ -135,7 +135,7 @@ nsListBoxObject::ScrollByLines(PRInt32 aNumLines) NS_IMETHODIMP nsListBoxObject::GetItemAtIndex(PRInt32 index, nsIDOMElement **_retval) { - nsIListBoxObject* body = GetListBoxBody(PR_TRUE); + nsListBoxBodyFrame* body = GetListBoxBody(PR_TRUE); if (body) return body->GetItemAtIndex(index, _retval); return NS_OK; @@ -146,7 +146,7 @@ nsListBoxObject::GetIndexOfItem(nsIDOMElement* aElement, PRInt32 *aResult) { *aResult = 0; - nsIListBoxObject* body = GetListBoxBody(PR_TRUE); + nsListBoxBodyFrame* body = GetListBoxBody(PR_TRUE); if (body) return body->GetIndexOfItem(aElement, aResult); return NS_OK; @@ -180,7 +180,7 @@ FindBodyContent(nsIContent* aParent, nsIContent** aResult) } } -nsIListBoxObject* +nsListBoxBodyFrame* nsListBoxObject::GetListBoxBody(PRBool aFlush) { if (mListBoxBody) { @@ -217,10 +217,10 @@ nsListBoxObject::GetListBoxBody(PRBool aFlush) return nsnull; // It's a frame. Refcounts are irrelevant. - nsIListBoxObject* listBoxBody = nsnull; + nsListBoxBodyFrame* listBoxBody = nsnull; CallQueryInterface(yeahBaby, &listBoxBody); NS_ENSURE_TRUE(listBoxBody && - static_cast(listBoxBody)->SetBoxObject(this), + listBoxBody->SetBoxObject(this), nsnull); mListBoxBody = listBoxBody; return mListBoxBody; diff --git a/layout/xul/base/src/nsPIListBoxObject.h b/layout/xul/base/src/nsPIListBoxObject.h index a194aadec48c..fd77892a96e5 100644 --- a/layout/xul/base/src/nsPIListBoxObject.h +++ b/layout/xul/base/src/nsPIListBoxObject.h @@ -38,6 +38,8 @@ #ifndef nsPIListBoxObject_h__ #define nsPIListBoxObject_h__ +class nsListBoxBodyFrame; + // fa9549f7-ee09-48fc-89f7-30cceee21c15 #define NS_PILISTBOXOBJECT_IID \ { 0xfa9549f7, 0xee09, 0x48fc, \ @@ -52,7 +54,7 @@ class nsPIListBoxObject : public nsIListBoxObject { * Get the list box body. This will search for it as needed. * If aFlush is PR_FALSE we don't Flush_Frames though. */ - virtual nsIListBoxObject* GetListBoxBody(PRBool aFlush) = 0; + virtual nsListBoxBodyFrame* GetListBoxBody(PRBool aFlush) = 0; }; NS_DEFINE_STATIC_IID_ACCESSOR(nsPIListBoxObject, NS_PILISTBOXOBJECT_IID)