Open Bug 1791695 Opened 2 years ago Updated 2 years ago

`HTMLEditor::InsertObject` should be called with valid insertion point

Categories

(Core :: DOM: Editor, task, P4)

task

Tracking

()

ASSIGNED

People

(Reporter: masayuki, Assigned: masayuki)

References

Details

It's a tricky method. It may be called with unset insertion point, then, its callees try to get Selection for insertion. However, it's too late in some cases. If there is no valid insertion point, it should quite earlier.

I realized that it's not possible from point of view of the running cost. It may be called for:

  • Drag and drop
  • Paste

In the former case, especially when you drag from an editor and drop it into same editor, insertion point is not related to the selection. Therefore, the insertion point needs to be specified explicitly. However, in the latter case, pasted content needs to be inserted to a collapsed point after deleting selection. However, the point needs to be computed with complicated code because it depends on whether the containers which become empty should be deleted or not, and most complicated case is replacing a part of table, but it depends on inserting text, and finally, the selection deletion may be changed by the legacy event listeners.

Therefore, we cannot specify insertion point in some cases. However, as I misunderstood the code design, perhaps, the point should be represented as Maybe<EditorDOMPoint>, and if it's some, the point must be set and valid. Then, it's clearer that it can be "nothing".

Priority: P2 → P4
You need to log in before you can comment on or make changes to this bug.