2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 14:30:37 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-06-30 22:17:43 +00:00
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The contents of this file are subject to the Mozilla 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/MPL/
|
1999-06-30 22:17:43 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* 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.
|
1999-06-30 22:17:43 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-28 20:14:13 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Contributor(s):
|
2000-11-16 22:25:45 +00:00
|
|
|
* Blake Ross <blakeross@telocity.com>
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 14:30:37 +00:00
|
|
|
* either of 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"),
|
2001-09-28 20:14:13 +00:00
|
|
|
* 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
|
2004-04-18 14:30:37 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-28 20:14:13 +00:00
|
|
|
* 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
|
2004-04-18 14:30:37 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-06-30 22:17:43 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Eric Vaughan
|
|
|
|
// Netscape Communications
|
|
|
|
//
|
|
|
|
// See documentation in associated header file
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "nsSplitterFrame.h"
|
2006-12-26 17:47:52 +00:00
|
|
|
#include "nsGkAtoms.h"
|
1999-06-30 22:17:43 +00:00
|
|
|
#include "nsIDOMElement.h"
|
2003-10-21 11:43:40 +00:00
|
|
|
#include "nsIDOMXULElement.h"
|
1999-06-30 22:17:43 +00:00
|
|
|
#include "nsIDOMDocument.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
2011-04-08 01:04:40 +00:00
|
|
|
#include "nsRenderingContext.h"
|
2000-12-30 19:22:22 +00:00
|
|
|
#include "nsIDocument.h"
|
1999-06-30 22:17:43 +00:00
|
|
|
#include "nsINameSpaceManager.h"
|
|
|
|
#include "nsScrollbarButtonFrame.h"
|
2007-05-14 09:11:38 +00:00
|
|
|
#include "nsIDOMEventTarget.h"
|
2011-06-28 17:59:14 +00:00
|
|
|
#include "nsIDOMEventListener.h"
|
1999-11-03 07:11:45 +00:00
|
|
|
#include "nsIDOMMouseEvent.h"
|
1999-09-05 20:46:59 +00:00
|
|
|
#include "nsIPresShell.h"
|
2009-04-25 08:33:32 +00:00
|
|
|
#include "nsFrameList.h"
|
1999-09-05 20:46:59 +00:00
|
|
|
#include "nsHTMLParts.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsStyleContext.h"
|
2000-03-31 07:02:06 +00:00
|
|
|
#include "nsBoxLayoutState.h"
|
2000-05-09 21:42:40 +00:00
|
|
|
#include "nsIXBLService.h"
|
|
|
|
#include "nsIServiceManager.h"
|
2011-12-27 20:18:48 +00:00
|
|
|
#include "nsContainerFrame.h"
|
2001-07-16 02:40:48 +00:00
|
|
|
#include "nsGUIEvent.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsAutoPtr.h"
|
2001-02-19 21:50:04 +00:00
|
|
|
#include "nsContentCID.h"
|
2004-01-28 00:18:22 +00:00
|
|
|
#include "nsStyleSet.h"
|
2005-08-23 03:57:07 +00:00
|
|
|
#include "nsLayoutUtils.h"
|
2006-01-26 02:29:17 +00:00
|
|
|
#include "nsDisplayList.h"
|
2006-04-24 05:40:11 +00:00
|
|
|
#include "nsContentUtils.h"
|
2011-07-20 19:18:54 +00:00
|
|
|
#include "mozilla/dom/Element.h"
|
1999-09-05 20:46:59 +00:00
|
|
|
|
|
|
|
class nsSplitterInfo {
|
|
|
|
public:
|
2003-12-21 04:04:05 +00:00
|
|
|
nscoord min;
|
|
|
|
nscoord max;
|
|
|
|
nscoord current;
|
|
|
|
nscoord changed;
|
2005-10-11 18:59:58 +00:00
|
|
|
nsCOMPtr<nsIContent> childElem;
|
2003-12-21 04:04:05 +00:00
|
|
|
PRInt32 flex;
|
|
|
|
PRInt32 index;
|
1999-09-05 20:46:59 +00:00
|
|
|
};
|
|
|
|
|
2011-06-28 17:59:14 +00:00
|
|
|
class nsSplitterFrameInner : public nsIDOMEventListener
|
|
|
|
{
|
1999-09-05 20:46:59 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
2011-06-28 17:59:14 +00:00
|
|
|
NS_DECL_NSIDOMEVENTLISTENER
|
1999-09-05 20:46:59 +00:00
|
|
|
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
nsSplitterFrameInner(nsSplitterFrame* aSplitter)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
mOuter = aSplitter;
|
2011-10-17 14:59:28 +00:00
|
|
|
mPressed = false;
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
2000-04-03 03:55:38 +00:00
|
|
|
virtual ~nsSplitterFrameInner();
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2007-05-21 07:33:32 +00:00
|
|
|
void Disconnect() { mOuter = nsnull; }
|
|
|
|
|
2011-06-28 17:59:14 +00:00
|
|
|
nsresult MouseDown(nsIDOMEvent* aMouseEvent);
|
|
|
|
nsresult MouseUp(nsIDOMEvent* aMouseEvent);
|
|
|
|
nsresult MouseMove(nsIDOMEvent* aMouseEvent);
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
void MouseDrag(nsPresContext* aPresContext, nsGUIEvent* aEvent);
|
|
|
|
void MouseUp(nsPresContext* aPresContext, nsGUIEvent* aEvent);
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
void AdjustChildren(nsPresContext* aPresContext);
|
2011-09-29 06:19:26 +00:00
|
|
|
void AdjustChildren(nsPresContext* aPresContext, nsSplitterInfo* aChildInfos, PRInt32 aCount, bool aIsHorizontal);
|
1999-09-05 20:46:59 +00:00
|
|
|
|
|
|
|
void AddRemoveSpace(nscoord aDiff,
|
|
|
|
nsSplitterInfo* aChildInfos,
|
|
|
|
PRInt32 aCount,
|
|
|
|
PRInt32& aSpaceLeft);
|
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
void ResizeChildTo(nsPresContext* aPresContext,
|
1999-10-26 04:44:41 +00:00
|
|
|
nscoord& aDiff,
|
1999-09-05 20:46:59 +00:00
|
|
|
nsSplitterInfo* aChildrenBeforeInfos,
|
|
|
|
nsSplitterInfo* aChildrenAfterInfos,
|
|
|
|
PRInt32 aChildrenBeforeCount,
|
|
|
|
PRInt32 aChildrenAfterCount,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aBounded);
|
1999-09-05 20:46:59 +00:00
|
|
|
|
|
|
|
void UpdateState();
|
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
void AddListener(nsPresContext* aPresContext);
|
1999-09-05 20:46:59 +00:00
|
|
|
void RemoveListener();
|
|
|
|
|
2007-11-15 03:38:16 +00:00
|
|
|
enum ResizeType { Closest, Farthest, Flex, Grow };
|
2006-07-19 22:30:33 +00:00
|
|
|
enum State { Open, CollapsedBefore, CollapsedAfter, Dragging };
|
|
|
|
enum CollapseDirection { Before, After };
|
1999-09-05 20:46:59 +00:00
|
|
|
|
|
|
|
ResizeType GetResizeBefore();
|
|
|
|
ResizeType GetResizeAfter();
|
|
|
|
State GetState();
|
|
|
|
|
|
|
|
void Reverse(nsSplitterInfo*& aIndexes, PRInt32 aCount);
|
2011-09-29 06:19:26 +00:00
|
|
|
bool SupportsCollapseDirection(CollapseDirection aDirection);
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
void EnsureOrient();
|
2011-09-29 06:19:26 +00:00
|
|
|
void SetPreferredSize(nsBoxLayoutState& aState, nsIBox* aChildBox, nscoord aOnePixel, bool aIsHorizontal, nscoord* aSize);
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
|
|
|
|
nsSplitterFrame* mOuter;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mDidDrag;
|
2005-08-23 03:57:07 +00:00
|
|
|
nscoord mDragStart;
|
1999-09-05 20:46:59 +00:00
|
|
|
nscoord mCurrentPos;
|
2000-03-31 07:02:06 +00:00
|
|
|
nsIBox* mParentBox;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mPressed;
|
1999-09-05 20:46:59 +00:00
|
|
|
nsSplitterInfo* mChildInfosBefore;
|
|
|
|
nsSplitterInfo* mChildInfosAfter;
|
|
|
|
PRInt32 mChildInfosBeforeCount;
|
|
|
|
PRInt32 mChildInfosAfterCount;
|
|
|
|
State mState;
|
|
|
|
nscoord mSplitterPos;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mDragging;
|
2000-03-31 07:02:06 +00:00
|
|
|
|
1999-09-05 20:46:59 +00:00
|
|
|
};
|
|
|
|
|
2011-06-28 17:59:14 +00:00
|
|
|
NS_IMPL_ISUPPORTS1(nsSplitterFrameInner, nsIDOMEventListener)
|
1999-09-05 20:46:59 +00:00
|
|
|
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
nsSplitterFrameInner::ResizeType
|
|
|
|
nsSplitterFrameInner::GetResizeBefore()
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2007-11-15 03:38:16 +00:00
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
|
|
|
{&nsGkAtoms::farthest, &nsGkAtoms::flex, nsnull};
|
|
|
|
switch (mOuter->GetContent()->FindAttrValueIn(kNameSpaceID_None,
|
|
|
|
nsGkAtoms::resizebefore,
|
|
|
|
strings, eCaseMatters)) {
|
|
|
|
case 0: return Farthest;
|
|
|
|
case 1: return Flex;
|
|
|
|
}
|
2003-12-21 04:04:05 +00:00
|
|
|
return Closest;
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
2000-04-03 03:55:38 +00:00
|
|
|
nsSplitterFrameInner::~nsSplitterFrameInner()
|
|
|
|
{
|
|
|
|
delete[] mChildInfosBefore;
|
|
|
|
delete[] mChildInfosAfter;
|
|
|
|
}
|
|
|
|
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
nsSplitterFrameInner::ResizeType
|
|
|
|
nsSplitterFrameInner::GetResizeAfter()
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2006-04-24 05:40:11 +00:00
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2007-11-15 03:38:16 +00:00
|
|
|
{&nsGkAtoms::farthest, &nsGkAtoms::flex, &nsGkAtoms::grow, nsnull};
|
2006-04-24 05:40:11 +00:00
|
|
|
switch (mOuter->GetContent()->FindAttrValueIn(kNameSpaceID_None,
|
2006-12-26 17:47:52 +00:00
|
|
|
nsGkAtoms::resizeafter,
|
2006-04-24 05:40:11 +00:00
|
|
|
strings, eCaseMatters)) {
|
|
|
|
case 0: return Farthest;
|
2007-11-15 03:38:16 +00:00
|
|
|
case 1: return Flex;
|
|
|
|
case 2: return Grow;
|
2006-04-24 05:40:11 +00:00
|
|
|
}
|
2003-12-21 04:04:05 +00:00
|
|
|
return Closest;
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
nsSplitterFrameInner::State
|
|
|
|
nsSplitterFrameInner::GetState()
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2006-04-24 05:40:11 +00:00
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2006-12-26 17:47:52 +00:00
|
|
|
{&nsGkAtoms::dragging, &nsGkAtoms::collapsed, nsnull};
|
2006-07-19 22:30:33 +00:00
|
|
|
static nsIContent::AttrValuesArray strings_substate[] =
|
2006-12-26 17:47:52 +00:00
|
|
|
{&nsGkAtoms::before, &nsGkAtoms::after, nsnull};
|
2006-04-24 05:40:11 +00:00
|
|
|
switch (mOuter->GetContent()->FindAttrValueIn(kNameSpaceID_None,
|
2006-12-26 17:47:52 +00:00
|
|
|
nsGkAtoms::state,
|
2006-04-24 05:40:11 +00:00
|
|
|
strings, eCaseMatters)) {
|
|
|
|
case 0: return Dragging;
|
2006-07-19 22:30:33 +00:00
|
|
|
case 1:
|
|
|
|
switch (mOuter->GetContent()->FindAttrValueIn(kNameSpaceID_None,
|
2006-12-26 17:47:52 +00:00
|
|
|
nsGkAtoms::substate,
|
2006-07-19 22:30:33 +00:00
|
|
|
strings_substate,
|
|
|
|
eCaseMatters)) {
|
|
|
|
case 0: return CollapsedBefore;
|
|
|
|
case 1: return CollapsedAfter;
|
|
|
|
default:
|
|
|
|
if (SupportsCollapseDirection(After))
|
|
|
|
return CollapsedAfter;
|
|
|
|
return CollapsedBefore;
|
|
|
|
}
|
2006-04-24 05:40:11 +00:00
|
|
|
}
|
2003-12-21 04:04:05 +00:00
|
|
|
return Open;
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
1999-06-30 22:17:43 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// NS_NewSplitterFrame
|
|
|
|
//
|
2005-10-26 21:46:39 +00:00
|
|
|
// Creates a new Toolbar frame and returns it
|
1999-06-30 22:17:43 +00:00
|
|
|
//
|
2005-10-26 21:46:39 +00:00
|
|
|
nsIFrame*
|
2006-03-26 21:30:36 +00:00
|
|
|
NS_NewSplitterFrame (nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1999-06-30 22:17:43 +00:00
|
|
|
{
|
2006-03-26 21:30:36 +00:00
|
|
|
return new (aPresShell) nsSplitterFrame(aPresShell, aContext);
|
2009-09-12 16:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsSplitterFrame)
|
1999-06-30 22:17:43 +00:00
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
nsSplitterFrame::nsSplitterFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
|
|
: nsBoxFrame(aPresShell, aContext),
|
2003-12-21 04:04:05 +00:00
|
|
|
mInner(0)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-05-21 07:33:32 +00:00
|
|
|
void
|
2009-12-24 05:21:15 +00:00
|
|
|
nsSplitterFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2003-12-21 04:04:05 +00:00
|
|
|
if (mInner) {
|
|
|
|
mInner->RemoveListener();
|
2007-05-21 07:33:32 +00:00
|
|
|
mInner->Disconnect();
|
2003-12-21 04:04:05 +00:00
|
|
|
mInner->Release();
|
2007-05-21 07:33:32 +00:00
|
|
|
mInner = nsnull;
|
2003-12-21 04:04:05 +00:00
|
|
|
}
|
2009-12-24 05:21:15 +00:00
|
|
|
nsBoxFrame::DestroyFrom(aDestructRoot);
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
2000-05-26 06:42:29 +00:00
|
|
|
|
1999-09-14 22:17:19 +00:00
|
|
|
NS_IMETHODIMP
|
2004-12-30 21:56:11 +00:00
|
|
|
nsSplitterFrame::GetCursor(const nsPoint& aPoint,
|
|
|
|
nsIFrame::Cursor& aCursor)
|
1999-09-14 22:17:19 +00:00
|
|
|
{
|
2004-12-30 21:56:11 +00:00
|
|
|
return nsBoxFrame::GetCursor(aPoint, aCursor);
|
2000-01-18 23:14:25 +00:00
|
|
|
|
2003-12-21 04:04:05 +00:00
|
|
|
/*
|
|
|
|
if (IsHorizontal())
|
1999-09-14 22:17:19 +00:00
|
|
|
aCursor = NS_STYLE_CURSOR_N_RESIZE;
|
2003-12-21 04:04:05 +00:00
|
|
|
else
|
1999-09-14 22:17:19 +00:00
|
|
|
aCursor = NS_STYLE_CURSOR_W_RESIZE;
|
2003-12-21 04:04:05 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
*/
|
1999-09-14 22:17:19 +00:00
|
|
|
}
|
|
|
|
|
1999-06-30 22:17:43 +00:00
|
|
|
NS_IMETHODIMP
|
2005-09-07 16:49:21 +00:00
|
|
|
nsSplitterFrame::AttributeChanged(PRInt32 aNameSpaceID,
|
2003-07-11 21:16:12 +00:00
|
|
|
nsIAtom* aAttribute,
|
|
|
|
PRInt32 aModType)
|
1999-06-30 22:17:43 +00:00
|
|
|
{
|
2005-09-07 16:49:21 +00:00
|
|
|
nsresult rv = nsBoxFrame::AttributeChanged(aNameSpaceID, aAttribute,
|
|
|
|
aModType);
|
1999-06-30 22:17:43 +00:00
|
|
|
// if the alignment changed. Let the grippy know
|
2006-12-26 17:47:52 +00:00
|
|
|
if (aAttribute == nsGkAtoms::align) {
|
2003-12-21 04:04:05 +00:00
|
|
|
// tell the slider its attribute changed so it can
|
|
|
|
// update itself
|
|
|
|
nsIFrame* grippy = nsnull;
|
2007-03-30 21:11:41 +00:00
|
|
|
nsScrollbarButtonFrame::GetChildWithTag(PresContext(), nsGkAtoms::grippy, this, grippy);
|
2003-12-21 04:04:05 +00:00
|
|
|
if (grippy)
|
2005-09-07 16:49:21 +00:00
|
|
|
grippy->AttributeChanged(aNameSpaceID, aAttribute, aModType);
|
2006-12-26 17:47:52 +00:00
|
|
|
} else if (aAttribute == nsGkAtoms::state) {
|
2003-12-21 04:04:05 +00:00
|
|
|
mInner->UpdateState();
|
1999-06-30 22:17:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize us. If we are in a box get our alignment so we know what direction we are
|
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
2006-03-09 18:55:21 +00:00
|
|
|
nsSplitterFrame::Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
1999-06-30 22:17:43 +00:00
|
|
|
{
|
2003-12-21 04:04:05 +00:00
|
|
|
NS_ENSURE_FALSE(mInner, NS_ERROR_ALREADY_INITIALIZED);
|
|
|
|
mInner = new nsSplitterFrameInner(this);
|
|
|
|
if (!mInner)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
mInner->AddRef();
|
|
|
|
mInner->mChildInfosAfter = nsnull;
|
|
|
|
mInner->mChildInfosBefore = nsnull;
|
|
|
|
mInner->mState = nsSplitterFrameInner::Open;
|
2011-10-17 14:59:28 +00:00
|
|
|
mInner->mDragging = false;
|
2004-10-28 07:25:57 +00:00
|
|
|
|
2001-10-26 00:09:12 +00:00
|
|
|
// determine orientation of parent, and if vertical, set orient to vertical
|
|
|
|
// on splitter content, then re-resolve style
|
2007-10-04 02:58:48 +00:00
|
|
|
// XXXbz this is pretty messed up, since this can change whether we should
|
|
|
|
// have a frame at all. This really needs a better solution.
|
2004-09-28 18:37:50 +00:00
|
|
|
if (aParent && aParent->IsBoxFrame()) {
|
2007-01-31 16:02:42 +00:00
|
|
|
if (!aParent->IsHorizontal()) {
|
2006-04-24 05:40:11 +00:00
|
|
|
if (!nsContentUtils::HasNonEmptyAttr(aContent, kNameSpaceID_None,
|
2006-12-26 17:47:52 +00:00
|
|
|
nsGkAtoms::orient)) {
|
|
|
|
aContent->SetAttr(kNameSpaceID_None, nsGkAtoms::orient,
|
2011-10-17 14:59:28 +00:00
|
|
|
NS_LITERAL_STRING("vertical"), false);
|
2007-10-04 02:58:48 +00:00
|
|
|
nsStyleContext* parentStyleContext = GetStyleContext()->GetParent();
|
|
|
|
nsRefPtr<nsStyleContext> newContext = PresContext()->StyleSet()->
|
2010-04-30 13:12:06 +00:00
|
|
|
ResolveStyleFor(aContent->AsElement(), parentStyleContext);
|
2006-03-26 21:30:36 +00:00
|
|
|
SetStyleContextWithoutNotification(newContext);
|
2001-10-26 00:09:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
nsresult rv = nsBoxFrame::Init(aContent, aParent, aPrevInFlow);
|
2007-05-14 00:42:38 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
1999-06-30 22:17:43 +00:00
|
|
|
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
mInner->mState = nsSplitterFrameInner::Open;
|
2007-03-30 21:11:41 +00:00
|
|
|
mInner->AddListener(PresContext());
|
2000-03-31 07:02:06 +00:00
|
|
|
mInner->mParentBox = nsnull;
|
1999-06-30 22:17:43 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
NS_IMETHODIMP
|
2000-07-07 22:24:06 +00:00
|
|
|
nsSplitterFrame::DoLayout(nsBoxLayoutState& aState)
|
2000-03-31 07:02:06 +00:00
|
|
|
{
|
2004-09-28 18:37:50 +00:00
|
|
|
if (GetStateBits() & NS_FRAME_FIRST_REFLOW)
|
2000-05-26 06:42:29 +00:00
|
|
|
{
|
2007-02-22 18:05:14 +00:00
|
|
|
mInner->mParentBox = GetParentBox();
|
2000-03-31 07:02:06 +00:00
|
|
|
mInner->UpdateState();
|
|
|
|
}
|
2000-05-26 06:42:29 +00:00
|
|
|
|
2000-07-07 22:24:06 +00:00
|
|
|
return nsBoxFrame::DoLayout(aState);
|
2000-03-31 07:02:06 +00:00
|
|
|
}
|
|
|
|
|
2001-03-08 00:47:22 +00:00
|
|
|
|
|
|
|
void
|
2011-09-29 06:19:26 +00:00
|
|
|
nsSplitterFrame::GetInitialOrientation(bool& aIsHorizontal)
|
2001-03-08 00:47:22 +00:00
|
|
|
{
|
2007-02-22 18:05:14 +00:00
|
|
|
nsIBox* box = GetParentBox();
|
2001-03-08 00:47:22 +00:00
|
|
|
if (box) {
|
2007-01-31 16:02:42 +00:00
|
|
|
aIsHorizontal = !box->IsHorizontal();
|
2001-03-08 00:47:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
nsBoxFrame::GetInitialOrientation(aIsHorizontal);
|
|
|
|
}
|
|
|
|
|
1999-09-05 20:46:59 +00:00
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsSplitterFrame::HandlePress(nsPresContext* aPresContext,
|
1999-09-05 20:46:59 +00:00
|
|
|
nsGUIEvent * aEvent,
|
1999-11-24 06:03:41 +00:00
|
|
|
nsEventStatus* aEventStatus)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsSplitterFrame::HandleMultiplePress(nsPresContext* aPresContext,
|
2009-07-28 12:53:20 +00:00
|
|
|
nsGUIEvent * aEvent,
|
|
|
|
nsEventStatus* aEventStatus,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aControlHeld)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-08-03 03:39:02 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSplitterFrame::HandleDrag(nsPresContext* aPresContext,
|
|
|
|
nsGUIEvent * aEvent,
|
|
|
|
nsEventStatus* aEventStatus)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSplitterFrame::HandleRelease(nsPresContext* aPresContext,
|
|
|
|
nsGUIEvent * aEvent,
|
|
|
|
nsEventStatus* aEventStatus)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSplitterFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
2005-09-19 02:15:54 +00:00
|
|
|
{
|
2006-01-26 02:29:17 +00:00
|
|
|
nsresult rv = nsBoxFrame::BuildDisplayList(aBuilder, aDirtyRect, aLists);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
1999-09-05 20:46:59 +00:00
|
|
|
// if the mouse is captured always return us as the frame.
|
2000-08-30 21:51:02 +00:00
|
|
|
if (mInner->mDragging)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2000-03-22 02:43:08 +00:00
|
|
|
// XXX It's probably better not to check visibility here, right?
|
2006-01-26 02:29:17 +00:00
|
|
|
return aLists.Outlines()->AppendNewToTop(new (aBuilder)
|
2010-08-13 10:01:13 +00:00
|
|
|
nsDisplayEventReceiver(aBuilder, this));
|
2003-11-15 00:47:43 +00:00
|
|
|
}
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
return NS_OK;
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsSplitterFrame::HandleEvent(nsPresContext* aPresContext,
|
1999-09-05 20:46:59 +00:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 06:03:41 +00:00
|
|
|
nsEventStatus* aEventStatus)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2009-02-27 10:48:25 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aEventStatus);
|
|
|
|
if (nsEventStatus_eConsumeNoDefault == *aEventStatus) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-10-02 06:50:34 +00:00
|
|
|
nsWeakFrame weakFrame(this);
|
|
|
|
nsRefPtr<nsSplitterFrameInner> kungFuDeathGrip(mInner);
|
2003-12-21 04:04:05 +00:00
|
|
|
switch (aEvent->message) {
|
1999-09-05 20:46:59 +00:00
|
|
|
case NS_MOUSE_MOVE:
|
2003-12-21 04:04:05 +00:00
|
|
|
mInner->MouseDrag(aPresContext, aEvent);
|
1999-09-05 20:46:59 +00:00
|
|
|
break;
|
|
|
|
|
2006-11-16 21:35:39 +00:00
|
|
|
case NS_MOUSE_BUTTON_UP:
|
|
|
|
if (aEvent->eventStructType == NS_MOUSE_EVENT &&
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsMouseEvent*>(aEvent)->button ==
|
2006-11-16 21:35:39 +00:00
|
|
|
nsMouseEvent::eLeftButton) {
|
|
|
|
mInner->MouseUp(aPresContext, aEvent);
|
|
|
|
}
|
1999-09-05 20:46:59 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-10-02 06:50:34 +00:00
|
|
|
NS_ENSURE_STATE(weakFrame.IsAlive());
|
2000-08-30 21:51:02 +00:00
|
|
|
return nsBoxFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
1999-09-08 23:51:02 +00:00
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsSplitterFrameInner::MouseUp(nsPresContext* aPresContext, nsGUIEvent* aEvent)
|
1999-09-08 23:51:02 +00:00
|
|
|
{
|
2007-05-21 07:33:32 +00:00
|
|
|
if (mDragging && mOuter) {
|
2003-12-21 04:04:05 +00:00
|
|
|
AdjustChildren(aPresContext);
|
|
|
|
AddListener(aPresContext);
|
2009-09-13 13:13:16 +00:00
|
|
|
nsIPresShell::SetCapturingContent(nsnull, 0); // XXXndeakin is this needed?
|
2011-10-17 14:59:28 +00:00
|
|
|
mDragging = false;
|
2003-12-21 04:04:05 +00:00
|
|
|
State newState = GetState();
|
|
|
|
// if the state is dragging then make it Open.
|
|
|
|
if (newState == Dragging)
|
2011-10-17 14:59:28 +00:00
|
|
|
mOuter->mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::state, EmptyString(), true);
|
2003-10-21 11:43:40 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
mPressed = false;
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
|
2003-12-21 04:04:05 +00:00
|
|
|
// if we dragged then fire a command event.
|
|
|
|
if (mDidDrag) {
|
|
|
|
nsCOMPtr<nsIDOMXULElement> element = do_QueryInterface(mOuter->GetContent());
|
|
|
|
element->DoCommand();
|
|
|
|
}
|
|
|
|
|
|
|
|
//printf("MouseUp\n");
|
|
|
|
}
|
2005-10-11 18:59:58 +00:00
|
|
|
|
|
|
|
delete[] mChildInfosBefore;
|
|
|
|
delete[] mChildInfosAfter;
|
|
|
|
mChildInfosBefore = nsnull;
|
|
|
|
mChildInfosAfter = nsnull;
|
2008-09-17 14:38:33 +00:00
|
|
|
mChildInfosBeforeCount = 0;
|
|
|
|
mChildInfosAfterCount = 0;
|
1999-09-08 23:51:02 +00:00
|
|
|
}
|
|
|
|
|
1999-09-05 20:46:59 +00:00
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsSplitterFrameInner::MouseDrag(nsPresContext* aPresContext, nsGUIEvent* aEvent)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2007-05-21 07:33:32 +00:00
|
|
|
if (mDragging && mOuter) {
|
1999-09-14 22:17:19 +00:00
|
|
|
|
2003-12-21 04:04:05 +00:00
|
|
|
//printf("Dragging\n");
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isHorizontal = !mOuter->IsHorizontal();
|
2003-12-21 04:04:05 +00:00
|
|
|
// convert coord to pixels
|
2005-08-23 20:48:56 +00:00
|
|
|
nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent,
|
|
|
|
mParentBox);
|
2005-08-23 03:57:07 +00:00
|
|
|
nscoord pos = isHorizontal ? pt.x : pt.y;
|
1999-09-14 22:17:19 +00:00
|
|
|
|
2005-08-23 03:57:07 +00:00
|
|
|
// mDragStart is in frame coordinates
|
|
|
|
nscoord start = mDragStart;
|
2005-04-18 05:18:34 +00:00
|
|
|
|
2005-11-20 22:05:24 +00:00
|
|
|
// take our current position and subtract the start location
|
2003-12-21 04:04:05 +00:00
|
|
|
pos -= start;
|
|
|
|
|
|
|
|
//printf("Diff=%d\n", pos);
|
|
|
|
|
|
|
|
ResizeType resizeAfter = GetResizeAfter();
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool bounded;
|
2003-12-21 04:04:05 +00:00
|
|
|
|
|
|
|
if (resizeAfter == nsSplitterFrameInner::Grow)
|
2011-10-17 14:59:28 +00:00
|
|
|
bounded = false;
|
2003-12-21 04:04:05 +00:00
|
|
|
else
|
2011-10-17 14:59:28 +00:00
|
|
|
bounded = true;
|
2003-12-21 04:04:05 +00:00
|
|
|
|
|
|
|
int i;
|
|
|
|
for (i=0; i < mChildInfosBeforeCount; i++)
|
|
|
|
mChildInfosBefore[i].changed = mChildInfosBefore[i].current;
|
|
|
|
|
|
|
|
for (i=0; i < mChildInfosAfterCount; i++)
|
|
|
|
mChildInfosAfter[i].changed = mChildInfosAfter[i].current;
|
|
|
|
|
|
|
|
nscoord oldPos = pos;
|
|
|
|
|
|
|
|
ResizeChildTo(aPresContext, pos, mChildInfosBefore, mChildInfosAfter, mChildInfosBeforeCount, mChildInfosAfterCount, bounded);
|
|
|
|
|
|
|
|
State currentState = GetState();
|
2011-09-29 06:19:26 +00:00
|
|
|
bool supportsBefore = SupportsCollapseDirection(Before);
|
|
|
|
bool supportsAfter = SupportsCollapseDirection(After);
|
2003-12-21 04:04:05 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
const bool isRTL = mOuter->GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL;
|
|
|
|
bool pastEnd = oldPos > 0 && oldPos > pos;
|
|
|
|
bool pastBegin = oldPos < 0 && oldPos < pos;
|
2010-04-11 23:46:08 +00:00
|
|
|
if (isRTL) {
|
|
|
|
// Swap the boundary checks in RTL mode
|
2011-09-29 06:19:26 +00:00
|
|
|
bool tmp = pastEnd;
|
2010-04-11 23:46:08 +00:00
|
|
|
pastEnd = pastBegin;
|
|
|
|
pastBegin = tmp;
|
|
|
|
}
|
2011-09-29 06:19:26 +00:00
|
|
|
const bool isCollapsedBefore = pastBegin && supportsBefore;
|
|
|
|
const bool isCollapsedAfter = pastEnd && supportsAfter;
|
2010-04-11 23:46:08 +00:00
|
|
|
|
2003-12-21 04:04:05 +00:00
|
|
|
// if we are in a collapsed position
|
2010-04-11 23:46:08 +00:00
|
|
|
if (isCollapsedBefore || isCollapsedAfter)
|
2003-12-21 04:04:05 +00:00
|
|
|
{
|
|
|
|
// and we are not collapsed then collapse
|
|
|
|
if (currentState == Dragging) {
|
2010-04-11 23:46:08 +00:00
|
|
|
if (pastEnd)
|
2003-12-21 04:04:05 +00:00
|
|
|
{
|
|
|
|
//printf("Collapse right\n");
|
2006-07-19 22:30:33 +00:00
|
|
|
if (supportsAfter)
|
2003-12-21 04:04:05 +00:00
|
|
|
{
|
2006-09-03 20:25:58 +00:00
|
|
|
nsCOMPtr<nsIContent> outer = mOuter->mContent;
|
2006-12-26 17:47:52 +00:00
|
|
|
outer->SetAttr(kNameSpaceID_None, nsGkAtoms::substate,
|
2006-09-03 20:25:58 +00:00
|
|
|
NS_LITERAL_STRING("after"),
|
2011-10-17 14:59:28 +00:00
|
|
|
true);
|
2006-12-26 17:47:52 +00:00
|
|
|
outer->SetAttr(kNameSpaceID_None, nsGkAtoms::state,
|
2006-09-03 20:25:58 +00:00
|
|
|
NS_LITERAL_STRING("collapsed"),
|
2011-10-17 14:59:28 +00:00
|
|
|
true);
|
2003-12-21 04:04:05 +00:00
|
|
|
}
|
|
|
|
|
2010-04-11 23:46:08 +00:00
|
|
|
} else if (pastBegin)
|
2003-12-21 04:04:05 +00:00
|
|
|
{
|
|
|
|
//printf("Collapse left\n");
|
2006-07-19 22:30:33 +00:00
|
|
|
if (supportsBefore)
|
2003-12-21 04:04:05 +00:00
|
|
|
{
|
2006-09-03 20:25:58 +00:00
|
|
|
nsCOMPtr<nsIContent> outer = mOuter->mContent;
|
2006-12-26 17:47:52 +00:00
|
|
|
outer->SetAttr(kNameSpaceID_None, nsGkAtoms::substate,
|
2006-09-03 20:25:58 +00:00
|
|
|
NS_LITERAL_STRING("before"),
|
2011-10-17 14:59:28 +00:00
|
|
|
true);
|
2006-12-26 17:47:52 +00:00
|
|
|
outer->SetAttr(kNameSpaceID_None, nsGkAtoms::state,
|
2006-09-03 20:25:58 +00:00
|
|
|
NS_LITERAL_STRING("collapsed"),
|
2011-10-17 14:59:28 +00:00
|
|
|
true);
|
2003-12-21 04:04:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// if we are not in a collapsed position and we are not dragging make sure
|
|
|
|
// we are dragging.
|
|
|
|
if (currentState != Dragging)
|
2011-10-17 14:59:28 +00:00
|
|
|
mOuter->mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::state, NS_LITERAL_STRING("dragging"), true);
|
2009-07-04 09:47:59 +00:00
|
|
|
AdjustChildren(aPresContext);
|
2003-12-21 04:04:05 +00:00
|
|
|
}
|
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
mDidDrag = true;
|
2003-12-21 04:04:05 +00:00
|
|
|
}
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsSplitterFrameInner::AddListener(nsPresContext* aPresContext)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2007-05-14 09:11:38 +00:00
|
|
|
mOuter->GetContent()->
|
2011-10-17 14:59:28 +00:00
|
|
|
AddEventListener(NS_LITERAL_STRING("mouseup"), this, false, false);
|
2007-05-14 09:11:38 +00:00
|
|
|
mOuter->GetContent()->
|
2011-10-17 14:59:28 +00:00
|
|
|
AddEventListener(NS_LITERAL_STRING("mousedown"), this, false, false);
|
2011-06-28 17:59:14 +00:00
|
|
|
mOuter->GetContent()->
|
2011-10-17 14:59:28 +00:00
|
|
|
AddEventListener(NS_LITERAL_STRING("mousemove"), this, false, false);
|
2011-06-28 17:59:14 +00:00
|
|
|
mOuter->GetContent()->
|
2011-10-17 14:59:28 +00:00
|
|
|
AddEventListener(NS_LITERAL_STRING("mouseout"), this, false, false);
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
nsSplitterFrameInner::RemoveListener()
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2007-05-21 07:33:32 +00:00
|
|
|
ENSURE_TRUE(mOuter);
|
2007-05-14 09:11:38 +00:00
|
|
|
mOuter->GetContent()->
|
2011-10-17 14:59:28 +00:00
|
|
|
RemoveEventListener(NS_LITERAL_STRING("mouseup"), this, false);
|
2011-06-28 17:59:14 +00:00
|
|
|
mOuter->GetContent()->
|
2011-10-17 14:59:28 +00:00
|
|
|
RemoveEventListener(NS_LITERAL_STRING("mousedown"), this, false);
|
2007-05-14 09:11:38 +00:00
|
|
|
mOuter->GetContent()->
|
2011-10-17 14:59:28 +00:00
|
|
|
RemoveEventListener(NS_LITERAL_STRING("mousemove"), this, false);
|
2011-06-28 17:59:14 +00:00
|
|
|
mOuter->GetContent()->
|
2011-10-17 14:59:28 +00:00
|
|
|
RemoveEventListener(NS_LITERAL_STRING("mouseout"), this, false);
|
2011-06-28 17:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsSplitterFrameInner::HandleEvent(nsIDOMEvent* aEvent)
|
|
|
|
{
|
|
|
|
nsAutoString eventType;
|
|
|
|
aEvent->GetType(eventType);
|
|
|
|
if (eventType.EqualsLiteral("mouseup"))
|
|
|
|
return MouseUp(aEvent);
|
|
|
|
if (eventType.EqualsLiteral("mousedown"))
|
|
|
|
return MouseDown(aEvent);
|
|
|
|
if (eventType.EqualsLiteral("mousemove") ||
|
|
|
|
eventType.EqualsLiteral("mouseout"))
|
|
|
|
return MouseMove(aEvent);
|
|
|
|
|
|
|
|
NS_ABORT();
|
|
|
|
return NS_OK;
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
nsSplitterFrameInner::MouseUp(nsIDOMEvent* aMouseEvent)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2007-05-21 07:33:32 +00:00
|
|
|
NS_ENSURE_TRUE(mOuter, NS_OK);
|
2011-10-17 14:59:28 +00:00
|
|
|
mPressed = false;
|
2002-04-10 04:58:02 +00:00
|
|
|
|
2009-09-13 13:13:16 +00:00
|
|
|
nsIPresShell::SetCapturingContent(nsnull, 0);
|
2002-04-10 04:58:02 +00:00
|
|
|
|
1999-09-05 20:46:59 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2007-05-21 07:33:32 +00:00
|
|
|
NS_ENSURE_TRUE(mOuter, NS_OK);
|
2000-05-15 22:43:47 +00:00
|
|
|
nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(aMouseEvent));
|
2011-06-28 17:59:14 +00:00
|
|
|
if (!mouseEvent)
|
|
|
|
return NS_OK;
|
2000-05-15 22:43:47 +00:00
|
|
|
|
|
|
|
PRUint16 button = 0;
|
|
|
|
mouseEvent->GetButton(&button);
|
|
|
|
|
|
|
|
// only if left button
|
2001-03-02 03:07:53 +00:00
|
|
|
if (button != 0)
|
2000-05-15 22:43:47 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
2006-01-10 20:00:39 +00:00
|
|
|
if (mOuter->GetContent()->
|
2006-12-26 17:47:52 +00:00
|
|
|
AttrValueIs(kNameSpaceID_None, nsGkAtoms::disabled,
|
|
|
|
nsGkAtoms::_true, eCaseMatters))
|
2000-09-08 06:55:10 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
2007-02-22 18:05:14 +00:00
|
|
|
mParentBox = mOuter->GetParentBox();
|
2006-03-24 21:05:11 +00:00
|
|
|
if (!mParentBox)
|
|
|
|
return NS_OK;
|
2009-04-25 08:33:32 +00:00
|
|
|
|
2006-03-24 21:05:11 +00:00
|
|
|
// get our index
|
2007-03-30 21:11:41 +00:00
|
|
|
nsPresContext* outerPresContext = mOuter->PresContext();
|
2011-08-24 20:54:30 +00:00
|
|
|
const nsFrameList& siblingList(mParentBox->PrincipalChildList());
|
2009-04-25 08:33:32 +00:00
|
|
|
PRInt32 childIndex = siblingList.IndexOf(mOuter);
|
|
|
|
// if it's 0 (or not found) then stop right here.
|
|
|
|
// It might be not found if we're not in the parent's primary frame list.
|
|
|
|
if (childIndex <= 0)
|
2007-08-24 10:39:08 +00:00
|
|
|
return NS_OK;
|
2006-03-24 21:05:11 +00:00
|
|
|
|
2009-04-25 08:33:32 +00:00
|
|
|
PRInt32 childCount = siblingList.GetLength();
|
2007-08-24 10:39:08 +00:00
|
|
|
// if it's the last index then we need to allow for resizeafter="grow"
|
|
|
|
if (childIndex == childCount - 1 && GetResizeAfter() != Grow)
|
2006-03-24 21:05:11 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
2011-04-08 01:04:40 +00:00
|
|
|
nsRefPtr<nsRenderingContext> rc =
|
2010-08-20 19:29:01 +00:00
|
|
|
outerPresContext->PresShell()->GetReferenceRenderingContext();
|
|
|
|
NS_ENSURE_TRUE(rc, NS_ERROR_FAILURE);
|
2007-04-29 22:24:59 +00:00
|
|
|
nsBoxLayoutState state(outerPresContext, rc);
|
1999-09-05 20:46:59 +00:00
|
|
|
mCurrentPos = 0;
|
2011-10-17 14:59:28 +00:00
|
|
|
mPressed = true;
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
mDidDrag = false;
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2003-12-21 04:04:05 +00:00
|
|
|
EnsureOrient();
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isHorizontal = !mOuter->IsHorizontal();
|
2001-08-15 04:09:41 +00:00
|
|
|
|
1999-09-05 20:46:59 +00:00
|
|
|
ResizeType resizeBefore = GetResizeBefore();
|
|
|
|
ResizeType resizeAfter = GetResizeAfter();
|
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
delete[] mChildInfosBefore;
|
|
|
|
delete[] mChildInfosAfter;
|
1999-09-05 20:46:59 +00:00
|
|
|
mChildInfosBefore = new nsSplitterInfo[childCount];
|
|
|
|
mChildInfosAfter = new nsSplitterInfo[childCount];
|
|
|
|
|
|
|
|
// create info 2 lists. One of the children before us and one after.
|
|
|
|
PRInt32 count = 0;
|
|
|
|
mChildInfosBeforeCount = 0;
|
|
|
|
mChildInfosAfterCount = 0;
|
|
|
|
|
2007-02-22 18:05:14 +00:00
|
|
|
nsIBox* childBox = mParentBox->GetChildBox();
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
while (nsnull != childBox)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2004-09-28 18:37:50 +00:00
|
|
|
nsIContent* content = childBox->GetContent();
|
2011-10-18 10:53:36 +00:00
|
|
|
nsIDocument* doc = content->OwnerDoc();
|
2011-10-18 11:19:44 +00:00
|
|
|
PRInt32 dummy;
|
|
|
|
nsIAtom* atom = doc->BindingManager()->ResolveTag(content, &dummy);
|
1999-09-05 20:46:59 +00:00
|
|
|
|
|
|
|
// skip over any splitters
|
2006-12-26 17:47:52 +00:00
|
|
|
if (atom != nsGkAtoms::splitter) {
|
2007-01-08 02:57:59 +00:00
|
|
|
nsSize prefSize = childBox->GetPrefSize(state);
|
|
|
|
nsSize minSize = childBox->GetMinSize(state);
|
2008-01-05 05:49:44 +00:00
|
|
|
nsSize maxSize = nsBox::BoundsCheckMinMax(minSize, childBox->GetMaxSize(state));
|
|
|
|
prefSize = nsBox::BoundsCheck(minSize, prefSize, maxSize);
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
mOuter->AddMargin(childBox, minSize);
|
|
|
|
mOuter->AddMargin(childBox, prefSize);
|
|
|
|
mOuter->AddMargin(childBox, maxSize);
|
|
|
|
|
2007-01-31 16:02:42 +00:00
|
|
|
nscoord flex = childBox->GetFlex(state);
|
1999-09-05 20:46:59 +00:00
|
|
|
|
|
|
|
nsMargin margin(0,0,0,0);
|
2000-03-31 07:02:06 +00:00
|
|
|
childBox->GetMargin(margin);
|
2004-09-28 18:37:50 +00:00
|
|
|
nsRect r(childBox->GetRect());
|
1999-09-05 20:46:59 +00:00
|
|
|
r.Inflate(margin);
|
|
|
|
|
2002-07-16 01:45:38 +00:00
|
|
|
// We need to check for hidden attribute too, since treecols with
|
|
|
|
// the hidden="true" attribute are not really hidden, just collapsed
|
2006-12-26 17:47:52 +00:00
|
|
|
if (!content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::fixed,
|
|
|
|
nsGkAtoms::_true, eCaseMatters) &&
|
|
|
|
!content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::hidden,
|
|
|
|
nsGkAtoms::_true, eCaseMatters)) {
|
2007-11-15 03:38:16 +00:00
|
|
|
if (count < childIndex && (resizeBefore != Flex || flex > 0)) {
|
2005-10-11 18:59:58 +00:00
|
|
|
mChildInfosBefore[mChildInfosBeforeCount].childElem = content;
|
2000-09-08 06:55:10 +00:00
|
|
|
mChildInfosBefore[mChildInfosBeforeCount].min = isHorizontal ? minSize.width : minSize.height;
|
|
|
|
mChildInfosBefore[mChildInfosBeforeCount].max = isHorizontal ? maxSize.width : maxSize.height;
|
|
|
|
mChildInfosBefore[mChildInfosBeforeCount].current = isHorizontal ? r.width : r.height;
|
|
|
|
mChildInfosBefore[mChildInfosBeforeCount].flex = flex;
|
|
|
|
mChildInfosBefore[mChildInfosBeforeCount].index = count;
|
|
|
|
mChildInfosBefore[mChildInfosBeforeCount].changed = mChildInfosBefore[mChildInfosBeforeCount].current;
|
|
|
|
mChildInfosBeforeCount++;
|
2007-11-15 03:38:16 +00:00
|
|
|
} else if (count > childIndex && (resizeAfter != Flex || flex > 0)) {
|
2005-10-11 18:59:58 +00:00
|
|
|
mChildInfosAfter[mChildInfosAfterCount].childElem = content;
|
2000-09-08 06:55:10 +00:00
|
|
|
mChildInfosAfter[mChildInfosAfterCount].min = isHorizontal ? minSize.width : minSize.height;
|
|
|
|
mChildInfosAfter[mChildInfosAfterCount].max = isHorizontal ? maxSize.width : maxSize.height;
|
|
|
|
mChildInfosAfter[mChildInfosAfterCount].current = isHorizontal ? r.width : r.height;
|
|
|
|
mChildInfosAfter[mChildInfosAfterCount].flex = flex;
|
|
|
|
mChildInfosAfter[mChildInfosAfterCount].index = count;
|
2002-07-16 01:45:38 +00:00
|
|
|
mChildInfosAfter[mChildInfosAfterCount].changed = mChildInfosAfter[mChildInfosAfterCount].current;
|
2000-09-08 06:55:10 +00:00
|
|
|
mChildInfosAfterCount++;
|
|
|
|
}
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-22 18:05:14 +00:00
|
|
|
childBox = childBox->GetNextBox();
|
1999-09-05 20:46:59 +00:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
|
2007-01-31 16:02:42 +00:00
|
|
|
if (!mParentBox->IsNormalDirection()) {
|
2001-08-15 04:09:41 +00:00
|
|
|
// The before array is really the after array, and the order needs to be reversed.
|
|
|
|
// First reverse both arrays.
|
|
|
|
Reverse(mChildInfosBefore, mChildInfosBeforeCount);
|
|
|
|
Reverse(mChildInfosAfter, mChildInfosAfterCount);
|
|
|
|
|
|
|
|
// Now swap the two arrays.
|
|
|
|
nscoord newAfterCount = mChildInfosBeforeCount;
|
|
|
|
mChildInfosBeforeCount = mChildInfosAfterCount;
|
|
|
|
mChildInfosAfterCount = newAfterCount;
|
|
|
|
nsSplitterInfo* temp = mChildInfosAfter;
|
|
|
|
mChildInfosAfter = mChildInfosBefore;
|
|
|
|
mChildInfosBefore = temp;
|
|
|
|
}
|
|
|
|
|
2007-11-15 03:38:16 +00:00
|
|
|
// if resizebefore is not Farthest, reverse the list because the first child
|
|
|
|
// in the list is the farthest, and we want the first child to be the closest.
|
|
|
|
if (resizeBefore != Farthest)
|
1999-09-05 20:46:59 +00:00
|
|
|
Reverse(mChildInfosBefore, mChildInfosBeforeCount);
|
|
|
|
|
1999-09-08 23:51:02 +00:00
|
|
|
// if the resizeafter is the Farthest we must reverse the list because the first child in the list
|
|
|
|
// is the closest we want the first child to be the Farthest.
|
|
|
|
if (resizeAfter == Farthest)
|
1999-09-05 20:46:59 +00:00
|
|
|
Reverse(mChildInfosAfter, mChildInfosAfterCount);
|
|
|
|
|
|
|
|
// grow only applys to the children after. If grow is set then no space should be taken out of any children after
|
|
|
|
// us. To do this we just set the size of that list to be 0.
|
|
|
|
if (resizeAfter == Grow)
|
|
|
|
mChildInfosAfterCount = 0;
|
|
|
|
|
2005-08-23 03:57:07 +00:00
|
|
|
PRInt32 c;
|
|
|
|
nsPoint pt = nsLayoutUtils::GetDOMEventCoordinatesRelativeTo(mouseEvent,
|
2005-08-23 20:48:56 +00:00
|
|
|
mParentBox);
|
1999-09-05 20:46:59 +00:00
|
|
|
if (isHorizontal) {
|
2005-08-23 03:57:07 +00:00
|
|
|
c = pt.x;
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
mSplitterPos = mOuter->mRect.x;
|
1999-09-05 20:46:59 +00:00
|
|
|
} else {
|
2005-08-23 03:57:07 +00:00
|
|
|
c = pt.y;
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
mSplitterPos = mOuter->mRect.y;
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
2005-08-23 03:57:07 +00:00
|
|
|
mDragStart = c;
|
2005-12-15 03:30:17 +00:00
|
|
|
|
2005-08-23 03:57:07 +00:00
|
|
|
//printf("Pressed mDragStart=%d\n",mDragStart);
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2009-09-13 13:13:16 +00:00
|
|
|
nsIPresShell::SetCapturingContent(mOuter->GetContent(), CAPTURE_IGNOREALLOWED);
|
2002-03-27 05:49:56 +00:00
|
|
|
|
1999-09-05 20:46:59 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
nsSplitterFrameInner::MouseMove(nsIDOMEvent* aMouseEvent)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2007-05-21 07:33:32 +00:00
|
|
|
NS_ENSURE_TRUE(mOuter, NS_OK);
|
1999-09-05 20:46:59 +00:00
|
|
|
if (!mPressed)
|
2005-12-15 03:30:17 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
2000-08-30 21:51:02 +00:00
|
|
|
if (mDragging)
|
1999-09-05 20:46:59 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
2011-06-28 17:59:14 +00:00
|
|
|
nsCOMPtr<nsIDOMEventListener> kungfuDeathGrip(this);
|
|
|
|
mOuter->mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::state,
|
2011-10-17 14:59:28 +00:00
|
|
|
NS_LITERAL_STRING("dragging"), true);
|
1999-09-05 20:46:59 +00:00
|
|
|
|
|
|
|
RemoveListener();
|
2011-10-17 14:59:28 +00:00
|
|
|
mDragging = true;
|
1999-09-05 20:46:59 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
nsSplitterFrameInner::Reverse(nsSplitterInfo*& aChildInfos, PRInt32 aCount)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
|
|
|
nsSplitterInfo* infos = new nsSplitterInfo[aCount];
|
|
|
|
|
|
|
|
for (int i=0; i < aCount; i++)
|
|
|
|
infos[i] = aChildInfos[aCount - 1 - i];
|
|
|
|
|
2000-04-03 03:55:38 +00:00
|
|
|
delete[] aChildInfos;
|
1999-09-05 20:46:59 +00:00
|
|
|
aChildInfos = infos;
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2006-07-19 22:30:33 +00:00
|
|
|
nsSplitterFrameInner::SupportsCollapseDirection
|
|
|
|
(
|
|
|
|
nsSplitterFrameInner::CollapseDirection aDirection
|
|
|
|
)
|
1999-09-14 22:17:19 +00:00
|
|
|
{
|
2006-04-24 05:40:11 +00:00
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2006-12-26 17:47:52 +00:00
|
|
|
{&nsGkAtoms::before, &nsGkAtoms::after, &nsGkAtoms::both, nsnull};
|
2006-07-19 22:30:33 +00:00
|
|
|
|
2006-04-24 05:40:11 +00:00
|
|
|
switch (mOuter->mContent->FindAttrValueIn(kNameSpaceID_None,
|
2006-12-26 17:47:52 +00:00
|
|
|
nsGkAtoms::collapse,
|
2006-04-24 05:40:11 +00:00
|
|
|
strings, eCaseMatters)) {
|
2006-07-19 22:30:33 +00:00
|
|
|
case 0:
|
|
|
|
return (aDirection == Before);
|
|
|
|
case 1:
|
|
|
|
return (aDirection == After);
|
|
|
|
case 2:
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2006-04-24 05:40:11 +00:00
|
|
|
}
|
2005-10-28 11:25:24 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
1999-09-14 22:17:19 +00:00
|
|
|
}
|
|
|
|
|
1999-09-05 20:46:59 +00:00
|
|
|
void
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
nsSplitterFrameInner::UpdateState()
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2000-03-08 00:14:53 +00:00
|
|
|
// State Transitions:
|
2006-07-19 22:30:33 +00:00
|
|
|
// Open -> Dragging
|
|
|
|
// Open -> CollapsedBefore
|
|
|
|
// Open -> CollapsedAfter
|
|
|
|
// CollapsedBefore -> Open
|
|
|
|
// CollapsedBefore -> Dragging
|
|
|
|
// CollapsedAfter -> Open
|
|
|
|
// CollapsedAfter -> Dragging
|
|
|
|
// Dragging -> Open
|
|
|
|
// Dragging -> CollapsedBefore (auto collapse)
|
|
|
|
// Dragging -> CollapsedAfter (auto collapse)
|
1999-09-14 22:17:19 +00:00
|
|
|
|
1999-09-05 20:46:59 +00:00
|
|
|
State newState = GetState();
|
|
|
|
|
2000-03-08 00:14:53 +00:00
|
|
|
if (newState == mState) {
|
|
|
|
// No change.
|
2003-12-21 04:04:05 +00:00
|
|
|
return;
|
2000-03-08 00:14:53 +00:00
|
|
|
}
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2009-04-25 08:33:32 +00:00
|
|
|
if ((SupportsCollapseDirection(Before) || SupportsCollapseDirection(After)) &&
|
|
|
|
mOuter->GetParent()->IsBoxFrame()) {
|
2003-12-21 04:04:05 +00:00
|
|
|
// Find the splitter's immediate sibling.
|
2009-04-25 08:33:32 +00:00
|
|
|
nsIFrame* splitterSibling;
|
|
|
|
if (newState == CollapsedBefore || mState == CollapsedBefore) {
|
2009-10-02 16:27:37 +00:00
|
|
|
splitterSibling = mOuter->GetPrevSibling();
|
2009-04-25 08:33:32 +00:00
|
|
|
} else {
|
|
|
|
splitterSibling = mOuter->GetNextSibling();
|
|
|
|
}
|
|
|
|
|
2009-05-21 02:50:17 +00:00
|
|
|
if (splitterSibling) {
|
2006-09-03 20:25:58 +00:00
|
|
|
nsCOMPtr<nsIContent> sibling = splitterSibling->GetContent();
|
2003-12-21 04:04:05 +00:00
|
|
|
if (sibling) {
|
2006-07-19 22:30:33 +00:00
|
|
|
if (mState == CollapsedBefore || mState == CollapsedAfter) {
|
|
|
|
// CollapsedBefore -> Open
|
|
|
|
// CollapsedBefore -> Dragging
|
|
|
|
// CollapsedAfter -> Open
|
|
|
|
// CollapsedAfter -> Dragging
|
2008-04-14 23:59:21 +00:00
|
|
|
nsContentUtils::AddScriptRunner(
|
|
|
|
new nsUnsetAttrRunnable(sibling, nsGkAtoms::collapsed));
|
2006-07-19 22:30:33 +00:00
|
|
|
} else if ((mState == Open || mState == Dragging)
|
|
|
|
&& (newState == CollapsedBefore ||
|
|
|
|
newState == CollapsedAfter)) {
|
|
|
|
// Open -> CollapsedBefore / CollapsedAfter
|
|
|
|
// Dragging -> CollapsedBefore / CollapsedAfter
|
2008-04-14 23:59:21 +00:00
|
|
|
nsContentUtils::AddScriptRunner(
|
|
|
|
new nsSetAttrRunnable(sibling, nsGkAtoms::collapsed,
|
|
|
|
NS_LITERAL_STRING("true")));
|
2000-03-08 02:33:52 +00:00
|
|
|
}
|
2000-03-08 00:14:53 +00:00
|
|
|
}
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
2003-12-21 04:04:05 +00:00
|
|
|
}
|
|
|
|
mState = newState;
|
2000-03-31 07:02:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSplitterFrameInner::EnsureOrient()
|
|
|
|
{
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isHorizontal = !(mParentBox->GetStateBits() & NS_STATE_IS_HORIZONTAL);
|
2000-03-31 07:02:06 +00:00
|
|
|
if (isHorizontal)
|
2003-12-21 04:04:05 +00:00
|
|
|
mOuter->mState |= NS_STATE_IS_HORIZONTAL;
|
2000-03-31 07:02:06 +00:00
|
|
|
else
|
2003-12-21 04:04:05 +00:00
|
|
|
mOuter->mState &= ~NS_STATE_IS_HORIZONTAL;
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsSplitterFrameInner::AdjustChildren(nsPresContext* aPresContext)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2000-03-31 07:02:06 +00:00
|
|
|
EnsureOrient();
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isHorizontal = !mOuter->IsHorizontal();
|
2000-03-31 07:02:06 +00:00
|
|
|
|
1999-09-05 20:46:59 +00:00
|
|
|
AdjustChildren(aPresContext, mChildInfosBefore, mChildInfosBeforeCount, isHorizontal);
|
|
|
|
AdjustChildren(aPresContext, mChildInfosAfter, mChildInfosAfterCount, isHorizontal);
|
|
|
|
|
2000-10-28 22:17:53 +00:00
|
|
|
// printf("----- Posting Dirty -----\n");
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2009-07-04 09:47:59 +00:00
|
|
|
aPresContext->PresShell()->FlushPendingNotifications(Flush_Display);
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
2005-10-11 18:59:58 +00:00
|
|
|
static nsIBox* GetChildBoxForContent(nsIBox* aParentBox, nsIContent* aContent)
|
|
|
|
{
|
2007-02-22 18:05:14 +00:00
|
|
|
nsIBox* childBox = aParentBox->GetChildBox();
|
2005-10-11 18:59:58 +00:00
|
|
|
|
|
|
|
while (nsnull != childBox) {
|
|
|
|
if (childBox->GetContent() == aContent) {
|
|
|
|
return childBox;
|
|
|
|
}
|
2007-02-22 18:05:14 +00:00
|
|
|
childBox = childBox->GetNextBox();
|
2005-10-11 18:59:58 +00:00
|
|
|
}
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
1999-09-05 20:46:59 +00:00
|
|
|
void
|
2011-09-29 06:19:26 +00:00
|
|
|
nsSplitterFrameInner::AdjustChildren(nsPresContext* aPresContext, nsSplitterInfo* aChildInfos, PRInt32 aCount, bool aIsHorizontal)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2003-12-21 04:04:05 +00:00
|
|
|
///printf("------- AdjustChildren------\n");
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2003-12-21 04:04:05 +00:00
|
|
|
nsBoxLayoutState state(aPresContext);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2007-02-07 07:46:44 +00:00
|
|
|
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2003-12-21 04:04:05 +00:00
|
|
|
// first set all the widths.
|
2007-02-22 18:05:14 +00:00
|
|
|
nsIBox* child = mOuter->GetChildBox();
|
2003-12-21 04:04:05 +00:00
|
|
|
while(child)
|
|
|
|
{
|
|
|
|
SetPreferredSize(state, child, onePixel, aIsHorizontal, nsnull);
|
2007-02-22 18:05:14 +00:00
|
|
|
child = child->GetNextBox();
|
2003-12-21 04:04:05 +00:00
|
|
|
}
|
2000-04-11 23:55:15 +00:00
|
|
|
|
2003-12-21 04:04:05 +00:00
|
|
|
// now set our changed widths.
|
|
|
|
for (int i=0; i < aCount; i++)
|
|
|
|
{
|
|
|
|
nscoord pref = aChildInfos[i].changed;
|
2005-10-11 18:59:58 +00:00
|
|
|
nsIBox* childBox = GetChildBoxForContent(mParentBox, aChildInfos[i].childElem);
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2005-10-11 18:59:58 +00:00
|
|
|
if (childBox) {
|
|
|
|
SetPreferredSize(state, childBox, onePixel, aIsHorizontal, &pref);
|
|
|
|
}
|
2003-12-21 04:04:05 +00:00
|
|
|
}
|
2000-04-11 23:55:15 +00:00
|
|
|
}
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2000-04-11 23:55:15 +00:00
|
|
|
void
|
2011-09-29 06:19:26 +00:00
|
|
|
nsSplitterFrameInner::SetPreferredSize(nsBoxLayoutState& aState, nsIBox* aChildBox, nscoord aOnePixel, bool aIsHorizontal, nscoord* aSize)
|
2000-04-11 23:55:15 +00:00
|
|
|
{
|
2004-09-28 18:37:50 +00:00
|
|
|
nsRect rect(aChildBox->GetRect());
|
2000-04-11 23:55:15 +00:00
|
|
|
nscoord pref = 0;
|
|
|
|
|
|
|
|
if (!aSize)
|
|
|
|
{
|
|
|
|
if (aIsHorizontal)
|
|
|
|
pref = rect.width;
|
|
|
|
else
|
|
|
|
pref = rect.height;
|
|
|
|
} else {
|
|
|
|
pref = *aSize;
|
|
|
|
}
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2000-04-11 23:55:15 +00:00
|
|
|
nsMargin margin(0,0,0,0);
|
|
|
|
aChildBox->GetMargin(margin);
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2000-04-11 23:55:15 +00:00
|
|
|
nsCOMPtr<nsIAtom> attribute;
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2000-04-11 23:55:15 +00:00
|
|
|
if (aIsHorizontal) {
|
2003-12-21 04:04:05 +00:00
|
|
|
pref -= (margin.left + margin.right);
|
2006-12-26 17:47:52 +00:00
|
|
|
attribute = nsGkAtoms::width;
|
2000-04-11 23:55:15 +00:00
|
|
|
} else {
|
2003-12-21 04:04:05 +00:00
|
|
|
pref -= (margin.top + margin.bottom);
|
2006-12-26 17:47:52 +00:00
|
|
|
attribute = nsGkAtoms::height;
|
2000-04-11 23:55:15 +00:00
|
|
|
}
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2004-09-28 18:37:50 +00:00
|
|
|
nsIContent* content = aChildBox->GetContent();
|
2000-04-11 23:55:15 +00:00
|
|
|
|
|
|
|
// set its preferred size.
|
2002-12-31 12:50:10 +00:00
|
|
|
nsAutoString prefValue;
|
|
|
|
prefValue.AppendInt(pref/aOnePixel);
|
2006-01-10 20:00:39 +00:00
|
|
|
if (content->AttrValueIs(kNameSpaceID_None, attribute,
|
|
|
|
prefValue, eCaseMatters))
|
2000-04-11 23:55:15 +00:00
|
|
|
return;
|
|
|
|
|
2006-09-03 20:25:58 +00:00
|
|
|
nsWeakFrame weakBox(aChildBox);
|
2011-10-17 14:59:28 +00:00
|
|
|
content->SetAttr(kNameSpaceID_None, attribute, prefValue, true);
|
2006-09-03 20:25:58 +00:00
|
|
|
ENSURE_TRUE(weakBox.IsAlive());
|
2007-05-06 19:16:51 +00:00
|
|
|
aState.PresShell()->FrameNeedsReflow(aChildBox, nsIPresShell::eStyleChange,
|
|
|
|
NS_FRAME_IS_DIRTY);
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
nsSplitterFrameInner::AddRemoveSpace(nscoord aDiff,
|
1999-09-05 20:46:59 +00:00
|
|
|
nsSplitterInfo* aChildInfos,
|
|
|
|
PRInt32 aCount,
|
|
|
|
PRInt32& aSpaceLeft)
|
|
|
|
{
|
|
|
|
aSpaceLeft = 0;
|
|
|
|
|
|
|
|
for (int i=0; i < aCount; i++) {
|
|
|
|
nscoord min = aChildInfos[i].min;
|
|
|
|
nscoord max = aChildInfos[i].max;
|
|
|
|
nscoord& c = aChildInfos[i].changed;
|
|
|
|
|
|
|
|
// figure our how much space to add or remove
|
|
|
|
if (c + aDiff < min) {
|
2003-12-21 04:04:05 +00:00
|
|
|
aDiff += (c - min);
|
|
|
|
c = min;
|
1999-09-05 20:46:59 +00:00
|
|
|
} else if (c + aDiff > max) {
|
2003-12-21 04:04:05 +00:00
|
|
|
aDiff -= (max - c);
|
|
|
|
c = max;
|
1999-09-05 20:46:59 +00:00
|
|
|
} else {
|
2003-12-21 04:04:05 +00:00
|
|
|
c += aDiff;
|
|
|
|
aDiff = 0;
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// there is not space left? We are done
|
|
|
|
if (aDiff == 0)
|
2003-12-21 04:04:05 +00:00
|
|
|
break;
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
aSpaceLeft = aDiff;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ok if we want to resize a child we will know the actual size in pixels we want it to be.
|
|
|
|
* This is not the preferred size. But they only way we can change a child is my manipulating its
|
|
|
|
* preferred size. So give the actual pixel size this return method will return figure out the preferred
|
|
|
|
* size and set it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsSplitterFrameInner::ResizeChildTo(nsPresContext* aPresContext,
|
1999-10-26 04:44:41 +00:00
|
|
|
nscoord& aDiff,
|
1999-09-05 20:46:59 +00:00
|
|
|
nsSplitterInfo* aChildrenBeforeInfos,
|
|
|
|
nsSplitterInfo* aChildrenAfterInfos,
|
|
|
|
PRInt32 aChildrenBeforeCount,
|
|
|
|
PRInt32 aChildrenAfterCount,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aBounded)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
|
|
|
nscoord spaceLeft;
|
|
|
|
AddRemoveSpace(aDiff, aChildrenBeforeInfos,aChildrenBeforeCount,spaceLeft);
|
|
|
|
|
|
|
|
// if there is any space left over remove it from the dif we were originally given
|
|
|
|
aDiff -= spaceLeft;
|
|
|
|
AddRemoveSpace(-aDiff, aChildrenAfterInfos,aChildrenAfterCount,spaceLeft);
|
|
|
|
|
|
|
|
if (spaceLeft != 0) {
|
|
|
|
if (aBounded) {
|
|
|
|
aDiff += spaceLeft;
|
|
|
|
AddRemoveSpace(spaceLeft, aChildrenBeforeInfos,aChildrenBeforeCount,spaceLeft);
|
|
|
|
} else {
|
|
|
|
spaceLeft = 0;
|
|
|
|
}
|
|
|
|
}
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
}
|