Bug 118851. Active Accessibility: return i18n compatible names again. r=jgaunt, sr=hewitt. Bug 119312. Active Accessibility: GetAccFocused needs to return the IAccessible for the currently focused node. r=jgaunt, sr=alecf

This commit is contained in:
aaronl%netscape.com 2002-01-12 00:23:06 +00:00
Родитель ffeeee071c
Коммит 39719216ba
9 изменённых файлов: 26 добавлений и 37 удалений

Просмотреть файл

@ -4,4 +4,5 @@ check = Check
uncheck = Uncheck
select = Select
open = Open
close = Close
close = Close
switch = Switch

Просмотреть файл

@ -572,7 +572,7 @@ NS_IMETHODIMP nsAccessible::GetAccChildCount(PRInt32 *aAccChildCount)
return NS_OK;
}
nsresult nsAccessible::GetTranslatedString(PRUnichar *aKey, nsAWritableString *aStringOut)
nsresult nsAccessible::GetTranslatedString(const nsAReadableString& aKey, nsAWritableString& aStringOut)
{
static nsCOMPtr<nsIStringBundle> stringBundle;
static PRBool firstTime = PR_TRUE;
@ -582,7 +582,6 @@ nsresult nsAccessible::GetTranslatedString(PRUnichar *aKey, nsAWritableString *a
nsresult rv;
nsCOMPtr<nsIStringBundleService> stringBundleService =
do_GetService(kStringBundleServiceCID, &rv);
// nsCOMPtr<nsIStringBundleService> stringBundleService(do_GetService(kStringBundleServiceCID, &rv));
if (!stringBundleService) {
NS_WARNING("ERROR: Failed to get StringBundle Service instance.\n");
return NS_ERROR_FAILURE;
@ -592,10 +591,10 @@ nsresult nsAccessible::GetTranslatedString(PRUnichar *aKey, nsAWritableString *a
nsXPIDLString xsValue;
if (!stringBundle ||
NS_FAILED(stringBundle->GetStringFromName(aKey, getter_Copies(xsValue))))
NS_FAILED(stringBundle->GetStringFromName(PromiseFlatString(aKey).get(), getter_Copies(xsValue))))
return NS_ERROR_FAILURE;
aStringOut->Assign(xsValue);
aStringOut.Assign(xsValue);
return NS_OK;
}
@ -709,33 +708,22 @@ NS_IMETHODIMP nsAccessible::GetAccState(PRUint32 *aAccState)
/* readonly attribute boolean accFocused; */
NS_IMETHODIMP nsAccessible::GetAccFocused(nsIAccessible * *aAccFocused)
{
*aAccFocused = nsnull;
nsCOMPtr<nsIAccessibilityService> accService(do_GetService("@mozilla.org/accessibilityService;1"));
nsCOMPtr<nsIDOMElement> focusedElement;
nsIFrame *frame = nsnull;
if (NS_SUCCEEDED(GetFocusedElement(getter_AddRefs(focusedElement)))) {
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
if (!shell) {
*aAccFocused = nsnull;
return NS_OK;
}
nsCOMPtr<nsIContent> content(do_QueryInterface(focusedElement));
if (shell && content)
shell->GetPrimaryFrameFor(content, &frame);
}
if (frame) {
nsCOMPtr<nsIAccessible> acc(do_QueryInterface(frame));
if (acc) {
*aAccFocused = acc;
if (accService && NS_SUCCEEDED(GetFocusedElement(getter_AddRefs(focusedElement)))) {
nsCOMPtr<nsIDOMNode> focusedNode(do_QueryInterface(focusedElement));
nsCOMPtr<nsIAccessible> accessible;
if (NS_SUCCEEDED(accService->GetAccessibleFor(focusedNode, getter_AddRefs(accessible)))) {
*aAccFocused = accessible;
NS_ADDREF(*aAccFocused);
return NS_OK;
}
}
*aAccFocused = nsnull;
return NS_OK;
return NS_ERROR_FAILURE;
}
/* nsIAccessible accGetChildAt (in long x, in long y); */

Просмотреть файл

@ -107,7 +107,7 @@ protected:
NS_IMETHOD CacheOptimizations(nsIAccessible *aParent, PRInt32 aSiblingIndex, nsIDOMNodeList *aSiblingList);
// helper method to verify frames
static PRBool IsCorrectFrameType(nsIFrame* aFrame, nsIAtom* aAtom);
static nsresult GetTranslatedString(PRUnichar *aKey, nsAWritableString *aStringOut);
static nsresult GetTranslatedString(const nsAReadableString& aKey, nsAWritableString& aStringOut);
void GetScreenOrigin(nsIPresContext *aPresContext, nsIFrame *aFrame, nsRect *aRect);
// Data Members

Просмотреть файл

@ -281,7 +281,7 @@ NS_IMETHODIMP nsLinkableAccessible::GetAccActionName(PRUint8 index, nsAWritableS
// Action 0 (default action): Jump to link
if (index == eAction_Jump) {
if (IsALink()) {
_retval = NS_LITERAL_STRING("jump");
nsAccessible::GetTranslatedString(NS_LITERAL_STRING("jump"), _retval);
return NS_OK;
}
}

Просмотреть файл

@ -162,7 +162,7 @@ NS_IMETHODIMP nsRadioButtonAccessible::GetAccNumActions(PRUint8 *_retval)
NS_IMETHODIMP nsRadioButtonAccessible::GetAccActionName(PRUint8 index, nsAWritableString& _retval)
{
if (index == eAction_Click) {
_retval = NS_LITERAL_STRING("select");
nsAccessible::GetTranslatedString(NS_LITERAL_STRING("select"), _retval);
return NS_OK;
}
return NS_ERROR_INVALID_ARG;

Просмотреть файл

@ -535,9 +535,9 @@ NS_IMETHODIMP nsComboboxButtonAccessible::GetAccActionName(PRUint8 index, nsAWri
return NS_ERROR_FAILURE;
comboFrame->IsDroppedDown(&isOpen);
if (isOpen)
_retval = NS_LITERAL_STRING("close");
nsAccessible::GetTranslatedString(NS_LITERAL_STRING("close"), _retval);
else
_retval = NS_LITERAL_STRING("open");
nsAccessible::GetTranslatedString(NS_LITERAL_STRING("open"), _retval);
return NS_OK;
}

Просмотреть файл

@ -84,9 +84,9 @@ NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccActionName(PRUint8 index, nsAWrita
GetAccState(&state);
if (state & STATE_CHECKED)
_retval = NS_LITERAL_STRING("uncheck");
nsAccessible::GetTranslatedString(NS_LITERAL_STRING("uncheck"), _retval);
else
_retval = NS_LITERAL_STRING("check");
nsAccessible::GetTranslatedString(NS_LITERAL_STRING("check"), _retval);
return NS_OK;
}
@ -171,7 +171,7 @@ NS_IMETHODIMP nsHTMLButtonAccessible::GetAccNumActions(PRUint8 *_retval)
NS_IMETHODIMP nsHTMLButtonAccessible::GetAccActionName(PRUint8 index, nsAWritableString& _retval)
{
if (index == eAction_Click) {
_retval = NS_LITERAL_STRING("press");
nsAccessible::GetTranslatedString(NS_LITERAL_STRING("press"), _retval);
return NS_OK;
}
return NS_ERROR_INVALID_ARG;
@ -225,7 +225,7 @@ NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccNumActions(PRUint8 *_retval)
NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccActionName(PRUint8 index, nsAWritableString& _retval)
{
if (index == eAction_Click) {
_retval = NS_LITERAL_STRING("press");
nsAccessible::GetTranslatedString(NS_LITERAL_STRING("press"), _retval);
return NS_OK;
}
return NS_ERROR_INVALID_ARG;

Просмотреть файл

@ -88,7 +88,7 @@ NS_IMETHODIMP nsXULButtonAccessible::GetAccNumActions(PRUint8 *_retval)
NS_IMETHODIMP nsXULButtonAccessible::GetAccActionName(PRUint8 index, nsAWritableString& _retval)
{
if (index == eAction_Click) {
_retval = NS_LITERAL_STRING("press");
nsAccessible::GetTranslatedString(NS_LITERAL_STRING("press"), _retval);
return NS_OK;
}
return NS_ERROR_INVALID_ARG;

Просмотреть файл

@ -74,7 +74,7 @@ NS_IMETHODIMP nsXULTabAccessible::GetAccNumActions(PRUint8 *_retval)
NS_IMETHODIMP nsXULTabAccessible::GetAccActionName(PRUint8 index, nsAWritableString& _retval)
{
if (index == eAction_Click) {
_retval = NS_LITERAL_STRING("switch");
nsAccessible::GetTranslatedString(NS_LITERAL_STRING("switch"), _retval);
return NS_OK;
}
return NS_ERROR_INVALID_ARG;