Last Comment Bug 714976 - [mac] the Role description for the web content is AXWebArea instead of "HTML Content"
: [mac] the Role description for the web content is AXWebArea instead of "HTML ...
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: Disability Access APIs (show other bugs)
: Trunk
: x86 Mac OS X
: -- normal (vote)
: mozilla12
Assigned To: Hubert Figuiere [:hub]
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-01-03 15:01 PST by Hubert Figuiere [:hub]
Modified: 2012-01-19 13:47 PST (History)
5 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
proposed patch (1.53 KB, patch)
2012-01-03 15:53 PST, Hubert Figuiere [:hub]
no flags Details | Diff | Review
The role description should be HTML Content. r= (4.65 KB, patch)
2012-01-04 16:11 PST, Hubert Figuiere [:hub]
l10n: feedback+
Details | Diff | Review
The role description should be HTML Content. (5.48 KB, patch)
2012-01-05 18:26 PST, Hubert Figuiere [:hub]
no flags Details | Diff | Review
The role description should be HTML Content. (5.03 KB, patch)
2012-01-06 09:09 PST, Hubert Figuiere [:hub]
tbsaunde+mozbugs: review+
Details | Diff | Review
The role description should be HTML Content. (5.04 KB, patch)
2012-01-06 15:21 PST, Hubert Figuiere [:hub]
no flags Details | Diff | Review

Description Hubert Figuiere [:hub] 2012-01-03 15:01:08 PST
The Role description for the web content is AXWebArea instead of "HTML Content". This is not user friendly and Voice Over reads it. "You are inside a AXWebArea".

Safari use the word "HTML Content". Let's use that and ensure it is localized.
Comment 1 Hubert Figuiere [:hub] 2012-01-03 15:53:14 PST
Created attachment 585591 [details] [diff] [review]
proposed patch

Proposed patch, in principle. It is missing localization support has this string is "human readable" (actually read out loud by VoiceOver)
Comment 2 Hubert Figuiere [:hub] 2012-01-03 15:56:53 PST
bug 673689 will require changes to this patch (or vice versa).
Comment 3 Marco Zehe (:MarcoZ) 2012-01-04 00:19:09 PST
Comment on attachment 585591 [details] [diff] [review]
proposed patch

>+    if ((mRole == nsIAccessibleRole::ROLE_INTERNAL_FRAME) || (mRole == nsIAccessibleRole::ROLE_DOCUMENT_FRAME))

Just a nit: Put the part after the || onto a new line and make sure it is indented such that it startss at the same position as the second opening (.
Comment 4 Hubert Figuiere [:hub] 2012-01-04 14:22:46 PST
I have a new patch that deal with localization. Still missing a few bits for the strings, I'll update when it is solved.
Comment 5 Hubert Figuiere [:hub] 2012-01-04 16:11:01 PST
Created attachment 585932 [details] [diff] [review]
The role description should be HTML Content. r=
Comment 6 Trevor Saunders (:tbsaunde) 2012-01-04 19:33:25 PST
Comment on attachment 585932 [details] [diff] [review]
The role description should be HTML Content. r=


>+#include "nsAccessNode.h"

what for?

>+static NSString* 
>+GetMacLocalizedString(const nsString& aString)

drop the Mac part since its in mac/ of course its for mac stuff only

>+{
>+  nsresult rv;

declare at first use not here

>+  nsCOMPtr<nsIStringBundleService> bundleService =
>+      mozilla::services::GetStringBundleService();

use namespace mozilla and just services::GetBlah()

>+  
>+  if (!bundleService)

no blank line

>+    return nil;
>+  
>+  nsCOMPtr<nsIStringBundle> bundle;
>+  rv = bundleService->CreateBundle(ACCESSIBLE_BUNDLE_URL,
>+                                   getter_AddRefs(bundle));
>+  
>+  if (!NS_SUCCEEDED(rv))
>+    return nil;

no blank line, and I'd probably do NS_ENSURE_SUCCESS(rv, nil)

>+  
>+  nsString text;
>+  rv = bundle->GetStringFromName(aString.get(),
>+                                 getter_Copies(text));
>+  if (NS_SUCCEEDED(rv))
>+    return [NSString stringWithCharacters:text.BeginReading()
>+                                  length:text.Length()];

NS_ENSURE_SUCCESS again, then make the last return be the success one

>+static NSString* sAXWebAreaLocalizedRoleDescription = nil;

do you have numbers showing a need to cache this? I'm not sure if we need to support changing the language at run time, Axel?

>+  if ([attribute isEqualToString:NSAccessibilityRoleDescriptionAttribute]) {
>+    if ((mRole == nsIAccessibleRole::ROLE_INTERNAL_FRAME) 
>+        || (mRole == nsIAccessibleRole::ROLE_DOCUMENT_FRAME))
>+      return GetAXWebAreaLocalizedRoleDescription();
>     return NSAccessibilityRoleDescription([self role], nil);

blank line between returns
Comment 7 Hubert Figuiere [:hub] 2012-01-04 21:22:23 PST
(In reply to Trevor Saunders (:tbsaunde) from comment #6)
> Comment on attachment 585932 [details] [diff] [review]
> The role description should be HTML Content. r=
> 
> 
> >+#include "nsAccessNode.h"
> 
> what for?

for ACCESSIBLE_BUNDLE_URL

> >+  nsCOMPtr<nsIStringBundleService> bundleService =
> >+      mozilla::services::GetStringBundleService();
> 
> use namespace mozilla and just services::GetBlah()

I did it that way because it is done like that everywhere else.

Will address the rest.
Comment 8 Trevor Saunders (:tbsaunde) 2012-01-04 21:58:32 PST
(In reply to Hub Figuiere [:hub] from comment #7)
> (In reply to Trevor Saunders (:tbsaunde) from comment #6)
> > Comment on attachment 585932 [details] [diff] [review]
> > The role description should be HTML Content. r=
> > 
> > 
> > >+#include "nsAccessNode.h"
> > 
> > what for?
> 
> for ACCESSIBLE_BUNDLE_URL

ok, thanks

> > >+  nsCOMPtr<nsIStringBundleService> bundleService =
> > >+      mozilla::services::GetStringBundleService();
> > 
> > use namespace mozilla and just services::GetBlah()
> 
> I did it that way because it is done like that everywhere else.
> 
> Will address the rest.

so far as the ones in accessible/ we really should do it the way I suggested, but don't because of some weird historical accident involving timing or something.  Note some of the files where it occurs also have using namespace mozilla for other things anyway, but if you'd really prefer I gues we can fix them all together.
Comment 9 Hubert Figuiere [:hub] 2012-01-04 22:27:36 PST
I'll wait for the l10n feedback before submitting a new patch.
Comment 10 Axel Hecht [:Pike] 2012-01-05 00:45:49 PST
Comment on attachment 585932 [details] [diff] [review]
The role description should be HTML Content. r=

Review of attachment 585932 [details] [diff] [review]:
-----------------------------------------------------------------

Is there any concrete question you have?

::: dom/locales/en-US/chrome/accessibility/mac/accessible.properties
@@ +12,5 @@
>  activate=       Activate
>  cycle   =       Cycle
> +
> +# API
> +htmlContent = HTML Content

Not sure what the comment here means?
Comment 11 Marco Zehe (:MarcoZ) 2012-01-05 05:20:59 PST
(In reply to Axel Hecht [:Pike] from comment #10)
> Is there any concrete question you have?

I think the main reason we're looping you in here is because we want to make sure we're using the right approach for this kind of string. It is something that will be spoken by VoiceOver (the Mac screen reader for the blind) whenever a user navigates the Firefox UI and encounters the area where the actual web page is being rendered.

> 
> ::: dom/locales/en-US/chrome/accessibility/mac/accessible.properties
> @@ +12,5 @@
> >  activate=       Activate
> >  cycle   =       Cycle
> > +
> > +# API
> > +htmlContent = HTML Content
> 
> Not sure what the comment here means?

Yes the comment should be clearer, stating that this is spoken by VoiceOver when navigation lands on the web rendering area. This mirrors what VoiceOver says in this instance for Safari.
Comment 12 Axel Hecht [:Pike] 2012-01-05 06:23:30 PST
Comment on attachment 585932 [details] [diff] [review]
The role description should be HTML Content. r=

Looks OK to me.
Comment 13 Trevor Saunders (:tbsaunde) 2012-01-05 06:46:42 PST
(In reply to Axel Hecht [:Pike] from comment #10)
> Comment on attachment 585932 [details] [diff] [review]
> The role description should be HTML Content. r=
> 
> Review of attachment 585932 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> Is there any concrete question you have?

wel, see

> NS_ENSURE_SUCCESS again, then make the last return be the success one
> 
> >+static NSString* sAXWebAreaLocalizedRoleDescription = nil;
> 
> do you have numbers showing a need to cache this? I'm not sure if we need to
> support changing the language at run time, Axel?
Comment 14 Axel Hecht [:Pike] 2012-01-05 06:55:19 PST
Yes, you should support changing the language at runtime. Sorry, didn't find that question.
Comment 15 Hubert Figuiere [:hub] 2012-01-05 13:23:52 PST
(In reply to Axel Hecht [:Pike] from comment #10)

> ::: dom/locales/en-US/chrome/accessibility/mac/accessible.properties
> @@ +12,5 @@
> >  activate=       Activate
> >  cycle   =       Cycle
> > +
> > +# API
> > +htmlContent = HTML Content
> 
> Not sure what the comment here means?

Sorry. I have put a much nicer explanation in the next version of the patch.
Comment 16 Hubert Figuiere [:hub] 2012-01-05 13:24:47 PST
(In reply to Axel Hecht [:Pike] from comment #14)
> Yes, you should support changing the language at runtime. Sorry, didn't find
> that question.

How do you change the UI language on Mac while Firefox is running?
Comment 17 Axel Hecht [:Pike] 2012-01-05 13:26:15 PST
locale switcher addon or go into about:config and edit general.useragent.locale, and then open a new window. There's no restart required.
Comment 18 Axel Hecht [:Pike] 2012-01-05 13:26:37 PST
PS: of course, you need to have a langpack installed, too.
Comment 19 Hubert Figuiere [:hub] 2012-01-05 18:26:58 PST
Created attachment 586307 [details] [diff] [review]
The role description should be HTML Content.
Comment 20 Hubert Figuiere [:hub] 2012-01-05 18:39:41 PST
Comment on attachment 586307 [details] [diff] [review]
The role description should be HTML Content.

Updated with all the comments.

Including the caching of the string.
Comment 21 Hubert Figuiere [:hub] 2012-01-06 09:09:12 PST
Created attachment 586454 [details] [diff] [review]
The role description should be HTML Content.
Comment 22 Trevor Saunders (:tbsaunde) 2012-01-06 14:23:56 PST
Comment on attachment 586454 [details] [diff] [review]
The role description should be HTML Content.

>+  static nsIStringBundle *GetStringBundle()

obligatory nit for Alex type* not type *

>+    { return gStringBundle; }

I think it probably makes sense to stop caching this altogether, but lets leave that for its own bug.

>+  nsString text;

nsAutoString

>+  if ([attribute isEqualToString:NSAccessibilityRoleDescriptionAttribute]) {
>+    if ((mRole == nsIAccessibleRole::ROLE_INTERNAL_FRAME) 
>+        || (mRole == nsIAccessibleRole::ROLE_DOCUMENT_FRAME))
>+      return GetLocalizedString(NS_LITERAL_STRING("htmlContent")) ? : @"HTML Content";
>+
>     return NSAccessibilityRoleDescription([self role], nil);
>+  }
>   if ([attribute isEqualToString:NSAccessibilityDescriptionAttribute])

blank line after }

r=me with that fixed
Comment 23 Hubert Figuiere [:hub] 2012-01-06 14:52:16 PST
(In reply to Trevor Saunders (:tbsaunde) from comment #22)

> >+  nsString text;
> 
> nsAutoString

Not since I'm using it as an out argument for an XPCOM method call. Actually the proper type is nsXPIDLString.
Comment 24 Hubert Figuiere [:hub] 2012-01-06 15:21:32 PST
Created attachment 586590 [details] [diff] [review]
The role description should be HTML Content.
Comment 25 Dão Gottwald [:dao] 2012-01-11 04:55:25 PST
Add checkin-needed once this is reviewed.
Comment 26 Hubert Figuiere [:hub] 2012-01-11 07:12:43 PST
(In reply to Dão Gottwald [:dao] from comment #25)
> Add checkin-needed once this is reviewed.

It has been reviewed. See attachment 586454 [details] [diff] [review].
Comment 27 Marco Zehe (:MarcoZ) 2012-01-11 09:31:37 PST
Landed on the accessibility project branch:
http://hg.mozilla.org/projects/accessibility/rev/8f723d91fb82
Comment 28 Marco Zehe (:MarcoZ) 2012-01-12 04:57:47 PST
Landed on m-c: http://hg.mozilla.org/mozilla-central/rev/8f723d91fb82
Comment 29 Francesco Lodolo [:flod] - OFFLINE Jun 26-Jul 3 2012-01-12 23:31:00 PST
Any help finding this feature in Safari? I'd like to use the same localization used in Safari for consistency (if it's not awful).
Comment 30 Marco Zehe (:MarcoZ) 2012-01-13 00:49:27 PST
(In reply to flod (Francesco Lodolo) from comment #29)
> Any help finding this feature in Safari? I'd like to use the same
> localization used in Safari for consistency (if it's not awful).

Open Safari, turn on VoiceOver with Cmd+F5, and with Option+Ctrl+Left and RightArrow, navigate through the main window until you hear "HTML Content". At the bottom of the screen, you also get a visual representation of what VoiceOver speaks.
Comment 31 Francesco Lodolo [:flod] - OFFLINE Jun 26-Jul 3 2012-01-13 00:58:36 PST
Thanks a lot Marco :-)
Comment 32 alexander :surkov 2012-01-19 04:15:20 PST
Comment on attachment 586590 [details] [diff] [review]
The role description should be HTML Content.

Review of attachment 586590 [details] [diff] [review]:
-----------------------------------------------------------------

::: accessible/src/mac/mozAccessible.mm
@@ +138,5 @@
> +
> +  nsXPIDLString text;
> +  nsresult rv = nsAccessNode::GetStringBundle()->GetStringFromName(aString.get(),
> +                                 getter_Copies(text));
> +  NS_ENSURE_SUCCESS(rv, nil);

nsAccessible provides GetTranslatedString. Why don't you use it or change it the way you need it. Exposing stringBundle object doesn't look like a good idea.
Comment 33 Trevor Saunders (:tbsaunde) 2012-01-19 06:39:40 PST
> 
> ::: accessible/src/mac/mozAccessible.mm
> @@ +138,5 @@
> > +
> > +  nsXPIDLString text;
> > +  nsresult rv = nsAccessNode::GetStringBundle()->GetStringFromName(aString.get(),
> > +                                 getter_Copies(text));
> > +  NS_ENSURE_SUCCESS(rv, nil);
> 
> nsAccessible provides GetTranslatedString. Why don't you use it or change it

I think a util function that returns a mac string is fine, though perhaps wrapping nsAccessible::GetTranslatedString() makes more sense.

btw, objections to moving it into some util file?

> the way you need it. Exposing stringBundle object doesn't look like a good
> idea.

Well, I believe that we shouldn't be caching the string bundle like that in the first place, but I don't see one more user of it making that fix any harder.
Comment 34 alexander :surkov 2012-01-19 10:10:37 PST
(In reply to Trevor Saunders (:tbsaunde) from comment #33)
> > 
> > ::: accessible/src/mac/mozAccessible.mm
> > @@ +138,5 @@
> > > +
> > > +  nsXPIDLString text;
> > > +  nsresult rv = nsAccessNode::GetStringBundle()->GetStringFromName(aString.get(),
> > > +                                 getter_Copies(text));
> > > +  NS_ENSURE_SUCCESS(rv, nil);
> > 
> > nsAccessible provides GetTranslatedString. Why don't you use it or change it
> 
> I think a util function that returns a mac string is fine, 

that's ok if you plan to use it often, because otherwise I don't see a huge win GetLocalizedString over GetTranslatedString(text); nsCocoaUtils::ToNSString(text);.

> though perhaps
> wrapping nsAccessible::GetTranslatedString() makes more sense.
>
> btw, objections to moving it into some util file?

yep, if you like to expose some inline analogue. Technically I don't think it's good idea to keep this as a part of accessnode object, it belongs to accessibility service I'd say or utility as you suggest.
 
> > the way you need it. Exposing stringBundle object doesn't look like a good
> > idea.
> 
> Well, I believe that we shouldn't be caching the string bundle like that in
> the first place, but I don't see one more user of it making that fix any
> harder.

maybe we shouldn't.
Comment 35 Hubert Figuiere [:hub] 2012-01-19 12:25:55 PST
Lets fix the localization stuff with the patch for bug 712927
Comment 36 Hubert Figuiere [:hub] 2012-01-19 12:49:34 PST
Also with bug 712927, the StringBundle is no longer exposed outside the MacUtils.mm
Comment 37 Hubert Figuiere [:hub] 2012-01-19 12:59:30 PST
> > nsAccessible provides GetTranslatedString. Why don't you use it or change it
> 
> I think a util function that returns a mac string is fine, though perhaps
> wrapping nsAccessible::GetTranslatedString() makes more sense.

I'm fine with that but nsAccessible::GetTranslatedString() is protected...
Comment 38 Hubert Figuiere [:hub] 2012-01-19 13:47:11 PST
See attachment 589979 [details] [diff] [review] for bug 712927

Note You need to log in before you can comment on or make changes to this bug.