Closed Bug 352340 Opened 18 years ago Closed 18 years ago

GetTextAtOffset doesn't work correctly for word boundaries

Categories

(Core :: Disability Access APIs, defect)

1.8 Branch
x86
All
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: aaronlev, Assigned: gaomingcn)

References

()

Details

(Keywords: access)

Attachments

(1 file, 3 obsolete files)

1. Reference the above URL for the testcase.
2. Use word start or word end
3. Notice how the same word is returned each time

A new word should be returned each time.
Assignee: nobody → gaomingcn
Assignee: gaomingcn → nian.liu
I think this is caused by the testcase.
Attached patch Patch for jstest.js (obsolete) — Splinter Review
I think this is not a bug. This patch for the test case works on my linux box.
Assignee: nian.liu → gaomingcn
The test case should show all the text. By feeding in the end offset each time back into getText, you should get the next chunk. That works when we do with BOUNDARY_LINE_START and BOUNDARY_LINE_END.

For example, if we take the following text:
abc def

We ask getTextAtOffset() using BOUNDARY_WORD_START at offset 0. We should get:
[0,4,"abc "]

Now ask getTextAtOffset() using BOUNDARY_WORD_START at offset 4. We should get
[4,7,"def"]

No?
Accoding to 
http://developer.gnome.org/doc/API/2.0/atk/AtkText.html#atk-text-get-text-at-offset,
"If the boundary_type is ATK_TEXT_BOUNDARY_WORD_START the returned string is from the word start at or before the offset to the word start after the offset.

The returned string will contain the word at the offset if the offset is inside a word and will contain the word before the offset if the offset is not inside a word. "

In your example, should we get [0,4,"abc "] at offset 4?
(In reply to comment #4)
> In your example, should we get [0,4,"abc "] at offset 4?
No, do it like in comment 3.

Offset 4 is inside the word "def". Basically, any offset that contains a character from a word is inside the word. But thanks for making sure we clarify that, it could be confusing.

Attached patch The patch. (obsolete) — Splinter Review
Attachment #240110 - Attachment is obsolete: true
Attachment #240356 - Flags: review?(aaronleventhal)
(In reply to comment #6)
> Created an attachment (id=240356) [edit]
> The patch.
> 

I have tested it on linux.
Comment on attachment 240356 [details] [diff] [review]
The patch.

I think we need to check if amount == eSelectWord.

Ginn, what do you think?

Also, should we also be doing anything when aType == eGetBefore?

You can probably put this new |if| block 2 lines up before |*aStartOffset = startOffset|, and just compare to endOffset instead of *aEndOffset.

Mike, with the next patch  please request r= from Ginn.
Attachment #240356 - Flags: review?(aaronleventhal) → review-
Also, please add a comment in the |if| block to say why it's necessary.
gaoming,

Please also fix the 2 NS_ASSERTIONs after.
I don't think they're correct.

BTW: We still have a bug, if I click the end of "abc" or "123" in the test case. 
Do you have the same problem?
Do we have a bug filed?
(In reply to comment #10)
> BTW: We still have a bug, if I click the end of "abc" or "123" in the test
> case. 
> Do you have the same problem?
> Do we have a bug filed?
> 

I just clicked outside the word.
(In reply to comment #8)
> (From update of attachment 240356 [details] [diff] [review] [edit])
> I think we need to check if amount == eSelectWord.
> 

Yes. This would be safer.

> Ginn, what do you think?
> 
> Also, should we also be doing anything when aType == eGetBefore?
> 
we use "if (aType == eGetAt && amount == eSelectWord && aOffset == endOffset)" as the condition, so we need not do anything for eGetBefore, right?

> You can probably put this new |if| block 2 lines up before |*aStartOffset =
> startOffset|, and just compare to endOffset instead of *aEndOffset.
> 
> Mike, with the next patch  please request r= from Ginn.
> 
(In reply to comment #11)
> (In reply to comment #10)
> > BTW: We still have a bug, if I click the end of "abc" or "123" in the test
> > case. 
> > Do you have the same problem?
> > Do we have a bug filed?
> > 
> 
> I just clicked outside the word.
> 

If you mean the Text: "[0,1] abc [1,6] 123 [6,10]", I get this when I click inside the text. Will you get any output if you click outside?

The odd Text: field hanppends for tag <span>. <br> is considered as one character and I don't know what [0,1] is.
Attached patch patch draft v2 (obsolete) — Splinter Review
Attachment #240356 - Attachment is obsolete: true
Attached patch patch draft v3Splinter Review
Attachment #240459 - Attachment is obsolete: true
Attachment #240499 - Flags: review?(ginn.chen)
(In reply to comment #13)

> If you mean the Text: "[0,1] abc [1,6] 123 [6,10]", I get this when I click
> inside the text. Will you get any output if you click outside?

Not in browser window.
In Error console or terminal.

************************************************************
* Call to xpconnect wrapped JSObject produced this error:  *
[Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIAccessibleText.getOffsetAtPoint]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://www.mozilla.org/access/qa/jstest.js :: updateDisplay :: line 177"  data: no]
************************************************************

Never mind, it's not related to this bug.
Attachment #240499 - Flags: review?(ginn.chen) → review+
checked in
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Depends on: 855732
No longer depends on: 855732
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: