Closed Bug 379585 Opened 17 years ago Closed 17 years ago

implement IAccessibleTable

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, 3 obsolete files)

 
Attached patch patch (obsolete) — Splinter Review
Attachment #263578 - Flags: review?(aaronleventhal)
Would it be easy later if we wanted to be able to implement nsIAccessibleTable for an nsAccessible where a web author used ARIA markup to define a table or spreadsheet?

(In reply to comment #2)
> Would it be easy later if we wanted to be able to implement nsIAccessibleTable
> for an nsAccessible where a web author used ARIA markup to define a table or
> spreadsheet?
> 

It shoudn't be a problem while we keep IAccessibleTable implementation separetely. I guess nsAccessibleWrap should be inherited from CAccessibleTable.
Okay, we can deal with that later then. I'm not sure if I even want to tackle that in Firefox 3. As long as it's fairly easy to change later.
+ #define GET_NSIACCESSIBLETABLE
I've read that in C++ it's preferred to use static inline instead of #define. It's more readable. You can define a static already_AddRefs() inline method and it won't take up any more size, but it's easier to understand -- right now it's not clear that a variable called tableAcc comes out of it, without going back and checking the definitom.

Out params should be initialized at the top of each method, before any early returns. For example, set *aAccessible = nsnull so that even on an error return the pointer will be set to something reasonable.

I see return rv a few times, even though we're expecting COM error returns. I suppose nsresults actually use the same values as HRESULTS, so it's probably okay. Did you intend that?
Attached patch patch2 (obsolete) — Splinter Review
Attachment #263578 - Attachment is obsolete: true
Attachment #263715 - Flags: review?(aaronleventhal)
Attachment #263578 - Flags: review?(aaronleventhal)
(In reply to comment #5)
> + #define GET_NSIACCESSIBLETABLE
> I've read that in C++ it's preferred to use static inline instead of #define.
> It's more readable. You can define a static already_AddRefs() inline method and
> it won't take up any more size, but it's easier to understand -- right now it's
> not clear that a variable called tableAcc comes out of it, without going back
> and checking the definitom.

I'm agree. But it would be something like:

inline already_AddRefs<nsIAccessibleTable> getBlaBla(const CAccessibleTable& aObj)
{
  nsIAccessibleTable* table;
  NS_ASSERTION(table, "Oops");
  NS_IF_ADDREF(table, do_QueryInterface(aObj));
}

nsCOMPtr<nsIAccessibleTable> table(getBlaBla(this));
if (!table)
  return E_FAIL;

It doesn't save code. Though probably I missed something.

> Out params should be initialized at the top of each method, before any early
> returns. For example, set *aAccessible = nsnull so that even on an error return
> the pointer will be set to something reasonable.

Fixed.

> I see return rv a few times, even though we're expecting COM error returns. I
> suppose nsresults actually use the same values as HRESULTS, so it's probably
> okay. Did you intend that?
> 

It's error because nsresult values can't be converted to HRESULT automatically of course. Thank you for the catch.
Actually if you use inline and not static inline then you don't have to pass |this|. It's not so much about saving code, but about readability. It's the same amount of compiled code either way, with an inline vs. a #define.
(In reply to comment #8)
> Actually if you use inline and not static inline then you don't have to pass
> |this|. It's not so much about saving code, but about readability. It's the
> same amount of compiled code either way, with an inline vs. a #define.
> 

Actually, it looks we'll save NS_ASSERTION only with inline method :). Do we need inline function then? Possibly I can use neither macros nor inline method.
> Actually, it looks we'll save NS_ASSERTION only with inline method :)
What do you mean?
(In reply to comment #10)
> > Actually, it looks we'll save NS_ASSERTION only with inline method :)
> What do you mean?
> 

Code with macros:
MACROS__

Code with inline method:
nsCOMPtr<nsIAccessibleTable> table(getBlaBla());
if (!table)
  return E_FAIL;

Code without inline method:
nsCOMPtr<nsIAccessibleTable> table(do_QueryInterface(this));
NS_ASSERTION(table, "blabla");
if (!table)
  return E_FAIL;

The difference is NS_ASSERTION
You can't have an assertion in an inline method?
(In reply to comment #12)
> You can't have an assertion in an inline method?
> 

I think I can. I wonder is it a worth to do because we do not save much code size by assertion moving into inline method?
The assertion only affects code size in debug builds, so it's fine.
(In reply to comment #14)
> The assertion only affects code size in debug builds, so it's fine.
> 

Sorry, I didn't have in view that. I mean inline method doesn't win in code lines.
Right, it's not fewer lines of code, but easier to understand and the same amount of compiled machine code.
Attached patch patch3 (obsolete) — Splinter Review
Attachment #263715 - Attachment is obsolete: true
Attachment #263730 - Flags: review?(aaronleventhal)
Attachment #263715 - Flags: review?(aaronleventhal)
Attachment #263730 - Flags: review?(aaronleventhal) → review+
Attached patch patch 4Splinter Review
for checkin
Attachment #263730 - 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: