Closed Bug 893166 Opened 12 years ago Closed 12 years ago

getTextBeforeOffset line end fails on wrapped lines

Categories

(Core :: Disability Access APIs, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla25

People

(Reporter: surkov, Assigned: surkov)

References

(Blocks 1 open bug)

Details

(Keywords: access)

Attachments

(2 files)

Attached patch patchSplinter Review
not super nice, obviously doesn't address all related problems, I bet there's similar thing for getTextAfterOffset, we just don't have a proper test. I want to simplify atCaretOffset text testing to add more tests and I need to fix this todo for this. Later I think we will come up with some nicer code.
Attachment #774867 - Flags: review?(trev.saunders)
Comment on attachment 774867 [details] [diff] [review] patch it seems like layout should be able to tell you what you need here with much less work, but this is probably fine for now. > *aEndOffset = FindLineBoundary(offset, ePrevLineEnd); >- *aStartOffset = FindLineBoundary(*aEndOffset, ePrevLineEnd); >+ int32_t tmpOffset = // adjust offset if line is wrapped >+ (*aEndOffset == 0 || IsTerminalCharAt(*aEndOffset)) ? >+ *aEndOffset : *aEndOffset - 1; this pretty funny especially the comment not on its own line. maybe int tmp = *aEndOffset = = FindLineBoundary(); // hnalde soft line break blah blah if (blah blah) tmp -= 1; >+ bool IsTerminalCharAt(int32_t aOffset) IsLineEndChar() would be more clear to me, terminal could mean all sorts of things \n \r \f \0 and probably other things
Attachment #774867 - Flags: review?(trev.saunders) → review+
(In reply to Trevor Saunders (:tbsaunde) from comment #1) > Comment on attachment 774867 [details] [diff] [review] > patch > > it seems like layout should be able to tell you what you need here with much > less work, but this is probably fine for now. same thinking but layout itself relies on \n character (for example http://mxr.mozilla.org/mozilla-central/source/layout/generic/nsTextFrameThebes.cpp#1490) > > *aEndOffset = FindLineBoundary(offset, ePrevLineEnd); > >- *aStartOffset = FindLineBoundary(*aEndOffset, ePrevLineEnd); > >+ int32_t tmpOffset = // adjust offset if line is wrapped > >+ (*aEndOffset == 0 || IsTerminalCharAt(*aEndOffset)) ? > >+ *aEndOffset : *aEndOffset - 1; > > this pretty funny especially the comment not on its own line. maybe > > int tmp = *aEndOffset = = FindLineBoundary(); > // hnalde soft line break blah blah > if (blah blah) > tmp -= 1; > > >+ bool IsTerminalCharAt(int32_t aOffset) > > IsLineEndChar() would be more clear to me, terminal could mean all sorts of > things \n \r \f \0 and probably other things ok
Attached patch patchSplinter Review
it seems we are ok with GetTextAfterOffset lineEnd
Attachment #777918 - Flags: review?
Attachment #777918 - Flags: review? → review?(trev.saunders)
Attachment #777918 - Flags: review?(trev.saunders) → review+
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla25
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: