Closed Bug 381312 Opened 17 years ago Closed 17 years ago

implement IAccessibleRelation

Categories

(Core :: Disability Access APIs, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: surkov, Assigned: surkov)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 2 obsolete files)

Attached patch patch (obsolete) — Splinter Review
Implementation of IAccessilbeRelation::get_targets and IAccessible::get_relations has wrong initialization of returned array. I can't get how to initialize it correctly, is it mismatch of IA2 API or do I get brake?
Attachment #265409 - Flags: superreview?(neil)
Attachment #265409 - Flags: review?(aaronleventhal)
Comment on attachment 265409 [details] [diff] [review]
patch

Looks good. Is the prefix "unk" on unkTargets and unkRelations short for "unknown"?
Attachment #265409 - Flags: review?(aaronleventhal) → review+
Summary: implemnnt IAccessibleRelation → implement IAccessibleRelation
I suppose I should not put r+ if you say your arrays are incorrectly initialized. Could you be more specific as to what is wrong?
Comment on attachment 265409 [details] [diff] [review]
patch

>+// IUnknown
>+
>+STDMETHODIMP
>+nsAccessibleRelationWrap::QueryInterface(REFIID iid, void** ppv)
>+{
>+  *ppv = NULL;
>+
>+  if (IID_IAccessibleRelation == iid) {
|| IUnknown == iid ?

>+  rv =  winAccessNode->QueryNativeInterface(IID_IUnknown, &instancePtr);
Nits: two spaces after =

>+  IUnknown **unkTargets = new IUnknown*[count];
Don't you have to use CoTaskMemAlloc for these?

>+    nsCOMPtr<nsIAccessible> target;
>+    rv = targets->QueryElementAt(index, NS_GET_IID(nsIAccessible),
>+                                 getter_AddRefs(target));
>+    if (NS_FAILED(rv))
>+      return E_FAIL;
>+
>+    nsCOMPtr<nsIWinAccessNode> winAccessNode(do_QueryInterface(target));
>+    if (!winAccessNode)
>+      return E_FAIL;
I don't see the point of going via nsIAccessible. Just use
nsCOMPtr<nsIWinAccessNode> winAccessNode(do_QueryElementAt(targets, index, &rv));

>+    if (NS_FAILED(rv))
>+      return E_FAIL;
You need to release the previous elements and free the memory or you will leak.
Attachment #265409 - Flags: superreview?(neil) → superreview-
(In reply to comment #2)
> I suppose I should not put r+ if you say your arrays are incorrectly
> initialized. Could you be more specific as to what is wrong?
> 

Let's consider get_targets(long aMaxTargets, IUnknown **aTarget, ..). If I'd like to return an object pointer then I should initialize *aTarget. Therefore if I like to return array of IUnknown* then I should initialize ***aTarget. Correct?

In the patch I do *aTarget = *unkTargets. It means I return first IUnknown pointer and the client can't get another IUnknowns.
(In reply to comment #1)
> (From update of attachment 265409 [details] [diff] [review])
> Looks good. Is the prefix "unk" on unkTargets and unkRelations short for
> "unknown"?
> 

yes
(In reply to comment #4)
>Let's consider get_targets(long aMaxTargets, IUnknown **aTarget, ..). If I'd
>like to return an object pointer then I should initialize *aTarget. Therefore
>if I like to return array of IUnknown* then I should initialize ***aTarget.
>Correct?
Well, that's how it works in XPCOM but MSCOM might be different. Unfortunately I don't know MSCOM so I'm having to guess here but assuming your declaration of aTarget is correct then it would appear that the caller has already allocated an array of size aMaxTargets and you merely have to write the elements in. There is also the question of who should release the elements if there is an error.
The caller is responsible for allocating the array. Mozilla is responsible for allocating space for the individual items which fill the array.
Attached patch patch2 (obsolete) — Splinter Review
Attachment #265409 - Attachment is obsolete: true
Attachment #265763 - Flags: superreview?(neil)
Attachment #265763 - Flags: superreview?(neil) → superreview+
Attached patch patch3Splinter Review
for checking in
Attachment #265763 - Attachment is obsolete: true
checked in
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: