diff --git a/layout/xul/base/src/nsBoxFrame.cpp b/layout/xul/base/src/nsBoxFrame.cpp index 2249b1aa2cf0..39967d067e8e 100644 --- a/layout/xul/base/src/nsBoxFrame.cpp +++ b/layout/xul/base/src/nsBoxFrame.cpp @@ -1470,8 +1470,6 @@ nsBoxFrameInner::GetDebugPref(nsIPresContext* aPresContext) } } -#include "nsIMonument.h" - NS_IMETHODIMP nsBoxFrame::Paint(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, diff --git a/layout/xul/base/src/nsGridLayout.cpp b/layout/xul/base/src/nsGridLayout.cpp deleted file mode 100644 index 1f2b26f68f5b..000000000000 --- a/layout/xul/base/src/nsGridLayout.cpp +++ /dev/null @@ -1,218 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -// -// Eric Vaughan -// Netscape Communications -// -// See documentation in associated header file -// - -#include "nsGridLayout.h" -#include "nsTempleLayout.h" -#include "nsIBox.h" -#include "nsIScrollableFrame.h" - -nsresult -NS_NewGridLayout( nsIPresShell* aPresShell, nsCOMPtr& aNewLayout) -{ - aNewLayout = new nsGridLayout(aPresShell); - - return NS_OK; - -} - -nsGridLayout::nsGridLayout(nsIPresShell* aPresShell):nsStackLayout() -{ -} - -/** - * Get the monuments in the other temple at the give monument index - */ -NS_IMETHODIMP -nsGridLayout::GetOtherMonumentsAt(nsIBox* aBox, PRInt32 aIndexOfObelisk, nsBoxSizeList** aList, nsMonumentLayout* aRequestor) -{ - nsTempleLayout* temple = nsnull; - nsIBox* templeBox = nsnull; - GetOtherTemple(aBox, &temple, &templeBox, aRequestor); - if (temple) - { - nsresult rv = temple->GetMonumentsAt(templeBox, aIndexOfObelisk, aList); - NS_RELEASE(temple); - return rv; - } - else - *aList = nsnull; - - return NS_OK; -} - -/** - * a Grid always has 2 temples. This is called by one temple to get the other - */ -NS_IMETHODIMP -nsGridLayout::GetOtherTemple(nsIBox* aBox, nsTempleLayout** aTemple, nsIBox** aTempleBox, nsMonumentLayout* aRequestor) -{ - // this is really easy. We know the index of the temple who requested - // so find our other temple who doesn't have that index. - - nsIBox* child = nsnull; - aBox->GetChildBox(&child); - - while(child) - { - nsIBox* oldBox = child; - nsresult rv = NS_OK; - nsCOMPtr scrollFrame = do_QueryInterface(child, &rv); - if (scrollFrame) { - nsIFrame* scrolledFrame = nsnull; - scrollFrame->GetScrolledFrame(nsnull, scrolledFrame); - NS_ASSERTION(scrolledFrame,"Error no scroll frame!!"); - nsCOMPtr b = do_QueryInterface(scrolledFrame); - child = b; - } - - nsCOMPtr layout; - child->GetLayoutManager(getter_AddRefs(layout)); - - // must find a temple that is not our requestor and is a monument. - if (layout != aRequestor) { - nsCOMPtr monument( do_QueryInterface(layout) ); - if (monument) - { - nsTempleLayout* temple = nsnull; - monument->CastToTemple(&temple); - if (temple) { - // yes its a temple. - *aTemple = temple; - *aTempleBox = child; - NS_ADDREF(temple); - return NS_OK; - } - } - } - - if (scrollFrame) { - child = oldBox; - } - - child->GetNextBox(&child); - } - - *aTemple = nsnull; - - return NS_OK; -} - - -NS_IMETHODIMP -nsGridLayout::CastToTemple(nsTempleLayout** aTemple) -{ - *aTemple = nsnull; - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -nsGridLayout::CastToObelisk(nsObeliskLayout** aObelisk) -{ - *aObelisk = nsnull; - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -nsGridLayout::CastToGrid(nsGridLayout** aGrid) -{ - *aGrid = this; - return NS_OK; -} - -NS_IMETHODIMP -nsGridLayout::GetParentMonument(nsIBox* aBox, nsCOMPtr& aParentBox, nsIMonument** aParentMonument) -{ - NS_ERROR("Should not be called"); - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -nsGridLayout::GetOtherMonuments(nsIBox* aBox, nsBoxSizeList** aList) -{ - NS_ERROR("Should not be called"); - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -nsGridLayout::GetMonumentsAt(nsIBox* aBox, PRInt32 aMonumentIndex, nsBoxSizeList** aList) -{ - NS_ERROR("Should not be called"); - return NS_ERROR_FAILURE; -} - - -NS_IMETHODIMP -nsGridLayout::BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize*& aFirst, nsBoxSize*& aLast, PRBool aIsHorizontal) -{ - NS_ERROR("Should not be called"); - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -nsGridLayout::GetMonumentList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSizeList** aList) -{ - NS_ERROR("Should not be called"); - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -nsGridLayout::EnscriptionChanged(nsBoxLayoutState& aState, PRInt32 aIndex) -{ - NS_ERROR("Should Never be Called!"); - return NS_OK; -} - -NS_IMETHODIMP -nsGridLayout::DesecrateMonuments(nsIBox* aBox, nsBoxLayoutState& aState) -{ - return NS_OK; -} - -NS_IMPL_ADDREF_INHERITED(nsGridLayout, nsStackLayout); -NS_IMPL_RELEASE_INHERITED(nsGridLayout, nsStackLayout); - -NS_INTERFACE_MAP_BEGIN(nsGridLayout) - NS_INTERFACE_MAP_ENTRY(nsIMonument) - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIMonument) -NS_INTERFACE_MAP_END_INHERITING(nsStackLayout) diff --git a/layout/xul/base/src/nsGridLayout.h b/layout/xul/base/src/nsGridLayout.h deleted file mode 100644 index 1de31fe1df26..000000000000 --- a/layout/xul/base/src/nsGridLayout.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/** - - Author: - Eric D Vaughan - -**/ - -#ifndef nsGridLayout_h___ -#define nsGridLayout_h___ - -#include "nsStackLayout.h" -#include "nsIMonument.h" -#include "nsCOMPtr.h" -#include "nsIBox.h" - -class nsTempleLayout; -class nsMonumentLayout; -class nsBoxSizeList; - -class nsGridLayout : public nsStackLayout, - public nsIMonument -{ -public: - - friend nsresult NS_NewGridLayout(nsIPresShell* aPresShell, nsCOMPtr& aNewLayout); - - NS_DECL_ISUPPORTS_INHERITED - - NS_IMETHOD CastToTemple(nsTempleLayout** aTemple); - NS_IMETHOD CastToObelisk(nsObeliskLayout** aObelisk); - NS_IMETHOD CastToGrid(nsGridLayout** aGrid); - - NS_IMETHOD GetOtherMonuments(nsIBox* aBox, nsBoxSizeList** aList); - NS_IMETHOD GetOtherMonumentsAt(nsIBox* aBox, PRInt32 aIndexOfObelisk, nsBoxSizeList** aList, nsMonumentLayout* aRequestor = nsnull); - NS_IMETHOD GetOtherTemple(nsIBox* aBox, nsTempleLayout** aTemple, nsIBox** aTempleBox, nsMonumentLayout* aRequestor = nsnull); - NS_IMETHOD GetMonumentsAt(nsIBox* aBox, PRInt32 aMonumentIndex, nsBoxSizeList** aList); - NS_IMETHOD BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize*& aFirst, nsBoxSize*& aLast, PRBool aIsHorizontal); - NS_IMETHOD GetParentMonument(nsIBox* aBox, nsCOMPtr& aParentBox, nsIMonument** aParentMonument); - NS_IMETHOD GetMonumentList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSizeList** aList); - NS_IMETHOD EnscriptionChanged(nsBoxLayoutState& aState, PRInt32 aIndex); - NS_IMETHOD DesecrateMonuments(nsIBox* aBox, nsBoxLayoutState& aState); - -protected: - nsGridLayout(nsIPresShell* aShell); -}; // class nsGridLayout - -#endif - diff --git a/layout/xul/base/src/nsIMonument.h b/layout/xul/base/src/nsIMonument.h deleted file mode 100644 index a4a8d575c401..000000000000 --- a/layout/xul/base/src/nsIMonument.h +++ /dev/null @@ -1,117 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsIMonument_h___ -#define nsIMonument_h___ - -#include "nsISupports.h" -#include "nsIFrame.h" -#include "nsIBox.h" - -class nsIBox; -class nsBoxLayoutState; -class nsTempleLayout; -class nsGridLayout; -class nsObeliskLayout; -class nsMonumentLayout; -class nsBoxLayoutState; -class nsIPresShell; -class nsBoxSize; -class nsBoxSizeList; - -class nsBoxSizeListener -{ -public: - virtual void WillBeDestroyed(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSizeList& aList)=0; - virtual void Desecrated(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSizeList& aList)=0; -}; - -class nsBoxSizeList -{ -public: - virtual ~nsBoxSizeList() {} - virtual nsBoxSize GetBoxSize(nsBoxLayoutState& aState, PRBool aIsHorizontal)=0; - virtual nsBoxSizeList* GetFirst()=0; - virtual nsBoxSizeList* GetLast()=0; - virtual nsBoxSizeList* GetNext()=0; - virtual nsBoxSizeList* GetParent()=0; - virtual nsBoxSizeList* GetAt(PRInt32 aIndex)=0; - virtual nsBoxSizeList* Get(nsIBox* aBox)=0; - virtual void SetParent(nsBoxSizeList* aParent)=0; - virtual void SetNext(nsBoxLayoutState& aState, nsBoxSizeList* aNext)=0; - virtual void Append(nsBoxLayoutState& aState, nsBoxSizeList* aChild)=0; - virtual void Clear(nsBoxLayoutState& aState)=0; - virtual PRInt32 GetCount()=0; - virtual void Desecrate(nsBoxLayoutState& aState)=0; - virtual void MarkDirty(nsBoxLayoutState& aState)=0; - virtual void AddRef()=0; - virtual void Release(nsBoxLayoutState& aState)=0; - virtual void Destroy(nsBoxLayoutState& aState)=0; - virtual PRBool IsSet()=0; - virtual nsIBox* GetBox()=0; - virtual PRInt32 GetRefCount()=0; - virtual PRBool SetListener(nsIBox* aBox, nsBoxSizeListener& aListener)=0; - virtual void RemoveListener()=0; - virtual void SetAdjacent(nsBoxLayoutState& aState, nsBoxSizeList* aList)=0; - virtual nsBoxSizeList* GetAdjacent()=0; -}; - -// {AF0C1603-06C3-11d4-BA07-001083023C1E} -#define NS_IMONUMENT_IID { 0xaf0c1603, 0x6c3, 0x11d4, { 0xba, 0x7, 0x0, 0x10, 0x83, 0x2, 0x3c, 0x1e } }; - -class nsIMonument : public nsISupports { - -public: - - static const nsIID& GetIID() { static nsIID iid = NS_IMONUMENT_IID; return iid; } - - NS_IMETHOD CastToTemple(nsTempleLayout** aTemple)=0; - NS_IMETHOD CastToObelisk(nsObeliskLayout** aObelisk)=0; - NS_IMETHOD CastToGrid(nsGridLayout** aGrid)=0; - NS_IMETHOD GetOtherMonuments(nsIBox* aBox, nsBoxSizeList** aList)=0; - NS_IMETHOD GetOtherMonumentsAt(nsIBox* aBox, PRInt32 aIndexOfObelisk, nsBoxSizeList** aList, nsMonumentLayout* aRequestor = nsnull)=0; - NS_IMETHOD GetOtherTemple(nsIBox* aBox, nsTempleLayout** aTemple, nsIBox** aTempleBox, nsMonumentLayout* aRequestor = nsnull)=0; - NS_IMETHOD GetMonumentsAt(nsIBox* aBox, PRInt32 aMonumentIndex, nsBoxSizeList** aList)=0; - NS_IMETHOD BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize*& aFirst, nsBoxSize*& aLast, PRBool aIsHorizontal)=0; - NS_IMETHOD GetParentMonument(nsIBox* aBox, nsCOMPtr& aParentBox, nsIMonument** aParentMonument)=0; - NS_IMETHOD GetMonumentList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSizeList** aList)=0; - NS_IMETHOD EnscriptionChanged(nsBoxLayoutState& aState, PRInt32 aIndex)=0; - NS_IMETHOD DesecrateMonuments(nsIBox* aBox, nsBoxLayoutState& aState)=0; -}; - -#endif - diff --git a/layout/xul/base/src/nsMonumentLayout.cpp b/layout/xul/base/src/nsMonumentLayout.cpp deleted file mode 100644 index 099a801e0f74..000000000000 --- a/layout/xul/base/src/nsMonumentLayout.cpp +++ /dev/null @@ -1,745 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -// -// Eric Vaughan -// Netscape Communications -// -// See documentation in associated header file -// - -#include "nsMonumentLayout.h" -#include "nsBoxLayoutState.h" -#include "nsIBox.h" -#include "nsIScrollableFrame.h" -#include "nsBox.h" - -// ----- Monument Iterator ----- - -nsLayoutIterator::nsLayoutIterator(nsIBox* aBox):mBox(nsnull),mStartBox(aBox),mParentCount(0) -{ -} - -void -nsLayoutIterator::Reset() -{ - mBox = nsnull; -} - -PRBool -nsLayoutIterator::GetNextLayout(nsIBoxLayout** aLayout, PRBool aSearchChildren) -{ - if (mBox == nsnull) { - mBox = mStartBox; - } else { - if (aSearchChildren) { - mParents[mParentCount++] = mBox; - NS_ASSERTION(mParentCount < PARENT_STACK_SIZE, "Stack overflow!!"); - mBox->GetChildBox(&mBox); - } else { - mBox->GetNextBox(&mBox); - } - } - - return DigDeep(aLayout, aSearchChildren); -} - -PRBool -nsLayoutIterator::DigDeep(nsIBoxLayout** aLayout, PRBool aSearchChildren) -{ - // if our box is null. See if we have any parents on the stack - // if so pop them off and continue. - if (!mBox) { - if (mParentCount > 0) { - mBox = mParents[--mParentCount]; - mBox->GetNextBox(&mBox); - return DigDeep(aLayout, aSearchChildren); - } - - *aLayout = nsnull; - return PR_FALSE; - } - - // if its a scrollframe. Then continue down into the scrolled frame - nsresult rv = NS_OK; - nsCOMPtr scrollFrame = do_QueryInterface(mBox, &rv); - if (scrollFrame) { - nsIFrame* scrolledFrame = nsnull; - scrollFrame->GetScrolledFrame(nsnull, scrolledFrame); - NS_ASSERTION(scrolledFrame,"Error no scroll frame!!"); - mParents[mParentCount++] = mBox; - NS_ASSERTION(mParentCount < PARENT_STACK_SIZE, "Stack overflow!!"); - nsCOMPtr b = do_QueryInterface(scrolledFrame); - mBox = b; - } - - // get the layout manager - nsCOMPtr layout; - - mBox->GetLayoutManager(getter_AddRefs(layout)); - - // if we are supposed to search our children. And the layout manager - // was null. Then dig into the children. - if (aSearchChildren && !layout) - { - mParents[mParentCount++] = mBox; - NS_ASSERTION(mParentCount < PARENT_STACK_SIZE, "Stack overflow!!"); - mBox->GetChildBox(&mBox); - return DigDeep(aLayout, aSearchChildren); - } - - *aLayout = layout; - NS_IF_ADDREF(*aLayout); - if (layout) - return PR_TRUE; - else - return PR_FALSE; -} - - -// ---- Monument Iterator ----- - -nsMonumentIterator::nsMonumentIterator(nsIBox* aBox):nsLayoutIterator(aBox) -{ -} - -PRBool -nsMonumentIterator::GetNextMonument(nsIMonument** aMonument, PRBool aSearchChildren) -{ - nsCOMPtr layout; - - while(GetNextLayout(getter_AddRefs(layout), aSearchChildren)) { - if (layout) - { - nsresult rv = NS_OK; - nsCOMPtr monument = do_QueryInterface(layout, &rv); - *aMonument = monument; - - if (monument) { - NS_IF_ADDREF(*aMonument); - return PR_TRUE; - } - } - } - - return PR_FALSE; -} - -PRBool -nsMonumentIterator::GetNextObelisk(nsObeliskLayout** aObelisk, PRBool aSearchChildren) -{ - nsCOMPtr monument; - PRBool searchChildren = aSearchChildren; - - while(GetNextMonument(getter_AddRefs(monument), searchChildren)) { - - searchChildren = aSearchChildren; - if (monument) - { - *aObelisk = nsnull; - monument->CastToObelisk(aObelisk); - - if (*aObelisk) { - return PR_TRUE; - } - - // ok we found another grid. Don't enter it. - nsGridLayout* grid = nsnull; - monument->CastToGrid(&grid); - if (grid) { - searchChildren = PR_FALSE; - } - } - } - - *aObelisk = nsnull; - - return PR_FALSE; -} - -//static long _nodes = 0; -//static long _lists = 0; - - -//------ nsInfoListNodeImpl ---- - -nsBoxSizeListNodeImpl::~nsBoxSizeListNodeImpl() -{ - MOZ_COUNT_DTOR(nsBoxSizeListNodeImpl); - //_nodes--; - //printf("Nodes %d\n",_nodes); -} - -void -nsBoxSizeListNodeImpl::Release(nsBoxLayoutState& aState) -{ - Destroy(aState); -} - -void -nsBoxSizeListNodeImpl::Destroy(nsBoxLayoutState& aState) -{ - delete this; -} - -void -nsBoxSizeListNodeImpl::Desecrate(nsBoxLayoutState& aState) -{ - if (mParent) - mParent->Desecrate(aState); -} - -void -nsBoxSizeListNodeImpl::MarkDirty(nsBoxLayoutState& aState) -{ - if (mBox) - mBox->MarkDirty(aState); -} - -void nsBoxSizeListNodeImpl::SetNext(nsBoxLayoutState& aState, nsBoxSizeList* aNext) -{ - mNext = aNext; -} - -void nsBoxSizeListNodeImpl::SetAdjacent(nsBoxLayoutState& aState, nsBoxSizeList* aNext) -{ - mAdjacent = aNext; -} - -void -nsBoxSizeListNodeImpl::Append(nsBoxLayoutState& aState, nsBoxSizeList* aChild) -{ - NS_ERROR("Attept at append to a leaf"); -} - -nsBoxSizeListNodeImpl::nsBoxSizeListNodeImpl(nsIBox* aBox):mNext(nsnull), - mParent(nsnull), - mAdjacent(nsnull), - mBox(aBox), - mRefCount(0), - mIsSet(PR_FALSE) -{ - MOZ_COUNT_CTOR(nsBoxSizeListNodeImpl); - // _nodes++; - // printf("Created. Nodes %d\n",_nodes); -} - -nsBoxSizeList* -nsBoxSizeListNodeImpl::GetAt(PRInt32 aIndex) -{ - nsBoxSizeList* node = this; - PRInt32 count = 0; - while(node) - { - if (count == aIndex) - return node; - - node = node->GetAdjacent(); - count++; - } - - return nsnull; -} - -nsBoxSizeList* -nsBoxSizeListNodeImpl::Get(nsIBox* aBox) -{ - nsBoxSizeList* node = this; - while(node) - { - if (node->GetBox() == aBox) - return node; - - node = node->GetNext(); - } - - return nsnull; -} - -//------ nsInfoListImpl2 ---- - -nsBoxSizeListImpl::nsBoxSizeListImpl(nsIBox* aBox):nsBoxSizeListNodeImpl(aBox), - mFirst(nsnull), - mLast(nsnull), - mCount(0), - mListener(nsnull), - mListenerBox(nsnull) -{ - MOZ_COUNT_CTOR(nsBoxSizeListImpl); - // _lists++; - // printf("Lists %d\n",_lists); -} - - -nsBoxSizeListImpl::~nsBoxSizeListImpl() -{ - MOZ_COUNT_DTOR(nsBoxSizeListImpl); - // _lists--; - // printf("Lists %d\n",_lists); -} - -/* Ownership model nsMonumentLayout - - nsTempleLayout owns - mMonuments (nsBoxSizeListImpl) - - nsBoxSizeListImpl owns - mAdjacent (nsBoxSizeListImpl) - mFirst (nsBoxSizeList) Now mFirst is a list of - nsBoxSizeListImpl or nsBoxSizeListNodeImpl. - It only owns nsBoxSizeNodeImpl not the - nsBoxSizeListImpl. -*/ -void -nsBoxSizeListImpl::Destroy(nsBoxLayoutState& aState) -{ - // notify the listener that we are going away - if (mListener) { - mListener->WillBeDestroyed(mListenerBox, aState, *this); - } - - // tell each of our children to release. If you ask - // a node to release it will delete itself. If you - // ask a list to release it will do nothing because - // Lists are not owned by other lists they are owned - // by Temples. - nsBoxSizeList* list = mFirst; - while(list) - { - nsBoxSizeList* toRelease = list; - list = list->GetNext(); - toRelease->Release(aState); - } - - // now tell each or our adacent children to be destroyed. - if (mAdjacent) - mAdjacent->Destroy(aState); - - delete this; -} - -void -nsBoxSizeListImpl::Release(nsBoxLayoutState& aState) -{ - // do nothing. We can only be destroyed by our owner - // by calling Destroy. - mParent = nsnull; -} - -void -nsBoxSizeListImpl::Clear(nsBoxLayoutState& aState) -{ - nsBoxSizeList* list = mFirst; - while(list) - { - nsBoxSizeList* toRelease = list; - list = list->GetNext(); - toRelease->Release(aState); - } - - mFirst = nsnull; - mLast = nsnull; -} - -void -nsBoxSizeListImpl::Append(nsBoxLayoutState& aState, nsBoxSizeList* aChild) -{ - if (!mFirst) - mFirst = aChild; - else - mLast->SetNext(aState, aChild); - - mLast = aChild; - mLast->SetNext(aState, nsnull); - aChild->SetParent(this); -} - -void -nsBoxSizeListImpl::Desecrate(nsBoxLayoutState& aState) -{ - if (mIsSet) { - mIsSet = PR_FALSE; - if (mListener) - mListener->Desecrated(mListenerBox, aState, *this); - - nsBoxSizeListNodeImpl::Desecrate(aState); - } -} - -void -nsBoxSizeListImpl::MarkDirty(nsBoxLayoutState& aState) -{ - nsBoxSizeList* child = mFirst; - while(child) - { - child->MarkDirty(aState); - child = child->GetNext(); - } - - nsBoxSizeListNodeImpl::MarkDirty(aState); -} - -PRBool -nsBoxSizeListImpl::SetListener(nsIBox* aBox, nsBoxSizeListener& aListener) -{ - if (mListener) - return PR_FALSE; - - mListener = &aListener; - mListenerBox = aBox; - return PR_TRUE; -} - -void -nsBoxSizeListImpl::RemoveListener() -{ - mListener = nsnull; - mListenerBox = nsnull; -} - -nsBoxSize -nsBoxSizeListImpl::GetBoxSize(nsBoxLayoutState& aState, PRBool aIsHorizontal) -{ - if (!mIsSet) { - - mIsSet = PR_TRUE; - - mBoxSize.Clear(); - - nsBoxSizeList* node = mFirst; - - while(node) { - nsBoxSize size = node->GetBoxSize(aState, aIsHorizontal); - - if (size.pref > mBoxSize.pref) - mBoxSize.pref = size.pref; - - if (size.min > mBoxSize.min) - mBoxSize.min = size.min; - - if (mBoxSize.max != NS_INTRINSICSIZE) - if (size.max == NS_INTRINSICSIZE) - mBoxSize.max = size.max; - else - mBoxSize.max += size.max; - - mBoxSize.flex = size.flex; - mBoxSize.ascent = size.ascent; - - node = node->GetNext(); - } - } - - return mBoxSize; -} - -nsBoxSize -nsBoxSizeListNodeImpl::GetBoxSize(nsBoxLayoutState& aState, PRBool aIsHorizontal) -{ - nsBoxSize size; - - nsSize pref(0,0); - nsSize min(0,0); - nsSize max(NS_INTRINSICSIZE,NS_INTRINSICSIZE); - nscoord ascent = 0; - nscoord flex = 0; - - if (!mBox) - return size; - - mBox->GetPrefSize(aState, pref); - mBox->GetMinSize(aState, min); - mBox->GetMaxSize(aState, max); - mBox->GetAscent(aState, ascent); - mBox->GetFlex(aState, flex); - nsBox::AddMargin(mBox, pref); - - size.Add(min, pref, max, ascent, flex, !aIsHorizontal); - - return size; -} - -// ------ nsMonumentLayout ------ - -nsMonumentLayout::nsMonumentLayout(nsIPresShell* aPresShell):nsSprocketLayout() -{ -} - - -NS_IMETHODIMP -nsMonumentLayout::CastToTemple(nsTempleLayout** aTemple) -{ - *aTemple = nsnull; - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -nsMonumentLayout::CastToObelisk(nsObeliskLayout** aObelisk) -{ - *aObelisk = nsnull; - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -nsMonumentLayout::CastToGrid(nsGridLayout** aGrid) -{ - *aGrid = nsnull; - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -nsMonumentLayout::GetParentMonument(nsIBox* aBox, nsCOMPtr& aParentBox, nsIMonument** aParentMonument) -{ - // go up and find our parent monument. Skip and non monument - // parents. - nsCOMPtr layout; - nsCOMPtr parentMonument; - nsresult rv = NS_OK; - *aParentMonument = nsnull; - aBox->GetParentBox(&aBox); - - while (aBox) { - aBox->GetLayoutManager(getter_AddRefs(layout)); - parentMonument = do_QueryInterface(layout, &rv); - if (NS_SUCCEEDED(rv) && parentMonument) { - aParentBox = aBox; - *aParentMonument = parentMonument.get(); - NS_IF_ADDREF(*aParentMonument); - return rv; - } - aBox->GetParentBox(&aBox); - } - - aParentBox = nsnull; - *aParentMonument = nsnull; - return rv; -} - -NS_IMETHODIMP -nsMonumentLayout::GetOtherMonuments(nsIBox* aBox, nsBoxSizeList** aList) -{ - nsCOMPtr parent; - nsCOMPtr parentBox; - GetParentMonument(aBox, parentBox, getter_AddRefs(parent)); - if (parent) - return parent->GetOtherMonumentsAt(parentBox, 0, aList, this); - else - return NS_OK; -} - -/** - * Get the monuments in the other temple at the give monument index - */ -NS_IMETHODIMP -nsMonumentLayout::GetOtherMonumentsAt(nsIBox* aBox, PRInt32 aIndexOfObelisk, nsBoxSizeList** aList, nsMonumentLayout* aRequestor) -{ - nsresult rv = NS_OK; - - PRInt32 index = -1; - nsIBox* child = nsnull; - aBox->GetChildBox(&child); - PRInt32 count = 0; - while(child) - { - nsCOMPtr childBox = child; - nsCOMPtr scrollFrame = do_QueryInterface(child, &rv); - if (scrollFrame) { - nsIFrame* childFrame = nsnull; - scrollFrame->GetScrolledFrame(nsnull, childFrame); - if (!childFrame) - return NS_ERROR_FAILURE; - childBox = do_QueryInterface(childFrame); - } - - nsCOMPtr layout; - childBox->GetLayoutManager(getter_AddRefs(layout)); - - // only all monuments - nsCOMPtr monument = do_QueryInterface(layout, &rv); - if (NS_SUCCEEDED(rv) && monument) - { - if (layout == aRequestor) { - index = count; - break; - } - count++; - } - child->GetNextBox(&child); - } - - NS_ASSERTION(index != -1,"Error can't find requestor!!"); - aIndexOfObelisk += index; - - nsCOMPtr parent; - nsCOMPtr parentBox; - GetParentMonument(aBox, parentBox, getter_AddRefs(parent)); - - if (parent) - parent->GetOtherMonumentsAt(parentBox, aIndexOfObelisk, aList, this); - - return NS_OK; -} - -NS_IMETHODIMP -nsMonumentLayout::GetOtherTemple(nsIBox* aBox, nsTempleLayout** aTemple, nsIBox** aTempleBox, nsMonumentLayout* aRequestor) -{ - nsCOMPtr parent; - nsCOMPtr parentBox; - GetParentMonument(aBox, parentBox, getter_AddRefs(parent)); - if(parent) - parent->GetOtherTemple(parentBox, aTemple, aTempleBox, this); - - return NS_OK; -} - -NS_IMETHODIMP -nsMonumentLayout::GetMonumentsAt(nsIBox* aBox, PRInt32 aMonumentIndex, nsBoxSizeList** aList) -{ - nsBoxLayoutState state((nsIPresContext*)nsnull); - - nsBoxSizeList* list = nsnull; - - GetMonumentList(aBox, state, &list); - - // create an info list for the given column. - PRInt32 count = 0; - while(list) { - if (count == aMonumentIndex) - { - *aList = list; - return NS_OK; - } - list = list->GetAdjacent(); - count++; - } - - return NS_ERROR_FAILURE; -} - - -NS_IMETHODIMP -nsMonumentLayout::BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize*& aFirst, nsBoxSize*& aLast, PRBool aIsHorizontal) -{ - aFirst = aLast = new (aState) nsBoxSize(); - - nsSize pref(0,0); - nsSize min(0,0); - nsSize max(NS_INTRINSICSIZE,NS_INTRINSICSIZE); - nscoord flex = 0; - nscoord ascent = 0; - - aBox->GetPrefSize(aState, pref); - aBox->GetMinSize(aState, min); - aBox->GetMaxSize(aState, max); - aBox->GetAscent(aState, ascent); - aBox->GetFlex(aState, flex); - nsBox::BoundsCheck(min, pref, max); - - nsMargin borderPadding(0,0,0,0); - aBox->GetBorderAndPadding(borderPadding); - - nsMargin margin(0,0,0,0); - aBox->GetMargin(margin); - - aFirst->Add(min, pref, max, ascent, flex, aIsHorizontal); - aFirst->Add(borderPadding,aIsHorizontal); - aFirst->Add(margin,aIsHorizontal); - - return NS_OK; -} - -NS_IMETHODIMP -nsMonumentLayout::GetMonumentList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSizeList** aList) -{ - nsIBox* child = nsnull; - aBox->GetChildBox(&child); - nsBoxSizeList* last = nsnull; - while(child) - { - nsBoxSizeList* newOne = new nsBoxSizeListNodeImpl(child); - if (*aList == nsnull) - *aList = last = newOne; - else { - last->SetAdjacent(aState, newOne); - last = newOne; - } - child->GetNextBox(&child); - } - - return NS_OK; -} - -NS_IMETHODIMP -nsMonumentLayout::EnscriptionChanged(nsBoxLayoutState& aState, PRInt32 aIndex) -{ - NS_ERROR("Should Never be Called!"); - return NS_OK; -} - -NS_IMETHODIMP -nsMonumentLayout::DesecrateMonuments(nsIBox* aBox, nsBoxLayoutState& aState) -{ - NS_ERROR("Should Never be Called!"); - return NS_OK; -} - -PRInt32 -nsMonumentLayout::GetIndexOfChild(nsIBox* aBox, nsIBox* aChild) -{ - nsIBox* child = nsnull; - aBox->GetChildBox(&child); - PRInt32 count = 0; - while(child) - { - if (child == aChild) { - return count; - } - - child->GetNextBox(&child); - count++; - } - - return -1; -} - -NS_IMPL_ADDREF_INHERITED(nsMonumentLayout, nsBoxLayout); -NS_IMPL_RELEASE_INHERITED(nsMonumentLayout, nsBoxLayout); - -NS_INTERFACE_MAP_BEGIN(nsMonumentLayout) - NS_INTERFACE_MAP_ENTRY(nsIMonument) - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIMonument) -NS_INTERFACE_MAP_END_INHERITING(nsBoxLayout) diff --git a/layout/xul/base/src/nsMonumentLayout.h b/layout/xul/base/src/nsMonumentLayout.h deleted file mode 100644 index 5663cb3b615d..000000000000 --- a/layout/xul/base/src/nsMonumentLayout.h +++ /dev/null @@ -1,176 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/** - - Author: - Eric D Vaughan - -**/ - -#ifndef nsMonumentLayout_h___ -#define nsMonumentLayout_h___ - -#include "nsSprocketLayout.h" -#include "nsIMonument.h" -class nsTempleLayout; -class nsGridLayout; -class nsBoxLayoutState; -class nsIPresShell; - -#define PARENT_STACK_SIZE 100 - -class nsLayoutIterator -{ -public: - nsLayoutIterator(nsIBox* aBox); - virtual void Reset(); - virtual PRBool GetNextLayout(nsIBoxLayout** aLayout, PRBool aSearchChildren = PR_FALSE); - virtual void GetBox(nsIBox** aBox) { *aBox = mBox; } - virtual PRBool DigDeep(nsIBoxLayout** aLayout, PRBool aSearchChildren); - -protected: - nsIBox* mBox; - nsIBox* mStartBox; - PRInt32 mParentCount; - nsIBox* mParents[PARENT_STACK_SIZE]; -}; - -class nsMonumentIterator: public nsLayoutIterator -{ -public: - nsMonumentIterator(nsIBox* aBox); - virtual PRBool GetNextMonument(nsIMonument** aMonument, PRBool aSearchChildren = PR_FALSE); - virtual PRBool GetNextObelisk(nsObeliskLayout** aObelisk, PRBool aSearchChildren = PR_FALSE); -}; - -// nsBoxSizeListNodeImpl are OWNED by nsBoxSizeListImpl -class nsBoxSizeListNodeImpl : public nsBoxSizeList -{ -public: - virtual nsBoxSize GetBoxSize(nsBoxLayoutState& aState, PRBool aIsHorizontal); - virtual nsBoxSizeList* GetFirst() { return nsnull; } - virtual nsBoxSizeList* GetLast() { return nsnull; } - virtual nsBoxSizeList* GetNext() { return mNext; } - virtual nsBoxSizeList* GetParent() { return mParent;} - virtual void SetParent(nsBoxSizeList* aParent) { mParent = aParent; } - virtual PRInt32 GetCount() { return 1; } - virtual void SetNext(nsBoxLayoutState& aState, nsBoxSizeList* aNext); - virtual void Append(nsBoxLayoutState& aState, nsBoxSizeList* aChild); - virtual void Clear(nsBoxLayoutState& aState) {} - virtual nsBoxSizeList* GetAt(PRInt32 aIndex); - virtual nsBoxSizeList* Get(nsIBox* aBox); - virtual PRBool SetListener(nsIBox* aBox, nsBoxSizeListener& aListener) { return PR_FALSE; } - virtual void RemoveListener() {} - virtual void Desecrate(nsBoxLayoutState& aState); - virtual void MarkDirty(nsBoxLayoutState& aState); - virtual void AddRef() { mRefCount++; } - virtual void Release(nsBoxLayoutState& aState); - virtual void Destroy(nsBoxLayoutState& aState); - virtual PRInt32 GetRefCount() { return mRefCount; } - virtual PRBool IsSet() { return mIsSet; } - virtual nsIBox* GetBox() { return mBox; } - - virtual void SetAdjacent(nsBoxLayoutState& aState, nsBoxSizeList* aAdjacent); - virtual nsBoxSizeList* GetAdjacent() { return mAdjacent; } - - nsBoxSizeListNodeImpl(nsIBox* aBox); - virtual ~nsBoxSizeListNodeImpl(); - - nsBoxSizeList* mNext; - nsBoxSizeList* mParent; - nsBoxSizeList* mAdjacent; // OWN - nsIBox* mBox; - PRInt32 mRefCount; - PRBool mIsSet; -}; - -// nsBoxSizeListImpl are OWNED by nsTempleLayout -class nsBoxSizeListImpl : public nsBoxSizeListNodeImpl -{ -public: - virtual nsBoxSize GetBoxSize(nsBoxLayoutState& aState, PRBool aIsHorizontal); - virtual nsBoxSizeList* GetFirst() { return mFirst; } - virtual nsBoxSizeList* GetLast() { return mLast; } - virtual PRInt32 GetCount() { return mCount; } - virtual void Desecrate(nsBoxLayoutState& aState); - virtual void MarkDirty(nsBoxLayoutState& aState); - virtual void Append(nsBoxLayoutState& aState, nsBoxSizeList* aChild); - virtual void Clear(nsBoxLayoutState& aState); - virtual PRBool SetListener(nsIBox* aBox, nsBoxSizeListener& aListener); - virtual void RemoveListener(); - virtual void Release(nsBoxLayoutState& aState); - virtual void Destroy(nsBoxLayoutState& aState); - - nsBoxSizeListImpl(nsIBox* aBox); - virtual ~nsBoxSizeListImpl(); - - nsBoxSizeList* mFirst; // OWN children who are nsBoxSizeListNodeImpl but not nsBoxSizeListImpl - nsBoxSizeList* mLast; // OWN children who are nsBoxSizeListNodeImpl but not nsBoxSizeListImpl - PRInt32 mCount; - nsBoxSize mBoxSize; - nsBoxSizeListener* mListener; - nsIBox* mListenerBox; -}; - -class nsMonumentLayout : public nsSprocketLayout, - public nsIMonument -{ -public: - NS_DECL_ISUPPORTS_INHERITED - - NS_IMETHOD CastToTemple(nsTempleLayout** aTemple); - NS_IMETHOD CastToObelisk(nsObeliskLayout** aObelisk); - NS_IMETHOD CastToGrid(nsGridLayout** aGrid); - NS_IMETHOD GetOtherMonuments(nsIBox* aBox, nsBoxSizeList** aList); - NS_IMETHOD GetOtherMonumentsAt(nsIBox* aBox, PRInt32 aIndexOfObelisk, nsBoxSizeList** aList, nsMonumentLayout* aRequestor = nsnull); - NS_IMETHOD GetOtherTemple(nsIBox* aBox, nsTempleLayout** aTemple, nsIBox** aTempleBox, nsMonumentLayout* aRequestor = nsnull); - NS_IMETHOD GetMonumentsAt(nsIBox* aBox, PRInt32 aMonumentIndex, nsBoxSizeList** aList); - NS_IMETHOD BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize*& aFirst, nsBoxSize*& aLast, PRBool aIsHorizontal); - NS_IMETHOD GetParentMonument(nsIBox* aBox, nsCOMPtr& aParentBox, nsIMonument** aParentMonument); - NS_IMETHOD GetMonumentList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSizeList** aList); - NS_IMETHOD EnscriptionChanged(nsBoxLayoutState& aState, PRInt32 aIndex); - NS_IMETHOD DesecrateMonuments(nsIBox* aBox, nsBoxLayoutState& aState); - -protected: - virtual PRInt32 GetIndexOfChild(nsIBox* aBox, nsIBox* aChild); - - nsMonumentLayout(nsIPresShell* aShell); -}; - -#endif - diff --git a/layout/xul/base/src/nsObeliskLayout.cpp b/layout/xul/base/src/nsObeliskLayout.cpp deleted file mode 100644 index 71bc1591877d..000000000000 --- a/layout/xul/base/src/nsObeliskLayout.cpp +++ /dev/null @@ -1,451 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -// -// Eric Vaughan -// Netscape Communications -// -// See documentation in associated header file -// - -#include "nsObeliskLayout.h" -#include "nsTempleLayout.h" -#include "nsBoxLayoutState.h" -#include "nsBox.h" -#include "nsIScrollableFrame.h" - -nsresult -NS_NewObeliskLayout( nsIPresShell* aPresShell, nsCOMPtr& aNewLayout) -{ - aNewLayout = new nsObeliskLayout(aPresShell); - - return NS_OK; - -} - -nsObeliskLayout::nsObeliskLayout(nsIPresShell* aPresShell):nsMonumentLayout(aPresShell), mOtherMonumentList(nsnull) -{ - mOtherMonumentList = nsnull; -} - -nsObeliskLayout::~nsObeliskLayout() -{ - if (mOtherMonumentList) - mOtherMonumentList->RemoveListener(); -} - -NS_IMETHODIMP -nsObeliskLayout::CastToObelisk(nsObeliskLayout** aObelisk) -{ - *aObelisk = this; - return NS_OK; -} - -void -nsObeliskLayout::UpdateMonuments(nsIBox* aBox, nsBoxLayoutState& aState) -{ - if (!mOtherMonumentList) - { - GetOtherMonuments(aBox, &mOtherMonumentList); - if (mOtherMonumentList) { - // if we fail to set the listener the null out our list. - // this could happend if someone put more than 1 or tags in a grid. This is - // technically illegal. But at the moment we can't stop them from doing it. - PRBool wasSet = mOtherMonumentList->SetListener(aBox, *this); - NS_ASSERTION(wasSet, "Too many columns or rows!"); - - // recover gracefully for the optimized bits. - if (!wasSet) - mOtherMonumentList = nsnull; - } - } -} - -NS_IMETHODIMP -nsObeliskLayout::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSize) -{ - nsresult rv = nsMonumentLayout::GetPrefSize(aBox, aState, aSize); - - UpdateMonuments(aBox, aState); - - nsBoxSizeList* node = mOtherMonumentList; - - PRBool isHorizontal = PR_FALSE; - aBox->GetOrientation(isHorizontal); - - if (node) { - // if the infos pref width is greater than aSize's use it. - // if the infos min width is greater than aSize's use it. - // if the infos max width is smaller than aSizes then set it. - nsBoxSize size = node->GetBoxSize(aState, isHorizontal); - - nscoord s = size.pref; - - nsMargin bp(0,0,0,0); - aBox->GetBorderAndPadding(bp); - if (isHorizontal) { - s += bp.top + bp.bottom; - } else { - s += bp.left + bp.right; - } - - nscoord& s2 = GET_HEIGHT(aSize, isHorizontal); - - if (s > s2) - s2 = s; - } - - return rv; -} - -NS_IMETHODIMP -nsObeliskLayout::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSize) -{ - //nsresult rv = nsMonumentLayout::GetMinSize(aBox, aState, aSize); - - PRBool isHorizontal = PR_FALSE; - aBox->GetOrientation(isHorizontal); - - aSize.width = 0; - aSize.height = 0; - - // run through all the children and get there min, max, and preferred sizes - // return us the size of the box - - nsIBox* child = nsnull; - aBox->GetChildBox(&child); - - // our flexes are determined by the other temple. So in getting out min size we need to - // iterator over our temples obelisks. - - nsTempleLayout* temple = nsnull; - nsIBox* aTempleBox = nsnull; - GetOtherTemple(aBox, &temple, &aTempleBox); - NS_IF_RELEASE(temple); - - nsMonumentIterator it(aTempleBox); - - while (child) - { - // ignore collapsed children - //PRBool isCollapsed = PR_FALSE; - //aBox->IsCollapsed(aState, isCollapsed); - - //if (!isCollapsed) - //{ - nsSize min(0,0); - nsSize pref(0,0); - nscoord flex = 0; - - child->GetMinSize(aState, min); - - // get the next obelisk and use its flex. - nsObeliskLayout* obelisk; - it.GetNextObelisk(&obelisk, PR_TRUE); - nsIBox* obeliskBox = nsnull; - it.GetBox(&obeliskBox); - - if (obeliskBox) { - obeliskBox->GetFlex(aState, flex); - } else { - child->GetFlex(aState, flex); - } - - // if the child is not flexible then - // its min size is its pref size. - if (flex == 0) { - child->GetPrefSize(aState, pref); - if (isHorizontal) - min.width = pref.width; - else - min.height = pref.height; - } - - AddMargin(child, min); - AddLargestSize(aSize, min, isHorizontal); - //} - - child->GetNextBox(&child); - } - - UpdateMonuments(aBox, aState); - - nsBoxSizeList* node = mOtherMonumentList; - - if (node) { - // if the infos pref width is greater than aSize's use it. - // if the infos min width is greater than aSize's use it. - // if the infos max width is smaller than aSizes then set it. - nsBoxSize size = node->GetBoxSize(aState, isHorizontal); - - nscoord s = size.min; - - nsMargin bp(0,0,0,0); - aBox->GetBorderAndPadding(bp); - if (isHorizontal) { - s += bp.top + bp.bottom; - } else { - s += bp.left + bp.right; - } - - nscoord& s2 = GET_HEIGHT(aSize, isHorizontal); - - if (s > s2) - s2 = s; - } - - return NS_OK; -} - -NS_IMETHODIMP -nsObeliskLayout::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSize) -{ - nsresult rv = nsMonumentLayout::GetMaxSize(aBox, aState, aSize); - - UpdateMonuments(aBox, aState); - - nsBoxSizeList* node = mOtherMonumentList; - - PRBool isHorizontal = PR_FALSE; - aBox->GetOrientation(isHorizontal); - - if (node) { - // if the infos pref width is greater than aSize's use it. - // if the infos min width is greater than aSize's use it. - // if the infos max width is smaller than aSizes then set it. - nsBoxSize size = node->GetBoxSize(aState, isHorizontal); - - nscoord s = size.max; - nscoord& s2 = GET_HEIGHT(aSize, isHorizontal); - - if (s > s2) - s2 = s; - - } - - return rv; -} - -NS_IMETHODIMP -nsObeliskLayout::ChildBecameDirty(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChild) -{ - // if one of our cells has changed size and needs reflow - // make sure we clean any cached information about it. - nsCOMPtr parent; - nsCOMPtr parentBox; - GetParentMonument(aBox, parentBox, getter_AddRefs(parent)); - if (!parent) - return NS_OK; - - nsIBox* child = nsnull; - aBox->GetChildBox(&child); - PRInt32 count = 0; - nsCOMPtr layout; - while(child) - { - if (child == aChild) { - parent->EnscriptionChanged(aState, count); - return NS_OK; - } - - child->GetNextBox(&child); - count++; - } - - return NS_OK; -} - -NS_IMETHODIMP -nsObeliskLayout::BecameDirty(nsIBox* aBox, nsBoxLayoutState& aState) -{ - /* - nsCOMPtr parent; - nsCOMPtr parentBox; - GetParentMonument(aBox, parentBox, getter_AddRefs(parent)); - parent->DesecrateMonuments(aBox, aState); - */ - - UpdateMonuments(aBox, aState); - if (mOtherMonumentList) - mOtherMonumentList->MarkDirty(aState); - - return NS_OK; -} - -void -nsObeliskLayout::PopulateBoxSizes(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize*& aBoxSizes, nsComputedBoxSize*& aComputedBoxSizes, nscoord& aMinSize, nscoord& aMaxSize, PRInt32& aFlexes) -{ - nsTempleLayout* temple = nsnull; - nsIBox* aTempleBox = nsnull; - GetOtherTemple(aBox, &temple, &aTempleBox); - if (temple) { - // substitute our sizes for the other temples obelisk sizes. - PRBool isHorizontal = PR_FALSE; - aTempleBox->GetOrientation(isHorizontal); - nsBoxSize* first = nsnull; - nsBoxSize* last = nsnull; - temple->BuildBoxSizeList(aTempleBox, aState, first, last, isHorizontal); - aBoxSizes = first; - } - - nsSprocketLayout::PopulateBoxSizes(aBox, aState, aBoxSizes, aComputedBoxSizes, aMinSize, aMaxSize, aFlexes); - NS_IF_RELEASE(temple); -} - -void -nsObeliskLayout::ComputeChildSizes(nsIBox* aBox, - nsBoxLayoutState& aState, - nscoord& aGivenSize, - nsBoxSize* aBoxSizes, - nsComputedBoxSize*& aComputedBoxSizes) -{ - nsCOMPtr layout; - nsCOMPtr parentMonument; - nsCOMPtr scrollable; - - nsresult rv = NS_OK; - aBox->GetParentBox(&aBox); - nscoord size = aGivenSize; - - while (aBox) { - aBox->GetLayoutManager(getter_AddRefs(layout)); - parentMonument = do_QueryInterface(layout, &rv); - if (NS_SUCCEEDED(rv) && parentMonument) { - // we have a parent monument good. Go up until we hit the grid. - nsGridLayout* grid; - parentMonument->CastToGrid(&grid); - if (grid) { - if (size > aGivenSize) { - nscoord diff = size - aGivenSize; - aGivenSize += diff; - nsSprocketLayout::ComputeChildSizes(aBox, aState, aGivenSize, aBoxSizes, aComputedBoxSizes); - nsComputedBoxSize* s = aComputedBoxSizes; - nsComputedBoxSize* last = aComputedBoxSizes; - while(s) - { - last = s; - s = s->next; - } - - last->size -= diff; - aGivenSize -= diff; - } else { - nsSprocketLayout::ComputeChildSizes(aBox, aState, aGivenSize, aBoxSizes, aComputedBoxSizes); - } - return; - } - } else { - scrollable = do_QueryInterface(aBox, &rv); - if (NS_SUCCEEDED(rv)) { - // oops we are in a scrollable. Did it change our size? - // if so remove the excess space. - nsRect r; - aBox->GetBounds(r); - PRBool isHorizontal = PR_FALSE; - aBox->GetOrientation(isHorizontal); - - if (size < GET_WIDTH(r, isHorizontal)) { - if (isHorizontal) { - size = r.width; - } else { - size = r.height; - } - } - } - } - aBox->GetParentBox(&aBox); - } - - // Not in GRID!!! do the default. - nsSprocketLayout::ComputeChildSizes(aBox, aState, aGivenSize, aBoxSizes, aComputedBoxSizes); -} - -void -nsObeliskLayout::WillBeDestroyed(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSizeList& aList) -{ - Desecrated(aBox, aState, aList); - mOtherMonumentList = nsnull; -} - -void -nsObeliskLayout::Desecrated(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSizeList& aList) -{ - NS_ASSERTION(&aList == mOtherMonumentList,"Wrong list!!"); - if (mOtherMonumentList) { - nsCOMPtr layout; - aBox->GetLayoutManager(getter_AddRefs(layout)); - aBox->SetLayoutManager(nsnull); - aBox->MarkDirtyChildren(aState); - aBox->SetLayoutManager(layout); - } -} - -NS_IMETHODIMP -nsObeliskLayout::ChildrenInserted(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aPrevBox, nsIBox* aChildList) -{ - nsCOMPtr parent; - nsCOMPtr parentBox; - GetParentMonument(aBox, parentBox, getter_AddRefs(parent)); - if (parent) - return parent->DesecrateMonuments(aBox, aState); - else - return NS_OK; -} - -NS_IMETHODIMP -nsObeliskLayout::ChildrenAppended(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList) -{ - nsCOMPtr parent; - nsCOMPtr parentBox; - GetParentMonument(aBox, parentBox, getter_AddRefs(parent)); - if (parent) - return parent->DesecrateMonuments(aBox, aState); - else - return NS_OK; -} - -NS_IMETHODIMP -nsObeliskLayout::ChildrenRemoved(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList) -{ - nsCOMPtr parent; - nsCOMPtr parentBox; - GetParentMonument(aBox, parentBox, getter_AddRefs(parent)); - if (parent) - return parent->DesecrateMonuments(aBox, aState); - else - return NS_OK; -} diff --git a/layout/xul/base/src/nsObeliskLayout.h b/layout/xul/base/src/nsObeliskLayout.h deleted file mode 100644 index 00bf276410b1..000000000000 --- a/layout/xul/base/src/nsObeliskLayout.h +++ /dev/null @@ -1,101 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/** - - Author: - Eric D Vaughan - -**/ - -#ifndef nsObeliskLayout_h___ -#define nsObeliskLayout_h___ - -#include "nsMonumentLayout.h" -#include "nsCOMPtr.h" - -class nsObeliskLayout : public nsMonumentLayout, - public nsBoxSizeListener -{ -public: - - friend nsresult NS_NewObeliskLayout(nsIPresShell* aPresShell, nsCOMPtr& aNewLayout); - - NS_IMETHOD GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize& aSize); - NS_IMETHOD GetMinSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize& aSize); - NS_IMETHOD GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize& aSize); - NS_IMETHOD CastToObelisk(nsObeliskLayout** aObelisk); - NS_IMETHOD ChildBecameDirty(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChild); - NS_IMETHOD BecameDirty(nsIBox* aBox, nsBoxLayoutState& aState); - NS_IMETHOD ChildrenInserted(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aPrevBox, nsIBox* aChildList); - NS_IMETHOD ChildrenAppended(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList); - NS_IMETHOD ChildrenRemoved(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList); - -protected: - - void ChildNeedsLayout(nsIBox* aBox, nsIBoxLayout* aChild); - virtual void UpdateMonuments(nsIBox* aBox, nsBoxLayoutState& aState); - - /* - virtual void ComputeChildSizes(nsIBox* aBox, - nsBoxLayoutState& aState, - nscoord& aGivenSize, - nsBoxSize* aBoxSizes, - nsComputedBoxSize*& aComputedBoxSizes); - */ - - virtual void PopulateBoxSizes(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsBoxSize*& aBoxSizes, nsComputedBoxSize*& aComputedBoxSizes, nscoord& aMinSize, nscoord& aMaxSize, PRInt32& aFlexes); - virtual void ComputeChildSizes(nsIBox* aBox, - nsBoxLayoutState& aState, - nscoord& aGivenSize, - nsBoxSize* aBoxSizes, - nsComputedBoxSize*& aComputedBoxSizes); - - - virtual void WillBeDestroyed(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSizeList& aList); - virtual void Desecrated(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSizeList& aList); - - nsObeliskLayout(nsIPresShell* aShell); - virtual ~nsObeliskLayout(); - -private: - nsBoxSizeList* mOtherMonumentList; - -}; // class nsObeliskLayout - -#endif - diff --git a/layout/xul/base/src/nsTempleLayout.cpp b/layout/xul/base/src/nsTempleLayout.cpp deleted file mode 100644 index 3d25445f2776..000000000000 --- a/layout/xul/base/src/nsTempleLayout.cpp +++ /dev/null @@ -1,265 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -// -// Eric Vaughan -// Netscape Communications -// -// See documentation in associated header file -// - -#include "nsTempleLayout.h" -#include "nsIBox.h" -#include "nsCOMPtr.h" -#include "nsIScrollableFrame.h" -#include "nsBoxLayoutState.h" - -nsresult -NS_NewTempleLayout( nsIPresShell* aPresShell, nsCOMPtr& aNewLayout) -{ - aNewLayout = new nsTempleLayout(aPresShell); - - return NS_OK; - -} - -nsTempleLayout::nsTempleLayout(nsIPresShell* aPresShell):nsMonumentLayout(aPresShell), mMonuments(nsnull) -{ -} - -nsTempleLayout::~nsTempleLayout() -{ - if (mMonuments) { - nsBoxLayoutState state((nsIPresContext*)nsnull); - mMonuments->Destroy(state); - } -} - -NS_IMETHODIMP -nsTempleLayout::CastToTemple(nsTempleLayout** aTemple) -{ - *aTemple = this; - return NS_OK; -} - -NS_IMETHODIMP -nsTempleLayout::EnscriptionChanged(nsBoxLayoutState& aState, PRInt32 aIndex) -{ - // if a cell changes size. - if (mMonuments) { - nsBoxSizeList* size = mMonuments->GetAt(aIndex); - if (size) - size->Desecrate(aState); - } - - return NS_OK; -} - -NS_IMETHODIMP -nsTempleLayout::GetMonumentList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSizeList** aList) -{ - if (mMonuments) { - *aList = mMonuments; - return NS_OK; - } - - // run through our children. - // ask each child for its monument list - // append the list to our list - nsIBox* firstChild = nsnull; - aBox->GetChildBox(&firstChild); - - nsBoxSizeList* current = nsnull; - nsCOMPtr monument; - nsMonumentIterator it(firstChild); - - nsIBox* box = nsnull; - while(it.GetNextMonument(getter_AddRefs(monument))) { - - it.GetBox(&box); - - current = mMonuments; - nsBoxSizeList* node = nsnull; - monument->GetMonumentList(box, aState, &node); - - while(node) - { - if (!mMonuments) { - mMonuments = new nsBoxSizeListImpl(firstChild); - current = mMonuments; - } - - current->Append(aState, node); - - node = node->GetAdjacent(); - - if (node && !current->GetAdjacent()) { - nsBoxSizeList* newOne = new nsBoxSizeListImpl(box); - current->SetAdjacent(aState, newOne); - current = newOne; - } else { - current = current->GetAdjacent(); - } - } - } - - *aList = mMonuments; - return NS_OK; -} - -NS_IMETHODIMP -nsTempleLayout::BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize*& aFirst, nsBoxSize*& aLast, PRBool aIsHorizontal) -{ - // ok we need to build a nsBoxSize for each obelisk in this temple. We will then return the list of them. - // We are just returning a flattened list that we will use to layout our each cell. - nsIBox* box = nsnull; - aBox->GetChildBox(&box); - - aFirst = nsnull; - aLast = nsnull; - - nsBoxSize* first; - nsBoxSize* last; - PRInt32 count = 0; - - nsCOMPtr layout; - - nsLayoutIterator it(box); - - while(it.GetNextLayout(getter_AddRefs(layout))) { - - it.GetBox(&box); - - if (layout) { - nsresult rv = NS_OK; - nsCOMPtr monument = do_QueryInterface(layout, &rv); - - if (monument) - monument->BuildBoxSizeList(box, aState, first, last, aIsHorizontal); - else { - nsMonumentLayout::BuildBoxSizeList(box, aState, first, last, aIsHorizontal); - first->bogus = PR_TRUE; - } - - if (count == 0) - aFirst = first; - else if (aLast) - (aLast)->next = first; - aLast = last; - } - - count++; - } - - // ok now we might have a margin or border. If we do then we need to take that into account. One example - // might be if we are oriented vertically making us a "columns" and we contain a horizontal obelisk "row". - // Now say we have a left border of 10px. Well if we just layed things out then the whole row would be pushed over and - // the columns would not not line up. So we must take the space from somewhere. So if its on the left we take from the first - // child (which is leftmost) and if its on the right we take from the last child (which is rightmost). So for our example we - // need to subtract 10px from the first child. - - // so get the border and padding and add them up. - nsMargin borderPadding(0,0,0,0); - aBox->GetBorderAndPadding(borderPadding); - nsMargin margin(0,0,0,0); - aBox->GetMargin(margin); - - // add the margins up - nsMargin leftMargin(borderPadding.left + margin.left, borderPadding.top + margin.top, 0, 0); - nsMargin rightMargin(0,0, borderPadding.right + margin.right, borderPadding.bottom + margin.bottom); - - // Subtract them out. - PRBool isHorizontal = PR_FALSE; - aBox->GetOrientation(isHorizontal); - - if (aFirst) - aFirst->Add(leftMargin,isHorizontal); - - if (aLast) - aLast->Add(rightMargin,isHorizontal); - - return NS_OK; -} - -NS_IMETHODIMP -nsTempleLayout::ChildrenInserted(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aPrevBox, nsIBox* aChildList) -{ - DesecrateMonuments(aBox, aState); - return NS_OK; -} - -NS_IMETHODIMP -nsTempleLayout::ChildrenAppended(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList) -{ - DesecrateMonuments(aBox, aState); - return NS_OK; -} - -NS_IMETHODIMP -nsTempleLayout::ChildrenRemoved(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList) -{ - DesecrateMonuments(aBox, aState); - return NS_OK; -} - -NS_IMETHODIMP -nsTempleLayout::DesecrateMonuments(nsIBox* aBox, nsBoxLayoutState& aState) -{ - nsCOMPtr parent; - nsCOMPtr parentBox; - GetParentMonument(aBox, parentBox, getter_AddRefs(parent)); - if (parent) - parent->DesecrateMonuments(parentBox, aState); - - if (mMonuments) { - mMonuments->Destroy(aState); - mMonuments = nsnull; - } - - return NS_OK; -} - -// redefined because the normal GetMinSize in sprocket looks at flex -// if the child is not flexible then its min size is its pref size. -// but in this case its up to the column. The column's flex is the -// flex thats used. -NS_IMETHODIMP -nsTempleLayout::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSize) -{ - return nsSprocketLayout::GetMinSize(aBox, aState, aSize); -} - diff --git a/layout/xul/base/src/nsTempleLayout.h b/layout/xul/base/src/nsTempleLayout.h deleted file mode 100644 index 5b60a6a288b3..000000000000 --- a/layout/xul/base/src/nsTempleLayout.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/** - - Author: - Eric D Vaughan - -**/ - -#ifndef nsTempleLayout_h___ -#define nsTempleLayout_h___ - -#include "nsMonumentLayout.h" - -class nsTempleLayout : public nsMonumentLayout -{ -public: - - friend nsresult NS_NewTempleLayout(nsIPresShell* aPresShell, nsCOMPtr& aNewLayout); - - NS_IMETHOD CastToTemple(nsTempleLayout** aTemple); - NS_IMETHOD BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize*& aFirst, nsBoxSize*& aLast, PRBool aIsHorizontal); - NS_IMETHOD GetMonumentList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSizeList** aList); - NS_IMETHOD ChildrenInserted(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aPrevBox, nsIBox* aChildList); - NS_IMETHOD ChildrenAppended(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList); - NS_IMETHOD ChildrenRemoved(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList); - NS_IMETHOD DesecrateMonuments(nsIBox* aBox, nsBoxLayoutState& aState); - NS_IMETHOD EnscriptionChanged(nsBoxLayoutState& aState, PRInt32 aIndex); - NS_IMETHOD GetMinSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize& aSize); - -protected: - - nsTempleLayout(nsIPresShell* aShell); - virtual ~nsTempleLayout(); - -private: - nsBoxSizeList* mMonuments; -}; - -#endif - diff --git a/layout/xul/base/src/nsToolbarDragListener.cpp b/layout/xul/base/src/nsToolbarDragListener.cpp deleted file mode 100644 index ae39903d23ee..000000000000 --- a/layout/xul/base/src/nsToolbarDragListener.cpp +++ /dev/null @@ -1,473 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsToolbarDragListener.h" -#include "nsToolbarFrame.h" - -#include "nsCOMPtr.h" -#include "nsIDOMMouseEvent.h" -#include "nsIPresContext.h" -#include "nsIContent.h" -#include "nsIDOMElement.h" -#include "nsXULAtoms.h" -#include "nsIEventStateManager.h" -#include "nsISupportsPrimitives.h" -#include "nsINameSpaceManager.h" -#include "nsIDOMXULDocument.h" -#include "nsIDocument.h" -#include "nsIPresShell.h" -#include "nsIDOMEventTarget.h" - - -NS_IMPL_ADDREF(nsToolbarDragListener) -NS_IMPL_RELEASE(nsToolbarDragListener) -NS_IMPL_QUERY_INTERFACE2(nsToolbarDragListener, nsIDOMDragListener, nsIDOMEventListener) - - -// -// nsToolbarDragListener ctor -// -// Init member variables. We can't really do much of anything important here because -// any subframes might not be totally intialized yet, or in the hash table -// -nsToolbarDragListener :: nsToolbarDragListener ( nsToolbarFrame* inToolbar, nsIPresContext* inPresContext ) - : mToolbar(inToolbar), mPresContext(inPresContext), mCurrentDropLoc(-1) -{ - NS_INIT_REFCNT(); - - // we really need this all over the place. just be safe that we have it. - NS_ASSERTION ( mPresContext, "no pres context set on toolbar drag listener" ); - -} // nsToolbarDragListener ctor - - -// -// nsToolbarDragListener dtor -// -// Cleanup. -// -nsToolbarDragListener::~nsToolbarDragListener() -{ -} - - -//////////////////////////////////////////////////////////////////////// -nsresult -nsToolbarDragListener::HandleEvent(nsIDOMEvent* aEvent) -{ - return NS_OK; -} - - -//////////////////////////////////////////////////////////////////////// -nsresult -nsToolbarDragListener::DragGesture(nsIDOMEvent* aDragEvent) -{ - // this code should all be in JS. - return NS_OK; -} - - -//////////////////////////////////////////////////////////////////////// -nsresult -nsToolbarDragListener::DragEnter(nsIDOMEvent* aDragEvent) -{ - // We don't need to do anything special here. If anything does need to be done, - // the code should all be in JS. - return NS_OK; -} - - -// -// ItemMouseIsOver -// -// Figure out which child item mouse is over. |outIndex| is the index of the item the object -// should be dropped _before_. Therefore if the item should be dropped at the end, the index -// will be greater than the number of items in the list. |outOnChild| is true if the item -// is a container and the drop would be "on" that item. -// -void -nsToolbarDragListener :: ItemMouseIsOver ( nsIDOMEvent* aDragEvent, nscoord* outXLoc, - PRUint32* outIndex, PRBool* outOnChild ) -{ - *outOnChild = PR_FALSE; - - // figure out which frame is the right one for determining the drop feedback. Do we - // want to do this every time? We certainly can't do it upon toolbar creation (hash - // tables not setup at that time), so we're forced to do it now. What happens if while - // we're dragging some rule gets fired that causes the frame to go away? - nsIFrame* dropAreaFrame = LocateDropAreaFrame(); - if ( !dropAreaFrame ) { - // gaaak, we're doomed. - outIndex = 0; - outXLoc = 0; - return; - } - - // - // Get the mouse coordinates from the DOM event, but they will be in the - // window/widget coordinate system. We must first get them into the frame-relative - // coordinate system. Yuck. - // - - // get mouse coordinates and translate them into twips - nsCOMPtr mouseEvent(do_QueryInterface(aDragEvent)); - PRInt32 x,y = 0; - mouseEvent->GetClientX(&x); - mouseEvent->GetClientY(&y); - float p2t; - mPresContext->GetScaledPixelsToTwips(&p2t); - nscoord onePixel = NSIntPixelsToTwips(1, p2t); - nscoord xp = NSIntPixelsToTwips(x, p2t); - nscoord yp = NSIntPixelsToTwips(y, p2t); - - // compute the offset to top level in twips - PRInt32 frameOffsetX = 0, frameOffsetY = 0; - nsIFrame* curr = dropAreaFrame; - curr->GetParent(&curr); - float t2p; - mPresContext->GetTwipsToPixels(&t2p); - while ( curr ) { - nsPoint origin; - curr->GetOrigin(origin); // in twips - frameOffsetX += origin.x; // build the offset incrementally - frameOffsetY += origin.y; - curr->GetParent(&curr); // moving up the chain - } // until we reach the top - - // subtract the offset from the x,y coord to put into frame relative coordinates. - xp -= frameOffsetX; - yp -= frameOffsetY; - nsPoint pnt(xp, yp); - - // get the toolbar's rect - nsRect tbRect; - dropAreaFrame->GetRect(tbRect); - - PRUint32 count = 0; - PRBool found = PR_FALSE; - nsIFrame* childFrame; - nsRect rect; // child frame's rect - nsRect prevRect(-1, -1, 0, 0); - - // - // Now loop through the child and see if the mouse is over a child - // - - dropAreaFrame->FirstChild(mPresContext, nsnull, &childFrame); - while ( childFrame ) { - - // The mouse coords are in the toolbar's domain - // Get child's rect and adjust to the toolbar's domain - childFrame->GetRect(rect); - rect.MoveBy(tbRect.x, tbRect.y); - - // remember the previous child x location - if (pnt.x < rect.x && prevRect.x == -1) - prevRect = rect; - - // now check to see if the mouse inside an items bounds - if (rect.Contains(pnt)) { - nsCOMPtr content; - childFrame->GetContent(getter_AddRefs(content)); - if ( content ) { - nsCOMPtr tag; - content->GetTag(*getter_AddRefs(tag)); - - // for now I am checking for both titlebutton and toolbar items - if (tag.get() == nsXULAtoms::toolbaritem) { - - // now check if item is a container - PRBool isContainer = PR_FALSE; - nsCOMPtr domElement ( do_QueryInterface(content) ); - if ( domElement ) { - nsAutoString value; - domElement->GetAttribute(NS_LITERAL_STRING("container"), value); // can't use an atom here =( - isContainer = value.Equals(NS_LITERAL_STRING("true")); - } - else - NS_WARNING("Not a DOM element"); - - // if we have a container, the area is broken up into 3 pieces (left, middle, right). If - // it isn't it's only broken up into two (left and right) - PRInt32 xc = -1; - if ( isContainer ) { - if (pnt.x <= (rect.x + (rect.width / 4))) { - *outIndex = count; - xc = rect.x - tbRect.x; - } - else if (pnt.x >= (rect.x + PRInt32(float(rect.width) *0.75))) { - *outIndex = count + 1; - xc = rect.x - tbRect.x + rect.width - onePixel; - } - else { - // we're on a container, don't draw anything so xc shouldn't get set. - *outIndex = count; - *outOnChild = PR_TRUE; - } - } else { - if (pnt.x <= (rect.x + (rect.width / 2))) { - *outIndex = count; - xc = rect.x - tbRect.x; - } - else { - *outIndex = count + 1; - xc = rect.x - tbRect.x + rect.width + onePixel; - } - } - - *outXLoc = xc; - } - else { - // mouse is over something (probably a spacer) so return the left side of - // the spacer. - *outXLoc = rect.x - tbRect.x; - *outIndex = count; - } - - // found something, break out of the loop - found = PR_TRUE; - break; - } - } // if mouse is in an item - - nsresult rv = childFrame->GetNextSibling(&childFrame); - NS_ASSERTION(rv == NS_OK,"failed to get next child"); - count++; - } // foreach child - - if (!found) { - *outIndex = count; // already incremented past last item - if ( count ) - *outXLoc = prevRect.x - tbRect.x + rect.width + onePixel; - else - *outXLoc = onePixel; - } -} - - -// -// DragOver -// -// The mouse has moved over the toolbar while a drag is happening. We really just want to -// "annotate" the toolbar with the current drop location. We don't want to make any judgement -// as this stage as to whether or not the drag should be accepted or draw any feedback. -// -nsresult -nsToolbarDragListener::DragOver(nsIDOMEvent* aDragEvent) -{ - // Check to see if the mouse is over an item and which one it is. - nscoord xLoc = 0; - PRBool onChild; - PRUint32 beforeIndex = 0; - ItemMouseIsOver(aDragEvent, &xLoc, &beforeIndex, &onChild); - if ( xLoc != mCurrentDropLoc ) { - - // stash the new location in the toolbar's content model. Note that the toolbar code doesn't - // care at all about "tb-droplocation", only the coordinate so there is no need to send the - // AttributeChanged() about that attribute. - nsCOMPtr content; - mToolbar->GetContent ( getter_AddRefs(content) ); - if ( content ) { - char buffer[10]; - - // need the cast, because on some platforms, PR[U]int32 != long, but we're using "%ld" - sprintf(buffer, "%ld", NS_STATIC_CAST(long, xLoc)); - content->SetAttribute ( kNameSpaceID_None, nsXULAtoms::ddDropLocationCoord, NS_ConvertASCIItoUCS2(buffer), PR_TRUE ); - sprintf(buffer, "%ld", NS_STATIC_CAST(long, beforeIndex)); - content->SetAttribute ( kNameSpaceID_None, nsXULAtoms::ddDropLocation, NS_ConvertASCIItoUCS2(buffer), PR_FALSE ); - content->SetAttribute ( kNameSpaceID_None, nsXULAtoms::ddDropOn, NS_ConvertASCIItoUCS2(onChild ? "true" : "false"), PR_FALSE ); - } - - // cache the current drop location - mCurrentDropLoc = xLoc; - } - - // NS_OK means event is NOT consumed. We want to make sure JS gets this so it - // can determine if the drag is allowed. - return NS_OK; -} - - -// -// DragExit -// -// Handle when the mouse leaves the toolbar. We have to do some extra checking of both -// the target and the relatedNode to see if they are our children, but the gist is if -// the mouse leaves the toolbar for some other destination, reset the drop feedback -// attributes and trigger a repaint. -// -nsresult -nsToolbarDragListener::DragExit(nsIDOMEvent* aDragEvent) -{ - nsCOMPtr mouseEvent ( do_QueryInterface(aDragEvent) ); - if ( !mouseEvent ) - return NS_OK; - - nsCOMPtr relatedTarget; - mouseEvent->GetRelatedTarget ( getter_AddRefs(relatedTarget) ); - nsCOMPtr relatedNode; - if (relatedTarget) relatedNode = do_QueryInterface(relatedTarget); - - nsCOMPtr target; - aDragEvent->GetTarget ( getter_AddRefs(target) ); - nsCOMPtr targetNode = nsnull; - if (target) targetNode = do_QueryInterface(target); - - // we only care about the case where the toolbar or one of its children - // is the target of this dragExit event. Recall we get all exit events because - // they will bubble up to us. - if ( !IsNodeAChild(targetNode) ) - return NS_OK; - - if ( ! IsNodeAChild(relatedNode) ) { - nsCOMPtr myContent; - mToolbar->GetContent ( getter_AddRefs(myContent) ); - - // tell the toolbar to not do any more drop feedback. Note that the toolbar code doesn't - // care at all about "tb-droplocation", only the coordinate so there is no need to send the - // AttributeChanged() about that attribute. - myContent->SetAttribute ( kNameSpaceID_None, nsXULAtoms::ddDropLocationCoord, NS_LITERAL_STRING("-1"), PR_TRUE ); - myContent->SetAttribute ( kNameSpaceID_None, nsXULAtoms::ddDropLocation, NS_LITERAL_STRING("-1"), PR_FALSE ); - myContent->SetAttribute ( kNameSpaceID_None, nsXULAtoms::ddTriggerRepaint, NS_LITERAL_STRING("1"), PR_TRUE ); - - // reset the current drop location - mCurrentDropLoc = -1; - } - - return NS_OK; // don't consume event -} - - -// -// IsNodeAChild -// -// Returns TRUE if the given dom node is a child (or equals) this toolbar -// -PRBool -nsToolbarDragListener :: IsNodeAChild ( nsIDOMNode* inNode ) -{ - PRBool foundAsChild = PR_FALSE; - - nsCOMPtr myContent; - mToolbar->GetContent ( getter_AddRefs(myContent) ); - nsCOMPtr myContentAsNode ( do_QueryInterface(myContent) ); - - NS_ASSERTION ( myContent && myContentAsNode, "No content nodes" ); - - nsCOMPtr currNode ( inNode ); - while ( currNode ) { - // did we hit the toolbar? - if ( currNode == myContentAsNode ) { - foundAsChild = PR_TRUE; - break; - } - // if not, keep going - nsCOMPtr temp ( currNode ); - temp->GetParentNode(getter_AddRefs(currNode)); - } // while we're going up the parent chain - - return foundAsChild; - -} // IsNodeAChild - - -//////////////////////////////////////////////////////////////////////// -nsresult -nsToolbarDragListener::DragDrop(nsIDOMEvent* aMouseEvent) -{ - // this code should all be in JS. - return NS_OK; -} - - -// -// LocateDropAreaFrame -// -// Returns the frame (or subframe) that contains the buttons that can be dragged. -// Either it will be the toolbar frame as a whole, or it will be some subframe of the bar id'd by -// the |dragdroparea| attribute. -// -nsIFrame* -nsToolbarDragListener :: LocateDropAreaFrame ( ) -{ - nsIFrame* retVal = nsnull; - - // is a subframe the drag/drop area? determine if the attribute is set. - nsString dropAreaID; - PRBool dropAreaIsSubframe = PR_FALSE; - nsCOMPtr toolbarContent; - mToolbar->GetContent ( getter_AddRefs(toolbarContent) ); - if ( toolbarContent ) { - if ( toolbarContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::ddDragDropArea, dropAreaID) == NS_CONTENT_ATTR_HAS_VALUE ) - dropAreaIsSubframe = PR_TRUE; - } - - // if there is a named subframe, go find it, otherwise use the entire toolbar - if ( dropAreaIsSubframe ) { - - // get the presShell so we can call GetPrimaryFrameFor later. - nsCOMPtr presShell; - mPresContext->GetShell ( getter_AddRefs(presShell) ); - - // get the document so we can get do a GetElementByID. - nsCOMPtr document; - toolbarContent->GetDocument ( *getter_AddRefs(document) ); - if ( document ) { - nsCOMPtr xulDoc ( do_QueryInterface(document) ); - if ( xulDoc ) { - nsCOMPtr domElementOfSubframe; - xulDoc->GetElementById ( dropAreaID, getter_AddRefs(domElementOfSubframe) ); - - // finally get the frame associated with that dom node - nsCOMPtr contentOfSubframe ( do_QueryInterface(domElementOfSubframe) ); - if ( contentOfSubframe && presShell ) - presShell->GetPrimaryFrameFor ( contentOfSubframe, &retVal ); - } - } - - } // if named subframe - else - retVal = mToolbar; - - NS_ASSERTION ( retVal, "toolbar drag listener couldn't figure out the drag area." ); - return retVal; - -} // LocateDropAreaFrame - - - diff --git a/layout/xul/base/src/nsToolbarDragListener.h b/layout/xul/base/src/nsToolbarDragListener.h deleted file mode 100644 index 3936a42d510c..000000000000 --- a/layout/xul/base/src/nsToolbarDragListener.h +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsToolbarDragListener_h__ -#define nsToolbarDragListener_h__ - -#include "nsIDOMDragListener.h" -#include "nsCoord.h" - - -class nsToolbarFrame; -class nsIPresContext; -class nsIDOMEvent; -class nsIFrame; -class nsIDOMNode; - - -class nsToolbarDragListener : public nsIDOMDragListener -{ -public: - - // default ctor and dtor - nsToolbarDragListener ( nsToolbarFrame* inToolbar, nsIPresContext* inPresContext ); - virtual ~nsToolbarDragListener(); - - // interfaces for addref and release and queryinterface - NS_DECL_ISUPPORTS - - // nsIDOMDragListener - virtual nsresult HandleEvent(nsIDOMEvent* aEvent); - virtual nsresult DragEnter(nsIDOMEvent* aDragEvent); - virtual nsresult DragOver(nsIDOMEvent* aDragEvent); - virtual nsresult DragExit(nsIDOMEvent* aDragEvent); - virtual nsresult DragDrop(nsIDOMEvent* aDragEvent); - virtual nsresult DragGesture(nsIDOMEvent* aDragEvent); - -protected: - - // Figure out which child item mouse is over. |outIndex| is the index of the item the object - // should be dropped _before_. Therefore if the item should be dropped at the end, the index - // will be greater than the number of items in the list. |outOnChild| is true if the item - // is a container and the drop would be "on" that item. - void ItemMouseIsOver(nsIDOMEvent* aDragEvent, nscoord* outXLoc, PRUint32* outIndex, PRBool* outOnChild); - - // Utility to help determine if a node is a child of the toolbar - PRBool IsNodeAChild ( nsIDOMNode* inNode ) ; - - // Find the frame (or subframe) that contains the buttons that can be dragged. - nsIFrame* LocateDropAreaFrame ( ) ; - - nsToolbarFrame * mToolbar; // toolbar owns me, don't be circular - nsIPresContext * mPresContext; // weak reference - PRInt32 mCurrentDropLoc; - -}; // class nsToolbarDragListener - - -#endif diff --git a/layout/xul/base/src/nsToolbarItemFrame.cpp b/layout/xul/base/src/nsToolbarItemFrame.cpp deleted file mode 100644 index af21807156a6..000000000000 --- a/layout/xul/base/src/nsToolbarItemFrame.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Pierre Phaneuf - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsToolbarItemFrame.h" -#include "nsCOMPtr.h" -#include "nsReadableUtils.h" - -#include "nsWidgetsCID.h" - -// Drag & Drop, Clipboard Support -static NS_DEFINE_CID(kCDragServiceCID, NS_DRAGSERVICE_CID); -static NS_DEFINE_CID(kCTransferableCID, NS_TRANSFERABLE_CID); -static NS_DEFINE_IID(kCDataFlavorCID, NS_DATAFLAVOR_CID); - - -// -// NS_NewToolbarItemFrame (friend) -// -// Creates a new toolbar item frame and returns it in |aNewFrame| -// -nsresult -NS_NewToolbarItemFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame ) -{ - NS_PRECONDITION(aNewFrame, "null OUT ptr"); - if ( !aNewFrame ) - return NS_ERROR_NULL_POINTER; - - nsToolbarItemFrame* it = new (aPresShell) nsToolbarItemFrame(aPresShell); - if ( !it ) - return NS_ERROR_OUT_OF_MEMORY; - - *aNewFrame = it; - return NS_OK; - -} // NS_NewToolbarItemFrame - - -// -// nsToolbarItemFrame ctor and dtor -// -nsToolbarItemFrame::nsToolbarItemFrame(nsIPresShell* aPresShell):nsBoxFrame(aPresShell) -{ -} - -nsToolbarItemFrame::~nsToolbarItemFrame() -{ -} - - -// -// Init -// -// Ummm, just forwards for now. -// -NS_IMETHODIMP -nsToolbarItemFrame::Init(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIFrame* aParent, - nsIStyleContext* aContext, - nsIFrame* aPrevInFlow) -{ - nsresult rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); - - return rv; -} - - -// -// Init -// -// Ummm, just forwards for now. Most of this code is now in the drag listener's -// mouseMoved event. -// -// еее remove all this. -// -NS_IMETHODIMP -nsToolbarItemFrame::HandleEvent(nsIPresContext* aPresContext, - nsGUIEvent* aEvent, - nsEventStatus* aEventStatus) -{ - // if disabled do nothing - /*if (PR_TRUE == mRenderer.isDisabled()) { - return NS_OK; - } - - switch (aEvent->message) { - case NS_KEY_PRESS: - if (NS_KEY_EVENT == aEvent->eventStructType) { - nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent; - if (NS_VK_SPACE == keyEvent->keyCode || NS_VK_RETURN == keyEvent->keyCode) { - MouseClicked(aPresContext); - } - } - break; - - case NS_MOUSE_LEFT_CLICK: - MouseClicked(aPresContext); - break; - } -*/ - -/* // Start Drag - nsIDragService* dragService; - nsresult rv = nsServiceManager::GetService(kCDragServiceCID, - NS_GET_IID(nsIDragService), - (nsISupports **)&dragService); - if (NS_OK == rv) { - nsCOMPtr trans; - rv = nsComponentManager::CreateInstance(kCTransferableCID, nsnull, - NS_GET_IID(nsITransferable), getter_AddRefs(trans)); - nsCOMPtr trans2; - rv = nsComponentManager::CreateInstance(kCTransferableCID, nsnull, - NS_GET_IID(nsITransferable), getter_AddRefs(trans2)); - if ( trans && trans2 ) { - nsString textPlainFlavor ( "text/plain" ); - trans->AddDataFlavor(&textPlainFlavor); - nsString dragText = "Drag Text"; - PRUint32 len = 9; - trans->SetTransferData(&textPlainFlavor, ToNewCString(dragText), len); // transferable consumes the data - - trans2->AddDataFlavor(&textPlainFlavor); - nsString dragText2 = "More Drag Text"; - len = 14; - trans2->SetTransferData(&textPlainFlavor, ToNewCString(dragText2), len); // transferable consumes the data - - nsCOMPtr items; - NS_NewISupportsArray(getter_AddRefs(items)); - if ( items ) { - items->AppendElement(trans); - items->AppendElement(trans2); - dragService->InvokeDragSession(items, nsnull, nsIDragService::DRAGDROP_ACTION_COPY | nsIDragService::DRAGDROP_ACTION_MOVE); - } - } - nsServiceManager::ReleaseService(kCDragServiceCID, dragService); - } */ - printf("ToolbarItem %d\n", aEvent->message); - return nsBoxFrame::HandleEvent(aPresContext, aEvent, aEventStatus); -} - - -/* - * We are a frame and we do not maintain a ref count - */ -NS_IMETHODIMP_(nsrefcnt) -nsToolbarItemFrame::AddRef(void) -{ - return NS_OK; -} - -NS_IMETHODIMP_(nsrefcnt) -nsToolbarItemFrame::Release(void) -{ - return NS_OK; -} - - - diff --git a/layout/xul/base/src/nsToolbarItemFrame.h b/layout/xul/base/src/nsToolbarItemFrame.h deleted file mode 100644 index 2cbe329f8e1d..000000000000 --- a/layout/xul/base/src/nsToolbarItemFrame.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsToolbarItemFrame_h___ -#define nsToolbarItemFrame_h___ - - -#include "nsBoxFrame.h" - -class nsIFrame; -class nsIPresContext; -class nsIStyleContext; - - -class nsToolbarItemFrame : public nsBoxFrame -{ -public: - - nsToolbarItemFrame(nsIPresShell* aShell); - virtual ~nsToolbarItemFrame(); - - friend nsresult NS_NewToolbarItemFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame); - - NS_IMETHOD_(nsrefcnt) AddRef(void); - NS_IMETHOD_(nsrefcnt) Release(void); - - NS_IMETHOD Init(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIFrame* aParent, - nsIStyleContext* aContext, - nsIFrame* asPrevInFlow); - - NS_IMETHOD HandleEvent(nsIPresContext* aPresContext, - nsGUIEvent* aEvent, - nsEventStatus* aEventStatus); - - -}; // class nsToolbarItemFrame - -#endif /* nsToolbarItemFrame_h___ */ diff --git a/layout/xul/base/src/nsTreeLayout.cpp b/layout/xul/base/src/nsTreeLayout.cpp index c778b5bb4758..506022f3b3b6 100644 --- a/layout/xul/base/src/nsTreeLayout.cpp +++ b/layout/xul/base/src/nsTreeLayout.cpp @@ -64,11 +64,7 @@ NS_NewTreeLayout( nsIPresShell* aPresShell, nsCOMPtr& aNewLayout) } nsTreeLayout::nsTreeLayout(nsIPresShell* aPresShell): -#ifdef MOZ_GRID2 nsGridRowGroupLayout(aPresShell) -#else - nsTempleLayout(aPresShell) -#endif { } @@ -111,11 +107,7 @@ nsXULTreeSliceFrame* nsTreeLayout::GetRowFrame(nsIBox* aBox) NS_IMETHODIMP nsTreeLayout::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize& aSize) { -#ifdef MOZ_GRID2 nsresult rv = nsGridRowGroupLayout::GetPrefSize(aBox, aBoxLayoutState, aSize); -#else - nsresult rv = nsTempleLayout::GetPrefSize(aBox, aBoxLayoutState, aSize); -#endif nsXULTreeOuterGroupFrame* frame = GetOuterFrame(aBox); if (frame) { @@ -144,11 +136,7 @@ nsTreeLayout::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSiz NS_IMETHODIMP nsTreeLayout::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize& aSize) { -#ifdef MOZ_GRID2 nsresult rv = nsGridRowGroupLayout::GetMinSize(aBox, aBoxLayoutState, aSize); -#else - nsresult rv = nsTempleLayout::GetMinSize(aBox, aBoxLayoutState, aSize); -#endif nsXULTreeOuterGroupFrame* frame = GetOuterFrame(aBox); if (frame) { @@ -177,11 +165,7 @@ nsTreeLayout::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize NS_IMETHODIMP nsTreeLayout::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize& aSize) { -#ifdef MOZ_GRID2 nsresult rv = nsGridRowGroupLayout::GetMaxSize(aBox, aBoxLayoutState, aSize); -#else - nsresult rv = nsTempleLayout::GetMaxSize(aBox, aBoxLayoutState, aSize); -#endif nsXULTreeOuterGroupFrame* frame = GetOuterFrame(aBox); if (frame) { diff --git a/layout/xul/base/src/nsTreeLayout.h b/layout/xul/base/src/nsTreeLayout.h index c25cfed2361c..071a000f5720 100644 --- a/layout/xul/base/src/nsTreeLayout.h +++ b/layout/xul/base/src/nsTreeLayout.h @@ -45,25 +45,14 @@ #ifndef nsTreeLayout_h___ #define nsTreeLayout_h___ -#define MOZ_GRID2 1 - -#ifdef MOZ_GRID2 - #include "nsGridRowGroupLayout.h" -#else -#include "nsTempleLayout.h" -#endif - +#include "nsGridRowGroupLayout.h" #include "nsXULTreeOuterGroupFrame.h" #include "nsXULTreeSliceFrame.h" class nsIBox; class nsBoxLayoutState; -#ifdef MOZ_GRID2 class nsTreeLayout : public nsGridRowGroupLayout -#else -class nsTreeLayout : public nsTempleLayout -#endif { public: nsTreeLayout(nsIPresShell* aShell); diff --git a/layout/xul/base/src/nsXULTreeCellFrame.cpp b/layout/xul/base/src/nsXULTreeCellFrame.cpp index 9ca257ecb427..e68441e18272 100644 --- a/layout/xul/base/src/nsXULTreeCellFrame.cpp +++ b/layout/xul/base/src/nsXULTreeCellFrame.cpp @@ -43,19 +43,10 @@ #include "nsIStyleContext.h" #include "nsINameSpaceManager.h" #include "nsIXULTreeSlice.h" -#include "nsIMonument.h" #include "nsIBoxLayout.h" -#include "nsMonumentLayout.h" -#define MOZ_GRID2 1 - -#ifdef MOZ_GRID2 #include "nsGrid.h" #include "nsGridRow.h" -#else -#include "nsGridLayout.h" -#include "nsTempleLayout.h" -#endif @@ -137,7 +128,6 @@ nsXULTreeCellFrame::GetFrameForPoint(nsIPresContext* aPresContext, nsCOMPtr box(do_QueryInterface(mParent)); nsCOMPtr lm; -#ifdef MOZ_GRID2 box->GetLayoutManager(getter_AddRefs(lm)); nsCOMPtr part(do_QueryInterface(lm)); @@ -147,39 +137,6 @@ nsXULTreeCellFrame::GetFrameForPoint(nsIPresContext* aPresContext, nsIBox* splitBox = nsnull; if (grid->GetColumnCount() > 0) splitBox = grid->GetColumnAt(i)->GetBox(); -#else - box->GetLayoutManager(getter_AddRefs(lm)); - nsCOMPtr mon(do_QueryInterface(lm)); - - nsTempleLayout* temple = nsnull; - nsIBox* templeBox = nsnull; - mon->GetOtherTemple(box, &temple, &templeBox); - NS_IF_RELEASE(temple); - - nsMonumentIterator iter(templeBox); - nsIBox* child = nsnull; - nsObeliskLayout* ob; - PRInt32 currIndex = 0; - if (left) - i--; - - do { - if (i < 0) break; - - iter.GetNextObelisk(&ob, PR_TRUE); - iter.GetBox(&child); - - if (currIndex >= i) - break; - - currIndex++; - - } while (child); - - nsIBox* splitBox = nsnull; - if (child) - child->GetNextBox(&splitBox); -#endif nsIFrame* splitter = nsnull; if (splitBox) diff --git a/layout/xul/base/src/nsXULTreeOuterGroupFrame.cpp b/layout/xul/base/src/nsXULTreeOuterGroupFrame.cpp index 170b468e6abf..95b766fefab7 100644 --- a/layout/xul/base/src/nsXULTreeOuterGroupFrame.cpp +++ b/layout/xul/base/src/nsXULTreeOuterGroupFrame.cpp @@ -54,7 +54,6 @@ #include "nsIDragService.h" #include "nsIServiceManager.h" #include "nsIScrollableView.h" -#include "nsIMonument.h" #include "nsTreeLayout.h" #include "nsITimer.h" #include "nsIBindingManager.h" @@ -65,13 +64,7 @@ #include "nsIStyleContext.h" #include "nsIDOMText.h" -#define MOZ_GRID2 1 - -#ifdef MOZ_GRID2 - #include "nsGridRowGroupLayout.h" -#else -#include "nsTempleLayout.h" -#endif +#include "nsGridRowGroupLayout.h" #define TICK_FACTOR 50