2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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-07-01 02:17:43 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
// Eric Vaughan
|
|
|
|
// Netscape Communications
|
|
|
|
//
|
|
|
|
// See documentation in associated header file
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "nsSplitterFrame.h"
|
2006-12-26 20:47:52 +03:00
|
|
|
#include "nsGkAtoms.h"
|
1999-07-01 02:17:43 +04:00
|
|
|
#include "nsIDOMElement.h"
|
2003-10-21 15:43:40 +04:00
|
|
|
#include "nsIDOMXULElement.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2011-04-08 05:04:40 +04:00
|
|
|
#include "nsRenderingContext.h"
|
2000-12-30 22:22:22 +03:00
|
|
|
#include "nsIDocument.h"
|
2014-02-28 03:04:46 +04:00
|
|
|
#include "nsNameSpaceManager.h"
|
1999-07-01 02:17:43 +04:00
|
|
|
#include "nsScrollbarButtonFrame.h"
|
2011-06-28 21:59:14 +04:00
|
|
|
#include "nsIDOMEventListener.h"
|
1999-11-03 10:11:45 +03:00
|
|
|
#include "nsIDOMMouseEvent.h"
|
1999-09-06 00:46:59 +04:00
|
|
|
#include "nsIPresShell.h"
|
2009-04-25 12:33:32 +04:00
|
|
|
#include "nsFrameList.h"
|
1999-09-06 00:46:59 +04:00
|
|
|
#include "nsHTMLParts.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.h"
|
2000-03-31 11:02:06 +04:00
|
|
|
#include "nsBoxLayoutState.h"
|
2000-05-10 01:42:40 +04:00
|
|
|
#include "nsIServiceManager.h"
|
2011-12-28 00:18:48 +04:00
|
|
|
#include "nsContainerFrame.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2001-02-20 00:50:04 +03:00
|
|
|
#include "nsContentCID.h"
|
2004-01-28 03:18:22 +03:00
|
|
|
#include "nsStyleSet.h"
|
2005-08-23 07:57:07 +04:00
|
|
|
#include "nsLayoutUtils.h"
|
2006-01-26 05:29:17 +03:00
|
|
|
#include "nsDisplayList.h"
|
2006-04-24 09:40:11 +04:00
|
|
|
#include "nsContentUtils.h"
|
2011-07-20 23:18:54 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
2013-09-25 15:21:18 +04:00
|
|
|
#include "mozilla/MouseEvents.h"
|
1999-09-06 00:46:59 +04:00
|
|
|
|
2013-10-02 07:46:03 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
|
1999-09-06 00:46:59 +04:00
|
|
|
class nsSplitterInfo {
|
|
|
|
public:
|
2003-12-21 07:04:05 +03:00
|
|
|
nscoord min;
|
|
|
|
nscoord max;
|
|
|
|
nscoord current;
|
|
|
|
nscoord changed;
|
2005-10-11 22:59:58 +04:00
|
|
|
nsCOMPtr<nsIContent> childElem;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t flex;
|
|
|
|
int32_t index;
|
1999-09-06 00:46:59 +04:00
|
|
|
};
|
|
|
|
|
2011-06-28 21:59:14 +04:00
|
|
|
class nsSplitterFrameInner : public nsIDOMEventListener
|
|
|
|
{
|
1999-09-06 00:46:59 +04:00
|
|
|
public:
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
2011-06-28 21:59:14 +04:00
|
|
|
NS_DECL_NSIDOMEVENTLISTENER
|
1999-09-06 00:46:59 +04: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-10 01:02:40 +03:00
|
|
|
nsSplitterFrameInner(nsSplitterFrame* aSplitter)
|
1999-09-06 00:46:59 +04: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-10 01:02:40 +03:00
|
|
|
mOuter = aSplitter;
|
2011-10-17 18:59:28 +04:00
|
|
|
mPressed = false;
|
1999-09-06 00:46:59 +04:00
|
|
|
}
|
2000-04-03 07:55:38 +04:00
|
|
|
virtual ~nsSplitterFrameInner();
|
1999-09-06 00:46:59 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
void Disconnect() { mOuter = nullptr; }
|
2007-05-21 11:33:32 +04:00
|
|
|
|
2011-06-28 21:59:14 +04:00
|
|
|
nsresult MouseDown(nsIDOMEvent* aMouseEvent);
|
|
|
|
nsresult MouseUp(nsIDOMEvent* aMouseEvent);
|
|
|
|
nsresult MouseMove(nsIDOMEvent* aMouseEvent);
|
1999-09-06 00:46:59 +04:00
|
|
|
|
2013-10-02 07:46:03 +04:00
|
|
|
void MouseDrag(nsPresContext* aPresContext, WidgetGUIEvent* aEvent);
|
|
|
|
void MouseUp(nsPresContext* aPresContext, WidgetGUIEvent* aEvent);
|
1999-09-06 00:46:59 +04:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
void AdjustChildren(nsPresContext* aPresContext);
|
2012-08-22 19:56:38 +04:00
|
|
|
void AdjustChildren(nsPresContext* aPresContext, nsSplitterInfo* aChildInfos, int32_t aCount, bool aIsHorizontal);
|
1999-09-06 00:46:59 +04:00
|
|
|
|
|
|
|
void AddRemoveSpace(nscoord aDiff,
|
|
|
|
nsSplitterInfo* aChildInfos,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aCount,
|
|
|
|
int32_t& aSpaceLeft);
|
1999-09-06 00:46:59 +04:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
void ResizeChildTo(nsPresContext* aPresContext,
|
1999-10-26 08:44:41 +04:00
|
|
|
nscoord& aDiff,
|
1999-09-06 00:46:59 +04:00
|
|
|
nsSplitterInfo* aChildrenBeforeInfos,
|
|
|
|
nsSplitterInfo* aChildrenAfterInfos,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aChildrenBeforeCount,
|
|
|
|
int32_t aChildrenAfterCount,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aBounded);
|
1999-09-06 00:46:59 +04:00
|
|
|
|
|
|
|
void UpdateState();
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
void AddListener(nsPresContext* aPresContext);
|
1999-09-06 00:46:59 +04:00
|
|
|
void RemoveListener();
|
|
|
|
|
2007-11-15 06:38:16 +03:00
|
|
|
enum ResizeType { Closest, Farthest, Flex, Grow };
|
2006-07-20 02:30:33 +04:00
|
|
|
enum State { Open, CollapsedBefore, CollapsedAfter, Dragging };
|
|
|
|
enum CollapseDirection { Before, After };
|
1999-09-06 00:46:59 +04:00
|
|
|
|
|
|
|
ResizeType GetResizeBefore();
|
|
|
|
ResizeType GetResizeAfter();
|
|
|
|
State GetState();
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void Reverse(nsSplitterInfo*& aIndexes, int32_t aCount);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool SupportsCollapseDirection(CollapseDirection aDirection);
|
1999-09-06 00:46:59 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
void EnsureOrient();
|
2012-08-06 07:00:57 +04: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-10 01:02:40 +03:00
|
|
|
|
|
|
|
nsSplitterFrame* mOuter;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mDidDrag;
|
2005-08-23 07:57:07 +04:00
|
|
|
nscoord mDragStart;
|
1999-09-06 00:46:59 +04:00
|
|
|
nscoord mCurrentPos;
|
2012-08-06 07:00:57 +04:00
|
|
|
nsIFrame* mParentBox;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mPressed;
|
1999-09-06 00:46:59 +04:00
|
|
|
nsSplitterInfo* mChildInfosBefore;
|
|
|
|
nsSplitterInfo* mChildInfosAfter;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mChildInfosBeforeCount;
|
|
|
|
int32_t mChildInfosAfterCount;
|
1999-09-06 00:46:59 +04:00
|
|
|
State mState;
|
|
|
|
nscoord mSplitterPos;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mDragging;
|
2000-03-31 11:02:06 +04:00
|
|
|
|
1999-09-06 00:46:59 +04:00
|
|
|
};
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(nsSplitterFrameInner, nsIDOMEventListener)
|
1999-09-06 00:46:59 +04: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-10 01:02:40 +03:00
|
|
|
nsSplitterFrameInner::ResizeType
|
|
|
|
nsSplitterFrameInner::GetResizeBefore()
|
1999-09-06 00:46:59 +04:00
|
|
|
{
|
2007-11-15 06:38:16 +03:00
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2012-07-30 18:20:58 +04:00
|
|
|
{&nsGkAtoms::farthest, &nsGkAtoms::flex, nullptr};
|
2007-11-15 06:38:16 +03:00
|
|
|
switch (mOuter->GetContent()->FindAttrValueIn(kNameSpaceID_None,
|
|
|
|
nsGkAtoms::resizebefore,
|
|
|
|
strings, eCaseMatters)) {
|
|
|
|
case 0: return Farthest;
|
|
|
|
case 1: return Flex;
|
|
|
|
}
|
2003-12-21 07:04:05 +03:00
|
|
|
return Closest;
|
1999-09-06 00:46:59 +04:00
|
|
|
}
|
|
|
|
|
2000-04-03 07:55:38 +04: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-10 01:02:40 +03:00
|
|
|
nsSplitterFrameInner::ResizeType
|
|
|
|
nsSplitterFrameInner::GetResizeAfter()
|
1999-09-06 00:46:59 +04:00
|
|
|
{
|
2006-04-24 09:40:11 +04:00
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2012-07-30 18:20:58 +04:00
|
|
|
{&nsGkAtoms::farthest, &nsGkAtoms::flex, &nsGkAtoms::grow, nullptr};
|
2006-04-24 09:40:11 +04:00
|
|
|
switch (mOuter->GetContent()->FindAttrValueIn(kNameSpaceID_None,
|
2006-12-26 20:47:52 +03:00
|
|
|
nsGkAtoms::resizeafter,
|
2006-04-24 09:40:11 +04:00
|
|
|
strings, eCaseMatters)) {
|
|
|
|
case 0: return Farthest;
|
2007-11-15 06:38:16 +03:00
|
|
|
case 1: return Flex;
|
|
|
|
case 2: return Grow;
|
2006-04-24 09:40:11 +04:00
|
|
|
}
|
2003-12-21 07:04:05 +03:00
|
|
|
return Closest;
|
1999-09-06 00:46:59 +04: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-10 01:02:40 +03:00
|
|
|
nsSplitterFrameInner::State
|
|
|
|
nsSplitterFrameInner::GetState()
|
1999-09-06 00:46:59 +04:00
|
|
|
{
|
2006-04-24 09:40:11 +04:00
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2012-07-30 18:20:58 +04:00
|
|
|
{&nsGkAtoms::dragging, &nsGkAtoms::collapsed, nullptr};
|
2006-07-20 02:30:33 +04:00
|
|
|
static nsIContent::AttrValuesArray strings_substate[] =
|
2012-07-30 18:20:58 +04:00
|
|
|
{&nsGkAtoms::before, &nsGkAtoms::after, nullptr};
|
2006-04-24 09:40:11 +04:00
|
|
|
switch (mOuter->GetContent()->FindAttrValueIn(kNameSpaceID_None,
|
2006-12-26 20:47:52 +03:00
|
|
|
nsGkAtoms::state,
|
2006-04-24 09:40:11 +04:00
|
|
|
strings, eCaseMatters)) {
|
|
|
|
case 0: return Dragging;
|
2006-07-20 02:30:33 +04:00
|
|
|
case 1:
|
|
|
|
switch (mOuter->GetContent()->FindAttrValueIn(kNameSpaceID_None,
|
2006-12-26 20:47:52 +03:00
|
|
|
nsGkAtoms::substate,
|
2006-07-20 02:30:33 +04:00
|
|
|
strings_substate,
|
|
|
|
eCaseMatters)) {
|
|
|
|
case 0: return CollapsedBefore;
|
|
|
|
case 1: return CollapsedAfter;
|
|
|
|
default:
|
|
|
|
if (SupportsCollapseDirection(After))
|
|
|
|
return CollapsedAfter;
|
|
|
|
return CollapsedBefore;
|
|
|
|
}
|
2006-04-24 09:40:11 +04:00
|
|
|
}
|
2003-12-21 07:04:05 +03:00
|
|
|
return Open;
|
1999-09-06 00:46:59 +04:00
|
|
|
}
|
1999-07-01 02:17:43 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
// NS_NewSplitterFrame
|
|
|
|
//
|
2005-10-27 01:46:39 +04:00
|
|
|
// Creates a new Toolbar frame and returns it
|
1999-07-01 02:17:43 +04:00
|
|
|
//
|
2005-10-27 01:46:39 +04:00
|
|
|
nsIFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewSplitterFrame (nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1999-07-01 02:17:43 +04:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
return new (aPresShell) nsSplitterFrame(aPresShell, aContext);
|
2009-09-12 20:49:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsSplitterFrame)
|
1999-07-01 02:17:43 +04:00
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
nsSplitterFrame::nsSplitterFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
|
|
: nsBoxFrame(aPresShell, aContext),
|
2003-12-21 07:04:05 +03:00
|
|
|
mInner(0)
|
1999-09-06 00:46:59 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-05-21 11:33:32 +04:00
|
|
|
void
|
2009-12-24 08:21:15 +03:00
|
|
|
nsSplitterFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
1999-09-06 00:46:59 +04:00
|
|
|
{
|
2003-12-21 07:04:05 +03:00
|
|
|
if (mInner) {
|
|
|
|
mInner->RemoveListener();
|
2007-05-21 11:33:32 +04:00
|
|
|
mInner->Disconnect();
|
2003-12-21 07:04:05 +03:00
|
|
|
mInner->Release();
|
2012-07-30 18:20:58 +04:00
|
|
|
mInner = nullptr;
|
2003-12-21 07:04:05 +03:00
|
|
|
}
|
2009-12-24 08:21:15 +03:00
|
|
|
nsBoxFrame::DestroyFrom(aDestructRoot);
|
1999-09-06 00:46:59 +04:00
|
|
|
}
|
|
|
|
|
2000-05-26 10:42:29 +04:00
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2004-12-31 00:56:11 +03:00
|
|
|
nsSplitterFrame::GetCursor(const nsPoint& aPoint,
|
|
|
|
nsIFrame::Cursor& aCursor)
|
1999-09-15 02:17:19 +04:00
|
|
|
{
|
2004-12-31 00:56:11 +03:00
|
|
|
return nsBoxFrame::GetCursor(aPoint, aCursor);
|
2000-01-19 02:14:25 +03:00
|
|
|
|
2003-12-21 07:04:05 +03:00
|
|
|
/*
|
|
|
|
if (IsHorizontal())
|
1999-09-15 02:17:19 +04:00
|
|
|
aCursor = NS_STYLE_CURSOR_N_RESIZE;
|
2003-12-21 07:04:05 +03:00
|
|
|
else
|
1999-09-15 02:17:19 +04:00
|
|
|
aCursor = NS_STYLE_CURSOR_W_RESIZE;
|
2003-12-21 07:04:05 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
*/
|
1999-09-15 02:17:19 +04:00
|
|
|
}
|
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSplitterFrame::AttributeChanged(int32_t aNameSpaceID,
|
2003-07-12 01:16:12 +04:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aModType)
|
1999-07-01 02:17:43 +04:00
|
|
|
{
|
2005-09-07 20:49:21 +04:00
|
|
|
nsresult rv = nsBoxFrame::AttributeChanged(aNameSpaceID, aAttribute,
|
|
|
|
aModType);
|
1999-07-01 02:17:43 +04:00
|
|
|
// if the alignment changed. Let the grippy know
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::align) {
|
2003-12-21 07:04:05 +03:00
|
|
|
// tell the slider its attribute changed so it can
|
|
|
|
// update itself
|
2012-07-30 18:20:58 +04:00
|
|
|
nsIFrame* grippy = nullptr;
|
2007-03-31 01:11:41 +04:00
|
|
|
nsScrollbarButtonFrame::GetChildWithTag(PresContext(), nsGkAtoms::grippy, this, grippy);
|
2003-12-21 07:04:05 +03:00
|
|
|
if (grippy)
|
2005-09-07 20:49:21 +04:00
|
|
|
grippy->AttributeChanged(aNameSpaceID, aAttribute, aModType);
|
2006-12-26 20:47:52 +03:00
|
|
|
} else if (aAttribute == nsGkAtoms::state) {
|
2003-12-21 07:04:05 +03:00
|
|
|
mInner->UpdateState();
|
1999-07-01 02:17:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize us. If we are in a box get our alignment so we know what direction we are
|
|
|
|
*/
|
2013-03-20 05:47:48 +04:00
|
|
|
void
|
2014-05-25 02:20:40 +04:00
|
|
|
nsSplitterFrame::Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
1999-07-01 02:17:43 +04:00
|
|
|
{
|
2013-03-20 05:47:48 +04:00
|
|
|
MOZ_ASSERT(!mInner);
|
2003-12-21 07:04:05 +03:00
|
|
|
mInner = new nsSplitterFrameInner(this);
|
|
|
|
|
|
|
|
mInner->AddRef();
|
2012-07-30 18:20:58 +04:00
|
|
|
mInner->mChildInfosAfter = nullptr;
|
|
|
|
mInner->mChildInfosBefore = nullptr;
|
2003-12-21 07:04:05 +03:00
|
|
|
mInner->mState = nsSplitterFrameInner::Open;
|
2011-10-17 18:59:28 +04:00
|
|
|
mInner->mDragging = false;
|
2004-10-28 11:25:57 +04:00
|
|
|
|
2001-10-26 04:09:12 +04:00
|
|
|
// determine orientation of parent, and if vertical, set orient to vertical
|
|
|
|
// on splitter content, then re-resolve style
|
2007-10-04 06:58:48 +04: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 22:37:50 +04:00
|
|
|
if (aParent && aParent->IsBoxFrame()) {
|
2007-01-31 19:02:42 +03:00
|
|
|
if (!aParent->IsHorizontal()) {
|
2006-04-24 09:40:11 +04:00
|
|
|
if (!nsContentUtils::HasNonEmptyAttr(aContent, kNameSpaceID_None,
|
2006-12-26 20:47:52 +03:00
|
|
|
nsGkAtoms::orient)) {
|
|
|
|
aContent->SetAttr(kNameSpaceID_None, nsGkAtoms::orient,
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_LITERAL_STRING("vertical"), false);
|
2013-02-16 09:38:33 +04:00
|
|
|
nsStyleContext* parentStyleContext = StyleContext()->GetParent();
|
2007-10-04 06:58:48 +04:00
|
|
|
nsRefPtr<nsStyleContext> newContext = PresContext()->StyleSet()->
|
2010-04-30 17:12:06 +04:00
|
|
|
ResolveStyleFor(aContent->AsElement(), parentStyleContext);
|
2006-03-27 01:30:36 +04:00
|
|
|
SetStyleContextWithoutNotification(newContext);
|
2001-10-26 04:09:12 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-20 05:47:48 +04:00
|
|
|
nsBoxFrame::Init(aContent, aParent, aPrevInFlow);
|
1999-07-01 02:17:43 +04: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-10 01:02:40 +03:00
|
|
|
mInner->mState = nsSplitterFrameInner::Open;
|
2007-03-31 01:11:41 +04:00
|
|
|
mInner->AddListener(PresContext());
|
2012-07-30 18:20:58 +04:00
|
|
|
mInner->mParentBox = nullptr;
|
1999-07-01 02:17:43 +04:00
|
|
|
}
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
NS_IMETHODIMP
|
2000-07-08 02:24:06 +04:00
|
|
|
nsSplitterFrame::DoLayout(nsBoxLayoutState& aState)
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
2004-09-28 22:37:50 +04:00
|
|
|
if (GetStateBits() & NS_FRAME_FIRST_REFLOW)
|
2000-05-26 10:42:29 +04:00
|
|
|
{
|
2007-02-22 21:05:14 +03:00
|
|
|
mInner->mParentBox = GetParentBox();
|
2000-03-31 11:02:06 +04:00
|
|
|
mInner->UpdateState();
|
|
|
|
}
|
2000-05-26 10:42:29 +04:00
|
|
|
|
2000-07-08 02:24:06 +04:00
|
|
|
return nsBoxFrame::DoLayout(aState);
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2001-03-08 03:47:22 +03:00
|
|
|
|
|
|
|
void
|
2011-09-29 10:19:26 +04:00
|
|
|
nsSplitterFrame::GetInitialOrientation(bool& aIsHorizontal)
|
2001-03-08 03:47:22 +03:00
|
|
|
{
|
2012-08-06 07:00:57 +04:00
|
|
|
nsIFrame* box = GetParentBox();
|
2001-03-08 03:47:22 +03:00
|
|
|
if (box) {
|
2007-01-31 19:02:42 +03:00
|
|
|
aIsHorizontal = !box->IsHorizontal();
|
2001-03-08 03:47:22 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
nsBoxFrame::GetInitialOrientation(aIsHorizontal);
|
|
|
|
}
|
|
|
|
|
1999-09-06 00:46:59 +04:00
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsSplitterFrame::HandlePress(nsPresContext* aPresContext,
|
2013-10-02 07:46:03 +04:00
|
|
|
WidgetGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus)
|
1999-09-06 00:46:59 +04:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsSplitterFrame::HandleMultiplePress(nsPresContext* aPresContext,
|
2013-10-02 07:46:03 +04:00
|
|
|
WidgetGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aControlHeld)
|
1999-09-06 00:46:59 +04:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-08-03 07:39:02 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSplitterFrame::HandleDrag(nsPresContext* aPresContext,
|
2013-10-02 07:46:03 +04:00
|
|
|
WidgetGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus)
|
2011-08-03 07:39:02 +04:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSplitterFrame::HandleRelease(nsPresContext* aPresContext,
|
2013-10-02 07:46:03 +04:00
|
|
|
WidgetGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus)
|
2011-08-03 07:39:02 +04:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
void
|
2006-01-26 05:29:17 +03:00
|
|
|
nsSplitterFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
2005-09-19 06:15:54 +04:00
|
|
|
{
|
2013-02-14 15:08:08 +04:00
|
|
|
nsBoxFrame::BuildDisplayList(aBuilder, aDirtyRect, aLists);
|
2006-01-26 05:29:17 +03:00
|
|
|
|
1999-09-06 00:46:59 +04:00
|
|
|
// if the mouse is captured always return us as the frame.
|
2000-08-31 01:51:02 +04:00
|
|
|
if (mInner->mDragging)
|
1999-09-06 00:46:59 +04:00
|
|
|
{
|
2000-03-22 05:43:08 +03:00
|
|
|
// XXX It's probably better not to check visibility here, right?
|
2013-02-14 15:08:08 +04:00
|
|
|
aLists.Outlines()->AppendNewToTop(new (aBuilder)
|
|
|
|
nsDisplayEventReceiver(aBuilder, this));
|
2013-02-14 15:12:27 +04:00
|
|
|
return;
|
2003-11-15 03:47:43 +03:00
|
|
|
}
|
1999-09-06 00:46:59 +04:00
|
|
|
}
|
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2013-10-02 07:46:03 +04:00
|
|
|
nsSplitterFrame::HandleEvent(nsPresContext* aPresContext,
|
|
|
|
WidgetGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus)
|
1999-09-06 00:46:59 +04:00
|
|
|
{
|
2009-02-27 13:48:25 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(aEventStatus);
|
|
|
|
if (nsEventStatus_eConsumeNoDefault == *aEventStatus) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-10-02 10:50:34 +04:00
|
|
|
nsWeakFrame weakFrame(this);
|
|
|
|
nsRefPtr<nsSplitterFrameInner> kungFuDeathGrip(mInner);
|
2003-12-21 07:04:05 +03:00
|
|
|
switch (aEvent->message) {
|
1999-09-06 00:46:59 +04:00
|
|
|
case NS_MOUSE_MOVE:
|
2003-12-21 07:04:05 +03:00
|
|
|
mInner->MouseDrag(aPresContext, aEvent);
|
1999-09-06 00:46:59 +04:00
|
|
|
break;
|
|
|
|
|
2006-11-17 00:35:39 +03:00
|
|
|
case NS_MOUSE_BUTTON_UP:
|
2013-10-22 12:55:20 +04:00
|
|
|
if (aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) {
|
2006-11-17 00:35:39 +03:00
|
|
|
mInner->MouseUp(aPresContext, aEvent);
|
|
|
|
}
|
1999-09-06 00:46:59 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-10-02 10:50:34 +04:00
|
|
|
NS_ENSURE_STATE(weakFrame.IsAlive());
|
2000-08-31 01:51:02 +04:00
|
|
|
return nsBoxFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
1999-09-06 00:46:59 +04:00
|
|
|
}
|
|
|
|
|
1999-09-09 03:51:02 +04:00
|
|
|
void
|
2013-10-02 07:46:03 +04:00
|
|
|
nsSplitterFrameInner::MouseUp(nsPresContext* aPresContext,
|
|
|
|
WidgetGUIEvent* aEvent)
|
1999-09-09 03:51:02 +04:00
|
|
|
{
|
2007-05-21 11:33:32 +04:00
|
|
|
if (mDragging && mOuter) {
|
2003-12-21 07:04:05 +03:00
|
|
|
AdjustChildren(aPresContext);
|
|
|
|
AddListener(aPresContext);
|
2012-07-30 18:20:58 +04:00
|
|
|
nsIPresShell::SetCapturingContent(nullptr, 0); // XXXndeakin is this needed?
|
2011-10-17 18:59:28 +04:00
|
|
|
mDragging = false;
|
2003-12-21 07:04:05 +03:00
|
|
|
State newState = GetState();
|
|
|
|
// if the state is dragging then make it Open.
|
|
|
|
if (newState == Dragging)
|
2011-10-17 18:59:28 +04:00
|
|
|
mOuter->mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::state, EmptyString(), true);
|
2003-10-21 15:43:40 +04:00
|
|
|
|
2011-10-17 18:59:28 +04: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-10 01:02:40 +03:00
|
|
|
|
2003-12-21 07:04:05 +03: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 22:59:58 +04:00
|
|
|
|
|
|
|
delete[] mChildInfosBefore;
|
|
|
|
delete[] mChildInfosAfter;
|
2012-07-30 18:20:58 +04:00
|
|
|
mChildInfosBefore = nullptr;
|
|
|
|
mChildInfosAfter = nullptr;
|
2008-09-17 18:38:33 +04:00
|
|
|
mChildInfosBeforeCount = 0;
|
|
|
|
mChildInfosAfterCount = 0;
|
1999-09-09 03:51:02 +04:00
|
|
|
}
|
|
|
|
|
1999-09-06 00:46:59 +04:00
|
|
|
void
|
2013-10-02 07:46:03 +04:00
|
|
|
nsSplitterFrameInner::MouseDrag(nsPresContext* aPresContext,
|
|
|
|
WidgetGUIEvent* aEvent)
|
1999-09-06 00:46:59 +04:00
|
|
|
{
|
2007-05-21 11:33:32 +04:00
|
|
|
if (mDragging && mOuter) {
|
1999-09-15 02:17:19 +04:00
|
|
|
|
2003-12-21 07:04:05 +03: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-10 01:02:40 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isHorizontal = !mOuter->IsHorizontal();
|
2003-12-21 07:04:05 +03:00
|
|
|
// convert coord to pixels
|
2005-08-24 00:48:56 +04:00
|
|
|
nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent,
|
|
|
|
mParentBox);
|
2005-08-23 07:57:07 +04:00
|
|
|
nscoord pos = isHorizontal ? pt.x : pt.y;
|
1999-09-15 02:17:19 +04:00
|
|
|
|
2005-08-23 07:57:07 +04:00
|
|
|
// mDragStart is in frame coordinates
|
|
|
|
nscoord start = mDragStart;
|
2005-04-18 09:18:34 +04:00
|
|
|
|
2005-11-21 01:05:24 +03:00
|
|
|
// take our current position and subtract the start location
|
2003-12-21 07:04:05 +03:00
|
|
|
pos -= start;
|
|
|
|
|
|
|
|
//printf("Diff=%d\n", pos);
|
|
|
|
|
|
|
|
ResizeType resizeAfter = GetResizeAfter();
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool bounded;
|
2003-12-21 07:04:05 +03:00
|
|
|
|
|
|
|
if (resizeAfter == nsSplitterFrameInner::Grow)
|
2011-10-17 18:59:28 +04:00
|
|
|
bounded = false;
|
2003-12-21 07:04:05 +03:00
|
|
|
else
|
2011-10-17 18:59:28 +04:00
|
|
|
bounded = true;
|
2003-12-21 07:04:05 +03: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 10:19:26 +04:00
|
|
|
bool supportsBefore = SupportsCollapseDirection(Before);
|
|
|
|
bool supportsAfter = SupportsCollapseDirection(After);
|
2003-12-21 07:04:05 +03:00
|
|
|
|
2013-02-17 01:51:02 +04:00
|
|
|
const bool isRTL = mOuter->StyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool pastEnd = oldPos > 0 && oldPos > pos;
|
|
|
|
bool pastBegin = oldPos < 0 && oldPos < pos;
|
2010-04-12 03:46:08 +04:00
|
|
|
if (isRTL) {
|
|
|
|
// Swap the boundary checks in RTL mode
|
2011-09-29 10:19:26 +04:00
|
|
|
bool tmp = pastEnd;
|
2010-04-12 03:46:08 +04:00
|
|
|
pastEnd = pastBegin;
|
|
|
|
pastBegin = tmp;
|
|
|
|
}
|
2011-09-29 10:19:26 +04:00
|
|
|
const bool isCollapsedBefore = pastBegin && supportsBefore;
|
|
|
|
const bool isCollapsedAfter = pastEnd && supportsAfter;
|
2010-04-12 03:46:08 +04:00
|
|
|
|
2003-12-21 07:04:05 +03:00
|
|
|
// if we are in a collapsed position
|
2010-04-12 03:46:08 +04:00
|
|
|
if (isCollapsedBefore || isCollapsedAfter)
|
2003-12-21 07:04:05 +03:00
|
|
|
{
|
|
|
|
// and we are not collapsed then collapse
|
|
|
|
if (currentState == Dragging) {
|
2010-04-12 03:46:08 +04:00
|
|
|
if (pastEnd)
|
2003-12-21 07:04:05 +03:00
|
|
|
{
|
|
|
|
//printf("Collapse right\n");
|
2006-07-20 02:30:33 +04:00
|
|
|
if (supportsAfter)
|
2003-12-21 07:04:05 +03:00
|
|
|
{
|
2006-09-04 00:25:58 +04:00
|
|
|
nsCOMPtr<nsIContent> outer = mOuter->mContent;
|
2006-12-26 20:47:52 +03:00
|
|
|
outer->SetAttr(kNameSpaceID_None, nsGkAtoms::substate,
|
2006-09-04 00:25:58 +04:00
|
|
|
NS_LITERAL_STRING("after"),
|
2011-10-17 18:59:28 +04:00
|
|
|
true);
|
2006-12-26 20:47:52 +03:00
|
|
|
outer->SetAttr(kNameSpaceID_None, nsGkAtoms::state,
|
2006-09-04 00:25:58 +04:00
|
|
|
NS_LITERAL_STRING("collapsed"),
|
2011-10-17 18:59:28 +04:00
|
|
|
true);
|
2003-12-21 07:04:05 +03:00
|
|
|
}
|
|
|
|
|
2010-04-12 03:46:08 +04:00
|
|
|
} else if (pastBegin)
|
2003-12-21 07:04:05 +03:00
|
|
|
{
|
|
|
|
//printf("Collapse left\n");
|
2006-07-20 02:30:33 +04:00
|
|
|
if (supportsBefore)
|
2003-12-21 07:04:05 +03:00
|
|
|
{
|
2006-09-04 00:25:58 +04:00
|
|
|
nsCOMPtr<nsIContent> outer = mOuter->mContent;
|
2006-12-26 20:47:52 +03:00
|
|
|
outer->SetAttr(kNameSpaceID_None, nsGkAtoms::substate,
|
2006-09-04 00:25:58 +04:00
|
|
|
NS_LITERAL_STRING("before"),
|
2011-10-17 18:59:28 +04:00
|
|
|
true);
|
2006-12-26 20:47:52 +03:00
|
|
|
outer->SetAttr(kNameSpaceID_None, nsGkAtoms::state,
|
2006-09-04 00:25:58 +04:00
|
|
|
NS_LITERAL_STRING("collapsed"),
|
2011-10-17 18:59:28 +04:00
|
|
|
true);
|
2003-12-21 07:04:05 +03: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 18:59:28 +04:00
|
|
|
mOuter->mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::state, NS_LITERAL_STRING("dragging"), true);
|
2009-07-04 13:47:59 +04:00
|
|
|
AdjustChildren(aPresContext);
|
2003-12-21 07:04:05 +03:00
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
mDidDrag = true;
|
2003-12-21 07:04:05 +03:00
|
|
|
}
|
1999-09-06 00:46:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsSplitterFrameInner::AddListener(nsPresContext* aPresContext)
|
1999-09-06 00:46:59 +04:00
|
|
|
{
|
2007-05-14 13:11:38 +04:00
|
|
|
mOuter->GetContent()->
|
2011-10-17 18:59:28 +04:00
|
|
|
AddEventListener(NS_LITERAL_STRING("mouseup"), this, false, false);
|
2007-05-14 13:11:38 +04:00
|
|
|
mOuter->GetContent()->
|
2011-10-17 18:59:28 +04:00
|
|
|
AddEventListener(NS_LITERAL_STRING("mousedown"), this, false, false);
|
2011-06-28 21:59:14 +04:00
|
|
|
mOuter->GetContent()->
|
2011-10-17 18:59:28 +04:00
|
|
|
AddEventListener(NS_LITERAL_STRING("mousemove"), this, false, false);
|
2011-06-28 21:59:14 +04:00
|
|
|
mOuter->GetContent()->
|
2011-10-17 18:59:28 +04:00
|
|
|
AddEventListener(NS_LITERAL_STRING("mouseout"), this, false, false);
|
1999-09-06 00:46:59 +04: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-10 01:02:40 +03:00
|
|
|
nsSplitterFrameInner::RemoveListener()
|
1999-09-06 00:46:59 +04:00
|
|
|
{
|
2007-05-21 11:33:32 +04:00
|
|
|
ENSURE_TRUE(mOuter);
|
2007-05-14 13:11:38 +04:00
|
|
|
mOuter->GetContent()->
|
2011-10-17 18:59:28 +04:00
|
|
|
RemoveEventListener(NS_LITERAL_STRING("mouseup"), this, false);
|
2011-06-28 21:59:14 +04:00
|
|
|
mOuter->GetContent()->
|
2011-10-17 18:59:28 +04:00
|
|
|
RemoveEventListener(NS_LITERAL_STRING("mousedown"), this, false);
|
2007-05-14 13:11:38 +04:00
|
|
|
mOuter->GetContent()->
|
2011-10-17 18:59:28 +04:00
|
|
|
RemoveEventListener(NS_LITERAL_STRING("mousemove"), this, false);
|
2011-06-28 21:59:14 +04:00
|
|
|
mOuter->GetContent()->
|
2011-10-17 18:59:28 +04:00
|
|
|
RemoveEventListener(NS_LITERAL_STRING("mouseout"), this, false);
|
2011-06-28 21:59:14 +04: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-06 00:46:59 +04: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-10 01:02:40 +03:00
|
|
|
nsSplitterFrameInner::MouseUp(nsIDOMEvent* aMouseEvent)
|
1999-09-06 00:46:59 +04:00
|
|
|
{
|
2007-05-21 11:33:32 +04:00
|
|
|
NS_ENSURE_TRUE(mOuter, NS_OK);
|
2011-10-17 18:59:28 +04:00
|
|
|
mPressed = false;
|
2002-04-10 08:58:02 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
nsIPresShell::SetCapturingContent(nullptr, 0);
|
2002-04-10 08:58:02 +04:00
|
|
|
|
1999-09-06 00:46:59 +04: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-10 01:02:40 +03:00
|
|
|
nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent)
|
1999-09-06 00:46:59 +04:00
|
|
|
{
|
2007-05-21 11:33:32 +04:00
|
|
|
NS_ENSURE_TRUE(mOuter, NS_OK);
|
2000-05-16 02:43:47 +04:00
|
|
|
nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(aMouseEvent));
|
2011-06-28 21:59:14 +04:00
|
|
|
if (!mouseEvent)
|
|
|
|
return NS_OK;
|
2000-05-16 02:43:47 +04:00
|
|
|
|
2014-02-20 22:38:13 +04:00
|
|
|
int16_t button = 0;
|
2000-05-16 02:43:47 +04:00
|
|
|
mouseEvent->GetButton(&button);
|
|
|
|
|
|
|
|
// only if left button
|
2001-03-02 06:07:53 +03:00
|
|
|
if (button != 0)
|
2000-05-16 02:43:47 +04:00
|
|
|
return NS_OK;
|
|
|
|
|
2006-01-10 23:00:39 +03:00
|
|
|
if (mOuter->GetContent()->
|
2006-12-26 20:47:52 +03:00
|
|
|
AttrValueIs(kNameSpaceID_None, nsGkAtoms::disabled,
|
|
|
|
nsGkAtoms::_true, eCaseMatters))
|
2000-09-08 10:55:10 +04:00
|
|
|
return NS_OK;
|
|
|
|
|
2007-02-22 21:05:14 +03:00
|
|
|
mParentBox = mOuter->GetParentBox();
|
2006-03-25 00:05:11 +03:00
|
|
|
if (!mParentBox)
|
|
|
|
return NS_OK;
|
2009-04-25 12:33:32 +04:00
|
|
|
|
2006-03-25 00:05:11 +03:00
|
|
|
// get our index
|
2007-03-31 01:11:41 +04:00
|
|
|
nsPresContext* outerPresContext = mOuter->PresContext();
|
2011-08-25 00:54:30 +04:00
|
|
|
const nsFrameList& siblingList(mParentBox->PrincipalChildList());
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t childIndex = siblingList.IndexOf(mOuter);
|
2009-04-25 12:33:32 +04: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 14:39:08 +04:00
|
|
|
return NS_OK;
|
2006-03-25 00:05:11 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t childCount = siblingList.GetLength();
|
2007-08-24 14:39:08 +04:00
|
|
|
// if it's the last index then we need to allow for resizeafter="grow"
|
|
|
|
if (childIndex == childCount - 1 && GetResizeAfter() != Grow)
|
2006-03-25 00:05:11 +03:00
|
|
|
return NS_OK;
|
|
|
|
|
2011-04-08 05:04:40 +04:00
|
|
|
nsRefPtr<nsRenderingContext> rc =
|
2014-04-15 08:30:25 +04:00
|
|
|
outerPresContext->PresShell()->CreateReferenceRenderingContext();
|
2007-04-30 02:24:59 +04:00
|
|
|
nsBoxLayoutState state(outerPresContext, rc);
|
1999-09-06 00:46:59 +04:00
|
|
|
mCurrentPos = 0;
|
2011-10-17 18:59:28 +04:00
|
|
|
mPressed = true;
|
1999-09-06 00:46:59 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
mDidDrag = false;
|
1999-09-06 00:46:59 +04:00
|
|
|
|
2003-12-21 07:04:05 +03:00
|
|
|
EnsureOrient();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isHorizontal = !mOuter->IsHorizontal();
|
2001-08-15 08:09:41 +04:00
|
|
|
|
1999-09-06 00:46:59 +04:00
|
|
|
ResizeType resizeBefore = GetResizeBefore();
|
|
|
|
ResizeType resizeAfter = GetResizeAfter();
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
delete[] mChildInfosBefore;
|
|
|
|
delete[] mChildInfosAfter;
|
1999-09-06 00:46:59 +04: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 19:56:38 +04:00
|
|
|
int32_t count = 0;
|
1999-09-06 00:46:59 +04:00
|
|
|
mChildInfosBeforeCount = 0;
|
|
|
|
mChildInfosAfterCount = 0;
|
|
|
|
|
2012-08-06 07:00:57 +04:00
|
|
|
nsIFrame* childBox = mParentBox->GetChildBox();
|
1999-09-06 00:46:59 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
while (nullptr != childBox)
|
1999-09-06 00:46:59 +04:00
|
|
|
{
|
2004-09-28 22:37:50 +04:00
|
|
|
nsIContent* content = childBox->GetContent();
|
2011-10-18 14:53:36 +04:00
|
|
|
nsIDocument* doc = content->OwnerDoc();
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t dummy;
|
2011-10-18 15:19:44 +04:00
|
|
|
nsIAtom* atom = doc->BindingManager()->ResolveTag(content, &dummy);
|
1999-09-06 00:46:59 +04:00
|
|
|
|
|
|
|
// skip over any splitters
|
2006-12-26 20:47:52 +03:00
|
|
|
if (atom != nsGkAtoms::splitter) {
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize prefSize = childBox->GetPrefSize(state);
|
|
|
|
nsSize minSize = childBox->GetMinSize(state);
|
2008-01-05 08:49:44 +03:00
|
|
|
nsSize maxSize = nsBox::BoundsCheckMinMax(minSize, childBox->GetMaxSize(state));
|
|
|
|
prefSize = nsBox::BoundsCheck(minSize, prefSize, maxSize);
|
1999-09-06 00:46:59 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
mOuter->AddMargin(childBox, minSize);
|
|
|
|
mOuter->AddMargin(childBox, prefSize);
|
|
|
|
mOuter->AddMargin(childBox, maxSize);
|
|
|
|
|
2007-01-31 19:02:42 +03:00
|
|
|
nscoord flex = childBox->GetFlex(state);
|
1999-09-06 00:46:59 +04:00
|
|
|
|
|
|
|
nsMargin margin(0,0,0,0);
|
2000-03-31 11:02:06 +04:00
|
|
|
childBox->GetMargin(margin);
|
2004-09-28 22:37:50 +04:00
|
|
|
nsRect r(childBox->GetRect());
|
1999-09-06 00:46:59 +04:00
|
|
|
r.Inflate(margin);
|
|
|
|
|
2002-07-16 05:45:38 +04: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 20:47:52 +03:00
|
|
|
if (!content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::fixed,
|
|
|
|
nsGkAtoms::_true, eCaseMatters) &&
|
|
|
|
!content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::hidden,
|
|
|
|
nsGkAtoms::_true, eCaseMatters)) {
|
2007-11-15 06:38:16 +03:00
|
|
|
if (count < childIndex && (resizeBefore != Flex || flex > 0)) {
|
2005-10-11 22:59:58 +04:00
|
|
|
mChildInfosBefore[mChildInfosBeforeCount].childElem = content;
|
2000-09-08 10:55:10 +04: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 06:38:16 +03:00
|
|
|
} else if (count > childIndex && (resizeAfter != Flex || flex > 0)) {
|
2005-10-11 22:59:58 +04:00
|
|
|
mChildInfosAfter[mChildInfosAfterCount].childElem = content;
|
2000-09-08 10:55:10 +04: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 05:45:38 +04:00
|
|
|
mChildInfosAfter[mChildInfosAfterCount].changed = mChildInfosAfter[mChildInfosAfterCount].current;
|
2000-09-08 10:55:10 +04:00
|
|
|
mChildInfosAfterCount++;
|
|
|
|
}
|
1999-09-06 00:46:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-22 21:05:14 +03:00
|
|
|
childBox = childBox->GetNextBox();
|
1999-09-06 00:46:59 +04:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
|
2007-01-31 19:02:42 +03:00
|
|
|
if (!mParentBox->IsNormalDirection()) {
|
2001-08-15 08:09:41 +04: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 06:38:16 +03: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-06 00:46:59 +04:00
|
|
|
Reverse(mChildInfosBefore, mChildInfosBeforeCount);
|
|
|
|
|
1999-09-09 03:51:02 +04: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-06 00:46:59 +04: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 19:56:38 +04:00
|
|
|
int32_t c;
|
2005-08-23 07:57:07 +04:00
|
|
|
nsPoint pt = nsLayoutUtils::GetDOMEventCoordinatesRelativeTo(mouseEvent,
|
2005-08-24 00:48:56 +04:00
|
|
|
mParentBox);
|
1999-09-06 00:46:59 +04:00
|
|
|
if (isHorizontal) {
|
2005-08-23 07:57:07 +04: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-10 01:02:40 +03:00
|
|
|
mSplitterPos = mOuter->mRect.x;
|
1999-09-06 00:46:59 +04:00
|
|
|
} else {
|
2005-08-23 07:57:07 +04: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-10 01:02:40 +03:00
|
|
|
mSplitterPos = mOuter->mRect.y;
|
1999-09-06 00:46:59 +04:00
|
|
|
}
|
|
|
|
|
2005-08-23 07:57:07 +04:00
|
|
|
mDragStart = c;
|
2005-12-15 06:30:17 +03:00
|
|
|
|
2005-08-23 07:57:07 +04:00
|
|
|
//printf("Pressed mDragStart=%d\n",mDragStart);
|
1999-09-06 00:46:59 +04:00
|
|
|
|
2009-09-13 17:13:16 +04:00
|
|
|
nsIPresShell::SetCapturingContent(mOuter->GetContent(), CAPTURE_IGNOREALLOWED);
|
2002-03-27 08:49:56 +03:00
|
|
|
|
1999-09-06 00:46:59 +04: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-10 01:02:40 +03:00
|
|
|
nsSplitterFrameInner::MouseMove(nsIDOMEvent* aMouseEvent)
|
1999-09-06 00:46:59 +04:00
|
|
|
{
|
2007-05-21 11:33:32 +04:00
|
|
|
NS_ENSURE_TRUE(mOuter, NS_OK);
|
1999-09-06 00:46:59 +04:00
|
|
|
if (!mPressed)
|
2005-12-15 06:30:17 +03:00
|
|
|
return NS_OK;
|
|
|
|
|
2000-08-31 01:51:02 +04:00
|
|
|
if (mDragging)
|
1999-09-06 00:46:59 +04:00
|
|
|
return NS_OK;
|
|
|
|
|
2011-06-28 21:59:14 +04:00
|
|
|
nsCOMPtr<nsIDOMEventListener> kungfuDeathGrip(this);
|
|
|
|
mOuter->mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::state,
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_LITERAL_STRING("dragging"), true);
|
1999-09-06 00:46:59 +04:00
|
|
|
|
|
|
|
RemoveListener();
|
2011-10-17 18:59:28 +04:00
|
|
|
mDragging = true;
|
1999-09-06 00:46:59 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSplitterFrameInner::Reverse(nsSplitterInfo*& aChildInfos, int32_t aCount)
|
1999-09-06 00:46:59 +04:00
|
|
|
{
|
|
|
|
nsSplitterInfo* infos = new nsSplitterInfo[aCount];
|
|
|
|
|
|
|
|
for (int i=0; i < aCount; i++)
|
|
|
|
infos[i] = aChildInfos[aCount - 1 - i];
|
|
|
|
|
2000-04-03 07:55:38 +04:00
|
|
|
delete[] aChildInfos;
|
1999-09-06 00:46:59 +04:00
|
|
|
aChildInfos = infos;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2006-07-20 02:30:33 +04:00
|
|
|
nsSplitterFrameInner::SupportsCollapseDirection
|
|
|
|
(
|
|
|
|
nsSplitterFrameInner::CollapseDirection aDirection
|
|
|
|
)
|
1999-09-15 02:17:19 +04:00
|
|
|
{
|
2006-04-24 09:40:11 +04:00
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2012-07-30 18:20:58 +04:00
|
|
|
{&nsGkAtoms::before, &nsGkAtoms::after, &nsGkAtoms::both, nullptr};
|
2006-07-20 02:30:33 +04:00
|
|
|
|
2006-04-24 09:40:11 +04:00
|
|
|
switch (mOuter->mContent->FindAttrValueIn(kNameSpaceID_None,
|
2006-12-26 20:47:52 +03:00
|
|
|
nsGkAtoms::collapse,
|
2006-04-24 09:40:11 +04:00
|
|
|
strings, eCaseMatters)) {
|
2006-07-20 02:30:33 +04:00
|
|
|
case 0:
|
|
|
|
return (aDirection == Before);
|
|
|
|
case 1:
|
|
|
|
return (aDirection == After);
|
|
|
|
case 2:
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2006-04-24 09:40:11 +04:00
|
|
|
}
|
2005-10-28 15:25:24 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
1999-09-15 02:17:19 +04:00
|
|
|
}
|
|
|
|
|
1999-09-06 00:46:59 +04: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-10 01:02:40 +03:00
|
|
|
nsSplitterFrameInner::UpdateState()
|
1999-09-06 00:46:59 +04:00
|
|
|
{
|
2000-03-08 03:14:53 +03:00
|
|
|
// State Transitions:
|
2006-07-20 02:30:33 +04: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-15 02:17:19 +04:00
|
|
|
|
1999-09-06 00:46:59 +04:00
|
|
|
State newState = GetState();
|
|
|
|
|
2000-03-08 03:14:53 +03:00
|
|
|
if (newState == mState) {
|
|
|
|
// No change.
|
2003-12-21 07:04:05 +03:00
|
|
|
return;
|
2000-03-08 03:14:53 +03:00
|
|
|
}
|
1999-09-06 00:46:59 +04:00
|
|
|
|
2009-04-25 12:33:32 +04:00
|
|
|
if ((SupportsCollapseDirection(Before) || SupportsCollapseDirection(After)) &&
|
|
|
|
mOuter->GetParent()->IsBoxFrame()) {
|
2003-12-21 07:04:05 +03:00
|
|
|
// Find the splitter's immediate sibling.
|
2009-04-25 12:33:32 +04:00
|
|
|
nsIFrame* splitterSibling;
|
|
|
|
if (newState == CollapsedBefore || mState == CollapsedBefore) {
|
2009-10-02 20:27:37 +04:00
|
|
|
splitterSibling = mOuter->GetPrevSibling();
|
2009-04-25 12:33:32 +04:00
|
|
|
} else {
|
|
|
|
splitterSibling = mOuter->GetNextSibling();
|
|
|
|
}
|
|
|
|
|
2009-05-21 06:50:17 +04:00
|
|
|
if (splitterSibling) {
|
2006-09-04 00:25:58 +04:00
|
|
|
nsCOMPtr<nsIContent> sibling = splitterSibling->GetContent();
|
2003-12-21 07:04:05 +03:00
|
|
|
if (sibling) {
|
2006-07-20 02:30:33 +04:00
|
|
|
if (mState == CollapsedBefore || mState == CollapsedAfter) {
|
|
|
|
// CollapsedBefore -> Open
|
|
|
|
// CollapsedBefore -> Dragging
|
|
|
|
// CollapsedAfter -> Open
|
|
|
|
// CollapsedAfter -> Dragging
|
2008-04-15 03:59:21 +04:00
|
|
|
nsContentUtils::AddScriptRunner(
|
|
|
|
new nsUnsetAttrRunnable(sibling, nsGkAtoms::collapsed));
|
2006-07-20 02:30:33 +04:00
|
|
|
} else if ((mState == Open || mState == Dragging)
|
|
|
|
&& (newState == CollapsedBefore ||
|
|
|
|
newState == CollapsedAfter)) {
|
|
|
|
// Open -> CollapsedBefore / CollapsedAfter
|
|
|
|
// Dragging -> CollapsedBefore / CollapsedAfter
|
2008-04-15 03:59:21 +04:00
|
|
|
nsContentUtils::AddScriptRunner(
|
|
|
|
new nsSetAttrRunnable(sibling, nsGkAtoms::collapsed,
|
|
|
|
NS_LITERAL_STRING("true")));
|
2000-03-08 05:33:52 +03:00
|
|
|
}
|
2000-03-08 03:14:53 +03:00
|
|
|
}
|
1999-09-06 00:46:59 +04:00
|
|
|
}
|
2003-12-21 07:04:05 +03:00
|
|
|
}
|
|
|
|
mState = newState;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSplitterFrameInner::EnsureOrient()
|
|
|
|
{
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isHorizontal = !(mParentBox->GetStateBits() & NS_STATE_IS_HORIZONTAL);
|
2000-03-31 11:02:06 +04:00
|
|
|
if (isHorizontal)
|
2003-12-21 07:04:05 +03:00
|
|
|
mOuter->mState |= NS_STATE_IS_HORIZONTAL;
|
2000-03-31 11:02:06 +04:00
|
|
|
else
|
2003-12-21 07:04:05 +03:00
|
|
|
mOuter->mState &= ~NS_STATE_IS_HORIZONTAL;
|
1999-09-06 00:46:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsSplitterFrameInner::AdjustChildren(nsPresContext* aPresContext)
|
1999-09-06 00:46:59 +04:00
|
|
|
{
|
2000-03-31 11:02:06 +04:00
|
|
|
EnsureOrient();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isHorizontal = !mOuter->IsHorizontal();
|
2000-03-31 11:02:06 +04:00
|
|
|
|
1999-09-06 00:46:59 +04:00
|
|
|
AdjustChildren(aPresContext, mChildInfosBefore, mChildInfosBeforeCount, isHorizontal);
|
|
|
|
AdjustChildren(aPresContext, mChildInfosAfter, mChildInfosAfterCount, isHorizontal);
|
|
|
|
}
|
|
|
|
|
2012-08-06 07:00:57 +04:00
|
|
|
static nsIFrame* GetChildBoxForContent(nsIFrame* aParentBox, nsIContent* aContent)
|
2005-10-11 22:59:58 +04:00
|
|
|
{
|
2012-08-06 07:00:57 +04:00
|
|
|
nsIFrame* childBox = aParentBox->GetChildBox();
|
2005-10-11 22:59:58 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
while (nullptr != childBox) {
|
2005-10-11 22:59:58 +04:00
|
|
|
if (childBox->GetContent() == aContent) {
|
|
|
|
return childBox;
|
|
|
|
}
|
2007-02-22 21:05:14 +03:00
|
|
|
childBox = childBox->GetNextBox();
|
2005-10-11 22:59:58 +04:00
|
|
|
}
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2005-10-11 22:59:58 +04:00
|
|
|
}
|
|
|
|
|
1999-09-06 00:46:59 +04:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSplitterFrameInner::AdjustChildren(nsPresContext* aPresContext, nsSplitterInfo* aChildInfos, int32_t aCount, bool aIsHorizontal)
|
1999-09-06 00:46:59 +04:00
|
|
|
{
|
2003-12-21 07:04:05 +03:00
|
|
|
///printf("------- AdjustChildren------\n");
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2003-12-21 07:04:05 +03:00
|
|
|
nsBoxLayoutState state(aPresContext);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2007-02-07 10:46:44 +03:00
|
|
|
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
|
1999-09-06 00:46:59 +04:00
|
|
|
|
2003-12-21 07:04:05 +03:00
|
|
|
// first set all the widths.
|
2012-08-06 07:00:57 +04:00
|
|
|
nsIFrame* child = mOuter->GetChildBox();
|
2003-12-21 07:04:05 +03:00
|
|
|
while(child)
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
SetPreferredSize(state, child, onePixel, aIsHorizontal, nullptr);
|
2007-02-22 21:05:14 +03:00
|
|
|
child = child->GetNextBox();
|
2003-12-21 07:04:05 +03:00
|
|
|
}
|
2000-04-12 03:55:15 +04:00
|
|
|
|
2003-12-21 07:04:05 +03:00
|
|
|
// now set our changed widths.
|
|
|
|
for (int i=0; i < aCount; i++)
|
|
|
|
{
|
|
|
|
nscoord pref = aChildInfos[i].changed;
|
2012-08-06 07:00:57 +04:00
|
|
|
nsIFrame* childBox = GetChildBoxForContent(mParentBox, aChildInfos[i].childElem);
|
1999-09-06 00:46:59 +04:00
|
|
|
|
2005-10-11 22:59:58 +04:00
|
|
|
if (childBox) {
|
|
|
|
SetPreferredSize(state, childBox, onePixel, aIsHorizontal, &pref);
|
|
|
|
}
|
2003-12-21 07:04:05 +03:00
|
|
|
}
|
2000-04-12 03:55:15 +04:00
|
|
|
}
|
1999-09-06 00:46:59 +04:00
|
|
|
|
2000-04-12 03:55:15 +04:00
|
|
|
void
|
2012-08-06 07:00:57 +04:00
|
|
|
nsSplitterFrameInner::SetPreferredSize(nsBoxLayoutState& aState, nsIFrame* aChildBox, nscoord aOnePixel, bool aIsHorizontal, nscoord* aSize)
|
2000-04-12 03:55:15 +04:00
|
|
|
{
|
2004-09-28 22:37:50 +04:00
|
|
|
nsRect rect(aChildBox->GetRect());
|
2000-04-12 03:55:15 +04:00
|
|
|
nscoord pref = 0;
|
|
|
|
|
|
|
|
if (!aSize)
|
|
|
|
{
|
|
|
|
if (aIsHorizontal)
|
|
|
|
pref = rect.width;
|
|
|
|
else
|
|
|
|
pref = rect.height;
|
|
|
|
} else {
|
|
|
|
pref = *aSize;
|
|
|
|
}
|
1999-09-06 00:46:59 +04:00
|
|
|
|
2000-04-12 03:55:15 +04:00
|
|
|
nsMargin margin(0,0,0,0);
|
|
|
|
aChildBox->GetMargin(margin);
|
1999-09-06 00:46:59 +04:00
|
|
|
|
2000-04-12 03:55:15 +04:00
|
|
|
nsCOMPtr<nsIAtom> attribute;
|
1999-09-06 00:46:59 +04:00
|
|
|
|
2000-04-12 03:55:15 +04:00
|
|
|
if (aIsHorizontal) {
|
2003-12-21 07:04:05 +03:00
|
|
|
pref -= (margin.left + margin.right);
|
2006-12-26 20:47:52 +03:00
|
|
|
attribute = nsGkAtoms::width;
|
2000-04-12 03:55:15 +04:00
|
|
|
} else {
|
2003-12-21 07:04:05 +03:00
|
|
|
pref -= (margin.top + margin.bottom);
|
2006-12-26 20:47:52 +03:00
|
|
|
attribute = nsGkAtoms::height;
|
2000-04-12 03:55:15 +04:00
|
|
|
}
|
1999-09-06 00:46:59 +04:00
|
|
|
|
2004-09-28 22:37:50 +04:00
|
|
|
nsIContent* content = aChildBox->GetContent();
|
2000-04-12 03:55:15 +04:00
|
|
|
|
|
|
|
// set its preferred size.
|
2002-12-31 15:50:10 +03:00
|
|
|
nsAutoString prefValue;
|
|
|
|
prefValue.AppendInt(pref/aOnePixel);
|
2006-01-10 23:00:39 +03:00
|
|
|
if (content->AttrValueIs(kNameSpaceID_None, attribute,
|
|
|
|
prefValue, eCaseMatters))
|
2000-04-12 03:55:15 +04:00
|
|
|
return;
|
|
|
|
|
2006-09-04 00:25:58 +04:00
|
|
|
nsWeakFrame weakBox(aChildBox);
|
2011-10-17 18:59:28 +04:00
|
|
|
content->SetAttr(kNameSpaceID_None, attribute, prefValue, true);
|
2006-09-04 00:25:58 +04:00
|
|
|
ENSURE_TRUE(weakBox.IsAlive());
|
2007-05-06 23:16:51 +04:00
|
|
|
aState.PresShell()->FrameNeedsReflow(aChildBox, nsIPresShell::eStyleChange,
|
|
|
|
NS_FRAME_IS_DIRTY);
|
1999-09-06 00:46:59 +04: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-10 01:02:40 +03:00
|
|
|
nsSplitterFrameInner::AddRemoveSpace(nscoord aDiff,
|
1999-09-06 00:46:59 +04:00
|
|
|
nsSplitterInfo* aChildInfos,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aCount,
|
|
|
|
int32_t& aSpaceLeft)
|
1999-09-06 00:46:59 +04: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 07:04:05 +03:00
|
|
|
aDiff += (c - min);
|
|
|
|
c = min;
|
1999-09-06 00:46:59 +04:00
|
|
|
} else if (c + aDiff > max) {
|
2003-12-21 07:04:05 +03:00
|
|
|
aDiff -= (max - c);
|
|
|
|
c = max;
|
1999-09-06 00:46:59 +04:00
|
|
|
} else {
|
2003-12-21 07:04:05 +03:00
|
|
|
c += aDiff;
|
|
|
|
aDiff = 0;
|
1999-09-06 00:46:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// there is not space left? We are done
|
|
|
|
if (aDiff == 0)
|
2003-12-21 07:04:05 +03:00
|
|
|
break;
|
1999-09-06 00:46:59 +04: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-08-01 03:15:21 +04:00
|
|
|
nsSplitterFrameInner::ResizeChildTo(nsPresContext* aPresContext,
|
1999-10-26 08:44:41 +04:00
|
|
|
nscoord& aDiff,
|
1999-09-06 00:46:59 +04:00
|
|
|
nsSplitterInfo* aChildrenBeforeInfos,
|
|
|
|
nsSplitterInfo* aChildrenAfterInfos,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aChildrenBeforeCount,
|
|
|
|
int32_t aChildrenAfterCount,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aBounded)
|
1999-09-06 00:46:59 +04: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-10 01:02:40 +03:00
|
|
|
}
|