Closed Bug 1742933 Opened 2 years ago Closed 2 years ago

Add callback to `HTMLEditor::CreateAndInsertElementWithTransaction` to initialize new element before inserting the new element into the tree

Categories

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

enhancement

Tracking

()

RESOLVED FIXED
100 Branch
Tracking Status
firefox100 --- fixed

People

(Reporter: masayuki, Assigned: masayuki)

References

(Blocks 1 open bug)

Details

Attachments

(12 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
48 bytes, text/x-phabricator-request
Details | Review

Callers of HTMLEditor::CreateAndInsertElementWithTransaction appends attributes and/or its children after each call. It causes redundant mutation events/notifications and wastes memory space with redundant transaction instances.

Before doing this, we need to drop CreateElementTransaction.

For making initializing new element safer and faster, it's better to initialize
new element's attributes and appending children before inserting the new element
into the DOM tree.

Assignee: nobody → masayuki
Status: NEW → ASSIGNED

At initializing new element which has not been connected, undo transactions
are not necessary because just removing the new element gets same result for
users. Therefore, they should be able to work without transactions.

Depends on D140467

For avoiding simple back-out of the patches when we get serious regression
reports, we should have a pref to disable the new pref.

Depends on D140474

For making the callers simpler, they should be able to be omitted if they
want to do nothing.

Depends on D140475

Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/28759b90db6e
part 1: Make `HTMLEditor::CreateAndInsertElementWithTransaction()` take a callback function r=m_kato
Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/6525cb40a8e0
part 2: Make `HTMLEditor::CopyLastEditableChildStylesWithTransaction` clone attributes to new elements before inserting them into the DOM tree r=m_kato
Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/7b37517e2b86
part 3: Make `HTMLEditor::AlignBlockContentsWithDivElement` set `align` attribute or equivalent before inserting a new `<div>` into the DOM tree r=m_kato
Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/b92fd32ccea3
part 4: Make `HTMLEditor::CreateAndInsertElementWithTransaction()` and `HTMLEditor::InsertBRElementWithTransaction()` work without transactions r=m_kato
Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/5915bbe06732
part 5: Make `HTMLEditor::HandleInsertParagraphInHeadingElement()` insert `<br>` element into the new paragraph before connecting to the DOM tree r=m_kato
https://hg.mozilla.org/integration/autoland/rev/d7c979cbcbcc
part 6: Make `HTMLEditor::HandleInsertParagraphInListItemElement()` insert `<br>` element into the new paragraph before connecting to the DOM tree r=m_kato
Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/ffb5b57840a1
part 7: Make `HTMLEditor::ChangeSelectedHardLinesToList()` insert list item into the new list element before connected to the DOM tree r=m_kato
Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/330f4429ae10
part 8: Make `HTMLEditor::PasteAsQuotationAsAction()` set "type" attribute of new blockquote element before connecting it to the DOM tree r=m_kato
https://hg.mozilla.org/integration/autoland/rev/fd4655669d31
part 9: Make `HTMLEditor::InsertAsPlaintextQuotation()` set attributes of `<span>` before connecting to the DOM tree r=m_kato
Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/389698b4a258
part 10: Make `HTMLEditor::InsertAsCitedQuotationInternal()` set attributes of `<blockquote>` before connecting it to the DOM tree r=m_kato
https://hg.mozilla.org/integration/autoland/rev/279f83f54bf9
part 11: Create a pref to get back the traditional behavior r=m_kato
https://hg.mozilla.org/integration/autoland/rev/6e0716832ef0
part 12: Make all `aInitializer` arguments optional r=m_kato
Regressions: 1759885
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: