mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 17:25:36 +00:00
Keyboard navigation is online.
This commit is contained in:
parent
78bda58ee6
commit
04b1b1dc8f
@ -255,10 +255,8 @@ nsTreeCellFrame::HandleMouseExitEvent(nsIPresContext& aPresContext,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTreeCellFrame::HandleDoubleClickEvent(nsIPresContext& aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus& aEventStatus)
|
||||
void
|
||||
nsTreeCellFrame::ToggleOpenClose()
|
||||
{
|
||||
if (!mIsHeader)
|
||||
{
|
||||
@ -272,7 +270,7 @@ nsTreeCellFrame::HandleDoubleClickEvent(nsIPresContext& aPresContext,
|
||||
nsCOMPtr<nsIDOMElement> treeItem( do_QueryInterface(treeItemContent) );
|
||||
NS_ASSERTION(treeItem, "not a DOM element");
|
||||
if (! treeItem)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
return;
|
||||
|
||||
// Take the tree item content and toggle the value of its open attribute.
|
||||
nsAutoString attrValue;
|
||||
@ -290,6 +288,72 @@ nsTreeCellFrame::HandleDoubleClickEvent(nsIPresContext& aPresContext,
|
||||
treeItem->SetAttribute("open", "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsTreeCellFrame::Open()
|
||||
{
|
||||
if (!mIsHeader)
|
||||
{
|
||||
// Perform an expand/collapse
|
||||
// Iterate up the chain to the row and then to the item.
|
||||
nsCOMPtr<nsIContent> treeItemContent;
|
||||
nsCOMPtr<nsIContent> treeRowContent;
|
||||
mContent->GetParent(*getter_AddRefs(treeRowContent));
|
||||
treeRowContent->GetParent(*getter_AddRefs(treeItemContent));
|
||||
|
||||
nsCOMPtr<nsIDOMElement> treeItem( do_QueryInterface(treeItemContent) );
|
||||
NS_ASSERTION(treeItem, "not a DOM element");
|
||||
if (! treeItem)
|
||||
return;
|
||||
|
||||
// Take the tree item content and toggle the value of its open attribute.
|
||||
nsAutoString attrValue;
|
||||
nsresult result = treeItem->GetAttribute("open", attrValue);
|
||||
attrValue.ToLowerCase();
|
||||
PRBool isExpanded = (attrValue=="true");
|
||||
if (!isExpanded) {
|
||||
// We're expanding and need to add frames to the flow.
|
||||
treeItem->SetAttribute("open", "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsTreeCellFrame::Close()
|
||||
{
|
||||
if (!mIsHeader)
|
||||
{
|
||||
// Perform an expand/collapse
|
||||
// Iterate up the chain to the row and then to the item.
|
||||
nsCOMPtr<nsIContent> treeItemContent;
|
||||
nsCOMPtr<nsIContent> treeRowContent;
|
||||
mContent->GetParent(*getter_AddRefs(treeRowContent));
|
||||
treeRowContent->GetParent(*getter_AddRefs(treeItemContent));
|
||||
|
||||
nsCOMPtr<nsIDOMElement> treeItem( do_QueryInterface(treeItemContent) );
|
||||
NS_ASSERTION(treeItem, "not a DOM element");
|
||||
if (! treeItem)
|
||||
return;
|
||||
|
||||
// Take the tree item content and toggle the value of its open attribute.
|
||||
nsAutoString attrValue;
|
||||
nsresult result = treeItem->GetAttribute("open", attrValue);
|
||||
attrValue.ToLowerCase();
|
||||
PRBool isExpanded = (attrValue=="true");
|
||||
if (isExpanded) {
|
||||
// We're expanding and need to add frames to the flow.
|
||||
treeItem->RemoveAttribute("open");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTreeCellFrame::HandleDoubleClickEvent(nsIPresContext& aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus& aEventStatus)
|
||||
{
|
||||
ToggleOpenClose();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,10 @@ public:
|
||||
|
||||
void SetAllowEvents(PRBool allowEvents) { mAllowEvents = allowEvents; };
|
||||
|
||||
void ToggleOpenClose();
|
||||
void Open();
|
||||
void Close();
|
||||
|
||||
protected:
|
||||
nsTreeCellFrame();
|
||||
virtual ~nsTreeCellFrame();
|
||||
|
@ -142,7 +142,10 @@ nsTreeFrame::HandleEvent(nsIPresContext& aPresContext,
|
||||
nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent;
|
||||
PRUint32 keyCode = keyEvent->keyCode;
|
||||
if (keyCode == NS_VK_UP ||
|
||||
keyCode == NS_VK_DOWN) {
|
||||
keyCode == NS_VK_DOWN ||
|
||||
keyCode == NS_VK_LEFT ||
|
||||
keyCode == NS_VK_RIGHT ||
|
||||
keyCode == NS_VK_ENTER) {
|
||||
|
||||
// Get our treechildren child frame.
|
||||
nsTreeRowGroupFrame* treeRowGroup = nsnull;
|
||||
@ -204,8 +207,15 @@ nsTreeFrame::HandleEvent(nsIPresContext& aPresContext,
|
||||
if (!cellFrame)
|
||||
return NS_OK; // No cell. Whatever. Bail.
|
||||
|
||||
// We got it! Perform the selection.
|
||||
SetSelection(aPresContext, cellFrame);
|
||||
// We got it! Perform the selection on an up/down.
|
||||
if (keyCode == NS_VK_UP || keyCode == NS_VK_DOWN)
|
||||
SetSelection(aPresContext, cellFrame);
|
||||
else if (keyCode == NS_VK_ENTER || keyCode == NS_VK_RETURN)
|
||||
cellFrame->ToggleOpenClose();
|
||||
else if (keyCode == NS_VK_LEFT)
|
||||
cellFrame->Close();
|
||||
else if (keyCode == NS_VK_RIGHT)
|
||||
cellFrame->Open();
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -650,15 +650,15 @@ nsTreeRowGroupFrame::ReflowAfterRowLayout(nsIPresContext& aPresContext,
|
||||
mScrollbar = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ComputeVisibleRowCount(mRowCount, mContent); // XXX This sucks! Needs to be cheap!
|
||||
|
||||
if (mShouldHaveScrollbar && (mRowGroupHeight != NS_UNCONSTRAINEDSIZE) &&
|
||||
mIsFull) {
|
||||
// Ensure the scrollbar has been created.
|
||||
if (!mScrollbar)
|
||||
CreateScrollbar(aPresContext);
|
||||
|
||||
ComputeVisibleRowCount(mRowCount, mContent); // XXX This sucks! Needs to be cheap!
|
||||
|
||||
// Set the maxpos of the scrollbar.
|
||||
nsCOMPtr<nsIContent> scrollbarContent;
|
||||
mScrollbar->GetContent(getter_AddRefs(scrollbarContent));
|
||||
|
Loading…
Reference in New Issue
Block a user