2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
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"
|
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"
|
2014-02-27 23:04:46 +00:00
|
|
|
#include "nsNameSpaceManager.h"
|
1999-06-30 22:17:43 +00:00
|
|
|
#include "nsScrollbarButtonFrame.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 "nsIServiceManager.h"
|
2011-12-27 20:18:48 +00:00
|
|
|
#include "nsContainerFrame.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"
|
2013-09-25 11:21:18 +00:00
|
|
|
#include "mozilla/MouseEvents.h"
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2013-10-02 03:46:03 +00:00
|
|
|
using namespace mozilla;
|
|
|
|
|
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;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t flex;
|
|
|
|
int32_t 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
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
void Disconnect() { mOuter = nullptr; }
|
2007-05-21 07:33:32 +00:00
|
|
|
|
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
|
|
|
|
2013-10-02 03:46:03 +00:00
|
|
|
void MouseDrag(nsPresContext* aPresContext, WidgetGUIEvent* aEvent);
|
|
|
|
void MouseUp(nsPresContext* aPresContext, WidgetGUIEvent* aEvent);
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
void AdjustChildren(nsPresContext* aPresContext);
|
2012-08-22 15:56:38 +00:00
|
|
|
void AdjustChildren(nsPresContext* aPresContext, nsSplitterInfo* aChildInfos, int32_t aCount, bool aIsHorizontal);
|
1999-09-05 20:46:59 +00:00
|
|
|
|
|
|
|
void AddRemoveSpace(nscoord aDiff,
|
|
|
|
nsSplitterInfo* aChildInfos,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aCount,
|
|
|
|
int32_t& aSpaceLeft);
|
1999-09-05 20:46:59 +00:00
|
|
|
|
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,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aChildrenBeforeCount,
|
|
|
|
int32_t 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();
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
void Reverse(nsSplitterInfo*& aIndexes, int32_t 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();
|
2012-08-06 03:00:57 +00:00
|
|
|
void SetPreferredSize(nsBoxLayoutState& aState, nsIFrame* 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;
|
2012-08-06 03:00:57 +00:00
|
|
|
nsIFrame* mParentBox;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mPressed;
|
1999-09-05 20:46:59 +00:00
|
|
|
nsSplitterInfo* mChildInfosBefore;
|
|
|
|
nsSplitterInfo* mChildInfosAfter;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t mChildInfosBeforeCount;
|
|
|
|
int32_t mChildInfosAfterCount;
|
1999-09-05 20:46:59 +00:00
|
|
|
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[] =
|
2012-07-30 14:20:58 +00:00
|
|
|
{&nsGkAtoms::farthest, &nsGkAtoms::flex, nullptr};
|
2007-11-15 03:38:16 +00:00
|
|
|
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[] =
|
2012-07-30 14:20:58 +00:00
|
|
|
{&nsGkAtoms::farthest, &nsGkAtoms::flex, &nsGkAtoms::grow, nullptr};
|
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[] =
|
2012-07-30 14:20:58 +00:00
|
|
|
{&nsGkAtoms::dragging, &nsGkAtoms::collapsed, nullptr};
|
2006-07-19 22:30:33 +00:00
|
|
|
static nsIContent::AttrValuesArray strings_substate[] =
|
2012-07-30 14:20:58 +00:00
|
|
|
{&nsGkAtoms::before, &nsGkAtoms::after, nullptr};
|
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();
|
2012-07-30 14:20:58 +00:00
|
|
|
mInner = nullptr;
|
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
|
|
|
|
2014-02-18 07:47:48 +00:00
|
|
|
nsresult
|
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
|
|
|
}
|
|
|
|
|
2014-02-18 07:47:48 +00:00
|
|
|
nsresult
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSplitterFrame::AttributeChanged(int32_t aNameSpaceID,
|
2003-07-11 21:16:12 +00:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t 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
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIFrame* grippy = nullptr;
|
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
|
|
|
|
*/
|
2013-03-20 01:47:48 +00:00
|
|
|
void
|
2006-03-09 18:55:21 +00:00
|
|
|
nsSplitterFrame::Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
1999-06-30 22:17:43 +00:00
|
|
|
{
|
2013-03-20 01:47:48 +00:00
|
|
|
MOZ_ASSERT(!mInner);
|
2003-12-21 04:04:05 +00:00
|
|
|
mInner = new nsSplitterFrameInner(this);
|
|
|
|
|
|
|
|
mInner->AddRef();
|
2012-07-30 14:20:58 +00:00
|
|
|
mInner->mChildInfosAfter = nullptr;
|
|
|
|
mInner->mChildInfosBefore = nullptr;
|
2003-12-21 04:04:05 +00:00
|
|
|
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);
|
2013-02-16 05:38:33 +00:00
|
|
|
nsStyleContext* parentStyleContext = StyleContext()->GetParent();
|
2007-10-04 02:58:48 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-20 01:47:48 +00:00
|
|
|
nsBoxFrame::Init(aContent, aParent, aPrevInFlow);
|
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());
|
2012-07-30 14:20:58 +00:00
|
|
|
mInner->mParentBox = nullptr;
|
1999-06-30 22:17:43 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2012-08-06 03:00:57 +00:00
|
|
|
nsIFrame* 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,
|
2013-10-02 03:46:03 +00:00
|
|
|
WidgetGUIEvent* aEvent,
|
|
|
|
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,
|
2013-10-02 03:46:03 +00:00
|
|
|
WidgetGUIEvent* 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,
|
2013-10-02 03:46:03 +00:00
|
|
|
WidgetGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus)
|
2011-08-03 03:39:02 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSplitterFrame::HandleRelease(nsPresContext* aPresContext,
|
2013-10-02 03:46:03 +00:00
|
|
|
WidgetGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus)
|
2011-08-03 03:39:02 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-02-14 11:12:27 +00:00
|
|
|
void
|
2006-01-26 02:29:17 +00:00
|
|
|
nsSplitterFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
2005-09-19 02:15:54 +00:00
|
|
|
{
|
2013-02-14 11:08:08 +00:00
|
|
|
nsBoxFrame::BuildDisplayList(aBuilder, aDirtyRect, aLists);
|
2006-01-26 02:29:17 +00:00
|
|
|
|
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?
|
2013-02-14 11:08:08 +00:00
|
|
|
aLists.Outlines()->AppendNewToTop(new (aBuilder)
|
|
|
|
nsDisplayEventReceiver(aBuilder, this));
|
2013-02-14 11:12:27 +00:00
|
|
|
return;
|
2003-11-15 00:47:43 +00:00
|
|
|
}
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
2014-02-18 07:47:48 +00:00
|
|
|
nsresult
|
2013-10-02 03:46:03 +00:00
|
|
|
nsSplitterFrame::HandleEvent(nsPresContext* aPresContext,
|
|
|
|
WidgetGUIEvent* aEvent,
|
|
|
|
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:
|
2013-10-22 08:55:20 +00:00
|
|
|
if (aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) {
|
2006-11-16 21:35:39 +00:00
|
|
|
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
|
2013-10-02 03:46:03 +00:00
|
|
|
nsSplitterFrameInner::MouseUp(nsPresContext* aPresContext,
|
|
|
|
WidgetGUIEvent* 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);
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIPresShell::SetCapturingContent(nullptr, 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;
|
2012-07-30 14:20:58 +00:00
|
|
|
mChildInfosBefore = nullptr;
|
|
|
|
mChildInfosAfter = nullptr;
|
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
|
2013-10-02 03:46:03 +00:00
|
|
|
nsSplitterFrameInner::MouseDrag(nsPresContext* aPresContext,
|
|
|
|
WidgetGUIEvent* 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
|
|
|
|
2013-02-16 21:51:02 +00:00
|
|
|
const bool isRTL = mOuter->StyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL;
|
2011-09-29 06:19:26 +00:00
|
|
|
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
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIPresShell::SetCapturingContent(nullptr, 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
|
|
|
|
2014-02-20 18:38:13 +00:00
|
|
|
int16_t button = 0;
|
2000-05-15 22:43:47 +00:00
|
|
|
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());
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t childIndex = siblingList.IndexOf(mOuter);
|
2009-04-25 08:33:32 +00:00
|
|
|
// 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
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t 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 =
|
2014-04-15 04:30:25 +00:00
|
|
|
outerPresContext->PresShell()->CreateReferenceRenderingContext();
|
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.
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t count = 0;
|
1999-09-05 20:46:59 +00:00
|
|
|
mChildInfosBeforeCount = 0;
|
|
|
|
mChildInfosAfterCount = 0;
|
|
|
|
|
2012-08-06 03:00:57 +00:00
|
|
|
nsIFrame* childBox = mParentBox->GetChildBox();
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
while (nullptr != 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();
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t dummy;
|
2011-10-18 11:19:44 +00:00
|
|
|
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;
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t c;
|
2005-08-23 03:57:07 +00:00
|
|
|
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
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSplitterFrameInner::Reverse(nsSplitterInfo*& aChildInfos, int32_t 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[] =
|
2012-07-30 14:20:58 +00:00
|
|
|
{&nsGkAtoms::before, &nsGkAtoms::after, &nsGkAtoms::both, nullptr};
|
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);
|
|
|
|
}
|
|
|
|
|
2012-08-06 03:00:57 +00:00
|
|
|
static nsIFrame* GetChildBoxForContent(nsIFrame* aParentBox, nsIContent* aContent)
|
2005-10-11 18:59:58 +00:00
|
|
|
{
|
2012-08-06 03:00:57 +00:00
|
|
|
nsIFrame* childBox = aParentBox->GetChildBox();
|
2005-10-11 18:59:58 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
while (nullptr != childBox) {
|
2005-10-11 18:59:58 +00:00
|
|
|
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
|
|
|
}
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2005-10-11 18:59:58 +00:00
|
|
|
}
|
|
|
|
|
1999-09-05 20:46:59 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSplitterFrameInner::AdjustChildren(nsPresContext* aPresContext, nsSplitterInfo* aChildInfos, int32_t 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.
|
2012-08-06 03:00:57 +00:00
|
|
|
nsIFrame* child = mOuter->GetChildBox();
|
2003-12-21 04:04:05 +00:00
|
|
|
while(child)
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
SetPreferredSize(state, child, onePixel, aIsHorizontal, nullptr);
|
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;
|
2012-08-06 03:00:57 +00:00
|
|
|
nsIFrame* 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
|
2012-08-06 03:00:57 +00:00
|
|
|
nsSplitterFrameInner::SetPreferredSize(nsBoxLayoutState& aState, nsIFrame* 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,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aCount,
|
|
|
|
int32_t& aSpaceLeft)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
|
|
|
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,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aChildrenBeforeCount,
|
|
|
|
int32_t 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
|
|
|
}
|