зеркало из https://github.com/mozilla/pjs.git
Bug 226232 DRefTool analysis for xul files
r=roc sr=roc
This commit is contained in:
Родитель
dd49d5d888
Коммит
57d9d7b390
|
@ -351,6 +351,8 @@ nsPopupSetFrame::ShowPopup(nsIContent* aElementContent, nsIContent* aPopupConten
|
||||||
entry = mPopupList->GetEntry(aPopupContent);
|
entry = mPopupList->GetEntry(aPopupContent);
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
entry = new nsPopupFrameList(aPopupContent, mPopupList);
|
entry = new nsPopupFrameList(aPopupContent, mPopupList);
|
||||||
|
if (!entry)
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
mPopupList = entry;
|
mPopupList = entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -801,6 +803,8 @@ nsPopupSetFrame::AddPopupFrame(nsIFrame* aPopup)
|
||||||
entry = mPopupList->GetEntry(content);
|
entry = mPopupList->GetEntry(content);
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
entry = new nsPopupFrameList(content, mPopupList);
|
entry = new nsPopupFrameList(content, mPopupList);
|
||||||
|
if (!entry)
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
mPopupList = entry;
|
mPopupList = entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -321,6 +321,9 @@ nsRootBoxFrame::AddTooltipSupport(nsIContent* aNode)
|
||||||
// it will add itself to, and destroyed when those targets
|
// it will add itself to, and destroyed when those targets
|
||||||
// are destroyed
|
// are destroyed
|
||||||
nsXULTooltipListener* listener = new nsXULTooltipListener();
|
nsXULTooltipListener* listener = new nsXULTooltipListener();
|
||||||
|
if (!listener)
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
listener->Init(aNode, this);
|
listener->Init(aNode, this);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,13 +84,13 @@ PRInt32 realTimeDrag;
|
||||||
|
|
||||||
class nsSplitterInfo {
|
class nsSplitterInfo {
|
||||||
public:
|
public:
|
||||||
nscoord min;
|
nscoord min;
|
||||||
nscoord max;
|
nscoord max;
|
||||||
nscoord current;
|
nscoord current;
|
||||||
nscoord changed;
|
nscoord changed;
|
||||||
nsIBox* child;
|
nsIBox* child;
|
||||||
PRInt32 flex;
|
PRInt32 flex;
|
||||||
PRInt32 index;
|
PRInt32 index;
|
||||||
};
|
};
|
||||||
|
|
||||||
class nsSplitterFrameInner : public nsIDOMMouseListener, public nsIDOMMouseMotionListener {
|
class nsSplitterFrameInner : public nsIDOMMouseListener, public nsIDOMMouseMotionListener {
|
||||||
|
@ -183,13 +183,12 @@ NS_IMPL_ISUPPORTS2(nsSplitterFrameInner, nsIDOMMouseListener, nsIDOMMouseMotionL
|
||||||
nsSplitterFrameInner::ResizeType
|
nsSplitterFrameInner::ResizeType
|
||||||
nsSplitterFrameInner::GetResizeBefore()
|
nsSplitterFrameInner::GetResizeBefore()
|
||||||
{
|
{
|
||||||
nsString value;
|
nsString value;
|
||||||
mOuter->GetContent()->GetAttr(kNameSpaceID_None,
|
mOuter->GetContent()->GetAttr(kNameSpaceID_None,
|
||||||
nsXULAtoms::resizebefore, value);
|
nsXULAtoms::resizebefore, value);
|
||||||
if (value.Equals(NS_LITERAL_STRING("farthest")))
|
if (value.Equals(NS_LITERAL_STRING("farthest")))
|
||||||
return Farthest;
|
return Farthest;
|
||||||
else
|
return Closest;
|
||||||
return Closest;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsSplitterFrameInner::~nsSplitterFrameInner()
|
nsSplitterFrameInner::~nsSplitterFrameInner()
|
||||||
|
@ -201,30 +200,27 @@ nsSplitterFrameInner::~nsSplitterFrameInner()
|
||||||
nsSplitterFrameInner::ResizeType
|
nsSplitterFrameInner::ResizeType
|
||||||
nsSplitterFrameInner::GetResizeAfter()
|
nsSplitterFrameInner::GetResizeAfter()
|
||||||
{
|
{
|
||||||
nsString value;
|
nsString value;
|
||||||
mOuter->GetContent()->GetAttr(kNameSpaceID_None,
|
mOuter->GetContent()->GetAttr(kNameSpaceID_None,
|
||||||
nsXULAtoms::resizeafter, value);
|
nsXULAtoms::resizeafter, value);
|
||||||
if (value.Equals(NS_LITERAL_STRING("farthest")))
|
if (value.Equals(NS_LITERAL_STRING("farthest")))
|
||||||
return Farthest;
|
return Farthest;
|
||||||
else if (value.Equals(NS_LITERAL_STRING("grow")))
|
if (value.Equals(NS_LITERAL_STRING("grow")))
|
||||||
return Grow;
|
return Grow;
|
||||||
else
|
return Closest;
|
||||||
return Closest;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsSplitterFrameInner::State
|
nsSplitterFrameInner::State
|
||||||
nsSplitterFrameInner::GetState()
|
nsSplitterFrameInner::GetState()
|
||||||
{
|
{
|
||||||
nsString value;
|
nsString value;
|
||||||
mOuter->GetContent()->GetAttr(kNameSpaceID_None,
|
mOuter->GetContent()->GetAttr(kNameSpaceID_None,
|
||||||
nsXULAtoms::state, value);
|
nsXULAtoms::state, value);
|
||||||
if (value.Equals(NS_LITERAL_STRING("dragging")))
|
if (value.Equals(NS_LITERAL_STRING("dragging")))
|
||||||
return Dragging;
|
return Dragging;
|
||||||
else if (value.Equals(NS_LITERAL_STRING("collapsed")))
|
if (value.Equals(NS_LITERAL_STRING("collapsed")))
|
||||||
return Collapsed;
|
return Collapsed;
|
||||||
else
|
return Open;
|
||||||
return Open;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -248,20 +244,18 @@ NS_NewSplitterFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame )
|
||||||
|
|
||||||
} // NS_NewSplitterFrame
|
} // NS_NewSplitterFrame
|
||||||
|
|
||||||
nsSplitterFrame::nsSplitterFrame(nsIPresShell* aPresShell):nsBoxFrame(aPresShell)
|
nsSplitterFrame::nsSplitterFrame(nsIPresShell* aPresShell)
|
||||||
|
: nsBoxFrame(aPresShell),
|
||||||
|
mInner(0)
|
||||||
{
|
{
|
||||||
mInner = new nsSplitterFrameInner(this);
|
|
||||||
mInner->AddRef();
|
|
||||||
mInner->mChildInfosAfter = nsnull;
|
|
||||||
mInner->mChildInfosBefore = nsnull;
|
|
||||||
mInner->mState = nsSplitterFrameInner::Open;
|
|
||||||
mInner->mDragging = PR_FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsSplitterFrame::~nsSplitterFrame()
|
nsSplitterFrame::~nsSplitterFrame()
|
||||||
{
|
{
|
||||||
mInner->RemoveListener();
|
if (mInner) {
|
||||||
mInner->Release();
|
mInner->RemoveListener();
|
||||||
|
mInner->Release();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -277,16 +271,16 @@ nsSplitterFrame::GetCursor(nsIPresContext* aPresContext,
|
||||||
nsPoint& aPoint,
|
nsPoint& aPoint,
|
||||||
PRInt32& aCursor)
|
PRInt32& aCursor)
|
||||||
{
|
{
|
||||||
return nsBoxFrame::GetCursor(aPresContext, aPoint, aCursor);
|
return nsBoxFrame::GetCursor(aPresContext, aPoint, aCursor);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (IsHorizontal())
|
if (IsHorizontal())
|
||||||
aCursor = NS_STYLE_CURSOR_N_RESIZE;
|
aCursor = NS_STYLE_CURSOR_N_RESIZE;
|
||||||
else
|
else
|
||||||
aCursor = NS_STYLE_CURSOR_W_RESIZE;
|
aCursor = NS_STYLE_CURSOR_W_RESIZE;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -301,14 +295,14 @@ nsSplitterFrame::AttributeChanged(nsIPresContext* aPresContext,
|
||||||
aModType);
|
aModType);
|
||||||
// if the alignment changed. Let the grippy know
|
// if the alignment changed. Let the grippy know
|
||||||
if (aAttribute == nsHTMLAtoms::align) {
|
if (aAttribute == nsHTMLAtoms::align) {
|
||||||
// tell the slider its attribute changed so it can
|
// tell the slider its attribute changed so it can
|
||||||
// update itself
|
// update itself
|
||||||
nsIFrame* grippy = nsnull;
|
nsIFrame* grippy = nsnull;
|
||||||
nsScrollbarButtonFrame::GetChildWithTag(aPresContext, nsXULAtoms::grippy, this, grippy);
|
nsScrollbarButtonFrame::GetChildWithTag(aPresContext, nsXULAtoms::grippy, this, grippy);
|
||||||
if (grippy)
|
if (grippy)
|
||||||
grippy->AttributeChanged(aPresContext, aChild, aNameSpaceID, aAttribute, aModType);
|
grippy->AttributeChanged(aPresContext, aChild, aNameSpaceID, aAttribute, aModType);
|
||||||
} else if (aAttribute == nsXULAtoms::state) {
|
} else if (aAttribute == nsXULAtoms::state) {
|
||||||
mInner->UpdateState();
|
mInner->UpdateState();
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -324,14 +318,24 @@ nsSplitterFrame::Init(nsIPresContext* aPresContext,
|
||||||
nsStyleContext* aContext,
|
nsStyleContext* aContext,
|
||||||
nsIFrame* aPrevInFlow)
|
nsIFrame* aPrevInFlow)
|
||||||
{
|
{
|
||||||
|
NS_ENSURE_FALSE(mInner, NS_ERROR_ALREADY_INITIALIZED);
|
||||||
|
mInner = new nsSplitterFrameInner(this);
|
||||||
|
if (!mInner)
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
mInner->AddRef();
|
||||||
|
mInner->mChildInfosAfter = nsnull;
|
||||||
|
mInner->mChildInfosBefore = nsnull;
|
||||||
|
mInner->mState = nsSplitterFrameInner::Open;
|
||||||
|
mInner->mDragging = PR_FALSE;
|
||||||
/* make it real time drag for now due to problems
|
/* make it real time drag for now due to problems
|
||||||
nsILookAndFeel* lookAndFeel;
|
nsILookAndFeel* lookAndFeel;
|
||||||
if (NS_SUCCEEDED(nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, NS_GET_IID(nsILookAndFeel), (void**)&lookAndFeel))) {
|
if (NS_SUCCEEDED(nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, NS_GET_IID(nsILookAndFeel), (void**)&lookAndFeel))) {
|
||||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_DragFullWindow, realTimeDrag);
|
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_DragFullWindow, realTimeDrag);
|
||||||
NS_RELEASE(lookAndFeel);
|
NS_RELEASE(lookAndFeel);
|
||||||
}
|
}
|
||||||
else */
|
else */
|
||||||
realTimeDrag = 1;
|
realTimeDrag = 1;
|
||||||
|
|
||||||
// determine orientation of parent, and if vertical, set orient to vertical
|
// determine orientation of parent, and if vertical, set orient to vertical
|
||||||
// on splitter content, then re-resolve style
|
// on splitter content, then re-resolve style
|
||||||
|
@ -369,11 +373,11 @@ nsSplitterFrame::Init(nsIPresContext* aPresContext,
|
||||||
viewManager->SetViewZIndex(view, PR_FALSE, kMaxZ);
|
viewManager->SetViewZIndex(view, PR_FALSE, kMaxZ);
|
||||||
|
|
||||||
if (!realTimeDrag) {
|
if (!realTimeDrag) {
|
||||||
// currently this only works on win32 and mac
|
// currently this only works on win32 and mac
|
||||||
static NS_DEFINE_CID(kCChildCID, NS_CHILD_CID);
|
static NS_DEFINE_CID(kCChildCID, NS_CHILD_CID);
|
||||||
|
|
||||||
// Need to have a widget to appear on top of other widgets.
|
// Need to have a widget to appear on top of other widgets.
|
||||||
view->CreateWidget(kCChildCID);
|
view->CreateWidget(kCChildCID);
|
||||||
}
|
}
|
||||||
|
|
||||||
mInner->mState = nsSplitterFrameInner::Open;
|
mInner->mState = nsSplitterFrameInner::Open;
|
||||||
|
@ -433,7 +437,7 @@ nsSplitterFrame::HandleDrag(nsIPresContext* aPresContext,
|
||||||
nsGUIEvent * aEvent,
|
nsGUIEvent * aEvent,
|
||||||
nsEventStatus* aEventStatus)
|
nsEventStatus* aEventStatus)
|
||||||
{
|
{
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -474,14 +478,13 @@ nsSplitterFrame::HandleEvent(nsIPresContext* aPresContext,
|
||||||
nsGUIEvent* aEvent,
|
nsGUIEvent* aEvent,
|
||||||
nsEventStatus* aEventStatus)
|
nsEventStatus* aEventStatus)
|
||||||
{
|
{
|
||||||
|
switch (aEvent->message) {
|
||||||
switch (aEvent->message) {
|
|
||||||
case NS_MOUSE_MOVE:
|
case NS_MOUSE_MOVE:
|
||||||
mInner->MouseDrag(aPresContext, aEvent);
|
mInner->MouseDrag(aPresContext, aEvent);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NS_MOUSE_LEFT_BUTTON_UP:
|
case NS_MOUSE_LEFT_BUTTON_UP:
|
||||||
mInner->MouseUp(aPresContext, aEvent);
|
mInner->MouseUp(aPresContext, aEvent);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,169 +494,160 @@ nsSplitterFrame::HandleEvent(nsIPresContext* aPresContext,
|
||||||
void
|
void
|
||||||
nsSplitterFrameInner::MouseUp(nsIPresContext* aPresContext, nsGUIEvent* aEvent)
|
nsSplitterFrameInner::MouseUp(nsIPresContext* aPresContext, nsGUIEvent* aEvent)
|
||||||
{
|
{
|
||||||
if (mDragging) {
|
if (mDragging) {
|
||||||
AdjustChildren(aPresContext);
|
AdjustChildren(aPresContext);
|
||||||
AddListener(aPresContext);
|
AddListener(aPresContext);
|
||||||
mOuter->CaptureMouse(aPresContext, PR_FALSE);
|
mOuter->CaptureMouse(aPresContext, PR_FALSE);
|
||||||
mDragging = PR_FALSE;
|
mDragging = PR_FALSE;
|
||||||
State newState = GetState();
|
State newState = GetState();
|
||||||
// if the state is dragging then make it Open.
|
// if the state is dragging then make it Open.
|
||||||
if (newState == Dragging)
|
if (newState == Dragging)
|
||||||
mOuter->mContent->SetAttr(kNameSpaceID_None, nsXULAtoms::state, nsAutoString(), PR_TRUE);
|
mOuter->mContent->SetAttr(kNameSpaceID_None, nsXULAtoms::state, nsAutoString(), PR_TRUE);
|
||||||
|
|
||||||
mPressed = PR_FALSE;
|
mPressed = PR_FALSE;
|
||||||
|
|
||||||
// if we dragged then fire a command event.
|
// if we dragged then fire a command event.
|
||||||
if (mDidDrag) {
|
if (mDidDrag) {
|
||||||
nsCOMPtr<nsIDOMXULElement> element = do_QueryInterface(mOuter->GetContent());
|
nsCOMPtr<nsIDOMXULElement> element = do_QueryInterface(mOuter->GetContent());
|
||||||
element->DoCommand();
|
element->DoCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
//printf("MouseUp\n");
|
//printf("MouseUp\n");
|
||||||
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nsSplitterFrameInner::MouseDrag(nsIPresContext* aPresContext, nsGUIEvent* aEvent)
|
nsSplitterFrameInner::MouseDrag(nsIPresContext* aPresContext, nsGUIEvent* aEvent)
|
||||||
{
|
{
|
||||||
if (mDragging) {
|
if (mDragging) {
|
||||||
|
|
||||||
//printf("Dragging\n");
|
//printf("Dragging\n");
|
||||||
|
|
||||||
PRBool isHorizontal = !mOuter->IsHorizontal();
|
PRBool isHorizontal = !mOuter->IsHorizontal();
|
||||||
// convert coord to pixels
|
// convert coord to pixels
|
||||||
nscoord pos = isHorizontal ? aEvent->point.x : aEvent->point.y;
|
nscoord pos = isHorizontal ? aEvent->point.x : aEvent->point.y;
|
||||||
|
|
||||||
// mDragStartPx is in pixels and is in our client areas coordinate system.
|
// mDragStartPx is in pixels and is in our client areas coordinate system.
|
||||||
// so we need to first convert it so twips and then get it into our coordinate system.
|
// so we need to first convert it so twips and then get it into our coordinate system.
|
||||||
|
|
||||||
// convert start to twips
|
// convert start to twips
|
||||||
nscoord startpx = mDragStartPx;
|
nscoord startpx = mDragStartPx;
|
||||||
|
|
||||||
float p2t;
|
|
||||||
aPresContext->GetScaledPixelsToTwips(&p2t);
|
|
||||||
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
|
|
||||||
nscoord start = startpx*onePixel;
|
|
||||||
|
|
||||||
// get it into our coordintate system by subtracting our parents offsets.
|
float p2t;
|
||||||
nsIFrame* parent = mOuter;
|
aPresContext->GetScaledPixelsToTwips(&p2t);
|
||||||
while(parent != nsnull)
|
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
|
||||||
{
|
nscoord start = startpx*onePixel;
|
||||||
// if we hit a scrollable view make sure we take into account
|
|
||||||
// how much we are scrolled.
|
|
||||||
nsIView* view = parent->GetView();
|
|
||||||
if (view) {
|
|
||||||
nsIScrollableView* scrollingView;
|
|
||||||
nsresult result = CallQueryInterface(view, &scrollingView);
|
|
||||||
if (NS_SUCCEEDED(result)) {
|
|
||||||
nscoord xoff = 0;
|
|
||||||
nscoord yoff = 0;
|
|
||||||
scrollingView->GetScrollPosition(xoff, yoff);
|
|
||||||
isHorizontal ? start += xoff : start += yoff;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nsRect r = parent->GetRect();
|
|
||||||
isHorizontal ? start -= r.x : start -= r.y;
|
|
||||||
parent = parent->GetParent();
|
|
||||||
}
|
|
||||||
|
|
||||||
// take our current position and substract the start location
|
// get it into our coordintate system by subtracting our parents offsets.
|
||||||
pos -= start;
|
nsIFrame* parent = mOuter;
|
||||||
|
while(parent != nsnull)
|
||||||
|
{
|
||||||
|
// if we hit a scrollable view make sure we take into account
|
||||||
|
// how much we are scrolled.
|
||||||
|
nsIView* view = parent->GetView();
|
||||||
|
if (view) {
|
||||||
|
nsIScrollableView* scrollingView;
|
||||||
|
nsresult result = CallQueryInterface(view, &scrollingView);
|
||||||
|
if (NS_SUCCEEDED(result)) {
|
||||||
|
nscoord xoff = 0;
|
||||||
|
nscoord yoff = 0;
|
||||||
|
scrollingView->GetScrollPosition(xoff, yoff);
|
||||||
|
isHorizontal ? start += xoff : start += yoff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//printf("Diff=%d\n", pos);
|
nsRect r = parent->GetRect();
|
||||||
|
isHorizontal ? start -= r.x : start -= r.y;
|
||||||
ResizeType resizeAfter = GetResizeAfter();
|
parent = parent->GetParent();
|
||||||
|
|
||||||
PRBool bounded;
|
|
||||||
|
|
||||||
if (resizeAfter == nsSplitterFrameInner::Grow)
|
|
||||||
bounded = PR_FALSE;
|
|
||||||
else
|
|
||||||
bounded = PR_TRUE;
|
|
||||||
|
|
||||||
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();
|
|
||||||
CollapseDirection dir = GetCollapseDirection();
|
|
||||||
|
|
||||||
// if we are in a collapsed position
|
|
||||||
if (realTimeDrag && ((oldPos > 0 && oldPos > pos && dir == After) || (oldPos < 0 && oldPos < pos && dir == Before)))
|
|
||||||
{
|
|
||||||
// and we are not collapsed then collapse
|
|
||||||
if (currentState == Dragging) {
|
|
||||||
if (oldPos > 0 && oldPos > pos)
|
|
||||||
{
|
|
||||||
//printf("Collapse right\n");
|
|
||||||
if (GetCollapseDirection() == After)
|
|
||||||
{
|
|
||||||
mOuter->mContent->SetAttr(kNameSpaceID_None, nsXULAtoms::state, NS_LITERAL_STRING("collapsed"), PR_TRUE);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (oldPos < 0 && oldPos < pos)
|
|
||||||
{
|
|
||||||
//printf("Collapse left\n");
|
|
||||||
if (GetCollapseDirection() == Before)
|
|
||||||
{
|
|
||||||
mOuter->mContent->SetAttr(kNameSpaceID_None, nsXULAtoms::state, NS_LITERAL_STRING("collapsed"), PR_TRUE);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// if we are not in a collapsed position and we are not dragging make sure
|
|
||||||
// we are dragging.
|
|
||||||
if (currentState != Dragging)
|
|
||||||
mOuter->mContent->SetAttr(kNameSpaceID_None, nsXULAtoms::state, NS_LITERAL_STRING("dragging"), PR_TRUE);
|
|
||||||
|
|
||||||
if (realTimeDrag)
|
|
||||||
AdjustChildren(aPresContext);
|
|
||||||
else
|
|
||||||
MoveSplitterBy(aPresContext, pos);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// printf("----- resize ----- ");
|
|
||||||
/*
|
|
||||||
for (i=0; i < mChildInfosBeforeCount; i++)
|
|
||||||
printf("before, index=%d, current=%d, changed=%d\n", mChildInfosBefore[i].index, mChildInfosBefore[i].current, mChildInfosBefore[i].changed);
|
|
||||||
for (i=0; i < mChildInfosAfterCount; i++)
|
|
||||||
printf("after, index=%d, current=%d, changed=%d\n", mChildInfosAfter[i].index, mChildInfosAfter[i].current, mChildInfosAfter[i].changed);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
nsCOMPtr<nsIPresShell> shell;
|
|
||||||
aPresContext->GetShell(getter_AddRefs(shell));
|
|
||||||
|
|
||||||
nsCOMPtr<nsHTMLReflowCommand> reflowCmd;
|
|
||||||
nsresult rv = NS_NewHTMLReflowCommand(getter_AddRefs(reflowCmd), mOuter->mParent,
|
|
||||||
eReflowType_StyleChanged);
|
|
||||||
if (NS_SUCCEEDED(rv))
|
|
||||||
shell->AppendReflowCommand(reflowCmd);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIPresShell> shell;
|
|
||||||
aPresContext->GetShell(getter_AddRefs(shell));
|
|
||||||
|
|
||||||
mOuter->mState |= NS_FRAME_IS_DIRTY;
|
|
||||||
mOuter->mParent->ReflowDirtyChild(shell, mOuter);
|
|
||||||
*/
|
|
||||||
mDidDrag = PR_TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// take our current position and substract the start location
|
||||||
|
pos -= start;
|
||||||
|
|
||||||
|
//printf("Diff=%d\n", pos);
|
||||||
|
|
||||||
|
ResizeType resizeAfter = GetResizeAfter();
|
||||||
|
|
||||||
|
PRBool bounded;
|
||||||
|
|
||||||
|
if (resizeAfter == nsSplitterFrameInner::Grow)
|
||||||
|
bounded = PR_FALSE;
|
||||||
|
else
|
||||||
|
bounded = PR_TRUE;
|
||||||
|
|
||||||
|
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();
|
||||||
|
CollapseDirection dir = GetCollapseDirection();
|
||||||
|
|
||||||
|
// if we are in a collapsed position
|
||||||
|
if (realTimeDrag && ((oldPos > 0 && oldPos > pos && dir == After) || (oldPos < 0 && oldPos < pos && dir == Before)))
|
||||||
|
{
|
||||||
|
// and we are not collapsed then collapse
|
||||||
|
if (currentState == Dragging) {
|
||||||
|
if (oldPos > 0 && oldPos > pos)
|
||||||
|
{
|
||||||
|
//printf("Collapse right\n");
|
||||||
|
if (GetCollapseDirection() == After)
|
||||||
|
{
|
||||||
|
mOuter->mContent->SetAttr(kNameSpaceID_None, nsXULAtoms::state, NS_LITERAL_STRING("collapsed"), PR_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (oldPos < 0 && oldPos < pos)
|
||||||
|
{
|
||||||
|
//printf("Collapse left\n");
|
||||||
|
if (GetCollapseDirection() == Before)
|
||||||
|
{
|
||||||
|
mOuter->mContent->SetAttr(kNameSpaceID_None, nsXULAtoms::state, NS_LITERAL_STRING("collapsed"), PR_TRUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// if we are not in a collapsed position and we are not dragging make sure
|
||||||
|
// we are dragging.
|
||||||
|
if (currentState != Dragging)
|
||||||
|
mOuter->mContent->SetAttr(kNameSpaceID_None, nsXULAtoms::state, NS_LITERAL_STRING("dragging"), PR_TRUE);
|
||||||
|
if (realTimeDrag)
|
||||||
|
AdjustChildren(aPresContext);
|
||||||
|
else
|
||||||
|
MoveSplitterBy(aPresContext, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
// printf("----- resize ----- ");
|
||||||
|
/*
|
||||||
|
for (i=0; i < mChildInfosBeforeCount; i++)
|
||||||
|
printf("before, index=%d, current=%d, changed=%d\n", mChildInfosBefore[i].index, mChildInfosBefore[i].current, mChildInfosBefore[i].changed);
|
||||||
|
for (i=0; i < mChildInfosAfterCount; i++)
|
||||||
|
printf("after, index=%d, current=%d, changed=%d\n", mChildInfosAfter[i].index, mChildInfosAfter[i].current, mChildInfosAfter[i].changed);
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
nsCOMPtr<nsIPresShell> shell;
|
||||||
|
aPresContext->GetShell(getter_AddRefs(shell));
|
||||||
|
|
||||||
|
nsCOMPtr<nsHTMLReflowCommand> reflowCmd;
|
||||||
|
nsresult rv = NS_NewHTMLReflowCommand(getter_AddRefs(reflowCmd), mOuter->mParent,
|
||||||
|
eReflowType_StyleChanged);
|
||||||
|
if (NS_SUCCEEDED(rv))
|
||||||
|
shell->AppendReflowCommand(reflowCmd);
|
||||||
|
|
||||||
|
nsCOMPtr<nsIPresShell> shell;
|
||||||
|
aPresContext->GetShell(getter_AddRefs(shell));
|
||||||
|
|
||||||
|
mOuter->mState |= NS_FRAME_IS_DIRTY;
|
||||||
|
mOuter->mParent->ReflowDirtyChild(shell, mOuter);
|
||||||
|
*/
|
||||||
|
mDidDrag = PR_TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -683,7 +677,7 @@ nsSplitterFrameInner::RemoveListener()
|
||||||
nsresult
|
nsresult
|
||||||
nsSplitterFrameInner :: CaptureMouse(nsIPresContext* aPresContext, PRBool aGrabMouseEvents)
|
nsSplitterFrameInner :: CaptureMouse(nsIPresContext* aPresContext, PRBool aGrabMouseEvents)
|
||||||
{
|
{
|
||||||
// get its view
|
// get its view
|
||||||
nsIView* view = mOuter->GetView();
|
nsIView* view = mOuter->GetView();
|
||||||
PRBool result;
|
PRBool result;
|
||||||
|
|
||||||
|
@ -693,7 +687,7 @@ nsSplitterFrameInner :: CaptureMouse(nsIPresContext* aPresContext, PRBool aGrabM
|
||||||
// nsIWidget* widget = view->GetWidget();
|
// nsIWidget* widget = view->GetWidget();
|
||||||
if (aGrabMouseEvents) {
|
if (aGrabMouseEvents) {
|
||||||
viewMan->GrabMouseEvents(view,result);
|
viewMan->GrabMouseEvents(view,result);
|
||||||
// if (widget)
|
// if (widget)
|
||||||
// widget->CaptureMouse(PR_TRUE);
|
// widget->CaptureMouse(PR_TRUE);
|
||||||
} else {
|
} else {
|
||||||
viewMan->GrabMouseEvents(nsnull,result);
|
viewMan->GrabMouseEvents(nsnull,result);
|
||||||
|
@ -774,7 +768,7 @@ nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
EnsureOrient();
|
EnsureOrient();
|
||||||
PRBool isHorizontal = !mOuter->IsHorizontal();
|
PRBool isHorizontal = !mOuter->IsHorizontal();
|
||||||
|
|
||||||
ResizeType resizeBefore = GetResizeBefore();
|
ResizeType resizeBefore = GetResizeBefore();
|
||||||
|
@ -987,38 +981,37 @@ nsSplitterFrameInner::UpdateState()
|
||||||
|
|
||||||
if (newState == mState) {
|
if (newState == mState) {
|
||||||
// No change.
|
// No change.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CollapseDirection direction = GetCollapseDirection();
|
CollapseDirection direction = GetCollapseDirection();
|
||||||
if (direction != None) {
|
if (direction != None) {
|
||||||
nsIBox* splitter = mOuter;
|
nsIBox* splitter = mOuter;
|
||||||
// Find the splitter's immediate sibling.
|
// Find the splitter's immediate sibling.
|
||||||
nsIBox* splitterSibling =
|
nsIBox* splitterSibling =
|
||||||
nsFrameNavigator::GetChildBeforeAfter(mOuter->mPresContext, splitter,
|
nsFrameNavigator::GetChildBeforeAfter(mOuter->mPresContext, splitter,
|
||||||
(direction == Before));
|
(direction == Before));
|
||||||
if (splitterSibling) {
|
if (splitterSibling) {
|
||||||
nsIFrame* splitterSiblingFrame = nsnull;
|
nsIFrame* splitterSiblingFrame = nsnull;
|
||||||
splitterSibling->GetFrame(&splitterSiblingFrame);
|
splitterSibling->GetFrame(&splitterSiblingFrame);
|
||||||
nsIContent* sibling = splitterSiblingFrame->GetContent();
|
nsIContent* sibling = splitterSiblingFrame->GetContent();
|
||||||
if (sibling) {
|
if (sibling) {
|
||||||
if (mState == Collapsed) {
|
if (mState == Collapsed) {
|
||||||
// Collapsed -> Open
|
// Collapsed -> Open
|
||||||
// Collapsed -> Dragging
|
// Collapsed -> Dragging
|
||||||
sibling->UnsetAttr(kNameSpaceID_None, nsXULAtoms::collapsed,
|
sibling->UnsetAttr(kNameSpaceID_None, nsXULAtoms::collapsed,
|
||||||
PR_TRUE);
|
PR_TRUE);
|
||||||
} else if ((mState == Open || mState == Dragging)
|
} else if ((mState == Open || mState == Dragging)
|
||||||
&& newState == Collapsed) {
|
&& newState == Collapsed) {
|
||||||
// Open -> Collapsed
|
// Open -> Collapsed
|
||||||
// Dragging -> Collapsed
|
// Dragging -> Collapsed
|
||||||
sibling->SetAttr(kNameSpaceID_None, nsXULAtoms::collapsed,
|
sibling->SetAttr(kNameSpaceID_None, nsXULAtoms::collapsed,
|
||||||
NS_LITERAL_STRING("true"), PR_TRUE);
|
NS_LITERAL_STRING("true"), PR_TRUE);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mState = newState;
|
}
|
||||||
|
mState = newState;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1029,9 +1022,9 @@ nsSplitterFrameInner::EnsureOrient()
|
||||||
|
|
||||||
PRBool isHorizontal = !(frame->GetStateBits() & NS_STATE_IS_HORIZONTAL);
|
PRBool isHorizontal = !(frame->GetStateBits() & NS_STATE_IS_HORIZONTAL);
|
||||||
if (isHorizontal)
|
if (isHorizontal)
|
||||||
mOuter->mState |= NS_STATE_IS_HORIZONTAL;
|
mOuter->mState |= NS_STATE_IS_HORIZONTAL;
|
||||||
else
|
else
|
||||||
mOuter->mState &= ~NS_STATE_IS_HORIZONTAL;
|
mOuter->mState &= ~NS_STATE_IS_HORIZONTAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1047,7 +1040,7 @@ nsSplitterFrameInner::AdjustChildren(nsIPresContext* aPresContext)
|
||||||
// printf("----- Posting Dirty -----\n");
|
// printf("----- Posting Dirty -----\n");
|
||||||
|
|
||||||
|
|
||||||
if (realTimeDrag) {
|
if (realTimeDrag) {
|
||||||
nsCOMPtr<nsIPresShell> shell;
|
nsCOMPtr<nsIPresShell> shell;
|
||||||
aPresContext->GetShell(getter_AddRefs(shell));
|
aPresContext->GetShell(getter_AddRefs(shell));
|
||||||
nsIFrame* frame = nsnull;
|
nsIFrame* frame = nsnull;
|
||||||
|
@ -1065,45 +1058,44 @@ if (realTimeDrag) {
|
||||||
viewManager->DisableRefresh();
|
viewManager->DisableRefresh();
|
||||||
shell->FlushPendingNotifications(PR_FALSE);
|
shell->FlushPendingNotifications(PR_FALSE);
|
||||||
viewManager->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
|
viewManager->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
nsBoxLayoutState state(aPresContext);
|
nsBoxLayoutState state(aPresContext);
|
||||||
mOuter->MarkDirty(state);
|
mOuter->MarkDirty(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nsSplitterFrameInner::AdjustChildren(nsIPresContext* aPresContext, nsSplitterInfo* aChildInfos, PRInt32 aCount, PRBool aIsHorizontal)
|
nsSplitterFrameInner::AdjustChildren(nsIPresContext* aPresContext, nsSplitterInfo* aChildInfos, PRInt32 aCount, PRBool aIsHorizontal)
|
||||||
{
|
{
|
||||||
///printf("------- AdjustChildren------\n");
|
///printf("------- AdjustChildren------\n");
|
||||||
|
|
||||||
nsBoxLayoutState state(aPresContext);
|
nsBoxLayoutState state(aPresContext);
|
||||||
|
|
||||||
nsCOMPtr<nsIPresShell> shell;
|
nsCOMPtr<nsIPresShell> shell;
|
||||||
state.GetPresShell(getter_AddRefs(shell));
|
state.GetPresShell(getter_AddRefs(shell));
|
||||||
|
|
||||||
float p2t;
|
float p2t;
|
||||||
aPresContext->GetScaledPixelsToTwips(&p2t);
|
aPresContext->GetScaledPixelsToTwips(&p2t);
|
||||||
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
|
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
|
||||||
|
|
||||||
// first set all the widths.
|
// first set all the widths.
|
||||||
nsIBox* child = nsnull;
|
nsIBox* child = nsnull;
|
||||||
mOuter->GetChildBox(&child);
|
mOuter->GetChildBox(&child);
|
||||||
while(child)
|
while(child)
|
||||||
{
|
{
|
||||||
SetPreferredSize(state, child, onePixel, aIsHorizontal, nsnull);
|
SetPreferredSize(state, child, onePixel, aIsHorizontal, nsnull);
|
||||||
child->GetNextBox(&child);
|
child->GetNextBox(&child);
|
||||||
}
|
}
|
||||||
|
|
||||||
// now set our changed widths.
|
// now set our changed widths.
|
||||||
for (int i=0; i < aCount; i++)
|
for (int i=0; i < aCount; i++)
|
||||||
{
|
{
|
||||||
nscoord pref = aChildInfos[i].changed;
|
nscoord pref = aChildInfos[i].changed;
|
||||||
nsIBox* childBox = aChildInfos[i].child;
|
nsIBox* childBox = aChildInfos[i].child;
|
||||||
|
|
||||||
SetPreferredSize(state, childBox, onePixel, aIsHorizontal, &pref);
|
SetPreferredSize(state, childBox, onePixel, aIsHorizontal, &pref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1138,11 +1130,11 @@ nsSplitterFrameInner::SetPreferredSize(nsBoxLayoutState& aState, nsIBox* aChildB
|
||||||
nsCOMPtr<nsIAtom> attribute;
|
nsCOMPtr<nsIAtom> attribute;
|
||||||
|
|
||||||
if (aIsHorizontal) {
|
if (aIsHorizontal) {
|
||||||
pref -= (margin.left + margin.right);
|
pref -= (margin.left + margin.right);
|
||||||
attribute = nsHTMLAtoms::width;
|
attribute = nsHTMLAtoms::width;
|
||||||
} else {
|
} else {
|
||||||
pref -= (margin.top + margin.bottom);
|
pref -= (margin.top + margin.bottom);
|
||||||
attribute = nsHTMLAtoms::height;
|
attribute = nsHTMLAtoms::height;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIFrame* childFrame = nsnull;
|
nsIFrame* childFrame = nsnull;
|
||||||
|
@ -1178,19 +1170,19 @@ nsSplitterFrameInner::AddRemoveSpace(nscoord aDiff,
|
||||||
|
|
||||||
// figure our how much space to add or remove
|
// figure our how much space to add or remove
|
||||||
if (c + aDiff < min) {
|
if (c + aDiff < min) {
|
||||||
aDiff += (c - min);
|
aDiff += (c - min);
|
||||||
c = min;
|
c = min;
|
||||||
} else if (c + aDiff > max) {
|
} else if (c + aDiff > max) {
|
||||||
aDiff -= (max - c);
|
aDiff -= (max - c);
|
||||||
c = max;
|
c = max;
|
||||||
} else {
|
} else {
|
||||||
c += aDiff;
|
c += aDiff;
|
||||||
aDiff = 0;
|
aDiff = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// there is not space left? We are done
|
// there is not space left? We are done
|
||||||
if (aDiff == 0)
|
if (aDiff == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
aSpaceLeft = aDiff;
|
aSpaceLeft = aDiff;
|
||||||
|
@ -1241,13 +1233,13 @@ nsSplitterFrameInner::MoveSplitterBy(nsIPresContext* aPresContext, nscoord aDiff
|
||||||
EnsureOrient();
|
EnsureOrient();
|
||||||
PRBool isHorizontal = !mOuter->IsHorizontal();
|
PRBool isHorizontal = !mOuter->IsHorizontal();
|
||||||
if (isHorizontal) {
|
if (isHorizontal) {
|
||||||
mOuter->SetPosition(nsPoint(mSplitterPos + aDiff, r.y));
|
mOuter->SetPosition(nsPoint(mSplitterPos + aDiff, r.y));
|
||||||
vm->MoveViewTo(v, mSplitterViewPos + aDiff, vr.y);
|
vm->MoveViewTo(v, mSplitterViewPos + aDiff, vr.y);
|
||||||
invalid.UnionRect(r,mOuter->mRect);
|
invalid.UnionRect(r,mOuter->mRect);
|
||||||
} else {
|
} else {
|
||||||
mOuter->SetPosition(nsPoint(r.x, mSplitterPos + aDiff));
|
mOuter->SetPosition(nsPoint(r.x, mSplitterPos + aDiff));
|
||||||
vm->MoveViewTo(v, vr.x, mSplitterViewPos + aDiff);
|
vm->MoveViewTo(v, vr.x, mSplitterViewPos + aDiff);
|
||||||
invalid.UnionRect(r,mOuter->mRect);
|
invalid.UnionRect(r,mOuter->mRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
// redraw immediately only what changed. This is animation so
|
// redraw immediately only what changed. This is animation so
|
||||||
|
|
|
@ -157,8 +157,7 @@ nsTextBoxFrame::nsTextBoxFrame(nsIPresShell* aShell):nsLeafBoxFrame(aShell), mCr
|
||||||
|
|
||||||
nsTextBoxFrame::~nsTextBoxFrame()
|
nsTextBoxFrame::~nsTextBoxFrame()
|
||||||
{
|
{
|
||||||
if (mAccessKeyInfo)
|
delete mAccessKeyInfo;
|
||||||
delete mAccessKeyInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -733,8 +732,11 @@ nsTextBoxFrame::UpdateAccessIndex()
|
||||||
mAccessKeyInfo = nsnull;
|
mAccessKeyInfo = nsnull;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!mAccessKeyInfo)
|
if (!mAccessKeyInfo) {
|
||||||
mAccessKeyInfo = new nsAccessKeyInfo();
|
mAccessKeyInfo = new nsAccessKeyInfo();
|
||||||
|
if (!mAccessKeyInfo)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
nsAString::const_iterator start, end;
|
nsAString::const_iterator start, end;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче