Closed Bug 1419745 Opened 7 years ago Closed 7 years ago

Editor(Raw)DOMPoint should store child node at offset by itself

Categories

(Core :: DOM: Editor, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla59
Tracking Status
firefox-esr52 --- unaffected
firefox57 --- unaffected
firefox58 --- wontfix
firefox59 --- fixed

People

(Reporter: masayuki, Assigned: masayuki)

References

Details

(Keywords: regression)

Attachments

(3 files)

I realized this big bug.

Editor(Raw)DOMPoint does not store anything by itself. Its base class, (Raw)RangeBoundary stores container, *previous sibling of* child at offset and offset.

If users of Editor(Raw)DOMPoint want to keep referring child node but the child node is moved different point unexpectedly (e.g., by mutation observer), Editor(Raw)DOMPoint keeps referring the *old* previous sibling.  Therefore, GetChildAtOffset() will return different child node with current DOM tree.

So, Editor(Raw)DOMPoint should cache the child node by itself.

So, this bug is, we've changed HTML editor behavior in a lot of places if web apps changes position of new DOM nodes which are created by editor.
Hmm, I was thinking that Editor(Raw)DOMPoint should override some methods of RangeBoundaryBase to cache actual child node at offset.  However, that causes making EditorDOMPointBase complicated and riskier to change RangeBoundaryBase. So, probably, we should stop EditorDOMPointBase inherits RangeBoundaryBase since it's not useful base class for editor.
No longer depends on: 1420359
Priority: -- → P3
The patch is too risky to uplift and fortunately, we have no regression reports depending on this bug. So, we should give up to fix this on 58. (FYI: The fixes causing this regression fixed some regressions which are new in 58. So, we shouldn't back them out.)
Comment on attachment 8932450 [details]
Bug 1419745 - part 1: Make EditorDOMPointBase not a sub class of RangeBoundaryBase and duplicate methods of RangeBoundaryBase into EditorDOMPointBase

https://reviewboard.mozilla.org/r/203496/#review209274
Attachment #8932450 - Flags: review?(m_kato) → review+
Comment on attachment 8932451 [details]
Bug 1419745 - part 2: Make EditorDOMPointBase store child node at offset instead of previous sibling of child node at offset

https://reviewboard.mozilla.org/r/203498/#review209288
Attachment #8932451 - Flags: review?(m_kato) → review+
Comment on attachment 8932452 [details]
Bug 1419745 - part 3: CreateElementTransaction and SplitNodeTransaction should store DOM point with EditorDOMPoint rather than RangeBoundary

https://reviewboard.mozilla.org/r/203500/#review209290
Attachment #8932452 - Flags: review?(m_kato) → review+
Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/31082fdbf643
part 1: Make EditorDOMPointBase not a sub class of RangeBoundaryBase and duplicate methods of RangeBoundaryBase into EditorDOMPointBase r=m_kato
https://hg.mozilla.org/integration/autoland/rev/dc40e5160744
part 2: Make EditorDOMPointBase store child node at offset instead of previous sibling of child node at offset r=m_kato
https://hg.mozilla.org/integration/autoland/rev/9319d599c3b0
part 3: CreateElementTransaction and SplitNodeTransaction should store DOM point with EditorDOMPoint rather than RangeBoundary r=m_kato
Now, EditorDOMPointBase<A, B> has stopped inheriting RangeBoundaryBase<A, B>. So, we can back some patches out from RangeBoundary.h, that were added for EditorDOMPoint.

catalinb, do you think I should back them out from RangeBoundary.h to keep the implementation as far as simple? If so, I'll file a follow up bug and post a patch.
Flags: needinfo?(catalin.badea392)
(In reply to Masayuki Nakano [:masayuki] (JST, +0900) from comment #21)
> Now, EditorDOMPointBase<A, B> has stopped inheriting RangeBoundaryBase<A,
> B>. So, we can back some patches out from RangeBoundary.h, that were added
> for EditorDOMPoint.
> 
> catalinb, do you think I should back them out from RangeBoundary.h to keep
> the implementation as far as simple? If so, I'll file a follow up bug and
> post a patch.

Yes, please. No reason to keep them around if they aren't used anymore.
Flags: needinfo?(catalin.badea392)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: