From 0ab4b2d080a5318799450d6341e25d85655892c8 Mon Sep 17 00:00:00 2001 From: "aaronleventhal@moonset.net" Date: Mon, 11 Feb 2008 04:22:56 -0800 Subject: [PATCH] Bug 415944. Avoid screen readers speaking password text. r=surkov, a=schrep --- accessible/src/html/nsHyperTextAccessible.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/accessible/src/html/nsHyperTextAccessible.cpp b/accessible/src/html/nsHyperTextAccessible.cpp index 390a5223ff07..90f36ce68ce0 100644 --- a/accessible/src/html/nsHyperTextAccessible.cpp +++ b/accessible/src/html/nsHyperTextAccessible.cpp @@ -343,6 +343,9 @@ nsHyperTextAccessible::GetPosAndText(PRInt32& aStartOffset, PRInt32& aEndOffset, PRInt32 startOffset = aStartOffset; PRInt32 endOffset = aEndOffset; + // XXX this prevents text interface usage on + // but work is needed on aria-secret (which may be removed) + PRBool isPassword = (Role(this) == nsIAccessibleRole::ROLE_PASSWORD_TEXT); // Clear out parameters and set up loop if (aText) { @@ -433,9 +436,15 @@ nsHyperTextAccessible::GetPosAndText(PRInt32& aStartOffset, PRInt32& aEndOffset, aEndOffset = endOffset; } if (aText) { - nsCOMPtr pAcc(do_QueryInterface(accessible)); - pAcc->AppendTextTo(*aText, startOffset, - substringEndOffset - startOffset); + if (isPassword) { + for (PRInt32 count = startOffset; count < substringEndOffset; count ++) + *aText += '*'; // Show *'s only for password text + } + else { + nsCOMPtr pAcc(do_QueryInterface(accessible)); + pAcc->AppendTextTo(*aText, startOffset, + substringEndOffset - startOffset); + } } if (aBoundsRect) { // Caller wants the bounds of the text aBoundsRect->UnionRect(*aBoundsRect,