Closed Bug 110422 Opened 23 years ago Closed 23 years ago

Active Accessibility: Optimize nsIAccessibleProvider implementations in XBL

Categories

(SeaMonkey :: General, defect, P4)

x86
Windows 2000
defect

Tracking

(Not tracked)

RESOLVED FIXED
mozilla0.9.8

People

(Reporter: aaronlev, Assigned: mozilla)

Details

(Keywords: access)

Attachments

(1 file, 2 obsolete files)

Jag has suggested some javascript improvements for the same lines of code we
repeated in many XBL bindings:

var accService =
Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
return (accService? accService.createXULTextAccessible(this): null);

Quoted from Jag:

There is no need to check whether accService is null. If anything fails, an
exception will be thrown and you'll never reach that line, so:

var accService =
Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
return accService.createXULTextAccessible(this);

This is assuming that in normal situations the getService won't fail. If there's
a chance this service isn't included while these xul widgets are, you'll need to
do something like:

const ACCESSIBILITYSERVICE_CONTRACTID = "@mozilla.org/accessibilityService;1";
if (ACCESSIBILITYSERVICE_CONTRACTID in Components.classes) {
 var accService =
Components.classes[(ACCESSIBILITYSERVICE_CONTRACTID].getService(Components.interfaces.nsIAccessibilityService);
 return accService.createXULTextAccessible(this);
}
return null;

===================
Brendan, what do you think?
Keywords: access
Whiteboard: Waiting for Brendan's feedback
Priority: -- → P4
Target Milestone: --- → Future
Brendan, do you have any comments on the javascript recommended here?
Sure, jag has good JS fu.  I don't need to bless his advice, in general.  Yes,
use const.  Use the in operator when you need to (and not otherwise!).  And let
exceptions get thrown.

/be
-> John
Assignee: aaronl → jgaunt
Whiteboard: Waiting for Brendan's feedback
building right now to test these.
Hmmm...finally got a build completed and testing this approach. It totally
breaks venkman because it doesn't call through the MSAA api, but just enumerates
all the JS properties. So there is no service and kerplunk, kerpluey.

I'll be going with door #2 then, and will be posting a patch shortly.

btw - I think I see a significant increase in the speed of gettin accessible
objects with this fix right now, unfortunatly  I think door # 2 is going to slow
us back down.
Status: NEW → ASSIGNED
Target Milestone: Future → mozilla0.9.8
Attached patch patch using door #2, (obsolete) — Splinter Review
doesn't cause venkman fits ( Yay! ) but I don't think it's really a performance
win.

trading one comparison for an additional variable and a comparison.

Is the old way really that bad?
Attachment #64350 - Attachment is obsolete: true
Comment on attachment 64425 [details] [diff] [review]
patch using door #2,

r=rginda
Attachment #64425 - Flags: review+
As jag mentioned, the old way had a useless test.  If your service wasn't there,
you never would have reached the ?: test.

I'm not sure why the exception caused a problem for venkman though.  Is the code
that calls into this XBL not dealing with the exception properly?
Comment on attachment 64425 [details] [diff] [review]
patch using door #2,

revoking r= per discussion with jgaunt
Attachment #64425 - Flags: review+
After some closer investigation spurred on by rginda, it turns out I was wrong.
It was causing venkman problems. So we get the perf win. Yay!

Also taking out a WARN_IF_FALSE that pops up and replacing with a regular if
statement.
Attachment #64425 - Attachment is obsolete: true
Comment on attachment 64437 [details] [diff] [review]
My bad, back to the original diff

sr=jag
Attachment #64437 - Flags: superreview+
Though I'm surprised you're seeing a significant increase, you're only removing
one ?: statement.
Comment on attachment 64437 [details] [diff] [review]
My bad, back to the original diff

r=rginda
Attachment #64437 - Flags: review+
checked in to the trunk
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Product: Browser → Seamonkey
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: