From 3aa794ee3cbc5ac3747001d8fc9c1e81b77f2329 Mon Sep 17 00:00:00 2001 From: "aaronleventhal%moonset.net" Date: Thu, 8 Feb 2007 19:48:32 +0000 Subject: [PATCH] Bug 365866. Expose appropriate tree table state, name and actions for cells that are checkboxes and cyclers. Patch by david.bolter@utoronto.ca. r=aaronlev, r=surkov, r=bienvenu, sr=mscott --- accessible/src/xul/nsXULTreeAccessible.cpp | 44 ++++++++++++++----- .../accessibility/mac/accessible.properties | 1 + .../accessibility/unix/accessible.properties | 1 + .../accessibility/win/accessible.properties | 1 + .../chrome/messenger/messenger.properties | 9 ++++ mailnews/base/src/nsMsgDBView.cpp | 40 ++++++++++++++++- 6 files changed, 84 insertions(+), 12 deletions(-) diff --git a/accessible/src/xul/nsXULTreeAccessible.cpp b/accessible/src/xul/nsXULTreeAccessible.cpp index 37c0b98186a..4f1b0ed1915 100644 --- a/accessible/src/xul/nsXULTreeAccessible.cpp +++ b/accessible/src/xul/nsXULTreeAccessible.cpp @@ -547,7 +547,14 @@ NS_IMETHODIMP nsXULTreeitemAccessible::Shutdown() NS_IMETHODIMP nsXULTreeitemAccessible::GetName(nsAString& aName) { NS_ENSURE_TRUE(mTree && mTreeView, NS_ERROR_FAILURE); - return mTreeView->GetCellText(mRow, mColumn, aName); + mTreeView->GetCellText(mRow, mColumn, aName); + + // if still no name try cell value + if (aName.IsEmpty()) { + mTreeView->GetCellValue(mRow, mColumn, aName); + } + + return NS_OK; } NS_IMETHODIMP nsXULTreeitemAccessible::GetUniqueID(void **aUniqueID) @@ -614,7 +621,7 @@ NS_IMETHODIMP nsXULTreeitemAccessible::GetState(PRUint32 *_retval) return NS_OK; } -// "activate" action is available for all treeitems +// "activate" (xor "cycle") action is available for all treeitems // "expand/collapse" action is avaible for treeitem which is container NS_IMETHODIMP nsXULTreeitemAccessible::GetNumActions(PRUint8 *_retval) { @@ -632,10 +639,17 @@ NS_IMETHODIMP nsXULTreeitemAccessible::GetNumActions(PRUint8 *_retval) // Return the name of our actions NS_IMETHODIMP nsXULTreeitemAccessible::GetActionName(PRUint8 index, nsAString& _retval) { - NS_ENSURE_TRUE(mTree && mTreeView, NS_ERROR_FAILURE); + NS_ENSURE_TRUE(mColumn && mTree && mTreeView, NS_ERROR_FAILURE); if (index == eAction_Click) { - nsAccessible::GetTranslatedString(NS_LITERAL_STRING("activate"), _retval); + PRBool isCycler; + mColumn->GetCycler(&isCycler); + if (isCycler) { + nsAccessible::GetTranslatedString(NS_LITERAL_STRING("cycle"), _retval); + } + else { + nsAccessible::GetTranslatedString(NS_LITERAL_STRING("activate"), _retval); + } return NS_OK; } else if (index == eAction_Expand) { @@ -754,16 +768,24 @@ NS_IMETHODIMP nsXULTreeitemAccessible::GetPreviousSibling(nsIAccessible **aPrevi NS_IMETHODIMP nsXULTreeitemAccessible::DoAction(PRUint8 index) { - NS_ENSURE_TRUE(mTree && mTreeView, NS_ERROR_FAILURE); + NS_ENSURE_TRUE(mColumn && mTree && mTreeView, NS_ERROR_FAILURE); if (index == eAction_Click) { - nsCOMPtr selection; - mTreeView->GetSelection(getter_AddRefs(selection)); - if (selection) { - nsresult rv = selection->Select(mRow); - mTree->EnsureRowIsVisible(mRow); - return rv; + nsresult rv = NS_OK; + PRBool isCycler; + mColumn->GetCycler(&isCycler); + if (isCycler) { + rv = mTreeView->CycleCell(mRow, mColumn); + } + else { + nsCOMPtr selection; + mTreeView->GetSelection(getter_AddRefs(selection)); + if (selection) { + rv = selection->Select(mRow); + mTree->EnsureRowIsVisible(mRow); + } } + return rv; } else if (index == eAction_Expand) { PRBool isContainer; diff --git a/dom/locales/en-US/chrome/accessibility/mac/accessible.properties b/dom/locales/en-US/chrome/accessibility/mac/accessible.properties index 5563b016b21..d9b15749eb7 100644 --- a/dom/locales/en-US/chrome/accessibility/mac/accessible.properties +++ b/dom/locales/en-US/chrome/accessibility/mac/accessible.properties @@ -10,3 +10,4 @@ click = Click collapse= Collapse expand = Expand activate= Activate +cycle = Cycle diff --git a/dom/locales/en-US/chrome/accessibility/unix/accessible.properties b/dom/locales/en-US/chrome/accessibility/unix/accessible.properties index 5563b016b21..d9b15749eb7 100644 --- a/dom/locales/en-US/chrome/accessibility/unix/accessible.properties +++ b/dom/locales/en-US/chrome/accessibility/unix/accessible.properties @@ -10,3 +10,4 @@ click = Click collapse= Collapse expand = Expand activate= Activate +cycle = Cycle diff --git a/dom/locales/en-US/chrome/accessibility/win/accessible.properties b/dom/locales/en-US/chrome/accessibility/win/accessible.properties index 5563b016b21..d9b15749eb7 100644 --- a/dom/locales/en-US/chrome/accessibility/win/accessible.properties +++ b/dom/locales/en-US/chrome/accessibility/win/accessible.properties @@ -10,3 +10,4 @@ click = Click collapse= Collapse expand = Expand activate= Activate +cycle = Cycle diff --git a/mail/locales/en-US/chrome/messenger/messenger.properties b/mail/locales/en-US/chrome/messenger/messenger.properties index 9a20b34bbdf..0d007251925 100644 --- a/mail/locales/en-US/chrome/messenger/messenger.properties +++ b/mail/locales/en-US/chrome/messenger/messenger.properties @@ -120,6 +120,15 @@ errorGettingDB=Unable to open the summary file for %S. Perhaps there was an erro defaultServerTag=(Default) useDefaultServer=Use default server +# Used in message database list view to provide a text value for graphic based cells. +messageRead=Read +messageUnread=Unread +messageHasFlag=Starred +messageHasNoFlag=Not Starred +messageHasAttachment=Has Attachment +messageHasNoAttachment=No Attachment + + # Used in the SMTP Account Settings panel when a server value has no properties smtpServerList-NotSpecified= smtpServer-SecureConnection-Type-0=None diff --git a/mailnews/base/src/nsMsgDBView.cpp b/mailnews/base/src/nsMsgDBView.cpp index 26650312936..6635cacc265 100644 --- a/mailnews/base/src/nsMsgDBView.cpp +++ b/mailnews/base/src/nsMsgDBView.cpp @@ -1526,7 +1526,45 @@ nsMsgDBView::GetProgressMode(PRInt32 aRow, nsITreeColumn* aCol, PRInt32* _retval NS_IMETHODIMP nsMsgDBView::GetCellValue(PRInt32 aRow, nsITreeColumn* aCol, nsAString& aValue) { - return NS_OK; + nsCOMPtr msgHdr; + nsresult rv = GetMsgHdrForViewIndex(aRow, getter_AddRefs(msgHdr)); + + if (NS_FAILED(rv) || !msgHdr) + { + ClearHdrCache(); + return NS_MSG_INVALID_DBVIEW_INDEX; + } + + const PRUnichar* colID; + aCol->GetIdConst(&colID); + + PRUint32 flags; + msgHdr->GetFlags(&flags); + + // provide a string "value" for cells that do not normally have text. + switch (colID[0]) + { + case 'a': // attachment column + aValue.Assign(GetString ((flags & MSG_FLAG_ATTACHMENT) ? + NS_LITERAL_STRING("messageHasAttachment").get() + : NS_LITERAL_STRING("messageHasNoAttachment").get())); + break; + case 'f': // flagged (starred) column + aValue.Assign(GetString ((flags & MSG_FLAG_MARKED) ? + NS_LITERAL_STRING("messageHasFlag").get() + : NS_LITERAL_STRING("messageHasNoFlag").get())); + break; + case 'u': // read/unread column + aValue.Assign(GetString ((flags & MSG_FLAG_READ) ? + NS_LITERAL_STRING("messageRead").get() + : NS_LITERAL_STRING("messageUnread").get())); + break; + default: + aValue.Assign(colID); + break; + } + + return rv; } //add a custom column handler