Closed Bug 1543966 Opened 3 years ago Closed 3 years ago

Make all edit command classes singleton

Categories

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

task

Tracking

()

RESOLVED FIXED
mozilla68
Tracking Status
firefox68 --- fixed

People

(Reporter: masayuki, Assigned: masayuki)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

Most edit command classes are created per editor instance. This means that we have not reasonable runtime cost to allocate them when there are too many editors. Fortunately, most classes are stateless, and the statefull classes can be changed to stateless. Therefore, we can make them singleton.

If we make them singleton, we might be able to access them from nsHTMLDocument::ExecCommand() directly.

Type: defect → task
Priority: -- → P3

Different from the comment in EditorCommands.h, editing commands and
editor commands are instantiated for each editable document or each
HTMLInputElement or HTMLTextareaElement. Therefore, even though they
are stateless, we allocate too many instances of them. We should make
them singleton classes to reduce the footprint and save runtime allocation
cost.

Some "HTML editor commands" are stateful due to storing tag name to handle it
with specific command. However, we can make it stateless with retrieving
tag name from command name once per command only when it's necessary. The
runtime cost must be really cheap since we can map it with hash table.

This patch makes them stateless and singleton classes. So, we can save
footprint and allocation runtime cost with this change.

Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/47b6254afb9a
part 1: Make "editing commands" and "editor commands" singleton classes r=m_kato
https://hg.mozilla.org/integration/autoland/rev/b742fcff4f2b
part 2: Make "HTML editor commands" and "document state commands" singleton classes r=m_kato
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla68
You need to log in before you can comment on or make changes to this bug.