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