Bug 461576 - nsListBoxBodyFrame shouldn't need to implement nsIListBoxObject - r=enn sr=roc

This commit is contained in:
Benjamin Smedberg 2008-10-28 00:47:19 -04:00
Родитель 87c2e7ef23
Коммит d79f9af814
5 изменённых файлов: 41 добавлений и 20 удалений

Просмотреть файл

@ -8690,9 +8690,8 @@ PRBool NotifyListBoxBody(nsPresContext* aPresContext,
xulElement->GetBoxObject(getter_AddRefs(boxObject));
nsCOMPtr<nsPIListBoxObject> listBoxObject = do_QueryInterface(boxObject);
if (listBoxObject) {
nsIListBoxObject* listboxBody = listBoxObject->GetListBoxBody(PR_FALSE);
if (listboxBody) {
nsListBoxBodyFrame *listBoxBodyFrame = static_cast<nsListBoxBodyFrame*>(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....

Просмотреть файл

@ -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)

Просмотреть файл

@ -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<nsPIBoxObject> mBoxObject;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsListBoxBodyFrame, NS_LISTBOXBODYFRAME_IID)
#endif // nsListBoxBodyFrame_h

Просмотреть файл

@ -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<nsListBoxBodyFrame*>(listBoxBody)->SetBoxObject(this),
listBoxBody->SetBoxObject(this),
nsnull);
mListBoxBody = listBoxBody;
return mListBoxBody;

Просмотреть файл

@ -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)