Closed
Bug 634201
Opened 14 years ago
Closed 8 years ago
fix getTextAt/Before/After for word boundaries to use cached text
Categories
(Core :: Disability Access APIs, defect)
Core
Disability Access APIs
Tracking
()
RESOLVED
INCOMPLETE
People
(Reporter: surkov, Unassigned)
References
(Blocks 1 open bug)
Details
(Keywords: access, Whiteboard: [auto-closed:inactivity])
spun off bug 630001 comment #19
Reporter | ||
Comment 1•14 years ago
|
||
Ehsan, can we share code logic that is used by layout to navigate by words? a11y needs to find word start/end in the cached text at the offset.
Comment 2•14 years ago
|
||
(In reply to comment #1)
> Ehsan, can we share code logic that is used by layout to navigate by words?
> a11y needs to find word start/end in the cached text at the offset.
It kind of depends on how you want to do this. The underlying API is nsIFrame::PeekOffset. For example, to get to the word end, you create a nsPeekOffsetStruct and use eSelectWord as the amount, eDirNext as the direction, eEndWord as word movement type, and false for visual, and you also specify the desired offsets, etc.
PeekOffset gives you a result content node and offset (and a frame).
If you want a higher level API, look into nsTypedSelection::Modify, although I think PeekOffset is a better option.
Reporter | ||
Comment 3•14 years ago
|
||
(In reply to comment #2)
> (In reply to comment #1)
> > Ehsan, can we share code logic that is used by layout to navigate by words?
> > a11y needs to find word start/end in the cached text at the offset.
>
> It kind of depends on how you want to do this. The underlying API is
> nsIFrame::PeekOffset. For example, to get to the word end, you create a
> nsPeekOffsetStruct and use eSelectWord as the amount, eDirNext as the
> direction, eEndWord as word movement type, and false for visual, and you also
> specify the desired offsets, etc.
that's how we do currently, but we need to operate on text cached on a11y side.
Comment 4•14 years ago
|
||
(In reply to comment #3)
> (In reply to comment #2)
> > (In reply to comment #1)
> > > Ehsan, can we share code logic that is used by layout to navigate by words?
> > > a11y needs to find word start/end in the cached text at the offset.
> >
> > It kind of depends on how you want to do this. The underlying API is
> > nsIFrame::PeekOffset. For example, to get to the word end, you create a
> > nsPeekOffsetStruct and use eSelectWord as the amount, eDirNext as the
> > direction, eEndWord as word movement type, and false for visual, and you also
> > specify the desired offsets, etc.
>
> that's how we do currently, but we need to operate on text cached on a11y side.
I'm not sure what you mean. Is this information separate to the information stored in the frame tree and the content tree?
Reporter | ||
Comment 5•14 years ago
|
||
(In reply to comment #4)
> I'm not sure what you mean. Is this information separate to the information
> stored in the frame tree and the content tree?
We get a text from nsIFrame::GetRenderedText and cache it on a11y side, so let's we have an offset and that string (cached text) and we need to find word start and word end. nsIFrame::PeekOffset can't be used for that, right?
Comment 6•14 years ago
|
||
(In reply to comment #5)
> (In reply to comment #4)
>
> > I'm not sure what you mean. Is this information separate to the information
> > stored in the frame tree and the content tree?
>
> We get a text from nsIFrame::GetRenderedText and cache it on a11y side, so
> let's we have an offset and that string (cached text) and we need to find word
> start and word end. nsIFrame::PeekOffset can't be used for that, right?
No.
Reporter | ||
Comment 7•14 years ago
|
||
Ehsan, so what's the best way for us then? Obviously we want to compatible with word definition used in layout: we should report word end/start the same as user gets it by caret movement by words (ctrl+arrow key).
Comment 8•14 years ago
|
||
(In reply to comment #7)
> Ehsan, so what's the best way for us then? Obviously we want to compatible with
> word definition used in layout: we should report word end/start the same as
> user gets it by caret movement by words (ctrl+arrow key).
Well, the problem is that what we do in layout is really complicated by the fact that text can be spread over multiple frames at arbitrary points...
Look at the eSelectWord here: <http://mxr.mozilla.org/mozilla-central/source/layout/generic/nsFrame.cpp#5501>. This is where most of the top-level magic happens. This is where we handle platform specific details (such as, whether Ctrl+right should eat the space or not -- the layout.word_select.eat_space_to_next_word pref) too.
The high-level algorithm is relatively simple. We iterate over the frames, and call PeekOffsetWord on them. nsTextFrame::PeekOffsetWord is a lot more complex though, especially the cluster iteration parts, which depends on the textrun code. You *really* don't want to duplicate all that code.
And to make things more complicated, selecting words based on frames automatically takes care of hidden parts of a text for example (think of a display:none span in the middle of the text), and gets the word selection process closer to what the user would expect judging by what they see on the screen.
I don't know how you "cache" text in a11y, but can't you just query the frame tree when you need to jump on word boundaries?
Reporter | ||
Comment 9•14 years ago
|
||
(In reply to comment #8)
> I don't know how you "cache" text in a11y, but can't you just query the frame
> tree when you need to jump on word boundaries?
cache is result of nsIFrame::GetRenderedText. AT can call us when layout is in middle of update, it leads to wrong returned info and crashes.
Reporter | ||
Comment 10•14 years ago
|
||
(In reply to comment #8)
> nsTextFrame::PeekOffsetWord is a lot more complex
> though, especially the cluster iteration parts, which depends on the textrun
> code. You *really* don't want to duplicate all that code.
We'd need to have shared code, though it appears it's not trivial.
> This is where most of the top-level magic happens. This is where we handle
> platform specific details (such as, whether Ctrl+right should eat the space or
> not -- the layout.word_select.eat_space_to_next_word pref) too.
If this preference affect on word term definition then that's not what I look for.
What is nsIWordBreaker about?
Comment 11•14 years ago
|
||
What is the reason that you have to cache frame text content? Are those frames no longer around when you need to access them? Have they changed?
Comment 12•14 years ago
|
||
(In reply to comment #11)
> What is the reason that you have to cache frame text content? Are those frames
> no longer around when you need to access them? Have they changed?
We decided at the last work week, in a meeting with roc, that we'd need to do this. See bug 626660 for background.
Comment 13•14 years ago
|
||
(In reply to comment #12)
> (In reply to comment #11)
> > What is the reason that you have to cache frame text content? Are those frames
> > no longer around when you need to access them? Have they changed?
>
> We decided at the last work week, in a meeting with roc, that we'd need to do
> this. See bug 626660 for background.
Maybe we could have a chat tomorrow about this?
Reporter | ||
Comment 14•14 years ago
|
||
(In reply to comment #13)
> Maybe we could have a chat tomorrow about this?
fine with me, I try to not fall asleep :)
Comment 15•8 years ago
|
||
AUTO-CLOSED. This bug untouched for over 2000 days. Please reopen if you can confirm the bug and help it progress.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → INCOMPLETE
Whiteboard: [auto-closed:inactivity]
You need to log in
before you can comment on or make changes to this bug.
Description
•