Closed Bug 303399 Opened 20 years ago Closed 20 years ago

Bidi: Problems with caret positioning on blank lines

Categories

(Core :: Layout: Text and Fonts, defect)

defect
Not set
normal

Tracking

()

VERIFIED FIXED
mozilla1.8beta4

People

(Reporter: uriber, Assigned: uriber)

References

()

Details

(Keywords: fixed1.8)

Attachments

(1 file, 4 obsolete files)

When the caret is logically placed in a blank line in a textarea, it is sometimes displayed as if it were at the end of the previous line. This was originally reported in bug 207186 comment 6, and bug 207186 comment 7 (and 8). Testcase #3 from bug 207186: https://bugzilla.mozilla.org/attachment.cgi?id=128682 In the RTL textarea, place the caret at the end of the text, and press Enter. The caret remains in its place. Typing some letters verifies that the caret is, logically, on a new line. In the LTR textarea, move to the end of the text, then type some RTL (Hebrew) letters, and then hit "Enter". Again, the caret won't visually move, although it is logically in the new line. Testcase #4 from bug 207186: https://bugzilla.mozilla.org/attachment.cgi?id=128683 In the RTL textarea, place the caret at the ond of the text, and press "Enter". The caret correctly appears on the next line. Now switch the keyboard to an LTR (English) layout. The caret will be displayed at the end of the first line (although it's still logically on the second line). The LTR textarea displays similar behaviour (when you switch the keyboard to RTL).
Attached patch tentative patch (obsolete) — Splinter Review
The problem, as I understand it, is that nsCaret::SetupDrawingFrameAndOffset() is using the wrong frameSelection. It is always using the document frame selection (obtained via nsPresShell), but but a textarea has its own frame selection (controlled by nsTextInputSelectionImpl) - and that's the selection that should be used. What is happening is that when the document frame selection has a different hint than the textarea frame selection, frameSelection->GetPrevNextBidiLevels() uses the wrong (doc selection) hint, and therefore gets a different frame as the current frame, and that confuses the bidi caret positioning algorithm. So what I wanted to do was to use the actual frame selection associated with the caret, rather than the document one. However, I couldn't find a way to get to it through the DOM selection (held as mDomSelectionWeak), so I needed to add a COM getter method - which I added to nsISelectionPrivate. Things I'd like to get review on: - Is my analysis of the problem and my proposed solution (using the "other" frame selection) correct? - Do I really have to add a method to a XPCOM reference in order to do that? - Does my choice of adding the method to nsISelectionPrivate (as opposed to, say, nsISelection) make sense? - Did I technically did this correctly? (Is the method named correctly, did I really need to replace the UUID, etc.) Blake - these are basically the questions I asked you in my latest e-mail (before I had a patch), so you can just reply here instead of replying to the e-mail, if you want to.
Attachment #191878 - Flags: review?(mrbkap)
Attached patch tentative patch (obsolete) — Splinter Review
Bah. That one contained some unrelated stuff. This one should be OK.
Attachment #191878 - Attachment is obsolete: true
Attachment #191878 - Flags: review?(mrbkap)
Attachment #191879 - Flags: review?(mrbkap)
Attached patch patch v 2 (obsolete) — Splinter Review
Same thing, but also use privateSelection->GetFrameSelection() instead of presShell->FrameSelection() in nsCaret::GetCaretCoordinates() (for corectness). Notice that getting the hint is now easier.
Attachment #191879 - Attachment is obsolete: true
Attachment #192022 - Flags: review?(mrbkap)
Attachment #191879 - Flags: review?(mrbkap)
Comment on attachment 192022 [details] [diff] [review] patch v 2 Sorry. Wrong patch. right one coming in a minute.
Attachment #192022 - Flags: review?(mrbkap)
Attached patch patch v 2 (obsolete) — Splinter Review
The correct patch, hopefully.
Attachment #192022 - Attachment is obsolete: true
Attachment #192023 - Flags: review?(mrbkap)
Comment on attachment 192023 [details] [diff] [review] patch v 2 Thanks for figuring all of this messy frame selection stuff out! r=me
Attachment #192023 - Flags: review?(mrbkap) → review+
Attachment #192023 - Flags: superreview?(roc)
Status: NEW → ASSIGNED
Comment on attachment 192023 [details] [diff] [review] patch v 2 Looks good, except that GetFrameSelection should AddRef its out parameter, and you should call GetFrameSelection(getter_AddRefs(frameSelection)) (after converting frameSelection to an nsCOMPtr)
Attachment #192023 - Flags: superreview?(roc) → superreview-
Attached patch Patch v 2.1Splinter Review
Right. I think I'm starting to get the hang of this XPCOM stuff (I originally tried using getter_AddRefs(), but since I neglected to do the NS_ADDREF part in the getter itself, I ended up with a null pointer later. Duh!). Not sure if I have to get r+ again, so asking just to be on the safe side.
Attachment #192023 - Attachment is obsolete: true
Attachment #193548 - Flags: superreview?(roc)
Attachment #193548 - Flags: review?(mrbkap)
Comment on attachment 193548 [details] [diff] [review] Patch v 2.1 >Index: layout/generic/nsSelection.cpp >+ *aFrameSelection = mFrameSelection; >+ NS_ADDREF(*aFrameSelection); This could be written as: NS_ADDREF(*aFrameSelection = mFrameSelection); But it's your stylistic choice. Sorry for not catching this before. r=mrbkap
Attachment #193548 - Flags: review?(mrbkap) → review+
Attachment #193548 - Flags: superreview?(roc) → superreview+
Patch checked in by mrbkap at 2005-08-24 10:44.
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Nominating for 1.8/fx1.5.
Flags: blocking1.8b4?
Comment on attachment 193548 [details] [diff] [review] Patch v 2.1 Asking for approval1.8b4. This bug is relatively major (it makes editing bidi text pretty annoying), and the fix isn't too complicated. It would be a shame not to have this fixed for 1.5.
Attachment #193548 - Flags: approval1.8b4?
Flags: blocking1.8b4? → blocking1.8b4+
Attachment #193548 - Flags: approval1.8b4? → approval1.8b4+
If we're going to take this, we need a lot of reports of it working well on the trunk, with bidi, extensions that do weird things with selection, Midas, etc. before we put it on the branch. (N.B. that such positive reports are not a guarantee that it'll be on the branch. We need to lock that baby down tight tight to avoid regressions that put 1.5 at risk.) Also: is this a regression vs. 1.0? If so, can someone characterize the impact on real-world sites?
(In reply to comment #13) > Also: is this a regression vs. 1.0? If so, can someone characterize the impact > on real-world sites? This is not a regression vs. 1.0. Bidi editing was practicably unusable on 1.0. (see the fifth paragraph of bug 207186, comment #6). This is part of an effort to make it usable on 1.5.
Checked into 1.8 branch. Many thanks, Uri!
Status: RESOLVED → VERIFIED
Keywords: fixed1.8
Target Milestone: --- → mozilla1.8beta4
Component: Layout: BiDi Hebrew & Arabic → Layout: Text
QA Contact: zach → layout.fonts-and-text
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: