Open
Bug 1058446
Opened 11 years ago
Updated 3 years ago
ContentEventHandler should append a line break at the end of <p> element
Categories
(Core :: DOM: UI Events & Focus Handling, defect)
Core
DOM: UI Events & Focus Handling
Tracking
()
NEW
People
(Reporter: masayuki, Unassigned)
References
(Depends on 1 open bug, Blocks 2 open bugs)
Details
(Keywords: inputmethod)
Currently, ContentEventHandler appends line breaks at <br> found.
However, in our HTML editor, "foo" + Enter + "bar" causes following HTML content:
<p>foo</p>
<p>bar<br></p>
Current ContentEventHandler generates flat text from this as "foobar\n". This is too bad because setting focus before "bar" and after "foo" is equivalent. Actually, selection set event can move caret only after "foo".
| Reporter | ||
Comment 1•11 years ago
|
||
Um, it might be better to check primary frame's display. when it's not inline, inserting a line break at start of the content and end of the content allows to specify any point from flat text offset. The demerit of this approach is that the generated text becomes longer in rich text editors.
For example,
<p>A<img>B</p>
<div>C<p>D</p>E</div>
is currently represented as "ABCDE".
If we insert line breaks at start of each element, then, it becomes: "\nA\nB\nC\nDE".
If we insert line breaks at end of each element, then, it becomes: "A\nB\nCD\nE\n".
If we insert line breaks at both start and end, then, it becomes: "\nA\nB\n\nC\nD\nE\n".
However, looks like that "</p><div>" shouldn't cause inserting \n twice because in our HTML editor, users cannot move caret between them. It may cause bug if IME sets selection between them.
So, I think that if previous sibling of a block is block, it shouldn't cause "\n\n".
Inserting start of non-inline box is easy. However, inserting line break to end of boxes is difficult. I have no idea how to do it with content iterator.
Comment 2•10 years ago
|
||
It seems fixing this could potentially also fix bug 1145224.
> it might be better to check primary frame's display.
Probably easier to just check frame->IsFrameOfType(nsIFrame::eLineParticipant)
> Inserting start of non-inline box is easy. However, inserting line break to
> end of boxes is difficult. I have no idea how to do it with content iterator.
I'm not sure why inserting at the start is easier. We have two kinds of content iterator: preorder and postorder, which can be created via NS_NewPreContentIterator and NS_NewContentIterator respectively. But we don't have a content iterator which visits a parent node at both the start and the end. We could create that, though.
I'm more concerned about other problem like the mapping between the generated content and DOM range.
Blocks: 1145224
| Reporter | ||
Comment 3•10 years ago
|
||
(In reply to Xidorn Quan [:xidorn] (UTC+12) from comment #2)
> > it might be better to check primary frame's display.
>
> Probably easier to just check
> frame->IsFrameOfType(nsIFrame::eLineParticipant)
Oh, thanks. I'll check it.
> > Inserting start of non-inline box is easy. However, inserting line break to
> > end of boxes is difficult. I have no idea how to do it with content iterator.
>
> I'm not sure why inserting at the start is easier. We have two kinds of
> content iterator: preorder and postorder, which can be created via
> NS_NewPreContentIterator and NS_NewContentIterator respectively.
Because ContentEventHandler needs to compute offset from start of the selection root.
> But we don't have a content iterator which visits a parent node at both the start
> and the end. We could create that, though.
Yeah.
> I'm more concerned about other problem like the mapping between the
> generated content and DOM range.
It's out of scope of this bug. Generated contents are not handled normally in Gecko (like selection, find, etc).
| Reporter | ||
Comment 4•10 years ago
|
||
I'm working on bug 1213589 which is caused by not inserting line breaks at open/close tag of block level elements. So, the patches will fix this bug completely.
Depends on: 1213589
| Reporter | ||
Comment 5•10 years ago
|
||
I landed the patches for bug 1213589. Therefore, open tag and empty elements cause line breaks in 45. I'll work on inserting line breaks at close tags later.
| Assignee | ||
Updated•6 years ago
|
Component: Event Handling → User events and focus handling
| Reporter | ||
Comment 6•5 years ago
|
||
Resetting assignee which I don't work on in this several months.
Assignee: masayuki → nobody
Status: ASSIGNED → NEW
Updated•3 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•