Closed Bug 1740872 Opened 3 years ago Closed 3 years ago

Add `HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction()`

Categories

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

enhancement

Tracking

()

RESOLVED FIXED
96 Branch
Tracking Status
firefox96 --- fixed

People

(Reporter: masayuki, Assigned: masayuki)

References

Details

Attachments

(11 files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

MaybeSplitAncestorsForInsertWithTransaction() and CreateNodeWithTransaction() are used with similar code. So for saving the maintenance cost, there should be a wrapper method for the users.

Summary: Add `HTMLEditor::InsertElementAndSplitAncestorsWithTransaction()` → Add `HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction()`

I realized that it's now used only by HTMLEditor so that we can move it
into HTMLEditor and we can make CreateElementTransaction treat HTMLEditor
directly rather than via EditorBase.

There are a lot of places which calls
HTMLEditor::MaybeSplitAncestorsForInsertWithTransaction() and then calls
HTMLEditor::CreateAndInsertElementWithTransaction() with split point of the
preceding result. It's better to wrap them in a method for reducing the
maintenance cost.

HTMLEditor::CreateOrChangeBlockContainerElement() handles to calling them
safer than the others so that let's use this code for the new method. The
additional change won't change the most web apps which don't touch the DOM
tree from legacy mutation event listeners.

Depends on D131198

Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/88d1b7401340
part 1: Move `EditorBase::CreateElementWithTransaction()` into `HTMLEditor` r=m_kato
https://hg.mozilla.org/integration/autoland/rev/b97163a65d2b
part 2: Create `HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction()` to wrap to call a pair of `MaybeSplitAncestorsForInsertWithTransaction()` and `CreateAndInsertElementWithTransaction()` r=m_kato
https://hg.mozilla.org/integration/autoland/rev/d6cb4390e6f9
part 3: Make `HTMLEditor::ChangeSelectedHardLinesToList()` use `HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction()` r=m_kato
Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/c8a55bef68ac
part 4: Make `HTMLEditor::FormatBlockContainerWithTransaction()` use `HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction()` r=m_kato
Severity: -- → S3
Priority: -- → P3
Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/086ba791bea0
part 5: Make `HTMLEditor::IndentListChild()` use `HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction()` r=m_kato
Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/3088b7d11351
part 6: Make `HTMLEditor::HandleCSSIndentAtSelectionInternal()` use `HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction()` r=m_kato
Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/56092011cff6
part 7: Make `HTMLEditor::HandleHTMLIndentAtSelectionInternal()` use `HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction()` r=m_kato
Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/11958ca23821
part 8: Make `HTMLEditor::AlignNodesAndDescendants()` use `HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction()` r=m_kato
Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/253d2d0969c9
part 9: Make `HTMLEditor::MoveNodesIntoNewBlockquoteElement()` use `HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction()` r=m_kato
Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/3dc781627f47
part 10: Make `HTMLEditor::MoveSelectedContentsToDivElementToMakeItAbsolutePosition()` use `HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction()` r=m_kato
Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/f8dde932c1d6
part 11: Make `HTMLEditor::AlignContentsAtSelectionWithEmptyDivElement()` use `HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction()` r=m_kato
Regressions: 1752462
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: